idx
int64
func
string
target
int64
226,172
GF_Box *stbl_box_new() { ISOM_DECL_BOX_ALLOC(GF_SampleTableBox, GF_ISOM_BOX_TYPE_STBL); //maxSamplePer chunk is 10 by default tmp->MaxSamplePerChunk = 10; tmp->groupID = 1; return (GF_Box *)tmp; }
0
314,770
cdf_dump_stream(const cdf_header_t *h, const cdf_stream_t *sst) { size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ? CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h); cdf_dump(sst->sst_tab, ss * sst->sst_len); }
0
500,684
static void sftp_ext_free(sftp_ext ext) { unsigned int i; if (ext == NULL) { return; } if (ext->count) { for (i = 0; i < ext->count; i++) { SAFE_FREE(ext->name[i]); SAFE_FREE(ext->data[i]); } SAFE_FREE(ext->name); SAFE_FREE(ext->data); } SAFE_FREE(ext); }
0
386,590
void DL_Dxf::writeDimAligned(DL_WriterA& dw, const DL_DimensionData& data, const DL_DimAlignedData& edata, const DL_Attributes& attrib) { dw.entity("DIMENSION"); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbEntity"); } dw.entityAttributes(attrib); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbDimension"); } dw.dxfReal(10, data.dpx); dw.dxfReal(20, data.dpy); dw.dxfReal(30, data.dpz); dw.dxfReal(11, data.mpx); dw.dxfReal(21, data.mpy); dw.dxfReal(31, 0.0); dw.dxfInt(70, data.type); if (version>DL_VERSION_R12) { dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(74, data.arrow1Flipped); dw.dxfInt(75, data.arrow2Flipped); dw.dxfReal(41, data.lineSpacingFactor); // opt } dw.dxfReal(42, data.angle); dw.dxfString(1, data.text); // opt //dw.dxfString(3, data.style); dw.dxfString(3, "Standard"); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbAlignedDimension"); } dw.dxfReal(13, edata.epx1); dw.dxfReal(23, edata.epy1); dw.dxfReal(33, 0.0); dw.dxfReal(14, edata.epx2); dw.dxfReal(24, edata.epy2); dw.dxfReal(34, 0.0); writeDimStyleOverrides(dw, data); }
0
437,718
static void control_rx_s_carrier_window(struct cx23885_dev *dev, unsigned int carrier, unsigned int *carrier_range_low, unsigned int *carrier_range_high) { u32 v; unsigned int c16 = carrier * 16; if (*carrier_range_low < DIV_ROUND_CLOSEST(c16, 16 + 3)) { v = CNTRL_WIN_3_4; *carrier_range_low = DIV_ROUND_CLOSEST(c16, 16 + 4); } else { v = CNTRL_WIN_3_3; *carrier_range_low = DIV_ROUND_CLOSEST(c16, 16 + 3); } if (*carrier_range_high > DIV_ROUND_CLOSEST(c16, 16 - 3)) { v |= CNTRL_WIN_4_3; *carrier_range_high = DIV_ROUND_CLOSEST(c16, 16 - 4); } else { v |= CNTRL_WIN_3_3; *carrier_range_high = DIV_ROUND_CLOSEST(c16, 16 - 3); } cx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~CNTRL_WIN, v); }
0
336,632
RedRecord *reds_get_record(RedsState *reds) { if (reds->record) { return red_record_ref(reds->record); } return NULL; }
0
220,397
mrb_ary_pop(mrb_state *mrb, mrb_value ary) { struct RArray *a = mrb_ary_ptr(ary); mrb_int len = ARY_LEN(a); ary_modify_check(mrb, a); if (len == 0) return mrb_nil_value(); ARY_SET_LEN(a, len-1); return ARY_PTR(a)[len-1]; }
0
333,047
nfa_regexec_both( char_u *line, colnr_T startcol, // column to start looking for match proftime_T *tm, // timeout limit or NULL int *timed_out) // flag set on timeout or NULL { nfa_regprog_T *prog; long retval = 0L; int i; colnr_T col = startcol; if (REG_MULTI) { prog = (nfa_regprog_T *)rex.reg_mmatch->regprog; line = reg_getline((linenr_T)0); // relative to the cursor rex.reg_startpos = rex.reg_mmatch->startpos; rex.reg_endpos = rex.reg_mmatch->endpos; } else { prog = (nfa_regprog_T *)rex.reg_match->regprog; rex.reg_startp = rex.reg_match->startp; rex.reg_endp = rex.reg_match->endp; } // Be paranoid... if (prog == NULL || line == NULL) { iemsg(_(e_null_argument)); goto theend; } // If pattern contains "\c" or "\C": overrule value of rex.reg_ic if (prog->regflags & RF_ICASE) rex.reg_ic = TRUE; else if (prog->regflags & RF_NOICASE) rex.reg_ic = FALSE; // If pattern contains "\Z" overrule value of rex.reg_icombine if (prog->regflags & RF_ICOMBINE) rex.reg_icombine = TRUE; rex.line = line; rex.lnum = 0; // relative to line rex.nfa_has_zend = prog->has_zend; rex.nfa_has_backref = prog->has_backref; rex.nfa_nsubexpr = prog->nsubexp; rex.nfa_listid = 1; rex.nfa_alt_listid = 2; #ifdef DEBUG nfa_regengine.expr = prog->pattern; #endif if (prog->reganch && col > 0) return 0L; rex.need_clear_subexpr = TRUE; #ifdef FEAT_SYN_HL // Clear the external match subpointers if necessary. if (prog->reghasz == REX_SET) { rex.nfa_has_zsubexpr = TRUE; rex.need_clear_zsubexpr = TRUE; } else { rex.nfa_has_zsubexpr = FALSE; rex.need_clear_zsubexpr = FALSE; } #endif if (prog->regstart != NUL) { // Skip ahead until a character we know the match must start with. // When there is none there is no match. if (skip_to_start(prog->regstart, &col) == FAIL) return 0L; // If match_text is set it contains the full text that must match. // Nothing else to try. Doesn't handle combining chars well. if (prog->match_text != NULL && !rex.reg_icombine) return find_match_text(col, prog->regstart, prog->match_text); } // If the start column is past the maximum column: no need to try. if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) goto theend; // Set the "nstate" used by nfa_regcomp() to zero to trigger an error when // it's accidentally used during execution. nstate = 0; for (i = 0; i < prog->nstate; ++i) { prog->state[i].id = i; prog->state[i].lastlist[0] = 0; prog->state[i].lastlist[1] = 0; } retval = nfa_regtry(prog, col, tm, timed_out); #ifdef DEBUG nfa_regengine.expr = NULL; #endif theend: if (retval > 0) { // Make sure the end is never before the start. Can happen when \zs and // \ze are used. if (REG_MULTI) { lpos_T *start = &rex.reg_mmatch->startpos[0]; lpos_T *end = &rex.reg_mmatch->endpos[0]; if (end->lnum < start->lnum || (end->lnum == start->lnum && end->col < start->col)) rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; } else { if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) rex.reg_match->endp[0] = rex.reg_match->startp[0]; } } return retval; }
0
512,237
void Item_equal::sort(Item_field_cmpfunc compare, void *arg) { bubble_sort<Item>(&equal_items, compare, arg); }
0
225,611
GF_Err stsh_box_read(GF_Box *s, GF_BitStream *bs) { GF_Err e; u32 count, i; GF_ShadowSyncBox *ptr = (GF_ShadowSyncBox *)s; ISOM_DECREASE_SIZE(s, 4) count = gf_bs_read_u32(bs); if (ptr->size / 8 < count) return GF_ISOM_INVALID_FILE; for (i = 0; i < count; i++) { GF_StshEntry *ent = (GF_StshEntry *) gf_malloc(sizeof(GF_StshEntry)); if (!ent) return GF_OUT_OF_MEM; ent->shadowedSampleNumber = gf_bs_read_u32(bs); ent->syncSampleNumber = gf_bs_read_u32(bs); e = gf_list_add(ptr->entries, ent); if (e) return e; } return GF_OK; }
0
224,575
Status ReduceScatterShape(shape_inference::InferenceContext* c) { shape_inference::ShapeHandle in = c->input(0); if (!c->RankKnown(in)) { // Input shape unknown, so set unknown output shape. c->set_output(0, in); return Status::OK(); } shape_inference::ShapeHandle group_assignment_shape = c->input(1); if (c->Rank(group_assignment_shape) != 2) return errors::InvalidArgument( "ReduceScatter group_assignment should be rank 2"); const Tensor* scatter_dimension = c->input_tensor(2); if (!scatter_dimension) { c->set_output(0, c->UnknownShape()); return Status::OK(); } int64_t scatter_dim; TF_RETURN_IF_ERROR(c->GetScalarFromTensor(scatter_dimension, &scatter_dim)); std::vector<shape_inference::DimensionHandle> out_dims; out_dims.reserve(c->Rank(in)); for (int i = 0; i < c->Rank(in); ++i) { // If the dimension is the scatter_dimension, then divide the dimension // by the partition size in the group_assignment. if (i == scatter_dim) { shape_inference::DimensionHandle dim = c->Dim(in, i); shape_inference::DimensionHandle out_dim; TF_RETURN_IF_ERROR(c->Divide(dim, c->Dim(group_assignment_shape, 1), /*evenly_divisible=*/true, &out_dim)); out_dims.push_back(out_dim); } else { out_dims.emplace_back(c->Dim(in, i)); } } c->set_output(0, c->MakeShape(out_dims)); return Status::OK(); }
0
292,213
find_session_from_type (int type, server *serv) { session *sess; GSList *list = sess_list; while (list) { sess = list->data; if (sess->type == type && serv == sess->server) return sess; list = list->next; } return NULL; }
0
250,684
HttpFile::HttpFile(std::shared_ptr<HttpFileImpl> &&implPtr) : implPtr_(std::move(implPtr)) { }
0
413,659
static int fcn_print_verbose(RCore *core, RAnalFunction *fcn, bool use_color) { char *name = r_core_anal_fcn_name (core, fcn); int ebbs = 0; int addrwidth = 8; const char *color = ""; const char *color_end = ""; if (use_color) { color_end = Color_RESET; if (strstr (name, "sym.imp.")) { color = Color_YELLOW; } else if (strstr (name, "sym.")) { color = Color_GREEN; } else if (strstr (name, "sub.")) { color = Color_MAGENTA; } } if (core->anal->bits == 64) { addrwidth = 16; } r_cons_printf (FCN_LIST_VERBOSE_ENTRY, color, addrwidth, fcn->addr, r_anal_function_realsize (fcn), r_list_length (fcn->bbs), r_anal_function_count_edges (fcn, &ebbs), r_anal_function_complexity (fcn), r_anal_function_cost (fcn), addrwidth, r_anal_function_min_addr (fcn), r_anal_function_linear_size (fcn), addrwidth, r_anal_function_max_addr (fcn), fcn->meta.numcallrefs, r_anal_var_count_locals (fcn), r_anal_var_count_args (fcn), fcn->meta.numrefs, fcn->maxstack, name, color_end); free (name); return 0; }
0
450,352
static void write_png_palette(int idx, uint32_t pix, void *opaque) { struct palette_cb_priv *priv = opaque; VncState *vs = priv->vs; png_colorp color = &priv->png_palette[idx]; if (vs->tight->pixel24) { color->red = (pix >> vs->client_pf.rshift) & vs->client_pf.rmax; color->green = (pix >> vs->client_pf.gshift) & vs->client_pf.gmax; color->blue = (pix >> vs->client_pf.bshift) & vs->client_pf.bmax; } else { int red, green, blue; red = (pix >> vs->client_pf.rshift) & vs->client_pf.rmax; green = (pix >> vs->client_pf.gshift) & vs->client_pf.gmax; blue = (pix >> vs->client_pf.bshift) & vs->client_pf.bmax; color->red = ((red * 255 + vs->client_pf.rmax / 2) / vs->client_pf.rmax); color->green = ((green * 255 + vs->client_pf.gmax / 2) / vs->client_pf.gmax); color->blue = ((blue * 255 + vs->client_pf.bmax / 2) / vs->client_pf.bmax); } }
0
513,251
change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &res_selected_fields, List<Item> &res_all_fields, uint elements, List<Item> &all_fields) { List_iterator_fast<Item> it(all_fields); Item *item_field,*item; DBUG_ENTER("change_to_use_tmp_fields"); res_selected_fields.empty(); res_all_fields.empty(); uint border= all_fields.elements - elements; for (uint i= 0; (item= it++); i++) { Field *field; if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) || item->with_window_func) item_field= item; else if (item->type() == Item::FIELD_ITEM) item_field= item->get_tmp_table_item(thd); else if (item->type() == Item::FUNC_ITEM && ((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC) { field= item->get_tmp_table_field(); if (field != NULL) { /* Replace "@:=<expression>" with "@:=<tmp table column>". Otherwise, we would re-evaluate <expression>, and if expression were a subquery, this would access already-unlocked tables. */ Item_func_set_user_var* suv= new (thd->mem_root) Item_func_set_user_var(thd, (Item_func_set_user_var*) item); Item_field *new_field= new (thd->mem_root) Item_temptable_field(thd, field); if (!suv || !new_field) DBUG_RETURN(true); // Fatal error List<Item> list; list.push_back(new_field, thd->mem_root); suv->set_arguments(thd, list); item_field= suv; } else item_field= item; } else if ((field= item->get_tmp_table_field())) { if (item->type() == Item::SUM_FUNC_ITEM && field->table->group) item_field= ((Item_sum*) item)->result_item(thd, field); else item_field= (Item *) new (thd->mem_root) Item_temptable_field(thd, field); if (!item_field) DBUG_RETURN(true); // Fatal error if (item->real_item()->type() != Item::FIELD_ITEM) field->orig_table= 0; item_field->name= item->name; if (item->type() == Item::REF_ITEM) { Item_field *ifield= (Item_field *) item_field; Item_ref *iref= (Item_ref *) item; ifield->table_name= iref->table_name; ifield->db_name= iref->db_name; } #ifndef DBUG_OFF if (!item_field->name) { char buff[256]; String str(buff,sizeof(buff),&my_charset_bin); str.length(0); str.extra_allocation(1024); item->print(&str, QT_ORDINARY); item_field->name= thd->strmake(str.ptr(),str.length()); } #endif } else item_field= item; res_all_fields.push_back(item_field, thd->mem_root); ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]= item_field; } List_iterator_fast<Item> itr(res_all_fields); for (uint i= 0; i < border; i++) itr++; itr.sublist(res_selected_fields, elements); DBUG_RETURN(false); }
0
432,205
static void unassigned_io_write(struct uc_struct *uc, void* opaque, hwaddr addr, uint64_t data, unsigned size) { }
0
252,321
static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_zip_internal_state *pState = pZip->m_pState; mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); #ifdef _MSC_VER if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) #else if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) #endif return 0; if (new_size > pState->m_mem_capacity) { void *pNew_block; size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2; if (NULL == (pNew_block = pZip->m_pRealloc( pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) return 0; pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity; } memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); pState->m_mem_size = (size_t)new_size; return n; }
0
310,277
routerstatus_format_entry(char *buf, size_t buf_len, routerstatus_t *rs, const char *version, routerstatus_format_type_t format) { int r; struct in_addr in; char *cp; char *summary; char published[ISO_TIME_LEN+1]; char ipaddr[INET_NTOA_BUF_LEN]; char identity64[BASE64_DIGEST_LEN+1]; char digest64[BASE64_DIGEST_LEN+1]; format_iso_time(published, rs->published_on); digest_to_base64(identity64, rs->identity_digest); digest_to_base64(digest64, rs->descriptor_digest); in.s_addr = htonl(rs->addr); tor_inet_ntoa(&in, ipaddr, sizeof(ipaddr)); r = tor_snprintf(buf, buf_len, "r %s %s %s%s%s %s %d %d\n", rs->nickname, identity64, (format==NS_V3_CONSENSUS_MICRODESC)?"":digest64, (format==NS_V3_CONSENSUS_MICRODESC)?"":" ", published, ipaddr, (int)rs->or_port, (int)rs->dir_port); if (r<0) { log_warn(LD_BUG, "Not enough space in buffer."); return -1; } /* TODO: Maybe we want to pass in what we need to build the rest of * this here, instead of in the caller. Then we could use the * networkstatus_type_t values, with an additional control port value * added -MP */ if (format == NS_V3_CONSENSUS || format == NS_V3_CONSENSUS_MICRODESC) return 0; cp = buf + strlen(buf); /* NOTE: Whenever this list expands, be sure to increase MAX_FLAG_LINE_LEN*/ r = tor_snprintf(cp, buf_len - (cp-buf), "s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", /* These must stay in alphabetical order. */ rs->is_authority?" Authority":"", rs->is_bad_directory?" BadDirectory":"", rs->is_bad_exit?" BadExit":"", rs->is_exit?" Exit":"", rs->is_fast?" Fast":"", rs->is_possible_guard?" Guard":"", rs->is_hs_dir?" HSDir":"", rs->is_named?" Named":"", rs->is_running?" Running":"", rs->is_stable?" Stable":"", rs->is_unnamed?" Unnamed":"", rs->is_v2_dir?" V2Dir":"", rs->is_valid?" Valid":""); if (r<0) { log_warn(LD_BUG, "Not enough space in buffer."); return -1; } cp += strlen(cp); /* length of "opt v \n" */ #define V_LINE_OVERHEAD 7 if (version && strlen(version) < MAX_V_LINE_LEN - V_LINE_OVERHEAD) { if (tor_snprintf(cp, buf_len - (cp-buf), "opt v %s\n", version)<0) { log_warn(LD_BUG, "Unable to print router version."); return -1; } cp += strlen(cp); } if (format != NS_V2) { routerinfo_t* desc = router_get_by_digest(rs->identity_digest); uint32_t bw; if (format != NS_CONTROL_PORT) { /* Blow up more or less nicely if we didn't get anything or not the * thing we expected. */ if (!desc) { char id[HEX_DIGEST_LEN+1]; char dd[HEX_DIGEST_LEN+1]; base16_encode(id, sizeof(id), rs->identity_digest, DIGEST_LEN); base16_encode(dd, sizeof(dd), rs->descriptor_digest, DIGEST_LEN); log_warn(LD_BUG, "Cannot get any descriptor for %s " "(wanted descriptor %s).", id, dd); return -1; }; /* This assert can fire for the control port, because * it can request NS documents before all descriptors * have been fetched. */ if (tor_memneq(desc->cache_info.signed_descriptor_digest, rs->descriptor_digest, DIGEST_LEN)) { char rl_d[HEX_DIGEST_LEN+1]; char rs_d[HEX_DIGEST_LEN+1]; char id[HEX_DIGEST_LEN+1]; base16_encode(rl_d, sizeof(rl_d), desc->cache_info.signed_descriptor_digest, DIGEST_LEN); base16_encode(rs_d, sizeof(rs_d), rs->descriptor_digest, DIGEST_LEN); base16_encode(id, sizeof(id), rs->identity_digest, DIGEST_LEN); log_err(LD_BUG, "descriptor digest in routerlist does not match " "the one in routerstatus: %s vs %s " "(router %s)\n", rl_d, rs_d, id); tor_assert(tor_memeq(desc->cache_info.signed_descriptor_digest, rs->descriptor_digest, DIGEST_LEN)); }; } if (format == NS_CONTROL_PORT && rs->has_bandwidth) { bw = rs->bandwidth; } else { tor_assert(desc); bw = router_get_advertised_bandwidth_capped(desc) / 1000; } r = tor_snprintf(cp, buf_len - (cp-buf), "w Bandwidth=%d\n", bw); if (r<0) { log_warn(LD_BUG, "Not enough space in buffer."); return -1; } cp += strlen(cp); if (format == NS_V3_VOTE && rs->has_measured_bw) { *--cp = '\0'; /* Kill "\n" */ r = tor_snprintf(cp, buf_len - (cp-buf), " Measured=%d\n", rs->measured_bw); if (r<0) { log_warn(LD_BUG, "Not enough space in buffer for weight line."); return -1; } cp += strlen(cp); } if (desc) { summary = policy_summarize(desc->exit_policy); r = tor_snprintf(cp, buf_len - (cp-buf), "p %s\n", summary); if (r<0) { log_warn(LD_BUG, "Not enough space in buffer."); tor_free(summary); return -1; } cp += strlen(cp); tor_free(summary); } } return 0; }
0
90,794
void QuotaManager::NotifyOriginNoLongerInUse(const GURL& origin) { DCHECK(io_thread_->BelongsToCurrentThread()); DCHECK(IsOriginInUse(origin)); int& count = origins_in_use_[origin]; if (--count == 0) origins_in_use_.erase(origin); }
0
364,753
get_tagstack(win_T *wp, dict_T *retdict) { list_T *l; int i; dict_T *d; dict_add_number(retdict, "length", wp->w_tagstacklen); dict_add_number(retdict, "curidx", wp->w_tagstackidx + 1); l = list_alloc_id(aid_tagstack_items); if (l == NULL) return; dict_add_list(retdict, "items", l); for (i = 0; i < wp->w_tagstacklen; i++) { if ((d = dict_alloc_id(aid_tagstack_details)) == NULL) return; list_append_dict(l, d); get_tag_details(&wp->w_tagstack[i], d); } }
0
259,261
static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; int last, type, size, ret; uint8_t buf[4]; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; if ((uint64_t)atom.size > (1<<30) || atom.size < 42) return AVERROR_INVALIDDATA; /* Check FlacSpecificBox version. */ if (avio_r8(pb) != 0) return AVERROR_INVALIDDATA; avio_rb24(pb); /* Flags */ if (avio_read(pb, buf, sizeof(buf)) != sizeof(buf)) { av_log(c->fc, AV_LOG_ERROR, "failed to read FLAC metadata block header\n"); return pb->error < 0 ? pb->error : AVERROR_INVALIDDATA; } flac_parse_block_header(buf, &last, &type, &size); if (type != FLAC_METADATA_TYPE_STREAMINFO || size != FLAC_STREAMINFO_SIZE) { av_log(c->fc, AV_LOG_ERROR, "STREAMINFO must be first FLACMetadataBlock\n"); return AVERROR_INVALIDDATA; } ret = ff_get_extradata(c->fc, st->codecpar, pb, size); if (ret < 0) return ret; if (!last) av_log(c->fc, AV_LOG_WARNING, "non-STREAMINFO FLACMetadataBlock(s) ignored\n"); return 0; }
0
314,475
static bool FNAME(is_bad_mt_xwr)(struct rsvd_bits_validate *rsvd_check, u64 gpte) { #if PTTYPE != PTTYPE_EPT return false; #else return __is_bad_mt_xwr(rsvd_check, gpte); #endif }
0
253,549
receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, int *num_mids) { char *buf = server->smallbuf; struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf; unsigned int npages; struct page **pages; unsigned int len; unsigned int buflen = server->pdu_size; int rc; int i = 0; struct smb2_decrypt_work *dw; *num_mids = 1; len = min_t(unsigned int, buflen, server->vals->read_rsp_size + sizeof(struct smb2_transform_hdr)) - HEADER_SIZE(server) + 1; rc = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, len); if (rc < 0) return rc; server->total_read += rc; len = le32_to_cpu(tr_hdr->OriginalMessageSize) - server->vals->read_rsp_size; npages = DIV_ROUND_UP(len, PAGE_SIZE); pages = kmalloc_array(npages, sizeof(struct page *), GFP_KERNEL); if (!pages) { rc = -ENOMEM; goto discard_data; } for (; i < npages; i++) { pages[i] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM); if (!pages[i]) { rc = -ENOMEM; goto discard_data; } } /* read read data into pages */ rc = read_data_into_pages(server, pages, npages, len); if (rc) goto free_pages; rc = cifs_discard_remaining_data(server); if (rc) goto free_pages; /* * For large reads, offload to different thread for better performance, * use more cores decrypting which can be expensive */ if ((server->min_offload) && (server->in_flight > 1) && (server->pdu_size >= server->min_offload)) { dw = kmalloc(sizeof(struct smb2_decrypt_work), GFP_KERNEL); if (dw == NULL) goto non_offloaded_decrypt; dw->buf = server->smallbuf; server->smallbuf = (char *)cifs_small_buf_get(); INIT_WORK(&dw->decrypt, smb2_decrypt_offload); dw->npages = npages; dw->server = server; dw->ppages = pages; dw->len = len; queue_work(decrypt_wq, &dw->decrypt); *num_mids = 0; /* worker thread takes care of finding mid */ return -1; } non_offloaded_decrypt: rc = decrypt_raw_data(server, buf, server->vals->read_rsp_size, pages, npages, len, false); if (rc) goto free_pages; *mid = smb2_find_mid(server, buf); if (*mid == NULL) cifs_dbg(FYI, "mid not found\n"); else { cifs_dbg(FYI, "mid found\n"); (*mid)->decrypted = true; rc = handle_read_data(server, *mid, buf, server->vals->read_rsp_size, pages, npages, len, false); if (rc >= 0) { if (server->ops->is_network_name_deleted) { server->ops->is_network_name_deleted(buf, server); } } } free_pages: for (i = i - 1; i >= 0; i--) put_page(pages[i]); kfree(pages); return rc; discard_data: cifs_discard_remaining_data(server); goto free_pages; }
0
195,742
static GF_Err gf_isom_parse_movie_boxes_internal(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode) { GF_Box *a; u64 totSize, mdat_end=0; GF_Err e = GF_OK; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->single_moof_mode && mov->single_moof_state == 2) { return e; } /*restart from where we stopped last*/ totSize = mov->current_top_box_start; if (mov->bytes_removed) { assert(totSize >= mov->bytes_removed); totSize -= mov->bytes_removed; } gf_bs_seek(mov->movieFileMap->bs, totSize); #endif /*while we have some data, parse our boxes*/ while (gf_bs_available(mov->movieFileMap->bs)) { *bytesMissing = 0; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS mov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed; GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Parsing a top-level box at position %d\n", mov->current_top_box_start)); #endif e = gf_isom_parse_root_box(&a, mov->movieFileMap->bs, boxType, bytesMissing, progressive_mode); if (e >= 0) { } else if (e == GF_ISOM_INCOMPLETE_FILE) { /*our mdat is uncomplete, only valid for READ ONLY files...*/ if (mov->openMode != GF_ISOM_OPEN_READ) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Incomplete MDAT while file is not read-only\n")); return GF_ISOM_INVALID_FILE; } if ((mov->openMode == GF_ISOM_OPEN_READ) && !progressive_mode) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Incomplete file while reading for dump - aborting parsing\n")); break; } return e; } else { return e; } switch (a->type) { /*MOOV box*/ case GF_ISOM_BOX_TYPE_MOOV: if (mov->moov) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate MOOV detected!\n")); gf_isom_box_del(a); return GF_ISOM_INVALID_FILE; } mov->moov = (GF_MovieBox *)a; mov->original_moov_offset = mov->current_top_box_start; /*set our pointer to the movie*/ mov->moov->mov = mov; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->moov->mvex) mov->moov->mvex->mov = mov; #ifdef GF_ENABLE_CTRN if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { gf_isom_setup_traf_inheritance(mov); } #endif #endif e = gf_list_add(mov->TopBoxes, a); if (e) return e; totSize += a->size; if (!mov->moov->mvhd) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing MovieHeaderBox\n")); return GF_ISOM_INVALID_FILE; } if (mov->meta) { gf_isom_meta_restore_items_ref(mov, mov->meta); } //dump senc info in dump mode if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { u32 k; for (k=0; k<gf_list_count(mov->moov->trackList); k++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k); if (trak->sample_encryption) { e = senc_Parse(mov->movieFileMap->bs, trak, NULL, trak->sample_encryption); if (e) return e; } } } else { u32 k; for (k=0; k<gf_list_count(mov->moov->trackList); k++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k); if (trak->Media->information->sampleTable->sampleGroups) { convert_compact_sample_groups(trak->Media->information->sampleTable->child_boxes, trak->Media->information->sampleTable->sampleGroups); } } } if (mdat_end && mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) { gf_isom_push_mdat_end(mov, mdat_end); mdat_end=0; } break; /*META box*/ case GF_ISOM_BOX_TYPE_META: if (mov->meta) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate META detected!\n")); gf_isom_box_del(a); return GF_ISOM_INVALID_FILE; } mov->meta = (GF_MetaBox *)a; mov->original_meta_offset = mov->current_top_box_start; e = gf_list_add(mov->TopBoxes, a); if (e) { return e; } totSize += a->size; gf_isom_meta_restore_items_ref(mov, mov->meta); break; /*we only keep the MDAT in READ for dump purposes*/ case GF_ISOM_BOX_TYPE_MDAT: if (!mov->first_data_toplevel_offset) { mov->first_data_toplevel_offset = mov->current_top_box_start; mov->first_data_toplevel_size = a->size; } totSize += a->size; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->emsgs) { gf_isom_box_array_del(mov->emsgs); mov->emsgs = NULL; } #endif if (mov->openMode == GF_ISOM_OPEN_READ) { if (!mov->mdat) { mov->mdat = (GF_MediaDataBox *) a; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) { return e; } } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS else if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) gf_list_add(mov->TopBoxes, a); #endif else gf_isom_box_del(a); //in other modes we don't care if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) { mdat_end = gf_bs_get_position(mov->movieFileMap->bs); if (mov->moov) { gf_isom_push_mdat_end(mov, mdat_end); mdat_end=0; } } } /*if we don't have any MDAT yet, create one (edit-write mode) We only work with one mdat, but we're puting it at the place of the first mdat found when opening a file for editing*/ else if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) { gf_isom_box_del(a); mov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT); if (!mov->mdat) return GF_OUT_OF_MEM; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) { return e; } } else { gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_FTYP: /*ONE AND ONLY ONE FTYP*/ if (mov->brand) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate 'ftyp' detected!\n")); return GF_ISOM_INVALID_FILE; } mov->brand = (GF_FileTypeBox *)a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; case GF_ISOM_BOX_TYPE_OTYP: /*ONE AND ONLY ONE FTYP*/ if (mov->otyp) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate 'otyp' detected!\n")); return GF_ISOM_INVALID_FILE; } if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { mov->otyp = (GF_Box *)a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; } else { GF_FileTypeBox *brand = (GF_FileTypeBox *) gf_isom_box_find_child(a->child_boxes, GF_ISOM_BOX_TYPE_FTYP); if (brand) { s32 pos; gf_list_del_item(a->child_boxes, brand); pos = gf_list_del_item(mov->TopBoxes, mov->brand); gf_isom_box_del((GF_Box *) mov->brand); mov->brand = brand; if (pos<0) pos=0; gf_list_insert(mov->TopBoxes, brand, pos); } gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_PDIN: /*ONE AND ONLY ONE PDIN*/ if (mov->pdin) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate 'pdin'' detected!\n")); return GF_ISOM_INVALID_FILE; } mov->pdin = (GF_ProgressiveDownloadBox *) a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS case GF_ISOM_BOX_TYPE_STYP: { u32 brand = ((GF_FileTypeBox *)a)->majorBrand; switch (brand) { case GF_ISOM_BRAND_SISX: case GF_ISOM_BRAND_RISX: case GF_ISOM_BRAND_SSSS: mov->is_index_segment = GF_TRUE; break; default: break; } } /*fall-through*/ case GF_ISOM_BOX_TYPE_SIDX: case GF_ISOM_BOX_TYPE_SSIX: if (mov->moov && !mov->first_data_toplevel_offset) { mov->first_data_toplevel_offset = mov->current_top_box_start; mov->first_data_toplevel_size = a->size; } totSize += a->size; if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { e = gf_list_add(mov->TopBoxes, a); if (e) return e; } else if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) && (mov->openMode!=GF_ISOM_OPEN_KEEP_FRAGMENTS) ) { if (a->type==GF_ISOM_BOX_TYPE_SIDX) { if (mov->root_sidx) gf_isom_box_del( (GF_Box *) mov->root_sidx); mov->root_sidx = (GF_SegmentIndexBox *) a; mov->sidx_start_offset = mov->current_top_box_start; mov->sidx_end_offset = gf_bs_get_position(mov->movieFileMap->bs); } else if (a->type==GF_ISOM_BOX_TYPE_STYP) { mov->styp_start_offset = mov->current_top_box_start; if (mov->seg_styp) gf_isom_box_del(mov->seg_styp); mov->seg_styp = a; } else if (a->type==GF_ISOM_BOX_TYPE_SSIX) { if (mov->seg_ssix) gf_isom_box_del(mov->seg_ssix); mov->seg_ssix = a; } else { gf_isom_box_del(a); } gf_isom_push_mdat_end(mov, mov->current_top_box_start); } else if (!mov->NextMoofNumber && (a->type==GF_ISOM_BOX_TYPE_SIDX)) { if (mov->main_sidx) gf_isom_box_del( (GF_Box *) mov->main_sidx); mov->main_sidx = (GF_SegmentIndexBox *) a; mov->main_sidx_end_pos = mov->current_top_box_start + a->size; } else { gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_MOOF: //no support for inplace rewrite for fragmented files gf_isom_disable_inplace_rewrite(mov); if (!mov->moov) { GF_LOG(mov->moof ? GF_LOG_DEBUG : GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Movie fragment but no moov (yet) - possibly broken parsing!\n")); } if (mov->single_moof_mode) { mov->single_moof_state++; if (mov->single_moof_state > 1) { gf_isom_box_del(a); return GF_OK; } } ((GF_MovieFragmentBox *)a)->mov = mov; totSize += a->size; mov->moof = (GF_MovieFragmentBox *) a; /*some smooth streaming streams contain a SDTP under the TRAF: this is incorrect, convert it*/ FixTrackID(mov); if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { FixSDTPInTRAF(mov->moof); } else { u32 k; for (k=0; k<gf_list_count(mov->moof->TrackList); k++) { GF_TrackFragmentBox *traf = (GF_TrackFragmentBox *)gf_list_get(mov->moof->TrackList, k); if (traf->sampleGroups) { convert_compact_sample_groups(traf->child_boxes, traf->sampleGroups); } } } /*read & debug: store at root level*/ if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { u32 k; gf_list_add(mov->TopBoxes, a); /*also update pointers to trex for debug*/ if (mov->moov) { for (k=0; k<gf_list_count(mov->moof->TrackList); k++) { GF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k); if (traf->tfhd && mov->moov->mvex && mov->moov->mvex->TrackExList) { GF_TrackBox *trak = gf_isom_get_track_from_id(mov->moov, traf->tfhd->trackID); u32 j=0; while ((traf->trex = (GF_TrackExtendsBox*)gf_list_enum(mov->moov->mvex->TrackExList, &j))) { if (traf->trex->trackID == traf->tfhd->trackID) { if (!traf->trex->track) traf->trex->track = trak; break; } traf->trex = NULL; } } //we should only parse senc/psec when no saiz/saio is present, otherwise we fetch the info directly if (traf->trex && traf->tfhd && traf->trex->track && traf->sample_encryption) { GF_TrackBox *trak = GetTrackbyID(mov->moov, traf->tfhd->trackID); if (trak) { trak->current_traf_stsd_idx = traf->tfhd->sample_desc_index ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index; e = senc_Parse(mov->movieFileMap->bs, trak, traf, traf->sample_encryption); if (e) return e; trak->current_traf_stsd_idx = 0; } } } } else { for (k=0; k<gf_list_count(mov->moof->TrackList); k++) { GF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k); if (traf->sample_encryption) { e = senc_Parse(mov->movieFileMap->bs, NULL, traf, traf->sample_encryption); if (e) return e; } } } } else if (mov->openMode==GF_ISOM_OPEN_KEEP_FRAGMENTS) { mov->NextMoofNumber = mov->moof->mfhd->sequence_number+1; mov->moof = NULL; gf_isom_box_del(a); } else { /*merge all info*/ e = MergeFragment((GF_MovieFragmentBox *)a, mov); gf_isom_box_del(a); if (e) return e; } //done with moov if (mov->root_sidx) { gf_isom_box_del((GF_Box *) mov->root_sidx); mov->root_sidx = NULL; } if (mov->root_ssix) { gf_isom_box_del(mov->seg_ssix); mov->root_ssix = NULL; } if (mov->seg_styp) { gf_isom_box_del(mov->seg_styp); mov->seg_styp = NULL; } mov->sidx_start_offset = 0; mov->sidx_end_offset = 0; mov->styp_start_offset = 0; break; #endif case GF_ISOM_BOX_TYPE_UNKNOWN: { GF_UnknownBox *box = (GF_UnknownBox*)a; if (box->original_4cc == GF_ISOM_BOX_TYPE_JP) { u8 *c = (u8 *) box->data; if ((box->dataSize==4) && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A)) mov->is_jp2 = 1; gf_isom_box_del(a); } else { e = gf_list_add(mov->TopBoxes, a); if (e) return e; } } break; case GF_ISOM_BOX_TYPE_PRFT: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (!(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { //keep the last one read if (mov->last_producer_ref_time) gf_isom_box_del(a); else mov->last_producer_ref_time = (GF_ProducerReferenceTimeBox *)a; break; } #endif //fallthrough case GF_ISOM_BOX_TYPE_EMSG: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { if (!mov->emsgs) mov->emsgs = gf_list_new(); gf_list_add(mov->emsgs, a); break; } #endif case GF_ISOM_BOX_TYPE_MFRA: case GF_ISOM_BOX_TYPE_MFRO: //only keep for dump mode, otherwise we ignore these boxes and we don't want to carry them over in non-fragmented file if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { totSize += a->size; gf_isom_box_del(a); break; } default: totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*remember where we left, in case we append an entire number of movie fragments*/ mov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed; #endif } /*we need at least moov or meta*/ if (!mov->moov && !mov->meta #ifndef GPAC_DISABLE_ISOM_FRAGMENTS && !mov->moof && !mov->is_index_segment #endif ) { return GF_ISOM_INCOMPLETE_FILE; } /*we MUST have movie header*/ if (!gf_opts_get_bool("core", "no-check")) { if (mov->moov && !mov->moov->mvhd) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing MVHD in MOOV!\n")); return GF_ISOM_INVALID_FILE; } /*we MUST have meta handler*/ if (mov->meta && !mov->meta->handler) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing handler in META!\n")); return GF_ISOM_INVALID_FILE; } } #ifndef GPAC_DISABLE_ISOM_WRITE if (mov->moov) { /*set the default interleaving time*/ mov->interleavingTime = mov->moov->mvhd->timeScale; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*in edit mode with successfully loaded fragments, delete all fragment signaling since file is no longer fragmented*/ if ((mov->openMode > GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS) && mov->moov->mvex) { gf_isom_box_del_parent(&mov->moov->child_boxes, (GF_Box *)mov->moov->mvex); mov->moov->mvex = NULL; } #endif } //create a default mdat if none was found if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) { mov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT); if (!mov->mdat) return GF_OUT_OF_MEM; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) return e; } #endif /*GPAC_DISABLE_ISOM_WRITE*/ return GF_OK; }
1
409,488
add_termcode(char_u *name, char_u *string, int flags) { struct termcode *new_tc; int i, j; char_u *s; int len; if (string == NULL || *string == NUL) { del_termcode(name); return; } #if defined(MSWIN) && !defined(FEAT_GUI) s = vim_strnsave(string, STRLEN(string) + 1); #else # ifdef VIMDLL if (!gui.in_use) s = vim_strnsave(string, STRLEN(string) + 1); else # endif s = vim_strsave(string); #endif if (s == NULL) return; // Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) { STRMOVE(s, s + 1); s[0] = term_7to8bit(string); } #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) # ifdef VIMDLL if (!gui.in_use) # endif { if (s[0] == K_NUL) { STRMOVE(s + 1, s); s[1] = 3; } } #endif len = (int)STRLEN(s); need_gather = TRUE; // need to fill termleader[] /* * need to make space for more entries */ if (tc_len == tc_max_len) { tc_max_len += 20; new_tc = ALLOC_MULT(struct termcode, tc_max_len); if (new_tc == NULL) { tc_max_len -= 20; vim_free(s); return; } for (i = 0; i < tc_len; ++i) new_tc[i] = termcodes[i]; vim_free(termcodes); termcodes = new_tc; } /* * Look for existing entry with the same name, it is replaced. * Look for an existing entry that is alphabetical higher, the new entry * is inserted in front of it. */ for (i = 0; i < tc_len; ++i) { if (termcodes[i].name[0] < name[0]) continue; if (termcodes[i].name[0] == name[0]) { if (termcodes[i].name[1] < name[1]) continue; /* * Exact match: May replace old code. */ if (termcodes[i].name[1] == name[1]) { if (flags == ATC_FROM_TERM && (j = termcode_star( termcodes[i].code, termcodes[i].len)) > 0) { // Don't replace ESC[123;*X or ESC O*X with another when // invoked from got_code_from_term(). if (len == termcodes[i].len - j && STRNCMP(s, termcodes[i].code, len - 1) == 0 && s[len - 1] == termcodes[i].code[termcodes[i].len - 1]) { // They are equal but for the ";*": don't add it. vim_free(s); return; } } else { // Replace old code. vim_free(termcodes[i].code); --tc_len; break; } } } /* * Found alphabetical larger entry, move rest to insert new entry */ for (j = tc_len; j > i; --j) termcodes[j] = termcodes[j - 1]; break; } termcodes[i].name[0] = name[0]; termcodes[i].name[1] = name[1]; termcodes[i].code = s; termcodes[i].len = len; // For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that // accept modifiers. termcodes[i].modlen = 0; j = termcode_star(s, len); if (j > 0) { termcodes[i].modlen = len - 1 - j; // For "CSI[@;X" the "@" is not included in "modlen". if (termcodes[i].code[termcodes[i].modlen - 1] == '@') --termcodes[i].modlen; } ++tc_len; }
0
289,298
static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct snd_pcm_str *pstr = entry->private_data; struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; mutex_lock(&pstr->oss.setup_mutex); while (setup) { snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", setup->task_name, setup->periods, setup->period_size, setup->disable ? " disable" : "", setup->direct ? " direct" : "", setup->block ? " block" : "", setup->nonblock ? " non-block" : "", setup->partialfrag ? " partial-frag" : "", setup->nosilence ? " no-silence" : ""); setup = setup->next; } mutex_unlock(&pstr->oss.setup_mutex); }
0
222,877
bool ShouldUpdateOutputShapesAndValues(NodeContext* c, int64_t max_size) { InferenceContext* ic = c->inference_context.get(); // Due to the cost of running EvaluateNode(), we limit only to white listed // op types. if (!IsAllowListedOpTypeForEvaluateNode(c->op_data->op_def.name())) { return false; } // Check input dtypes are number types. for (const auto& input_type : c->input_types) { if (!IsNumericType(input_type)) { return false; } } // Check output dtypes are number types. for (const auto& output_type : c->output_types) { if (!IsNumericType(output_type)) { return false; } } // Check if the number of elements of each of input tensor is no larger than // the given max size. for (int i = 0; i < ic->num_inputs(); i++) { const Tensor* tensor = ic->input_tensor(i); const ShapeHandle& input_shape_handle = ic->input(i); if (tensor != nullptr) { if (tensor->NumElements() > max_size) { return false; } } else if (ic->Value(ic->NumElements(input_shape_handle)) > max_size) { return false; } } // Check if we know the shape of each output tensor, and the number of // elements is larger than the given max size. for (int i = 0; i < ic->num_outputs(); i++) { const ShapeHandle& shape_handle = ic->output(i); if (!ic->FullyDefined(shape_handle) || ic->Value(ic->NumElements(shape_handle)) > max_size) { return false; } } return true; }
0
427,733
cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h, const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst, const cdf_dir_t *dir) { size_t i, j; cdf_directory_t *d; char name[__arraycount(d->d_name)]; cdf_stream_t scn; struct timespec ts; static const char *types[] = { "empty", "user storage", "user stream", "lockbytes", "property", "root storage" }; for (i = 0; i < dir->dir_len; i++) { char buf[26]; d = &dir->dir_tab[i]; for (j = 0; j < sizeof(name); j++) name[j] = (char)CDF_TOLE2(d->d_name[j]); (void)fprintf(stderr, "Directory %" SIZE_T_FORMAT "u: %s\n", i, name); if (d->d_type < __arraycount(types)) (void)fprintf(stderr, "Type: %s\n", types[d->d_type]); else (void)fprintf(stderr, "Type: %d\n", d->d_type); (void)fprintf(stderr, "Color: %s\n", d->d_color ? "black" : "red"); (void)fprintf(stderr, "Left child: %d\n", d->d_left_child); (void)fprintf(stderr, "Right child: %d\n", d->d_right_child); (void)fprintf(stderr, "Flags: %#x\n", d->d_flags); cdf_timestamp_to_timespec(&ts, d->d_created); (void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec, buf)); cdf_timestamp_to_timespec(&ts, d->d_modified); (void)fprintf(stderr, "Modified %s", cdf_ctime(&ts.tv_sec, buf)); (void)fprintf(stderr, "Stream %d\n", d->d_stream_first_sector); (void)fprintf(stderr, "Size %d\n", d->d_size); switch (d->d_type) { case CDF_DIR_TYPE_USER_STORAGE: (void)fprintf(stderr, "Storage: %d\n", d->d_storage); break; case CDF_DIR_TYPE_USER_STREAM: if (sst == NULL) break; if (cdf_read_sector_chain(info, h, sat, ssat, sst, d->d_stream_first_sector, d->d_size, &scn) == -1) { warn("Can't read stream for %s at %d len %d", name, d->d_stream_first_sector, d->d_size); break; } cdf_dump_stream(&scn); free(scn.sst_tab); break; default: break; } } }
0
264,412
static CURLcode cookie_output(struct Curl_easy *data, struct CookieInfo *c, const char *filename) { struct Cookie *co; FILE *out = NULL; bool use_stdout = FALSE; char *tempstore = NULL; CURLcode error = CURLE_OK; if(!c) /* no cookie engine alive */ return CURLE_OK; /* at first, remove expired cookies */ remove_expired(c); if(!strcmp("-", filename)) { /* use stdout */ out = stdout; use_stdout = TRUE; } else { error = Curl_fopen(data, filename, &out, &tempstore); if(error) goto error; } fputs("# Netscape HTTP Cookie File\n" "# https://curl.se/docs/http-cookies.html\n" "# This file was generated by libcurl! Edit at your own risk.\n\n", out); if(c->numcookies) { unsigned int i; size_t nvalid = 0; struct Cookie **array; array = calloc(1, sizeof(struct Cookie *) * c->numcookies); if(!array) { error = CURLE_OUT_OF_MEMORY; goto error; } /* only sort the cookies with a domain property */ for(i = 0; i < COOKIE_HASH_SIZE; i++) { for(co = c->cookies[i]; co; co = co->next) { if(!co->domain) continue; array[nvalid++] = co; } } qsort(array, nvalid, sizeof(struct Cookie *), cookie_sort_ct); for(i = 0; i < nvalid; i++) { char *format_ptr = get_netscape_format(array[i]); if(!format_ptr) { free(array); error = CURLE_OUT_OF_MEMORY; goto error; } fprintf(out, "%s\n", format_ptr); free(format_ptr); } free(array); } if(!use_stdout) { fclose(out); out = NULL; if(tempstore && Curl_rename(tempstore, filename)) { unlink(tempstore); error = CURLE_WRITE_ERROR; goto error; } } /* * If we reach here we have successfully written a cookie file so theree is * no need to inspect the error, any error case should have jumped into the * error block below. */ free(tempstore); return CURLE_OK; error: if(out && !use_stdout) fclose(out); free(tempstore); return error; }
0
450,349
void start_auth_vnc(VncState *vs) { Error *err = NULL; if (qcrypto_random_bytes(vs->challenge, sizeof(vs->challenge), &err)) { trace_vnc_auth_fail(vs, vs->auth, "cannot get random bytes", error_get_pretty(err)); error_free(err); authentication_failed(vs); return; } /* Send client a 'random' challenge */ vnc_write(vs, vs->challenge, sizeof(vs->challenge)); vnc_flush(vs); vnc_read_when(vs, protocol_client_auth_vnc, sizeof(vs->challenge)); }
0
432,705
static void ipa_bmp_draw(wmfAPI *API, wmfBMP_Draw_t *bmp_draw) { wmf_magick_t *ddata = WMF_MAGICK_GetData(API); ExceptionInfo *exception; Image *image; MagickWand *magick_wand; double height, width; PixelInfo white; if (bmp_draw->bmp.data == 0) return; image = (Image*)bmp_draw->bmp.data; if (!image) return; exception=ddata->exception; if (bmp_draw->crop.x || bmp_draw->crop.y || (bmp_draw->crop.w != bmp_draw->bmp.width) || (bmp_draw->crop.h != bmp_draw->bmp.height)) { /* Image needs to be cropped */ Image *crop_image; RectangleInfo crop_info; crop_info.x = bmp_draw->crop.x; crop_info.y = bmp_draw->crop.y; crop_info.width = bmp_draw->crop.w; crop_info.height = bmp_draw->crop.h; crop_image = CropImage( image, &crop_info, exception ); if (crop_image) { image=DestroyImageList(image); image = crop_image; bmp_draw->bmp.data = (void*)image; } } QueryColorCompliance( "white", AllCompliance, &white, exception ); if ( ddata->image_info->texture || !(IsPixelInfoEquivalent(&ddata->image_info->background_color,&white)) || ddata->image_info->background_color.alpha != OpaqueAlpha ) { /* Set image white background to transparent so that it may be overlaid over non-white backgrounds. */ QueryColorCompliance( "white", AllCompliance, &white, exception ); TransparentPaintImage( image, &white, QuantumRange, MagickFalse, exception ); } width = fabs(bmp_draw->pixel_width * (double) bmp_draw->crop.w); height = fabs(bmp_draw->pixel_height * (double) bmp_draw->crop.h); magick_wand=NewMagickWandFromImage(image); (void) DrawComposite(WmfDrawingWand, CopyCompositeOp, XC(bmp_draw->pt.x) * ddata->scale_x, YC(bmp_draw->pt.y) * ddata->scale_y, width * ddata->scale_x, height * ddata->scale_y, magick_wand); magick_wand=DestroyMagickWand(magick_wand); #if 0 printf("bmp_draw->bmp.data = 0x%lx\n", (long)bmp_draw->bmp.data); printf("registry id = %li\n", id); /* printf("pixel_width = %g\n", bmp_draw->pixel_width); */ /* printf("pixel_height = %g\n", bmp_draw->pixel_height); */ printf("bmp_draw->bmp WxH = %ix%i\n", bmp_draw->bmp.width, bmp_draw->bmp.height); printf("bmp_draw->crop WxH = %ix%i\n", bmp_draw->crop.w, bmp_draw->crop.h); printf("bmp_draw->crop x,y = %i,%i\n", bmp_draw->crop.x, bmp_draw->crop.y); printf("image size WxH = %lux%lu\n", image->columns, image->rows); #endif }
0
273,402
Tensor OutputSlice(Tensor* t, int pos, const string& name) { Tensor res = UnalignedSlice(*t, pos); if (res.IsAligned()) { return res; } else { Tensor aligned = AlignTensor(res, name); copy_out_.emplace_back(res, aligned); return aligned; } }
0
338,208
uint8_t WasmBinaryBuilder::getLaneIndex(size_t lanes) { BYN_TRACE("<==\n"); auto ret = getInt8(); if (ret >= lanes) { throwError("Illegal lane index"); } BYN_TRACE("getLaneIndex(" << lanes << "): " << ret << " ==>" << std::endl); return ret; }
0
338,194
void WasmBinaryBuilder::readSourceMapHeader() { if (!sourceMap) { return; } auto skipWhitespace = [&]() { while (sourceMap->peek() == ' ' || sourceMap->peek() == '\n') { sourceMap->get(); } }; auto maybeReadChar = [&](char expected) { if (sourceMap->peek() != expected) { return false; } sourceMap->get(); return true; }; auto mustReadChar = [&](char expected) { char c = sourceMap->get(); if (c != expected) { throw MapParseException(std::string("Unexpected char: expected '") + expected + "' got '" + c + "'"); } }; auto findField = [&](const char* name) { bool matching = false; size_t len = strlen(name); size_t pos; while (1) { int ch = sourceMap->get(); if (ch == EOF) { return false; } if (ch == '\"') { if (matching) { // we matched a terminating quote. if (pos == len) { break; } matching = false; } else { matching = true; pos = 0; } } else if (matching && name[pos] == ch) { ++pos; } else if (matching) { matching = false; } } skipWhitespace(); mustReadChar(':'); skipWhitespace(); return true; }; auto readString = [&](std::string& str) { std::vector<char> vec; skipWhitespace(); mustReadChar('\"'); if (!maybeReadChar('\"')) { while (1) { int ch = sourceMap->get(); if (ch == EOF) { throw MapParseException("unexpected EOF in the middle of string"); } if (ch == '\"') { break; } vec.push_back(ch); } } skipWhitespace(); str = std::string(vec.begin(), vec.end()); }; if (!findField("sources")) { throw MapParseException("cannot find the 'sources' field in map"); } skipWhitespace(); mustReadChar('['); if (!maybeReadChar(']')) { do { std::string file; readString(file); Index index = wasm.debugInfoFileNames.size(); wasm.debugInfoFileNames.push_back(file); debugInfoFileIndices[file] = index; } while (maybeReadChar(',')); mustReadChar(']'); } if (!findField("mappings")) { throw MapParseException("cannot find the 'mappings' field in map"); } mustReadChar('\"'); if (maybeReadChar('\"')) { // empty mappings nextDebugLocation.first = 0; return; } // read first debug location uint32_t position = readBase64VLQ(*sourceMap); uint32_t fileIndex = readBase64VLQ(*sourceMap); uint32_t lineNumber = readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number uint32_t columnNumber = readBase64VLQ(*sourceMap); nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}}; }
0
508,352
No_such_table_error_handler::handle_condition(THD *, uint sql_errno, const char*, Sql_condition::enum_warning_level *level, const char*, Sql_condition ** cond_hdl) { *cond_hdl= NULL; if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE) { m_handled_errors++; return TRUE; } if (*level == Sql_condition::WARN_LEVEL_ERROR) m_unhandled_errors++; return FALSE; }
0
312,553
ex_cbuffer(exarg_T *eap) { buf_T *buf = NULL; qf_info_T *qi; char_u *au_name = NULL; int res; int_u save_qfid; win_T *wp = NULL; char_u *qf_title; linenr_T line1; linenr_T line2; au_name = cbuffer_get_auname(eap->cmdidx); if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { #ifdef FEAT_EVAL if (aborting()) return; #endif } // Must come after autocommands. qi = qf_cmd_get_or_alloc_stack(eap, &wp); if (qi == NULL) return; if (cbuffer_process_args(eap, &buf, &line1, &line2) == FAIL) return; qf_title = qf_cmdtitle(*eap->cmdlinep); if (buf->b_sfname) { vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", (char *)qf_title, (char *)buf->b_sfname); qf_title = IObuff; } incr_quickfix_busy(); res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm, (eap->cmdidx != CMD_caddbuffer && eap->cmdidx != CMD_laddbuffer), line1, line2, qf_title, NULL); if (qf_stack_empty(qi)) { decr_quickfix_busy(); return; } if (res >= 0) qf_list_changed(qf_get_curlist(qi)); // Remember the current quickfix list identifier, so that we can // check for autocommands changing the current quickfix list. save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) { buf_T *curbuf_old = curbuf; apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, TRUE, curbuf); if (curbuf != curbuf_old) // Autocommands changed buffer, don't jump now, "qi" may // be invalid. res = 0; } // Jump to the first error for a new list and if autocmds didn't // free the list. if (res > 0 && (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer) && qflist_valid(wp, save_qfid)) // display the first error qf_jump_first(qi, save_qfid, eap->forceit); decr_quickfix_busy(); }
0
487,642
static void k_getrusage(struct task_struct *p, int who, struct rusage *r) { struct task_struct *t; unsigned long flags; cputime_t utime, stime; memset((char *) r, 0, sizeof *r); utime = stime = cputime_zero; rcu_read_lock(); if (!lock_task_sighand(p, &flags)) { rcu_read_unlock(); return; } switch (who) { case RUSAGE_BOTH: case RUSAGE_CHILDREN: utime = p->signal->cutime; stime = p->signal->cstime; r->ru_nvcsw = p->signal->cnvcsw; r->ru_nivcsw = p->signal->cnivcsw; r->ru_minflt = p->signal->cmin_flt; r->ru_majflt = p->signal->cmaj_flt; if (who == RUSAGE_CHILDREN) break; case RUSAGE_SELF: utime = cputime_add(utime, p->signal->utime); stime = cputime_add(stime, p->signal->stime); r->ru_nvcsw += p->signal->nvcsw; r->ru_nivcsw += p->signal->nivcsw; r->ru_minflt += p->signal->min_flt; r->ru_majflt += p->signal->maj_flt; t = p; do { utime = cputime_add(utime, t->utime); stime = cputime_add(stime, t->stime); r->ru_nvcsw += t->nvcsw; r->ru_nivcsw += t->nivcsw; r->ru_minflt += t->min_flt; r->ru_majflt += t->maj_flt; t = next_thread(t); } while (t != p); break; default: BUG(); } unlock_task_sighand(p, &flags); rcu_read_unlock(); cputime_to_timeval(utime, &r->ru_utime); cputime_to_timeval(stime, &r->ru_stime); }
0
222,738
PJ_DEF(pj_status_t) pjmedia_rtcp_xr_update_info( pjmedia_rtcp_xr_session *sess, unsigned info, pj_int32_t val) { int v = val; switch(info) { case PJMEDIA_RTCP_XR_INFO_SIGNAL_LVL: sess->stat.rx.voip_mtc.signal_lvl = (pj_int8_t) v; break; case PJMEDIA_RTCP_XR_INFO_NOISE_LVL: sess->stat.rx.voip_mtc.noise_lvl = (pj_int8_t) v; break; case PJMEDIA_RTCP_XR_INFO_RERL: sess->stat.rx.voip_mtc.rerl = (pj_uint8_t) v; break; case PJMEDIA_RTCP_XR_INFO_R_FACTOR: sess->stat.rx.voip_mtc.ext_r_factor = (pj_uint8_t) v; break; case PJMEDIA_RTCP_XR_INFO_MOS_LQ: sess->stat.rx.voip_mtc.mos_lq = (pj_uint8_t) v; break; case PJMEDIA_RTCP_XR_INFO_MOS_CQ: sess->stat.rx.voip_mtc.mos_cq = (pj_uint8_t) v; break; case PJMEDIA_RTCP_XR_INFO_CONF_PLC: if (v >= 0 && v <= 3) { sess->stat.rx.voip_mtc.rx_config &= 0x3F; sess->stat.rx.voip_mtc.rx_config |= (pj_uint8_t) (v << 6); } break; case PJMEDIA_RTCP_XR_INFO_CONF_JBA: if (v >= 0 && v <= 3) { sess->stat.rx.voip_mtc.rx_config &= 0xCF; sess->stat.rx.voip_mtc.rx_config |= (pj_uint8_t) (v << 4); } break; case PJMEDIA_RTCP_XR_INFO_CONF_JBR: if (v >= 0 && v <= 15) { sess->stat.rx.voip_mtc.rx_config &= 0xF0; sess->stat.rx.voip_mtc.rx_config |= (pj_uint8_t) v; } break; case PJMEDIA_RTCP_XR_INFO_JB_NOM: sess->stat.rx.voip_mtc.jb_nom = (pj_uint16_t) v; break; case PJMEDIA_RTCP_XR_INFO_JB_MAX: sess->stat.rx.voip_mtc.jb_max = (pj_uint16_t) v; break; case PJMEDIA_RTCP_XR_INFO_JB_ABS_MAX: sess->stat.rx.voip_mtc.jb_abs_max = (pj_uint16_t) v; break; default: return PJ_EINVAL; } return PJ_SUCCESS; }
0
215,948
ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp) { mp_limb_t u1, u0; mp_size_t n; n = 2*p->size; u1 = rp[--n]; u0 = rp[n-1]; /* This is not particularly fast, but should work well with assembly implementation. */ for (; n >= p->size; n--) { mp_limb_t q2, q1, q0, t, cy; /* <q2, q1, q0> = v * u1 + <u1,u0>, with v = 2^32 - 1: +---+---+ | u1| u0| +---+---+ |-u1| +-+-+-+ | u1| +---+-+-+-+-+ | q2| q1| q0| +---+---+---+ */ q1 = u1 - (u1 > u0); q0 = u0 - u1; t = u1 << 32; q0 += t; t = (u1 >> 32) + (q0 < t) + 1; q1 += t; q2 = q1 < t; /* Compute candidate remainder */ u1 = u0 + (q1 << 32) - q1; t = -(mp_limb_t) (u1 > q0); u1 -= t & 0xffffffff; q1 += t; q2 += t + (q1 < t); assert (q2 < 2); /* We multiply by two low limbs of p, 2^96 - 1, so we could use shifts rather than mul. */ t = mpn_submul_1 (rp + n - 4, p->m, 2, q1); t += cnd_sub_n (q2, rp + n - 3, p->m, 1); t += (-q2) & 0xffffffff; u0 = rp[n-2]; cy = (u0 < t); u0 -= t; t = (u1 < cy); u1 -= cy; u1 += cnd_add_n (t, rp + n - 4, p->m, 3); u1 -= (-t) & 0xffffffff; } rp[2] = u0; rp[3] = u1; }
1
259,226
static void mov_build_index(MOVContext *mov, AVStream *st) { MOVStreamContext *sc = st->priv_data; FFStream *const sti = ffstream(st); int64_t current_offset; int64_t current_dts = 0; unsigned int stts_index = 0; unsigned int stsc_index = 0; unsigned int stss_index = 0; unsigned int stps_index = 0; unsigned int i, j; uint64_t stream_size = 0; MOVCtts *ctts_data_old = sc->ctts_data; unsigned int ctts_count_old = sc->ctts_count; int ret = build_open_gop_key_points(st); if (ret < 0) return; if (sc->elst_count) { int i, edit_start_index = 0, multiple_edits = 0; int64_t empty_duration = 0; // empty duration of the first edit list entry int64_t start_time = 0; // start time of the media for (i = 0; i < sc->elst_count; i++) { const MOVElst *e = &sc->elst_data[i]; if (i == 0 && e->time == -1) { /* if empty, the first entry is the start time of the stream * relative to the presentation itself */ empty_duration = e->duration; edit_start_index = 1; } else if (i == edit_start_index && e->time >= 0) { start_time = e->time; } else { multiple_edits = 1; } } if (multiple_edits && !mov->advanced_editlist) av_log(mov->fc, AV_LOG_WARNING, "multiple edit list entries, " "Use -advanced_editlist to correctly decode otherwise " "a/v desync might occur\n"); /* adjust first dts according to edit list */ if ((empty_duration || start_time) && mov->time_scale > 0) { if (empty_duration) empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale); if (av_sat_sub64(start_time, empty_duration) != start_time - (uint64_t)empty_duration) av_log(mov->fc, AV_LOG_WARNING, "start_time - empty_duration is not representable\n"); sc->time_offset = start_time - (uint64_t)empty_duration; sc->min_corrected_pts = start_time; if (!mov->advanced_editlist) current_dts = -sc->time_offset; } if (!multiple_edits && !mov->advanced_editlist && st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0) sc->start_pad = start_time; } /* only use old uncompressed audio chunk demuxing when stts specifies it */ if (!(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && sc->stts_count == 1 && sc->stts_data[0].duration == 1)) { unsigned int current_sample = 0; unsigned int stts_sample = 0; unsigned int sample_size; unsigned int distance = 0; unsigned int rap_group_index = 0; unsigned int rap_group_sample = 0; int rap_group_present = sc->rap_group_count && sc->rap_group; int key_off = (sc->keyframe_count && sc->keyframes[0] > 0) || (sc->stps_count && sc->stps_data[0] > 0); current_dts -= sc->dts_shift; if (!sc->sample_count || sti->nb_index_entries) return; if (sc->sample_count >= UINT_MAX / sizeof(*sti->index_entries) - sti->nb_index_entries) return; if (av_reallocp_array(&sti->index_entries, sti->nb_index_entries + sc->sample_count, sizeof(*sti->index_entries)) < 0) { sti->nb_index_entries = 0; return; } sti->index_entries_allocated_size = (sti->nb_index_entries + sc->sample_count) * sizeof(*sti->index_entries); if (ctts_data_old) { // Expand ctts entries such that we have a 1-1 mapping with samples if (sc->sample_count >= UINT_MAX / sizeof(*sc->ctts_data)) return; sc->ctts_count = 0; sc->ctts_allocated_size = 0; sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, sc->sample_count * sizeof(*sc->ctts_data)); if (!sc->ctts_data) { av_free(ctts_data_old); return; } memset((uint8_t*)(sc->ctts_data), 0, sc->ctts_allocated_size); for (i = 0; i < ctts_count_old && sc->ctts_count < sc->sample_count; i++) for (j = 0; j < ctts_data_old[i].count && sc->ctts_count < sc->sample_count; j++) add_ctts_entry(&sc->ctts_data, &sc->ctts_count, &sc->ctts_allocated_size, 1, ctts_data_old[i].duration); av_free(ctts_data_old); } for (i = 0; i < sc->chunk_count; i++) { int64_t next_offset = i+1 < sc->chunk_count ? sc->chunk_offsets[i+1] : INT64_MAX; current_offset = sc->chunk_offsets[i]; while (mov_stsc_index_valid(stsc_index, sc->stsc_count) && i + 1 == sc->stsc_data[stsc_index + 1].first) stsc_index++; if (next_offset > current_offset && sc->sample_size>0 && sc->sample_size < sc->stsz_sample_size && sc->stsc_data[stsc_index].count * (int64_t)sc->stsz_sample_size > next_offset - current_offset) { av_log(mov->fc, AV_LOG_WARNING, "STSZ sample size %d invalid (too large), ignoring\n", sc->stsz_sample_size); sc->stsz_sample_size = sc->sample_size; } if (sc->stsz_sample_size>0 && sc->stsz_sample_size < sc->sample_size) { av_log(mov->fc, AV_LOG_WARNING, "STSZ sample size %d invalid (too small), ignoring\n", sc->stsz_sample_size); sc->stsz_sample_size = sc->sample_size; } for (j = 0; j < sc->stsc_data[stsc_index].count; j++) { int keyframe = 0; if (current_sample >= sc->sample_count) { av_log(mov->fc, AV_LOG_ERROR, "wrong sample count\n"); return; } if (!sc->keyframe_absent && (!sc->keyframe_count || current_sample+key_off == sc->keyframes[stss_index])) { keyframe = 1; if (stss_index + 1 < sc->keyframe_count) stss_index++; } else if (sc->stps_count && current_sample+key_off == sc->stps_data[stps_index]) { keyframe = 1; if (stps_index + 1 < sc->stps_count) stps_index++; } if (rap_group_present && rap_group_index < sc->rap_group_count) { if (sc->rap_group[rap_group_index].index > 0) keyframe = 1; if (++rap_group_sample == sc->rap_group[rap_group_index].count) { rap_group_sample = 0; rap_group_index++; } } if (sc->keyframe_absent && !sc->stps_count && !rap_group_present && (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || (i==0 && j==0))) keyframe = 1; if (keyframe) distance = 0; sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample]; if (sc->pseudo_stream_id == -1 || sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) { AVIndexEntry *e; if (sample_size > 0x3FFFFFFF) { av_log(mov->fc, AV_LOG_ERROR, "Sample size %u is too large\n", sample_size); return; } e = &sti->index_entries[sti->nb_index_entries++]; e->pos = current_offset; e->timestamp = current_dts; e->size = sample_size; e->min_distance = distance; e->flags = keyframe ? AVINDEX_KEYFRAME : 0; av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", " "size %u, distance %u, keyframe %d\n", st->index, current_sample, current_offset, current_dts, sample_size, distance, keyframe); if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sti->nb_index_entries < 100) ff_rfps_add_frame(mov->fc, st, current_dts); } current_offset += sample_size; stream_size += sample_size; current_dts += sc->stts_data[stts_index].duration; distance++; stts_sample++; current_sample++; if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) { stts_sample = 0; stts_index++; } } } if (st->duration > 0) st->codecpar->bit_rate = stream_size*8*sc->time_scale/st->duration; } else { unsigned chunk_samples, total = 0; if (!sc->chunk_count) return; // compute total chunk count for (i = 0; i < sc->stsc_count; i++) { unsigned count, chunk_count; chunk_samples = sc->stsc_data[i].count; if (i != sc->stsc_count - 1 && sc->samples_per_frame && chunk_samples % sc->samples_per_frame) { av_log(mov->fc, AV_LOG_ERROR, "error unaligned chunk\n"); return; } if (sc->samples_per_frame >= 160) { // gsm count = chunk_samples / sc->samples_per_frame; } else if (sc->samples_per_frame > 1) { unsigned samples = (1024/sc->samples_per_frame)*sc->samples_per_frame; count = (chunk_samples+samples-1) / samples; } else { count = (chunk_samples+1023) / 1024; } if (mov_stsc_index_valid(i, sc->stsc_count)) chunk_count = sc->stsc_data[i+1].first - sc->stsc_data[i].first; else chunk_count = sc->chunk_count - (sc->stsc_data[i].first - 1); total += chunk_count * count; } av_log(mov->fc, AV_LOG_TRACE, "chunk count %u\n", total); if (total >= UINT_MAX / sizeof(*sti->index_entries) - sti->nb_index_entries) return; if (av_reallocp_array(&sti->index_entries, sti->nb_index_entries + total, sizeof(*sti->index_entries)) < 0) { sti->nb_index_entries = 0; return; } sti->index_entries_allocated_size = (sti->nb_index_entries + total) * sizeof(*sti->index_entries); // populate index for (i = 0; i < sc->chunk_count; i++) { current_offset = sc->chunk_offsets[i]; if (mov_stsc_index_valid(stsc_index, sc->stsc_count) && i + 1 == sc->stsc_data[stsc_index + 1].first) stsc_index++; chunk_samples = sc->stsc_data[stsc_index].count; while (chunk_samples > 0) { AVIndexEntry *e; unsigned size, samples; if (sc->samples_per_frame > 1 && !sc->bytes_per_frame) { avpriv_request_sample(mov->fc, "Zero bytes per frame, but %d samples per frame", sc->samples_per_frame); return; } if (sc->samples_per_frame >= 160) { // gsm samples = sc->samples_per_frame; size = sc->bytes_per_frame; } else { if (sc->samples_per_frame > 1) { samples = FFMIN((1024 / sc->samples_per_frame)* sc->samples_per_frame, chunk_samples); size = (samples / sc->samples_per_frame) * sc->bytes_per_frame; } else { samples = FFMIN(1024, chunk_samples); size = samples * sc->sample_size; } } if (sti->nb_index_entries >= total) { av_log(mov->fc, AV_LOG_ERROR, "wrong chunk count %u\n", total); return; } if (size > 0x3FFFFFFF) { av_log(mov->fc, AV_LOG_ERROR, "Sample size %u is too large\n", size); return; } e = &sti->index_entries[sti->nb_index_entries++]; e->pos = current_offset; e->timestamp = current_dts; e->size = size; e->min_distance = 0; e->flags = AVINDEX_KEYFRAME; av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, chunk %u, offset %"PRIx64", dts %"PRId64", " "size %u, duration %u\n", st->index, i, current_offset, current_dts, size, samples); current_offset += size; current_dts += samples; chunk_samples -= samples; } } } if (!mov->ignore_editlist && mov->advanced_editlist) { // Fix index according to edit lists. mov_fix_index(mov, st); } // Update start time of the stream. if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sti->nb_index_entries > 0) { st->start_time = sti->index_entries[0].timestamp + sc->dts_shift; if (sc->ctts_data) { st->start_time += sc->ctts_data[0].duration; } } mov_estimate_video_delay(mov, st); }
0
513,134
static bool register_builtin(struct st_maria_plugin *plugin, struct st_plugin_int *tmp, struct st_plugin_int **ptr) { DBUG_ENTER("register_builtin"); tmp->ref_count= 0; tmp->plugin_dl= 0; if (insert_dynamic(&plugin_array, (uchar*)&tmp)) DBUG_RETURN(1); *ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1, struct st_plugin_int **)= (struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)tmp, sizeof(struct st_plugin_int)); if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr)) DBUG_RETURN(1); DBUG_RETURN(0); }
0
274,650
callbacks_show_selection_on_invisible (GtkMenuItem *menuitem, gpointer user_data) { mainProject->show_invisible_selection = GTK_CHECK_MENU_ITEM(menuitem)->active; render_refresh_rendered_image_on_screen(); }
0
202,125
_inplace_src_spans (void *abstract_renderer, int y, int h, const cairo_half_open_span_t *spans, unsigned num_spans) { cairo_image_span_renderer_t *r = abstract_renderer; uint8_t *m; int x0; if (num_spans == 0) return CAIRO_STATUS_SUCCESS; x0 = spans[0].x; m = r->_buf; do { int len = spans[1].x - spans[0].x; if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) { if (spans[0].x != x0) { #if PIXMAN_HAS_OP_LERP pixman_image_composite32 (PIXMAN_OP_LERP_SRC, r->src, r->mask, r->u.composite.dst, x0 + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, x0, y, spans[0].x - x0, h); #else pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE, r->mask, NULL, r->u.composite.dst, 0, 0, 0, 0, x0, y, spans[0].x - x0, h); pixman_image_composite32 (PIXMAN_OP_ADD, r->src, r->mask, r->u.composite.dst, x0 + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, x0, y, spans[0].x - x0, h); #endif } pixman_image_composite32 (PIXMAN_OP_SRC, r->src, NULL, r->u.composite.dst, spans[0].x + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, spans[0].x, y, spans[1].x - spans[0].x, h); m = r->_buf; x0 = spans[1].x; } else if (spans[0].coverage == 0x0) { if (spans[0].x != x0) { #if PIXMAN_HAS_OP_LERP pixman_image_composite32 (PIXMAN_OP_LERP_SRC, r->src, r->mask, r->u.composite.dst, x0 + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, x0, y, spans[0].x - x0, h); #else pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE, r->mask, NULL, r->u.composite.dst, 0, 0, 0, 0, x0, y, spans[0].x - x0, h); pixman_image_composite32 (PIXMAN_OP_ADD, r->src, r->mask, r->u.composite.dst, x0 + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, x0, y, spans[0].x - x0, h); #endif } m = r->_buf; x0 = spans[1].x; } else { *m++ = spans[0].coverage; if (len > 1) { memset (m, spans[0].coverage, --len); m += len; } } spans++; } while (--num_spans > 1); if (spans[0].x != x0) { #if PIXMAN_HAS_OP_LERP pixman_image_composite32 (PIXMAN_OP_LERP_SRC, r->src, r->mask, r->u.composite.dst, x0 + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, x0, y, spans[0].x - x0, h); #else pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE, r->mask, NULL, r->u.composite.dst, 0, 0, 0, 0, x0, y, spans[0].x - x0, h); pixman_image_composite32 (PIXMAN_OP_ADD, r->src, r->mask, r->u.composite.dst, x0 + r->u.composite.src_x, y + r->u.composite.src_y, 0, 0, x0, y, spans[0].x - x0, h); #endif } return CAIRO_STATUS_SUCCESS; }
1
477,263
static void tipc_aead_free(struct rcu_head *rp) { struct tipc_aead *aead = container_of(rp, struct tipc_aead, rcu); struct tipc_tfm *tfm_entry, *head, *tmp; if (aead->cloned) { tipc_aead_put(aead->cloned); } else { head = *get_cpu_ptr(aead->tfm_entry); put_cpu_ptr(aead->tfm_entry); list_for_each_entry_safe(tfm_entry, tmp, &head->list, list) { crypto_free_aead(tfm_entry->tfm); list_del(&tfm_entry->list); kfree(tfm_entry); } /* Free the head */ crypto_free_aead(head->tfm); list_del(&head->list); kfree(head); } free_percpu(aead->tfm_entry); kfree_sensitive(aead->key); kfree(aead); }
0
513,139
static void plugin_deinitialize(struct st_plugin_int *plugin, bool ref_check) { /* we don't want to hold the LOCK_plugin mutex as it may cause deinitialization to deadlock if plugins have worker threads with plugin locks */ mysql_mutex_assert_not_owner(&LOCK_plugin); if (plugin->plugin->status_vars) { /* historical ndb behavior caused MySQL plugins to specify status var names in full, with the plugin name prefix. this was never fixed in MySQL. MariaDB fixes that but supports MySQL style too. */ SHOW_VAR *show_vars= plugin->plugin->status_vars; SHOW_VAR tmp_array[2]= { {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, {0, 0, SHOW_UNDEF} }; if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length)) show_vars= tmp_array; remove_status_vars(show_vars); } if (plugin_type_deinitialize[plugin->plugin->type]) { if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin)) { sql_print_error("Plugin '%s' of type %s failed deinitialization", plugin->name.str, plugin_type_names[plugin->plugin->type].str); } } else if (plugin->plugin->deinit) { DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); if (plugin->plugin->deinit(plugin)) { DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", plugin->name.str)); } } plugin->state= PLUGIN_IS_UNINITIALIZED; if (ref_check && plugin->ref_count) sql_print_error("Plugin '%s' has ref_count=%d after deinitialization.", plugin->name.str, plugin->ref_count); plugin_variables_deinit(plugin); }
0
261,905
njs_string_prototype_index_of(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { int64_t from, length; njs_int_t ret; njs_value_t *this, *search, *pos, search_lvalue, pos_lvalue; njs_string_prop_t string, s; this = njs_argument(args, 0); if (njs_slow_path(njs_is_null_or_undefined(this))) { njs_type_error(vm, "cannot convert \"%s\"to object", njs_type_string(this->type)); return NJS_ERROR; } ret = njs_value_to_string(vm, this, this); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } search = njs_lvalue_arg(&search_lvalue, args, nargs, 1); ret = njs_value_to_string(vm, search, search); if (njs_slow_path(ret != NJS_OK)) { return ret; } pos = njs_lvalue_arg(&pos_lvalue, args, nargs, 2); ret = njs_value_to_integer(vm, pos, &from); if (njs_slow_path(ret != NJS_OK)) { return ret; } length = njs_string_prop(&string, this); (void) njs_string_prop(&s, search); from = njs_min(njs_max(from, 0), length); njs_set_number(&vm->retval, njs_string_index_of(&string, &s, from)); return NJS_OK; }
0
369,328
static __cold int io_uring_alloc_task_context(struct task_struct *task, struct io_ring_ctx *ctx) { struct io_uring_task *tctx; int ret; tctx = kzalloc(sizeof(*tctx), GFP_KERNEL); if (unlikely(!tctx)) return -ENOMEM; tctx->registered_rings = kcalloc(IO_RINGFD_REG_MAX, sizeof(struct file *), GFP_KERNEL); if (unlikely(!tctx->registered_rings)) { kfree(tctx); return -ENOMEM; } ret = percpu_counter_init(&tctx->inflight, 0, GFP_KERNEL); if (unlikely(ret)) { kfree(tctx->registered_rings); kfree(tctx); return ret; } tctx->io_wq = io_init_wq_offload(ctx, task); if (IS_ERR(tctx->io_wq)) { ret = PTR_ERR(tctx->io_wq); percpu_counter_destroy(&tctx->inflight); kfree(tctx->registered_rings); kfree(tctx); return ret; } xa_init(&tctx->xa); init_waitqueue_head(&tctx->wait); atomic_set(&tctx->in_idle, 0); task->io_uring = tctx; spin_lock_init(&tctx->task_lock); INIT_WQ_LIST(&tctx->task_list); INIT_WQ_LIST(&tctx->prior_task_list); init_task_work(&tctx->task_work, tctx_task_work); return 0;
0
328,948
R_API RBinJavaElementValuePair *r_bin_java_element_pair_new(ut8 *buffer, ut64 sz, ut64 buf_offset) { if (!buffer || sz < 8) { return NULL; } RBinJavaElementValuePair *evp = R_NEW0 (RBinJavaElementValuePair); if (!evp) { return NULL; } // TODO: What is the signifigance of evp element evp->element_name_idx = R_BIN_JAVA_USHORT (buffer, 0); ut64 offset = 2; evp->file_offset = buf_offset; evp->name = r_bin_java_get_utf8_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, evp->element_name_idx); if (!evp->name) { // TODO: eprintf unable to find the name for the given index eprintf ("ElementValue Name is invalid.\n"); evp->name = strdup ("UNKNOWN"); } if (offset >= sz) { free (evp); return NULL; } evp->value = r_bin_java_element_value_new (buffer + offset, sz - offset, buf_offset + offset); if (evp->value) { offset += evp->value->size; if (offset >= sz) { free (evp->value); free (evp); return NULL; } } evp->size = offset; return evp; }
0
292,239
do_dns (session *sess, char *nick, char *host, const message_tags_data *tags_data) { GResolver *res = g_resolver_get_default (); GInetAddress *addr; char *po; po = strrchr (host, '@'); if (po) host = po + 1; if (nick) EMIT_SIGNAL_TIMESTAMP (XP_TE_RESOLVINGUSER, sess, nick, host, NULL, NULL, 0, tags_data->timestamp); PrintTextf (sess, _("Looking up %s..."), host); addr = g_inet_address_new_from_string (host); if (addr) g_resolver_lookup_by_address_async (res, addr, NULL, dns_addr_callback, sess); else g_resolver_lookup_by_name_async (res, host, NULL, dns_name_callback, sess); }
0
231,699
bool getCanIgnorePathMTU() override { return false; }
0
264,663
static GF_Err BM_ParseProtoDelete(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list) { u32 flag, count; GF_Command *com = gf_sg_command_new(codec->current_graph, GF_SG_PROTO_DELETE); flag = gf_bs_read_int(bs, 1); if (flag) { count = 0; flag = gf_bs_read_int(bs, 1); while (flag) { com->del_proto_list = (u32*)gf_realloc(com->del_proto_list, sizeof(u32) * (com->del_proto_list_size+1)); com->del_proto_list[count] = gf_bs_read_int(bs, codec->info->config.ProtoIDBits); com->del_proto_list_size++; flag = gf_bs_read_int(bs, 1); } } else { flag = gf_bs_read_int(bs, 5); com->del_proto_list_size = gf_bs_read_int(bs, flag); com->del_proto_list = (u32*)gf_realloc(com->del_proto_list, sizeof(u32) * (com->del_proto_list_size)); flag = 0; while (flag<com->del_proto_list_size) { com->del_proto_list[flag] = gf_bs_read_int(bs, codec->info->config.ProtoIDBits); flag++; } } gf_list_add(com_list, com); return GF_OK; }
0
447,060
void printIFD(std::ostream& out, PrintStructureOption option, uint64_t dir_offset, int depth) { BasicIo& io = Image::io(); depth++; bool bFirst = true; // buffer bool bPrint = true; do { // Read top of directory io.seek(dir_offset, BasicIo::beg); const uint64_t entries = readData(header_.format() == Header::StandardTiff? 2: 8); const bool tooBig = entries > 500; if ( bFirst && bPrint ) { out << Internal::indent(depth) << Internal::stringFormat("STRUCTURE OF BIGTIFF FILE ") << io.path() << std::endl; if (tooBig) out << Internal::indent(depth) << "entries = " << entries << std::endl; } if (tooBig) break; // Read the dictionary for ( uint64_t i = 0; i < entries; i ++ ) { if ( bFirst && bPrint ) out << Internal::indent(depth) << " address | tag | " << " type | count | offset | value\n"; bFirst = false; const uint16_t tag = readData(2); const uint16_t type = readData(2); const uint64_t count = readData(dataSize_); const DataBuf data = io.read(dataSize_); // Read data as raw value. what should be done about it will be decided depending on type std::string sp = "" ; // output spacer //prepare to print the value // TODO: figure out what's going on with kount const uint64_t kount = isStringType(type)? (count > 32 ? 32 : count) // restrict long arrays : count > 5 ? 5 : count ; const uint32_t pad = isStringType(type) ? 1 : 0; const uint32_t size = isStringType(type) ? 1 : is2ByteType(type) ? 2 : is4ByteType(type) ? 4 : is8ByteType(type) ? 8 : 1; // #55 memory allocation crash test/data/POC8 long long allocate = (long long) (size*count + pad); if ( allocate > (long long) io.size() ) { throw Error(57); } DataBuf buf(allocate); const uint64_t offset = header_.format() == Header::StandardTiff? byteSwap4(data, 0, doSwap_): byteSwap8(data, 0, doSwap_); // big data? Use 'data' as pointer to real data const bool usePointer = (size_t) count*size > (size_t) dataSize_; if ( usePointer ) // read into buffer { size_t restore = io.tell(); // save io.seek(offset, BasicIo::beg); // position io.read(buf.pData_, count * size); // read io.seek(restore, BasicIo::beg); // restore } else // use 'data' as data :) std::memcpy(buf.pData_, data.pData_, count * size); // copy data if ( bPrint ) { const int entrySize = header_.format() == Header::StandardTiff? 12: 20; const uint64_t address = dir_offset + 2 + i * entrySize; const std::string offsetString = usePointer? Internal::stringFormat("%10u", offset): ""; out << Internal::indent(depth) << Internal::stringFormat("%8u | %#06x %-25s |%10s |%9u |%10s | ", address, tag, tagName(tag).c_str(), typeName(type), count, offsetString.c_str()); if ( isShortType(type) ) { for ( size_t k = 0 ; k < kount ; k++ ) { out << sp << byteSwap2(buf, k*size, doSwap_); sp = " "; } } else if ( isLongType(type) ) { for ( size_t k = 0 ; k < kount ; k++ ) { out << sp << byteSwap4(buf, k*size, doSwap_); sp = " "; } } else if ( isLongLongType(type) ) { for ( size_t k = 0 ; k < kount ; k++ ) { out << sp << byteSwap8(buf, k*size, doSwap_); sp = " "; } } else if ( isRationalType(type) ) { for ( size_t k = 0 ; k < kount ; k++ ) { uint32_t a = byteSwap4(buf, k*size+0, doSwap_); uint32_t b = byteSwap4(buf, k*size+4, doSwap_); out << sp << a << "/" << b; sp = " "; } } else if ( isStringType(type) ) out << sp << Internal::binaryToString(buf, kount); sp = kount == count ? "" : " ..."; out << sp << std::endl; if ( option == kpsRecursive && (tag == 0x8769 /* ExifTag */ || tag == 0x014a/*SubIFDs*/ || type == tiffIfd || type == tiffIfd8) ) { for ( size_t k = 0 ; k < count ; k++ ) { const size_t restore = io.tell(); const uint64_t ifdOffset = type == tiffIfd8? byteSwap8(buf, k*size, doSwap_): byteSwap4(buf, k*size, doSwap_); std::cerr << "tag = " << Internal::stringFormat("%#x",tag) << std::endl; printIFD(out, option, ifdOffset, depth); io.seek(restore, BasicIo::beg); } } else if ( option == kpsRecursive && tag == 0x83bb /* IPTCNAA */ ) { const size_t restore = io.tell(); // save io.seek(offset, BasicIo::beg); // position byte* bytes=new byte[count] ; // allocate memory io.read(bytes,count) ; // read io.seek(restore, BasicIo::beg); // restore IptcData::printStructure(out,bytes,count,depth); delete[] bytes; // free } else if ( option == kpsRecursive && tag == 0x927c /* MakerNote */ && count > 10) { size_t restore = io.tell(); // save uint32_t jump= 10 ; byte bytes[20] ; const char* chars = (const char*) &bytes[0] ; io.seek(dir_offset, BasicIo::beg); // position io.read(bytes,jump ) ; // read bytes[jump]=0 ; if ( ::strcmp("Nikon",chars) == 0 ) { // tag is an embedded tiff byte* bytes=new byte[count-jump] ; // allocate memory io.read(bytes,count-jump) ; // read MemIo memIo(bytes,count-jump) ; // create a file std::cerr << "Nikon makernote" << std::endl; // printTiffStructure(memIo,out,option,depth); TODO: fix it delete[] bytes ; // free } else { // tag is an IFD io.seek(0, BasicIo::beg); // position std::cerr << "makernote" << std::endl; printIFD(out,option,offset,depth); } io.seek(restore,BasicIo::beg); // restore } } } const uint64_t nextDirOffset = readData(dataSize_); dir_offset = tooBig ? 0 : nextDirOffset; out.flush(); } while (dir_offset != 0); if ( bPrint ) out << Internal::indent(depth) << "END " << io.path() << std::endl; depth--; }
0
513,016
Item *get_copy(THD *thd) { return get_item_copy<Item_cache_str_for_nullif>(thd, this); }
0
344,764
mktemp_proto(char *s, size_t len) { const char *tmpdir; int r; if ((tmpdir = getenv("TMPDIR")) != NULL) { r = snprintf(s, len, "%s/ssh-XXXXXXXXXXXX", tmpdir); if (r > 0 && (size_t)r < len) return; } r = snprintf(s, len, "/tmp/ssh-XXXXXXXXXXXX"); if (r < 0 || (size_t)r >= len) fatal_f("template string too short"); }
0
346,452
source_dbg_tick(void *cookie) { return &((source_cookie_T *)cookie)->dbg_tick; }
0
380,955
ins_bs( int c, int mode, int *inserted_space_p) { linenr_T lnum; int cc; int temp = 0; // init for GCC colnr_T save_col; colnr_T mincol; int did_backspace = FALSE; int in_indent; int oldState; int cpc[MAX_MCO]; // composing characters int call_fix_indent = FALSE; /* * can't delete anything in an empty file * can't backup past first character in buffer * can't backup past starting point unless 'backspace' > 1 * can backup to a previous line if 'backspace' == 0 */ if ( BUFEMPTY() || ( #ifdef FEAT_RIGHTLEFT !revins_on && #endif ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0) || (!can_bs(BS_START) && ((arrow_used #ifdef FEAT_JOB_CHANNEL && !bt_prompt(curbuf) #endif ) || (curwin->w_cursor.lnum == Insstart_orig.lnum && curwin->w_cursor.col <= Insstart_orig.col))) || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0 && curwin->w_cursor.col <= ai_col) || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) { vim_beep(BO_BS); return FALSE; } if (stop_arrow() == FAIL) return FALSE; in_indent = inindent(0); if (in_indent) can_cindent = FALSE; end_comment_pending = NUL; // After BS, don't auto-end comment #ifdef FEAT_RIGHTLEFT if (revins_on) // put cursor after last inserted char inc_cursor(); #endif // Virtualedit: // BACKSPACE_CHAR eats a virtual space // BACKSPACE_WORD eats all coladd // BACKSPACE_LINE eats all coladd and keeps going if (curwin->w_cursor.coladd > 0) { if (mode == BACKSPACE_CHAR) { --curwin->w_cursor.coladd; return TRUE; } if (mode == BACKSPACE_WORD) { curwin->w_cursor.coladd = 0; return TRUE; } curwin->w_cursor.coladd = 0; } /* * Delete newline! */ if (curwin->w_cursor.col == 0) { lnum = Insstart.lnum; if (curwin->w_cursor.lnum == lnum #ifdef FEAT_RIGHTLEFT || revins_on #endif ) { if (u_save((linenr_T)(curwin->w_cursor.lnum - 2), (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL) return FALSE; --Insstart.lnum; Insstart.col = (colnr_T)STRLEN(ml_get(Insstart.lnum)); } /* * In replace mode: * cc < 0: NL was inserted, delete it * cc >= 0: NL was replaced, put original characters back */ cc = -1; if (State & REPLACE_FLAG) cc = replace_pop(); // returns -1 if NL was inserted /* * In replace mode, in the line we started replacing, we only move the * cursor. */ if ((State & REPLACE_FLAG) && curwin->w_cursor.lnum <= lnum) { dec_cursor(); } else { if (!(State & VREPLACE_FLAG) || curwin->w_cursor.lnum > orig_line_count) { temp = gchar_cursor(); // remember current char --curwin->w_cursor.lnum; // When "aw" is in 'formatoptions' we must delete the space at // the end of the line, otherwise the line will be broken // again when auto-formatting. if (has_format_option(FO_AUTO) && has_format_option(FO_WHITE_PAR)) { char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); int len; len = (int)STRLEN(ptr); if (len > 0 && ptr[len - 1] == ' ') ptr[len - 1] = NUL; } (void)do_join(2, FALSE, FALSE, FALSE, FALSE); if (temp == NUL && gchar_cursor() != NUL) inc_cursor(); } else dec_cursor(); /* * In MODE_REPLACE mode we have to put back the text that was * replaced by the NL. On the replace stack is first a * NUL-terminated sequence of characters that were deleted and then * the characters that NL replaced. */ if (State & REPLACE_FLAG) { /* * Do the next ins_char() in MODE_NORMAL state, to * prevent ins_char() from replacing characters and * avoiding showmatch(). */ oldState = State; State = MODE_NORMAL; /* * restore characters (blanks) deleted after cursor */ while (cc > 0) { save_col = curwin->w_cursor.col; mb_replace_pop_ins(cc); curwin->w_cursor.col = save_col; cc = replace_pop(); } // restore the characters that NL replaced replace_pop_ins(); State = oldState; } } did_ai = FALSE; } else { /* * Delete character(s) before the cursor. */ #ifdef FEAT_RIGHTLEFT if (revins_on) // put cursor on last inserted char dec_cursor(); #endif mincol = 0; // keep indent if (mode == BACKSPACE_LINE && (curbuf->b_p_ai || cindent_on()) #ifdef FEAT_RIGHTLEFT && !revins_on #endif ) { save_col = curwin->w_cursor.col; beginline(BL_WHITE); if (curwin->w_cursor.col < save_col) { mincol = curwin->w_cursor.col; // should now fix the indent to match with the previous line call_fix_indent = TRUE; } curwin->w_cursor.col = save_col; } /* * Handle deleting one 'shiftwidth' or 'softtabstop'. */ if ( mode == BACKSPACE_CHAR && ((p_sta && in_indent) || ((get_sts_value() != 0 #ifdef FEAT_VARTABS || tabstop_count(curbuf->b_p_vsts_array) #endif ) && curwin->w_cursor.col > 0 && (*(ml_get_cursor() - 1) == TAB || (*(ml_get_cursor() - 1) == ' ' && (!*inserted_space_p || arrow_used)))))) { int ts; colnr_T vcol; colnr_T want_vcol; colnr_T start_vcol; *inserted_space_p = FALSE; // Compute the virtual column where we want to be. Since // 'showbreak' may get in the way, need to get the last column of // the previous character. getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); start_vcol = vcol; dec_cursor(); getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol); inc_cursor(); #ifdef FEAT_VARTABS if (p_sta && in_indent) { ts = (int)get_sw_value(curbuf); want_vcol = (want_vcol / ts) * ts; } else want_vcol = tabstop_start(want_vcol, get_sts_value(), curbuf->b_p_vsts_array); #else if (p_sta && in_indent) ts = (int)get_sw_value(curbuf); else ts = (int)get_sts_value(); want_vcol = (want_vcol / ts) * ts; #endif // delete characters until we are at or before want_vcol while (vcol > want_vcol && curwin->w_cursor.col > 0 && (cc = *(ml_get_cursor() - 1), VIM_ISWHITE(cc))) ins_bs_one(&vcol); // insert extra spaces until we are at want_vcol while (vcol < want_vcol) { // Remember the first char we inserted if (curwin->w_cursor.lnum == Insstart_orig.lnum && curwin->w_cursor.col < Insstart_orig.col) Insstart_orig.col = curwin->w_cursor.col; if (State & VREPLACE_FLAG) ins_char(' '); else { ins_str((char_u *)" "); if ((State & REPLACE_FLAG)) replace_push(NUL); } getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); } // If we are now back where we started delete one character. Can // happen when using 'sts' and 'linebreak'. if (vcol >= start_vcol) ins_bs_one(&vcol); } /* * Delete up to starting point, start of line or previous word. */ else { int cclass = 0, prev_cclass = 0; if (has_mbyte) cclass = mb_get_class(ml_get_cursor()); do { #ifdef FEAT_RIGHTLEFT if (!revins_on) // put cursor on char to be deleted #endif dec_cursor(); cc = gchar_cursor(); // look multi-byte character class if (has_mbyte) { prev_cclass = cclass; cclass = mb_get_class(ml_get_cursor()); } // start of word? if (mode == BACKSPACE_WORD && !vim_isspace(cc)) { mode = BACKSPACE_WORD_NOT_SPACE; temp = vim_iswordc(cc); } // end of word? else if (mode == BACKSPACE_WORD_NOT_SPACE && ((vim_isspace(cc) || vim_iswordc(cc) != temp) || prev_cclass != cclass)) { #ifdef FEAT_RIGHTLEFT if (!revins_on) #endif inc_cursor(); #ifdef FEAT_RIGHTLEFT else if (State & REPLACE_FLAG) dec_cursor(); #endif break; } if (State & REPLACE_FLAG) replace_do_bs(-1); else { if (enc_utf8 && p_deco) (void)utfc_ptr2char(ml_get_cursor(), cpc); (void)del_char(FALSE); /* * If there are combining characters and 'delcombine' is set * move the cursor back. Don't back up before the base * character. */ if (enc_utf8 && p_deco && cpc[0] != NUL) inc_cursor(); #ifdef FEAT_RIGHTLEFT if (revins_chars) { revins_chars--; revins_legal++; } if (revins_on && gchar_cursor() == NUL) break; #endif } // Just a single backspace?: if (mode == BACKSPACE_CHAR) break; } while ( #ifdef FEAT_RIGHTLEFT revins_on || #endif (curwin->w_cursor.col > mincol && (can_bs(BS_NOSTOP) || (curwin->w_cursor.lnum != Insstart_orig.lnum || curwin->w_cursor.col != Insstart_orig.col) ))); } did_backspace = TRUE; } did_si = FALSE; can_si = FALSE; can_si_back = FALSE; if (curwin->w_cursor.col <= 1) did_ai = FALSE; if (call_fix_indent) fix_indent(); /* * It's a little strange to put backspaces into the redo * buffer, but it makes auto-indent a lot easier to deal * with. */ AppendCharToRedobuff(c); // If deleted before the insertion point, adjust it if (curwin->w_cursor.lnum == Insstart_orig.lnum && curwin->w_cursor.col < Insstart_orig.col) Insstart_orig.col = curwin->w_cursor.col; // vi behaviour: the cursor moves backward but the character that // was there remains visible // Vim behaviour: the cursor moves backward and the character that // was there is erased from the screen. // We can emulate the vi behaviour by pretending there is a dollar // displayed even when there isn't. // --pkv Sun Jan 19 01:56:40 EST 2003 if (vim_strchr(p_cpo, CPO_BACKSPACE) != NULL && dollar_vcol == -1) dollar_vcol = curwin->w_virtcol; #ifdef FEAT_FOLDING // When deleting a char the cursor line must never be in a closed fold. // E.g., when 'foldmethod' is indent and deleting the first non-white // char before a Tab. if (did_backspace) foldOpenCursor(); #endif return did_backspace; }
0
274,885
TEST(ComparisonsTest, GreaterEqualBroadcast) { ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 1}, TensorType_INT32, BuiltinOperator_GREATER_EQUAL); model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3}); model.PopulateTensor<int>(model.input2(), {7}); model.Invoke(); EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, true, false)); EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4)); }
0
352,961
attributeCertificateValidate( Syntax *syntax, struct berval *in ) { BerElementBuffer berbuf; BerElement *ber = (BerElement *)&berbuf; ber_tag_t tag; ber_len_t len; ber_int_t version; int cont = 0; ber_init2( ber, in, LBER_USE_DER ); tag = ber_skip_tag( ber, &len ); /* Signed wrapper */ if ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX; tag = ber_skip_tag( ber, &len ); /* Sequence */ if ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX; tag = ber_peek_tag( ber, &len ); /* Version */ if ( tag != LBER_INTEGER ) return LDAP_INVALID_SYNTAX; tag = ber_get_int( ber, &version ); /* X.509 only allows v2 */ if ( version != SLAP_X509AC_V2 ) return LDAP_INVALID_SYNTAX; tag = ber_skip_tag( ber, &len ); /* Holder */ if ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX; ber_skip_data( ber, len ); tag = ber_skip_tag( ber, &len ); /* Issuer */ if ( tag != SLAP_X509AC_ISSUER ) return LDAP_INVALID_SYNTAX; ber_skip_data( ber, len ); tag = ber_skip_tag( ber, &len ); /* Signature */ if ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX; ber_skip_data( ber, len ); tag = ber_skip_tag( ber, &len ); /* Serial number */ if ( tag != LBER_INTEGER ) return LDAP_INVALID_SYNTAX; ber_skip_data( ber, len ); tag = ber_skip_tag( ber, &len ); /* AttCertValidityPeriod */ if ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX; ber_skip_data( ber, len ); tag = ber_skip_tag( ber, &len ); /* Attributes */ if ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX; ber_skip_data( ber, len ); tag = ber_peek_tag( ber, &len ); if ( tag == LBER_BITSTRING ) { /* issuerUniqueID */ tag = ber_skip_tag( ber, &len ); ber_skip_data( ber, len ); tag = ber_peek_tag( ber, &len ); } if ( tag == LBER_SEQUENCE ) { /* extensions or signatureAlgorithm */ tag = ber_skip_tag( ber, &len ); ber_skip_data( ber, len ); cont++; tag = ber_peek_tag( ber, &len ); } if ( tag == LBER_SEQUENCE ) { /* signatureAlgorithm */ tag = ber_skip_tag( ber, &len ); ber_skip_data( ber, len ); cont++; tag = ber_peek_tag( ber, &len ); } if ( tag == LBER_BITSTRING ) { /* Signature */ tag = ber_skip_tag( ber, &len ); ber_skip_data( ber, len ); cont++; tag = ber_peek_tag( ber, &len ); } /* Must be at end now */ if ( len != 0 || tag != LBER_DEFAULT || cont < 2 ) return LDAP_INVALID_SYNTAX; return LDAP_SUCCESS; }
0
208,505
networkstatus_parse_vote_from_string(const char *s, const char **eos_out, networkstatus_type_t ns_type) { smartlist_t *tokens = smartlist_create(); smartlist_t *rs_tokens = NULL, *footer_tokens = NULL; networkstatus_voter_info_t *voter = NULL; networkstatus_t *ns = NULL; digests_t ns_digests; const char *cert, *end_of_header, *end_of_footer, *s_dup = s; directory_token_t *tok; int ok; struct in_addr in; int i, inorder, n_signatures = 0; memarea_t *area = NULL, *rs_area = NULL; consensus_flavor_t flav = FLAV_NS; tor_assert(s); if (eos_out) *eos_out = NULL; if (router_get_networkstatus_v3_hashes(s, &ns_digests)) { log_warn(LD_DIR, "Unable to compute digest of network-status"); goto err; } area = memarea_new(); end_of_header = find_start_of_next_routerstatus(s); if (tokenize_string(area, s, end_of_header, tokens, (ns_type == NS_TYPE_CONSENSUS) ? networkstatus_consensus_token_table : networkstatus_token_table, 0)) { log_warn(LD_DIR, "Error tokenizing network-status vote header"); goto err; } ns = tor_malloc_zero(sizeof(networkstatus_t)); memcpy(&ns->digests, &ns_digests, sizeof(ns_digests)); tok = find_by_keyword(tokens, K_NETWORK_STATUS_VERSION); tor_assert(tok); if (tok->n_args > 1) { int flavor = networkstatus_parse_flavor_name(tok->args[1]); if (flavor < 0) { log_warn(LD_DIR, "Can't parse document with unknown flavor %s", escaped(tok->args[2])); goto err; } ns->flavor = flav = flavor; } if (flav != FLAV_NS && ns_type != NS_TYPE_CONSENSUS) { log_warn(LD_DIR, "Flavor found on non-consensus networkstatus."); goto err; } if (ns_type != NS_TYPE_CONSENSUS) { const char *end_of_cert = NULL; if (!(cert = strstr(s, "\ndir-key-certificate-version"))) goto err; ++cert; ns->cert = authority_cert_parse_from_string(cert, &end_of_cert); if (!ns->cert || !end_of_cert || end_of_cert > end_of_header) goto err; } tok = find_by_keyword(tokens, K_VOTE_STATUS); tor_assert(tok->n_args); if (!strcmp(tok->args[0], "vote")) { ns->type = NS_TYPE_VOTE; } else if (!strcmp(tok->args[0], "consensus")) { ns->type = NS_TYPE_CONSENSUS; } else if (!strcmp(tok->args[0], "opinion")) { ns->type = NS_TYPE_OPINION; } else { log_warn(LD_DIR, "Unrecognized vote status %s in network-status", escaped(tok->args[0])); goto err; } if (ns_type != ns->type) { log_warn(LD_DIR, "Got the wrong kind of v3 networkstatus."); goto err; } if (ns->type == NS_TYPE_VOTE || ns->type == NS_TYPE_OPINION) { tok = find_by_keyword(tokens, K_PUBLISHED); if (parse_iso_time(tok->args[0], &ns->published)) goto err; ns->supported_methods = smartlist_create(); tok = find_opt_by_keyword(tokens, K_CONSENSUS_METHODS); if (tok) { for (i=0; i < tok->n_args; ++i) smartlist_add(ns->supported_methods, tor_strdup(tok->args[i])); } else { smartlist_add(ns->supported_methods, tor_strdup("1")); } } else { tok = find_opt_by_keyword(tokens, K_CONSENSUS_METHOD); if (tok) { ns->consensus_method = (int)tor_parse_long(tok->args[0], 10, 1, INT_MAX, &ok, NULL); if (!ok) goto err; } else { ns->consensus_method = 1; } } tok = find_by_keyword(tokens, K_VALID_AFTER); if (parse_iso_time(tok->args[0], &ns->valid_after)) goto err; tok = find_by_keyword(tokens, K_FRESH_UNTIL); if (parse_iso_time(tok->args[0], &ns->fresh_until)) goto err; tok = find_by_keyword(tokens, K_VALID_UNTIL); if (parse_iso_time(tok->args[0], &ns->valid_until)) goto err; tok = find_by_keyword(tokens, K_VOTING_DELAY); tor_assert(tok->n_args >= 2); ns->vote_seconds = (int) tor_parse_long(tok->args[0], 10, 0, INT_MAX, &ok, NULL); if (!ok) goto err; ns->dist_seconds = (int) tor_parse_long(tok->args[1], 10, 0, INT_MAX, &ok, NULL); if (!ok) goto err; if (ns->valid_after + MIN_VOTE_INTERVAL > ns->fresh_until) { log_warn(LD_DIR, "Vote/consensus freshness interval is too short"); goto err; } if (ns->valid_after + MIN_VOTE_INTERVAL*2 > ns->valid_until) { log_warn(LD_DIR, "Vote/consensus liveness interval is too short"); goto err; } if (ns->vote_seconds < MIN_VOTE_SECONDS) { log_warn(LD_DIR, "Vote seconds is too short"); goto err; } if (ns->dist_seconds < MIN_DIST_SECONDS) { log_warn(LD_DIR, "Dist seconds is too short"); goto err; } if ((tok = find_opt_by_keyword(tokens, K_CLIENT_VERSIONS))) { ns->client_versions = tor_strdup(tok->args[0]); } if ((tok = find_opt_by_keyword(tokens, K_SERVER_VERSIONS))) { ns->server_versions = tor_strdup(tok->args[0]); } tok = find_by_keyword(tokens, K_KNOWN_FLAGS); ns->known_flags = smartlist_create(); inorder = 1; for (i = 0; i < tok->n_args; ++i) { smartlist_add(ns->known_flags, tor_strdup(tok->args[i])); if (i>0 && strcmp(tok->args[i-1], tok->args[i])>= 0) { log_warn(LD_DIR, "%s >= %s", tok->args[i-1], tok->args[i]); inorder = 0; } } if (!inorder) { log_warn(LD_DIR, "known-flags not in order"); goto err; } tok = find_opt_by_keyword(tokens, K_PARAMS); if (tok) { inorder = 1; ns->net_params = smartlist_create(); for (i = 0; i < tok->n_args; ++i) { int ok=0; char *eq = strchr(tok->args[i], '='); if (!eq) { log_warn(LD_DIR, "Bad element '%s' in params", escaped(tok->args[i])); goto err; } tor_parse_long(eq+1, 10, INT32_MIN, INT32_MAX, &ok, NULL); if (!ok) { log_warn(LD_DIR, "Bad element '%s' in params", escaped(tok->args[i])); goto err; } if (i > 0 && strcmp(tok->args[i-1], tok->args[i]) >= 0) { log_warn(LD_DIR, "%s >= %s", tok->args[i-1], tok->args[i]); inorder = 0; } smartlist_add(ns->net_params, tor_strdup(tok->args[i])); } if (!inorder) { log_warn(LD_DIR, "params not in order"); goto err; } } ns->voters = smartlist_create(); SMARTLIST_FOREACH_BEGIN(tokens, directory_token_t *, _tok) { tok = _tok; if (tok->tp == K_DIR_SOURCE) { tor_assert(tok->n_args >= 6); if (voter) smartlist_add(ns->voters, voter); voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t)); voter->sigs = smartlist_create(); if (ns->type != NS_TYPE_CONSENSUS) memcpy(voter->vote_digest, ns_digests.d[DIGEST_SHA1], DIGEST_LEN); voter->nickname = tor_strdup(tok->args[0]); if (strlen(tok->args[1]) != HEX_DIGEST_LEN || base16_decode(voter->identity_digest, sizeof(voter->identity_digest), tok->args[1], HEX_DIGEST_LEN) < 0) { log_warn(LD_DIR, "Error decoding identity digest %s in " "network-status vote.", escaped(tok->args[1])); goto err; } if (ns->type != NS_TYPE_CONSENSUS && tor_memneq(ns->cert->cache_info.identity_digest, voter->identity_digest, DIGEST_LEN)) { log_warn(LD_DIR,"Mismatch between identities in certificate and vote"); goto err; } voter->address = tor_strdup(tok->args[2]); if (!tor_inet_aton(tok->args[3], &in)) { log_warn(LD_DIR, "Error decoding IP address %s in network-status.", escaped(tok->args[3])); goto err; } voter->addr = ntohl(in.s_addr); voter->dir_port = (uint16_t) tor_parse_long(tok->args[4], 10, 0, 65535, &ok, NULL); if (!ok) goto err; voter->or_port = (uint16_t) tor_parse_long(tok->args[5], 10, 0, 65535, &ok, NULL); if (!ok) goto err; } else if (tok->tp == K_CONTACT) { if (!voter || voter->contact) { log_warn(LD_DIR, "contact element is out of place."); goto err; } voter->contact = tor_strdup(tok->args[0]); } else if (tok->tp == K_VOTE_DIGEST) { tor_assert(ns->type == NS_TYPE_CONSENSUS); tor_assert(tok->n_args >= 1); if (!voter || ! tor_digest_is_zero(voter->vote_digest)) { log_warn(LD_DIR, "vote-digest element is out of place."); goto err; } if (strlen(tok->args[0]) != HEX_DIGEST_LEN || base16_decode(voter->vote_digest, sizeof(voter->vote_digest), tok->args[0], HEX_DIGEST_LEN) < 0) { log_warn(LD_DIR, "Error decoding vote digest %s in " "network-status consensus.", escaped(tok->args[0])); goto err; } } } SMARTLIST_FOREACH_END(_tok); if (voter) { smartlist_add(ns->voters, voter); voter = NULL; } if (smartlist_len(ns->voters) == 0) { log_warn(LD_DIR, "Missing dir-source elements in a vote networkstatus."); goto err; } else if (ns->type != NS_TYPE_CONSENSUS && smartlist_len(ns->voters) != 1) { log_warn(LD_DIR, "Too many dir-source elements in a vote networkstatus."); goto err; } if (ns->type != NS_TYPE_CONSENSUS && (tok = find_opt_by_keyword(tokens, K_LEGACY_DIR_KEY))) { int bad = 1; if (strlen(tok->args[0]) == HEX_DIGEST_LEN) { networkstatus_voter_info_t *voter = smartlist_get(ns->voters, 0); if (base16_decode(voter->legacy_id_digest, DIGEST_LEN, tok->args[0], HEX_DIGEST_LEN)<0) bad = 1; else bad = 0; } if (bad) { log_warn(LD_DIR, "Invalid legacy key digest %s on vote.", escaped(tok->args[0])); } } /* Parse routerstatus lines. */ rs_tokens = smartlist_create(); rs_area = memarea_new(); s = end_of_header; ns->routerstatus_list = smartlist_create(); while (!strcmpstart(s, "r ")) { if (ns->type != NS_TYPE_CONSENSUS) { vote_routerstatus_t *rs = tor_malloc_zero(sizeof(vote_routerstatus_t)); if (routerstatus_parse_entry_from_string(rs_area, &s, rs_tokens, ns, rs, 0, 0)) smartlist_add(ns->routerstatus_list, rs); else { tor_free(rs->version); tor_free(rs); } } else { routerstatus_t *rs; if ((rs = routerstatus_parse_entry_from_string(rs_area, &s, rs_tokens, NULL, NULL, ns->consensus_method, flav))) smartlist_add(ns->routerstatus_list, rs); } } for (i = 1; i < smartlist_len(ns->routerstatus_list); ++i) { routerstatus_t *rs1, *rs2; if (ns->type != NS_TYPE_CONSENSUS) { vote_routerstatus_t *a = smartlist_get(ns->routerstatus_list, i-1); vote_routerstatus_t *b = smartlist_get(ns->routerstatus_list, i); rs1 = &a->status; rs2 = &b->status; } else { rs1 = smartlist_get(ns->routerstatus_list, i-1); rs2 = smartlist_get(ns->routerstatus_list, i); } if (fast_memcmp(rs1->identity_digest, rs2->identity_digest, DIGEST_LEN) >= 0) { log_warn(LD_DIR, "Vote networkstatus entries not sorted by identity " "digest"); goto err; } } /* Parse footer; check signature. */ footer_tokens = smartlist_create(); if ((end_of_footer = strstr(s, "\nnetwork-status-version "))) ++end_of_footer; else end_of_footer = s + strlen(s); if (tokenize_string(area,s, end_of_footer, footer_tokens, networkstatus_vote_footer_token_table, 0)) { log_warn(LD_DIR, "Error tokenizing network-status vote footer."); goto err; } { int found_sig = 0; SMARTLIST_FOREACH_BEGIN(footer_tokens, directory_token_t *, _tok) { tok = _tok; if (tok->tp == K_DIRECTORY_SIGNATURE) found_sig = 1; else if (found_sig) { log_warn(LD_DIR, "Extraneous token after first directory-signature"); goto err; } } SMARTLIST_FOREACH_END(_tok); } if ((tok = find_opt_by_keyword(footer_tokens, K_DIRECTORY_FOOTER))) { if (tok != smartlist_get(footer_tokens, 0)) { log_warn(LD_DIR, "Misplaced directory-footer token"); goto err; } } tok = find_opt_by_keyword(footer_tokens, K_BW_WEIGHTS); if (tok) { ns->weight_params = smartlist_create(); for (i = 0; i < tok->n_args; ++i) { int ok=0; char *eq = strchr(tok->args[i], '='); if (!eq) { log_warn(LD_DIR, "Bad element '%s' in weight params", escaped(tok->args[i])); goto err; } tor_parse_long(eq+1, 10, INT32_MIN, INT32_MAX, &ok, NULL); if (!ok) { log_warn(LD_DIR, "Bad element '%s' in params", escaped(tok->args[i])); goto err; } smartlist_add(ns->weight_params, tor_strdup(tok->args[i])); } } SMARTLIST_FOREACH_BEGIN(footer_tokens, directory_token_t *, _tok) { char declared_identity[DIGEST_LEN]; networkstatus_voter_info_t *v; document_signature_t *sig; const char *id_hexdigest = NULL; const char *sk_hexdigest = NULL; digest_algorithm_t alg = DIGEST_SHA1; tok = _tok; if (tok->tp != K_DIRECTORY_SIGNATURE) continue; tor_assert(tok->n_args >= 2); if (tok->n_args == 2) { id_hexdigest = tok->args[0]; sk_hexdigest = tok->args[1]; } else { const char *algname = tok->args[0]; int a; id_hexdigest = tok->args[1]; sk_hexdigest = tok->args[2]; a = crypto_digest_algorithm_parse_name(algname); if (a<0) { log_warn(LD_DIR, "Unknown digest algorithm %s; skipping", escaped(algname)); continue; } alg = a; } if (!tok->object_type || strcmp(tok->object_type, "SIGNATURE") || tok->object_size < 128 || tok->object_size > 512) { log_warn(LD_DIR, "Bad object type or length on directory-signature"); goto err; } if (strlen(id_hexdigest) != HEX_DIGEST_LEN || base16_decode(declared_identity, sizeof(declared_identity), id_hexdigest, HEX_DIGEST_LEN) < 0) { log_warn(LD_DIR, "Error decoding declared identity %s in " "network-status vote.", escaped(id_hexdigest)); goto err; } if (!(v = networkstatus_get_voter_by_id(ns, declared_identity))) { log_warn(LD_DIR, "ID on signature on network-status vote does not match " "any declared directory source."); goto err; } sig = tor_malloc_zero(sizeof(document_signature_t)); memcpy(sig->identity_digest, v->identity_digest, DIGEST_LEN); sig->alg = alg; if (strlen(sk_hexdigest) != HEX_DIGEST_LEN || base16_decode(sig->signing_key_digest, sizeof(sig->signing_key_digest), sk_hexdigest, HEX_DIGEST_LEN) < 0) { log_warn(LD_DIR, "Error decoding declared signing key digest %s in " "network-status vote.", escaped(sk_hexdigest)); tor_free(sig); goto err; } if (ns->type != NS_TYPE_CONSENSUS) { if (tor_memneq(declared_identity, ns->cert->cache_info.identity_digest, DIGEST_LEN)) { log_warn(LD_DIR, "Digest mismatch between declared and actual on " "network-status vote."); tor_free(sig); goto err; } } if (voter_get_sig_by_algorithm(v, sig->alg)) { /* We already parsed a vote with this algorithm from this voter. Use the first one. */ log_fn(LOG_PROTOCOL_WARN, LD_DIR, "We received a networkstatus " "that contains two votes from the same voter with the same " "algorithm. Ignoring the second vote."); tor_free(sig); continue; } if (ns->type != NS_TYPE_CONSENSUS) { if (check_signature_token(ns_digests.d[DIGEST_SHA1], DIGEST_LEN, tok, ns->cert->signing_key, 0, "network-status vote")) { tor_free(sig); goto err; } sig->good_signature = 1; } else { if (tok->object_size >= INT_MAX || tok->object_size >= SIZE_T_CEILING) { tor_free(sig); goto err; } sig->signature = tor_memdup(tok->object_body, tok->object_size); sig->signature_len = (int) tok->object_size; } smartlist_add(v->sigs, sig); ++n_signatures; } SMARTLIST_FOREACH_END(_tok); if (! n_signatures) { log_warn(LD_DIR, "No signatures on networkstatus vote."); goto err; } else if (ns->type == NS_TYPE_VOTE && n_signatures != 1) { log_warn(LD_DIR, "Received more than one signature on a " "network-status vote."); goto err; } if (eos_out) *eos_out = end_of_footer; goto done; err: dump_desc(s_dup, "v3 networkstatus"); networkstatus_vote_free(ns); ns = NULL; done: if (tokens) { SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t)); smartlist_free(tokens); } if (voter) { if (voter->sigs) { SMARTLIST_FOREACH(voter->sigs, document_signature_t *, sig, document_signature_free(sig)); smartlist_free(voter->sigs); } tor_free(voter->nickname); tor_free(voter->address); tor_free(voter->contact); tor_free(voter); } if (rs_tokens) { SMARTLIST_FOREACH(rs_tokens, directory_token_t *, t, token_clear(t)); smartlist_free(rs_tokens); } if (footer_tokens) { SMARTLIST_FOREACH(footer_tokens, directory_token_t *, t, token_clear(t)); smartlist_free(footer_tokens); } if (area) { DUMP_AREA(area, "v3 networkstatus"); memarea_drop_all(area); } if (rs_area) memarea_drop_all(rs_area); return ns; }
1
513,138
static void report_error(int where_to, uint error, ...) { va_list args; DBUG_ASSERT(where_to & (REPORT_TO_USER | REPORT_TO_LOG)); if (where_to & REPORT_TO_USER) { va_start(args, error); my_printv_error(error, ER(error), MYF(0), args); va_end(args); } if (where_to & REPORT_TO_LOG) { va_start(args, error); error_log_print(ERROR_LEVEL, ER_DEFAULT(error), args); va_end(args); } }
0
369,391
static __cold void io_ring_ctx_free(struct io_ring_ctx *ctx) { io_sq_thread_finish(ctx); if (ctx->mm_account) { mmdrop(ctx->mm_account); ctx->mm_account = NULL; } io_rsrc_refs_drop(ctx); /* __io_rsrc_put_work() may need uring_lock to progress, wait w/o it */ io_wait_rsrc_data(ctx->buf_data); io_wait_rsrc_data(ctx->file_data); mutex_lock(&ctx->uring_lock); if (ctx->buf_data) __io_sqe_buffers_unregister(ctx); if (ctx->file_data) __io_sqe_files_unregister(ctx); if (ctx->rings) __io_cqring_overflow_flush(ctx, true); io_eventfd_unregister(ctx); io_flush_apoll_cache(ctx); mutex_unlock(&ctx->uring_lock); io_destroy_buffers(ctx); if (ctx->sq_creds) put_cred(ctx->sq_creds); /* there are no registered resources left, nobody uses it */ if (ctx->rsrc_node) io_rsrc_node_destroy(ctx->rsrc_node); if (ctx->rsrc_backup_node) io_rsrc_node_destroy(ctx->rsrc_backup_node); flush_delayed_work(&ctx->rsrc_put_work); flush_delayed_work(&ctx->fallback_work); WARN_ON_ONCE(!list_empty(&ctx->rsrc_ref_list)); WARN_ON_ONCE(!llist_empty(&ctx->rsrc_put_llist)); #if defined(CONFIG_UNIX) if (ctx->ring_sock) { ctx->ring_sock->file = NULL; /* so that iput() is called */ sock_release(ctx->ring_sock); } #endif WARN_ON_ONCE(!list_empty(&ctx->ltimeout_list)); io_mem_free(ctx->rings); io_mem_free(ctx->sq_sqes); percpu_ref_exit(&ctx->refs); free_uid(ctx->user); io_req_caches_free(ctx); if (ctx->hash_map) io_wq_put_hash(ctx->hash_map); kfree(ctx->cancel_hash); kfree(ctx->dummy_ubuf); kfree(ctx->io_buffers); kfree(ctx);
0
139,235
void OverlayWindowViews::OnNativeBlur() { if (is_initialized_) UpdateControlsVisibility(false); views::Widget::OnNativeBlur(); }
0
254,750
njs_typed_array_get_string_tag(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { njs_value_t *this; static const njs_value_t *tags[NJS_OBJ_TYPE_TYPED_ARRAY_SIZE] = { &njs_typed_array_uint8_tag, &njs_typed_array_uint8_clamped_tag, &njs_typed_array_int8_tag, &njs_typed_array_uint16_tag, &njs_typed_array_int16_tag, &njs_typed_array_uint32_tag, &njs_typed_array_int32_tag, &njs_typed_array_float32_tag, &njs_typed_array_float64_tag, }; this = njs_argument(args, 0); if (!njs_is_typed_array(this)) { njs_set_undefined(&vm->retval); return NJS_OK; } vm->retval = *tags[njs_typed_array_index(njs_typed_array(this)->type)]; return NJS_OK; }
0
247,330
static void pgpPrtHex(const char *pre, const uint8_t *p, size_t plen) { char *hex = NULL; if (!_print) return; if (pre && *pre) fprintf(stderr, "%s", pre); hex = pgpHexStr(p, plen); fprintf(stderr, " %s", hex); free(hex); }
0
248,298
DLLIMPORT double cfg_getnfloat(cfg_t *cfg, const char *name, unsigned int index) { return cfg_opt_getnfloat(cfg_getopt(cfg, name), index); }
0
489,142
struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc, union sctp_addr *laddr, struct sockaddr *addrs, int addrcnt, __be16 flags) { sctp_addip_param_t param; struct sctp_chunk *retval; union sctp_addr_param addr_param; union sctp_addr *addr; void *addr_buf; struct sctp_af *af; int paramlen = sizeof(param); int addr_param_len = 0; int totallen = 0; int i; /* Get total length of all the address parameters. */ addr_buf = addrs; for (i = 0; i < addrcnt; i++) { addr = (union sctp_addr *)addr_buf; af = sctp_get_af_specific(addr->v4.sin_family); addr_param_len = af->to_addr_param(addr, &addr_param); totallen += paramlen; totallen += addr_param_len; addr_buf += af->sockaddr_len; } /* Create an asconf chunk with the required length. */ retval = sctp_make_asconf(asoc, laddr, totallen); if (!retval) return NULL; /* Add the address parameters to the asconf chunk. */ addr_buf = addrs; for (i = 0; i < addrcnt; i++) { addr = (union sctp_addr *)addr_buf; af = sctp_get_af_specific(addr->v4.sin_family); addr_param_len = af->to_addr_param(addr, &addr_param); param.param_hdr.type = flags; param.param_hdr.length = htons(paramlen + addr_param_len); param.crr_id = i; sctp_addto_chunk(retval, paramlen, &param); sctp_addto_chunk(retval, addr_param_len, &addr_param); addr_buf += af->sockaddr_len; } return retval; }
0
482,500
deallocateRuleNames(TranslationTableHeader *table) { RuleName **ruleName = &table->ruleNames; while (*ruleName) { RuleName *rn = *ruleName; *ruleName = rn->next; free(rn); } }
0
314,511
static void parse_version(pj_scanner *scanner, volatile parse_context *ctx) { ctx->last_error = PJMEDIA_SDP_EINVER; /* check equal sign */ if (*(scanner->curptr+1) != '=') { on_scanner_error(scanner); return; } /* check version is 0 */ if (*(scanner->curptr+2) != '0') { on_scanner_error(scanner); return; } /* We've got what we're looking for, skip anything until newline */ pj_scan_skip_line(scanner); }
0
274,754
static int ntfs_attr_map_partial_runlist(ntfs_attr *na, VCN vcn) { VCN last_vcn; VCN highest_vcn; VCN needed; runlist_element *rl; ATTR_RECORD *a; BOOL startseen; ntfs_attr_search_ctx *ctx; BOOL done; BOOL newrunlist; if (NAttrFullyMapped(na)) return 0; ctx = ntfs_attr_get_search_ctx(na->ni, NULL); if (!ctx) return -1; /* Get the last vcn in the attribute. */ last_vcn = na->allocated_size >> na->ni->vol->cluster_size_bits; needed = vcn; highest_vcn = 0; startseen = FALSE; done = FALSE; rl = (runlist_element*)NULL; do { newrunlist = FALSE; /* Find the attribute in the mft record. */ if (!ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE, needed, NULL, 0, ctx)) { a = ctx->attr; /* Decode and merge the runlist. */ if (ntfs_rl_vcn_to_lcn(na->rl, needed) == LCN_RL_NOT_MAPPED) { rl = ntfs_mapping_pairs_decompress(na->ni->vol, a, na->rl); newrunlist = TRUE; } else rl = na->rl; if (rl) { na->rl = rl; highest_vcn = sle64_to_cpu(a->highest_vcn); if (highest_vcn < needed) { /* corruption detection on unchanged runlists */ if (newrunlist && ((highest_vcn + 1) < last_vcn)) { ntfs_log_error("Corrupt attribute list\n"); rl = (runlist_element*)NULL; errno = EIO; } done = TRUE; } needed = highest_vcn + 1; if (!a->lowest_vcn) startseen = TRUE; } } else { done = TRUE; } } while (rl && !done && (needed < last_vcn)); ntfs_attr_put_search_ctx(ctx); /* * Make sure we reached the end, unless the last * runlist was modified earlier (using HOLES_DELAY * leads to have a visibility over attributes which * have not yet been fully updated) */ if (done && newrunlist && (needed < last_vcn)) { ntfs_log_error("End of runlist not reached\n"); rl = (runlist_element*)NULL; errno = EIO; } /* mark fully mapped if we did so */ if (rl && startseen) NAttrSetFullyMapped(na); return (rl ? 0 : -1); }
0
223,480
static void delayed_mem_copy_move(delayed_mem_copy_status *status, int load_base, sljit_sw load_offset, int store_base, sljit_sw store_offset) { struct sljit_compiler *compiler = status->compiler; int next_tmp_reg = status->next_tmp_reg; int tmp_reg = status->tmp_regs[next_tmp_reg]; SLJIT_ASSERT(load_base > 0 && store_base > 0); if (status->store_bases[next_tmp_reg] == -1) { /* Preserve virtual registers. */ if (sljit_get_register_index(status->saved_tmp_regs[next_tmp_reg]) < 0) OP1(SLJIT_MOV, status->saved_tmp_regs[next_tmp_reg], 0, tmp_reg, 0); } else OP1(SLJIT_MOV, SLJIT_MEM1(status->store_bases[next_tmp_reg]), status->store_offsets[next_tmp_reg], tmp_reg, 0); OP1(SLJIT_MOV, tmp_reg, 0, SLJIT_MEM1(load_base), load_offset); status->store_bases[next_tmp_reg] = store_base; status->store_offsets[next_tmp_reg] = store_offset; status->next_tmp_reg = (next_tmp_reg + 1) % RECURSE_TMP_REG_COUNT; }
0
90,107
virtual void AddNetworkManagerObserver(NetworkManagerObserver* observer) {}
0
415,210
cmd_pksign (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); int rc; unsigned char *outdata; size_t outdatalen; char *keyidstr; int hash_algo; if (has_option (line, "--hash=rmd160")) hash_algo = GCRY_MD_RMD160; else if (has_option (line, "--hash=sha1")) hash_algo = GCRY_MD_SHA1; else if (has_option (line, "--hash=sha224")) hash_algo = GCRY_MD_SHA224; else if (has_option (line, "--hash=sha256")) hash_algo = GCRY_MD_SHA256; else if (has_option (line, "--hash=sha384")) hash_algo = GCRY_MD_SHA384; else if (has_option (line, "--hash=sha512")) hash_algo = GCRY_MD_SHA512; else if (has_option (line, "--hash=md5")) hash_algo = GCRY_MD_MD5; else if (!strstr (line, "--")) hash_algo = GCRY_MD_SHA1; else return set_error (GPG_ERR_ASS_PARAMETER, "invalid hash algorithm"); line = skip_options (line); if ( IS_LOCKED (ctrl) ) return gpg_error (GPG_ERR_LOCKED); if ((rc = open_card (ctrl, NULL))) return rc; /* We have to use a copy of the key ID because the function may use the pin_cb which in turn uses the assuan line buffer and thus overwriting the original line with the keyid */ keyidstr = xtrystrdup (line); if (!keyidstr) return out_of_core (); rc = app_sign (ctrl->app_ctx, keyidstr, hash_algo, pin_cb, ctx, ctrl->in_data.value, ctrl->in_data.valuelen, &outdata, &outdatalen); xfree (keyidstr); if (rc) { log_error ("app_sign failed: %s\n", gpg_strerror (rc)); } else { rc = assuan_send_data (ctx, outdata, outdatalen); xfree (outdata); if (rc) return rc; /* that is already an assuan error code */ } TEST_CARD_REMOVAL (ctrl, rc); return rc; }
0
274,739
static void parea_report (gerbv_net_t *net, gerbv_image_t *img, gerbv_project_t *prj) { gerbv_net_t *n; unsigned int c = 0; gerbv_interpolation_t inter_prev; double x, y; if (net->interpolation != GERBV_INTERPOLATION_PAREA_START) return; /* Count vertices */ for (gerbv_net_t *n = net->next; n != NULL; n = n->next) { if (n->interpolation == GERBV_INTERPOLATION_PAREA_END) break; c++; } g_message (_(" Number of vertices: %u"), c - 1); for (n = net->next, inter_prev = net->interpolation; n != NULL && n->interpolation != GERBV_INTERPOLATION_PAREA_END; n = n->next) { switch (n->interpolation) { case GERBV_INTERPOLATION_LINEARx1: if (inter_prev != n->interpolation) { x = n->start_x; y = n->start_y; gerbv_transform_coord_for_image(&x, &y, img, prj); g_message (_(" Line from: (%g, %g) %s"), screen_units(x), screen_units(y), screen_units_str()); } x = n->stop_x; y = n->stop_y; gerbv_transform_coord_for_image(&x, &y, img, prj); g_message (_(" Line to: (%g, %g) %s"), screen_units(x), screen_units(y), screen_units_str()); break; case GERBV_INTERPOLATION_CW_CIRCULAR: case GERBV_INTERPOLATION_CCW_CIRCULAR: x = n->start_x; y = n->start_y; gerbv_transform_coord_for_image(&x, &y, img, prj); g_message (_(" Arc from: (%g, %g) %s"), screen_units(x), screen_units(y), screen_units_str()); x = n->stop_x; y = n->stop_y; gerbv_transform_coord_for_image(&x, &y, img, prj); g_message (_(" Arc to: (%g, %g) %s"), screen_units(x), screen_units(y), screen_units_str()); x = n->cirseg->cp_x; y = n->cirseg->cp_y; gerbv_transform_coord_for_image(&x, &y, img, prj); g_message (_(" Center: (%g, %g) %s"), screen_units(x), screen_units(y), screen_units_str()); x = n->cirseg->width; y = n->cirseg->height; gerbv_transform_coord_for_image(&x, &y, img, prj); g_message (_(" Radius: %g %s"), screen_units(x)/2, screen_units_str()); g_message (_(" Angle: %g deg"), fabs(n->cirseg->angle1 - n->cirseg->angle2)); g_message (_(" Angles: (%g, %g) deg"), n->cirseg->angle1, n->cirseg->angle2); g_message (_(" Direction: %s"), (n->interpolation == GERBV_INTERPOLATION_CW_CIRCULAR)? _("CW"): _("CCW")); break; default: g_message(" Skipping interpolation: %s", _(gerbv_interpolation_name(n->interpolation))); } inter_prev = n->interpolation; } }
0
356,686
bool OtherInstanceOf(Napi::Object source, const char* object_type) { if (strncmp(object_type, "Date", 4) == 0) { return source.InstanceOf(source.Env().Global().Get("Date").As<Function>()); } else if (strncmp(object_type, "RegExp", 6) == 0) { return source.InstanceOf(source.Env().Global().Get("RegExp").As<Function>()); } return false; }
0
254,899
Value DocumentSourceGroup::computeId(const Document& root) { // If only one expression, return result directly if (_idExpressions.size() == 1) { Value retValue = _idExpressions[0]->evaluate(root, &pExpCtx->variables); return retValue.missing() ? Value(BSONNULL) : std::move(retValue); } // Multiple expressions get results wrapped in a vector vector<Value> vals; vals.reserve(_idExpressions.size()); for (size_t i = 0; i < _idExpressions.size(); i++) { vals.push_back(_idExpressions[i]->evaluate(root, &pExpCtx->variables)); } return Value(std::move(vals)); }
0
301,019
pcx24b_print_page(gx_device_printer * pdev, gp_file * file) { pcx_header header; header = pcx_header_prototype; header.version = version_3_0; header.bpp = 8; header.nplanes = 3; assign_ushort(header.palinfo, palinfo_color); return pcx_write_page(pdev, file, &header, true); }
0
359,466
DEFUN (bgp_default_local_preference, bgp_default_local_preference_cmd, "bgp default local-preference <0-4294967295>", "BGP specific commands\n" "Configure BGP defaults\n" "local preference (higher=more preferred)\n" "Configure default local preference value\n") { struct bgp *bgp; u_int32_t local_pref; bgp = vty->index; VTY_GET_INTEGER ("local preference", local_pref, argv[0]); bgp_default_local_preference_set (bgp, local_pref); return CMD_SUCCESS; }
0
512,618
Item_bool_rowready_func2* Le_creator::create(THD *thd, Item *a, Item *b) const { return new(thd->mem_root) Item_func_le(thd, a, b); }
0
214,276
static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr) { struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; struct tipc_aead_key *skey = NULL; u16 key_gen = msg_key_gen(hdr); u16 size = msg_data_sz(hdr); u8 *data = msg_data(hdr); spin_lock(&rx->lock); if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) { pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name, rx->skey, key_gen, rx->key_gen); goto exit; } /* Allocate memory for the key */ skey = kmalloc(size, GFP_ATOMIC); if (unlikely(!skey)) { pr_err("%s: unable to allocate memory for skey\n", rx->name); goto exit; } /* Copy key from msg data */ skey->keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME))); memcpy(skey->alg_name, data, TIPC_AEAD_ALG_NAME); memcpy(skey->key, data + TIPC_AEAD_ALG_NAME + sizeof(__be32), skey->keylen); /* Sanity check */ if (unlikely(size != tipc_aead_key_size(skey))) { kfree(skey); skey = NULL; goto exit; } rx->key_gen = key_gen; rx->skey_mode = msg_key_mode(hdr); rx->skey = skey; rx->nokey = 0; mb(); /* for nokey flag */ exit: spin_unlock(&rx->lock); /* Schedule the key attaching on this crypto */ if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0))) return true; return false; }
1
459,205
void tcf_exts_destroy(struct tcf_exts *exts) { #ifdef CONFIG_NET_CLS_ACT if (exts->actions) { tcf_action_destroy(exts->actions, TCA_ACT_UNBIND); kfree(exts->actions); } exts->nr_actions = 0; #endif }
0
310,076
chop_out(char *string, unsigned i, unsigned j) { TR(TRACE_DATABASE, ("chop_out %d..%d from %s", i, j, _nc_visbuf(string))); while (string[j] != '\0') { string[i++] = string[j++]; } string[i] = '\0'; return i; }
0
326,915
static void vidtv_s302m_write_frames(struct vidtv_encoder *e) { struct vidtv_access_unit *au = e->access_units; struct vidtv_s302m_ctx *ctx = e->ctx; u32 nbytes_per_unit = 0; u32 nbytes = 0; u32 au_sz = 0; u16 sample; u32 j; while (au) { au_sz = au->num_samples * sizeof(struct vidtv_s302m_frame_16); nbytes_per_unit = vidtv_s302m_write_h(e, au_sz); for (j = 0; j < au->num_samples; ++j) { sample = vidtv_s302m_get_sample(e); nbytes_per_unit += vidtv_s302m_write_frame(e, sample); if (e->src_buf) e->src_buf_offset += sizeof(u16); e->sample_count++; } au->nbytes = nbytes_per_unit; if (au_sz + sizeof(struct vidtv_smpte_s302m_es) != nbytes_per_unit) { pr_warn_ratelimited("write size was %u, expected %zu\n", nbytes_per_unit, au_sz + sizeof(struct vidtv_smpte_s302m_es)); } nbytes += nbytes_per_unit; au->offset = nbytes - nbytes_per_unit; nbytes_per_unit = 0; ctx->au_count++; au = au->next; } }
0
336,668
SPICE_GNUC_VISIBLE int spice_server_get_peer_info(SpiceServer *reds, struct sockaddr *sa, socklen_t *salen) { return -1; }
0
90,879
void reset_status_callback_count() { status_callback_count_ = 0; }
0
326,619
set_xattrs(struct archive_write_disk *a) { struct archive_entry *entry = a->entry; struct archive_string errlist; int ret = ARCHIVE_OK; int i = archive_entry_xattr_reset(entry); short fail = 0; archive_string_init(&errlist); while (i--) { const char *name; const void *value; size_t size; int e; archive_entry_xattr_next(entry, &name, &value, &size); if (name == NULL) continue; #if ARCHIVE_XATTR_LINUX /* Linux: quietly skip POSIX.1e ACL extended attributes */ if (strncmp(name, "system.", 7) == 0 && (strcmp(name + 7, "posix_acl_access") == 0 || strcmp(name + 7, "posix_acl_default") == 0)) continue; if (strncmp(name, "trusted.SGI_", 12) == 0 && (strcmp(name + 12, "ACL_DEFAULT") == 0 || strcmp(name + 12, "ACL_FILE") == 0)) continue; /* Linux: xfsroot namespace is obsolete and unsupported */ if (strncmp(name, "xfsroot.", 8) == 0) { fail = 1; archive_strcat(&errlist, name); archive_strappend_char(&errlist, ' '); continue; } #endif if (a->fd >= 0) { #if ARCHIVE_XATTR_LINUX e = fsetxattr(a->fd, name, value, size, 0); #elif ARCHIVE_XATTR_DARWIN e = fsetxattr(a->fd, name, value, size, 0, 0); #elif ARCHIVE_XATTR_AIX e = fsetea(a->fd, name, value, size, 0); #endif } else { #if ARCHIVE_XATTR_LINUX e = lsetxattr(archive_entry_pathname(entry), name, value, size, 0); #elif ARCHIVE_XATTR_DARWIN e = setxattr(archive_entry_pathname(entry), name, value, size, 0, XATTR_NOFOLLOW); #elif ARCHIVE_XATTR_AIX e = lsetea(archive_entry_pathname(entry), name, value, size, 0); #endif } if (e == -1) { ret = ARCHIVE_WARN; archive_strcat(&errlist, name); archive_strappend_char(&errlist, ' '); if (errno != ENOTSUP && errno != ENOSYS) fail = 1; } } if (ret == ARCHIVE_WARN) { if (fail && errlist.length > 0) { errlist.length--; errlist.s[errlist.length] = '\0'; archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Cannot restore extended attributes: %s", errlist.s); } else archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Cannot restore extended " "attributes on this file system."); } archive_string_free(&errlist); return (ret); }
0
233,865
static void wrap_in_tiff(deark *c, dbuf *f, i64 dpos, i64 dlen, const char *swstring, unsigned int tag, const char *ext, unsigned int createflags) { dbuf *outf = NULL; i64 ifdoffs; i64 sw_len, sw_len_padded; i64 data_len_padded; sw_len = 1+(i64)de_strlen(swstring); if(sw_len<=4) return; sw_len_padded = de_pad_to_2(sw_len); if(dlen>4) { data_len_padded = de_pad_to_2(dlen); } else { data_len_padded = 0; } outf = dbuf_create_output_file(c, ext, NULL, 0); dbuf_write(outf, (const u8*)"\x4d\x4d\x00\x2a", 4); ifdoffs = 8 + sw_len_padded + data_len_padded; dbuf_writeu32be(outf, ifdoffs); dbuf_write(outf, (const u8*)swstring, sw_len); if(sw_len%2) dbuf_writebyte(outf, 0); if(dlen>4) { dbuf_copy(f, dpos, dlen, outf); if(dlen%2) dbuf_writebyte(outf, 0); } dbuf_writeu16be(outf, 2); // number of dir entries; dbuf_writeu16be(outf, 305); // Software tag dbuf_writeu16be(outf, 2); // type=ASCII dbuf_writeu32be(outf, sw_len); dbuf_writeu32be(outf, 8); // offset dbuf_writeu16be(outf, (i64)tag); dbuf_writeu16be(outf, 1); dbuf_writeu32be(outf, dlen); if(dlen>4) { dbuf_writeu32be(outf, 8+sw_len_padded); } else { dbuf_copy(f, dpos, dlen, outf); dbuf_write_zeroes(outf, 4-dlen); } dbuf_writeu32be(outf, 0); // end of IFD dbuf_close(outf); }
0
217,565
static MagickBooleanType GetICCProperty(const Image *image,const char *property) { const StringInfo *profile; /* Return ICC profile property. */ magick_unreferenced(property); profile=GetImageProfile(image,"icc"); if (profile == (StringInfo *) NULL) profile=GetImageProfile(image,"icm"); if (profile == (StringInfo *) NULL) return(MagickFalse); if (GetStringInfoLength(profile) < 128) return(MagickFalse); /* minimum ICC profile length */ #if defined(MAGICKCORE_LCMS_DELEGATE) { cmsHPROFILE icc_profile; icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile), (cmsUInt32Number) GetStringInfoLength(profile)); if (icc_profile != (cmsHPROFILE *) NULL) { #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000) const char *name; name=cmsTakeProductName(icc_profile); if (name != (const char *) NULL) (void) SetImageProperty((Image *) image,"icc:name",name); #else StringInfo *info; unsigned int extent; info=AcquireStringInfo(0); extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,"en","US", NULL,0); if (extent != 0) { SetStringInfoLength(info,extent+1); extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,"en", "US",(char *) GetStringInfoDatum(info),extent); if (extent != 0) (void) SetImageProperty((Image *) image,"icc:description", (char *) GetStringInfoDatum(info)); } extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,"en","US", NULL,0); if (extent != 0) { SetStringInfoLength(info,extent+1); extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,"en", "US",(char *) GetStringInfoDatum(info),extent); if (extent != 0) (void) SetImageProperty((Image *) image,"icc:manufacturer", (char *) GetStringInfoDatum(info)); } extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en","US", NULL,0); if (extent != 0) { SetStringInfoLength(info,extent+1); extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en","US", (char *) GetStringInfoDatum(info),extent); if (extent != 0) (void) SetImageProperty((Image *) image,"icc:model", (char *) GetStringInfoDatum(info)); } extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,"en","US", NULL,0); if (extent != 0) { SetStringInfoLength(info,extent+1); extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,"en", "US",(char *) GetStringInfoDatum(info),extent); if (extent != 0) (void) SetImageProperty((Image *) image,"icc:copyright", (char *) GetStringInfoDatum(info)); } info=DestroyStringInfo(info); #endif (void) cmsCloseProfile(icc_profile); } } #endif return(MagickTrue); }
0
349,270
static int parse_exports_table(long long *table_start) { /* * Note on overflow limits: * Size of SBlk.s.inodes is 2^32 (unsigned int) * Max indexes is (2^32*8)/8K or 2^22 * Max length is ((2^32*8)/8K)*8 or 2^25 */ int res; int indexes = SQUASHFS_LOOKUP_BLOCKS((long long) sBlk.s.inodes); int length = SQUASHFS_LOOKUP_BLOCK_BYTES((long long) sBlk.s.inodes); long long *export_index_table; /* * The size of the index table (length bytes) should match the * table start and end points */ if(length != (*table_start - sBlk.s.lookup_table_start)) { ERROR("parse_exports_table: Bad inode count in super block\n"); return FALSE; } export_index_table = alloc_index_table(indexes); res = read_fs_bytes(fd, sBlk.s.lookup_table_start, length, export_index_table); if(res == FALSE) { ERROR("parse_exports_table: failed to read export index table\n"); return FALSE; } SQUASHFS_INSWAP_LOOKUP_BLOCKS(export_index_table, indexes); /* * export_index_table[0] stores the start of the compressed export blocks. * This by definition is also the end of the previous filesystem * table - the fragment table. */ *table_start = export_index_table[0]; return TRUE; }
0
246,739
u32 parse_senc_param(char *arg_val, u32 opt) { switch (opt) { case 0: //-sync smenc_opts.flags |= GF_SM_ENCODE_RAP_INBAND; smenc_opts.rap_freq = atoi(arg_val); break; case 1: //-shadow smenc_opts.flags &= ~GF_SM_ENCODE_RAP_INBAND; smenc_opts.flags |= GF_SM_ENCODE_RAP_SHADOW; smenc_opts.rap_freq = atoi(arg_val); break; case 2: //-carousel smenc_opts.flags &= ~(GF_SM_ENCODE_RAP_INBAND | GF_SM_ENCODE_RAP_SHADOW); smenc_opts.rap_freq = atoi(arg_val); break; case 3: //-auto-quant smenc_opts.resolution = atoi(arg_val); smenc_opts.auto_quant = 1; break; case 4: //-global-quant smenc_opts.resolution = atoi(arg_val); smenc_opts.auto_quant = 2; break; case 5: //-ctx-in or -inctx chunk_mode = GF_TRUE; input_ctx = arg_val; } return 0; }
0
225,829
GF_Err def_parent_box_write(GF_Box *s, GF_BitStream *bs) { return gf_isom_box_write_header(s, bs); }
0
522,327
void GmfSetFloatPrecision(int64_t MshIdx , int FltSiz) { GmfMshSct *msh = (GmfMshSct *)MshIdx; if(FltSiz != 32 && FltSiz != 64) return; msh->FltSiz = FltSiz; GmfSetKwd(MshIdx, GmfFloatingPointPrecision, 1); GmfSetLin(MshIdx, GmfFloatingPointPrecision, FltSiz); }
0
313,140
testStorageLookup(const void *args) { const struct testLookupData *data = args; int ret = 0; virStorageSourcePtr result; virStorageSourcePtr actualParent; unsigned int idx; if (virStorageFileParseChainIndex(data->target, data->name, &idx) < 0 && data->expIndex) { fprintf(stderr, "call should not have failed\n"); ret = -1; } if (idx != data->expIndex) { fprintf(stderr, "index: expected %u, got %u\n", data->expIndex, idx); ret = -1; } /* Test twice to ensure optional parameter doesn't cause NULL deref. */ result = virStorageFileChainLookup(data->chain, data->from, idx ? NULL : data->name, idx, NULL); if (!data->expResult) { if (virGetLastErrorCode() == VIR_ERR_OK) { fprintf(stderr, "call should have failed\n"); ret = -1; } virResetLastError(); } else { if (virGetLastErrorCode()) { fprintf(stderr, "call should not have warned\n"); ret = -1; } } if (!result) { if (data->expResult) { fprintf(stderr, "result 1: expected %s, got NULL\n", data->expResult); ret = -1; } } else if (STRNEQ_NULLABLE(data->expResult, result->path)) { fprintf(stderr, "result 1: expected %s, got %s\n", NULLSTR(data->expResult), NULLSTR(result->path)); ret = -1; } result = virStorageFileChainLookup(data->chain, data->from, data->name, idx, &actualParent); if (!data->expResult) virResetLastError(); if (!result) { if (data->expResult) { fprintf(stderr, "result 2: expected %s, got NULL\n", data->expResult); ret = -1; } } else if (STRNEQ_NULLABLE(data->expResult, result->path)) { fprintf(stderr, "result 2: expected %s, got %s\n", NULLSTR(data->expResult), NULLSTR(result->path)); ret = -1; } if (data->expMeta != result) { fprintf(stderr, "meta: expected %p, got %p\n", data->expMeta, result); ret = -1; } if (data->expParent != actualParent) { fprintf(stderr, "parent: expected %s, got %s\n", NULLSTR(data->expParent ? data->expParent->path : NULL), NULLSTR(actualParent ? actualParent->path : NULL)); ret = -1; } return ret; }
0
224,220
static RRBNode *_find_entry_submap_node(RIOBank *bank, RIOSubMap *sm) { RRBNode *node = r_crbtree_find_node (bank->submaps, sm, _find_lowest_intersection_sm_cb, NULL); if (!node) { return NULL; } RRBNode *prev = r_rbnode_prev (node); while (prev && r_io_submap_overlap (((RIOSubMap *)prev->data), sm)) { node = prev; prev = r_rbnode_prev (node); } return node; }
0
411,922
dump_distinct_digest_count(int severity) { #ifdef COUNT_DISTINCT_DIGESTS if (!verified_digests) verified_digests = digestmap_new(); log(severity, LD_GENERAL, "%d *distinct* router digests verified", digestmap_size(verified_digests)); #else (void)severity; /* suppress "unused parameter" warning */ #endif }
0
359,515
safi2str (safi_t safi) { if (safi == SAFI_UNICAST) return "SAFI_UNICAST"; else if (safi == SAFI_MULTICAST) return "SAFI_MULTICAST"; else if (safi == SAFI_MPLS_VPN || safi == BGP_SAFI_VPNV4) return "SAFI_MPLS_VPN"; else return "Unknown SAFI"; }
0
252,346
static mz_bool mz_zip_writer_add_to_central_dir( mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) { mz_zip_internal_state *pState = pZip->m_pState; mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; size_t orig_central_dir_size = pState->m_central_dir.m_size; mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; // No zip64 support yet if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_central_dir_header( pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) return MZ_FALSE; if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &central_dir_ofs, 1))) { // Try to push the central directory array back into its original state. mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } return MZ_TRUE; }
0
292,245
inbound_join (server *serv, char *chan, char *user, char *ip, char *account, char *realname, const message_tags_data *tags_data) { session *sess = find_channel (serv, chan); if (sess) { EMIT_SIGNAL_TIMESTAMP (XP_TE_JOIN, sess, user, chan, ip, account, 0, tags_data->timestamp); userlist_add (sess, user, ip, account, realname, tags_data); } }
0
513,220
static void update_func_str(THD *thd, struct st_mysql_sys_var *var, void *tgt, const void *save) { char *value= *(char**) save; if (var->flags & PLUGIN_VAR_MEMALLOC) { char *old= *(char**) tgt; if (value) *(char**) tgt= my_strdup(value, MYF(0)); else *(char**) tgt= 0; my_free(old); } else *(char**) tgt= value; }
0
313,555
void rose_rt_device_down(struct net_device *dev) { struct rose_neigh *s, *rose_neigh; struct rose_node *t, *rose_node; int i; spin_lock_bh(&rose_node_list_lock); spin_lock_bh(&rose_neigh_list_lock); rose_neigh = rose_neigh_list; while (rose_neigh != NULL) { s = rose_neigh; rose_neigh = rose_neigh->next; if (s->dev != dev) continue; rose_node = rose_node_list; while (rose_node != NULL) { t = rose_node; rose_node = rose_node->next; for (i = 0; i < t->count; i++) { if (t->neighbour[i] != s) continue; t->count--; switch (i) { case 0: t->neighbour[0] = t->neighbour[1]; fallthrough; case 1: t->neighbour[1] = t->neighbour[2]; break; case 2: break; } } if (t->count <= 0) rose_remove_node(t); } rose_remove_neigh(s); } spin_unlock_bh(&rose_neigh_list_lock); spin_unlock_bh(&rose_node_list_lock); }
0