idx
int64
func
string
target
int64
512,917
Item *in_decimal::create_item(THD *thd) { return new (thd->mem_root) Item_decimal(thd, 0, FALSE); }
0
344,806
exited_cleanly(pid_t pid, const char *tag, const char *cmd, int quiet) { int status; while (waitpid(pid, &status, 0) == -1) { if (errno != EINTR) { error("%s waitpid: %s", tag, strerror(errno)); return -1; } } if (WIFSIGNALED(status)) { error("%s %s exited on signal %d", tag, cmd, WTERMSIG(status)); return -1; } else if (WEXITSTATUS(status) != 0) { do_log2(quiet ? SYSLOG_LEVEL_DEBUG1 : SYSLOG_LEVEL_INFO, "%s %s failed, status %d", tag, cmd, WEXITSTATUS(status)); return -1; } return 0; }
0
313,732
nv_scroll(cmdarg_T *cap) { int used = 0; long n; #ifdef FEAT_FOLDING linenr_T lnum; #endif int half; cap->oap->motion_type = MLINE; setpcmark(); if (cap->cmdchar == 'L') { validate_botline(); // make sure curwin->w_botline is valid curwin->w_cursor.lnum = curwin->w_botline - 1; if (cap->count1 - 1 >= curwin->w_cursor.lnum) curwin->w_cursor.lnum = 1; else { #ifdef FEAT_FOLDING if (hasAnyFolding(curwin)) { // Count a fold for one screen line. for (n = cap->count1 - 1; n > 0 && curwin->w_cursor.lnum > curwin->w_topline; --n) { (void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL); --curwin->w_cursor.lnum; } } else #endif curwin->w_cursor.lnum -= cap->count1 - 1; } } else { if (cap->cmdchar == 'M') { #ifdef FEAT_DIFF // Don't count filler lines above the window. used -= diff_check_fill(curwin, curwin->w_topline) - curwin->w_topfill; #endif validate_botline(); // make sure w_empty_rows is valid half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) { #ifdef FEAT_DIFF // Count half he number of filler lines to be "below this // line" and half to be "above the next line". if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline + n) / 2 >= half) { --n; break; } #endif used += plines(curwin->w_topline + n); if (used >= half) break; #ifdef FEAT_FOLDING if (hasFolding(curwin->w_topline + n, NULL, &lnum)) n = lnum - curwin->w_topline; #endif } if (n > 0 && used > curwin->w_height) --n; } else // (cap->cmdchar == 'H') { n = cap->count1 - 1; #ifdef FEAT_FOLDING if (hasAnyFolding(curwin)) { // Count a fold for one screen line. lnum = curwin->w_topline; while (n-- > 0 && lnum < curwin->w_botline - 1) { (void)hasFolding(lnum, NULL, &lnum); ++lnum; } n = lnum - curwin->w_topline; } #endif } curwin->w_cursor.lnum = curwin->w_topline + n; if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; } // Correct for 'so', except when an operator is pending. if (cap->oap->op_type == OP_NOP) cursor_correct(); beginline(BL_SOL | BL_FIX); }
0
238,605
static int check_tp_buffer_access(struct bpf_verifier_env *env, const struct bpf_reg_state *reg, int regno, int off, int size) { int err; err = __check_buffer_access(env, "tracepoint", reg, regno, off, size); if (err) return err; if (off + size > env->prog->aux->max_tp_access) env->prog->aux->max_tp_access = off + size; return 0; }
0
312,451
wipe_qf_buffer(qf_info_T *qi) { buf_T *qfbuf; if (qi->qf_bufnr != INVALID_QFBUFNR) { qfbuf = buflist_findnr(qi->qf_bufnr); if (qfbuf != NULL && qfbuf->b_nwindows == 0) { // If the quickfix buffer is not loaded in any window, then // wipe the buffer. close_buffer(NULL, qfbuf, DOBUF_WIPE, FALSE, FALSE); qi->qf_bufnr = INVALID_QFBUFNR; } } }
0
455,179
MOBI_RET mobi_load_rec(MOBIData *m, FILE *file) { MOBI_RET ret; if (m == NULL) { debug_print("%s", "Mobi structure not initialized\n"); return MOBI_INIT_FAILED; } MOBIPdbRecord *curr = m->rec; while (curr != NULL) { MOBIPdbRecord *next; size_t size; if (curr->next != NULL) { next = curr->next; size = next->offset - curr->offset; } else { fseek(file, 0, SEEK_END); long diff = ftell(file) - curr->offset; if (diff <= 0) { debug_print("Wrong record size: %li\n", diff); return MOBI_DATA_CORRUPT; } size = (size_t) diff; next = NULL; } curr->size = size; ret = mobi_load_recdata(curr, file); if (ret != MOBI_SUCCESS) { debug_print("Error loading record uid %i data\n", curr->uid); mobi_free_rec(m); return ret; } curr = next; } return MOBI_SUCCESS; }
0
508,894
init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex) { TABLE_LIST *table_list; Table_ident *table_ident; SELECT_LEX *select_lex= &lex->select_lex; Name_resolution_context *context= &select_lex->context; /* We will call the parser to create a part_info struct based on the partition string stored in the frm file. We will use a local lex object for this purpose. However we also need to set the Name_resolution_object for this lex object. We do this by using add_table_to_list where we add the table that we're working with to the Name_resolution_context. */ thd->lex= lex; lex_start(thd); context->init(); if ((!(table_ident= new Table_ident(thd, table->s->table_name, table->s->db, TRUE))) || (!(table_list= select_lex->add_table_to_list(thd, table_ident, NULL, 0)))) return TRUE; context->resolve_in_table_list_only(table_list); lex->use_only_table_context= TRUE; lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VCOL_EXPR; select_lex->cur_pos_in_select_list= UNDEF_POS; table->map= 1; //To ensure correct calculation of const item table_list->table= table; table_list->cacheable_table= false; return FALSE; }
0
338,053
Name WasmBinaryBuilder::getInlineString() { BYN_TRACE("<==\n"); auto len = getU32LEB(); auto data = getByteView(len); std::string str(data.first, data.second); if (str.find('\0') != std::string::npos) { throwError( "inline string contains NULL (0). that is technically valid in wasm, " "but you shouldn't do it, and it's not supported in binaryen"); } BYN_TRACE("getInlineString: " << str << " ==>\n"); return Name(str); }
0
230,146
static int validate_safetynet_ca_root(json_t * j_params, gnutls_x509_crt_t cert_leaf, json_t * j_header_x5c) { gnutls_x509_crt_t cert_x509[(json_array_size(j_header_x5c)+1)], root_x509 = NULL; gnutls_x509_trust_list_t tlist = NULL; int ret = G_OK; unsigned int result, i; json_t * j_cert; unsigned char * header_cert_decoded; size_t header_cert_decoded_len; gnutls_datum_t cert_dat; cert_x509[0] = cert_leaf; for (i=1; i<json_array_size(j_header_x5c); i++) { j_cert = json_array_get(j_header_x5c, i); if ((header_cert_decoded = o_malloc(json_string_length(j_cert))) != NULL) { if (o_base64_decode((const unsigned char *)json_string_value(j_cert), json_string_length(j_cert), header_cert_decoded, &header_cert_decoded_len)) { if (!gnutls_x509_crt_init(&cert_x509[i])) { cert_dat.data = header_cert_decoded; cert_dat.size = header_cert_decoded_len; if ((ret = gnutls_x509_crt_import(cert_x509[i], &cert_dat, GNUTLS_X509_FMT_DER)) < 0) { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error gnutls_x509_crt_import: %d", ret); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error gnutls_x509_crt_init"); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error o_base64_decode x5c leaf"); ret = G_ERROR; } o_free(header_cert_decoded); } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error allocating resources for header_cert_decoded"); ret = G_ERROR_MEMORY; } } if (ret == G_OK) { cert_dat.data = (unsigned char *)json_string_value(json_object_get(json_object_get(j_params, "google-root-ca-r2-content"), "x509")); cert_dat.size = json_string_length(json_object_get(json_object_get(j_params, "google-root-ca-r2-content"), "x509")); if (!gnutls_x509_crt_init(&cert_x509[json_array_size(j_header_x5c)]) && !gnutls_x509_crt_import(cert_x509[json_array_size(j_header_x5c)], &cert_dat, GNUTLS_X509_FMT_PEM)) { if (!gnutls_x509_crt_init(&root_x509) && !gnutls_x509_crt_import(root_x509, &cert_dat, GNUTLS_X509_FMT_PEM)) { if (!gnutls_x509_trust_list_init(&tlist, 0)) { if (gnutls_x509_trust_list_add_cas(tlist, &root_x509, 1, 0) >= 0) { if (gnutls_x509_trust_list_verify_crt(tlist, cert_x509, (json_array_size(j_header_x5c)+1), 0, &result, NULL) >= 0) { if (!result) { ret = G_OK; } else { y_log_message(Y_LOG_LEVEL_DEBUG, "validate_safetynet_ca_root - certificate chain invalid"); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error gnutls_x509_trust_list_verify_crt"); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error gnutls_x509_trust_list_add_cas"); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error gnutls_x509_trust_list_init"); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error import root cert"); ret = G_ERROR; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "validate_safetynet_ca_root - Error import last cert"); ret = G_ERROR; } } // Clean after me for (i=1; i<json_array_size(j_header_x5c); i++) { gnutls_x509_crt_deinit(cert_x509[i]); } gnutls_x509_crt_deinit(cert_x509[json_array_size(j_header_x5c)]); gnutls_x509_trust_list_deinit(tlist, 1); return ret; }
0
432,234
static MemTxResult flatview_write(struct uc_struct *uc, FlatView *fv, hwaddr addr, MemTxAttrs attrs, const void *buf, hwaddr len) { hwaddr l; hwaddr addr1; MemoryRegion *mr; MemTxResult result = MEMTX_OK; l = len; mr = flatview_translate(uc, fv, addr, &addr1, &l, true, attrs); result = flatview_write_continue(uc, fv, addr, attrs, buf, len, addr1, l, mr); return result; }
0
281,169
xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl, struct xfrm_state **xfrm, unsigned short family) { struct xfrm_state *tp[XFRM_MAX_DEPTH]; struct xfrm_state **tpp = (npols > 1) ? tp : xfrm; int cnx = 0; int error; int ret; int i; for (i = 0; i < npols; i++) { if (cnx + pols[i]->xfrm_nr >= XFRM_MAX_DEPTH) { error = -ENOBUFS; goto fail; } ret = xfrm_tmpl_resolve_one(pols[i], fl, &tpp[cnx], family); if (ret < 0) { error = ret; goto fail; } else cnx += ret; } /* found states are sorted for outbound processing */ if (npols > 1) xfrm_state_sort(xfrm, tpp, cnx, family); return cnx; fail: for (cnx--; cnx >= 0; cnx--) xfrm_state_put(tpp[cnx]); return error; }
0
430,448
size_t ovs_key_attr_size(void) { /* Whenever adding new OVS_KEY_ FIELDS, we should consider * updating this function. */ BUILD_BUG_ON(OVS_KEY_ATTR_MAX != 32); return nla_total_size(4) /* OVS_KEY_ATTR_PRIORITY */ + nla_total_size(0) /* OVS_KEY_ATTR_TUNNEL */ + ovs_tun_key_attr_size() + nla_total_size(4) /* OVS_KEY_ATTR_IN_PORT */ + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */ + nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */ + nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */ + nla_total_size(4) /* OVS_KEY_ATTR_CT_STATE */ + nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */ + nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */ + nla_total_size(16) /* OVS_KEY_ATTR_CT_LABELS */ + nla_total_size(40) /* OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6 */ + nla_total_size(0) /* OVS_KEY_ATTR_NSH */ + ovs_nsh_key_attr_size() + nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */ + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ + nla_total_size(4) /* OVS_KEY_ATTR_VLAN */ + nla_total_size(0) /* OVS_KEY_ATTR_ENCAP */ + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ + nla_total_size(40) /* OVS_KEY_ATTR_IPV6 */ + nla_total_size(2) /* OVS_KEY_ATTR_ICMPV6 */ + nla_total_size(28) /* OVS_KEY_ATTR_ND */ + nla_total_size(2); /* OVS_KEY_ATTR_IPV6_EXTHDRS */ }
0
292,214
inbound_cap_nak (server *serv, const message_tags_data *tags_data) { serv->sent_capend = TRUE; tcp_send_len (serv, "CAP END\r\n", 9); }
0
195,234
Status BuildInputArgIndex(const OpDef::ArgDef& arg_def, AttrSlice attr_values, const FunctionDef::ArgAttrs* arg_attrs, bool ints_on_device, int64_t resource_arg_unique_id) { bool is_type_list; DataTypeVector dtypes; TF_RETURN_IF_ERROR( ArgNumType(attr_values, arg_def, &is_type_list, &dtypes)); if (dtypes.size() < size_t{1}) { return errors::Internal("Expected a list of at least one dtype"); } int arg_index = result_.nodes.size(); TF_RETURN_IF_ERROR( AddItem(arg_def.name(), {true, arg_index, 0, is_type_list, dtypes})); // Creates dtypes.size() nodes in the graph. for (size_t i = 0; i < dtypes.size(); ++i) { TF_RETURN_IF_ERROR(AddItem(strings::StrCat(arg_def.name(), ":", i), {true, arg_index, 0, false, {dtypes[i]}})); DCHECK_EQ(arg_index, result_.nodes.size()); string name = arg_def.name(); if (dtypes.size() > 1) { strings::StrAppend(&name, "_", i); } NodeDef* gnode = AddNode(name); if (ints_on_device && dtypes[i] == DataType::DT_INT32) { gnode->set_op(FunctionLibraryDefinition::kDeviceArgOp); } else { gnode->set_op(FunctionLibraryDefinition::kArgOp); } DataType dtype = arg_def.is_ref() ? MakeRefType(dtypes[i]) : dtypes[i]; AddAttr("T", dtype, gnode); AddAttr("index", arg_index, gnode); if (resource_arg_unique_id >= 0) { AddAttr("_resource_arg_unique_id", resource_arg_unique_id, gnode); } if (arg_attrs) { for (const auto& arg_attr : arg_attrs->attr()) { AddAttr(arg_attr.first, arg_attr.second, gnode->mutable_attr()); } } result_.arg_types.push_back(dtypes[i]); ++arg_index; } return Status::OK(); }
1
313,778
nv_nop(cmdarg_T *cap UNUSED) { }
0
439,173
static MagickBooleanType WriteAAIImage(const ImageInfo *image_info,Image *image) { MagickBooleanType status; MagickOffsetType scene; register const PixelPacket *magick_restrict p; register ssize_t x; register unsigned char *magick_restrict q; size_t imageListLength; ssize_t count, y; unsigned char *pixels; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); scene=0; imageListLength=GetImageListLength(image); do { /* Write AAI header. */ (void) TransformImageColorspace(image,sRGBColorspace); (void) WriteBlobLSBLong(image,(unsigned int) image->columns); (void) WriteBlobLSBLong(image,(unsigned int) image->rows); /* Allocate memory for pixels. */ pixels=(unsigned char *) AcquireQuantumMemory(image->columns, 4*sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); /* Convert MIFF to AAI raster pixels. */ for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); if (p == (PixelPacket *) NULL) break; q=pixels; for (x=0; x < (ssize_t) image->columns; x++) { *q++=ScaleQuantumToChar(GetPixelBlue(p)); *q++=ScaleQuantumToChar(GetPixelGreen(p)); *q++=ScaleQuantumToChar(GetPixelRed(p)); *q=ScaleQuantumToChar((Quantum) (QuantumRange-(image->matte != MagickFalse ? GetPixelOpacity(p) : OpaqueOpacity))); if (*q == 255) *q=254; p++; q++; } count=WriteBlob(image,(size_t) (q-pixels),pixels); if (count != (ssize_t) (q-pixels)) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } pixels=(unsigned char *) RelinquishMagickMemory(pixels); if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); if (status == MagickFalse) break; } while (image_info->adjoin != MagickFalse); (void) CloseBlob(image); return(MagickTrue); }
0
359,598
bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi) { struct bgp_filter *filter; char orf_pfx_name[BUFSIZ]; int orf_pfx_count; filter = &p->filter[afi][safi]; vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), VTY_NEWLINE); if (p->af_group[afi][safi]) vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) { vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", ORF_TYPE_PREFIX, VTY_NEWLINE); bgp_show_peer_afi_orf_cap (vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, PEER_CAP_ORF_PREFIX_RM_ADV, PEER_CAP_ORF_PREFIX_SM_RCV, PEER_CAP_ORF_PREFIX_RM_RCV); } if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); bgp_show_peer_afi_orf_cap (vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, PEER_CAP_ORF_PREFIX_RM_ADV, PEER_CAP_ORF_PREFIX_SM_OLD_RCV, PEER_CAP_ORF_PREFIX_RM_OLD_RCV); } sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name); if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) || orf_pfx_count) { vty_out (vty, " Outbound Route Filter (ORF):"); if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) vty_out (vty, " sent;"); if (orf_pfx_count) vty_out (vty, " received (%d entries)", orf_pfx_count); vty_out (vty, "%s", VTY_NEWLINE); } if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)) vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) { vty_out (vty, " Community attribute sent to this neighbor"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) vty_out (vty, "(both)%s", VTY_NEWLINE); else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) vty_out (vty, "(extended)%s", VTY_NEWLINE); else vty_out (vty, "(standard)%s", VTY_NEWLINE); } if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) { vty_out (vty, " Default information originate,"); if (p->default_rmap[afi][safi].name) vty_out (vty, " default route-map %s%s,", p->default_rmap[afi][safi].map ? "*" : "", p->default_rmap[afi][safi].name); if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) vty_out (vty, " default sent%s", VTY_NEWLINE); else vty_out (vty, " default not sent%s", VTY_NEWLINE); } if (filter->plist[FILTER_IN].name || filter->dlist[FILTER_IN].name || filter->aslist[FILTER_IN].name || filter->map[RMAP_IN].name) vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); if (filter->plist[FILTER_OUT].name || filter->dlist[FILTER_OUT].name || filter->aslist[FILTER_OUT].name || filter->map[RMAP_OUT].name || filter->usmap.name) vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); if (filter->map[RMAP_IMPORT].name) vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE); if (filter->map[RMAP_EXPORT].name) vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE); /* prefix-list */ if (filter->plist[FILTER_IN].name) vty_out (vty, " Incoming update prefix filter list is %s%s%s", filter->plist[FILTER_IN].plist ? "*" : "", filter->plist[FILTER_IN].name, VTY_NEWLINE); if (filter->plist[FILTER_OUT].name) vty_out (vty, " Outgoing update prefix filter list is %s%s%s", filter->plist[FILTER_OUT].plist ? "*" : "", filter->plist[FILTER_OUT].name, VTY_NEWLINE); /* distribute-list */ if (filter->dlist[FILTER_IN].name) vty_out (vty, " Incoming update network filter list is %s%s%s", filter->dlist[FILTER_IN].alist ? "*" : "", filter->dlist[FILTER_IN].name, VTY_NEWLINE); if (filter->dlist[FILTER_OUT].name) vty_out (vty, " Outgoing update network filter list is %s%s%s", filter->dlist[FILTER_OUT].alist ? "*" : "", filter->dlist[FILTER_OUT].name, VTY_NEWLINE); /* filter-list. */ if (filter->aslist[FILTER_IN].name) vty_out (vty, " Incoming update AS path filter list is %s%s%s", filter->aslist[FILTER_IN].aslist ? "*" : "", filter->aslist[FILTER_IN].name, VTY_NEWLINE); if (filter->aslist[FILTER_OUT].name) vty_out (vty, " Outgoing update AS path filter list is %s%s%s", filter->aslist[FILTER_OUT].aslist ? "*" : "", filter->aslist[FILTER_OUT].name, VTY_NEWLINE); /* route-map. */ if (filter->map[RMAP_IN].name) vty_out (vty, " Route map for incoming advertisements is %s%s%s", filter->map[RMAP_IN].map ? "*" : "", filter->map[RMAP_IN].name, VTY_NEWLINE); if (filter->map[RMAP_OUT].name) vty_out (vty, " Route map for outgoing advertisements is %s%s%s", filter->map[RMAP_OUT].map ? "*" : "", filter->map[RMAP_OUT].name, VTY_NEWLINE); if (filter->map[RMAP_IMPORT].name) vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s", filter->map[RMAP_IMPORT].map ? "*" : "", filter->map[RMAP_IMPORT].name, VTY_NEWLINE); if (filter->map[RMAP_EXPORT].name) vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s", filter->map[RMAP_EXPORT].map ? "*" : "", filter->map[RMAP_EXPORT].name, VTY_NEWLINE); /* unsuppress-map */ if (filter->usmap.name) vty_out (vty, " Route map for selective unsuppress is %s%s%s", filter->usmap.map ? "*" : "", filter->usmap.name, VTY_NEWLINE); /* Receive prefix count */ vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); /* Maximum prefix */ if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) ? " (warning-only)" : "", VTY_NEWLINE); vty_out (vty, " Threshold for warning message %d%%", p->pmax_threshold[afi][safi]); if (p->pmax_restart[afi][safi]) vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); vty_out (vty, "%s", VTY_NEWLINE); } vty_out (vty, "%s", VTY_NEWLINE); }
0
249,510
Status DecodeImageAPNG(Span<const uint8_t> bytes, ThreadPool* pool, CodecInOut* io) { Reader r; unsigned int id, i, j, w, h, w0, h0, x0, y0; unsigned int delay_num, delay_den, dop, bop, rowbytes, imagesize; unsigned char sig[8]; png_structp png_ptr; png_infop info_ptr; CHUNK chunk; CHUNK chunkIHDR; std::vector<CHUNK> chunksInfo; bool isAnimated = false; bool skipFirst = false; bool hasInfo = false; bool all_dispose_bg = true; APNGFrame frameRaw = {}; r = {bytes.data(), bytes.data() + bytes.size()}; // Not an aPNG => not an error unsigned char png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; if (r.Read(sig, 8) || memcmp(sig, png_signature, 8) != 0) { return false; } id = read_chunk(&r, &chunkIHDR); io->frames.clear(); io->dec_pixels = 0; io->metadata.m.SetUintSamples(8); io->metadata.m.SetAlphaBits(8); io->metadata.m.color_encoding = ColorEncoding::SRGB(); // todo: get data from png metadata (void)io->dec_hints.Foreach( [](const std::string& key, const std::string& /*value*/) { JXL_WARNING("APNG decoder ignoring %s hint", key.c_str()); return true; }); bool errorstate = true; if (id == kId_IHDR && chunkIHDR.size == 25) { w0 = w = png_get_uint_32(chunkIHDR.p + 8); h0 = h = png_get_uint_32(chunkIHDR.p + 12); if (w > cMaxPNGSize || h > cMaxPNGSize) { return false; } x0 = 0; y0 = 0; delay_num = 1; delay_den = 10; dop = 0; bop = 0; rowbytes = w * 4; imagesize = h * rowbytes; frameRaw.p = new unsigned char[imagesize]; frameRaw.rows = new png_bytep[h * sizeof(png_bytep)]; for (j = 0; j < h; j++) frameRaw.rows[j] = frameRaw.p + j * rowbytes; if (!processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo, chunkIHDR, chunksInfo)) { bool last_base_was_none = true; while (!r.Eof()) { id = read_chunk(&r, &chunk); if (!id) break; JXL_ASSERT(chunk.p != nullptr); if (id == kId_acTL && !hasInfo && !isAnimated) { isAnimated = true; skipFirst = true; io->metadata.m.have_animation = true; io->metadata.m.animation.tps_numerator = 1000; } else if (id == kId_IEND || (id == kId_fcTL && (!hasInfo || isAnimated))) { if (hasInfo) { if (!processing_finish(png_ptr, info_ptr)) { ImageBundle bundle(&io->metadata.m); bundle.duration = delay_num * 1000 / delay_den; bundle.origin.x0 = x0; bundle.origin.y0 = y0; // TODO(veluca): this could in principle be implemented. if (last_base_was_none && !all_dispose_bg && (x0 != 0 || y0 != 0 || w0 != w || h0 != h || bop != 0)) { return JXL_FAILURE( "APNG with dispose-to-0 is not supported for non-full or " "blended frames"); } switch (dop) { case 0: bundle.use_for_next_frame = true; last_base_was_none = false; all_dispose_bg = false; break; case 2: bundle.use_for_next_frame = false; all_dispose_bg = false; break; default: bundle.use_for_next_frame = false; last_base_was_none = true; } bundle.blend = bop != 0; io->dec_pixels += w0 * h0; Image3F sub_frame(w0, h0); ImageF sub_frame_alpha(w0, h0); for (size_t y = 0; y < h0; ++y) { float* const JXL_RESTRICT row_r = sub_frame.PlaneRow(0, y); float* const JXL_RESTRICT row_g = sub_frame.PlaneRow(1, y); float* const JXL_RESTRICT row_b = sub_frame.PlaneRow(2, y); float* const JXL_RESTRICT row_alpha = sub_frame_alpha.Row(y); uint8_t* const f = frameRaw.rows[y]; for (size_t x = 0; x < w0; ++x) { if (f[4 * x + 3] == 0) { row_alpha[x] = 0; row_r[x] = 0; row_g[x] = 0; row_b[x] = 0; continue; } row_r[x] = f[4 * x + 0] * (1.f / 255); row_g[x] = f[4 * x + 1] * (1.f / 255); row_b[x] = f[4 * x + 2] * (1.f / 255); row_alpha[x] = f[4 * x + 3] * (1.f / 255); } } bundle.SetFromImage(std::move(sub_frame), ColorEncoding::SRGB()); bundle.SetAlpha(std::move(sub_frame_alpha), /*alpha_is_premultiplied=*/false); io->frames.push_back(std::move(bundle)); } else { delete[] chunk.p; break; } } if (id == kId_IEND) { errorstate = false; break; } // At this point the old frame is done. Let's start a new one. w0 = png_get_uint_32(chunk.p + 12); h0 = png_get_uint_32(chunk.p + 16); x0 = png_get_uint_32(chunk.p + 20); y0 = png_get_uint_32(chunk.p + 24); delay_num = png_get_uint_16(chunk.p + 28); delay_den = png_get_uint_16(chunk.p + 30); dop = chunk.p[32]; bop = chunk.p[33]; if (!delay_den) delay_den = 100; if (w0 > cMaxPNGSize || h0 > cMaxPNGSize || x0 > cMaxPNGSize || y0 > cMaxPNGSize || x0 + w0 > w || y0 + h0 > h || dop > 2 || bop > 1) { delete[] chunk.p; break; } if (hasInfo) { memcpy(chunkIHDR.p + 8, chunk.p + 12, 8); if (processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo, chunkIHDR, chunksInfo)) { delete[] chunk.p; break; } } else skipFirst = false; if (io->frames.size() == (skipFirst ? 1 : 0)) { bop = 0; if (dop == 2) dop = 1; } } else if (id == kId_IDAT) { hasInfo = true; if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) { delete[] chunk.p; break; } } else if (id == kId_fdAT && isAnimated) { png_save_uint_32(chunk.p + 4, chunk.size - 16); memcpy(chunk.p + 8, "IDAT", 4); if (processing_data(png_ptr, info_ptr, chunk.p + 4, chunk.size - 4)) { delete[] chunk.p; break; } } else if (!isAbc(chunk.p[4]) || !isAbc(chunk.p[5]) || !isAbc(chunk.p[6]) || !isAbc(chunk.p[7])) { delete[] chunk.p; break; } else if (!hasInfo) { if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) { delete[] chunk.p; break; } chunksInfo.push_back(chunk); continue; } delete[] chunk.p; } } delete[] frameRaw.rows; delete[] frameRaw.p; } for (i = 0; i < chunksInfo.size(); i++) delete[] chunksInfo[i].p; chunksInfo.clear(); delete[] chunkIHDR.p; if (errorstate) return false; SetIntensityTarget(io); return true; }
0
314,478
static gfn_t gpte_to_gfn_lvl(pt_element_t gpte, int lvl) { return (gpte & PT_LVL_ADDR_MASK(lvl)) >> PAGE_SHIFT; }
0
226,321
GF_Err prhd_box_size(GF_Box *s) { s->size += 12; return GF_OK;
0
244,109
void saiz_box_del(GF_Box *s) { GF_SampleAuxiliaryInfoSizeBox*ptr = (GF_SampleAuxiliaryInfoSizeBox*)s; if (ptr == NULL) return; if (ptr->sample_info_size) gf_free(ptr->sample_info_size); gf_free(ptr); }
0
244,164
void bloc_box_del(GF_Box *s) { gf_free(s); }
0
310,074
check_cursor(TERMTYPE2 *tp) { int count; char *list[4]; if (hard_copy) { check_noaddress(tp, "hard_copy"); } else if (generic_type) { check_noaddress(tp, "generic_type"); } else if (strchr(tp->term_names, '+') == 0) { int y = 0; int x = 0; if (PRESENT(column_address)) ++y; if (PRESENT(cursor_address)) y = x = 10; if (PRESENT(cursor_home)) ++y, ++x; if (PRESENT(cursor_mem_address)) y = x = 10; if (PRESENT(cursor_to_ll)) ++y, ++x; if (PRESENT(row_address)) ++x; if (PRESENT(cursor_down)) ++y; if (PRESENT(cursor_up)) ++y; if (PRESENT(cursor_left)) ++x; if (PRESENT(cursor_right)) ++x; if (x < 2 && y < 2) { _nc_warning("terminal lacks cursor addressing"); } else { if (x < 2) _nc_warning("terminal lacks cursor column-addressing"); if (y < 2) _nc_warning("terminal lacks cursor row-addressing"); } } /* it is rare to have an insert-line feature without a matching delete */ ANDMISSING(parm_insert_line, insert_line); ANDMISSING(parm_delete_line, delete_line); ANDMISSING(parm_insert_line, parm_delete_line); /* if we have a parameterized form, then the non-parameterized is easy */ ANDMISSING(parm_down_cursor, cursor_down); ANDMISSING(parm_up_cursor, cursor_up); ANDMISSING(parm_left_cursor, cursor_left); ANDMISSING(parm_right_cursor, cursor_right); /* Given any of a set of cursor movement, the whole set should be present. * Technically this is not true (we could use cursor_address to fill in * unsupported controls), but it is likely. */ count = 0; if (PRESENT(parm_down_cursor)) { list[count++] = parm_down_cursor; } if (PRESENT(parm_up_cursor)) { list[count++] = parm_up_cursor; } if (PRESENT(parm_left_cursor)) { list[count++] = parm_left_cursor; } if (PRESENT(parm_right_cursor)) { list[count++] = parm_right_cursor; } if (count == 4) { check_ansi_cursor(list); } else if (count != 0) { EXPECTED(parm_down_cursor); EXPECTED(parm_up_cursor); EXPECTED(parm_left_cursor); EXPECTED(parm_right_cursor); } count = 0; if (PRESENT(cursor_down)) { list[count++] = cursor_down; } if (PRESENT(cursor_up)) { list[count++] = cursor_up; } if (PRESENT(cursor_left)) { list[count++] = cursor_left; } if (PRESENT(cursor_right)) { list[count++] = cursor_right; } if (count == 4) { check_ansi_cursor(list); } else if (count != 0) { count = 0; if (PRESENT(cursor_down) && strcmp(cursor_down, "\n")) ++count; if (PRESENT(cursor_left) && strcmp(cursor_left, "\b")) ++count; if (PRESENT(cursor_up) && strlen(cursor_up) > 1) ++count; if (PRESENT(cursor_right) && strlen(cursor_right) > 1) ++count; if (count) { EXPECTED(cursor_down); EXPECTED(cursor_up); EXPECTED(cursor_left); EXPECTED(cursor_right); } } }
0
258,080
explicit ReverseOp(OpKernelConstruction* context) : OpKernel(context) {}
0
333,073
nfa_regcomp_start( char_u *expr, int re_flags) // see vim_regcomp() { size_t postfix_size; int nstate_max; nstate = 0; istate = 0; // A reasonable estimation for maximum size nstate_max = (int)(STRLEN(expr) + 1) * 25; // Some items blow up in size, such as [A-z]. Add more space for that. // When it is still not enough realloc_post_list() will be used. nstate_max += 1000; // Size for postfix representation of expr. postfix_size = sizeof(int) * nstate_max; post_start = alloc(postfix_size); if (post_start == NULL) return FAIL; post_ptr = post_start; post_end = post_start + nstate_max; wants_nfa = FALSE; rex.nfa_has_zend = FALSE; rex.nfa_has_backref = FALSE; // shared with BT engine regcomp_start(expr, re_flags); return OK; }
0
446,407
RZ_API ut64 rz_dyldcache_get_slide(RzDyldCache *cache) { rz_return_val_if_fail(cache, 0); if (!cache->rebase_infos || !cache->rebase_infos->length) { return 0; } size_t i; for (i = 0; i < cache->rebase_infos->length; i++) { if (cache->rebase_infos->entries[i].info) { return cache->rebase_infos->entries[i].info->slide; } } return 0; }
0
231,754
void initializeServerHandshake() override { fakeHandshake = new FakeServerHandshake( server->getNonConstConn(), FizzServerQuicHandshakeContext::Builder().build(), GetParam().chloSync, GetParam().cfinSync); if (GetParam().acceptZeroRtt) { fakeHandshake->allowZeroRttKeys(); } }
0
443,149
static int jfs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) { int ret; ret = nobh_write_begin(mapping, pos, len, flags, pagep, fsdata, jfs_get_block); if (unlikely(ret)) jfs_write_failed(mapping, pos + len); return ret; }
0
301,400
static int vfswrap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode) { #ifdef HAVE_NO_ACL errno = ENOSYS; return -1; #else int result; START_PROFILE(chmod_acl); result = chmod_acl(handle->conn, name, mode); END_PROFILE(chmod_acl); return result; #endif }
0
366,338
static inline void mnt_unhold_writers(struct mount *mnt) { /* * MNT_READONLY must become visible before ~MNT_WRITE_HOLD, so writers * that become unheld will see MNT_READONLY. */ smp_wmb(); mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; }
0
263,490
static void sco_connect_cfm(struct hci_conn *hcon, __u8 status) { if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) return; BT_DBG("hcon %p bdaddr %pMR status %u", hcon, &hcon->dst, status); if (!status) { struct sco_conn *conn; conn = sco_conn_add(hcon); if (conn) sco_conn_ready(conn); } else sco_conn_del(hcon, bt_to_errno(status)); }
0
247,736
TEST_P(SslSocketTest, FailedClientCertAllowExpiredBadHashVerification) { envoy::config::listener::v3::Listener listener; envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client; OptionalServerConfig server_config; server_config.allow_expired_cert = true; server_config.cert_hash = "0000000000000000000000000000000000000000000000000000000000000000"; configureServerAndExpiredClientCertificate(listener, client, server_config); TestUtilOptionsV2 test_options(listener, client, false, GetParam()); testUtilV2(test_options.setExpectedServerStats("ssl.fail_verify_cert_hash") .setExpectedClientCertUri("spiffe://lyft.com/test-team") .setExpectedTransportFailureReasonContains("SSLV3_ALERT_CERTIFICATE_EXPIRED")); }
0
512,592
int Arg_comparator::compare_e_row() { (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { if (!comparators[i].compare()) return 0; } return 1; }
0
317,268
static void selinux_inode_getsecid(struct inode *inode, u32 *secid) { struct inode_security_struct *isec = inode_security_novalidate(inode); *secid = isec->sid; }
0
279,910
make_filter_cmd( char_u *cmd, // command char_u *itmp, // NULL or name of input file char_u *otmp) // NULL or name of output file { char_u *buf; long_u len; #if defined(UNIX) int is_fish_shell; char_u *shell_name = get_isolated_shell_name(); if (shell_name == NULL) return NULL; // Account for fish's different syntax for subshells is_fish_shell = (fnamecmp(shell_name, "fish") == 0); vim_free(shell_name); if (is_fish_shell) len = (long_u)STRLEN(cmd) + 13; // "begin; " + "; end" + NUL else #endif len = (long_u)STRLEN(cmd) + 3; // "()" + NUL if (itmp != NULL) len += (long_u)STRLEN(itmp) + 9; // " { < " + " } " if (otmp != NULL) len += (long_u)STRLEN(otmp) + (long_u)STRLEN(p_srr) + 2; // " " buf = alloc(len); if (buf == NULL) return NULL; #if defined(UNIX) /* * Put braces around the command (for concatenated commands) when * redirecting input and/or output. */ if (itmp != NULL || otmp != NULL) { if (is_fish_shell) vim_snprintf((char *)buf, len, "begin; %s; end", (char *)cmd); else vim_snprintf((char *)buf, len, "(%s)", (char *)cmd); } else STRCPY(buf, cmd); if (itmp != NULL) { STRCAT(buf, " < "); STRCAT(buf, itmp); } #else // For shells that don't understand braces around commands, at least allow // the use of commands in a pipe. if (*p_sxe != NUL && *p_sxq == '(') { if (itmp != NULL || otmp != NULL) vim_snprintf((char *)buf, len, "(%s)", (char *)cmd); else STRCPY(buf, cmd); if (itmp != NULL) { STRCAT(buf, " < "); STRCAT(buf, itmp); } } else { STRCPY(buf, cmd); if (itmp != NULL) { char_u *p; // If there is a pipe, we have to put the '<' in front of it. // Don't do this when 'shellquote' is not empty, otherwise the // redirection would be inside the quotes. if (*p_shq == NUL) { p = find_pipe(buf); if (p != NULL) *p = NUL; } STRCAT(buf, " <"); // " < " causes problems on Amiga STRCAT(buf, itmp); if (*p_shq == NUL) { p = find_pipe(cmd); if (p != NULL) { STRCAT(buf, " "); // insert a space before the '|' for DOS STRCAT(buf, p); } } } } #endif if (otmp != NULL) append_redir(buf, (int)len, p_srr, otmp); return buf; }
0
359,411
DEFUN (neighbor_attr_unchanged4, neighbor_attr_unchanged4_cmd, NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n" "Med attribute\n" "As-path attribute\n" "Nexthop attribute\n") { u_int16_t flags = PEER_FLAG_MED_UNCHANGED; if (strncmp (argv[1], "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); else if (strncmp (argv[1], "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), flags); }
0
428,227
static CURLcode create_conn(struct SessionHandle *data, struct connectdata **in_connect, bool *async) { CURLcode result = CURLE_OK; struct connectdata *conn; struct connectdata *conn_temp = NULL; size_t urllen; char *user = NULL; char *passwd = NULL; char *options = NULL; bool reuse; char *proxy = NULL; bool prot_missing = FALSE; bool no_connections_available = FALSE; bool force_reuse = FALSE; size_t max_host_connections = Curl_multi_max_host_connections(data->multi); size_t max_total_connections = Curl_multi_max_total_connections(data->multi); *async = FALSE; /************************************************************* * Check input data *************************************************************/ if(!data->change.url) { result = CURLE_URL_MALFORMAT; goto out; } /* First, split up the current URL in parts so that we can use the parts for checking against the already present connections. In order to not have to modify everything at once, we allocate a temporary connection data struct and fill in for comparison purposes. */ conn = allocate_conn(data); if(!conn) { result = CURLE_OUT_OF_MEMORY; goto out; } /* We must set the return variable as soon as possible, so that our parent can cleanup any possible allocs we may have done before any failure */ *in_connect = conn; /* This initing continues below, see the comment "Continue connectdata * initialization here" */ /*********************************************************** * We need to allocate memory to store the path in. We get the size of the * full URL to be sure, and we need to make it at least 256 bytes since * other parts of the code will rely on this fact ***********************************************************/ #define LEAST_PATH_ALLOC 256 urllen=strlen(data->change.url); if(urllen < LEAST_PATH_ALLOC) urllen=LEAST_PATH_ALLOC; /* * We malloc() the buffers below urllen+2 to make room for 2 possibilities: * 1 - an extra terminating zero * 2 - an extra slash (in case a syntax like "www.host.com?moo" is used) */ Curl_safefree(data->state.pathbuffer); data->state.path = NULL; data->state.pathbuffer = malloc(urllen+2); if(NULL == data->state.pathbuffer) { result = CURLE_OUT_OF_MEMORY; /* really bad error */ goto out; } data->state.path = data->state.pathbuffer; conn->host.rawalloc = malloc(urllen+2); if(NULL == conn->host.rawalloc) { Curl_safefree(data->state.pathbuffer); data->state.path = NULL; result = CURLE_OUT_OF_MEMORY; goto out; } conn->host.name = conn->host.rawalloc; conn->host.name[0] = 0; user = strdup(""); passwd = strdup(""); options = strdup(""); if(!user || !passwd || !options) { result = CURLE_OUT_OF_MEMORY; goto out; } result = parseurlandfillconn(data, conn, &prot_missing, &user, &passwd, &options); if(result) goto out; /************************************************************* * No protocol part in URL was used, add it! *************************************************************/ if(prot_missing) { /* We're guessing prefixes here and if we're told to use a proxy or if we're gonna follow a Location: later or... then we need the protocol part added so that we have a valid URL. */ char *reurl; reurl = aprintf("%s://%s", conn->handler->scheme, data->change.url); if(!reurl) { result = CURLE_OUT_OF_MEMORY; goto out; } if(data->change.url_alloc) { Curl_safefree(data->change.url); data->change.url_alloc = FALSE; } data->change.url = reurl; data->change.url_alloc = TRUE; /* free this later */ } /************************************************************* * If the protocol can't handle url query strings, then cut * off the unhandable part *************************************************************/ if((conn->given->flags&PROTOPT_NOURLQUERY)) { char *path_q_sep = strchr(conn->data->state.path, '?'); if(path_q_sep) { /* according to rfc3986, allow the query (?foo=bar) also on protocols that can't handle it. cut the string-part after '?' */ /* terminate the string */ path_q_sep[0] = 0; } } if(data->set.str[STRING_BEARER]) { conn->xoauth2_bearer = strdup(data->set.str[STRING_BEARER]); if(!conn->xoauth2_bearer) { result = CURLE_OUT_OF_MEMORY; goto out; } } #ifndef CURL_DISABLE_PROXY /************************************************************* * Extract the user and password from the authentication string *************************************************************/ if(conn->bits.proxy_user_passwd) { result = parse_proxy_auth(data, conn); if(result) goto out; } /************************************************************* * Detect what (if any) proxy to use *************************************************************/ if(data->set.str[STRING_PROXY]) { proxy = strdup(data->set.str[STRING_PROXY]); /* if global proxy is set, this is it */ if(NULL == proxy) { failf(data, "memory shortage"); result = CURLE_OUT_OF_MEMORY; goto out; } } if(data->set.str[STRING_NOPROXY] && check_noproxy(conn->host.name, data->set.str[STRING_NOPROXY])) { if(proxy) { free(proxy); /* proxy is in exception list */ proxy = NULL; } } else if(!proxy) proxy = detect_proxy(conn); #ifdef USE_UNIX_SOCKETS if(proxy && data->set.str[STRING_UNIX_SOCKET_PATH]) { free(proxy); /* Unix domain sockets cannot be proxied, so disable it */ proxy = NULL; } #endif if(proxy && (!*proxy || (conn->handler->flags & PROTOPT_NONETWORK))) { free(proxy); /* Don't bother with an empty proxy string or if the protocol doesn't work with network */ proxy = NULL; } /*********************************************************************** * If this is supposed to use a proxy, we need to figure out the proxy host * name, proxy type and port number, so that we can re-use an existing * connection that may exist registered to the same proxy host. ***********************************************************************/ if(proxy) { result = parse_proxy(data, conn, proxy); Curl_safefree(proxy); /* parse_proxy copies the proxy string */ if(result) goto out; if((conn->proxytype == CURLPROXY_HTTP) || (conn->proxytype == CURLPROXY_HTTP_1_0)) { #ifdef CURL_DISABLE_HTTP /* asking for a HTTP proxy is a bit funny when HTTP is disabled... */ result = CURLE_UNSUPPORTED_PROTOCOL; goto out; #else /* force this connection's protocol to become HTTP if not already compatible - if it isn't tunneling through */ if(!(conn->handler->protocol & PROTO_FAMILY_HTTP) && !conn->bits.tunnel_proxy) conn->handler = &Curl_handler_http; conn->bits.httpproxy = TRUE; #endif } else conn->bits.httpproxy = FALSE; /* not a HTTP proxy */ conn->bits.proxy = TRUE; } else { /* we aren't using the proxy after all... */ conn->bits.proxy = FALSE; conn->bits.httpproxy = FALSE; conn->bits.proxy_user_passwd = FALSE; conn->bits.tunnel_proxy = FALSE; } #endif /* CURL_DISABLE_PROXY */ /************************************************************* * If the protocol is using SSL and HTTP proxy is used, we set * the tunnel_proxy bit. *************************************************************/ if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy) conn->bits.tunnel_proxy = TRUE; /************************************************************* * Figure out the remote port number and fix it in the URL *************************************************************/ result = parse_remote_port(data, conn); if(result) goto out; /* Check for overridden login details and set them accordingly so they they are known when protocol->setup_connection is called! */ result = override_login(data, conn, &user, &passwd, &options); if(result) goto out; result = set_login(conn, user, passwd, options); if(result) goto out; /************************************************************* * Setup internals depending on protocol. Needs to be done after * we figured out what/if proxy to use. *************************************************************/ result = setup_connection_internals(conn); if(result) goto out; conn->recv[FIRSTSOCKET] = Curl_recv_plain; conn->send[FIRSTSOCKET] = Curl_send_plain; conn->recv[SECONDARYSOCKET] = Curl_recv_plain; conn->send[SECONDARYSOCKET] = Curl_send_plain; /*********************************************************************** * file: is a special case in that it doesn't need a network connection ***********************************************************************/ #ifndef CURL_DISABLE_FILE if(conn->handler->flags & PROTOPT_NONETWORK) { bool done; /* this is supposed to be the connect function so we better at least check that the file is present here! */ DEBUGASSERT(conn->handler->connect_it); result = conn->handler->connect_it(conn, &done); /* Setup a "faked" transfer that'll do nothing */ if(!result) { conn->data = data; conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */ ConnectionStore(data, conn); /* * Setup whatever necessary for a resumed transfer */ result = setup_range(data); if(result) { DEBUGASSERT(conn->handler->done); /* we ignore the return code for the protocol-specific DONE */ (void)conn->handler->done(conn, result, FALSE); goto out; } Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ -1, NULL); /* no upload */ } /* since we skip do_init() */ do_init(conn); goto out; } #endif /* Get a cloned copy of the SSL config situation stored in the connection struct. But to get this going nicely, we must first make sure that the strings in the master copy are pointing to the correct strings in the session handle strings array! Keep in mind that the pointers in the master copy are pointing to strings that will be freed as part of the SessionHandle struct, but all cloned copies will be separately allocated. */ data->set.ssl.CApath = data->set.str[STRING_SSL_CAPATH]; data->set.ssl.CAfile = data->set.str[STRING_SSL_CAFILE]; data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE]; data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT]; data->set.ssl.random_file = data->set.str[STRING_SSL_RANDOM_FILE]; data->set.ssl.egdsocket = data->set.str[STRING_SSL_EGDSOCKET]; data->set.ssl.cipher_list = data->set.str[STRING_SSL_CIPHER_LIST]; #ifdef USE_TLS_SRP data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME]; data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD]; #endif if(!Curl_clone_ssl_config(&data->set.ssl, &conn->ssl_config)) { result = CURLE_OUT_OF_MEMORY; goto out; } prune_dead_connections(data); /************************************************************* * Check the current list of connections to see if we can * re-use an already existing one or if we have to create a * new one. *************************************************************/ /* reuse_fresh is TRUE if we are told to use a new connection by force, but we only acknowledge this option if this is not a re-used connection already (which happens due to follow-location or during a HTTP authentication phase). */ if(data->set.reuse_fresh && !data->state.this_is_a_follow) reuse = FALSE; else reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse); /* If we found a reusable connection, we may still want to open a new connection if we are pipelining. */ if(reuse && !force_reuse && IsPipeliningPossible(data, conn_temp)) { size_t pipelen = conn_temp->send_pipe->size + conn_temp->recv_pipe->size; if(pipelen > 0) { infof(data, "Found connection %ld, with requests in the pipe (%zu)\n", conn_temp->connection_id, pipelen); if(conn_temp->bundle->num_connections < max_host_connections && data->state.conn_cache->num_connections < max_total_connections) { /* We want a new connection anyway */ reuse = FALSE; infof(data, "We can reuse, but we want a new connection anyway\n"); } } } if(reuse) { /* * We already have a connection for this, we got the former connection * in the conn_temp variable and thus we need to cleanup the one we * just allocated before we can move along and use the previously * existing one. */ conn_temp->inuse = TRUE; /* mark this as being in use so that no other handle in a multi stack may nick it */ reuse_conn(conn, conn_temp); free(conn); /* we don't need this anymore */ conn = conn_temp; *in_connect = conn; /* set a pointer to the hostname we display */ fix_hostname(data, conn, &conn->host); infof(data, "Re-using existing connection! (#%ld) with host %s\n", conn->connection_id, conn->proxy.name?conn->proxy.dispname:conn->host.dispname); } else { /* We have decided that we want a new connection. However, we may not be able to do that if we have reached the limit of how many connections we are allowed to open. */ struct connectbundle *bundle; bundle = Curl_conncache_find_bundle(data->state.conn_cache, conn->host.name); if(max_host_connections > 0 && bundle && (bundle->num_connections >= max_host_connections)) { struct connectdata *conn_candidate; /* The bundle is full. Let's see if we can kill a connection. */ conn_candidate = find_oldest_idle_connection_in_bundle(data, bundle); if(conn_candidate) { /* Set the connection's owner correctly, then kill it */ conn_candidate->data = data; (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); } else no_connections_available = TRUE; } if(max_total_connections > 0 && (data->state.conn_cache->num_connections >= max_total_connections)) { struct connectdata *conn_candidate; /* The cache is full. Let's see if we can kill a connection. */ conn_candidate = find_oldest_idle_connection(data); if(conn_candidate) { /* Set the connection's owner correctly, then kill it */ conn_candidate->data = data; (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); } else no_connections_available = TRUE; } if(no_connections_available) { infof(data, "No connections available.\n"); conn_free(conn); *in_connect = NULL; result = CURLE_NO_CONNECTION_AVAILABLE; goto out; } else { /* * This is a brand new connection, so let's store it in the connection * cache of ours! */ ConnectionStore(data, conn); } #if defined(USE_NTLM) /* If NTLM is requested in a part of this connection, make sure we don't assume the state is fine as this is a fresh connection and NTLM is connection based. */ if((data->state.authhost.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && data->state.authhost.done) { infof(data, "NTLM picked AND auth done set, clear picked!\n"); data->state.authhost.picked = CURLAUTH_NONE; } if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && data->state.authproxy.done) { infof(data, "NTLM-proxy picked AND auth done set, clear picked!\n"); data->state.authproxy.picked = CURLAUTH_NONE; } #endif } /* Mark the connection as used */ conn->inuse = TRUE; /* Setup and init stuff before DO starts, in preparing for the transfer. */ do_init(conn); /* * Setup whatever necessary for a resumed transfer */ result = setup_range(data); if(result) goto out; /* Continue connectdata initialization here. */ /* * Inherit the proper values from the urldata struct AFTER we have arranged * the persistent connection stuff */ conn->fread_func = data->set.fread_func; conn->fread_in = data->set.in; conn->seek_func = data->set.seek_func; conn->seek_client = data->set.seek_client; /************************************************************* * Resolve the address of the server or proxy *************************************************************/ result = resolve_server(data, conn, async); out: Curl_safefree(options); Curl_safefree(passwd); Curl_safefree(user); Curl_safefree(proxy); return result; }
0
424,948
static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, const struct fw_img *fw, bool run_in_rfkill) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); bool hw_rfkill; int ret; /* This may fail if AMT took ownership of the device */ if (iwl_pcie_prepare_card_hw(trans)) { IWL_WARN(trans, "Exit HW not ready\n"); ret = -EIO; goto out; } iwl_enable_rfkill_int(trans); iwl_write32(trans, CSR_INT, 0xFFFFFFFF); /* * We enabled the RF-Kill interrupt and the handler may very * well be running. Disable the interrupts to make sure no other * interrupt can be fired. */ iwl_disable_interrupts(trans); /* Make sure it finished running */ iwl_pcie_synchronize_irqs(trans); mutex_lock(&trans_pcie->mutex); /* If platform's RF_KILL switch is NOT set to KILL */ hw_rfkill = iwl_pcie_check_hw_rf_kill(trans); if (hw_rfkill && !run_in_rfkill) { ret = -ERFKILL; goto out; } /* Someone called stop_device, don't try to start_fw */ if (trans_pcie->is_down) { IWL_WARN(trans, "Can't start_fw since the HW hasn't been started\n"); ret = -EIO; goto out; } /* make sure rfkill handshake bits are cleared */ iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ iwl_write32(trans, CSR_INT, 0xFFFFFFFF); ret = iwl_pcie_nic_init(trans); if (ret) { IWL_ERR(trans, "Unable to init nic\n"); goto out; } /* * Now, we load the firmware and don't want to be interrupted, even * by the RF-Kill interrupt (hence mask all the interrupt besides the * FH_TX interrupt which is needed to load the firmware). If the * RF-Kill switch is toggled, we will find out after having loaded * the firmware and return the proper value to the caller. */ iwl_enable_fw_load_int(trans); /* really make sure rfkill handshake bits are cleared */ iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Load the given image to the HW */ if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_8000) ret = iwl_pcie_load_given_ucode_8000(trans, fw); else ret = iwl_pcie_load_given_ucode(trans, fw); /* re-check RF-Kill state since we may have missed the interrupt */ hw_rfkill = iwl_pcie_check_hw_rf_kill(trans); if (hw_rfkill && !run_in_rfkill) ret = -ERFKILL; out: mutex_unlock(&trans_pcie->mutex); return ret; }
0
230,138
static json_t * register_new_attestation(struct config_module * config, json_t * j_params, json_t * j_scheme_data, json_t * j_credential) { json_t * j_return, * j_client_data = NULL, * j_error, * j_result, * j_pubkey = NULL, * j_cert = NULL, * j_query, * j_element = NULL; unsigned char * client_data = NULL, * challenge_b64 = NULL, * att_obj = NULL, * cbor_bs_handle = NULL, rpid_hash[32], * fmt = NULL, * credential_id_b64 = NULL, * cbor_auth_data, * cred_pub_key, cert_x[256], cert_y[256], pubkey_export[1024]; char * challenge_hash = NULL, * message = NULL; const char * rpid = NULL; size_t client_data_len = 0, challenge_b64_len = 0, att_obj_len = 0, rpid_hash_len = 32, fmt_len = 0, credential_id_len = 0, credential_id_b64_len, cbor_auth_data_len, cred_pub_key_len, cert_x_len = 0, cert_y_len = 0, pubkey_export_len = 1024, index = 0, cbor_bs_handle_len, rpid_len; uint32_t counter = 0; int ret = G_OK, res, status, has_x = 0, has_y = 0, key_type_valid = 0, key_alg_valid = 0; unsigned int i; struct cbor_load_result cbor_result; cbor_item_t * item = NULL, * key = NULL, * auth_data = NULL, * att_stmt = NULL, * cbor_cose = NULL, * cbor_key, * cbor_value; gnutls_pubkey_t g_key = NULL; gnutls_datum_t g_x, g_y; gnutls_ecc_curve_t curve = GNUTLS_ECC_CURVE_INVALID; if (j_scheme_data != NULL) { j_error = json_array(); if (j_error != NULL) { do { if (!json_string_length(json_object_get(json_object_get(j_scheme_data, "credential"), "rawId"))) { json_array_append_new(j_error, json_string("rawId mandatory")); ret = G_ERROR_PARAM; break; } if (!json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "clientDataJSON"))) { json_array_append_new(j_error, json_string("clientDataJSON mandatory")); ret = G_ERROR_PARAM; break; } if ((client_data = o_malloc(json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "clientDataJSON"))+1)) == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error allocating resources for client_data"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_MEMORY; break; } if (!o_base64_decode((const unsigned char *)json_string_value(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "clientDataJSON")), json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "clientDataJSON")), client_data, &client_data_len)) { y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error o_base64_decode client_data"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_PARAM; break; } client_data[client_data_len] = '\0'; j_client_data = json_loads((const char *)client_data, JSON_DECODE_ANY, NULL); if (j_client_data == NULL) { json_array_append_new(j_error, json_string("Error parsing JSON client data")); ret = G_ERROR_PARAM; break; } // Step 3 if (0 != o_strcmp(json_string_value(json_object_get(j_client_data, "type")), "webauthn.create")) { json_array_append_new(j_error, json_string("clientDataJSON.type invalid")); ret = G_ERROR_PARAM; break; } // Step 4 if (!json_string_length(json_object_get(j_client_data, "challenge"))) { json_array_append_new(j_error, json_string("clientDataJSON.challenge mandatory")); ret = G_ERROR_PARAM; break; } if ((challenge_b64 = o_malloc(json_string_length(json_object_get(j_client_data, "challenge"))+3)) == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error allocating resources for challenge_b64"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_MEMORY; break; } if (!o_base64url_2_base64((unsigned char *)json_string_value(json_object_get(j_client_data, "challenge")), json_string_length(json_object_get(j_client_data, "challenge")), challenge_b64, &challenge_b64_len)) { json_array_append_new(j_error, json_string("clientDataJSON.challenge invalid format")); ret = G_ERROR_PARAM; break; } challenge_b64[challenge_b64_len] = '\0'; if ((challenge_hash = generate_hash(config->hash_algorithm, (const char *)challenge_b64)) == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error generate_hash for challenge_b64"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR; break; } if (0 != o_strcmp(challenge_hash, json_string_value(json_object_get(j_credential, "challenge_hash")))) { json_array_append_new(j_error, json_string("clientDataJSON.challenge invalid")); ret = G_ERROR_PARAM; break; } // Step 5 if (!json_string_length(json_object_get(j_client_data, "origin"))) { json_array_append_new(j_error, json_string("clientDataJSON.origin mandatory")); ret = G_ERROR_PARAM; break; } if (0 != o_strcmp(json_string_value(json_object_get(j_params, "rp-origin")), json_string_value(json_object_get(j_client_data, "origin")))) { message = msprintf("clientDataJSON.origin invalid - Client send %s, required %s", json_string_value(json_object_get(j_client_data, "origin")), json_string_value(json_object_get(j_params, "rp-origin"))); json_array_append_new(j_error, json_string(message)); o_free(message); ret = G_ERROR_PARAM; break; } // Step 6 ?? if (!json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "attestationObject"))) { json_array_append_new(j_error, json_string("attestationObject required")); ret = G_ERROR_PARAM; break; } if ((att_obj = o_malloc(json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "attestationObject")))) == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error allocating resources for o_malloc"); ret = G_ERROR_MEMORY; break; } if (!o_base64_decode((unsigned char *)json_string_value(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "attestationObject")), json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, "credential"), "response"), "attestationObject")), att_obj, &att_obj_len)) { json_array_append_new(j_error, json_string("attestationObject invalid base64")); ret = G_ERROR_PARAM; break; } // Step 7 item = cbor_load(att_obj, att_obj_len, &cbor_result); if (cbor_result.error.code != CBOR_ERR_NONE) { json_array_append_new(j_error, json_string("attestationObject invalid cbor")); ret = G_ERROR_PARAM; break; } if (!cbor_isa_map(item)) { json_array_append_new(j_error, json_string("attestationObject invalid cbor item")); ret = G_ERROR_PARAM; break; } // Check attestation object if (cbor_map_size(item) != 3) { json_array_append_new(j_error, json_string("attestationObject invalid cbor item")); ret = G_ERROR_PARAM; break; } for (i=0; i<3; i++) { key = cbor_map_handle(item)[i].key; if (cbor_isa_string(key)) { if (0 == o_strncmp((const char *)cbor_string_handle(key), "fmt", MIN(o_strlen("fmt"), cbor_string_length(key)))) { if (!cbor_isa_string(cbor_map_handle(item)[i].value)) { json_array_append_new(j_error, json_string("CBOR map value 'fmt' isnt't a string")); ret = G_ERROR_PARAM; break; } else { fmt_len = cbor_string_length(cbor_map_handle(item)[i].value); fmt = cbor_string_handle(cbor_map_handle(item)[i].value); } } else if (0 == o_strncmp((const char *)cbor_string_handle(key), "attStmt", MIN(o_strlen("attStmt"), cbor_string_length(key)))) { att_stmt = cbor_map_handle(item)[i].value; } else if (0 == o_strncmp((const char *)cbor_string_handle(key), "authData", MIN(o_strlen("authData"), cbor_string_length(key)))) { auth_data = cbor_map_handle(item)[i].value; if (!cbor_isa_bytestring(auth_data) || cbor_bytestring_length(auth_data) < 56 || cbor_bytestring_is_indefinite(auth_data)) { json_array_append_new(j_error, json_string("CBOR map value 'authData' is invalid")); ret = G_ERROR_PARAM; break; } } else { message = msprintf("CBOR map element %d is not an expected item", i); json_array_append_new(j_error, json_string(message)); o_free(message); ret = G_ERROR_PARAM; break; } } } // Step 9 if (auth_data == NULL) { json_array_append_new(j_error, json_string("authData invalid")); ret = G_ERROR_PARAM; break; } cbor_bs_handle = cbor_bytestring_handle(auth_data); cbor_bs_handle_len = cbor_bytestring_length(auth_data); if (o_strstr(json_string_value(json_object_get(j_params, "rp-origin")), "://") == NULL) { y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - rp-origin invalid"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_PARAM; break; } if (o_strstr(json_string_value(json_object_get(j_params, "rp-origin")), "://") != NULL) { rpid = o_strstr(json_string_value(json_object_get(j_params, "rp-origin")), "://")+3; } else { rpid = json_string_value(json_object_get(j_params, "rp-origin")); } if (o_strchr(rpid, ':') != NULL) { rpid_len = o_strchr(rpid, ':') - rpid; } else { rpid_len = o_strlen(rpid); } if (!generate_digest_raw(digest_SHA256, (unsigned char *)rpid, rpid_len, rpid_hash, &rpid_hash_len)) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error generate_digest_raw"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_PARAM; break; } if (0 != memcmp(cbor_bs_handle, rpid_hash, rpid_hash_len)) { json_array_append_new(j_error, json_string("authData.rpIdHash invalid")); ret = G_ERROR_PARAM; break; } // Step 10 if (!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_USER_PRESENT)) { json_array_append_new(j_error, json_string("authData.userPresent not set")); ret = G_ERROR_PARAM; break; } if (!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_AT)) { json_array_append_new(j_error, json_string("authData.Attested credential data not set")); ret = G_ERROR_PARAM; break; } // Step 11 ignored for now //y_log_message(Y_LOG_LEVEL_DEBUG, "authData.userVerified: %d", !!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_USER_VERIFY)); // Step 12 ignored for now (no extension) //y_log_message(Y_LOG_LEVEL_DEBUG, "authData.Extension: %d", !!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_ED)); credential_id_len = cbor_bs_handle[CRED_ID_L_OFFSET+1] | (cbor_bs_handle[CRED_ID_L_OFFSET] << 8); if (cbor_bs_handle_len < CRED_ID_L_OFFSET+2+credential_id_len) { json_array_append_new(j_error, json_string("auth_data invalid size")); ret = G_ERROR_PARAM; break; } credential_id_b64 = o_malloc(credential_id_len*2); if (credential_id_b64 == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error o_malloc for credential_id_b64"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_PARAM; break; } if (!o_base64_encode(cbor_bs_handle+CRED_ID_L_OFFSET+2, credential_id_len, credential_id_b64, &credential_id_b64_len)) { y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error o_base64_encode for credential_id_b64"); json_array_append_new(j_error, json_string("Internal error")); ret = G_ERROR_PARAM; break; } // Compare credential_id_b64 with rawId if (memcmp(credential_id_b64, json_string_value(json_object_get(json_object_get(j_scheme_data, "credential"), "rawId")), MIN(json_string_length(json_object_get(json_object_get(j_scheme_data, "credential"), "rawId")), credential_id_b64_len))) { json_array_append_new(j_error, json_string("Invalid rawId")); ret = G_ERROR_PARAM; break; } // Extract public key from auth_data COSE structure // Extract credential ID cbor_auth_data_len = cbor_bytestring_length(auth_data); cbor_auth_data = cbor_bytestring_handle(auth_data); cred_pub_key = cbor_auth_data+CREDENTIAL_ID_OFFSET+credential_id_len; cred_pub_key_len = cbor_auth_data_len-CREDENTIAL_ID_OFFSET-credential_id_len; cbor_cose = cbor_load(cred_pub_key, cred_pub_key_len, &cbor_result); if (cbor_result.error.code != CBOR_ERR_NONE) { json_array_append_new(j_error, json_string("Invalid COSE key")); y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error cbor_load cbor_cose"); ret = G_ERROR_PARAM; break; } if (!cbor_isa_map(cbor_cose)) { json_array_append_new(j_error, json_string("Invalid COSE key")); y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error cbor_cose not a map"); ret = G_ERROR_PARAM; break; } for (i=0; i<cbor_map_size(cbor_cose); i++) { cbor_key = cbor_map_handle(cbor_cose)[i].key; cbor_value = cbor_map_handle(cbor_cose)[i].value; if (cbor_isa_negint(cbor_key) && cbor_get_int(cbor_key) == 1 && cbor_isa_bytestring(cbor_value)) { has_x = 1; memcpy(cert_x, cbor_bytestring_handle(cbor_value), cbor_bytestring_length(cbor_value)); cert_x_len = cbor_bytestring_length(cbor_value); g_x.data = cert_x; g_x.size = cbor_bytestring_length(cbor_value); } else if (cbor_isa_negint(cbor_key) && cbor_get_int(cbor_key) == 2 && cbor_isa_bytestring(cbor_value)) { has_y = 1; memcpy(cert_y, cbor_bytestring_handle(cbor_value), cbor_bytestring_length(cbor_value)); cert_y_len = cbor_bytestring_length(cbor_value); g_y.data = cert_y; g_y.size = cbor_bytestring_length(cbor_value); } else if (cbor_isa_uint(cbor_key) && cbor_get_int(cbor_key) == 1 && cbor_isa_uint(cbor_value) && cbor_get_int(cbor_value) == 2) { key_type_valid = 1; } else if (cbor_isa_uint(cbor_key) && cbor_get_int(cbor_key) == 3 && cbor_isa_negint(cbor_value)) { if (cbor_get_int(cbor_value) == 6 || cbor_get_int(cbor_value) == 34 || cbor_get_int(cbor_value) == 35) { json_array_foreach(json_object_get(j_params, "pubKey-cred-params"), index, j_element) { if (cbor_get_int(cbor_value) == 6 && json_integer_value(json_object_get(j_element, "alg")) == ECDSA256) { key_alg_valid = 1; curve = GNUTLS_ECC_CURVE_SECP256R1; } else if (cbor_get_int(cbor_value) == 34 && json_integer_value(json_object_get(j_element, "alg")) == ECDSA384) { key_alg_valid = 1; curve = GNUTLS_ECC_CURVE_SECP384R1; } else if (cbor_get_int(cbor_value) == 35 && json_integer_value(json_object_get(j_element, "alg")) == ECDSA512) { key_alg_valid = 1; curve = GNUTLS_ECC_CURVE_SECP521R1; } } } } } if (!has_x || !has_y || !key_type_valid || !key_alg_valid) { json_array_append_new(j_error, json_string("Invalid COSE key")); y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error invalid COSE key has_x %d && has_y %d && key_type_valid %d && key_alg_valid %d", has_x, has_y, key_type_valid, key_alg_valid); ret = G_ERROR_PARAM; break; } if (gnutls_pubkey_init(&g_key)) { json_array_append_new(j_error, json_string("Internal error")); y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error gnutls_pubkey_init"); ret = G_ERROR_PARAM; break; } if (gnutls_pubkey_import_ecc_raw(g_key, curve, &g_x, &g_y) < 0) { json_array_append_new(j_error, json_string("Internal error")); y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - error gnutls_pubkey_import_ecc_raw"); ret = G_ERROR_PARAM; break; } if ((ret = gnutls_pubkey_export(g_key, GNUTLS_X509_FMT_PEM, pubkey_export, &pubkey_export_len)) < 0) { json_array_append_new(j_error, json_string("Error exporting pubkey")); y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - Error gnutls_pubkey_export: %d", ret); ret = G_ERROR_PARAM; break; } // Steps 13-14 if (0 == o_strncmp("packed", (char *)fmt, MIN(fmt_len, o_strlen("packed"))) && (json_object_get(json_object_get(j_params, "fmt"), "packed") == json_true())) { j_result = check_attestation_packed(j_params, auth_data, att_stmt, client_data, g_key); if (check_result_value(j_result, G_ERROR_PARAM)) { json_array_extend(j_error, json_object_get(j_result, "error")); ret = G_ERROR_PARAM; } else if (!check_result_value(j_result, G_OK)) { ret = G_ERROR_PARAM; y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error check_attestation_packed"); json_array_append_new(j_error, json_string("internal error")); } else { j_cert = json_incref(json_object_get(json_object_get(j_result, "data"), "certificate")); } json_decref(j_result); } else if (0 == o_strncmp("tpm", (char *)fmt, MIN(fmt_len, o_strlen("tpm"))) && (json_object_get(json_object_get(j_params, "fmt"), "tpm") == json_true())) { json_array_append_new(j_error, json_string("Format 'tpm' not supported yet")); ret = G_ERROR_PARAM; } else if (0 == o_strncmp("android-key", (char *)fmt, MIN(fmt_len, o_strlen("android-key"))) && (json_object_get(json_object_get(j_params, "fmt"), "android-key") == json_true())) { json_array_append_new(j_error, json_string("Format 'android-key' not supported yet")); ret = G_ERROR_PARAM; } else if (0 == o_strncmp("android-safetynet", (char *)fmt, MIN(fmt_len, o_strlen("android-safetynet"))) && (json_object_get(json_object_get(j_params, "fmt"), "android-safetynet") == json_true())) { j_result = check_attestation_android_safetynet(j_params, auth_data, att_stmt, client_data); if (check_result_value(j_result, G_ERROR_PARAM)) { json_array_extend(j_error, json_object_get(j_result, "error")); ret = G_ERROR_PARAM; } else if (!check_result_value(j_result, G_OK)) { ret = G_ERROR_PARAM; y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error check_attestation_android_safetynet"); json_array_append_new(j_error, json_string("internal error")); } else { j_cert = json_incref(json_object_get(json_object_get(j_result, "data"), "certificate")); } json_decref(j_result); } else if (0 == o_strncmp("fido-u2f", (char *)fmt, MIN(fmt_len, o_strlen("fido-u2f"))) && (json_object_get(json_object_get(j_params, "fmt"), "fido-u2f") == json_true())) { j_result = check_attestation_fido_u2f(j_params, (cbor_auth_data+CREDENTIAL_ID_OFFSET), credential_id_len, cert_x, cert_x_len, cert_y, cert_y_len, att_stmt, rpid_hash, rpid_hash_len, client_data); if (check_result_value(j_result, G_ERROR_PARAM)) { json_array_extend(j_error, json_object_get(j_result, "error")); ret = G_ERROR_PARAM; } else if (!check_result_value(j_result, G_OK)) { ret = G_ERROR_PARAM; y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error check_attestation_fido_u2f"); json_array_append_new(j_error, json_string("internal error")); } else { j_cert = json_incref(json_object_get(json_object_get(j_result, "data"), "certificate")); } json_decref(j_result); } else if (0 == o_strncmp("apple", (char *)fmt, MIN(fmt_len, o_strlen("apple"))) && (json_object_get(json_object_get(j_params, "fmt"), "apple") == json_true() || json_object_get(j_params, "force-fmt-apple") == json_true())) { j_result = check_attestation_apple(j_params, auth_data, att_stmt, client_data, g_key); if (check_result_value(j_result, G_ERROR_PARAM)) { json_array_extend(j_error, json_object_get(j_result, "error")); ret = G_ERROR_PARAM; } else if (!check_result_value(j_result, G_OK)) { ret = G_ERROR_PARAM; y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error check_attestation_apple"); json_array_append_new(j_error, json_string("internal error")); } else { j_cert = json_incref(json_object_get(json_object_get(j_result, "data"), "certificate")); } json_decref(j_result); } else if (0 == o_strncmp("none", (char *)fmt, MIN(fmt_len, o_strlen("none"))) && (json_object_get(json_object_get(j_params, "fmt"), "none") == json_true() || json_object_get(j_params, "force-fmt-none") == json_true())) { if (att_stmt != NULL && cbor_isa_map(att_stmt) && cbor_map_is_definite(att_stmt) && !cbor_map_size(att_stmt)) { j_cert = json_string(""); } else { y_log_message(Y_LOG_LEVEL_DEBUG, "register_new_attestation - response type 'none' has invalid format"); json_array_append_new(j_error, json_string("response invalid")); ret = G_ERROR_PARAM; } } else { message = msprintf("Format '%.*s' is not supported by Glewlwyd WebAuthn scheme", fmt_len, fmt); json_array_append_new(j_error, json_string(message)); o_free(message); ret = G_ERROR_PARAM; } } while (0); // This is not a loop, but a structure where you can easily cancel the rest of the process with breaks if (ret != G_OK) { if (json_array_size(j_error)) { j_return = json_pack("{sisO}", "result", ret, "error", j_error); } else { j_return = json_pack("{si}", "result", ret); } } else { if ((res = check_certificate(config, j_params, json_string_value(json_object_get(json_object_get(j_scheme_data, "credential"), "rawId")), json_integer_value(json_object_get(j_credential, "gswu_id")))) == G_OK) { j_return = json_pack("{sis[s]}", "result", G_ERROR_PARAM, "error", "Credential already registered"); status = 2; } else if (res == G_ERROR_UNAUTHORIZED) { j_return = json_pack("{sis[s]}", "result", G_ERROR_PARAM, "error", "Credential unauthorized"); status = 2; } else if (res != G_ERROR_NOT_FOUND) { j_return = json_pack("{sis[s]}", "result", G_ERROR_PARAM, "error", "Internal error"); y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error check_certificate"); status = 2; } else { j_return = json_pack("{si}", "result", G_OK); status = 1; } counter = cbor_bs_handle[COUNTER_OFFSET+3] | (cbor_bs_handle[COUNTER_OFFSET+2] << 8) | (cbor_bs_handle[COUNTER_OFFSET+1] << 16) | (cbor_bs_handle[COUNTER_OFFSET] << 24); // Store credential in the database j_query = json_pack("{sss{siss%sOss%sOsi}s{sO}}", "table", G_TABLE_WEBAUTHN_CREDENTIAL, "set", "gswc_status", status, "gswc_name", fmt, fmt_len, "gswc_credential_id", json_object_get(json_object_get(j_scheme_data, "credential"), "rawId"), "gswc_public_key", pubkey_export, pubkey_export_len, "gswc_certificate", j_cert, "gswc_counter", counter, "where", "gswc_id", json_object_get(j_credential, "gswc_id")); res = h_update(config->conn, j_query, NULL); json_decref(j_query); if (res != H_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error h_update"); } } json_decref(j_error); json_decref(j_client_data); json_decref(j_pubkey); json_decref(j_cert); o_free(client_data); o_free(challenge_b64); o_free(challenge_hash); o_free(att_obj); o_free(credential_id_b64); gnutls_pubkey_deinit(g_key); if (item != NULL) { cbor_decref(&item); } if (cbor_cose != NULL) { cbor_decref(&cbor_cose); } } else { y_log_message(Y_LOG_LEVEL_ERROR, "register_new_attestation - Error allocating resources for j_error"); j_return = json_pack("{si}", "result", G_ERROR); } } else { j_return = json_pack("{sis[s]}", "result", G_ERROR_PARAM, "error", "scheme_data mandatory"); } return j_return; }
0
512,739
in_double::in_double(THD *thd, uint elements) :in_vector(thd, elements, sizeof(double), (qsort2_cmp) cmp_double, 0) {}
0
264,411
Curl_cookie_add(struct Curl_easy *data, /* * The 'data' pointer here may be NULL at times, and thus * must only be used very carefully for things that can deal * with data being NULL. Such as infof() and similar */ struct CookieInfo *c, bool httpheader, /* TRUE if HTTP header-style line */ bool noexpire, /* if TRUE, skip remove_expired() */ char *lineptr, /* first character of the line */ const char *domain, /* default domain */ const char *path, /* full path used when this cookie is set, used to get default path for the cookie unless set */ bool secure) /* TRUE if connection is over secure origin */ { struct Cookie *clist; struct Cookie *co; struct Cookie *lastc = NULL; struct Cookie *replace_co = NULL; struct Cookie *replace_clist = NULL; time_t now = time(NULL); bool replace_old = FALSE; bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */ size_t myhash; #ifdef CURL_DISABLE_VERBOSE_STRINGS (void)data; #endif DEBUGASSERT(MAX_SET_COOKIE_AMOUNT <= 255); /* counter is an unsigned char */ if(data->req.setcookies >= MAX_SET_COOKIE_AMOUNT) return NULL; /* First, alloc and init a new struct for it */ co = calloc(1, sizeof(struct Cookie)); if(!co) return NULL; /* bail out if we're this low on memory */ if(httpheader) { /* This line was read off a HTTP-header */ char name[MAX_NAME]; char what[MAX_NAME]; const char *ptr; const char *semiptr; size_t linelength = strlen(lineptr); if(linelength > MAX_COOKIE_LINE) { /* discard overly long lines at once */ free(co); return NULL; } semiptr = strchr(lineptr, ';'); /* first, find a semicolon */ while(*lineptr && ISBLANK(*lineptr)) lineptr++; ptr = lineptr; do { /* we have a <what>=<this> pair or a stand-alone word here */ name[0] = what[0] = 0; /* init the buffers */ if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n=] =%" MAX_NAME_TXT "[^;\r\n]", name, what)) { /* * Use strstore() below to properly deal with received cookie * headers that have the same string property set more than once, * and then we use the last one. */ const char *whatptr; bool done = FALSE; bool sep; size_t len = strlen(what); size_t nlen = strlen(name); const char *endofn = &ptr[ nlen ]; /* * Check for too long individual name or contents, or too long * combination of name + contents. Chrome and Firefox support 4095 or * 4096 bytes combo */ if(nlen >= (MAX_NAME-1) || len >= (MAX_NAME-1) || ((nlen + len) > MAX_NAME)) { freecookie(co); infof(data, "oversized cookie dropped, name/val %zu + %zu bytes", nlen, len); return NULL; } /* name ends with a '=' ? */ sep = (*endofn == '=')?TRUE:FALSE; if(nlen) { endofn--; /* move to the last character */ if(ISBLANK(*endofn)) { /* skip trailing spaces in name */ while(*endofn && ISBLANK(*endofn) && nlen) { endofn--; nlen--; } name[nlen] = 0; /* new end of name */ } } /* Strip off trailing whitespace from the 'what' */ while(len && ISBLANK(what[len-1])) { what[len-1] = 0; len--; } /* Skip leading whitespace from the 'what' */ whatptr = what; while(*whatptr && ISBLANK(*whatptr)) whatptr++; /* * Check if we have a reserved prefix set before anything else, as we * otherwise have to test for the prefix in both the cookie name and * "the rest". Prefixes must start with '__' and end with a '-', so * only test for names where that can possibly be true. */ if(nlen > 3 && name[0] == '_' && name[1] == '_') { if(!strncmp("__Secure-", name, 9)) co->prefix |= COOKIE_PREFIX__SECURE; else if(!strncmp("__Host-", name, 7)) co->prefix |= COOKIE_PREFIX__HOST; } if(!co->name) { /* The very first name/value pair is the actual cookie name */ if(!sep) { /* Bad name/value pair. */ badcookie = TRUE; break; } co->name = strdup(name); co->value = strdup(whatptr); done = TRUE; if(!co->name || !co->value) { badcookie = TRUE; break; } if(invalid_octets(whatptr) || invalid_octets(name)) { infof(data, "invalid octets in name/value, cookie dropped"); badcookie = TRUE; break; } } else if(!len) { /* * this was a "<name>=" with no content, and we must allow * 'secure' and 'httponly' specified this weirdly */ done = TRUE; /* * secure cookies are only allowed to be set when the connection is * using a secure protocol, or when the cookie is being set by * reading from file */ if(strcasecompare("secure", name)) { if(secure || !c->running) { co->secure = TRUE; } else { badcookie = TRUE; break; } } else if(strcasecompare("httponly", name)) co->httponly = TRUE; else if(sep) /* there was a '=' so we're not done parsing this field */ done = FALSE; } if(done) ; else if(strcasecompare("path", name)) { strstore(&co->path, whatptr); if(!co->path) { badcookie = TRUE; /* out of memory bad */ break; } free(co->spath); /* if this is set again */ co->spath = sanitize_cookie_path(co->path); if(!co->spath) { badcookie = TRUE; /* out of memory bad */ break; } } else if(strcasecompare("domain", name) && whatptr[0]) { bool is_ip; /* * Now, we make sure that our host is within the given domain, or * the given domain is not valid and thus cannot be set. */ if('.' == whatptr[0]) whatptr++; /* ignore preceding dot */ #ifndef USE_LIBPSL /* * Without PSL we don't know when the incoming cookie is set on a * TLD or otherwise "protected" suffix. To reduce risk, we require a * dot OR the exact host name being "localhost". */ if(bad_domain(whatptr)) domain = ":"; #endif is_ip = Curl_host_is_ipnum(domain ? domain : whatptr); if(!domain || (is_ip && !strcmp(whatptr, domain)) || (!is_ip && tailmatch(whatptr, domain))) { strstore(&co->domain, whatptr); if(!co->domain) { badcookie = TRUE; break; } if(!is_ip) co->tailmatch = TRUE; /* we always do that if the domain name was given */ } else { /* * We did not get a tailmatch and then the attempted set domain is * not a domain to which the current host belongs. Mark as bad. */ badcookie = TRUE; infof(data, "skipped cookie with bad tailmatch domain: %s", whatptr); } } else if(strcasecompare("version", name)) { strstore(&co->version, whatptr); if(!co->version) { badcookie = TRUE; break; } } else if(strcasecompare("max-age", name)) { /* * Defined in RFC2109: * * Optional. The Max-Age attribute defines the lifetime of the * cookie, in seconds. The delta-seconds value is a decimal non- * negative integer. After delta-seconds seconds elapse, the * client should discard the cookie. A value of zero means the * cookie should be discarded immediately. */ strstore(&co->maxage, whatptr); if(!co->maxage) { badcookie = TRUE; break; } } else if(strcasecompare("expires", name)) { strstore(&co->expirestr, whatptr); if(!co->expirestr) { badcookie = TRUE; break; } } /* * Else, this is the second (or more) name we don't know about! */ } else { /* this is an "illegal" <what>=<this> pair */ } if(!semiptr || !*semiptr) { /* we already know there are no more cookies */ semiptr = NULL; continue; } ptr = semiptr + 1; while(*ptr && ISBLANK(*ptr)) ptr++; semiptr = strchr(ptr, ';'); /* now, find the next semicolon */ if(!semiptr && *ptr) /* * There are no more semicolons, but there's a final name=value pair * coming up */ semiptr = strchr(ptr, '\0'); } while(semiptr); if(co->maxage) { CURLofft offt; offt = curlx_strtoofft((*co->maxage == '\"')? &co->maxage[1]:&co->maxage[0], NULL, 10, &co->expires); if(offt == CURL_OFFT_FLOW) /* overflow, used max value */ co->expires = CURL_OFF_T_MAX; else if(!offt) { if(!co->expires) /* already expired */ co->expires = 1; else if(CURL_OFF_T_MAX - now < co->expires) /* would overflow */ co->expires = CURL_OFF_T_MAX; else co->expires += now; } } else if(co->expirestr) { /* * Note that if the date couldn't get parsed for whatever reason, the * cookie will be treated as a session cookie */ co->expires = Curl_getdate_capped(co->expirestr); /* * Session cookies have expires set to 0 so if we get that back from the * date parser let's add a second to make it a non-session cookie */ if(co->expires == 0) co->expires = 1; else if(co->expires < 0) co->expires = 0; } if(!badcookie && !co->domain) { if(domain) { /* no domain was given in the header line, set the default */ co->domain = strdup(domain); if(!co->domain) badcookie = TRUE; } } if(!badcookie && !co->path && path) { /* * No path was given in the header line, set the default. Note that the * passed-in path to this function MAY have a '?' and following part that * MUST NOT be stored as part of the path. */ char *queryp = strchr(path, '?'); /* * queryp is where the interesting part of the path ends, so now we * want to the find the last */ char *endslash; if(!queryp) endslash = strrchr(path, '/'); else endslash = memrchr(path, '/', (queryp - path)); if(endslash) { size_t pathlen = (endslash-path + 1); /* include end slash */ co->path = malloc(pathlen + 1); /* one extra for the zero byte */ if(co->path) { memcpy(co->path, path, pathlen); co->path[pathlen] = 0; /* null-terminate */ co->spath = sanitize_cookie_path(co->path); if(!co->spath) badcookie = TRUE; /* out of memory bad */ } else badcookie = TRUE; } } /* * If we didn't get a cookie name, or a bad one, the this is an illegal * line so bail out. */ if(badcookie || !co->name) { freecookie(co); return NULL; } data->req.setcookies++; } else { /* * This line is NOT a HTTP header style line, we do offer support for * reading the odd netscape cookies-file format here */ char *ptr; char *firstptr; char *tok_buf = NULL; int fields; /* * IE introduced HTTP-only cookies to prevent XSS attacks. Cookies marked * with httpOnly after the domain name are not accessible from javascripts, * but since curl does not operate at javascript level, we include them * anyway. In Firefox's cookie files, these lines are preceded with * #HttpOnly_ and then everything is as usual, so we skip 10 characters of * the line.. */ if(strncmp(lineptr, "#HttpOnly_", 10) == 0) { lineptr += 10; co->httponly = TRUE; } if(lineptr[0]=='#') { /* don't even try the comments */ free(co); return NULL; } /* strip off the possible end-of-line characters */ ptr = strchr(lineptr, '\r'); if(ptr) *ptr = 0; /* clear it */ ptr = strchr(lineptr, '\n'); if(ptr) *ptr = 0; /* clear it */ firstptr = strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */ /* * Now loop through the fields and init the struct we already have * allocated */ for(ptr = firstptr, fields = 0; ptr && !badcookie; ptr = strtok_r(NULL, "\t", &tok_buf), fields++) { switch(fields) { case 0: if(ptr[0]=='.') /* skip preceding dots */ ptr++; co->domain = strdup(ptr); if(!co->domain) badcookie = TRUE; break; case 1: /* * flag: A TRUE/FALSE value indicating if all machines within a given * domain can access the variable. Set TRUE when the cookie says * .domain.com and to false when the domain is complete www.domain.com */ co->tailmatch = strcasecompare(ptr, "TRUE")?TRUE:FALSE; break; case 2: /* The file format allows the path field to remain not filled in */ if(strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) { /* only if the path doesn't look like a boolean option! */ co->path = strdup(ptr); if(!co->path) badcookie = TRUE; else { co->spath = sanitize_cookie_path(co->path); if(!co->spath) { badcookie = TRUE; /* out of memory bad */ } } break; } /* this doesn't look like a path, make one up! */ co->path = strdup("/"); if(!co->path) badcookie = TRUE; co->spath = strdup("/"); if(!co->spath) badcookie = TRUE; fields++; /* add a field and fall down to secure */ /* FALLTHROUGH */ case 3: co->secure = FALSE; if(strcasecompare(ptr, "TRUE")) { if(secure || c->running) co->secure = TRUE; else badcookie = TRUE; } break; case 4: if(curlx_strtoofft(ptr, NULL, 10, &co->expires)) badcookie = TRUE; break; case 5: co->name = strdup(ptr); if(!co->name) badcookie = TRUE; else { /* For Netscape file format cookies we check prefix on the name */ if(strncasecompare("__Secure-", co->name, 9)) co->prefix |= COOKIE_PREFIX__SECURE; else if(strncasecompare("__Host-", co->name, 7)) co->prefix |= COOKIE_PREFIX__HOST; } break; case 6: co->value = strdup(ptr); if(!co->value) badcookie = TRUE; break; } } if(6 == fields) { /* we got a cookie with blank contents, fix it */ co->value = strdup(""); if(!co->value) badcookie = TRUE; else fields++; } if(!badcookie && (7 != fields)) /* we did not find the sufficient number of fields */ badcookie = TRUE; if(badcookie) { freecookie(co); return NULL; } } if(co->prefix & COOKIE_PREFIX__SECURE) { /* The __Secure- prefix only requires that the cookie be set secure */ if(!co->secure) { freecookie(co); return NULL; } } if(co->prefix & COOKIE_PREFIX__HOST) { /* * The __Host- prefix requires the cookie to be secure, have a "/" path * and not have a domain set. */ if(co->secure && co->path && strcmp(co->path, "/") == 0 && !co->tailmatch) ; else { freecookie(co); return NULL; } } if(!c->running && /* read from a file */ c->newsession && /* clean session cookies */ !co->expires) { /* this is a session cookie since it doesn't expire! */ freecookie(co); return NULL; } co->livecookie = c->running; co->creationtime = ++c->lastct; /* * Now we have parsed the incoming line, we must now check if this supersedes * an already existing cookie, which it may if the previous have the same * domain and path as this. */ /* at first, remove expired cookies */ if(!noexpire) remove_expired(c); #ifdef USE_LIBPSL /* * Check if the domain is a Public Suffix and if yes, ignore the cookie. We * must also check that the data handle isn't NULL since the psl code will * dereference it. */ if(data && (domain && co->domain && !Curl_host_is_ipnum(co->domain))) { const psl_ctx_t *psl = Curl_psl_use(data); int acceptable; if(psl) { acceptable = psl_is_cookie_domain_acceptable(psl, domain, co->domain); Curl_psl_release(data); } else acceptable = !bad_domain(domain); if(!acceptable) { infof(data, "cookie '%s' dropped, domain '%s' must not " "set cookies for '%s'", co->name, domain, co->domain); freecookie(co); return NULL; } } #endif /* A non-secure cookie may not overlay an existing secure cookie. */ myhash = cookiehash(co->domain); clist = c->cookies[myhash]; while(clist) { if(strcasecompare(clist->name, co->name)) { /* the names are identical */ bool matching_domains = FALSE; if(clist->domain && co->domain) { if(strcasecompare(clist->domain, co->domain)) /* The domains are identical */ matching_domains = TRUE; } else if(!clist->domain && !co->domain) matching_domains = TRUE; if(matching_domains && /* the domains were identical */ clist->spath && co->spath && /* both have paths */ clist->secure && !co->secure && !secure) { size_t cllen; const char *sep; /* * A non-secure cookie may not overlay an existing secure cookie. * For an existing cookie "a" with path "/login", refuse a new * cookie "a" with for example path "/login/en", while the path * "/loginhelper" is ok. */ sep = strchr(clist->spath + 1, '/'); if(sep) cllen = sep - clist->spath; else cllen = strlen(clist->spath); if(strncasecompare(clist->spath, co->spath, cllen)) { infof(data, "cookie '%s' for domain '%s' dropped, would " "overlay an existing cookie", co->name, co->domain); freecookie(co); return NULL; } } } if(!replace_co && strcasecompare(clist->name, co->name)) { /* the names are identical */ if(clist->domain && co->domain) { if(strcasecompare(clist->domain, co->domain) && (clist->tailmatch == co->tailmatch)) /* The domains are identical */ replace_old = TRUE; } else if(!clist->domain && !co->domain) replace_old = TRUE; if(replace_old) { /* the domains were identical */ if(clist->spath && co->spath) { if(strcasecompare(clist->spath, co->spath)) replace_old = TRUE; else replace_old = FALSE; } else if(!clist->spath && !co->spath) replace_old = TRUE; else replace_old = FALSE; } if(replace_old && !co->livecookie && clist->livecookie) { /* * Both cookies matched fine, except that the already present cookie is * "live", which means it was set from a header, while the new one was * read from a file and thus isn't "live". "live" cookies are preferred * so the new cookie is freed. */ freecookie(co); return NULL; } if(replace_old) { replace_co = co; replace_clist = clist; } } lastc = clist; clist = clist->next; } if(replace_co) { co = replace_co; clist = replace_clist; co->next = clist->next; /* get the next-pointer first */ /* when replacing, creationtime is kept from old */ co->creationtime = clist->creationtime; /* then free all the old pointers */ free(clist->name); free(clist->value); free(clist->domain); free(clist->path); free(clist->spath); free(clist->expirestr); free(clist->version); free(clist->maxage); *clist = *co; /* then store all the new data */ free(co); /* free the newly allocated memory */ co = clist; } if(c->running) /* Only show this when NOT reading the cookies from a file */ infof(data, "%s cookie %s=\"%s\" for domain %s, path %s, " "expire %" CURL_FORMAT_CURL_OFF_T, replace_old?"Replaced":"Added", co->name, co->value, co->domain, co->path, co->expires); if(!replace_old) { /* then make the last item point on this new one */ if(lastc) lastc->next = co; else c->cookies[myhash] = co; c->numcookies++; /* one more cookie in the jar */ } /* * Now that we've added a new cookie to the jar, update the expiration * tracker in case it is the next one to expire. */ if(co->expires && (co->expires < c->next_expiration)) c->next_expiration = co->expires; return co; }
0
464,941
static inline int is_in_cp950_pua(int c1, int c) { if ((c1 >= 0xfa && c1 <= 0xfe) || (c1 >= 0x8e && c1 <= 0xa0) || (c1 >= 0x81 && c1 <= 0x8d) || (c1 >= 0xc7 && c1 <= 0xc8)) { return (c >=0x40 && c <= 0x7e) || (c >= 0xa1 && c <= 0xfe); } if (c1 == 0xc6) { return c >= 0xa1 && c <= 0xfe; } return 0; }
0
195,294
void Compute(OpKernelContext* ctx) override { StagingMap<Ordered>* map = nullptr; OP_REQUIRES_OK(ctx, GetStagingMap(ctx, def(), &map)); core::ScopedUnref scope(map); typename StagingMap<Ordered>::OptionalTuple tuple; const Tensor* key_tensor; const Tensor* indices_tensor; OpInputList values_tensor; OP_REQUIRES_OK(ctx, ctx->input("key", &key_tensor)); OP_REQUIRES_OK(ctx, ctx->input("indices", &indices_tensor)); OP_REQUIRES_OK(ctx, ctx->input_list("values", &values_tensor)); OP_REQUIRES(ctx, key_tensor->NumElements() > 0, errors::InvalidArgument("key must not be empty")); // Create copy for insertion into Staging Area Tensor key(*key_tensor); // Create the tuple to store for (std::size_t i = 0; i < values_tensor.size(); ++i) { tuple.push_back(values_tensor[i]); } // Store the tuple in the map OP_REQUIRES_OK(ctx, map->put(&key, indices_tensor, &tuple)); }
1
492,687
vte_sequence_handler_insert_lines (VteTerminal *terminal, GValueArray *params) { GValue *value; VteScreen *screen; long param, end, row; int i; screen = terminal->pvt->screen; /* The default is one. */ param = 1; /* Extract any parameters. */ if ((params != NULL) && (params->n_values > 0)) { value = g_value_array_get_nth(params, 0); if (G_VALUE_HOLDS_LONG(value)) { param = g_value_get_long(value); } } /* Find the region we're messing with. */ row = screen->cursor_current.row; if (screen->scrolling_restricted) { end = screen->insert_delta + screen->scrolling_region.end; } else { end = screen->insert_delta + terminal->row_count - 1; } /* Insert the new lines at the cursor. */ for (i = 0; i < param; i++) { /* Clear a line off the end of the region and add one to the * top of the region. */ _vte_terminal_ring_remove (terminal, end); _vte_terminal_ring_insert (terminal, row, TRUE); } /* Update the display. */ _vte_terminal_scroll_region(terminal, row, end - row + 1, param); /* Adjust the scrollbars if necessary. */ _vte_terminal_adjust_adjustments(terminal); /* We've modified the display. Make a note of it. */ terminal->pvt->text_inserted_flag = TRUE; }
0
289,277
static long snd_pcm_oss_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { /* * Everything is compatbile except SNDCTL_DSP_MAPINBUF/SNDCTL_DSP_MAPOUTBUF, * which are not implemented for the native case either */ return snd_pcm_oss_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); }
0
222,575
std::map<string, AttrValue> GetSetAttrs(const FunctionDef& fdef) { std::map<string, AttrValue> set_attrs; for (const auto& pair : fdef.attr()) { if (pair.second.value_case() != AttrValue::VALUE_NOT_SET) { set_attrs[pair.first] = pair.second; } } return set_attrs; }
0
381,879
udf_pblk_t udf_block_map(struct inode *inode, sector_t block) { struct kernel_lb_addr eloc; uint32_t elen; sector_t offset; struct extent_position epos = {}; udf_pblk_t ret; down_read(&UDF_I(inode)->i_data_sem); if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) ret = udf_get_lb_pblock(inode->i_sb, &eloc, offset); else ret = 0; up_read(&UDF_I(inode)->i_data_sem); brelse(epos.bh); if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_VARCONV)) return udf_fixed_to_variable(ret); else return ret; }
0
328,866
R_API RList *retrieve_all_field_access_string_and_value(void) { return retrieve_all_access_string_and_value (FIELD_ACCESS_FLAGS); }
0
476,127
static u8 encode_bMaxPower(enum usb_device_speed speed, struct usb_configuration *c) { unsigned val; if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)) val = c->MaxPower; else val = CONFIG_USB_GADGET_VBUS_DRAW; if (!val) return 0; if (speed < USB_SPEED_SUPER) return min(val, 500U) / 2; else /* * USB 3.x supports up to 900mA, but since 900 isn't divisible * by 8 the integral division will effectively cap to 896mA. */ return min(val, 900U) / 8; }
0
314,757
cdf_tole4(uint32_t sv) { return CDF_TOLE4(sv); }
0
502,706
X509 *SSL_SESSION_get0_peer(SSL_SESSION *s) { return s->peer; }
0
508,831
void LEX::link_first_table_back(TABLE_LIST *first, bool link_to_local) { if (first) { if ((first->next_global= query_tables)) query_tables->prev_global= &first->next_global; else query_tables_last= &first->next_global; query_tables= first; if (link_to_local) { first->next_local= select_lex.table_list.first; select_lex.context.table_list= first; select_lex.table_list.first= first; select_lex.table_list.elements++; //safety } } }
0
462,309
stprintf(stream * s, const char *fmt, ...) { int count; va_list args; char buf[1024]; va_start(args, fmt); count = gs_vsprintf(buf, fmt, args); if (count >= 0) { unsigned count_u = count; sputs(s, (const byte *)buf, count_u, &count_u); } va_end(args); }
0
338,157
static int decodeHexNibble(char ch) { return ch <= '9' ? ch & 15 : (ch & 15) + 9; }
0
242,586
EFI_STATUS verify_image(void *data, unsigned int datasize, EFI_LOADED_IMAGE *li, PE_COFF_LOADER_IMAGE_CONTEXT *context) { EFI_STATUS efi_status; UINT8 sha1hash[SHA1_DIGEST_SIZE]; UINT8 sha256hash[SHA256_DIGEST_SIZE]; /* * The binary header contains relevant context and section pointers */ efi_status = read_header(data, datasize, context); if (EFI_ERROR(efi_status)) { perror(L"Failed to read header: %r\n", efi_status); return efi_status; } /* * Perform the image verification before we start copying data around * in order to load it. */ if (secure_mode()) { efi_status = verify_buffer(data, datasize, context, sha256hash, sha1hash); if (EFI_ERROR(efi_status)) { if (verbose) console_print(L"Verification failed: %r\n", efi_status); else console_error(L"Verification failed", efi_status); return efi_status; } else if (verbose) console_print(L"Verification succeeded\n"); } /* * Calculate the hash for the TPM measurement. * XXX: We're computing these twice in secure boot mode when the * buffers already contain the previously computed hashes. Also, * this is only useful for the TPM1.2 case. We should try to fix * this in a follow-up. */ efi_status = generate_hash(data, datasize, context, sha256hash, sha1hash); if (EFI_ERROR(efi_status)) return efi_status; /* Measure the binary into the TPM */ #ifdef REQUIRE_TPM efi_status = #endif tpm_log_pe((EFI_PHYSICAL_ADDRESS)(UINTN)data, datasize, (EFI_PHYSICAL_ADDRESS)(UINTN)context->ImageAddress, li->FilePath, sha1hash, 4); #ifdef REQUIRE_TPM if (efi_status != EFI_SUCCESS) { return efi_status; } #endif return EFI_SUCCESS; }
0
247,647
TEST_P(SslSocketTest, FailedClientCertificateHashVerificationWrongClientCertificate) { const std::string client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_key.pem" )EOF"; const std::string server_ctx_yaml = absl::StrCat(R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" verify_certificate_hash: ")EOF", TEST_SAN_URI_CERT_256_HASH, "\""); TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam()); testUtil(test_options.setExpectedServerStats("ssl.fail_verify_cert_hash")); }
0
229,299
cql_server::connection::init_cql_serialization_format() { _cql_serialization_format = cql_serialization_format(_version); }
0
248,318
DLLIMPORT cfg_t *cfg_getsec(cfg_t *cfg, const char *name) { cfg_opt_t *opt; long int index; opt = cfg_getopt_secidx(cfg, name, &index); return cfg_opt_getnsec(opt, index); }
0
437,715
static u64 pulse_width_count_to_ns(u16 count, u16 divider) { u64 n; u32 rem; /* * The 2 lsb's of the pulse width timer count are not readable, hence * the (count << 2) | 0x3 */ n = (((u64) count << 2) | 0x3) * (divider + 1) * 1000; /* millicycles */ rem = do_div(n, CX23888_IR_REFCLK_FREQ / 1000000); /* / MHz => ns */ if (rem >= CX23888_IR_REFCLK_FREQ / 1000000 / 2) n++; return n; }
0
369,184
static int io_statx(struct io_kiocb *req, unsigned int issue_flags) { struct io_statx *ctx = &req->statx; int ret; if (issue_flags & IO_URING_F_NONBLOCK) return -EAGAIN; ret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask, ctx->buffer); if (ret < 0) req_set_fail(req); io_req_complete(req, ret); return 0; }
0
506,432
rpa_add_realm(string_t *realms, const char *realm, const char *service) { str_append(realms, service); str_append_c(realms, '@'); str_append(realms, realm); str_append_c(realms, ' '); }
0
256,434
static pj_status_t add_sdp_attr_rtcp_fb( pj_pool_t *pool, const char *pt, const pjmedia_rtcp_fb_cap *cap, pjmedia_sdp_media *m) { pjmedia_sdp_attr *a; char tmp[128]; pj_str_t val; pj_str_t type_name = {0}; if (cap->type < PJMEDIA_RTCP_FB_OTHER) pj_cstr(&type_name, rtcp_fb_type_name[cap->type].name); else if (cap->type == PJMEDIA_RTCP_FB_OTHER) type_name = cap->type_name; if (type_name.slen == 0) return PJ_EINVAL; /* Generate RTCP FB param */ if (cap->param.slen) { pj_ansi_snprintf(tmp, sizeof(tmp), "%s %.*s %.*s", pt, (int)type_name.slen, type_name.ptr, (int)cap->param.slen, cap->param.ptr); } else { pj_ansi_snprintf(tmp, sizeof(tmp), "%s %.*s", pt, (int)type_name.slen, type_name.ptr); } pj_strset2(&val, tmp); /* Generate and add SDP attribute a=rtcp-fb */ a = pjmedia_sdp_attr_create(pool, "rtcp-fb", &val); m->attr[m->attr_count++] = a; return PJ_SUCCESS; }
0
300,750
static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, struct msghdr *m, struct tipc_member *mb, u32 dnode, u32 dport, int dlen) { u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group); struct tipc_mc_method *method = &tsk->mc_method; int blks = tsk_blocks(GROUP_H_SIZE + dlen); struct tipc_msg *hdr = &tsk->phdr; struct sk_buff_head pkts; int mtu, rc; /* Complete message header */ msg_set_type(hdr, TIPC_GRP_UCAST_MSG); msg_set_hdr_sz(hdr, GROUP_H_SIZE); msg_set_destport(hdr, dport); msg_set_destnode(hdr, dnode); msg_set_grp_bc_seqno(hdr, bc_snd_nxt); /* Build message as chain of buffers */ __skb_queue_head_init(&pkts); mtu = tipc_node_get_mtu(net, dnode, tsk->portid, false); rc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts); if (unlikely(rc != dlen)) return rc; /* Send message */ rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); if (unlikely(rc == -ELINKCONG)) { tipc_dest_push(&tsk->cong_links, dnode, 0); tsk->cong_link_cnt++; } /* Update send window */ tipc_group_update_member(mb, blks); /* A broadcast sent within next EXPIRE period must follow same path */ method->rcast = true; method->mandatory = true; return dlen; }
0
410,714
static int packet_do_bind(struct sock *sk, const char *name, int ifindex, __be16 proto) { struct packet_sock *po = pkt_sk(sk); struct net_device *dev_curr; __be16 proto_curr; bool need_rehook; struct net_device *dev = NULL; int ret = 0; bool unlisted = false; lock_sock(sk); spin_lock(&po->bind_lock); rcu_read_lock(); if (po->fanout) { ret = -EINVAL; goto out_unlock; } if (name) { dev = dev_get_by_name_rcu(sock_net(sk), name); if (!dev) { ret = -ENODEV; goto out_unlock; } } else if (ifindex) { dev = dev_get_by_index_rcu(sock_net(sk), ifindex); if (!dev) { ret = -ENODEV; goto out_unlock; } } dev_hold(dev); proto_curr = po->prot_hook.type; dev_curr = po->prot_hook.dev; need_rehook = proto_curr != proto || dev_curr != dev; if (need_rehook) { if (po->running) { rcu_read_unlock(); /* prevents packet_notifier() from calling * register_prot_hook() */ WRITE_ONCE(po->num, 0); __unregister_prot_hook(sk, true); rcu_read_lock(); dev_curr = po->prot_hook.dev; if (dev) unlisted = !dev_get_by_index_rcu(sock_net(sk), dev->ifindex); } BUG_ON(po->running); WRITE_ONCE(po->num, proto); po->prot_hook.type = proto; if (unlikely(unlisted)) { dev_put(dev); po->prot_hook.dev = NULL; WRITE_ONCE(po->ifindex, -1); packet_cached_dev_reset(po); } else { po->prot_hook.dev = dev; WRITE_ONCE(po->ifindex, dev ? dev->ifindex : 0); packet_cached_dev_assign(po, dev); } } dev_put(dev_curr); if (proto == 0 || !need_rehook) goto out_unlock; if (!unlisted && (!dev || (dev->flags & IFF_UP))) { register_prot_hook(sk); } else { sk->sk_err = ENETDOWN; if (!sock_flag(sk, SOCK_DEAD)) sk_error_report(sk); } out_unlock: rcu_read_unlock(); spin_unlock(&po->bind_lock); release_sock(sk); return ret; }
0
513,237
static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list, bool *changed) { if (expr->argument_count()) { Name_resolution_context *context= &thd->lex->current_select->context; Item **arg,**arg_end; bool arg_changed= FALSE; for (arg= expr->arguments(), arg_end= expr->arguments() + expr->argument_count(); arg != arg_end; arg++) { Item *item= *arg; if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM) { ORDER *group_tmp; for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) { if (item->eq(*group_tmp->item,0)) { Item *new_item; if (!(new_item= new (thd->mem_root) Item_ref(thd, context, group_tmp->item, 0, item->name))) return 1; // fatal_error is set thd->change_item_tree(arg, new_item); arg_changed= TRUE; } } } else if (item->type() == Item::FUNC_ITEM) { if (change_group_ref(thd, (Item_func *) item, group_list, &arg_changed)) return 1; } } if (arg_changed) { expr->maybe_null= 1; expr->in_rollup= 1; *changed= TRUE; } } return 0; }
0
233,872
*/ static void php_wddx_add_var(wddx_packet *packet, zval *name_var) { zval *val; HashTable *target_hash; if (Z_TYPE_P(name_var) == IS_STRING) { zend_array *symbol_table = zend_rebuild_symbol_table(); if ((val = zend_hash_find(symbol_table, Z_STR_P(name_var))) != NULL) { if (Z_TYPE_P(val) == IS_INDIRECT) { val = Z_INDIRECT_P(val); } php_wddx_serialize_var(packet, val, Z_STR_P(name_var)); } } else if (Z_TYPE_P(name_var) == IS_ARRAY || Z_TYPE_P(name_var) == IS_OBJECT) { int is_array = Z_TYPE_P(name_var) == IS_ARRAY; target_hash = HASH_OF(name_var); if (is_array && target_hash->u.v.nApplyCount > 1) { php_error_docref(NULL, E_WARNING, "recursion detected"); return; } if (Z_IMMUTABLE_P(name_var)) { ZEND_HASH_FOREACH_VAL(target_hash, val) { php_wddx_add_var(packet, val); } ZEND_HASH_FOREACH_END(); } else { ZEND_HASH_FOREACH_VAL(target_hash, val) { if (is_array) { target_hash->u.v.nApplyCount++; } ZVAL_DEREF(val); php_wddx_add_var(packet, val); if (is_array) { target_hash->u.v.nApplyCount--; } } ZEND_HASH_FOREACH_END(); } }
0
248,291
DLLIMPORT cfg_value_t *cfg_setopt(cfg_t *cfg, cfg_opt_t *opt, const char *value) { cfg_value_t *val = NULL; const char *s; char *endptr; long int i; double f; void *p; int b; if (!cfg || !opt) { errno = EINVAL; return NULL; } if (opt->simple_value.ptr) { if (opt->type == CFGT_SEC) { errno = EINVAL; return NULL; } val = (cfg_value_t *)opt->simple_value.ptr; } else { if (is_set(CFGF_RESET, opt->flags)) { cfg_free_value(opt); opt->flags &= ~CFGF_RESET; } if (opt->nvalues == 0 || is_set(CFGF_MULTI, opt->flags) || is_set(CFGF_LIST, opt->flags)) { val = NULL; if (opt->type == CFGT_SEC && is_set(CFGF_TITLE, opt->flags)) { unsigned int i; /* XXX: Check if there already is a section with the same title. */ /* * Check there are either no sections at * all, or a non-NULL section title. */ if (opt->nvalues != 0 && !value) { errno = EINVAL; return NULL; } for (i = 0; i < opt->nvalues && val == NULL; i++) { cfg_t *sec = opt->values[i]->section; if (is_set(CFGF_NOCASE, cfg->flags)) { if (strcasecmp(value, sec->title) == 0) val = opt->values[i]; } else { if (strcmp(value, sec->title) == 0) val = opt->values[i]; } } if (val && is_set(CFGF_NO_TITLE_DUPES, opt->flags)) { cfg_error(cfg, _("found duplicate title '%s'"), value); return NULL; } } if (!val) { val = cfg_addval(opt); if (!val) return NULL; } } else { val = opt->values[0]; } } switch (opt->type) { case CFGT_INT: if (opt->parsecb) { if ((*opt->parsecb) (cfg, opt, value, &i) != 0) return NULL; } else { const char *str; int radix = 0; if (!value) { errno = EINVAL; return NULL; } str = value; if (value[0] == '0') { switch (value[1]) { case 'b': radix = 2; str = &value[2]; break; case 'x': radix = 16; str = &value[2]; break; default: radix = 8; str = &value[1]; } } i = strtol(str, &endptr, radix); if (*endptr != '\0') { cfg_error(cfg, _("invalid integer value for option '%s'"), opt->name); return NULL; } if (errno == ERANGE) { cfg_error(cfg, _("integer value for option '%s' is out of range"), opt->name); return NULL; } } val->number = i; break; case CFGT_FLOAT: if (opt->parsecb) { if ((*opt->parsecb) (cfg, opt, value, &f) != 0) return NULL; } else { if (!value) { errno = EINVAL; return NULL; } f = strtod(value, &endptr); if (*endptr != '\0') { cfg_error(cfg, _("invalid floating point value for option '%s'"), opt->name); return NULL; } if (errno == ERANGE) { cfg_error(cfg, _("floating point value for option '%s' is out of range"), opt->name); return NULL; } } val->fpnumber = f; break; case CFGT_STR: if (opt->parsecb) { s = NULL; if ((*opt->parsecb) (cfg, opt, value, &s) != 0) return NULL; } else { s = value; } if (!s) { errno = EINVAL; return NULL; } free(val->string); val->string = strdup(s); if (!val->string) return NULL; break; case CFGT_SEC: if (is_set(CFGF_MULTI, opt->flags) || val->section == NULL) { if (val->section) { val->section->path = NULL; /* Global search path */ cfg_free(val->section); } val->section = calloc(1, sizeof(cfg_t)); if (!val->section) return NULL; val->section->name = strdup(opt->name); if (!val->section->name) { free(val->section); return NULL; } val->section->flags = cfg->flags; if (is_set(CFGF_KEYSTRVAL, opt->flags)) val->section->flags |= CFGF_KEYSTRVAL; val->section->filename = cfg->filename ? strdup(cfg->filename) : NULL; if (cfg->filename && !val->section->filename) { free(val->section->name); free(val->section); return NULL; } val->section->line = cfg->line; val->section->errfunc = cfg->errfunc; val->section->title = value ? strdup(value) : NULL; if (value && !val->section->title) { free(val->section->filename); free(val->section->name); free(val->section); return NULL; } val->section->opts = cfg_dupopt_array(opt->subopts); if (!val->section->opts) { if (val->section->title) free(val->section->title); if (val->section->filename) free(val->section->filename); free(val->section->name); free(val->section); return NULL; } } if (!is_set(CFGF_DEFINIT, opt->flags)) cfg_init_defaults(val->section); break; case CFGT_BOOL: if (opt->parsecb) { if ((*opt->parsecb) (cfg, opt, value, &b) != 0) return NULL; } else { b = cfg_parse_boolean(value); if (b == -1) { cfg_error(cfg, _("invalid boolean value for option '%s'"), opt->name); return NULL; } } val->boolean = (cfg_bool_t)b; break; case CFGT_PTR: if (!opt->parsecb) { errno = EINVAL; return NULL; } if ((*opt->parsecb) (cfg, opt, value, &p) != 0) return NULL; if (val->ptr && opt->freecb) opt->freecb(val->ptr); val->ptr = p; break; default: cfg_error(cfg, "internal error in cfg_setopt(%s, %s)", opt->name, (value) ? (value) : "NULL"); return NULL; } opt->flags |= CFGF_MODIFIED; return val; }
0
338,233
static char formatNibble(int nibble) { return nibble < 10 ? '0' + nibble : 'a' - 10 + nibble; }
0
231,035
BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) { BaseType_t xReturn; Queue_t * const pxMutex = ( Queue_t * ) xMutex; configASSERT( pxMutex ); /* If this is the task that holds the mutex then xMutexHolder will not * change outside of this task. If this task does not hold the mutex then * pxMutexHolder can never coincidentally equal the tasks handle, and as * this is the only condition we are interested in it does not matter if * pxMutexHolder is accessed simultaneously by another task. Therefore no * mutual exclusion is required to test the pxMutexHolder variable. */ if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() ) { traceGIVE_MUTEX_RECURSIVE( pxMutex ); /* uxRecursiveCallCount cannot be zero if xMutexHolder is equal to * the task handle, therefore no underflow check is required. Also, * uxRecursiveCallCount is only modified by the mutex holder, and as * there can only be one, no mutual exclusion is required to modify the * uxRecursiveCallCount member. */ ( pxMutex->u.xSemaphore.uxRecursiveCallCount )--; /* Has the recursive call count unwound to 0? */ if( pxMutex->u.xSemaphore.uxRecursiveCallCount == ( UBaseType_t ) 0 ) { /* Return the mutex. This will automatically unblock any other * task that might be waiting to access the mutex. */ ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK ); } else { mtCOVERAGE_TEST_MARKER(); } xReturn = pdPASS; } else { /* The mutex cannot be given because the calling task is not the * holder. */ xReturn = pdFAIL; traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ); } return xReturn; }
0
225,472
void MutableGraphView::UpdateMaxRegularOutputPortForAddedFanin( const OutputPort& fanin) { if (max_regular_output_port()[fanin.node] < fanin.port_id) { max_regular_output_port()[fanin.node] = fanin.port_id; } }
0
393,509
static SQInteger closure_getroot(HSQUIRRELVM v) { if(SQ_FAILED(sq_getclosureroot(v,-1))) return SQ_ERROR; return 1; }
0
424,931
int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) { int ret; int t = 0; int iter; IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n"); ret = iwl_pcie_set_hw_ready(trans); /* If the card is ready, exit 0 */ if (ret >= 0) return 0; iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, CSR_RESET_LINK_PWR_MGMT_DISABLED); usleep_range(1000, 2000); for (iter = 0; iter < 10; iter++) { /* If HW is not ready, prepare the conditions to check again */ iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); do { ret = iwl_pcie_set_hw_ready(trans); if (ret >= 0) return 0; usleep_range(200, 1000); t += 200; } while (t < 150000); msleep(25); } IWL_ERR(trans, "Couldn't prepare the card\n"); return ret; }
0
279,914
ex_append(exarg_T *eap) { char_u *theline; int did_undo = FALSE; linenr_T lnum = eap->line2; int indent = 0; char_u *p; int vcol; int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); #ifdef FEAT_EVAL if (not_in_vim9(eap) == FAIL) return; #endif // the ! flag toggles autoindent if (eap->forceit) curbuf->b_p_ai = !curbuf->b_p_ai; // First autoindent comes from the line we start on if (eap->cmdidx != CMD_change && curbuf->b_p_ai && lnum > 0) append_indent = get_indent_lnum(lnum); if (eap->cmdidx != CMD_append) --lnum; // when the buffer is empty need to delete the dummy line if (empty && lnum == 1) lnum = 0; State = INSERT; // behave like in Insert mode if (curbuf->b_p_iminsert == B_IMODE_LMAP) State |= LANGMAP; for (;;) { msg_scroll = TRUE; need_wait_return = FALSE; if (curbuf->b_p_ai) { if (append_indent >= 0) { indent = append_indent; append_indent = -1; } else if (lnum > 0) indent = get_indent_lnum(lnum); } ex_keep_indent = FALSE; if (eap->getline == NULL) { // No getline() function, use the lines that follow. This ends // when there is no more. if (eap->nextcmd == NULL || *eap->nextcmd == NUL) break; p = vim_strchr(eap->nextcmd, NL); if (p == NULL) p = eap->nextcmd + STRLEN(eap->nextcmd); theline = vim_strnsave(eap->nextcmd, p - eap->nextcmd); if (*p != NUL) ++p; eap->nextcmd = p; } else { int save_State = State; // Set State to avoid the cursor shape to be set to INSERT mode // when getline() returns. State = CMDLINE; theline = eap->getline( #ifdef FEAT_EVAL eap->cstack->cs_looplevel > 0 ? -1 : #endif NUL, eap->cookie, indent, TRUE); State = save_State; } lines_left = Rows - 1; if (theline == NULL) break; // Using ^ CTRL-D in getexmodeline() makes us repeat the indent. if (ex_keep_indent) append_indent = indent; // Look for the "." after automatic indent. vcol = 0; for (p = theline; indent > vcol; ++p) { if (*p == ' ') ++vcol; else if (*p == TAB) vcol += 8 - vcol % 8; else break; } if ((p[0] == '.' && p[1] == NUL) || (!did_undo && u_save(lnum, lnum + 1 + (empty ? 1 : 0)) == FAIL)) { vim_free(theline); break; } // don't use autoindent if nothing was typed. if (p[0] == NUL) theline[0] = NUL; did_undo = TRUE; ml_append(lnum, theline, (colnr_T)0, FALSE); if (empty) // there are no marks below the inserted lines appended_lines(lnum, 1L); else appended_lines_mark(lnum, 1L); vim_free(theline); ++lnum; if (empty) { ml_delete(2L); empty = FALSE; } } State = NORMAL; if (eap->forceit) curbuf->b_p_ai = !curbuf->b_p_ai; // "start" is set to eap->line2+1 unless that position is invalid (when // eap->line2 pointed to the end of the buffer and nothing was appended) // "end" is set to lnum when something has been appended, otherwise // it is the same as "start" -- Acevedo if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count; if (eap->cmdidx != CMD_append) --curbuf->b_op_start.lnum; curbuf->b_op_end.lnum = (eap->line2 < lnum) ? lnum : curbuf->b_op_start.lnum; curbuf->b_op_start.col = curbuf->b_op_end.col = 0; } curwin->w_cursor.lnum = lnum; check_cursor_lnum(); beginline(BL_SOL | BL_FIX); need_wait_return = FALSE; // don't use wait_return() now ex_no_reprint = TRUE; }
0
314,477
static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault, struct guest_walker *gw) { struct kvm_mmu_page *sp = NULL; struct kvm_shadow_walk_iterator it; unsigned int direct_access, access; int top_level, ret; gfn_t base_gfn = fault->gfn; WARN_ON_ONCE(gw->gfn != base_gfn); direct_access = gw->pte_access; top_level = vcpu->arch.mmu->root_level; if (top_level == PT32E_ROOT_LEVEL) top_level = PT32_ROOT_LEVEL; /* * Verify that the top-level gpte is still there. Since the page * is a root page, it is either write protected (and cannot be * changed from now on) or it is invalid (in which case, we don't * really care if it changes underneath us after this point). */ if (FNAME(gpte_changed)(vcpu, gw, top_level)) goto out_gpte_changed; if (WARN_ON(!VALID_PAGE(vcpu->arch.mmu->root.hpa))) goto out_gpte_changed; for (shadow_walk_init(&it, vcpu, fault->addr); shadow_walk_okay(&it) && it.level > gw->level; shadow_walk_next(&it)) { gfn_t table_gfn; clear_sp_write_flooding_count(it.sptep); drop_large_spte(vcpu, it.sptep); sp = NULL; if (!is_shadow_present_pte(*it.sptep)) { table_gfn = gw->table_gfn[it.level - 2]; access = gw->pt_access[it.level - 2]; sp = kvm_mmu_get_page(vcpu, table_gfn, fault->addr, it.level-1, false, access); /* * We must synchronize the pagetable before linking it * because the guest doesn't need to flush tlb when * the gpte is changed from non-present to present. * Otherwise, the guest may use the wrong mapping. * * For PG_LEVEL_4K, kvm_mmu_get_page() has already * synchronized it transiently via kvm_sync_page(). * * For higher level pagetable, we synchronize it via * the slower mmu_sync_children(). If it needs to * break, some progress has been made; return * RET_PF_RETRY and retry on the next #PF. * KVM_REQ_MMU_SYNC is not necessary but it * expedites the process. */ if (sp->unsync_children && mmu_sync_children(vcpu, sp, false)) return RET_PF_RETRY; } /* * Verify that the gpte in the page we've just write * protected is still there. */ if (FNAME(gpte_changed)(vcpu, gw, it.level - 1)) goto out_gpte_changed; if (sp) link_shadow_page(vcpu, it.sptep, sp); } kvm_mmu_hugepage_adjust(vcpu, fault); trace_kvm_mmu_spte_requested(fault); for (; shadow_walk_okay(&it); shadow_walk_next(&it)) { clear_sp_write_flooding_count(it.sptep); /* * We cannot overwrite existing page tables with an NX * large page, as the leaf could be executable. */ if (fault->nx_huge_page_workaround_enabled) disallowed_hugepage_adjust(fault, *it.sptep, it.level); base_gfn = fault->gfn & ~(KVM_PAGES_PER_HPAGE(it.level) - 1); if (it.level == fault->goal_level) break; validate_direct_spte(vcpu, it.sptep, direct_access); drop_large_spte(vcpu, it.sptep); if (!is_shadow_present_pte(*it.sptep)) { sp = kvm_mmu_get_page(vcpu, base_gfn, fault->addr, it.level - 1, true, direct_access); link_shadow_page(vcpu, it.sptep, sp); if (fault->huge_page_disallowed && fault->req_level >= it.level) account_huge_nx_page(vcpu->kvm, sp); } } if (WARN_ON_ONCE(it.level != fault->goal_level)) return -EFAULT; ret = mmu_set_spte(vcpu, fault->slot, it.sptep, gw->pte_access, base_gfn, fault->pfn, fault); if (ret == RET_PF_SPURIOUS) return ret; FNAME(pte_prefetch)(vcpu, gw, it.sptep); ++vcpu->stat.pf_fixed; return ret; out_gpte_changed: return RET_PF_RETRY; }
0
316,990
static int selinux_dentry_init_security(struct dentry *dentry, int mode, const struct qstr *name, void **ctx, u32 *ctxlen) { u32 newsid; int rc; rc = selinux_determine_inode_label(selinux_cred(current_cred()), d_inode(dentry->d_parent), name, inode_mode_to_security_class(mode), &newsid); if (rc) return rc; return security_sid_to_context(&selinux_state, newsid, (char **)ctx, ctxlen); }
0
219,950
int callback_glewlwyd_check_admin_session_or_api_key (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid = NULL; json_t * j_user; int ret, res; const char * api_key = u_map_get_case(request->map_header, GLEWLWYD_API_KEY_HEADER_KEY), * ip_source = get_ip_source(request); if (NULL != api_key && 0 == o_strncmp(GLEWLWYD_API_KEY_HEADER_PREFIX, api_key, o_strlen(GLEWLWYD_API_KEY_HEADER_PREFIX))) { if ((res = verify_api_key(config, api_key + o_strlen(GLEWLWYD_API_KEY_HEADER_PREFIX))) == G_OK) { if (ulfius_set_response_shared_data(response, json_pack("{so}", "username", json_null()), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else if (res == G_ERROR_UNAUTHORIZED) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - API key invalid at IP Address %s", ip_source); ret = U_CALLBACK_UNAUTHORIZED; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_admin_session_or_api_key - Error verify_api_key"); ret = U_CALLBACK_ERROR; } } else if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if ((res = is_scope_list_valid_for_session(config, config->admin_scope, session_uid)) == G_OK) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { if (res == G_ERROR) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_admin_session_or_api_key - Error is_scope_list_valid_for_session"); } ret = U_CALLBACK_UNAUTHORIZED; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); o_free(session_uid); } else { ret = U_CALLBACK_UNAUTHORIZED; } return ret; }
0
513,199
static bool finalize_install(THD *thd, TABLE *table, const LEX_STRING *name, int *argc, char **argv) { struct st_plugin_int *tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN); int error; DBUG_ASSERT(tmp); mysql_mutex_assert_owner(&LOCK_plugin); // because of tmp->state if (tmp->state != PLUGIN_IS_UNINITIALIZED) { /* already installed */ return 0; } else { if (plugin_initialize(thd->mem_root, tmp, argc, argv, false)) { report_error(REPORT_TO_USER, ER_CANT_INITIALIZE_UDF, name->str, "Plugin initialization function failed."); tmp->state= PLUGIN_IS_DELETED; return 1; } } if (tmp->state == PLUGIN_IS_DISABLED) { if (global_system_variables.log_warnings) push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_CANT_INITIALIZE_UDF, ER_THD(thd, ER_CANT_INITIALIZE_UDF), name->str, "Plugin is disabled"); } /* We do not replicate the INSTALL PLUGIN statement. Disable binlogging of the insert into the plugin table, so that it is not replicated in row based mode. */ tmp_disable_binlog(thd); table->use_all_columns(); restore_record(table, s->default_values); table->field[0]->store(name->str, name->length, system_charset_info); table->field[1]->store(tmp->plugin_dl->dl.str, tmp->plugin_dl->dl.length, files_charset_info); error= table->file->ha_write_row(table->record[0]); reenable_binlog(thd); if (error) { table->file->print_error(error, MYF(0)); tmp->state= PLUGIN_IS_DELETED; return 1; } return 0; }
0
292,157
void CallInfo::set_common(Klass* resolved_klass, Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, CallKind kind, int index, TRAPS) { assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); _resolved_klass = resolved_klass; _selected_klass = selected_klass; _resolved_method = resolved_method; _selected_method = selected_method; _call_kind = kind; _call_index = index; _resolved_appendix = Handle(); DEBUG_ONLY(verify()); // verify before making side effects CompilationPolicy::compile_if_required(selected_method, THREAD); }
0
281,638
void CLASS foveon_load_camf() { unsigned type, wide, high, i, j, row, col, diff; ushort huff[258], vpred[2][2] = {{512,512},{512,512}}, hpred[2]; fseek (ifp, meta_offset, SEEK_SET); type = get4(); get4(); get4(); wide = get4(); high = get4(); if (type == 2) { fread (meta_data, 1, meta_length, ifp); for (i=0; i < meta_length; i++) { high = (high * 1597 + 51749) % 244944; wide = high * (INT64) 301593171 >> 24; meta_data[i] ^= ((((high << 8) - wide) >> 1) + wide) >> 17; } } else if (type == 4) { free (meta_data); meta_data = (char *) malloc (meta_length = wide*high*3/2); merror (meta_data, "foveon_load_camf()"); foveon_huff (huff); get4(); getbits(-1); for (j=row=0; row < high; row++) { for (col=0; col < wide; col++) { diff = ljpeg_diff(huff); if (col < 2) hpred[col] = vpred[row & 1][col] += diff; else hpred[col & 1] += diff; if (col & 1) { meta_data[j++] = hpred[0] >> 4; meta_data[j++] = hpred[0] << 4 | hpred[1] >> 8; meta_data[j++] = hpred[1]; } } } } #ifdef DCRAW_VERBOSE else fprintf (stderr,_("%s has unknown CAMF type %d.\n"), ifname, type); #endif }
0
244,042
GF_Box *dOps_box_new() { ISOM_DECL_BOX_ALLOC(GF_OpusSpecificBox, GF_ISOM_BOX_TYPE_DOPS); return (GF_Box *)tmp; }
0
232,333
void gf_isom_box_array_reset_parent(GF_List **child_boxes, GF_List *boxlist) { u32 count, i; if (!boxlist) return; count = gf_list_count(boxlist); for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(boxlist, i); if (a) gf_isom_box_del_parent(child_boxes, a); } gf_list_reset(boxlist); }
0
387,856
void InstanceKlass::set_source_debug_extension(const char* array, int length) { if (array == NULL) { _source_debug_extension = NULL; } else { // Adding one to the attribute length in order to store a null terminator // character could cause an overflow because the attribute length is // already coded with an u4 in the classfile, but in practice, it's // unlikely to happen. assert((length+1) > length, "Overflow checking"); char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass); for (int i = 0; i < length; i++) { sde[i] = array[i]; } sde[length] = '\0'; _source_debug_extension = sde; } }
0
349,525
static int virtbt_probe(struct virtio_device *vdev) { vq_callback_t *callbacks[VIRTBT_NUM_VQS] = { [VIRTBT_VQ_TX] = virtbt_tx_done, [VIRTBT_VQ_RX] = virtbt_rx_done, }; const char *names[VIRTBT_NUM_VQS] = { [VIRTBT_VQ_TX] = "tx", [VIRTBT_VQ_RX] = "rx", }; struct virtio_bluetooth *vbt; struct hci_dev *hdev; int err; __u8 type; if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) return -ENODEV; type = virtio_cread8(vdev, offsetof(struct virtio_bt_config, type)); switch (type) { case VIRTIO_BT_CONFIG_TYPE_PRIMARY: case VIRTIO_BT_CONFIG_TYPE_AMP: break; default: return -EINVAL; } vbt = kzalloc(sizeof(*vbt), GFP_KERNEL); if (!vbt) return -ENOMEM; vdev->priv = vbt; vbt->vdev = vdev; INIT_WORK(&vbt->rx, virtbt_rx_work); err = virtio_find_vqs(vdev, VIRTBT_NUM_VQS, vbt->vqs, callbacks, names, NULL); if (err) return err; hdev = hci_alloc_dev(); if (!hdev) { err = -ENOMEM; goto failed; } vbt->hdev = hdev; hdev->bus = HCI_VIRTIO; hdev->dev_type = type; hci_set_drvdata(hdev, vbt); hdev->open = virtbt_open; hdev->close = virtbt_close; hdev->flush = virtbt_flush; hdev->send = virtbt_send_frame; if (virtio_has_feature(vdev, VIRTIO_BT_F_VND_HCI)) { __u16 vendor; virtio_cread(vdev, struct virtio_bt_config, vendor, &vendor); switch (vendor) { case VIRTIO_BT_CONFIG_VENDOR_ZEPHYR: hdev->manufacturer = 1521; hdev->setup = virtbt_setup_zephyr; hdev->shutdown = virtbt_shutdown_generic; hdev->set_bdaddr = virtbt_set_bdaddr_zephyr; break; case VIRTIO_BT_CONFIG_VENDOR_INTEL: hdev->manufacturer = 2; hdev->setup = virtbt_setup_intel; hdev->shutdown = virtbt_shutdown_generic; hdev->set_bdaddr = virtbt_set_bdaddr_intel; set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks); break; case VIRTIO_BT_CONFIG_VENDOR_REALTEK: hdev->manufacturer = 93; hdev->setup = virtbt_setup_realtek; hdev->shutdown = virtbt_shutdown_generic; set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks); break; } } if (virtio_has_feature(vdev, VIRTIO_BT_F_MSFT_EXT)) { __u16 msft_opcode; virtio_cread(vdev, struct virtio_bt_config, msft_opcode, &msft_opcode); hci_set_msft_opcode(hdev, msft_opcode); } if (virtio_has_feature(vdev, VIRTIO_BT_F_AOSP_EXT)) hci_set_aosp_capable(hdev); if (hci_register_dev(hdev) < 0) { hci_free_dev(hdev); err = -EBUSY; goto failed; } return 0; failed: vdev->config->del_vqs(vdev); return err; }
0
508,859
Lex_input_stream::reset(char *buffer, unsigned int length) { yylineno= 1; yylval= NULL; lookahead_token= -1; lookahead_yylval= NULL; m_ptr= buffer; m_tok_start= NULL; m_tok_end= NULL; m_end_of_query= buffer + length; m_tok_start_prev= NULL; m_buf= buffer; m_buf_length= length; m_echo= TRUE; m_cpp_tok_start= NULL; m_cpp_tok_start_prev= NULL; m_cpp_tok_end= NULL; m_body_utf8= NULL; m_cpp_utf8_processed_ptr= NULL; next_state= MY_LEX_START; found_semicolon= NULL; ignore_space= MY_TEST(m_thd->variables.sql_mode & MODE_IGNORE_SPACE); stmt_prepare_mode= FALSE; multi_statements= TRUE; in_comment=NO_COMMENT; m_underscore_cs= NULL; m_cpp_ptr= m_cpp_buf; }
0
246,466
static void wasm_sec_free(RBinWasmSection *sec) { if (sec) { free (sec->name); free (sec); } }
0
90,788
QuotaCallback* NewWaitableGlobalQuotaCallback() { ++waiting_callbacks_; return callback_factory_.NewCallback( &UsageAndQuotaDispatcherTask::DidGetGlobalQuota); }
0
430,458
size_t ovs_tun_key_attr_size(void) { /* Whenever adding new OVS_TUNNEL_KEY_ FIELDS, we should consider * updating this function. */ return nla_total_size_64bit(8) /* OVS_TUNNEL_KEY_ATTR_ID */ + nla_total_size(16) /* OVS_TUNNEL_KEY_ATTR_IPV[46]_SRC */ + nla_total_size(16) /* OVS_TUNNEL_KEY_ATTR_IPV[46]_DST */ + nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TOS */ + nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TTL */ + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */ + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_CSUM */ + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_OAM */ + nla_total_size(256) /* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS */ /* OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS and * OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS is mutually exclusive with * OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS and covered by it. */ + nla_total_size(2) /* OVS_TUNNEL_KEY_ATTR_TP_SRC */ + nla_total_size(2); /* OVS_TUNNEL_KEY_ATTR_TP_DST */ }
0
220,230
const NodeDef& Node::def() const { return props_->node_def; }
0
231,703
TEST_F(QuicServerTransportTest, TimeoutsNotSetAfterClose) { StreamId streamId = server->createBidirectionalStream().value(); auto expected = IOBuf::copyBuffer("hello"); auto packet = packetToBuf(createStreamPacket( *clientConnectionId, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++, streamId, *expected, 0 /* cipherOverhead */, 0 /* largestAcked */)); server->close(std::make_pair( QuicErrorCode(TransportErrorCode::INTERNAL_ERROR), std::string("how about no"))); server->idleTimeout().cancelTimeout(); ASSERT_FALSE(server->idleTimeout().isScheduled()); deliverDataWithoutErrorCheck(packet->clone()); ASSERT_FALSE(server->idleTimeout().isScheduled()); ASSERT_FALSE(server->lossTimeout().isScheduled()); ASSERT_FALSE(server->ackTimeout().isScheduled()); ASSERT_TRUE(server->drainTimeout().isScheduled()); }
0
313,544
__acquires(rose_neigh_list_lock) { struct rose_neigh *rose_neigh; int i = 1; spin_lock_bh(&rose_neigh_list_lock); if (*pos == 0) return SEQ_START_TOKEN; for (rose_neigh = rose_neigh_list; rose_neigh && i < *pos; rose_neigh = rose_neigh->next, ++i); return (i == *pos) ? rose_neigh : NULL; }
0
218,764
static void XHighlightWidget(Display *display,const XWindowInfo *window_info, const int x,const int y) { /* Draw the widget highlighting rectangle. */ XSetBevelColor(display,window_info,MagickTrue); (void) XDrawRectangle(display,window_info->id,window_info->widget_context,x,y, window_info->width-(x << 1),window_info->height-(y << 1)); (void) XDrawRectangle(display,window_info->id,window_info->widget_context, x-1,y-1,window_info->width-(x << 1)+1,window_info->height-(y << 1)+1); XSetBevelColor(display,window_info,MagickFalse); (void) XDrawRectangle(display,window_info->id,window_info->widget_context, x-1,y-1,window_info->width-(x << 1),window_info->height-(y << 1)); (void) XSetFillStyle(display,window_info->widget_context,FillSolid); }
0
274,714
callbacks_save_project_activate (GtkMenuItem *menuitem, gpointer user_data) { if (mainProject->project) main_save_project_from_filename (mainProject, mainProject->project); else callbacks_generic_save_activate (menuitem, (gpointer) CALLBACKS_SAVE_PROJECT_AS); callbacks_update_layer_tree(); return; }
0
226,010
GF_Err hinf_box_read(GF_Box *s, GF_BitStream *bs) { return gf_isom_box_array_read(s, bs); }
0
343,159
static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) { int alen; int blksize; struct ip_esp_hdr *esph; struct crypto_aead *aead; struct esp_info esp; esp.inplace = true; esp.proto = *skb_mac_header(skb); *skb_mac_header(skb) = IPPROTO_ESP; /* skb is pure payload to encrypt */ aead = x->data; alen = crypto_aead_authsize(aead); esp.tfclen = 0; if (x->tfcpad) { struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); u32 padto; padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached)); if (skb->len < padto) esp.tfclen = padto - skb->len; } blksize = ALIGN(crypto_aead_blocksize(aead), 4); esp.clen = ALIGN(skb->len + 2 + esp.tfclen, blksize); esp.plen = esp.clen - skb->len - esp.tfclen; esp.tailen = esp.tfclen + esp.plen + alen; esp.esph = ip_esp_hdr(skb); esp.nfrags = esp6_output_head(x, skb, &esp); if (esp.nfrags < 0) return esp.nfrags; esph = esp.esph; esph->spi = x->id.spi; esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low); esp.seqno = cpu_to_be64(XFRM_SKB_CB(skb)->seq.output.low + ((u64)XFRM_SKB_CB(skb)->seq.output.hi << 32)); skb_push(skb, -skb_network_offset(skb)); return esp6_output_tail(x, skb, &esp); }
0
455,351
bash_forward_shellword (count, key) int count, key; { size_t slen; int c, p; DECLARE_MBSTATE; if (count < 0) return (bash_backward_shellword (-count, key)); /* The tricky part of this is deciding whether or not the first character we're on is an unquoted metacharacter. Not completely handled yet. */ /* XXX - need to test this stuff with backslash-escaped shell metacharacters and unclosed single- and double-quoted strings. */ p = rl_point; slen = rl_end; while (count) { if (p == rl_end) { rl_point = rl_end; return 0; } /* Are we in a quoted string? If we are, move to the end of the quoted string and continue the outer loop. We only want quoted strings, not backslash-escaped characters, but char_is_quoted doesn't differentiate. */ if (char_is_quoted (rl_line_buffer, p) && p > 0 && rl_line_buffer[p-1] != '\\') { do ADVANCE_CHAR (rl_line_buffer, slen, p); while (p < rl_end && char_is_quoted (rl_line_buffer, p)); count--; continue; } /* Rest of code assumes we are not in a quoted string. */ /* Move forward until we hit a non-metacharacter. */ while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c)) { switch (c) { default: ADVANCE_CHAR (rl_line_buffer, slen, p); continue; /* straight back to loop, don't increment p */ case '\\': if (p < rl_end && rl_line_buffer[p]) ADVANCE_CHAR (rl_line_buffer, slen, p); break; case '\'': p = skip_to_delim (rl_line_buffer, ++p, "'", SD_NOJMP); break; case '"': p = skip_to_delim (rl_line_buffer, ++p, "\"", SD_NOJMP); break; } if (p < rl_end) p++; } if (rl_line_buffer[p] == 0 || p == rl_end) { rl_point = rl_end; rl_ding (); return 0; } /* Now move forward until we hit a non-quoted metacharacter or EOL */ while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c) == 0) { switch (c) { default: ADVANCE_CHAR (rl_line_buffer, slen, p); continue; /* straight back to loop, don't increment p */ case '\\': if (p < rl_end && rl_line_buffer[p]) ADVANCE_CHAR (rl_line_buffer, slen, p); break; case '\'': p = skip_to_delim (rl_line_buffer, ++p, "'", SD_NOJMP); break; case '"': p = skip_to_delim (rl_line_buffer, ++p, "\"", SD_NOJMP); break; } if (p < rl_end) p++; } if (p == rl_end || rl_line_buffer[p] == 0) { rl_point = rl_end; return (0); } count--; } rl_point = p; return (0); }
0
438,654
u_undofile_reset_and_delete(buf_T *buf) { char_u *file_name; if (!buf->b_p_udf) return; file_name = u_get_undo_file_name(buf->b_ffname, TRUE); if (file_name != NULL) { mch_remove(file_name); vim_free(file_name); } set_option_value((char_u *)"undofile", 0L, NULL, OPT_LOCAL); }
0
225,782
GF_Err def_parent_full_box_read(GF_Box *s, GF_BitStream *bs) { return gf_isom_box_array_read(s, bs); }
0
312,468
qf_find_help_win(void) { win_T *wp; FOR_ALL_WINDOWS(wp) if (bt_help(wp->w_buffer)) return wp; return NULL; }
0
243,008
static int mbedtls_ssl_dtls_record_replay_check( mbedtls_ssl_context *ssl, uint8_t *record_in_ctr ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char *original_in_ctr; // save original in_ctr original_in_ctr = ssl->in_ctr; // use counter from record ssl->in_ctr = record_in_ctr; ret = mbedtls_ssl_dtls_replay_check( (mbedtls_ssl_context const *) ssl ); // restore the counter ssl->in_ctr = original_in_ctr; return ret; }
0
207,700
TerminalUserInfo UserTerminalRouter::getInfoForId(const string &id) { auto it = idInfoMap.find(id); if (it == idInfoMap.end()) { STFATAL << " Tried to read from an id that no longer exists"; } return it->second; }
1