idx
int64
func
string
target
int64
448,316
SProcXkbGetNames(ClientPtr client) { REQUEST(xkbGetNamesReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetNamesReq); swaps(&stuff->deviceSpec); swapl(&stuff->which); return ProcXkbGetNames(client); }
0
236,785
void Document::setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, DOMWrapperWorld* isolatedWorld) { DOMWindow* domWindow = this->domWindow(); if (!domWindow) return; domWindow->setAttributeEventListener(eventType, listener, isolatedWorld); }
0
372,360
cmsHPROFILE CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint) { cmsHPROFILE hProfile; cmsPipeline* LUT = NULL; hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL); if (hProfile == NULL) return NULL; cmsSetProfileVersion(hProfile, 2.1); cmsSetDeviceClass(hProfile, cmsSigAbstractClass); cmsSetColorSpace(hProfile, cmsSigLabData); cmsSetPCS(hProfile, cmsSigLabData); if (!SetTextTags(hProfile, L"Lab identity built-in")) return NULL; // An identity LUT is all we need LUT = cmsPipelineAlloc(ContextID, 3, 3); if (LUT == NULL) goto Error; if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCLut(ContextID, 3))) goto Error; if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT)) goto Error; cmsPipelineFree(LUT); return hProfile; Error: if (LUT != NULL) cmsPipelineFree(LUT); if (hProfile != NULL) cmsCloseProfile(hProfile); return NULL; }
0
215,925
Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { DCHECK(touch_layout_); int active_tab_index = touch_layout_->active_index(); Tab* tab = FindTabForEventFrom(point, active_tab_index, -1); return tab ? tab : FindTabForEventFrom(point, active_tab_index + 1, 1); }
0
408,251
static void __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc) { int err; if (WARN_ON(!consumer_del(uprobe, uc))) return; err = register_for_each_vma(uprobe, NULL); /* TODO : cant unregister? schedule a worker thread */ if (!uprobe->consumers && !err) delete_uprobe(uprobe); }
0
389,247
test_HaveKeyIncorrect(void) { const keyid_t KEYNO = 2; TEST_ASSERT_FALSE(auth_havekey(KEYNO)); TEST_ASSERT_FALSE(authhavekey(KEYNO)); return; }
0
399,286
*/ void mpvio_info(Vio *vio, MYSQL_PLUGIN_VIO_INFO *info) { memset(info, 0, sizeof(*info)); switch (vio->type) { case VIO_TYPE_TCPIP: info->protocol= MYSQL_VIO_TCP; info->socket= vio_fd(vio); return; case VIO_TYPE_SOCKET: info->protocol= MYSQL_VIO_SOCKET; info->socket= vio_fd(vio); return; case VIO_TYPE_SSL: { struct sockaddr addr; socklen_t addrlen= sizeof(addr); if (getsockname(vio_fd(vio), &addr, &addrlen)) return; info->protocol= addr.sa_family == AF_UNIX ? MYSQL_VIO_SOCKET : MYSQL_VIO_TCP; info->socket= vio_fd(vio); return; } #ifdef _WIN32 case VIO_TYPE_NAMEDPIPE: info->protocol= MYSQL_VIO_PIPE; info->handle= vio->hPipe; return; #ifdef HAVE_SMEM case VIO_TYPE_SHARED_MEMORY: info->protocol= MYSQL_VIO_MEMORY; info->handle= vio->handle_file_map; /* or what ? */ return; #endif #endif default: DBUG_ASSERT(0); }
0
53,873
static void __iommu_free_atomic(struct device *dev, void *cpu_addr, dma_addr_t handle, size_t size) { __iommu_remove_mapping(dev, handle, size); __free_from_pool(cpu_addr, size); }
0
337,646
static inline int64_t get_sector_offset(BlockDriverState *bs, int64_t sector_num, int write) { BDRVVPCState *s = bs->opaque; uint64_t offset = sector_num * 512; uint64_t bitmap_offset, block_offset; uint32_t pagetable_index, pageentry_index; pagetable_index = offset / s->block_size; pageentry_index = (offset % s->block_size) / 512; if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff) return -1; // not allocated bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index]; block_offset = bitmap_offset + s->bitmap_size + (512 * pageentry_index); // We must ensure that we don't write to any sectors which are marked as // unused in the bitmap. We get away with setting all bits in the block // bitmap each time we write to a new block. This might cause Virtual PC to // miss sparse read optimization, but it's not a problem in terms of // correctness. if (write && (s->last_bitmap_offset != bitmap_offset)) { uint8_t bitmap[s->bitmap_size]; s->last_bitmap_offset = bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); bdrv_pwrite(bs->file, bitmap_offset, bitmap, s->bitmap_size); } // printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n", // sector_num, pagetable_index, pageentry_index, // bitmap_offset, block_offset); // disabled by reason #if 0 #ifdef CACHE if (bitmap_offset != s->last_bitmap) { lseek(s->fd, bitmap_offset, SEEK_SET); s->last_bitmap = bitmap_offset; // Scary! Bitmap is stored as big endian 32bit entries, // while we used to look it up byte by byte read(s->fd, s->pageentry_u8, 512); for (i = 0; i < 128; i++) be32_to_cpus(&s->pageentry_u32[i]); } if ((s->pageentry_u8[pageentry_index / 8] >> (pageentry_index % 8)) & 1) return -1; #else lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET); read(s->fd, &bitmap_entry, 1); if ((bitmap_entry >> (pageentry_index % 8)) & 1) return -1; // not allocated #endif #endif return block_offset; }
1
375,818
static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, void *opaque) { const VMStateSubsection *sub = vmsd->subsections; while (sub && sub->needed) { if (sub->needed(opaque)) { const VMStateDescription *vmsd = sub->vmsd; uint8_t len; qemu_put_byte(f, QEMU_VM_SUBSECTION); len = strlen(vmsd->name); qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)vmsd->name, len); qemu_put_be32(f, vmsd->version_id); vmstate_save_state(f, vmsd, opaque); } sub++; } }
0
59,376
static void nfs4_free_pages(struct page **pages, size_t size) { int i; if (!pages) return; for (i = 0; i < size; i++) { if (!pages[i]) break; __free_page(pages[i]); } kfree(pages); }
0
149,584
_Pickler_Write(PicklerObject *self, const char *s, Py_ssize_t data_len) { Py_ssize_t i, n, required; char *buffer; int need_new_frame; assert(s != NULL); need_new_frame = (self->framing && self->frame_start == -1); if (need_new_frame) n = data_len + FRAME_HEADER_SIZE; else n = data_len; required = self->output_len + n; if (required > self->max_output_len) { /* Make place in buffer for the pickle chunk */ if (self->output_len >= PY_SSIZE_T_MAX / 2 - n) { PyErr_NoMemory(); return -1; } self->max_output_len = (self->output_len + n) / 2 * 3; if (_PyBytes_Resize(&self->output_buffer, self->max_output_len) < 0) return -1; } buffer = PyBytes_AS_STRING(self->output_buffer); if (need_new_frame) { /* Setup new frame */ Py_ssize_t frame_start = self->output_len; self->frame_start = frame_start; for (i = 0; i < FRAME_HEADER_SIZE; i++) { /* Write an invalid value, for debugging */ buffer[frame_start + i] = 0xFE; } self->output_len += FRAME_HEADER_SIZE; } if (data_len < 8) { /* This is faster than memcpy when the string is short. */ for (i = 0; i < data_len; i++) { buffer[self->output_len + i] = s[i]; } } else { memcpy(buffer + self->output_len, s, data_len); } self->output_len += data_len; return data_len; }
0
161,562
STATIC void S_reginsert(pTHX_ RExC_state_t *pRExC_state, const U8 op, const regnode_offset operand, const U32 depth) { regnode *src; regnode *dst; regnode *place; const int offset = regarglen[(U8)op]; const int size = NODE_STEP_REGNODE + offset; GET_RE_DEBUG_FLAGS_DECL; PERL_ARGS_ASSERT_REGINSERT; PERL_UNUSED_CONTEXT; PERL_UNUSED_ARG(depth); /* (PL_regkind[(U8)op] == CURLY ? EXTRA_STEP_2ARGS : 0); */ DEBUG_PARSE_FMT("inst"," - %s", PL_reg_name[op]); assert(!RExC_study_started); /* I believe we should never use reginsert once we have started studying. If this is wrong then we need to adjust RExC_recurse below like we do with RExC_open_parens/RExC_close_parens. */ change_engine_size(pRExC_state, (Ptrdiff_t) size); src = REGNODE_p(RExC_emit); RExC_emit += size; dst = REGNODE_p(RExC_emit); /* If we are in a "count the parentheses" pass, the numbers are unreliable, * and [perl #133871] shows this can lead to problems, so skip this * realignment of parens until a later pass when they are reliable */ if (! IN_PARENS_PASS && RExC_open_parens) { int paren; /*DEBUG_PARSE_FMT("inst"," - %" IVdf, (IV)RExC_npar);*/ /* remember that RExC_npar is rex->nparens + 1, * iow it is 1 more than the number of parens seen in * the pattern so far. */ for ( paren=0 ; paren < RExC_npar ; paren++ ) { /* note, RExC_open_parens[0] is the start of the * regex, it can't move. RExC_close_parens[0] is the end * of the regex, it *can* move. */ if ( paren && RExC_open_parens[paren] >= operand ) { /*DEBUG_PARSE_FMT("open"," - %d", size);*/ RExC_open_parens[paren] += size; } else { /*DEBUG_PARSE_FMT("open"," - %s","ok");*/ } if ( RExC_close_parens[paren] >= operand ) { /*DEBUG_PARSE_FMT("close"," - %d", size);*/ RExC_close_parens[paren] += size; } else { /*DEBUG_PARSE_FMT("close"," - %s","ok");*/ } } } if (RExC_end_op) RExC_end_op += size; while (src > REGNODE_p(operand)) { StructCopy(--src, --dst, regnode); #ifdef RE_TRACK_PATTERN_OFFSETS if (RExC_offsets) { /* MJD 20010112 */ MJD_OFFSET_DEBUG( ("%s(%d): (op %s) %s copy %" UVuf " -> %" UVuf " (max %" UVuf ").\n", "reginsert", __LINE__, PL_reg_name[op], (UV)(REGNODE_OFFSET(dst)) > RExC_offsets[0] ? "Overwriting end of array!\n" : "OK", (UV)REGNODE_OFFSET(src), (UV)REGNODE_OFFSET(dst), (UV)RExC_offsets[0])); Set_Node_Offset_To_R(REGNODE_OFFSET(dst), Node_Offset(src)); Set_Node_Length_To_R(REGNODE_OFFSET(dst), Node_Length(src)); } #endif } place = REGNODE_p(operand); /* Op node, where operand used to be. */ #ifdef RE_TRACK_PATTERN_OFFSETS if (RExC_offsets) { /* MJD */ MJD_OFFSET_DEBUG( ("%s(%d): (op %s) %s %" UVuf " <- %" UVuf " (max %" UVuf ").\n", "reginsert", __LINE__, PL_reg_name[op], (UV)REGNODE_OFFSET(place) > RExC_offsets[0] ? "Overwriting end of array!\n" : "OK", (UV)REGNODE_OFFSET(place), (UV)(RExC_parse - RExC_start), (UV)RExC_offsets[0])); Set_Node_Offset(place, RExC_parse); Set_Node_Length(place, 1); } #endif src = NEXTOPER(place); FLAGS(place) = 0; FILL_NODE(operand, op); /* Zero out any arguments in the new node */ Zero(src, offset, regnode);
0
32,921
char *charset_client2fs(const char * const string) { char *output = NULL, *output_; size_t inlen, outlen, outlen_; inlen = strlen(string); outlen_ = outlen = inlen * (size_t) 4U + (size_t) 1U; if (outlen <= inlen || (output_ = output = calloc(outlen, (size_t) 1U)) == NULL) { die_mem(); } if (utf8 > 0 && strcasecmp(charset_fs, "utf-8") != 0) { if (iconv(iconv_fd_utf82fs, (char **) &string, &inlen, &output_, &outlen_) == (size_t) -1) { strncpy(output, string, outlen); } } else if (utf8 <= 0 && strcasecmp(charset_fs, charset_client) != 0) { if (iconv(iconv_fd_client2fs, (char **) &string, &inlen, &output_, &outlen_) == (size_t) -1) { strncpy(output, string, outlen); } } else { strncpy(output, string, outlen); } output[outlen - 1] = 0; return output; }
0
490,922
static void free_filters(filter_rule *ent) { while (ent) { filter_rule *next = ent->next; free_filter(ent); ent = next; } }
0
119,744
SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newname) { return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0); }
0
243,381
void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) { DestroyTouchSelection(); switch (command_id) { case IDC_PASTE_AND_GO: model()->PasteAndGo(GetClipboardText()); return; case IDS_SHOW_URL: model()->Unelide(true /* exit_query_in_omnibox */); return; case IDC_EDIT_SEARCH_ENGINES: location_bar_view_->command_updater()->ExecuteCommand(command_id); return; case IDC_SEND_TAB_TO_SELF: send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kOmniboxMenu, SendTabToSelfClickResult::kClickItem); send_tab_to_self::CreateNewEntry(location_bar_view_->GetWebContents()); return; case IDS_APP_PASTE: ExecuteTextEditCommand(ui::TextEditCommand::PASTE); return; default: if (Textfield::IsCommandIdEnabled(command_id)) { Textfield::ExecuteCommand(command_id, event_flags); return; } OnBeforePossibleChange(); location_bar_view_->command_updater()->ExecuteCommand(command_id); OnAfterPossibleChange(true); return; } }
0
75,804
GF_Err gf_isom_remove_edits(GF_ISOFile *movie, u32 trackNumber) { GF_Err e; GF_TrackBox *trak; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; if (!trak->editBox || !trak->editBox->editList) return GF_OK; while (gf_list_count(trak->editBox->editList->entryList)) { GF_EdtsEntry *ent = (GF_EdtsEntry*)gf_list_get(trak->editBox->editList->entryList, 0); gf_free(ent); e = gf_list_rem(trak->editBox->editList->entryList, 0); if (e) return e; } //then delete the GF_EditBox... gf_isom_box_del_parent(&trak->child_boxes, (GF_Box *)trak->editBox); trak->editBox = NULL; return SetTrackDuration(trak); }
0
32,853
void Filter::setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) { callbacks_ = &callbacks; // As the decoder filter only pushes back via watermarks once data has reached // it, it can latch the current buffer limit and does not need to update the // limit if another filter increases it. buffer_limit_ = callbacks_->decoderBufferLimit(); }
0
253,898
std::string GetFileNameFromCD(const std::string& header, const std::string& referrer_charset) { std::string decoded; std::string param_value = GetHeaderParamValue(header, "filename*", QuoteRule::KEEP_OUTER_QUOTES); if (!param_value.empty()) { if (param_value.find('"') == std::string::npos) { std::string charset; std::string value; if (DecodeCharset(param_value, &charset, &value)) { if (!IsStringASCII(value)) return std::string(); std::string tmp = UnescapeURLComponent( value, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); if (base::ConvertToUtf8AndNormalize(tmp, charset, &decoded)) return decoded; } } } param_value = GetHeaderParamValue(header, "filename", QuoteRule::REMOVE_OUTER_QUOTES); if (param_value.empty()) { param_value = GetHeaderParamValue(header, "name", QuoteRule::REMOVE_OUTER_QUOTES); } if (param_value.empty()) return std::string(); if (DecodeParamValue(param_value, referrer_charset, &decoded)) return decoded; return std::string(); }
0
522,075
Field *Type_handler_blob_common::make_conversion_table_field(TABLE *table, uint metadata, const Field *target) const { uint pack_length= metadata & 0x00ff; if (pack_length < 1 || pack_length > 4) return NULL; // Broken binary log? return new(table->in_use->mem_root) Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME, table->s, pack_length, target->charset()); }
0
516,438
static int test_gf2m_modinv(void) { BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL; int i, j, st = 0; if (!TEST_ptr(a = BN_new()) || !TEST_ptr(b[0] = BN_new()) || !TEST_ptr(b[1] = BN_new()) || !TEST_ptr(c = BN_new()) || !TEST_ptr(d = BN_new())) goto err; if (!(TEST_true(BN_GF2m_arr2poly(p0, b[0])) && TEST_true(BN_GF2m_arr2poly(p1, b[1])))) goto err; for (i = 0; i < NUM0; i++) { if (!TEST_true(BN_bntest_rand(a, 512, 0, 0))) goto err; for (j = 0; j < 2; j++) { if (!(TEST_true(BN_GF2m_mod_inv(c, a, b[j], ctx)) && TEST_true(BN_GF2m_mod_mul(d, a, c, b[j], ctx)) /* Test that ((1/a)*a) = 1. */ && TEST_BN_eq_one(d))) goto err; } } st = 1; err: BN_free(a); BN_free(b[0]); BN_free(b[1]); BN_free(c); BN_free(d); return st; }
0
279,505
void FramebufferManager::CreateFramebuffer( GLuint client_id, GLuint service_id) { std::pair<FramebufferMap::iterator, bool> result = framebuffers_.insert( std::make_pair( client_id, scoped_refptr<Framebuffer>( new Framebuffer(this, service_id)))); DCHECK(result.second); }
0
494,486
CURLcode Curl_unencode_write(struct Curl_easy *data, struct contenc_writer *writer, const char *buf, size_t nbytes) { (void) data; (void) writer; (void) buf; (void) nbytes; return CURLE_NOT_BUILT_IN; }
0
176,433
static void monitor_worker_process(int child_pid, const debugger_request_t& request) { struct timespec timeout = {.tv_sec = 10, .tv_nsec = 0 }; if (should_attach_gdb(request)) { timeout.tv_sec = INT_MAX; } sigset_t signal_set; sigemptyset(&signal_set); sigaddset(&signal_set, SIGCHLD); bool kill_worker = false; bool kill_target = false; bool kill_self = false; int status; siginfo_t siginfo; int signal = TEMP_FAILURE_RETRY(sigtimedwait(&signal_set, &siginfo, &timeout)); if (signal == SIGCHLD) { pid_t rc = waitpid(-1, &status, WNOHANG | WUNTRACED); if (rc != child_pid) { ALOGE("debuggerd: waitpid returned unexpected pid (%d), committing murder-suicide", rc); if (WIFEXITED(status)) { ALOGW("debuggerd: pid %d exited with status %d", rc, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { ALOGW("debuggerd: pid %d received signal %d", rc, WTERMSIG(status)); } else if (WIFSTOPPED(status)) { ALOGW("debuggerd: pid %d stopped by signal %d", rc, WSTOPSIG(status)); } else if (WIFCONTINUED(status)) { ALOGW("debuggerd: pid %d continued", rc); } kill_worker = true; kill_target = true; kill_self = true; } else if (WIFSIGNALED(status)) { ALOGE("debuggerd: worker process %d terminated due to signal %d", child_pid, WTERMSIG(status)); kill_worker = false; kill_target = true; } else if (WIFSTOPPED(status)) { ALOGE("debuggerd: worker process %d stopped due to signal %d", child_pid, WSTOPSIG(status)); kill_worker = true; kill_target = true; } } else { ALOGE("debuggerd: worker process %d timed out", child_pid); kill_worker = true; kill_target = true; } if (kill_worker) { if (kill(child_pid, SIGKILL) != 0) { ALOGE("debuggerd: failed to kill worker process %d: %s", child_pid, strerror(errno)); } else { waitpid(child_pid, &status, 0); } } int exit_signal = SIGCONT; if (kill_target && request.action == DEBUGGER_ACTION_CRASH) { ALOGE("debuggerd: killing target %d", request.pid); exit_signal = SIGKILL; } else { ALOGW("debuggerd: resuming target %d", request.pid); } if (kill(request.pid, exit_signal) != 0) { ALOGE("debuggerd: failed to send signal %d to target: %s", exit_signal, strerror(errno)); } if (kill_self) { stop_signal_sender(); _exit(1); } }
0
91,849
int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ Table *pSelTab; /* A fake table from which we get the result set */ Select *pSel; /* Copy of the SELECT that implements the view */ int nErr = 0; /* Number of errors encountered */ int n; /* Temporarily holds the number of cursors assigned */ sqlite3 *db = pParse->db; /* Database connection for malloc errors */ #ifndef SQLITE_OMIT_VIRTUALTABLE int rc; #endif #ifndef SQLITE_OMIT_AUTHORIZATION sqlite3_xauth xAuth; /* Saved xAuth pointer */ #endif assert( pTable ); #ifndef SQLITE_OMIT_VIRTUALTABLE db->nSchemaLock++; rc = sqlite3VtabCallConnect(pParse, pTable); db->nSchemaLock--; if( rc ){ return 1; } if( IsVirtual(pTable) ) return 0; #endif #ifndef SQLITE_OMIT_VIEW /* A positive nCol means the columns names for this view are ** already known. */ if( pTable->nCol>0 ) return 0; /* A negative nCol is a special marker meaning that we are currently ** trying to compute the column names. If we enter this routine with ** a negative nCol, it means two or more views form a loop, like this: ** ** CREATE VIEW one AS SELECT * FROM two; ** CREATE VIEW two AS SELECT * FROM one; ** ** Actually, the error above is now caught prior to reaching this point. ** But the following test is still important as it does come up ** in the following: ** ** CREATE TABLE main.ex1(a); ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; ** SELECT * FROM temp.ex1; */ if( pTable->nCol<0 ){ sqlite3ErrorMsg(pParse, "view %s is circularly defined", pTable->zName); return 1; } assert( pTable->nCol>=0 ); /* If we get this far, it means we need to compute the table names. ** Note that the call to sqlite3ResultSetOfSelect() will expand any ** "*" elements in the results set of the view and will assign cursors ** to the elements of the FROM clause. But we do not want these changes ** to be permanent. So the computation is done on a copy of the SELECT ** statement that defines the view. */ assert( pTable->pSelect ); pSel = sqlite3SelectDup(db, pTable->pSelect, 0); if( pSel ){ #ifndef SQLITE_OMIT_ALTERTABLE u8 eParseMode = pParse->eParseMode; pParse->eParseMode = PARSE_MODE_NORMAL; #endif n = pParse->nTab; sqlite3SrcListAssignCursors(pParse, pSel->pSrc); pTable->nCol = -1; DisableLookaside; #ifndef SQLITE_OMIT_AUTHORIZATION xAuth = db->xAuth; db->xAuth = 0; pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); db->xAuth = xAuth; #else pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); #endif pParse->nTab = n; if( pTable->pCheck ){ /* CREATE VIEW name(arglist) AS ... ** The names of the columns in the table are taken from ** arglist which is stored in pTable->pCheck. The pCheck field ** normally holds CHECK constraints on an ordinary table, but for ** a VIEW it holds the list of column names. */ sqlite3ColumnsFromExprList(pParse, pTable->pCheck, &pTable->nCol, &pTable->aCol); if( db->mallocFailed==0 && pParse->nErr==0 && pTable->nCol==pSel->pEList->nExpr ){ sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel, SQLITE_AFF_NONE); } }else if( pSelTab ){ /* CREATE VIEW name AS... without an argument list. Construct ** the column names from the SELECT statement that defines the view. */ assert( pTable->aCol==0 ); pTable->nCol = pSelTab->nCol; pTable->aCol = pSelTab->aCol; pSelTab->nCol = 0; pSelTab->aCol = 0; assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); }else{ pTable->nCol = 0; nErr++; } pTable->nNVCol = pTable->nCol; sqlite3DeleteTable(db, pSelTab); sqlite3SelectDelete(db, pSel); EnableLookaside; #ifndef SQLITE_OMIT_ALTERTABLE pParse->eParseMode = eParseMode; #endif } else { nErr++; } pTable->pSchema->schemaFlags |= DB_UnresetViews; if( db->mallocFailed ){ sqlite3DeleteColumnNames(db, pTable); pTable->aCol = 0; pTable->nCol = 0; } #endif /* SQLITE_OMIT_VIEW */ return nErr; }
0
50,669
encode_attr_2( Slapi_PBlock *pb, BerElement *ber, Slapi_Entry *e, Slapi_ValueSet *vs, int attrsonly, const char *attribute_type, const char *returned_type) { char *attrs[2] = {NULL, NULL}; Slapi_Value *v; int i = slapi_valueset_first_value(vs, &v); if (i == -1) { return (0); } attrs[0] = (char *)attribute_type; #if !defined(DISABLE_ACL_CHECK) if (plugin_call_acl_plugin(pb, e, attrs, NULL, SLAPI_ACL_READ, ACLPLUGIN_ACCESS_READ_ON_ATTR, NULL) != LDAP_SUCCESS) { return (0); } #endif if (ber_printf(ber, "{s[", returned_type ? returned_type : attribute_type) == -1) { slapi_log_err(SLAPI_LOG_ERR, "encode_attr_2", "ber_printf failed 4\n"); ber_free(ber, 1); send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf type", 0, NULL); return (-1); } if (!attrsonly) { while (i != -1) { if (ber_printf(ber, "o", v->bv.bv_val, v->bv.bv_len) == -1) { slapi_log_err(SLAPI_LOG_ERR, "encode_attr_2", "ber_printf failed 5\n"); ber_free(ber, 1); send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf value", 0, NULL); return (-1); } i = slapi_valueset_next_value(vs, i, &v); } } if (ber_printf(ber, "]}") == -1) { slapi_log_err(SLAPI_LOG_ERR, "encode_attr_2", "ber_printf failed 6\n"); ber_free(ber, 1); send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "ber_printf type end", 0, NULL); return (-1); } return (0); }
0
368,904
string_strcasestr (const char *string, const char *search) { int length_search; length_search = utf8_strlen (search); if (!string || !search || (length_search == 0)) return NULL; while (string[0]) { if (string_strncasecmp (string, search, length_search) == 0) return (char *)string; string = utf8_next_char (string); } return NULL; }
0
309,681
const char* BrowserRootView::GetClassName() const { return kViewClassName; }
0
99,531
MagickExport MagickBooleanType GetMultilineTypeMetrics(Image *image, const DrawInfo *draw_info,TypeMetric *metrics) { char **textlist; DrawInfo *annotate_info; MagickBooleanType status; register ssize_t i; TypeMetric extent; assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(draw_info != (DrawInfo *) NULL); assert(draw_info->text != (char *) NULL); assert(draw_info->signature == MagickCoreSignature); if (*draw_info->text == '\0') return(MagickFalse); annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); annotate_info->text=DestroyString(annotate_info->text); /* Convert newlines to multiple lines of text. */ textlist=StringToList(draw_info->text); if (textlist == (char **) NULL) return(MagickFalse); annotate_info->render=MagickFalse; annotate_info->direction=UndefinedDirection; (void) memset(metrics,0,sizeof(*metrics)); (void) memset(&extent,0,sizeof(extent)); /* Find the widest of the text lines. */ annotate_info->text=textlist[0]; status=GetTypeMetrics(image,annotate_info,&extent); *metrics=extent; for (i=1; textlist[i] != (char *) NULL; i++) { annotate_info->text=textlist[i]; status=GetTypeMetrics(image,annotate_info,&extent); if (extent.width > metrics->width) *metrics=extent; } metrics->height=(double) (i*(size_t) (metrics->ascent-metrics->descent+0.5)+ (i-1)*draw_info->interline_spacing); /* Relinquish resources. */ annotate_info->text=(char *) NULL; annotate_info=DestroyDrawInfo(annotate_info); for (i=0; textlist[i] != (char *) NULL; i++) textlist[i]=DestroyString(textlist[i]); textlist=(char **) RelinquishMagickMemory(textlist); return(status); }
0
76,278
void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next) { int ctxn; if (__this_cpu_read(perf_sched_cb_usages)) perf_pmu_sched_task(task, next, false); if (atomic_read(&nr_switch_events)) perf_event_switch(task, next, false); for_each_task_context_nr(ctxn) perf_event_context_sched_out(task, ctxn, next); /* * if cgroup events exist on this CPU, then we need * to check if we have to switch out PMU state. * cgroup event are system-wide mode only */ if (atomic_read(this_cpu_ptr(&perf_cgroup_events))) perf_cgroup_sched_out(task, next); }
0
354,189
Type_handler_decimal_result::make_num_distinct_aggregator_field( MEM_ROOT *mem_root, const Item *item) const { DBUG_ASSERT(item->decimals <= DECIMAL_MAX_SCALE); return new (mem_root) Field_new_decimal(NULL, item->max_length, (uchar *) (item->maybe_null ? "" : 0), item->maybe_null ? 1 : 0, Field::NONE, item->name, item->decimals, 0, item->unsigned_flag); }
1
196,384
MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt) { int al; unsigned int ticklen; unsigned long ticket_lifetime_hint; if (!PACKET_get_net_4(pkt, &ticket_lifetime_hint) || !PACKET_get_net_2(pkt, &ticklen) || PACKET_remaining(pkt) != ticklen) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); goto f_err; } /* Server is allowed to change its mind and send an empty ticket. */ if (ticklen == 0) return MSG_PROCESS_CONTINUE_READING; if (s->session->session_id_length > 0) { int i = s->session_ctx->session_cache_mode; SSL_SESSION *new_sess; /* * We reused an existing session, so we need to replace it with a new * one */ if (i & SSL_SESS_CACHE_CLIENT) { /* * Remove the old session from the cache. We carry on if this fails */ SSL_CTX_remove_session(s->session_ctx, s->session); } if ((new_sess = ssl_session_dup(s->session, 0)) == 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); goto f_err; } SSL_SESSION_free(s->session); s->session = new_sess; } OPENSSL_free(s->session->tlsext_tick); s->session->tlsext_ticklen = 0; s->session->tlsext_tick = OPENSSL_malloc(ticklen); if (s->session->tlsext_tick == NULL) { SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); goto err; } if (!PACKET_copy_bytes(pkt, s->session->tlsext_tick, ticklen)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); goto f_err; } s->session->tlsext_tick_lifetime_hint = ticket_lifetime_hint; s->session->tlsext_ticklen = ticklen; /* * There are two ways to detect a resumed ticket session. One is to set * an appropriate session ID and then the server must return a match in * ServerHello. This allows the normal client session ID matching to work * and we know much earlier that the ticket has been accepted. The * other way is to set zero length session ID when the ticket is * presented and rely on the handshake to determine session resumption. * We choose the former approach because this fits in with assumptions * elsewhere in OpenSSL. The session ID is set to the SHA256 (or SHA1 is * SHA256 is disabled) hash of the ticket. */ if (!EVP_Digest(s->session->tlsext_tick, ticklen, s->session->session_id, &s->session->session_id_length, EVP_sha256(), NULL)) { SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_EVP_LIB); goto err; } return MSG_PROCESS_CONTINUE_READING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: ossl_statem_set_error(s); return MSG_PROCESS_ERROR; }
0
404,737
static ssize_t raw_preadv(struct bdev *bdev, struct iovec *iov, int iovcnt, off_t offset) { return preadv(bdev->fd, iov, iovcnt, offset); }
0
312,789
void RenderFrameHostImpl::FlushNetworkAndNavigationInterfacesForTesting() { DCHECK(network_service_connection_error_handler_holder_); network_service_connection_error_handler_holder_.FlushForTesting(); if (!navigation_control_) GetNavigationControl(); DCHECK(navigation_control_); navigation_control_.FlushForTesting(); }
0
54,284
WC_INLINE static int fp_mul_comba_mulx(fp_int *A, fp_int *B, fp_int *C) { int ix, iy, iz, pa; fp_int *dst; #ifndef WOLFSSL_SMALL_STACK fp_int tmp[1]; #else fp_int *tmp; #endif /* Variables used but not seen by cppcheck. */ (void)ix; (void)iy; (void)iz; #ifdef WOLFSSL_SMALL_STACK tmp = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT); if (tmp == NULL) return FP_MEM; #endif /* get size of output and trim */ pa = A->used + B->used; if (pa >= FP_SIZE) { pa = FP_SIZE-1; } /* Always take branch to use tmp variable. This avoids a cache attack for * determining if C equals A */ if (1) { fp_init(tmp); dst = tmp; } TFM_INTEL_MUL_COMBA(A, B, dst) ; dst->used = pa; dst->sign = A->sign ^ B->sign; fp_clamp(dst); fp_copy(dst, C); #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_BIGINT); #endif return FP_OKAY; }
0
125,872
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value) { if (value>0xFFFF) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); }
0
226,093
LayoutUnit RenderBox::containingBlockAvailableLineWidth() const { RenderBlock* cb = containingBlock(); if (cb->isRenderBlockFlow()) return toRenderBlockFlow(cb)->availableLogicalWidthForLine(logicalTop(), false, availableLogicalHeight(IncludeMarginBorderPadding)); return 0; }
0
113,733
static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) { struct socket *sock = sk->sk_socket; struct tipc_msg *msg = buf_msg(buf); unsigned int limit = rcvbuf_limit(sk, buf); u32 res = TIPC_OK; /* Reject message if it is wrong sort of message for socket */ if (msg_type(msg) > TIPC_DIRECT_MSG) return TIPC_ERR_NO_PORT; if (sock->state == SS_READY) { if (msg_connected(msg)) return TIPC_ERR_NO_PORT; } else { res = filter_connect(tipc_sk(sk), &buf); if (res != TIPC_OK || buf == NULL) return res; } /* Reject message if there isn't room to queue it */ if (sk_rmem_alloc_get(sk) + buf->truesize >= limit) return TIPC_ERR_OVERLOAD; /* Enqueue message */ TIPC_SKB_CB(buf)->handle = NULL; __skb_queue_tail(&sk->sk_receive_queue, buf); skb_set_owner_r(buf, sk); sk->sk_data_ready(sk, 0); return TIPC_OK; }
0
133,322
GF_EXPORT void gf_isom_box_del(GF_Box *a) { GF_List *child_boxes; const struct box_registry_entry *a_box_registry; if (!a) return; child_boxes = a->child_boxes; a->child_boxes = NULL; a_box_registry = a->registry; if (!a_box_registry) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Delete invalid box type %s without registry\n", gf_4cc_to_str(a->type) )); } else { a_box_registry->del_fn(a); } //delete the other boxes after deleting the box for dumper case where all child boxes are stored in otherbox if (child_boxes) { gf_isom_box_array_del(child_boxes); }
0
215,632
bool ContentSecurityPolicy::IsActive() const { return !policies_.IsEmpty(); }
0
4,429
int imap_exec(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags) { int rc; rc = cmd_start(adata, cmdstr, flags); if (rc < 0) { cmd_handle_fatal(adata); return IMAP_EXEC_FATAL; } if (flags & IMAP_CMD_QUEUE) return IMAP_EXEC_SUCCESS; if ((flags & IMAP_CMD_POLL) && (C_ImapPollTimeout > 0) && ((mutt_socket_poll(adata->conn, C_ImapPollTimeout)) == 0)) { mutt_error(_("Connection to %s timed out"), adata->conn->account.host); cmd_handle_fatal(adata); return IMAP_EXEC_FATAL; } /* Allow interruptions, particularly useful if there are network problems. */ mutt_sig_allow_interrupt(true); do { rc = imap_cmd_step(adata); } while (rc == IMAP_RES_CONTINUE); mutt_sig_allow_interrupt(false); if (rc == IMAP_RES_NO) return IMAP_EXEC_ERROR; if (rc != IMAP_RES_OK) { if (adata->status != IMAP_FATAL) return IMAP_EXEC_ERROR; mutt_debug(LL_DEBUG1, "command failed: %s\n", adata->buf); return IMAP_EXEC_FATAL; } return IMAP_EXEC_SUCCESS; }
1
195,969
explicit MultiPartResponseClient(WebPluginResourceClient* resource_client) : resource_client_(resource_client) { Clear(); }
0
252,552
status_t BnSoundTriggerHwService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case LIST_MODULES: { CHECK_INTERFACE(ISoundTriggerHwService, data, reply); unsigned int numModulesReq = data.readInt32(); if (numModulesReq > MAX_ITEMS_PER_LIST) { numModulesReq = MAX_ITEMS_PER_LIST; } unsigned int numModules = numModulesReq; struct sound_trigger_module_descriptor *modules = (struct sound_trigger_module_descriptor *)calloc(numModulesReq, sizeof(struct sound_trigger_module_descriptor)); if (modules == NULL) { reply->writeInt32(NO_MEMORY); reply->writeInt32(0); return NO_ERROR; } status_t status = listModules(modules, &numModules); reply->writeInt32(status); reply->writeInt32(numModules); ALOGV("LIST_MODULES status %d got numModules %d", status, numModules); if (status == NO_ERROR) { if (numModulesReq > numModules) { numModulesReq = numModules; } reply->write(modules, numModulesReq * sizeof(struct sound_trigger_module_descriptor)); } free(modules); return NO_ERROR; } case ATTACH: { CHECK_INTERFACE(ISoundTriggerHwService, data, reply); sound_trigger_module_handle_t handle; data.read(&handle, sizeof(sound_trigger_module_handle_t)); sp<ISoundTriggerClient> client = interface_cast<ISoundTriggerClient>(data.readStrongBinder()); sp<ISoundTrigger> module; status_t status = attach(handle, client, module); reply->writeInt32(status); if (module != 0) { reply->writeInt32(1); reply->writeStrongBinder(IInterface::asBinder(module)); } else { reply->writeInt32(0); } return NO_ERROR; } break; case SET_CAPTURE_STATE: { CHECK_INTERFACE(ISoundTriggerHwService, data, reply); reply->writeInt32(setCaptureState((bool)data.readInt32())); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
0
485,358
peer_default_originate_set_vty (struct vty *vty, const char *peer_str, afi_t afi, safi_t safi, const char *rmap, int set) { int ret; struct peer *peer; peer = peer_and_group_lookup_vty (vty, peer_str); if (! peer) return CMD_WARNING; if (set) ret = peer_default_originate_set (peer, afi, safi, rmap); else ret = peer_default_originate_unset (peer, afi, safi); return bgp_vty_return (vty, ret); }
0
511,855
static void test_json_append_escaped(void) { string_t *str = t_str_new(32); test_begin("json_append_escaped()"); json_append_escaped(str, "\b\f\r\n\t\"\\\001\002-\xC3\xA4\xf0\x90\x90\xb7\xff"); test_assert(strcmp(str_c(str), "\\b\\f\\r\\n\\t\\\"\\\\\\u0001\\u0002-\\u00e4\\ud801\\udc37" UNICODE_REPLACEMENT_CHAR_UTF8) == 0); test_end(); }
0
330,227
static int tta_get_unary(GetBitContext *gb) { int ret = 0; // count ones while(get_bits1(gb)) ret++; return ret; }
0
445,732
char *getusername_malloc(void) { const char *e; e = secure_getenv("USER"); if (e) return strdup(e); return uid_to_name(getuid()); }
0
294,427
static unsigned zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in, size_t insize, const LodePNGCompressSettings* settings) { if (!settings->custom_zlib) return 87; /*no custom zlib function provided */ return settings->custom_zlib(out, outsize, in, insize, settings); }
0
157,741
lldpd_get_lsb_release() { static char release[1024]; char *const command[] = { "lsb_release", "-s", "-d", NULL }; int pid, status, devnull, count; int pipefd[2]; log_debug("localchassis", "grab LSB release"); if (pipe(pipefd)) { log_warn("localchassis", "unable to get a pair of pipes"); return NULL; } pid = vfork(); switch (pid) { case -1: log_warn("localchassis", "unable to fork"); return NULL; case 0: /* Child, exec lsb_release */ close(pipefd[0]); if ((devnull = open("/dev/null", O_RDWR, 0)) != -1) { dup2(devnull, STDIN_FILENO); dup2(devnull, STDERR_FILENO); dup2(pipefd[1], STDOUT_FILENO); if (devnull > 2) close(devnull); if (pipefd[1] > 2) close(pipefd[1]); execvp("lsb_release", command); } _exit(127); break; default: /* Father, read the output from the children */ close(pipefd[1]); count = 0; do { status = read(pipefd[0], release+count, sizeof(release)-count); if ((status == -1) && (errno == EINTR)) continue; if (status > 0) count += status; } while (count < sizeof(release) && (status > 0)); if (status < 0) { log_info("localchassis", "unable to read from lsb_release"); close(pipefd[0]); waitpid(pid, &status, 0); return NULL; } close(pipefd[0]); if (count >= sizeof(release)) { log_info("localchassis", "output of lsb_release is too large"); waitpid(pid, &status, 0); return NULL; } status = -1; if (waitpid(pid, &status, 0) != pid) return NULL; if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { log_info("localchassis", "lsb_release information not available"); return NULL; } if (!count) { log_info("localchassis", "lsb_release returned an empty string"); return NULL; } release[count] = '\0'; return release; } /* Should not be here */ return NULL; }
0
283,154
newimage(Image *image) { memset(image, 0, sizeof *image); }
0
206,268
void PrintWebViewHelper::PrintPreviewContext::FinalizePrintReadyDocument() { DCHECK(IsRendering()); base::TimeTicks begin_time = base::TimeTicks::Now(); metafile_->FinishDocument(); if (print_ready_metafile_page_count_ <= 0) { NOTREACHED(); return; } UMA_HISTOGRAM_MEDIUM_TIMES("PrintPreview.RenderToPDFTime", document_render_time_); base::TimeDelta total_time = (base::TimeTicks::Now() - begin_time) + document_render_time_; UMA_HISTOGRAM_MEDIUM_TIMES("PrintPreview.RenderAndGeneratePDFTime", total_time); UMA_HISTOGRAM_MEDIUM_TIMES("PrintPreview.RenderAndGeneratePDFTimeAvgPerPage", total_time / pages_to_render_.size()); }
0
235,428
static void methodWithSequenceArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); TestObjectV8Internal::methodWithSequenceArgMethod(info); TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); }
0
372,711
void CLASS fuji_load_raw() { #ifndef LIBRAW_LIBRARY_BUILD ushort *pixel; int wide, row, col, r, c; fseek (ifp, (top_margin*raw_width + left_margin) * 2, SEEK_CUR); wide = fuji_width << !fuji_layout; pixel = (ushort *) calloc (wide, sizeof *pixel); merror (pixel, "fuji_load_raw()"); for (row=0; row < raw_height; row++) { read_shorts (pixel, wide); fseek (ifp, 2*(raw_width - wide), SEEK_CUR); for (col=0; col < wide; col++) { if (fuji_layout) { r = fuji_width - 1 - col + (row >> 1); c = col + ((row+1) >> 1); } else { r = fuji_width - 1 + row - (col >> 1); c = row + ((col+1) >> 1); } BAYER(r,c) = pixel[col]; } } free (pixel); #else read_shorts(raw_image,raw_width*raw_height); #endif }
0
441,513
static __always_inline void __vma_unlink_common(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *ignore) { vma_rb_erase_ignore(vma, &mm->mm_rb, ignore); __vma_unlink_list(mm, vma); /* Kill the cache */ vmacache_invalidate(mm); }
0
260,340
flatpak_proxy_client_get_policy (FlatpakProxyClient *client, const char *source) { if (source == NULL) return FLATPAK_POLICY_TALK; /* All clients can talk to the bus itself */ if (source[0] == ':') return GPOINTER_TO_UINT (g_hash_table_lookup (client->unique_id_policy, source)); return flatpak_proxy_get_policy (client->proxy, source); }
0
71,723
QString Utility::Substring(int start_index, int end_index, const QString &string) { return string.mid(start_index, end_index - start_index); }
0
270,237
void rds_conn_shutdown(struct rds_connection *conn) { /* shut it down unless it's down already */ if (!rds_conn_transition(conn, RDS_CONN_DOWN, RDS_CONN_DOWN)) { /* * Quiesce the connection mgmt handlers before we start tearing * things down. We don't hold the mutex for the entire * duration of the shutdown operation, else we may be * deadlocking with the CM handler. Instead, the CM event * handler is supposed to check for state DISCONNECTING */ mutex_lock(&conn->c_cm_lock); if (!rds_conn_transition(conn, RDS_CONN_UP, RDS_CONN_DISCONNECTING) && !rds_conn_transition(conn, RDS_CONN_ERROR, RDS_CONN_DISCONNECTING)) { rds_conn_error(conn, "shutdown called in state %d\n", atomic_read(&conn->c_state)); mutex_unlock(&conn->c_cm_lock); return; } mutex_unlock(&conn->c_cm_lock); wait_event(conn->c_waitq, !test_bit(RDS_IN_XMIT, &conn->c_flags)); wait_event(conn->c_waitq, !test_bit(RDS_RECV_REFILL, &conn->c_flags)); conn->c_trans->conn_shutdown(conn); rds_conn_reset(conn); if (!rds_conn_transition(conn, RDS_CONN_DISCONNECTING, RDS_CONN_DOWN)) { /* This can happen - eg when we're in the middle of tearing * down the connection, and someone unloads the rds module. * Quite reproduceable with loopback connections. * Mostly harmless. */ rds_conn_error(conn, "%s: failed to transition to state DOWN, " "current state is %d\n", __func__, atomic_read(&conn->c_state)); return; } } /* Then reconnect if it's still live. * The passive side of an IB loopback connection is never added * to the conn hash, so we never trigger a reconnect on this * conn - the reconnect is always triggered by the active peer. */ cancel_delayed_work_sync(&conn->c_conn_w); rcu_read_lock(); if (!hlist_unhashed(&conn->c_hash_node)) { rcu_read_unlock(); rds_queue_reconnect(conn); } else { rcu_read_unlock(); } }
0
397,455
static CharDriverState *qemu_chr_open_pipe(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { ChardevHostdev *opts = backend->u.pipe.data; const char *filename = opts->device; CharDriverState *chr; WinCharState *s; ChardevCommon *common = qapi_ChardevHostdev_base(opts); chr = qemu_chr_alloc(common, errp); if (!chr) { return NULL; } s = g_new0(WinCharState, 1); chr->opaque = s; chr->chr_write = win_chr_write; chr->chr_close = win_chr_close; if (win_chr_pipe_init(chr, filename, errp) < 0) { g_free(s); qemu_chr_free_common(chr); return NULL; } return chr; }
0
412,938
PHP_FUNCTION(ldap_dn2ufn) { char *dn, *ufn; int dn_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dn, &dn_len) != SUCCESS) { return; } ufn = ldap_dn2ufn(dn); if (ufn != NULL) { RETVAL_STRING(ufn, 1); #if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS ldap_memfree(ufn); #endif } else { RETURN_FALSE; } }
0
45,440
static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count) { *count = avio_rb32(pb); *refs = av_calloc(*count, sizeof(UID)); if (!*refs) { *count = 0; return AVERROR(ENOMEM); } avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); return 0; }
0
280,978
LayoutUnit RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, bool includeMaxWidth) const { LayoutUnit minLogicalWidth = computeReplacedLogicalWidthUsing(style()->logicalMinWidth()); LayoutUnit maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth()); return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); }
0
364,176
rfbSendRectEncodingTight(rfbClientPtr cl, int x, int y, int w, int h) { int nMaxRows; uint32_t colorValue; int dx, dy, dw, dh; int x_best, y_best, w_best, h_best; char *fbptr; rfbSendUpdateBuf(cl); compressLevel = cl->tightCompressLevel; qualityLevel = cl->tightQualityLevel; if ( cl->format.depth == 24 && cl->format.redMax == 0xFF && cl->format.greenMax == 0xFF && cl->format.blueMax == 0xFF ) { usePixelFormat24 = TRUE; } else { usePixelFormat24 = FALSE; } if (!cl->enableLastRectEncoding || w * h < MIN_SPLIT_RECT_SIZE) return SendRectSimple(cl, x, y, w, h); /* Make sure we can write at least one pixel into tightBeforeBuf. */ if (tightBeforeBufSize < 4) { tightBeforeBufSize = 4; if (tightBeforeBuf == NULL) tightBeforeBuf = (char *)malloc(tightBeforeBufSize); else tightBeforeBuf = (char *)realloc(tightBeforeBuf, tightBeforeBufSize); } /* Calculate maximum number of rows in one non-solid rectangle. */ { int maxRectSize, maxRectWidth, nMaxWidth; maxRectSize = tightConf[compressLevel].maxRectSize; maxRectWidth = tightConf[compressLevel].maxRectWidth; nMaxWidth = (w > maxRectWidth) ? maxRectWidth : w; nMaxRows = maxRectSize / nMaxWidth; } /* Try to find large solid-color areas and send them separately. */ for (dy = y; dy < y + h; dy += MAX_SPLIT_TILE_SIZE) { /* If a rectangle becomes too large, send its upper part now. */ if (dy - y >= nMaxRows) { if (!SendRectSimple(cl, x, y, w, nMaxRows)) return 0; y += nMaxRows; h -= nMaxRows; } dh = (dy + MAX_SPLIT_TILE_SIZE <= y + h) ? MAX_SPLIT_TILE_SIZE : (y + h - dy); for (dx = x; dx < x + w; dx += MAX_SPLIT_TILE_SIZE) { dw = (dx + MAX_SPLIT_TILE_SIZE <= x + w) ? MAX_SPLIT_TILE_SIZE : (x + w - dx); if (CheckSolidTile(cl, dx, dy, dw, dh, &colorValue, FALSE)) { /* Get dimensions of solid-color area. */ FindBestSolidArea(cl, dx, dy, w - (dx - x), h - (dy - y), colorValue, &w_best, &h_best); /* Make sure a solid rectangle is large enough (or the whole rectangle is of the same color). */ if ( w_best * h_best != w * h && w_best * h_best < MIN_SOLID_SUBRECT_SIZE ) continue; /* Try to extend solid rectangle to maximum size. */ x_best = dx; y_best = dy; ExtendSolidArea(cl, x, y, w, h, colorValue, &x_best, &y_best, &w_best, &h_best); /* Send rectangles at top and left to solid-color area. */ if ( y_best != y && !SendRectSimple(cl, x, y, w, y_best-y) ) return FALSE; if ( x_best != x && !rfbSendRectEncodingTight(cl, x, y_best, x_best-x, h_best) ) return FALSE; /* Send solid-color rectangle. */ if (!SendTightHeader(cl, x_best, y_best, w_best, h_best)) return FALSE; fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y_best) + (x_best * (cl->scaledScreen->bitsPerPixel / 8))); (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, &cl->format, fbptr, tightBeforeBuf, cl->scaledScreen->paddedWidthInBytes, 1, 1); if (!SendSolidRect(cl)) return FALSE; /* Send remaining rectangles (at right and bottom). */ if ( x_best + w_best != x + w && !rfbSendRectEncodingTight(cl, x_best+w_best, y_best, w-(x_best-x)-w_best, h_best) ) return FALSE; if ( y_best + h_best != y + h && !rfbSendRectEncodingTight(cl, x, y_best+h_best, w, h-(y_best-y)-h_best) ) return FALSE; /* Return after all recursive calls are done. */ return TRUE; } } } /* No suitable solid-color rectangles found. */ return SendRectSimple(cl, x, y, w, h); }
0
336,896
static void trigger_prot_fault(CPUS390XState *env, target_ulong vaddr, uint64_t mode) { CPUState *cs = CPU(s390_env_get_cpu(env)); int ilen = ILEN_LATER_INC; int bits = trans_bits(env, mode) | 4; DPRINTF("%s: vaddr=%016" PRIx64 " bits=%d\n", __func__, vaddr, bits); stq_phys(cs->as, env->psa + offsetof(LowCore, trans_exc_code), vaddr | bits); trigger_pgm_exception(env, PGM_PROTECTION, ilen); }
0
410,768
static void bans_show_channel(IRC_CHANNEL_REC *channel, IRC_SERVER_REC *server) { GSList *tmp; int counter; if (channel->banlist == NULL) { printformat(server, channel->visible_name, MSGLEVEL_CLIENTNOTICE, IRCTXT_NO_BANS, channel->visible_name); return; } /* show bans.. */ counter = 1; for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) { BAN_REC *rec = tmp->data; printformat(server, channel->visible_name, MSGLEVEL_CRAP, (rec->setby == NULL || *rec->setby == '\0') ? IRCTXT_BANLIST : IRCTXT_BANLIST_LONG, counter, channel->visible_name, rec->ban, rec->setby, (int) (time(NULL)-rec->time)); counter++; } }
0
472,024
stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; }
0
69,078
static struct fsnotify_event *inotify_merge(struct list_head *list, struct fsnotify_event *event) { struct fsnotify_event_holder *last_holder; struct fsnotify_event *last_event; /* and the list better be locked by something too */ spin_lock(&event->lock); last_holder = list_entry(list->prev, struct fsnotify_event_holder, event_list); last_event = last_holder->event; if (event_compare(last_event, event)) fsnotify_get_event(last_event); else last_event = NULL; spin_unlock(&event->lock); return last_event; }
0
429,994
int64_t get_next_session_id() { auto session_id = next_session_id_; if (next_session_id_ == std::numeric_limits<int64_t>::max()) { next_session_id_ = 1; } else { ++next_session_id_; } return session_id; }
0
270,590
int cil_gen_ibpkeycon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node) { enum cil_syntax syntax[] = { CIL_SYN_STRING, CIL_SYN_STRING, CIL_SYN_STRING | CIL_SYN_LIST, CIL_SYN_STRING | CIL_SYN_LIST, CIL_SYN_END }; int syntax_len = sizeof(syntax) / sizeof(*syntax); int rc = SEPOL_ERR; struct cil_ibpkeycon *ibpkeycon = NULL; if (!parse_current || !ast_node) goto exit; rc = __cil_verify_syntax(parse_current, syntax, syntax_len); if (rc != SEPOL_OK) goto exit; cil_ibpkeycon_init(&ibpkeycon); ibpkeycon->subnet_prefix_str = parse_current->next->data; if (parse_current->next->next->cl_head) { if (parse_current->next->next->cl_head->next && !parse_current->next->next->cl_head->next->next) { rc = cil_fill_integer(parse_current->next->next->cl_head, &ibpkeycon->pkey_low, 0); if (rc != SEPOL_OK) { cil_log(CIL_ERR, "Improper ibpkey specified\n"); goto exit; } rc = cil_fill_integer(parse_current->next->next->cl_head->next, &ibpkeycon->pkey_high, 0); if (rc != SEPOL_OK) { cil_log(CIL_ERR, "Improper ibpkey specified\n"); goto exit; } } else { cil_log(CIL_ERR, "Improper ibpkey range specified\n"); rc = SEPOL_ERR; goto exit; } } else { rc = cil_fill_integer(parse_current->next->next, &ibpkeycon->pkey_low, 0); if (rc != SEPOL_OK) { cil_log(CIL_ERR, "Improper ibpkey specified\n"); goto exit; } ibpkeycon->pkey_high = ibpkeycon->pkey_low; } if (!parse_current->next->next->next->cl_head) { ibpkeycon->context_str = parse_current->next->next->next->data; } else { cil_context_init(&ibpkeycon->context); rc = cil_fill_context(parse_current->next->next->next->cl_head, ibpkeycon->context); if (rc != SEPOL_OK) goto exit; } ast_node->data = ibpkeycon; ast_node->flavor = CIL_IBPKEYCON; return SEPOL_OK; exit: cil_tree_log(parse_current, CIL_ERR, "Bad ibpkeycon declaration"); cil_destroy_ibpkeycon(ibpkeycon); return rc; }
0
3,765
SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) { int ufd; struct timerfd_ctx *ctx; /* Check the TFD_* constants for consistency. */ BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK); if ((flags & ~TFD_CREATE_FLAGS) || (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME && clockid != CLOCK_REALTIME_ALARM && clockid != CLOCK_BOOTTIME && clockid != CLOCK_BOOTTIME_ALARM)) return -EINVAL; if (!capable(CAP_WAKE_ALARM) && (clockid == CLOCK_REALTIME_ALARM || clockid == CLOCK_BOOTTIME_ALARM)) return -EPERM; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; init_waitqueue_head(&ctx->wqh); ctx->clockid = clockid; if (isalarm(ctx)) alarm_init(&ctx->t.alarm, ctx->clockid == CLOCK_REALTIME_ALARM ? ALARM_REALTIME : ALARM_BOOTTIME, timerfd_alarmproc); else hrtimer_init(&ctx->t.tmr, clockid, HRTIMER_MODE_ABS); ctx->moffs = ktime_mono_to_real(0); ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS)); if (ufd < 0) kfree(ctx); return ufd; }
1
111,184
extend_parse_config(const char *token, char *cptr) { netsnmp_extend *extension; char exec_name[STRMAX]; char exec_name2[STRMAX]; /* For use with UCD execFix directive */ char exec_command[STRMAX]; oid oid_buf[MAX_OID_LEN]; size_t oid_len; extend_registration_block *eptr; int flags; int cache_timeout = 0; int exec_type = NS_EXTEND_ETYPE_EXEC; cptr = copy_nword(cptr, exec_name, sizeof(exec_name)); if (strcmp(exec_name, "-cacheTime") == 0) { char cache_timeout_str[32]; cptr = copy_nword(cptr, cache_timeout_str, sizeof(cache_timeout_str)); /* If atoi can't do the conversion, it returns 0 */ cache_timeout = atoi(cache_timeout_str); cptr = copy_nword(cptr, exec_name, sizeof(exec_name)); } if (strcmp(exec_name, "-execType") == 0) { char exec_type_str[16]; cptr = copy_nword(cptr, exec_type_str, sizeof(exec_type_str)); if (strcmp(exec_type_str, "sh") == 0) exec_type = NS_EXTEND_ETYPE_SHELL; else exec_type = NS_EXTEND_ETYPE_EXEC; cptr = copy_nword(cptr, exec_name, sizeof(exec_name)); } if ( *exec_name == '.' ) { oid_len = MAX_OID_LEN - 2; if (0 == read_objid( exec_name, oid_buf, &oid_len )) { config_perror("ERROR: Unrecognised OID" ); return; } cptr = copy_nword(cptr, exec_name, sizeof(exec_name)); if (!strcmp( token, "sh" ) || !strcmp( token, "exec" )) { config_perror("ERROR: This output format has been deprecated - Please use the 'extend' directive instead" ); return; } } else { memcpy( oid_buf, ns_extend_oid, sizeof(ns_extend_oid)); oid_len = OID_LENGTH(ns_extend_oid); } cptr = copy_nword(cptr, exec_command, sizeof(exec_command)); /* XXX - check 'exec_command' exists & is executable */ flags = (NS_EXTEND_FLAGS_ACTIVE | NS_EXTEND_FLAGS_CONFIG); if (!strcmp( token, "sh" ) || !strcmp( token, "extend-sh" ) || !strcmp( token, "sh2") || exec_type == NS_EXTEND_ETYPE_SHELL) flags |= NS_EXTEND_FLAGS_SHELL; if (!strcmp( token, "execFix" ) || !strcmp( token, "extendfix" ) || !strcmp( token, "execFix2" )) { strcpy( exec_name2, exec_name ); strcat( exec_name, "Fix" ); flags |= NS_EXTEND_FLAGS_WRITEABLE; /* XXX - Check for shell... */ } eptr = _register_extend( oid_buf, oid_len ); if (!eptr) { snmp_log(LOG_ERR, "Failed to register extend entry '%s' - possibly duplicate name.\n", exec_name ); return; } extension = _new_extension( exec_name, flags, eptr ); if (extension) { extension->command = strdup( exec_command ); if (cptr) extension->args = strdup( cptr ); if (cache_timeout != 0) extension->cache->timeout = cache_timeout; } else { snmp_log(LOG_ERR, "Failed to register extend entry '%s' - possibly duplicate name.\n", exec_name ); return; } #ifndef USING_UCD_SNMP_EXTENSIBLE_MODULE /* * Compatability with the UCD extTable */ if (!strcmp( token, "execFix" )) { int i; for ( i=0; i < num_compatability_entries; i++ ) { if (!strcmp( exec_name2, compatability_entries[i].exec_entry->token)) break; } if ( i == num_compatability_entries ) config_perror("No matching exec entry" ); else compatability_entries[ i ].efix_entry = extension; } else if (!strcmp( token, "sh" ) || !strcmp( token, "exec" )) { if ( num_compatability_entries == max_compatability_entries ) { /* XXX - should really use dynamic allocation */ netsnmp_old_extend *new_compatability_entries; new_compatability_entries = realloc(compatability_entries, max_compatability_entries*2*sizeof(netsnmp_old_extend)); if (!new_compatability_entries) config_perror("No further UCD-compatible entries" ); else { memset(new_compatability_entries+num_compatability_entries, 0, sizeof(netsnmp_old_extend)*max_compatability_entries); max_compatability_entries *= 2; compatability_entries = new_compatability_entries; } } if (num_compatability_entries != max_compatability_entries) compatability_entries[ num_compatability_entries++ ].exec_entry = extension; } #endif }
0
388,687
int smb_vfs_call_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name) { VFS_FIND(removexattr); return handle->fns->removexattr_fn(handle, path, name); }
0
202,012
void Com_EndRedirect( void ) { if ( rd_flush ) { rd_flush( rd_buffer ); } rd_buffer = NULL; rd_buffersize = 0; rd_flush = NULL; }
0
486,493
static void v9fs_getattr(void *opaque) { int32_t fid; size_t offset = 7; ssize_t retval = 0; struct stat stbuf; V9fsFidState *fidp; uint64_t request_mask; V9fsStatDotl v9stat_dotl; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; retval = pdu_unmarshal(pdu, offset, "dq", &fid, &request_mask); if (retval < 0) { goto out_nofid; } trace_v9fs_getattr(pdu->tag, pdu->id, fid, request_mask); fidp = get_fid(pdu, fid); if (fidp == NULL) { retval = -ENOENT; goto out_nofid; } /* * Currently we only support BASIC fields in stat, so there is no * need to look at request_mask. */ retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf); if (retval < 0) { goto out; } stat_to_v9stat_dotl(s, &stbuf, &v9stat_dotl); /* fill st_gen if requested and supported by underlying fs */ if (request_mask & P9_STATS_GEN) { retval = v9fs_co_st_gen(pdu, &fidp->path, stbuf.st_mode, &v9stat_dotl); switch (retval) { case 0: /* we have valid st_gen: update result mask */ v9stat_dotl.st_result_mask |= P9_STATS_GEN; break; case -EINTR: /* request cancelled, e.g. by Tflush */ goto out; default: /* failed to get st_gen: not fatal, ignore */ break; } } retval = pdu_marshal(pdu, offset, "A", &v9stat_dotl); if (retval < 0) { goto out; } retval += offset; trace_v9fs_getattr_return(pdu->tag, pdu->id, v9stat_dotl.st_result_mask, v9stat_dotl.st_mode, v9stat_dotl.st_uid, v9stat_dotl.st_gid); out: put_fid(pdu, fidp); out_nofid: pdu_complete(pdu, retval); }
0
488,227
static inline void ok_jpg_idct_1d_col_16(const int16_t *in, int *out) { static const int out_shift = 8; int t0, t1, t2; int p0, p1, p2, p3, p4, p5, p6, p7; int q0, q1, q2, q3, q4, q5, q6, q7; for (int x = 0; x < 8; x++) { // Quick check to avoid mults if (in[1] == 0 && in[2] == 0 && in[3] == 0 && in[4] == 0 && in[5] == 0 && in[6] == 0 && in[7] == 0) { t0 = in[0] << (12 - out_shift); out[ 0 * 8] = t0; out[ 1 * 8] = t0; out[ 2 * 8] = t0; out[ 3 * 8] = t0; out[ 4 * 8] = t0; out[ 5 * 8] = t0; out[ 6 * 8] = t0; out[ 7 * 8] = t0; out[ 8 * 8] = t0; out[ 9 * 8] = t0; out[10 * 8] = t0; out[11 * 8] = t0; out[12 * 8] = t0; out[13 * 8] = t0; out[14 * 8] = t0; out[15 * 8] = t0; } else { ok_jpg_idct_1d_16(in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]); out[ 0 * 8] = (p0 + q0) >> out_shift; out[ 1 * 8] = (p1 + q1) >> out_shift; out[ 2 * 8] = (p2 + q2) >> out_shift; out[ 3 * 8] = (p3 + q3) >> out_shift; out[ 4 * 8] = (p4 + q4) >> out_shift; out[ 5 * 8] = (p5 + q5) >> out_shift; out[ 6 * 8] = (p6 + q6) >> out_shift; out[ 7 * 8] = (p7 + q7) >> out_shift; out[ 8 * 8] = (p7 - q7) >> out_shift; out[ 9 * 8] = (p6 - q6) >> out_shift; out[10 * 8] = (p5 - q5) >> out_shift; out[11 * 8] = (p4 - q4) >> out_shift; out[12 * 8] = (p3 - q3) >> out_shift; out[13 * 8] = (p2 - q2) >> out_shift; out[14 * 8] = (p1 - q1) >> out_shift; out[15 * 8] = (p0 - q0) >> out_shift; } in += 8; out++; } }
0
247,333
void ExpandableContainerView::DetailsView::AddDetail( const base::string16& detail) { layout_->StartRowWithPadding(0, 0, 0, views::kRelatedControlSmallVerticalSpacing); views::Label* detail_label = new views::Label(PrepareForDisplay(detail, false)); detail_label->SetMultiLine(true); detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); layout_->AddView(detail_label); }
0
366,792
static int smack_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) { struct smk_audit_info ad; smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); smk_ad_setfield_u_fs_path_dentry(&ad, dentry); smk_ad_setfield_u_fs_path_mnt(&ad, mnt); return smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad); }
0
328,049
static void timerblock_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { timerblock *tb = (timerblock *)opaque; int64_t old; switch (addr) { case 0: /* Load */ tb->load = value; /* Fall through. */ case 4: /* Counter. */ if ((tb->control & 1) && tb->count) { /* Cancel the previous timer. */ qemu_del_timer(tb->timer); } tb->count = value; if (tb->control & 1) { timerblock_reload(tb, 1); } break; case 8: /* Control. */ old = tb->control; tb->control = value; if (((old & 1) == 0) && (value & 1)) { if (tb->count == 0 && (tb->control & 2)) { tb->count = tb->load; } timerblock_reload(tb, 1); } break; case 12: /* Interrupt status. */ tb->status &= ~value; timerblock_update_irq(tb); break; } }
0
283,199
bool FeatureInfo::IsWebGL2OrES3OrHigherContext() const { return IsWebGL2OrES3OrHigherContextType(context_type_); }
0
426,944
adv_error adv_png_read_iend(adv_fz* f, const unsigned char* data, unsigned data_size, unsigned type) { if (type == ADV_PNG_CN_IEND) return 0; /* ancillary bit. bit 5 of first byte. 0 (uppercase) = critical, 1 (lowercase) = ancillary. */ if ((type & 0x20000000) == 0) { char buf[4]; be_uint32_write(buf, type); error_unsupported_set("Unsupported critical chunk '%c%c%c%c'", buf[0], buf[1], buf[2], buf[3]); return -1; } while (1) { unsigned char* ptr; unsigned ptr_size; /* read next */ if (adv_png_read_chunk(f, &ptr, &ptr_size, &type) != 0) { return -1; } free(ptr); if (type == ADV_PNG_CN_IEND) break; /* ancillary bit. bit 5 of first byte. 0 (uppercase) = critical, 1 (lowercase) = ancillary. */ if ((type & 0x20000000) == 0) { char buf[4]; be_uint32_write(buf, type); error_unsupported_set("Unsupported critical chunk '%c%c%c%c'", buf[0], buf[1], buf[2], buf[3]); return -1; } } return 0; }
0
164,907
void Document::didUpdateSecurityOrigin() { if (!m_frame) return; m_frame->script().updateSecurityOrigin(getSecurityOrigin()); }
0
164,215
void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp) { int f2t = FrequencyToTranspose(psmp->nC4Speed); int transp = f2t >> 7; int ftune = f2t & 0x7F; if (ftune > 80) { transp++; ftune -= 128; } if (transp > 127) transp = 127; if (transp < -127) transp = -127; psmp->RelativeTone = transp; psmp->nFineTune = ftune; }
0
313,909
UtilityServiceFactory::UtilityServiceFactory() : network_registry_(base::MakeUnique<service_manager::BinderRegistry>()) {}
0
304,353
static void recalloc_sock(struct pool *pool, size_t len) { size_t old, new; old = strlen(pool->sockbuf); new = old + len + 1; if (new < pool->sockbuf_size) return; new = new + (RBUFSIZE - (new % RBUFSIZE)); applog(LOG_DEBUG, "Recallocing pool sockbuf to %lu", (unsigned long)new); pool->sockbuf = realloc(pool->sockbuf, new); if (!pool->sockbuf) quit(1, "Failed to realloc pool sockbuf in recalloc_sock"); memset(pool->sockbuf + old, 0, new - old); pool->sockbuf_size = new; }
0
48,220
static int tipc_getsockopt(struct socket *sock, int lvl, int opt, char __user *ov, int __user *ol) { struct sock *sk = sock->sk; struct tipc_sock *tsk = tipc_sk(sk); struct tipc_service_range seq; int len, scope; u32 value; int res; if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) return put_user(0, ol); if (lvl != SOL_TIPC) return -ENOPROTOOPT; res = get_user(len, ol); if (res) return res; lock_sock(sk); switch (opt) { case TIPC_IMPORTANCE: value = tsk_importance(tsk); break; case TIPC_SRC_DROPPABLE: value = tsk_unreliable(tsk); break; case TIPC_DEST_DROPPABLE: value = tsk_unreturnable(tsk); break; case TIPC_CONN_TIMEOUT: value = tsk->conn_timeout; /* no need to set "res", since already 0 at this point */ break; case TIPC_NODE_RECVQ_DEPTH: value = 0; /* was tipc_queue_size, now obsolete */ break; case TIPC_SOCK_RECVQ_DEPTH: value = skb_queue_len(&sk->sk_receive_queue); break; case TIPC_SOCK_RECVQ_USED: value = sk_rmem_alloc_get(sk); break; case TIPC_GROUP_JOIN: seq.type = 0; if (tsk->group) tipc_group_self(tsk->group, &seq, &scope); value = seq.type; break; default: res = -EINVAL; } release_sock(sk); if (res) return res; /* "get" failed */ if (len < sizeof(value)) return -EINVAL; if (copy_to_user(ov, &value, sizeof(value))) return -EFAULT; return put_user(sizeof(value), ol); }
0
225,983
void rfc_send_nsc(tRFC_MCB* p_mcb) { uint8_t* p_data; BT_HDR* p_buf = (BT_HDR*)osi_malloc(RFCOMM_CMD_BUF_SIZE); p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN; p_data = (uint8_t*)(p_buf + 1) + p_buf->offset; *p_data++ = RFCOMM_EA | RFCOMM_I_CR(false) | RFCOMM_MX_NSC; *p_data++ = RFCOMM_EA | (RFCOMM_MX_NSC_LEN << 1); *p_data++ = rfc_cb.rfc.rx_frame.ea | (rfc_cb.rfc.rx_frame.cr << RFCOMM_SHIFT_CR) | rfc_cb.rfc.rx_frame.type; /* Total length is sizeof NSC data + mx header 2 */ p_buf->len = RFCOMM_MX_NSC_LEN + 2; rfc_send_buf_uih(p_mcb, RFCOMM_MX_DLCI, p_buf); }
0
394,900
static _Bool have_gcrypt (void) /* {{{ */ { static _Bool result = 0; static _Bool need_init = 1; if (!need_init) return (result); need_init = 0; #if HAVE_LIBGCRYPT # if GCRYPT_VERSION_NUMBER < 0x010600 if (gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread)) return (0); # endif if (!gcry_check_version (GCRYPT_VERSION)) return (0); if (!gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0)) return (0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); result = 1; return (1); #else return(0); #endif } /* }}} _Bool have_gcrypt */
0
108,745
void tja1100DumpPhyReg(NetInterface *interface) { uint8_t i; //Loop through PHY registers for(i = 0; i < 32; i++) { //Display current PHY register TRACE_DEBUG("%02" PRIu8 ": 0x%04" PRIX16 "\r\n", i, tja1100ReadPhyReg(interface, i)); } //Terminate with a line feed TRACE_DEBUG("\r\n"); }
0
16,961
static void parse_palette_segment ( AVCodecContext * avctx , const uint8_t * buf , int buf_size ) { PGSSubContext * ctx = avctx -> priv_data ; const uint8_t * buf_end = buf + buf_size ; const uint8_t * cm = ff_cropTbl + MAX_NEG_CROP ; int color_id ; int y , cb , cr , alpha ; int r , g , b , r_add , g_add , b_add ; buf += 2 ; while ( buf < buf_end ) { color_id = bytestream_get_byte ( & buf ) ; y = bytestream_get_byte ( & buf ) ; cr = bytestream_get_byte ( & buf ) ; cb = bytestream_get_byte ( & buf ) ; alpha = bytestream_get_byte ( & buf ) ; YUV_TO_RGB1 ( cb , cr ) ; YUV_TO_RGB2 ( r , g , b , y ) ; av_dlog ( avctx , "Color %d := (%d,%d,%d,%d)\n" , color_id , r , g , b , alpha ) ; ctx -> clut [ color_id ] = RGBA ( r , g , b , alpha ) ; } }
0
10,077
static inline int btif_hl_select_close_connected(void){ char sig_on = btif_hl_signal_select_close_connected; BTIF_TRACE_DEBUG("btif_hl_select_close_connected"); return send(signal_fds[1], &sig_on, sizeof(sig_on), 0); }
1
67,288
int rad_packet_send(struct rad_packet_t *pack, int fd, struct sockaddr_in *addr) { int n; clock_gettime(CLOCK_MONOTONIC, &pack->tv); while (1) { if (addr) n = sendto(fd, pack->buf, pack->len, 0, addr, sizeof(*addr)); else n = write(fd, pack->buf, pack->len); if (n < 0) { if (errno == EINTR) continue; log_ppp_error("radius:write: %s\n", strerror(errno)); return -1; } else if (n != pack->len) { log_ppp_error("radius:write: short write %i, excpected %i\n", n, pack->len); return -1; } break; } return 0; }
0
146,482
file_cookies(const char *s) /* I - Cookie string or NULL */ { if (s) strlcpy(cookies, s, sizeof(cookies)); else cookies[0] = '\0'; }
0
177,842
void InspectorAgentRegistry::discardAgents() { for (size_t i = 0; i < m_agents.size(); i++) m_agents[i]->discardAgent(); }
0
184,199
int ssl3_get_record(SSL *s) { int ssl_major, ssl_minor, al; int enc_err, n, i, ret = -1; SSL3_RECORD *rr; SSL3_BUFFER *rbuf; SSL_SESSION *sess; unsigned char *p; unsigned char md[EVP_MAX_MD_SIZE]; short version; unsigned mac_size; unsigned int num_recs = 0; unsigned int max_recs; unsigned int j; rr = RECORD_LAYER_get_rrec(&s->rlayer); rbuf = RECORD_LAYER_get_rbuf(&s->rlayer); max_recs = s->max_pipelines; if (max_recs == 0) max_recs = 1; sess = s->session; do { /* check if we have the header */ if ((RECORD_LAYER_get_rstate(&s->rlayer) != SSL_ST_READ_BODY) || (RECORD_LAYER_get_packet_length(&s->rlayer) < SSL3_RT_HEADER_LENGTH)) { n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, SSL3_BUFFER_get_len(rbuf), 0, num_recs == 0 ? 1 : 0); if (n <= 0) return (n); /* error or non-blocking */ RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_BODY); p = RECORD_LAYER_get_packet(&s->rlayer); /* * The first record received by the server may be a V2ClientHello. */ if (s->server && RECORD_LAYER_is_first_record(&s->rlayer) && (p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) { /* * SSLv2 style record * * |num_recs| here will actually always be 0 because * |num_recs > 0| only ever occurs when we are processing * multiple app data records - which we know isn't the case here * because it is an SSLv2ClientHello. We keep it using * |num_recs| for the sake of consistency */ rr[num_recs].type = SSL3_RT_HANDSHAKE; rr[num_recs].rec_version = SSL2_VERSION; rr[num_recs].length = ((p[0] & 0x7f) << 8) | p[1]; if (rr[num_recs].length > SSL3_BUFFER_get_len(rbuf) - SSL2_RT_HEADER_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG); goto f_err; } if (rr[num_recs].length < MIN_SSL2_RECORD_LEN) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT); goto f_err; } } else { /* SSLv3+ style record */ if (s->msg_callback) s->msg_callback(0, 0, SSL3_RT_HEADER, p, 5, s, s->msg_callback_arg); /* Pull apart the header into the SSL3_RECORD */ rr[num_recs].type = *(p++); ssl_major = *(p++); ssl_minor = *(p++); version = (ssl_major << 8) | ssl_minor; rr[num_recs].rec_version = version; n2s(p, rr[num_recs].length); /* Lets check version */ if (!s->first_packet && version != s->version) { SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER); if ((s->version & 0xFF00) == (version & 0xFF00) && !s->enc_write_ctx && !s->write_hash) { if (rr->type == SSL3_RT_ALERT) { /* * The record is using an incorrect version number, * but what we've got appears to be an alert. We * haven't read the body yet to check whether its a * fatal or not - but chances are it is. We probably * shouldn't send a fatal alert back. We'll just * end. */ goto err; } /* * Send back error using their minor version number :-) */ s->version = (unsigned short)version; } al = SSL_AD_PROTOCOL_VERSION; goto f_err; } if ((version >> 8) != SSL3_VERSION_MAJOR) { if (RECORD_LAYER_is_first_record(&s->rlayer)) { /* Go back to start of packet, look at the five bytes * that we have. */ p = RECORD_LAYER_get_packet(&s->rlayer); if (strncmp((char *)p, "GET ", 4) == 0 || strncmp((char *)p, "POST ", 5) == 0 || strncmp((char *)p, "HEAD ", 5) == 0 || strncmp((char *)p, "PUT ", 4) == 0) { SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_HTTP_REQUEST); goto err; } else if (strncmp((char *)p, "CONNE", 5) == 0) { SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_HTTPS_PROXY_REQUEST); goto err; } /* Doesn't look like TLS - don't send an alert */ SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER); goto err; } else { SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER); al = SSL_AD_PROTOCOL_VERSION; goto f_err; } } if (rr[num_recs].length > SSL3_BUFFER_get_len(rbuf) - SSL3_RT_HEADER_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG); goto f_err; } } /* now s->rlayer.rstate == SSL_ST_READ_BODY */ } /* * s->rlayer.rstate == SSL_ST_READ_BODY, get and decode the data. * Calculate how much more data we need to read for the rest of the * record */ if (rr[num_recs].rec_version == SSL2_VERSION) { i = rr[num_recs].length + SSL2_RT_HEADER_LENGTH - SSL3_RT_HEADER_LENGTH; } else { i = rr[num_recs].length; } if (i > 0) { /* now s->packet_length == SSL3_RT_HEADER_LENGTH */ n = ssl3_read_n(s, i, i, 1, 0); if (n <= 0) return (n); /* error or non-blocking io */ } /* set state for later operations */ RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_HEADER); /* * At this point, s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length, * or s->packet_length == SSL2_RT_HEADER_LENGTH + rr->length * and we have that many bytes in s->packet */ if (rr[num_recs].rec_version == SSL2_VERSION) { rr[num_recs].input = &(RECORD_LAYER_get_packet(&s->rlayer)[SSL2_RT_HEADER_LENGTH]); } else { rr[num_recs].input = &(RECORD_LAYER_get_packet(&s->rlayer)[SSL3_RT_HEADER_LENGTH]); } /* * ok, we can now read from 's->packet' data into 'rr' rr->input points * at rr->length bytes, which need to be copied into rr->data by either * the decryption or by the decompression When the data is 'copied' into * the rr->data buffer, rr->input will be pointed at the new buffer */ /* * We now have - encrypted [ MAC [ compressed [ plain ] ] ] rr->length * bytes of encrypted compressed stuff. */ /* check is not needed I believe */ if (rr[num_recs].length > SSL3_RT_MAX_ENCRYPTED_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_ENCRYPTED_LENGTH_TOO_LONG); goto f_err; } /* decrypt in place in 'rr->input' */ rr[num_recs].data = rr[num_recs].input; rr[num_recs].orig_len = rr[num_recs].length; /* Mark this record as not read by upper layers yet */ rr[num_recs].read = 0; num_recs++; /* we have pulled in a full packet so zero things */ RECORD_LAYER_reset_packet_length(&s->rlayer); RECORD_LAYER_clear_first_record(&s->rlayer); } while (num_recs < max_recs && rr[num_recs - 1].type == SSL3_RT_APPLICATION_DATA && SSL_USE_EXPLICIT_IV(s) && s->enc_read_ctx != NULL && (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(s->enc_read_ctx)) & EVP_CIPH_FLAG_PIPELINE) && ssl3_record_app_data_waiting(s)); /* * If in encrypt-then-mac mode calculate mac from encrypted record. All * the details below are public so no timing details can leak. */ if (SSL_READ_ETM(s) && s->read_hash) { unsigned char *mac; mac_size = EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); for (j = 0; j < num_recs; j++) { if (rr[j].length < mac_size) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT); goto f_err; } rr[j].length -= mac_size; mac = rr[j].data + rr[j].length; i = s->method->ssl3_enc->mac(s, &rr[j], md, 0 /* not send */ ); if (i < 0 || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0) { al = SSL_AD_BAD_RECORD_MAC; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); goto f_err; } } } enc_err = s->method->ssl3_enc->enc(s, rr, num_recs, 0); /*- * enc_err is: * 0: (in non-constant time) if the record is publically invalid. * 1: if the padding is valid * -1: if the padding is invalid */ if (enc_err == 0) { al = SSL_AD_DECRYPTION_FAILED; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); goto f_err; } #ifdef SSL_DEBUG printf("dec %d\n", rr->length); { unsigned int z; for (z = 0; z < rr->length; z++) printf("%02X%c", rr->data[z], ((z + 1) % 16) ? ' ' : '\n'); } printf("\n"); #endif /* r->length is now the compressed data plus mac */ if ((sess != NULL) && (s->enc_read_ctx != NULL) && (!SSL_READ_ETM(s) && EVP_MD_CTX_md(s->read_hash) != NULL)) { /* s->read_hash != NULL => mac_size != -1 */ unsigned char *mac = NULL; unsigned char mac_tmp[EVP_MAX_MD_SIZE]; mac_size = EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); for (j = 0; j < num_recs; j++) { /* * orig_len is the length of the record before any padding was * removed. This is public information, as is the MAC in use, * therefore we can safely process the record in a different amount * of time if it's too short to possibly contain a MAC. */ if (rr[j].orig_len < mac_size || /* CBC records must have a padding length byte too. */ (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE && rr[j].orig_len < mac_size + 1)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT); goto f_err; } if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) { /* * We update the length so that the TLS header bytes can be * constructed correctly but we need to extract the MAC in * constant time from within the record, without leaking the * contents of the padding bytes. */ mac = mac_tmp; ssl3_cbc_copy_mac(mac_tmp, &rr[j], mac_size); rr[j].length -= mac_size; } else { /* * In this case there's no padding, so |rec->orig_len| equals * |rec->length| and we checked that there's enough bytes for * |mac_size| above. */ rr[j].length -= mac_size; mac = &rr[j].data[rr[j].length]; } i = s->method->ssl3_enc->mac(s, &rr[j], md, 0 /* not send */ ); if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0) enc_err = -1; if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + mac_size) enc_err = -1; } } if (enc_err < 0) { /* * A separate 'decryption_failed' alert was introduced with TLS 1.0, * SSL 3.0 only has 'bad_record_mac'. But unless a decryption * failure is directly visible from the ciphertext anyway, we should * not reveal which kind of error occurred -- this might become * visible to an attacker (e.g. via a logfile) */ al = SSL_AD_BAD_RECORD_MAC; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); goto f_err; } for (j = 0; j < num_recs; j++) { /* rr[j].length is now just compressed */ if (s->expand != NULL) { if (rr[j].length > SSL3_RT_MAX_COMPRESSED_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_COMPRESSED_LENGTH_TOO_LONG); goto f_err; } if (!ssl3_do_uncompress(s, &rr[j])) { al = SSL_AD_DECOMPRESSION_FAILURE; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BAD_DECOMPRESSION); goto f_err; } } if (rr[j].length > SSL3_RT_MAX_PLAIN_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } rr[j].off = 0; /*- * So at this point the following is true * rr[j].type is the type of record * rr[j].length == number of bytes in record * rr[j].off == offset to first valid byte * rr[j].data == where to take bytes from, increment after use :-). */ /* just read a 0 length packet */ if (rr[j].length == 0) { RECORD_LAYER_inc_empty_record_count(&s->rlayer); if (RECORD_LAYER_get_empty_record_count(&s->rlayer) > MAX_EMPTY_RECORDS) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_RECORD_TOO_SMALL); goto f_err; } } else { RECORD_LAYER_reset_empty_record_count(&s->rlayer); } } RECORD_LAYER_set_numrpipes(&s->rlayer, num_recs); return 1; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return ret; }
0
258,600
static void dtap_bcc_setup ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) { guint32 curr_offset ; guint32 consumed ; guint curr_len ; curr_offset = offset ; curr_len = len ; ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_BCC_CALL_REF , "(Broadcast identity)" ) ; ELEM_OPT_TLV ( 0x7e , GSM_A_PDU_TYPE_DTAP , DE_USER_USER , "(Originator-to-dispatcher information)" ) ; }
0
506,182
int dtls1_connect(SSL *s) { BUF_MEM *buf=NULL; unsigned long Time=(unsigned long)time(NULL); void (*cb)(const SSL *ssl,int type,int val)=NULL; int ret= -1; int new_state,state,skip=0; #ifndef OPENSSL_NO_SCTP unsigned char sctpauthkey[64]; char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; #endif RAND_add(&Time,sizeof(Time),0); ERR_clear_error(); clear_sys_error(); if (s->info_callback != NULL) cb=s->info_callback; else if (s->ctx->info_callback != NULL) cb=s->ctx->info_callback; s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); #ifndef OPENSSL_NO_SCTP /* Notify SCTP BIO socket to enter handshake * mode and prevent stream identifier other * than 0. Will be ignored if no SCTP is used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, s->in_handshake, NULL); #endif #ifndef OPENSSL_NO_HEARTBEATS /* If we're awaiting a HeartbeatResponse, pretend we * already got and don't await it anymore, because * Heartbeats don't make sense during handshakes anyway. */ if (s->tlsext_hb_pending) { dtls1_stop_timer(s); s->tlsext_hb_pending = 0; s->tlsext_hb_seq++; } #endif for (;;) { state=s->state; switch(s->state) { case SSL_ST_RENEGOTIATE: s->renegotiate=1; s->state=SSL_ST_CONNECT; s->ctx->stats.sess_connect_renegotiate++; /* break */ case SSL_ST_BEFORE: case SSL_ST_CONNECT: case SSL_ST_BEFORE|SSL_ST_CONNECT: case SSL_ST_OK|SSL_ST_CONNECT: s->server=0; if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); if ((s->version & 0xff00 ) != (DTLS1_VERSION & 0xff00) && (s->version & 0xff00 ) != (DTLS1_BAD_VER & 0xff00)) { SSLerr(SSL_F_DTLS1_CONNECT, ERR_R_INTERNAL_ERROR); ret = -1; goto end; } /* s->version=SSL3_VERSION; */ s->type=SSL_ST_CONNECT; if (s->init_buf == NULL) { if ((buf=BUF_MEM_new()) == NULL) { ret= -1; goto end; } if (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH)) { ret= -1; goto end; } s->init_buf=buf; buf=NULL; } if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } /* setup buffing BIO */ if (!ssl_init_wbio_buffer(s,0)) { ret= -1; goto end; } /* don't push the buffering BIO quite yet */ s->state=SSL3_ST_CW_CLNT_HELLO_A; s->ctx->stats.sess_connect++; s->init_num=0; /* mark client_random uninitialized */ memset(s->s3->client_random,0,sizeof(s->s3->client_random)); s->d1->send_cookie = 0; s->hit = 0; break; #ifndef OPENSSL_NO_SCTP case DTLS1_SCTP_ST_CR_READ_SOCK: if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { s->s3->in_read_app_data=2; s->rwstate=SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); ret = -1; goto end; } s->state=s->s3->tmp.next_state; break; case DTLS1_SCTP_ST_CW_WRITE_SOCK: /* read app data until dry event */ ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); if (ret < 0) goto end; if (ret == 0) { s->s3->in_read_app_data=2; s->rwstate=SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); ret = -1; goto end; } s->state=s->d1->next_state; break; #endif case SSL3_ST_CW_CLNT_HELLO_A: case SSL3_ST_CW_CLNT_HELLO_B: s->shutdown=0; /* every DTLS ClientHello resets Finished MAC */ ssl3_init_finished_mac(s); dtls1_start_timer(s); ret=dtls1_client_hello(s); if (ret <= 0) goto end; if ( s->d1->send_cookie) { s->state=SSL3_ST_CW_FLUSH; s->s3->tmp.next_state=SSL3_ST_CR_SRVR_HELLO_A; } else s->state=SSL3_ST_CR_SRVR_HELLO_A; s->init_num=0; #ifndef OPENSSL_NO_SCTP /* Disable buffering for SCTP */ if (!BIO_dgram_is_sctp(SSL_get_wbio(s))) { #endif /* turn on buffering for the next lot of output */ if (s->bbio != s->wbio) s->wbio=BIO_push(s->bbio,s->wbio); #ifndef OPENSSL_NO_SCTP } #endif break; case SSL3_ST_CR_SRVR_HELLO_A: case SSL3_ST_CR_SRVR_HELLO_B: ret=ssl3_get_server_hello(s); if (ret <= 0) goto end; else { dtls1_stop_timer(s); if (s->hit) { #ifndef OPENSSL_NO_SCTP /* Add new shared key for SCTP-Auth, * will be ignored if no SCTP used. */ snprintf((char*) labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), DTLS1_SCTP_AUTH_LABEL); SSL_export_keying_material(s, sctpauthkey, sizeof(sctpauthkey), labelbuffer, sizeof(labelbuffer), NULL, 0, 0); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, sizeof(sctpauthkey), sctpauthkey); #endif s->state=SSL3_ST_CR_FINISHED_A; } else s->state=DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A; } s->init_num=0; break; case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: ret = dtls1_get_hello_verify(s); if ( ret <= 0) goto end; dtls1_stop_timer(s); if ( s->d1->send_cookie) /* start again, with a cookie */ s->state=SSL3_ST_CW_CLNT_HELLO_A; else s->state = SSL3_ST_CR_CERT_A; s->init_num = 0; break; case SSL3_ST_CR_CERT_A: case SSL3_ST_CR_CERT_B: #ifndef OPENSSL_NO_TLSEXT ret=ssl3_check_finished(s); if (ret <= 0) goto end; if (ret == 2) { s->hit = 1; if (s->tlsext_ticket_expected) s->state=SSL3_ST_CR_SESSION_TICKET_A; else s->state=SSL3_ST_CR_FINISHED_A; s->init_num=0; break; } #endif /* Check if it is anon DH or PSK */ if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { ret=ssl3_get_server_certificate(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_TLSEXT if (s->tlsext_status_expected) s->state=SSL3_ST_CR_CERT_STATUS_A; else s->state=SSL3_ST_CR_KEY_EXCH_A; } else { skip = 1; s->state=SSL3_ST_CR_KEY_EXCH_A; } #else } else skip=1; s->state=SSL3_ST_CR_KEY_EXCH_A; #endif s->init_num=0; break; case SSL3_ST_CR_KEY_EXCH_A: case SSL3_ST_CR_KEY_EXCH_B: ret=ssl3_get_key_exchange(s); if (ret <= 0) goto end; s->state=SSL3_ST_CR_CERT_REQ_A; s->init_num=0; /* at this point we check that we have the * required stuff from the server */ if (!ssl3_check_cert_and_algorithm(s)) { ret= -1; goto end; } break; case SSL3_ST_CR_CERT_REQ_A: case SSL3_ST_CR_CERT_REQ_B: ret=ssl3_get_certificate_request(s); if (ret <= 0) goto end; s->state=SSL3_ST_CR_SRVR_DONE_A; s->init_num=0; break; case SSL3_ST_CR_SRVR_DONE_A: case SSL3_ST_CR_SRVR_DONE_B: ret=ssl3_get_server_done(s); if (ret <= 0) goto end; if (s->s3->tmp.cert_req) s->s3->tmp.next_state=SSL3_ST_CW_CERT_A; else s->s3->tmp.next_state=SSL3_ST_CW_KEY_EXCH_A; s->init_num=0; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && state == SSL_ST_RENEGOTIATE) s->state=DTLS1_SCTP_ST_CR_READ_SOCK; else #endif s->state=s->s3->tmp.next_state; break; case SSL3_ST_CW_CERT_A: case SSL3_ST_CW_CERT_B: case SSL3_ST_CW_CERT_C: case SSL3_ST_CW_CERT_D: dtls1_start_timer(s); ret=dtls1_send_client_certificate(s); if (ret <= 0) goto end; s->state=SSL3_ST_CW_KEY_EXCH_A; s->init_num=0; break; case SSL3_ST_CW_KEY_EXCH_A: case SSL3_ST_CW_KEY_EXCH_B: dtls1_start_timer(s); ret=dtls1_send_client_key_exchange(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP /* Add new shared key for SCTP-Auth, * will be ignored if no SCTP used. */ snprintf((char*) labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), DTLS1_SCTP_AUTH_LABEL); SSL_export_keying_material(s, sctpauthkey, sizeof(sctpauthkey), labelbuffer, sizeof(labelbuffer), NULL, 0, 0); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, sizeof(sctpauthkey), sctpauthkey); #endif /* EAY EAY EAY need to check for DH fix cert * sent back */ /* For TLS, cert_req is set to 2, so a cert chain * of nothing is sent, but no verify packet is sent */ if (s->s3->tmp.cert_req == 1) { s->state=SSL3_ST_CW_CERT_VRFY_A; } else { #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state=SSL3_ST_CW_CHANGE_A; s->state=DTLS1_SCTP_ST_CW_WRITE_SOCK; } else #endif s->state=SSL3_ST_CW_CHANGE_A; s->s3->change_cipher_spec=0; } s->init_num=0; break; case SSL3_ST_CW_CERT_VRFY_A: case SSL3_ST_CW_CERT_VRFY_B: dtls1_start_timer(s); ret=dtls1_send_client_verify(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state=SSL3_ST_CW_CHANGE_A; s->state=DTLS1_SCTP_ST_CW_WRITE_SOCK; } else #endif s->state=SSL3_ST_CW_CHANGE_A; s->init_num=0; s->s3->change_cipher_spec=0; break; case SSL3_ST_CW_CHANGE_A: case SSL3_ST_CW_CHANGE_B: if (!s->hit) dtls1_start_timer(s); ret=dtls1_send_change_cipher_spec(s, SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP /* Change to new shared key of SCTP-Auth, * will be ignored if no SCTP used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); #endif s->state=SSL3_ST_CW_FINISHED_A; s->init_num=0; s->session->cipher=s->s3->tmp.new_cipher; #ifdef OPENSSL_NO_COMP s->session->compress_meth=0; #else if (s->s3->tmp.new_compression == NULL) s->session->compress_meth=0; else s->session->compress_meth= s->s3->tmp.new_compression->id; #endif if (!s->method->ssl3_enc->setup_key_block(s)) { ret= -1; goto end; } if (!s->method->ssl3_enc->change_cipher_state(s, SSL3_CHANGE_CIPHER_CLIENT_WRITE)) { ret= -1; goto end; } dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); break; case SSL3_ST_CW_FINISHED_A: case SSL3_ST_CW_FINISHED_B: if (!s->hit) dtls1_start_timer(s); ret=dtls1_send_finished(s, SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B, s->method->ssl3_enc->client_finished_label, s->method->ssl3_enc->client_finished_label_len); if (ret <= 0) goto end; s->state=SSL3_ST_CW_FLUSH; /* clear flags */ s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER; if (s->hit) { s->s3->tmp.next_state=SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = s->s3->tmp.next_state; s->s3->tmp.next_state=DTLS1_SCTP_ST_CW_WRITE_SOCK; } #endif if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED) { s->state=SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = SSL_ST_OK; s->state=DTLS1_SCTP_ST_CW_WRITE_SOCK; } #endif s->s3->flags|=SSL3_FLAGS_POP_BUFFER; s->s3->delay_buf_pop_ret=0; } } else { #ifndef OPENSSL_NO_TLSEXT /* Allow NewSessionTicket if ticket expected */ if (s->tlsext_ticket_expected) s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A; else #endif s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A; } s->init_num=0; break; #ifndef OPENSSL_NO_TLSEXT case SSL3_ST_CR_SESSION_TICKET_A: case SSL3_ST_CR_SESSION_TICKET_B: ret=ssl3_get_new_session_ticket(s); if (ret <= 0) goto end; s->state=SSL3_ST_CR_FINISHED_A; s->init_num=0; break; case SSL3_ST_CR_CERT_STATUS_A: case SSL3_ST_CR_CERT_STATUS_B: ret=ssl3_get_cert_status(s); if (ret <= 0) goto end; s->state=SSL3_ST_CR_KEY_EXCH_A; s->init_num=0; break; #endif case SSL3_ST_CR_FINISHED_A: case SSL3_ST_CR_FINISHED_B: s->d1->change_cipher_spec_ok = 1; ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A, SSL3_ST_CR_FINISHED_B); if (ret <= 0) goto end; dtls1_stop_timer(s); if (s->hit) s->state=SSL3_ST_CW_CHANGE_A; else s->state=SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && state == SSL_ST_RENEGOTIATE) { s->d1->next_state=s->state; s->state=DTLS1_SCTP_ST_CW_WRITE_SOCK; } #endif s->init_num=0; break; case SSL3_ST_CW_FLUSH: s->rwstate=SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { /* If the write error was fatal, stop trying */ if (!BIO_should_retry(s->wbio)) { s->rwstate=SSL_NOTHING; s->state=s->s3->tmp.next_state; } ret= -1; goto end; } s->rwstate=SSL_NOTHING; s->state=s->s3->tmp.next_state; break; case SSL_ST_OK: /* clean a few things up */ ssl3_cleanup_key_block(s); #if 0 if (s->init_buf != NULL) { BUF_MEM_free(s->init_buf); s->init_buf=NULL; } #endif /* If we are not 'joining' the last two packets, * remove the buffering now */ if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER)) ssl_free_wbio_buffer(s); /* else do it later in ssl3_write */ s->init_num=0; s->renegotiate=0; s->new_session=0; ssl_update_cache(s,SSL_SESS_CACHE_CLIENT); if (s->hit) s->ctx->stats.sess_hit++; ret=1; /* s->server=0; */ s->handshake_func=dtls1_connect; s->ctx->stats.sess_connect_good++; if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); /* done with handshaking */ s->d1->handshake_read_seq = 0; s->d1->next_handshake_write_seq = 0; goto end; /* break; */ default: SSLerr(SSL_F_DTLS1_CONNECT,SSL_R_UNKNOWN_STATE); ret= -1; goto end; /* break; */ } /* did we do anything */ if (!s->s3->tmp.reuse_message && !skip) { if (s->debug) { if ((ret=BIO_flush(s->wbio)) <= 0) goto end; } if ((cb != NULL) && (s->state != state)) { new_state=s->state; s->state=state; cb(s,SSL_CB_CONNECT_LOOP,1); s->state=new_state; } } skip=0; }
0
95,881
void kernel_sigaction(int sig, __sighandler_t action) { spin_lock_irq(&current->sighand->siglock); current->sighand->action[sig - 1].sa.sa_handler = action; if (action == SIG_IGN) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, sig); flush_sigqueue_mask(&mask, &current->signal->shared_pending); flush_sigqueue_mask(&mask, &current->pending); recalc_sigpending(); } spin_unlock_irq(&current->sighand->siglock); }
0
345,623
static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int extended) { zval *IM, *EXT = NULL; gdImagePtr im=NULL; long col = -1, x = -1, y = -1; int str_len, fontname_len, i, brect[8]; double ptsize, angle; char *str = NULL, *fontname = NULL; char *error = NULL; int argc = ZEND_NUM_ARGS(); #if HAVE_GD_STRINGFTEX gdFTStringExtra strex = {0}; #endif #if !HAVE_GD_STRINGFTEX assert(!extended); #endif if (mode == TTFTEXT_BBOX) { if (argc < 4 || argc > ((extended) ? 5 : 4)) { ZEND_WRONG_PARAM_COUNT(); } else if (zend_parse_parameters(argc TSRMLS_CC, "ddss|a", &ptsize, &angle, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { RETURN_FALSE; } } else { if (argc < 8 || argc > ((extended) ? 9 : 8)) { ZEND_WRONG_PARAM_COUNT(); } else if (zend_parse_parameters(argc TSRMLS_CC, "rddlllss|a", &IM, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { RETURN_FALSE; } ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd); } /* convert angle to radians */ angle = angle * (M_PI/180); #if HAVE_GD_STRINGFTEX if (extended && EXT) { /* parse extended info */ HashPosition pos; /* walk the assoc array */ zend_hash_internal_pointer_reset_ex(HASH_OF(EXT), &pos); do { zval ** item; char * key; ulong num_key; if (zend_hash_get_current_key_ex(HASH_OF(EXT), &key, NULL, &num_key, 0, &pos) != HASH_KEY_IS_STRING) { continue; } if (zend_hash_get_current_data_ex(HASH_OF(EXT), (void **) &item, &pos) == FAILURE) { continue; } if (strcmp("linespacing", key) == 0) { convert_to_double_ex(item); strex.flags |= gdFTEX_LINESPACE; strex.linespacing = Z_DVAL_PP(item); } } while (zend_hash_move_forward_ex(HASH_OF(EXT), &pos) == SUCCESS); } #endif #ifdef VIRTUAL_DIR { char tmp_font_path[MAXPATHLEN]; if (!VCWD_REALPATH(fontname, tmp_font_path)) { fontname = NULL; } } #endif PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename"); #ifdef USE_GD_IMGSTRTTF # if HAVE_GD_STRINGFTEX if (extended) { error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex); } else # endif # if HAVE_GD_STRINGFT error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str); # elif HAVE_GD_STRINGTTF error = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y, str); # endif #endif if (error) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", error); RETURN_FALSE; } array_init(return_value); /* return array with the text's bounding box */ for (i = 0; i < 8; i++) { add_next_index_long(return_value, brect[i]); } }
1
160,768
int accept_conn(AsyncConnectionRef conn) { Mutex::Locker l(lock); auto it = conns.find(conn->peer_addr); if (it != conns.end()) { AsyncConnectionRef existing = it->second; // lazy delete, see "deleted_conns" // If conn already in, we will return 0 Mutex::Locker l(deleted_lock); if (deleted_conns.erase(existing)) { existing->get_perf_counter()->dec(l_msgr_active_connections); conns.erase(it); } else if (conn != existing) { return -1; } } conns[conn->peer_addr] = conn; conn->get_perf_counter()->inc(l_msgr_active_connections); accepting_conns.erase(conn); return 0; }
0
268,763
static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr, unsigned long end, struct mm_walk *walk) { #ifdef CONFIG_HUGETLB_PAGE unsigned char present; unsigned char *vec = walk->private; /* * Hugepages under user process are always in RAM and never * swapped out, but theoretically it needs to be checked. */ present = pte && !huge_pte_none(huge_ptep_get(pte)); for (; addr != end; vec++, addr += PAGE_SIZE) *vec = present; walk->private = vec; #else BUG(); #endif return 0; }
0