target
int64
0
1
func
stringlengths
7
484k
func_no_comments
stringlengths
7
484k
idx
int64
1
368k
1
static int vnc_zlib_stop(VncState *vs, int stream_id) { z_streamp zstream = &vs->zlib_stream[stream_id]; int previous_out; // switch back to normal output/zlib buffers vs->zlib = vs->output; vs->output = vs->zlib_tmp; // compress the zlib buffer // initialize the stream // XXX need one stream per session if (zstream->opaque != vs) { int err; VNC_DEBUG("VNC: initializing zlib stream %d\n", stream_id); VNC_DEBUG("VNC: opaque = %p | vs = %p\n", zstream->opaque, vs); zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; err = deflateInit2(zstream, vs->tight_compression, Z_DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (err != Z_OK) { fprintf(stderr, "VNC: error initializing zlib\n"); return -1; } zstream->opaque = vs; } // XXX what to do if tight_compression changed in between? // reserve memory in output buffer buffer_reserve(&vs->output, vs->zlib.offset + 64); // set pointers zstream->next_in = vs->zlib.buffer; zstream->avail_in = vs->zlib.offset; zstream->next_out = vs->output.buffer + vs->output.offset; zstream->avail_out = vs->output.capacity - vs->output.offset; zstream->data_type = Z_BINARY; previous_out = zstream->total_out; // start encoding if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) { fprintf(stderr, "VNC: error during zlib compression\n"); return -1; } vs->output.offset = vs->output.capacity - zstream->avail_out; return zstream->total_out - previous_out; }
static int vnc_zlib_stop(VncState *vs, int stream_id) { z_streamp zstream = &vs->zlib_stream[stream_id]; int previous_out;
518
1
spnego_gss_wrap_size_limit( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, OM_uint32 req_output_size, OM_uint32 *max_input_size) { OM_uint32 ret; ret = gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, qop_req, req_output_size, max_input_size); return (ret); }
spnego_gss_wrap_size_limit( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, int conf_req_flag, gss_qop_t qop_req, OM_uint32 req_output_size, OM_uint32 *max_input_size) { OM_uint32 ret; ret = gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, qop_req, req_output_size, max_input_size); return (ret); }
519
1
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { CSmartPtr<CWebSession> spSession = WebSock.GetSession(); if (sPageName == "settings") { // Admin Check if (!spSession->IsAdmin()) { return false; } return SettingsPage(WebSock, Tmpl); } else if (sPageName == "adduser") { // Admin Check if (!spSession->IsAdmin()) { return false; } return UserPage(WebSock, Tmpl); } else if (sPageName == "addnetwork") { CUser* pUser = SafeGetUserFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return NetworkPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "editnetwork") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } return NetworkPage(WebSock, Tmpl, pNetwork->GetUser(), pNetwork); } else if (sPageName == "delnetwork") { CString sUser = WebSock.GetParam("user"); if (sUser.empty() && !WebSock.IsPost()) { sUser = WebSock.GetParam("user", false); } CUser* pUser = CZNC::Get().FindUser(sUser); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } return DelNetwork(WebSock, pUser, Tmpl); } else if (sPageName == "editchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } CString sChan = WebSock.GetParam("name"); if(sChan.empty() && !WebSock.IsPost()) { sChan = WebSock.GetParam("name", false); } CChan* pChan = pNetwork->FindChan(sChan); if (!pChan) { WebSock.PrintErrorPage("No such channel"); return true; } return ChanPage(WebSock, Tmpl, pNetwork, pChan); } else if (sPageName == "addchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return ChanPage(WebSock, Tmpl, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "delchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return DelChan(WebSock, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "deluser") { if (!spSession->IsAdmin()) { return false; } if (!WebSock.IsPost()) { // Show the "Are you sure?" page: CString sUser = WebSock.GetParam("user", false); CUser* pUser = CZNC::Get().FindUser(sUser); if (!pUser) { WebSock.PrintErrorPage("No such username"); return true; } Tmpl.SetFile("del_user.tmpl"); Tmpl["Username"] = sUser; return true; } // The "Are you sure?" page has been submitted with "Yes", // so we actually delete the user now: CString sUser = WebSock.GetParam("user"); CUser* pUser = CZNC::Get().FindUser(sUser); if (pUser && pUser == spSession->GetUser()) { WebSock.PrintErrorPage("Please don't delete yourself, suicide is not the answer!"); return true; } else if (CZNC::Get().DeleteUser(sUser)) { WebSock.Redirect("listusers"); return true; } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "edituser") { CString sUserName = SafeGetUserNameParam(WebSock); CUser* pUser = CZNC::Get().FindUser(sUserName); if(!pUser) { if(sUserName.empty()) { pUser = spSession->GetUser(); } // else: the "no such user" message will be printed. } // Admin||Self Check if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return UserPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "listusers" && spSession->IsAdmin()) { return ListUsersPage(WebSock, Tmpl); } else if (sPageName == "traffic" && spSession->IsAdmin()) { return TrafficPage(WebSock, Tmpl); } else if (sPageName == "index") { return true; } else if (sPageName == "add_listener") { // Admin Check if (!spSession->IsAdmin()) { return false; } return AddListener(WebSock, Tmpl); } else if (sPageName == "del_listener") { // Admin Check if (!spSession->IsAdmin()) { return false; } return DelListener(WebSock, Tmpl); } return false; }
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { CSmartPtr<CWebSession> spSession = WebSock.GetSession(); if (sPageName == "settings") { if (!spSession->IsAdmin()) { return false; } return SettingsPage(WebSock, Tmpl); } else if (sPageName == "adduser") { if (!spSession->IsAdmin()) { return false; } return UserPage(WebSock, Tmpl); } else if (sPageName == "addnetwork") { CUser* pUser = SafeGetUserFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return NetworkPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "editnetwork") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } return NetworkPage(WebSock, Tmpl, pNetwork->GetUser(), pNetwork); } else if (sPageName == "delnetwork") { CString sUser = WebSock.GetParam("user"); if (sUser.empty() && !WebSock.IsPost()) { sUser = WebSock.GetParam("user", false); } CUser* pUser = CZNC::Get().FindUser(sUser); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } return DelNetwork(WebSock, pUser, Tmpl); } else if (sPageName == "editchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (!pNetwork) { WebSock.PrintErrorPage("No such username or network"); return true; } CString sChan = WebSock.GetParam("name"); if(sChan.empty() && !WebSock.IsPost()) { sChan = WebSock.GetParam("name", false); } CChan* pChan = pNetwork->FindChan(sChan); if (!pChan) { WebSock.PrintErrorPage("No such channel"); return true; } return ChanPage(WebSock, Tmpl, pNetwork, pChan); } else if (sPageName == "addchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return ChanPage(WebSock, Tmpl, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "delchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) { return false; } if (pNetwork) { return DelChan(WebSock, pNetwork); } WebSock.PrintErrorPage("No such username or network"); return true; } else if (sPageName == "deluser") { if (!spSession->IsAdmin()) { return false; } if (!WebSock.IsPost()) { CString sUser = WebSock.GetParam("user", false); CUser* pUser = CZNC::Get().FindUser(sUser); if (!pUser) { WebSock.PrintErrorPage("No such username"); return true; } Tmpl.SetFile("del_user.tmpl"); Tmpl["Username"] = sUser; return true; } CString sUser = WebSock.GetParam("user"); CUser* pUser = CZNC::Get().FindUser(sUser); if (pUser && pUser == spSession->GetUser()) { WebSock.PrintErrorPage("Please don't delete yourself, suicide is not the answer!"); return true; } else if (CZNC::Get().DeleteUser(sUser)) { WebSock.Redirect("listusers"); return true; } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "edituser") { CString sUserName = SafeGetUserNameParam(WebSock); CUser* pUser = CZNC::Get().FindUser(sUserName); if(!pUser) { if(sUserName.empty()) { pUser = spSession->GetUser(); } } if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) { return false; } if (pUser) { return UserPage(WebSock, Tmpl, pUser); } WebSock.PrintErrorPage("No such username"); return true; } else if (sPageName == "listusers" && spSession->IsAdmin()) { return ListUsersPage(WebSock, Tmpl); } else if (sPageName == "traffic" && spSession->IsAdmin()) { return TrafficPage(WebSock, Tmpl); } else if (sPageName == "index") { return true; } else if (sPageName == "add_listener") { if (!spSession->IsAdmin()) { return false; } return AddListener(WebSock, Tmpl); } else if (sPageName == "del_listener") { if (!spSession->IsAdmin()) { return false; } return DelListener(WebSock, Tmpl); } return false; }
520
0
void VoIPcalls_init_tap ( void ) { GString * error_string ; if ( have_voip_tap_listener == FALSE ) { error_string = register_tap_listener ( "voip" , & ( the_tapinfo_struct . voip_dummy ) , NULL , 0 , voip_calls_dlg_reset , VoIPcalls_packet , voip_calls_dlg_draw ) ; if ( error_string != NULL ) { simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , "%s" , error_string -> str ) ; g_string_free ( error_string , TRUE ) ; exit ( 1 ) ; } have_voip_tap_listener = TRUE ; } }
void VoIPcalls_init_tap ( void ) { GString * error_string ; if ( have_voip_tap_listener == FALSE ) { error_string = register_tap_listener ( "voip" , & ( the_tapinfo_struct . voip_dummy ) , NULL , 0 , voip_calls_dlg_reset , VoIPcalls_packet , voip_calls_dlg_draw ) ; if ( error_string != NULL ) { simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , "%s" , error_string -> str ) ; g_string_free ( error_string , TRUE ) ; exit ( 1 ) ; } have_voip_tap_listener = TRUE ; } }
521
1
static int grep_tree(struct grep_opt *opt, const char **paths, struct tree_desc *tree, const char *tree_name, const char *base) { int len; int hit = 0; struct name_entry entry; char *down; int tn_len = strlen(tree_name); char *path_buf = xmalloc(PATH_MAX + tn_len + 100); if (tn_len) { tn_len = sprintf(path_buf, "%s:", tree_name); down = path_buf + tn_len; strcat(down, base); } else { down = path_buf; strcpy(down, base); } len = strlen(path_buf); while (tree_entry(tree, &entry)) { strcpy(path_buf + len, entry.path); if (S_ISDIR(entry.mode)) /* Match "abc/" against pathspec to * decide if we want to descend into "abc" * directory. */ strcpy(path_buf + len + tree_entry_len(entry.path, entry.sha1), "/"); if (!pathspec_matches(paths, down)) ; else if (S_ISREG(entry.mode)) hit |= grep_sha1(opt, entry.sha1, path_buf, tn_len); else if (S_ISDIR(entry.mode)) { enum object_type type; struct tree_desc sub; void *data; unsigned long size; data = read_sha1_file(entry.sha1, &type, &size); if (!data) die("unable to read tree (%s)", sha1_to_hex(entry.sha1)); init_tree_desc(&sub, data, size); hit |= grep_tree(opt, paths, &sub, tree_name, down); free(data); } } return hit; }
static int grep_tree(struct grep_opt *opt, const char **paths, struct tree_desc *tree, const char *tree_name, const char *base) { int len; int hit = 0; struct name_entry entry; char *down; int tn_len = strlen(tree_name); char *path_buf = xmalloc(PATH_MAX + tn_len + 100); if (tn_len) { tn_len = sprintf(path_buf, "%s:", tree_name); down = path_buf + tn_len; strcat(down, base); } else { down = path_buf; strcpy(down, base); } len = strlen(path_buf); while (tree_entry(tree, &entry)) { strcpy(path_buf + len, entry.path); if (S_ISDIR(entry.mode)) strcpy(path_buf + len + tree_entry_len(entry.path, entry.sha1), "/"); if (!pathspec_matches(paths, down)) ; else if (S_ISREG(entry.mode)) hit |= grep_sha1(opt, entry.sha1, path_buf, tn_len); else if (S_ISDIR(entry.mode)) { enum object_type type; struct tree_desc sub; void *data; unsigned long size; data = read_sha1_file(entry.sha1, &type, &size); if (!data) die("unable to read tree (%s)", sha1_to_hex(entry.sha1)); init_tree_desc(&sub, data, size); hit |= grep_tree(opt, paths, &sub, tree_name, down); free(data); } } return hit; }
522
1
static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { FLACParseContext *fpc = s->priv_data; FLACHeaderMarker *curr; int nb_headers; const uint8_t *read_end = buf; const uint8_t *read_start = buf; if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { FLACFrameInfo fi; if (frame_header_is_valid(avctx, buf, &fi)) { s->duration = fi.blocksize; if (!avctx->sample_rate) avctx->sample_rate = fi.samplerate; if (fpc->pc->flags & PARSER_FLAG_USE_CODEC_TS){ fpc->pc->pts = fi.frame_or_sample_num; if (!fi.is_var_size) fpc->pc->pts *= fi.blocksize; } } *poutbuf = buf; *poutbuf_size = buf_size; return buf_size; } fpc->avctx = avctx; if (fpc->best_header_valid) return get_best_header(fpc, poutbuf, poutbuf_size); /* If a best_header was found last call remove it with the buffer data. */ if (fpc->best_header && fpc->best_header->best_child) { FLACHeaderMarker *temp; FLACHeaderMarker *best_child = fpc->best_header->best_child; /* Remove headers in list until the end of the best_header. */ for (curr = fpc->headers; curr != best_child; curr = temp) { if (curr != fpc->best_header) { av_log(avctx, AV_LOG_DEBUG, "dropping low score %i frame header from offset %i to %i\n", curr->max_score, curr->offset, curr->next->offset); } temp = curr->next; av_freep(&curr->link_penalty); av_free(curr); } /* Release returned data from ring buffer. */ av_fifo_drain(fpc->fifo_buf, best_child->offset); /* Fix the offset for the headers remaining to match the new buffer. */ for (curr = best_child->next; curr; curr = curr->next) curr->offset -= best_child->offset; best_child->offset = 0; fpc->headers = best_child; if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) { fpc->best_header = best_child; return get_best_header(fpc, poutbuf, poutbuf_size); } fpc->best_header = NULL; } else if (fpc->best_header) { /* No end frame no need to delete the buffer; probably eof */ FLACHeaderMarker *temp; for (curr = fpc->headers; curr != fpc->best_header; curr = temp) { temp = curr->next; av_freep(&curr->link_penalty); av_free(curr); } fpc->headers = fpc->best_header->next; av_freep(&fpc->best_header->link_penalty); av_freep(&fpc->best_header); } /* Find and score new headers. */ /* buf_size is to zero when padding, so check for this since we do */ /* not want to try to read more input once we have found the end. */ /* Note that as (non-modified) parameters, buf can be non-NULL, */ /* while buf_size is 0. */ while ((buf && buf_size && read_end < buf + buf_size && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) || ((!buf || !buf_size) && !fpc->end_padded)) { int start_offset; /* Pad the end once if EOF, to check the final region for headers. */ if (!buf || !buf_size) { fpc->end_padded = 1; buf_size = MAX_FRAME_HEADER_SIZE; read_end = read_start + MAX_FRAME_HEADER_SIZE; } else { /* The maximum read size is the upper-bound of what the parser needs to have the required number of frames buffered */ int nb_desired = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1; read_end = read_end + FFMIN(buf + buf_size - read_end, nb_desired * FLAC_AVG_FRAME_SIZE); } if (!av_fifo_space(fpc->fifo_buf) && av_fifo_size(fpc->fifo_buf) / FLAC_AVG_FRAME_SIZE > fpc->nb_headers_buffered * 20) { /* There is less than one valid flac header buffered for 20 headers * buffered. Therefore the fifo is most likely filled with invalid * data and the input is not a flac file. */ goto handle_error; } /* Fill the buffer. */ if ( av_fifo_space(fpc->fifo_buf) < read_end - read_start && av_fifo_realloc2(fpc->fifo_buf, (read_end - read_start) + 2*av_fifo_size(fpc->fifo_buf)) < 0) { av_log(avctx, AV_LOG_ERROR, "couldn't reallocate buffer of size %"PTRDIFF_SPECIFIER"\n", (read_end - read_start) + av_fifo_size(fpc->fifo_buf)); goto handle_error; } if (buf && buf_size) { av_fifo_generic_write(fpc->fifo_buf, (void*) read_start, read_end - read_start, NULL); } else { int8_t pad[MAX_FRAME_HEADER_SIZE] = { 0 }; av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL); } /* Tag headers and update sequences. */ start_offset = av_fifo_size(fpc->fifo_buf) - ((read_end - read_start) + (MAX_FRAME_HEADER_SIZE - 1)); start_offset = FFMAX(0, start_offset); nb_headers = find_new_headers(fpc, start_offset); if (nb_headers < 0) { av_log(avctx, AV_LOG_ERROR, "find_new_headers couldn't allocate FLAC header\n"); goto handle_error; } fpc->nb_headers_buffered = nb_headers; /* Wait till FLAC_MIN_HEADERS to output a valid frame. */ if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) { if (buf && read_end < buf + buf_size) { read_start = read_end; continue; } else { goto handle_error; } } /* If headers found, update the scores since we have longer chains. */ if (fpc->end_padded || fpc->nb_headers_found) score_sequences(fpc); /* restore the state pre-padding */ if (fpc->end_padded) { int warp = fpc->fifo_buf->wptr - fpc->fifo_buf->buffer < MAX_FRAME_HEADER_SIZE; /* HACK: drain the tail of the fifo */ fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE; fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE; if (warp) { fpc->fifo_buf->wptr += fpc->fifo_buf->end - fpc->fifo_buf->buffer; } buf_size = 0; read_start = read_end = NULL; } } for (curr = fpc->headers; curr; curr = curr->next) { if (curr->max_score > 0 && (!fpc->best_header || curr->max_score > fpc->best_header->max_score)) { fpc->best_header = curr; } } if (fpc->best_header) { fpc->best_header_valid = 1; if (fpc->best_header->offset > 0) { /* Output a junk frame. */ av_log(avctx, AV_LOG_DEBUG, "Junk frame till offset %i\n", fpc->best_header->offset); /* Set duration to 0. It is unknown or invalid in a junk frame. */ s->duration = 0; *poutbuf_size = fpc->best_header->offset; *poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size, &fpc->wrap_buf, &fpc->wrap_buf_allocated_size); return buf_size ? (read_end - buf) : (fpc->best_header->offset - av_fifo_size(fpc->fifo_buf)); } if (!buf_size) return get_best_header(fpc, poutbuf, poutbuf_size); } handle_error: *poutbuf = NULL; *poutbuf_size = 0; return buf_size ? read_end - buf : 0; }
static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { FLACParseContext *fpc = s->priv_data; FLACHeaderMarker *curr; int nb_headers; const uint8_t *read_end = buf; const uint8_t *read_start = buf; if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { FLACFrameInfo fi; if (frame_header_is_valid(avctx, buf, &fi)) { s->duration = fi.blocksize; if (!avctx->sample_rate) avctx->sample_rate = fi.samplerate; if (fpc->pc->flags & PARSER_FLAG_USE_CODEC_TS){ fpc->pc->pts = fi.frame_or_sample_num; if (!fi.is_var_size) fpc->pc->pts *= fi.blocksize; } } *poutbuf = buf; *poutbuf_size = buf_size; return buf_size; } fpc->avctx = avctx; if (fpc->best_header_valid) return get_best_header(fpc, poutbuf, poutbuf_size); if (fpc->best_header && fpc->best_header->best_child) { FLACHeaderMarker *temp; FLACHeaderMarker *best_child = fpc->best_header->best_child; for (curr = fpc->headers; curr != best_child; curr = temp) { if (curr != fpc->best_header) { av_log(avctx, AV_LOG_DEBUG, "dropping low score %i frame header from offset %i to %i\n", curr->max_score, curr->offset, curr->next->offset); } temp = curr->next; av_freep(&curr->link_penalty); av_free(curr); } av_fifo_drain(fpc->fifo_buf, best_child->offset); for (curr = best_child->next; curr; curr = curr->next) curr->offset -= best_child->offset; best_child->offset = 0; fpc->headers = best_child; if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) { fpc->best_header = best_child; return get_best_header(fpc, poutbuf, poutbuf_size); } fpc->best_header = NULL; } else if (fpc->best_header) { FLACHeaderMarker *temp; for (curr = fpc->headers; curr != fpc->best_header; curr = temp) { temp = curr->next; av_freep(&curr->link_penalty); av_free(curr); } fpc->headers = fpc->best_header->next; av_freep(&fpc->best_header->link_penalty); av_freep(&fpc->best_header); } while ((buf && buf_size && read_end < buf + buf_size && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) || ((!buf || !buf_size) && !fpc->end_padded)) { int start_offset; if (!buf || !buf_size) { fpc->end_padded = 1; buf_size = MAX_FRAME_HEADER_SIZE; read_end = read_start + MAX_FRAME_HEADER_SIZE; } else { int nb_desired = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1; read_end = read_end + FFMIN(buf + buf_size - read_end, nb_desired * FLAC_AVG_FRAME_SIZE); } if (!av_fifo_space(fpc->fifo_buf) && av_fifo_size(fpc->fifo_buf) / FLAC_AVG_FRAME_SIZE > fpc->nb_headers_buffered * 20) { goto handle_error; } if ( av_fifo_space(fpc->fifo_buf) < read_end - read_start && av_fifo_realloc2(fpc->fifo_buf, (read_end - read_start) + 2*av_fifo_size(fpc->fifo_buf)) < 0) { av_log(avctx, AV_LOG_ERROR, "couldn't reallocate buffer of size %"PTRDIFF_SPECIFIER"\n", (read_end - read_start) + av_fifo_size(fpc->fifo_buf)); goto handle_error; } if (buf && buf_size) { av_fifo_generic_write(fpc->fifo_buf, (void*) read_start, read_end - read_start, NULL); } else { int8_t pad[MAX_FRAME_HEADER_SIZE] = { 0 }; av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL); } start_offset = av_fifo_size(fpc->fifo_buf) - ((read_end - read_start) + (MAX_FRAME_HEADER_SIZE - 1)); start_offset = FFMAX(0, start_offset); nb_headers = find_new_headers(fpc, start_offset); if (nb_headers < 0) { av_log(avctx, AV_LOG_ERROR, "find_new_headers couldn't allocate FLAC header\n"); goto handle_error; } fpc->nb_headers_buffered = nb_headers; if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) { if (buf && read_end < buf + buf_size) { read_start = read_end; continue; } else { goto handle_error; } } if (fpc->end_padded || fpc->nb_headers_found) score_sequences(fpc); if (fpc->end_padded) { int warp = fpc->fifo_buf->wptr - fpc->fifo_buf->buffer < MAX_FRAME_HEADER_SIZE; fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE; fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE; if (warp) { fpc->fifo_buf->wptr += fpc->fifo_buf->end - fpc->fifo_buf->buffer; } buf_size = 0; read_start = read_end = NULL; } } for (curr = fpc->headers; curr; curr = curr->next) { if (curr->max_score > 0 && (!fpc->best_header || curr->max_score > fpc->best_header->max_score)) { fpc->best_header = curr; } } if (fpc->best_header) { fpc->best_header_valid = 1; if (fpc->best_header->offset > 0) { av_log(avctx, AV_LOG_DEBUG, "Junk frame till offset %i\n", fpc->best_header->offset); s->duration = 0; *poutbuf_size = fpc->best_header->offset; *poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size, &fpc->wrap_buf, &fpc->wrap_buf_allocated_size); return buf_size ? (read_end - buf) : (fpc->best_header->offset - av_fifo_size(fpc->fifo_buf)); } if (!buf_size) return get_best_header(fpc, poutbuf, poutbuf_size); } handle_error: *poutbuf = NULL; *poutbuf_size = 0; return buf_size ? read_end - buf : 0; }
523
1
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags) { VLCcode *buf; int i, j, ret; vlc->bits = nb_bits; if(flags & INIT_VLC_USE_NEW_STATIC){ VLC dyn_vlc = *vlc; if (vlc->table_size) return 0; ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags & ~INIT_VLC_USE_NEW_STATIC); av_assert0(ret >= 0); av_assert0(dyn_vlc.table_size <= vlc->table_allocated); if(dyn_vlc.table_size < vlc->table_allocated) av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated); memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table)); vlc->table_size = dyn_vlc.table_size; ff_free_vlc(&dyn_vlc); return 0; }else { vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; } av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); av_assert0(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) {\ GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ if (!(condition))\ continue;\ if (buf[j].bits > 3*nb_bits || buf[j].bits>32) {\ av_log(NULL, AV_LOG_ERROR, "Too long VLC in init_vlc\n");\ return -1;\ }\ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ if (buf[j].code >= (1LL<<buf[j].bits)) {\ av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n");\ return -1;\ }\ if (flags & INIT_VLC_LE)\ buf[j].code = bitswap_32(buf[j].code);\ else\ buf[j].code <<= 32 - buf[j].bits;\ if (symbols)\ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ else\ buf[j].symbol = i;\ j++;\ } COPY(buf[j].bits > nb_bits); // qsort is the slowest part of init_vlc, and could probably be improved or avoided qsort(buf, j, sizeof(VLCcode), compare_vlcspec); COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; ret = build_table(vlc, nb_bits, nb_codes, buf, flags); av_free(buf); if (ret < 0) { av_freep(&vlc->table); return -1; } return 0; }
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags) { VLCcode *buf; int i, j, ret; vlc->bits = nb_bits; if(flags & INIT_VLC_USE_NEW_STATIC){ VLC dyn_vlc = *vlc; if (vlc->table_size) return 0; ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags & ~INIT_VLC_USE_NEW_STATIC); av_assert0(ret >= 0); av_assert0(dyn_vlc.table_size <= vlc->table_allocated); if(dyn_vlc.table_size < vlc->table_allocated) av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated); memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table)); vlc->table_size = dyn_vlc.table_size; ff_free_vlc(&dyn_vlc); return 0; }else { vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; } av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); av_assert0(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) {\ GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ if (!(condition))\ continue;\ if (buf[j].bits > 3*nb_bits || buf[j].bits>32) {\ av_log(NULL, AV_LOG_ERROR, "Too long VLC in init_vlc\n");\ return -1;\ }\ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ if (buf[j].code >= (1LL<<buf[j].bits)) {\ av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n");\ return -1;\ }\ if (flags & INIT_VLC_LE)\ buf[j].code = bitswap_32(buf[j].code);\ else\ buf[j].code <<= 32 - buf[j].bits;\ if (symbols)\ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ else\ buf[j].symbol = i;\ j++;\ } COPY(buf[j].bits > nb_bits);
524
1
static int gss_iakerbmechglue_init(void) { struct gss_mech_config mech_iakerb; struct gss_config iakerb_mechanism = krb5_mechanism; /* IAKERB mechanism mirrors krb5, but with different context SPIs */ iakerb_mechanism.gss_accept_sec_context = iakerb_gss_accept_sec_context; iakerb_mechanism.gss_init_sec_context = iakerb_gss_init_sec_context; iakerb_mechanism.gss_delete_sec_context = iakerb_gss_delete_sec_context; iakerb_mechanism.gss_acquire_cred = iakerb_gss_acquire_cred; iakerb_mechanism.gssspi_acquire_cred_with_password = iakerb_gss_acquire_cred_with_password; memset(&mech_iakerb, 0, sizeof(mech_iakerb)); mech_iakerb.mech = &iakerb_mechanism; mech_iakerb.mechNameStr = "iakerb"; mech_iakerb.mech_type = (gss_OID)gss_mech_iakerb; gssint_register_mechinfo(&mech_iakerb); return 0; }
static int gss_iakerbmechglue_init(void) { struct gss_mech_config mech_iakerb; struct gss_config iakerb_mechanism = krb5_mechanism; iakerb_mechanism.gss_accept_sec_context = iakerb_gss_accept_sec_context; iakerb_mechanism.gss_init_sec_context = iakerb_gss_init_sec_context; iakerb_mechanism.gss_delete_sec_context = iakerb_gss_delete_sec_context; iakerb_mechanism.gss_acquire_cred = iakerb_gss_acquire_cred; iakerb_mechanism.gssspi_acquire_cred_with_password = iakerb_gss_acquire_cred_with_password; memset(&mech_iakerb, 0, sizeof(mech_iakerb)); mech_iakerb.mech = &iakerb_mechanism; mech_iakerb.mechNameStr = "iakerb"; mech_iakerb.mech_type = (gss_OID)gss_mech_iakerb; gssint_register_mechinfo(&mech_iakerb); return 0; }
525
1
void CConfig::Write(CFile& File, unsigned int iIndentation) { CString sIndentation = CString(iIndentation, '\t'); for (const auto& it : m_ConfigEntries) { for (const CString& sValue : it.second) { File.Write(sIndentation + it.first + " = " + sValue + "\n"); } } for (const auto& it : m_SubConfigs) { for (const auto& it2 : it.second) { File.Write("\n"); File.Write(sIndentation + "<" + it.first + " " + it2.first + ">\n"); it2.second.m_pSubConfig->Write(File, iIndentation + 1); File.Write(sIndentation + "</" + it.first + ">\n"); } } }
void CConfig::Write(CFile& File, unsigned int iIndentation) { CString sIndentation = CString(iIndentation, '\t'); for (const auto& it : m_ConfigEntries) { for (const CString& sValue : it.second) { File.Write(sIndentation + it.first + " = " + sValue + "\n"); } } for (const auto& it : m_SubConfigs) { for (const auto& it2 : it.second) { File.Write("\n"); File.Write(sIndentation + "<" + it.first + " " + it2.first + ">\n"); it2.second.m_pSubConfig->Write(File, iIndentation + 1); File.Write(sIndentation + "</" + it.first + ">\n"); } } }
526
1
static int dccp_setsockopt_change(struct sock *sk, int type, struct dccp_so_feat __user *optval) { struct dccp_so_feat opt; u8 *val; int rc; if (copy_from_user(&opt, optval, sizeof(opt))) return -EFAULT; val = kmalloc(opt.dccpsf_len, GFP_KERNEL); if (!val) return -ENOMEM; if (copy_from_user(val, opt.dccpsf_val, opt.dccpsf_len)) { rc = -EFAULT; goto out_free_val; } rc = dccp_feat_change(dccp_msk(sk), type, opt.dccpsf_feat, val, opt.dccpsf_len, GFP_KERNEL); if (rc) goto out_free_val; out: return rc; out_free_val: kfree(val); goto out; }
static int dccp_setsockopt_change(struct sock *sk, int type, struct dccp_so_feat __user *optval) { struct dccp_so_feat opt; u8 *val; int rc; if (copy_from_user(&opt, optval, sizeof(opt))) return -EFAULT; val = kmalloc(opt.dccpsf_len, GFP_KERNEL); if (!val) return -ENOMEM; if (copy_from_user(val, opt.dccpsf_val, opt.dccpsf_len)) { rc = -EFAULT; goto out_free_val; } rc = dccp_feat_change(dccp_msk(sk), type, opt.dccpsf_feat, val, opt.dccpsf_len, GFP_KERNEL); if (rc) goto out_free_val; out: return rc; out_free_val: kfree(val); goto out; }
528
1
static int sctp_setsockopt_auth_chunk(struct sock *sk, char __user *optval, int optlen) { struct sctp_authchunk val; if (optlen != sizeof(struct sctp_authchunk)) return -EINVAL; if (copy_from_user(&val, optval, optlen)) return -EFAULT; switch (val.sauth_chunk) { case SCTP_CID_INIT: case SCTP_CID_INIT_ACK: case SCTP_CID_SHUTDOWN_COMPLETE: case SCTP_CID_AUTH: return -EINVAL; } /* add this chunk id to the endpoint */ return sctp_auth_ep_add_chunkid(sctp_sk(sk)->ep, val.sauth_chunk); }
static int sctp_setsockopt_auth_chunk(struct sock *sk, char __user *optval, int optlen) { struct sctp_authchunk val; if (optlen != sizeof(struct sctp_authchunk)) return -EINVAL; if (copy_from_user(&val, optval, optlen)) return -EFAULT; switch (val.sauth_chunk) { case SCTP_CID_INIT: case SCTP_CID_INIT_ACK: case SCTP_CID_SHUTDOWN_COMPLETE: case SCTP_CID_AUTH: return -EINVAL; } return sctp_auth_ep_add_chunkid(sctp_sk(sk)->ep, val.sauth_chunk); }
530
1
static void idr(H264Context *h){ int i; ff_h264_remove_all_refs(h); h->prev_frame_num= 0; h->prev_frame_num_offset= 0; h->prev_poc_msb= h->prev_poc_lsb= 0; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) h->last_pocs[i] = INT_MIN; }
static void idr(H264Context *h){ int i; ff_h264_remove_all_refs(h); h->prev_frame_num= 0; h->prev_frame_num_offset= 0; h->prev_poc_msb= h->prev_poc_lsb= 0; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) h->last_pocs[i] = INT_MIN; }
531
1
iakerb_alloc_context(iakerb_ctx_id_t *pctx) { iakerb_ctx_id_t ctx; krb5_error_code code; *pctx = NULL; ctx = k5alloc(sizeof(*ctx), &code); if (ctx == NULL) goto cleanup; ctx->defcred = GSS_C_NO_CREDENTIAL; ctx->magic = KG_IAKERB_CONTEXT; ctx->state = IAKERB_AS_REQ; ctx->count = 0; code = krb5_gss_init_context(&ctx->k5c); if (code != 0) goto cleanup; *pctx = ctx; cleanup: if (code != 0) iakerb_release_context(ctx); return code; }
iakerb_alloc_context(iakerb_ctx_id_t *pctx) { iakerb_ctx_id_t ctx; krb5_error_code code; *pctx = NULL; ctx = k5alloc(sizeof(*ctx), &code); if (ctx == NULL) goto cleanup; ctx->defcred = GSS_C_NO_CREDENTIAL; ctx->magic = KG_IAKERB_CONTEXT; ctx->state = IAKERB_AS_REQ; ctx->count = 0; code = krb5_gss_init_context(&ctx->k5c); if (code != 0) goto cleanup; *pctx = ctx; cleanup: if (code != 0) iakerb_release_context(ctx); return code; }
532
1
void CClient::ReadLine(const CString& sData) { CLanguageScope user_lang(GetUser() ? GetUser()->GetLanguage() : ""); CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << GetFullName() << ") CLI -> ZNC [" << CDebug::Filter(sLine) << "]"); bool bReturn = false; if (IsAttached()) { NETWORKMODULECALL(OnUserRaw(sLine), m_pUser, m_pNetwork, this, &bReturn); } else { GLOBALMODULECALL(OnUnknownUserRaw(this, sLine), &bReturn); } if (bReturn) return; CMessage Message(sLine); Message.SetClient(this); if (IsAttached()) { NETWORKMODULECALL(OnUserRawMessage(Message), m_pUser, m_pNetwork, this, &bReturn); } else { GLOBALMODULECALL(OnUnknownUserRawMessage(Message), &bReturn); } if (bReturn) return; CString sCommand = Message.GetCommand(); if (!IsAttached()) { // The following commands happen before authentication with ZNC if (sCommand.Equals("PASS")) { m_bGotPass = true; CString sAuthLine = Message.GetParam(0); ParsePass(sAuthLine); AuthUser(); // Don't forward this msg. ZNC has already registered us. return; } else if (sCommand.Equals("NICK")) { CString sNick = Message.GetParam(0); m_sNick = sNick; m_bGotNick = true; AuthUser(); // Don't forward this msg. ZNC will handle nick changes until auth // is complete return; } else if (sCommand.Equals("USER")) { CString sAuthLine = Message.GetParam(0); if (m_sUser.empty() && !sAuthLine.empty()) { ParseUser(sAuthLine); } m_bGotUser = true; if (m_bGotPass) { AuthUser(); } else if (!m_bInCap) { SendRequiredPasswordNotice(); } // Don't forward this msg. ZNC has already registered us. return; } } if (Message.GetType() == CMessage::Type::Capability) { HandleCap(Message); // Don't let the client talk to the server directly about CAP, // we don't want anything enabled that ZNC does not support. return; } if (!m_pUser) { // Only CAP, NICK, USER and PASS are allowed before login return; } switch (Message.GetType()) { case CMessage::Type::Action: bReturn = OnActionMessage(Message); break; case CMessage::Type::CTCP: bReturn = OnCTCPMessage(Message); break; case CMessage::Type::Join: bReturn = OnJoinMessage(Message); break; case CMessage::Type::Mode: bReturn = OnModeMessage(Message); break; case CMessage::Type::Notice: bReturn = OnNoticeMessage(Message); break; case CMessage::Type::Part: bReturn = OnPartMessage(Message); break; case CMessage::Type::Ping: bReturn = OnPingMessage(Message); break; case CMessage::Type::Pong: bReturn = OnPongMessage(Message); break; case CMessage::Type::Quit: bReturn = OnQuitMessage(Message); break; case CMessage::Type::Text: bReturn = OnTextMessage(Message); break; case CMessage::Type::Topic: bReturn = OnTopicMessage(Message); break; default: bReturn = OnOtherMessage(Message); break; } if (bReturn) return; PutIRC(Message.ToString(CMessage::ExcludePrefix | CMessage::ExcludeTags)); }
void CClient::ReadLine(const CString& sData) { CLanguageScope user_lang(GetUser() ? GetUser()->GetLanguage() : ""); CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << GetFullName() << ") CLI -> ZNC [" << CDebug::Filter(sLine) << "]"); bool bReturn = false; if (IsAttached()) { NETWORKMODULECALL(OnUserRaw(sLine), m_pUser, m_pNetwork, this, &bReturn); } else { GLOBALMODULECALL(OnUnknownUserRaw(this, sLine), &bReturn); } if (bReturn) return; CMessage Message(sLine); Message.SetClient(this); if (IsAttached()) { NETWORKMODULECALL(OnUserRawMessage(Message), m_pUser, m_pNetwork, this, &bReturn); } else { GLOBALMODULECALL(OnUnknownUserRawMessage(Message), &bReturn); } if (bReturn) return; CString sCommand = Message.GetCommand(); if (!IsAttached()) { if (sCommand.Equals("PASS")) { m_bGotPass = true; CString sAuthLine = Message.GetParam(0); ParsePass(sAuthLine); AuthUser(); return; } else if (sCommand.Equals("NICK")) { CString sNick = Message.GetParam(0); m_sNick = sNick; m_bGotNick = true; AuthUser(); return; } else if (sCommand.Equals("USER")) { CString sAuthLine = Message.GetParam(0); if (m_sUser.empty() && !sAuthLine.empty()) { ParseUser(sAuthLine); } m_bGotUser = true; if (m_bGotPass) { AuthUser(); } else if (!m_bInCap) { SendRequiredPasswordNotice(); } return; } } if (Message.GetType() == CMessage::Type::Capability) { HandleCap(Message); return; } if (!m_pUser) { return; } switch (Message.GetType()) { case CMessage::Type::Action: bReturn = OnActionMessage(Message); break; case CMessage::Type::CTCP: bReturn = OnCTCPMessage(Message); break; case CMessage::Type::Join: bReturn = OnJoinMessage(Message); break; case CMessage::Type::Mode: bReturn = OnModeMessage(Message); break; case CMessage::Type::Notice: bReturn = OnNoticeMessage(Message); break; case CMessage::Type::Part: bReturn = OnPartMessage(Message); break; case CMessage::Type::Ping: bReturn = OnPingMessage(Message); break; case CMessage::Type::Pong: bReturn = OnPongMessage(Message); break; case CMessage::Type::Quit: bReturn = OnQuitMessage(Message); break; case CMessage::Type::Text: bReturn = OnTextMessage(Message); break; case CMessage::Type::Topic: bReturn = OnTopicMessage(Message); break; default: bReturn = OnOtherMessage(Message); break; } if (bReturn) return; PutIRC(Message.ToString(CMessage::ExcludePrefix | CMessage::ExcludeTags)); }
533
0
static void U_CALLCONV UConverter_fromUnicode_HZ_OFFSETS_LOGIC ( UConverterFromUnicodeArgs * args , UErrorCode * err ) { const UChar * mySource = args -> source ; char * myTarget = args -> target ; int32_t * offsets = args -> offsets ; int32_t mySourceIndex = 0 ; int32_t myTargetIndex = 0 ; int32_t targetLength = ( int32_t ) ( args -> targetLimit - myTarget ) ; int32_t mySourceLength = ( int32_t ) ( args -> sourceLimit - args -> source ) ; uint32_t targetUniChar = 0x0000 ; UChar32 mySourceChar = 0x0000 ; UConverterDataHZ * myConverterData = ( UConverterDataHZ * ) args -> converter -> extraInfo ; UBool isTargetUCharDBCS = ( UBool ) myConverterData -> isTargetUCharDBCS ; UBool oldIsTargetUCharDBCS ; int len = 0 ; const char * escSeq = NULL ; if ( args -> converter -> fromUChar32 != 0 && myTargetIndex < targetLength ) { goto getTrail ; } while ( mySourceIndex < mySourceLength ) { targetUniChar = missingCharMarker ; if ( myTargetIndex < targetLength ) { mySourceChar = ( UChar ) mySource [ mySourceIndex ++ ] ; oldIsTargetUCharDBCS = isTargetUCharDBCS ; if ( mySourceChar == UCNV_TILDE ) { len = ESC_LEN ; escSeq = TILDE_ESCAPE ; CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ; continue ; } else if ( mySourceChar <= 0x7f ) { targetUniChar = mySourceChar ; } else { int32_t length = ucnv_MBCSFromUChar32 ( myConverterData -> gbConverter -> sharedData , mySourceChar , & targetUniChar , args -> converter -> useFallback ) ; if ( length == 2 && ( uint16_t ) ( targetUniChar - 0xa1a1 ) <= ( 0xfdfe - 0xa1a1 ) && ( uint8_t ) ( targetUniChar - 0xa1 ) <= ( 0xfe - 0xa1 ) ) { targetUniChar -= 0x8080 ; } else { targetUniChar = missingCharMarker ; } } if ( targetUniChar != missingCharMarker ) { myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS = ( UBool ) ( targetUniChar > 0x00FF ) ; if ( oldIsTargetUCharDBCS != isTargetUCharDBCS || ! myConverterData -> isEscapeAppended ) { if ( ! isTargetUCharDBCS ) { len = ESC_LEN ; escSeq = SB_ESCAPE ; CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ; myConverterData -> isEscapeAppended = TRUE ; } else { len = ESC_LEN ; escSeq = DB_ESCAPE ; CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ; myConverterData -> isEscapeAppended = TRUE ; } } if ( isTargetUCharDBCS ) { if ( myTargetIndex < targetLength ) { myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar >> 8 ) ; if ( offsets ) { * ( offsets ++ ) = mySourceIndex - 1 ; } if ( myTargetIndex < targetLength ) { myTarget [ myTargetIndex ++ ] = ( char ) targetUniChar ; if ( offsets ) { * ( offsets ++ ) = mySourceIndex - 1 ; } } else { args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ; * err = U_BUFFER_OVERFLOW_ERROR ; } } else { args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) ( targetUniChar >> 8 ) ; args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ; * err = U_BUFFER_OVERFLOW_ERROR ; } } else { if ( myTargetIndex < targetLength ) { myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar ) ; if ( offsets ) { * ( offsets ++ ) = mySourceIndex - 1 ; } } else { args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ; * err = U_BUFFER_OVERFLOW_ERROR ; } } } else { if ( U16_IS_SURROGATE ( mySourceChar ) ) { if ( U16_IS_SURROGATE_LEAD ( mySourceChar ) ) { args -> converter -> fromUChar32 = mySourceChar ; getTrail : if ( mySourceIndex < mySourceLength ) { UChar trail = ( UChar ) args -> source [ mySourceIndex ] ; if ( U16_IS_TRAIL ( trail ) ) { ++ mySourceIndex ; mySourceChar = U16_GET_SUPPLEMENTARY ( args -> converter -> fromUChar32 , trail ) ; args -> converter -> fromUChar32 = 0x00 ; * err = U_INVALID_CHAR_FOUND ; } else { * err = U_ILLEGAL_CHAR_FOUND ; } } else { * err = U_ZERO_ERROR ; } } else { * err = U_ILLEGAL_CHAR_FOUND ; } } else { * err = U_INVALID_CHAR_FOUND ; } args -> converter -> fromUChar32 = mySourceChar ; break ; } } else { * err = U_BUFFER_OVERFLOW_ERROR ; break ; } targetUniChar = missingCharMarker ; } args -> target += myTargetIndex ; args -> source += mySourceIndex ; myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS ; }
static void U_CALLCONV UConverter_fromUnicode_HZ_OFFSETS_LOGIC ( UConverterFromUnicodeArgs * args , UErrorCode * err ) { const UChar * mySource = args -> source ; char * myTarget = args -> target ; int32_t * offsets = args -> offsets ; int32_t mySourceIndex = 0 ; int32_t myTargetIndex = 0 ; int32_t targetLength = ( int32_t ) ( args -> targetLimit - myTarget ) ; int32_t mySourceLength = ( int32_t ) ( args -> sourceLimit - args -> source ) ; uint32_t targetUniChar = 0x0000 ; UChar32 mySourceChar = 0x0000 ; UConverterDataHZ * myConverterData = ( UConverterDataHZ * ) args -> converter -> extraInfo ; UBool isTargetUCharDBCS = ( UBool ) myConverterData -> isTargetUCharDBCS ; UBool oldIsTargetUCharDBCS ; int len = 0 ; const char * escSeq = NULL ; if ( args -> converter -> fromUChar32 != 0 && myTargetIndex < targetLength ) { goto getTrail ; } while ( mySourceIndex < mySourceLength ) { targetUniChar = missingCharMarker ; if ( myTargetIndex < targetLength ) { mySourceChar = ( UChar ) mySource [ mySourceIndex ++ ] ; oldIsTargetUCharDBCS = isTargetUCharDBCS ; if ( mySourceChar == UCNV_TILDE ) { len = ESC_LEN ; escSeq = TILDE_ESCAPE ; CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ; continue ; } else if ( mySourceChar <= 0x7f ) { targetUniChar = mySourceChar ; } else { int32_t length = ucnv_MBCSFromUChar32 ( myConverterData -> gbConverter -> sharedData , mySourceChar , & targetUniChar , args -> converter -> useFallback ) ; if ( length == 2 && ( uint16_t ) ( targetUniChar - 0xa1a1 ) <= ( 0xfdfe - 0xa1a1 ) && ( uint8_t ) ( targetUniChar - 0xa1 ) <= ( 0xfe - 0xa1 ) ) { targetUniChar -= 0x8080 ; } else { targetUniChar = missingCharMarker ; } } if ( targetUniChar != missingCharMarker ) { myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS = ( UBool ) ( targetUniChar > 0x00FF ) ; if ( oldIsTargetUCharDBCS != isTargetUCharDBCS || ! myConverterData -> isEscapeAppended ) { if ( ! isTargetUCharDBCS ) { len = ESC_LEN ; escSeq = SB_ESCAPE ; CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ; myConverterData -> isEscapeAppended = TRUE ; } else { len = ESC_LEN ; escSeq = DB_ESCAPE ; CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ; myConverterData -> isEscapeAppended = TRUE ; } } if ( isTargetUCharDBCS ) { if ( myTargetIndex < targetLength ) { myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar >> 8 ) ; if ( offsets ) { * ( offsets ++ ) = mySourceIndex - 1 ; } if ( myTargetIndex < targetLength ) { myTarget [ myTargetIndex ++ ] = ( char ) targetUniChar ; if ( offsets ) { * ( offsets ++ ) = mySourceIndex - 1 ; } } else { args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ; * err = U_BUFFER_OVERFLOW_ERROR ; } } else { args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) ( targetUniChar >> 8 ) ; args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ; * err = U_BUFFER_OVERFLOW_ERROR ; } } else { if ( myTargetIndex < targetLength ) { myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar ) ; if ( offsets ) { * ( offsets ++ ) = mySourceIndex - 1 ; } } else { args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ; * err = U_BUFFER_OVERFLOW_ERROR ; } } } else { if ( U16_IS_SURROGATE ( mySourceChar ) ) { if ( U16_IS_SURROGATE_LEAD ( mySourceChar ) ) { args -> converter -> fromUChar32 = mySourceChar ; getTrail : if ( mySourceIndex < mySourceLength ) { UChar trail = ( UChar ) args -> source [ mySourceIndex ] ; if ( U16_IS_TRAIL ( trail ) ) { ++ mySourceIndex ; mySourceChar = U16_GET_SUPPLEMENTARY ( args -> converter -> fromUChar32 , trail ) ; args -> converter -> fromUChar32 = 0x00 ; * err = U_INVALID_CHAR_FOUND ; } else { * err = U_ILLEGAL_CHAR_FOUND ; } } else { * err = U_ZERO_ERROR ; } } else { * err = U_ILLEGAL_CHAR_FOUND ; } } else { * err = U_INVALID_CHAR_FOUND ; } args -> converter -> fromUChar32 = mySourceChar ; break ; } } else { * err = U_BUFFER_OVERFLOW_ERROR ; break ; } targetUniChar = missingCharMarker ; } args -> target += myTargetIndex ; args -> source += mySourceIndex ; myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS ; }
534
1
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
535
1
static void cg3_initfn(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); CG3State *s = CG3(obj); memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE, &error_abort); memory_region_set_readonly(&s->rom, true); sysbus_init_mmio(sbd, &s->rom); memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg", CG3_REG_SIZE); sysbus_init_mmio(sbd, &s->reg); }
static void cg3_initfn(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); CG3State *s = CG3(obj); memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE, &error_abort); memory_region_set_readonly(&s->rom, true); sysbus_init_mmio(sbd, &s->rom); memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg", CG3_REG_SIZE); sysbus_init_mmio(sbd, &s->reg); }
536
0
static int reassociate ( struct evport_data * epdp , struct fd_info * fdip , int fd ) { int sysevents = FDI_TO_SYSEVENTS ( fdip ) ; if ( sysevents != 0 ) { if ( port_associate ( epdp -> ed_port , PORT_SOURCE_FD , fd , sysevents , NULL ) == - 1 ) { event_warn ( "port_associate" ) ; return ( - 1 ) ; } } check_evportop ( epdp ) ; return ( 0 ) ; }
static int reassociate ( struct evport_data * epdp , struct fd_info * fdip , int fd ) { int sysevents = FDI_TO_SYSEVENTS ( fdip ) ; if ( sysevents != 0 ) { if ( port_associate ( epdp -> ed_port , PORT_SOURCE_FD , fd , sysevents , NULL ) == - 1 ) { event_warn ( "port_associate" ) ; return ( - 1 ) ; } } check_evportop ( epdp ) ; return ( 0 ) ; }
537
1
static int sctp_setsockopt_del_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkeyid val; struct sctp_association *asoc; if (optlen != sizeof(struct sctp_authkeyid)) return -EINVAL; if (copy_from_user(&val, optval, optlen)) return -EFAULT; asoc = sctp_id2assoc(sk, val.scact_assoc_id); if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) return -EINVAL; return sctp_auth_del_key_id(sctp_sk(sk)->ep, asoc, val.scact_keynumber); }
static int sctp_setsockopt_del_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkeyid val; struct sctp_association *asoc; if (optlen != sizeof(struct sctp_authkeyid)) return -EINVAL; if (copy_from_user(&val, optval, optlen)) return -EFAULT; asoc = sctp_id2assoc(sk, val.scact_assoc_id); if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) return -EINVAL; return sctp_auth_del_key_id(sctp_sk(sk)->ep, asoc, val.scact_keynumber); }
538
1
iakerb_gss_accept_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_cred_id_t verifier_cred_handle, gss_buffer_t input_token, gss_channel_bindings_t input_chan_bindings, gss_name_t *src_name, gss_OID *mech_type, gss_buffer_t output_token, OM_uint32 *ret_flags, OM_uint32 *time_rec, gss_cred_id_t *delegated_cred_handle) { OM_uint32 major_status = GSS_S_FAILURE; OM_uint32 code; iakerb_ctx_id_t ctx; int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT); if (initialContextToken) { code = iakerb_alloc_context(&ctx); if (code != 0) goto cleanup; } else ctx = (iakerb_ctx_id_t)*context_handle; if (iakerb_is_iakerb_token(input_token)) { if (ctx->gssc != GSS_C_NO_CONTEXT) { /* We shouldn't get an IAKERB token now. */ code = G_WRONG_TOKID; major_status = GSS_S_DEFECTIVE_TOKEN; goto cleanup; } code = iakerb_acceptor_step(ctx, initialContextToken, input_token, output_token); if (code == (OM_uint32)KRB5_BAD_MSIZE) major_status = GSS_S_DEFECTIVE_TOKEN; if (code != 0) goto cleanup; if (initialContextToken) { *context_handle = (gss_ctx_id_t)ctx; ctx = NULL; } if (src_name != NULL) *src_name = GSS_C_NO_NAME; if (mech_type != NULL) *mech_type = (gss_OID)gss_mech_iakerb; if (ret_flags != NULL) *ret_flags = 0; if (time_rec != NULL) *time_rec = 0; if (delegated_cred_handle != NULL) *delegated_cred_handle = GSS_C_NO_CREDENTIAL; major_status = GSS_S_CONTINUE_NEEDED; } else { krb5_gss_ctx_ext_rec exts; iakerb_make_exts(ctx, &exts); major_status = krb5_gss_accept_sec_context_ext(&code, &ctx->gssc, verifier_cred_handle, input_token, input_chan_bindings, src_name, NULL, output_token, ret_flags, time_rec, delegated_cred_handle, &exts); if (major_status == GSS_S_COMPLETE) { *context_handle = ctx->gssc; ctx->gssc = NULL; iakerb_release_context(ctx); } if (mech_type != NULL) *mech_type = (gss_OID)gss_mech_krb5; } cleanup: if (initialContextToken && GSS_ERROR(major_status)) { iakerb_release_context(ctx); *context_handle = GSS_C_NO_CONTEXT; } *minor_status = code; return major_status; }
iakerb_gss_accept_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_cred_id_t verifier_cred_handle, gss_buffer_t input_token, gss_channel_bindings_t input_chan_bindings, gss_name_t *src_name, gss_OID *mech_type, gss_buffer_t output_token, OM_uint32 *ret_flags, OM_uint32 *time_rec, gss_cred_id_t *delegated_cred_handle) { OM_uint32 major_status = GSS_S_FAILURE; OM_uint32 code; iakerb_ctx_id_t ctx; int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT); if (initialContextToken) { code = iakerb_alloc_context(&ctx); if (code != 0) goto cleanup; } else ctx = (iakerb_ctx_id_t)*context_handle; if (iakerb_is_iakerb_token(input_token)) { if (ctx->gssc != GSS_C_NO_CONTEXT) { code = G_WRONG_TOKID; major_status = GSS_S_DEFECTIVE_TOKEN; goto cleanup; } code = iakerb_acceptor_step(ctx, initialContextToken, input_token, output_token); if (code == (OM_uint32)KRB5_BAD_MSIZE) major_status = GSS_S_DEFECTIVE_TOKEN; if (code != 0) goto cleanup; if (initialContextToken) { *context_handle = (gss_ctx_id_t)ctx; ctx = NULL; } if (src_name != NULL) *src_name = GSS_C_NO_NAME; if (mech_type != NULL) *mech_type = (gss_OID)gss_mech_iakerb; if (ret_flags != NULL) *ret_flags = 0; if (time_rec != NULL) *time_rec = 0; if (delegated_cred_handle != NULL) *delegated_cred_handle = GSS_C_NO_CREDENTIAL; major_status = GSS_S_CONTINUE_NEEDED; } else { krb5_gss_ctx_ext_rec exts; iakerb_make_exts(ctx, &exts); major_status = krb5_gss_accept_sec_context_ext(&code, &ctx->gssc, verifier_cred_handle, input_token, input_chan_bindings, src_name, NULL, output_token, ret_flags, time_rec, delegated_cred_handle, &exts); if (major_status == GSS_S_COMPLETE) { *context_handle = ctx->gssc; ctx->gssc = NULL; iakerb_release_context(ctx); } if (mech_type != NULL) *mech_type = (gss_OID)gss_mech_krb5; } cleanup: if (initialContextToken && GSS_ERROR(major_status)) { iakerb_release_context(ctx); *context_handle = GSS_C_NO_CONTEXT; } *minor_status = code; return major_status; }
539
1
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) { int id, sr, ch, ba, tag, bps; id = avctx->codec_id; sr = avctx->sample_rate; ch = avctx->channels; ba = avctx->block_align; tag = avctx->codec_tag; bps = av_get_exact_bits_per_sample(avctx->codec_id); /* codecs with an exact constant bits per sample */ if (bps > 0 && ch > 0 && frame_bytes > 0) return (frame_bytes * 8) / (bps * ch); bps = avctx->bits_per_coded_sample; /* codecs with a fixed packet duration */ switch (id) { case CODEC_ID_ADPCM_ADX: return 32; case CODEC_ID_ADPCM_IMA_QT: return 64; case CODEC_ID_ADPCM_EA_XAS: return 128; case CODEC_ID_AMR_NB: case CODEC_ID_GSM: case CODEC_ID_QCELP: case CODEC_ID_RA_144: case CODEC_ID_RA_288: return 160; case CODEC_ID_IMC: return 256; case CODEC_ID_AMR_WB: case CODEC_ID_GSM_MS: return 320; case CODEC_ID_MP1: return 384; case CODEC_ID_ATRAC1: return 512; case CODEC_ID_ATRAC3: return 1024; case CODEC_ID_MP2: case CODEC_ID_MUSEPACK7: return 1152; case CODEC_ID_AC3: return 1536; } if (sr > 0) { /* calc from sample rate */ if (id == CODEC_ID_TTA) return 256 * sr / 245; if (ch > 0) { /* calc from sample rate and channels */ if (id == CODEC_ID_BINKAUDIO_DCT) return (480 << (sr / 22050)) / ch; } } if (ba > 0) { /* calc from block_align */ if (id == CODEC_ID_SIPR) { switch (ba) { case 20: return 160; case 19: return 144; case 29: return 288; case 37: return 480; } } } if (frame_bytes > 0) { /* calc from frame_bytes only */ if (id == CODEC_ID_TRUESPEECH) return 240 * (frame_bytes / 32); if (id == CODEC_ID_NELLYMOSER) return 256 * (frame_bytes / 64); if (bps > 0) { /* calc from frame_bytes and bits_per_coded_sample */ if (id == CODEC_ID_ADPCM_G726) return frame_bytes * 8 / bps; } if (ch > 0) { /* calc from frame_bytes and channels */ switch (id) { case CODEC_ID_ADPCM_4XM: case CODEC_ID_ADPCM_IMA_ISS: return (frame_bytes - 4 * ch) * 2 / ch; case CODEC_ID_ADPCM_IMA_SMJPEG: return (frame_bytes - 4) * 2 / ch; case CODEC_ID_ADPCM_IMA_AMV: return (frame_bytes - 8) * 2 / ch; case CODEC_ID_ADPCM_XA: return (frame_bytes / 128) * 224 / ch; case CODEC_ID_INTERPLAY_DPCM: return (frame_bytes - 6 - ch) / ch; case CODEC_ID_ROQ_DPCM: return (frame_bytes - 8) / ch; case CODEC_ID_XAN_DPCM: return (frame_bytes - 2 * ch) / ch; case CODEC_ID_MACE3: return 3 * frame_bytes / ch; case CODEC_ID_MACE6: return 6 * frame_bytes / ch; case CODEC_ID_PCM_LXF: return 2 * (frame_bytes / (5 * ch)); } if (tag) { /* calc from frame_bytes, channels, and codec_tag */ if (id == CODEC_ID_SOL_DPCM) { if (tag == 3) return frame_bytes / ch; else return frame_bytes * 2 / ch; } } if (ba > 0) { /* calc from frame_bytes, channels, and block_align */ int blocks = frame_bytes / ba; switch (avctx->codec_id) { case CODEC_ID_ADPCM_IMA_WAV: return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8); case CODEC_ID_ADPCM_IMA_DK3: return blocks * (((ba - 16) * 2 / 3 * 4) / ch); case CODEC_ID_ADPCM_IMA_DK4: return blocks * (1 + (ba - 4 * ch) * 2 / ch); case CODEC_ID_ADPCM_MS: return blocks * (2 + (ba - 7 * ch) * 2 / ch); } } if (bps > 0) { /* calc from frame_bytes, channels, and bits_per_coded_sample */ switch (avctx->codec_id) { case CODEC_ID_PCM_DVD: return 2 * (frame_bytes / ((bps * 2 / 8) * ch)); case CODEC_ID_PCM_BLURAY: return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8); case CODEC_ID_S302M: return 2 * (frame_bytes / ((bps + 4) / 4)) / ch; } } } } return 0; }
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) { int id, sr, ch, ba, tag, bps; id = avctx->codec_id; sr = avctx->sample_rate; ch = avctx->channels; ba = avctx->block_align; tag = avctx->codec_tag; bps = av_get_exact_bits_per_sample(avctx->codec_id); if (bps > 0 && ch > 0 && frame_bytes > 0) return (frame_bytes * 8) / (bps * ch); bps = avctx->bits_per_coded_sample; switch (id) { case CODEC_ID_ADPCM_ADX: return 32; case CODEC_ID_ADPCM_IMA_QT: return 64; case CODEC_ID_ADPCM_EA_XAS: return 128; case CODEC_ID_AMR_NB: case CODEC_ID_GSM: case CODEC_ID_QCELP: case CODEC_ID_RA_144: case CODEC_ID_RA_288: return 160; case CODEC_ID_IMC: return 256; case CODEC_ID_AMR_WB: case CODEC_ID_GSM_MS: return 320; case CODEC_ID_MP1: return 384; case CODEC_ID_ATRAC1: return 512; case CODEC_ID_ATRAC3: return 1024; case CODEC_ID_MP2: case CODEC_ID_MUSEPACK7: return 1152; case CODEC_ID_AC3: return 1536; } if (sr > 0) { if (id == CODEC_ID_TTA) return 256 * sr / 245; if (ch > 0) { if (id == CODEC_ID_BINKAUDIO_DCT) return (480 << (sr / 22050)) / ch; } } if (ba > 0) { if (id == CODEC_ID_SIPR) { switch (ba) { case 20: return 160; case 19: return 144; case 29: return 288; case 37: return 480; } } } if (frame_bytes > 0) { if (id == CODEC_ID_TRUESPEECH) return 240 * (frame_bytes / 32); if (id == CODEC_ID_NELLYMOSER) return 256 * (frame_bytes / 64); if (bps > 0) { if (id == CODEC_ID_ADPCM_G726) return frame_bytes * 8 / bps; } if (ch > 0) { switch (id) { case CODEC_ID_ADPCM_4XM: case CODEC_ID_ADPCM_IMA_ISS: return (frame_bytes - 4 * ch) * 2 / ch; case CODEC_ID_ADPCM_IMA_SMJPEG: return (frame_bytes - 4) * 2 / ch; case CODEC_ID_ADPCM_IMA_AMV: return (frame_bytes - 8) * 2 / ch; case CODEC_ID_ADPCM_XA: return (frame_bytes / 128) * 224 / ch; case CODEC_ID_INTERPLAY_DPCM: return (frame_bytes - 6 - ch) / ch; case CODEC_ID_ROQ_DPCM: return (frame_bytes - 8) / ch; case CODEC_ID_XAN_DPCM: return (frame_bytes - 2 * ch) / ch; case CODEC_ID_MACE3: return 3 * frame_bytes / ch; case CODEC_ID_MACE6: return 6 * frame_bytes / ch; case CODEC_ID_PCM_LXF: return 2 * (frame_bytes / (5 * ch)); } if (tag) { if (id == CODEC_ID_SOL_DPCM) { if (tag == 3) return frame_bytes / ch; else return frame_bytes * 2 / ch; } } if (ba > 0) { int blocks = frame_bytes / ba; switch (avctx->codec_id) { case CODEC_ID_ADPCM_IMA_WAV: return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8); case CODEC_ID_ADPCM_IMA_DK3: return blocks * (((ba - 16) * 2 / 3 * 4) / ch); case CODEC_ID_ADPCM_IMA_DK4: return blocks * (1 + (ba - 4 * ch) * 2 / ch); case CODEC_ID_ADPCM_MS: return blocks * (2 + (ba - 7 * ch) * 2 / ch); } } if (bps > 0) { switch (avctx->codec_id) { case CODEC_ID_PCM_DVD: return 2 * (frame_bytes / ((bps * 2 / 8) * ch)); case CODEC_ID_PCM_BLURAY: return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8); case CODEC_ID_S302M: return 2 * (frame_bytes / ((bps + 4) / 4)) / ch; } } } } return 0; }
540
1
static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, char __user *optval, int __user *optlen) { struct sctp_authchunks __user *p = (void __user *)optval; struct sctp_authchunks val; struct sctp_association *asoc; struct sctp_chunks_param *ch; u32 num_chunks; char __user *to; if (len <= sizeof(struct sctp_authchunks)) return -EINVAL; if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) return -EFAULT; to = p->gauth_chunks; asoc = sctp_id2assoc(sk, val.gauth_assoc_id); if (!asoc && val.gauth_assoc_id && sctp_style(sk, UDP)) return -EINVAL; if (asoc) ch = (struct sctp_chunks_param*)asoc->c.auth_chunks; else ch = sctp_sk(sk)->ep->auth_chunk_list; num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); if (len < num_chunks) return -EINVAL; len = num_chunks; if (put_user(len, optlen)) return -EFAULT; if (put_user(num_chunks, &p->gauth_number_of_chunks)) return -EFAULT; if (copy_to_user(to, ch->chunks, len)) return -EFAULT; return 0; }
static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, char __user *optval, int __user *optlen) { struct sctp_authchunks __user *p = (void __user *)optval; struct sctp_authchunks val; struct sctp_association *asoc; struct sctp_chunks_param *ch; u32 num_chunks; char __user *to; if (len <= sizeof(struct sctp_authchunks)) return -EINVAL; if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) return -EFAULT; to = p->gauth_chunks; asoc = sctp_id2assoc(sk, val.gauth_assoc_id); if (!asoc && val.gauth_assoc_id && sctp_style(sk, UDP)) return -EINVAL; if (asoc) ch = (struct sctp_chunks_param*)asoc->c.auth_chunks; else ch = sctp_sk(sk)->ep->auth_chunk_list; num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); if (len < num_chunks) return -EINVAL; len = num_chunks; if (put_user(len, optlen)) return -EFAULT; if (put_user(num_chunks, &p->gauth_number_of_chunks)) return -EFAULT; if (copy_to_user(to, ch->chunks, len)) return -EFAULT; return 0; }
541
1
void CIRCSock::ReadLine(const CString& sData) { CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]"); bool bReturn = false; IRCSOCKMODULECALL(OnRaw(sLine), &bReturn); if (bReturn) return; CMessage Message(sLine); Message.SetNetwork(m_pNetwork); IRCSOCKMODULECALL(OnRawMessage(Message), &bReturn); if (bReturn) return; switch (Message.GetType()) { case CMessage::Type::Account: bReturn = OnAccountMessage(Message); break; case CMessage::Type::Action: bReturn = OnActionMessage(Message); break; case CMessage::Type::Away: bReturn = OnAwayMessage(Message); break; case CMessage::Type::Capability: bReturn = OnCapabilityMessage(Message); break; case CMessage::Type::CTCP: bReturn = OnCTCPMessage(Message); break; case CMessage::Type::Error: bReturn = OnErrorMessage(Message); break; case CMessage::Type::Invite: bReturn = OnInviteMessage(Message); break; case CMessage::Type::Join: bReturn = OnJoinMessage(Message); break; case CMessage::Type::Kick: bReturn = OnKickMessage(Message); break; case CMessage::Type::Mode: bReturn = OnModeMessage(Message); break; case CMessage::Type::Nick: bReturn = OnNickMessage(Message); break; case CMessage::Type::Notice: bReturn = OnNoticeMessage(Message); break; case CMessage::Type::Numeric: bReturn = OnNumericMessage(Message); break; case CMessage::Type::Part: bReturn = OnPartMessage(Message); break; case CMessage::Type::Ping: bReturn = OnPingMessage(Message); break; case CMessage::Type::Pong: bReturn = OnPongMessage(Message); break; case CMessage::Type::Quit: bReturn = OnQuitMessage(Message); break; case CMessage::Type::Text: bReturn = OnTextMessage(Message); break; case CMessage::Type::Topic: bReturn = OnTopicMessage(Message); break; case CMessage::Type::Wallops: bReturn = OnWallopsMessage(Message); break; default: break; } if (bReturn) return; m_pNetwork->PutUser(Message); }
void CIRCSock::ReadLine(const CString& sData) { CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]"); bool bReturn = false; IRCSOCKMODULECALL(OnRaw(sLine), &bReturn); if (bReturn) return; CMessage Message(sLine); Message.SetNetwork(m_pNetwork); IRCSOCKMODULECALL(OnRawMessage(Message), &bReturn); if (bReturn) return; switch (Message.GetType()) { case CMessage::Type::Account: bReturn = OnAccountMessage(Message); break; case CMessage::Type::Action: bReturn = OnActionMessage(Message); break; case CMessage::Type::Away: bReturn = OnAwayMessage(Message); break; case CMessage::Type::Capability: bReturn = OnCapabilityMessage(Message); break; case CMessage::Type::CTCP: bReturn = OnCTCPMessage(Message); break; case CMessage::Type::Error: bReturn = OnErrorMessage(Message); break; case CMessage::Type::Invite: bReturn = OnInviteMessage(Message); break; case CMessage::Type::Join: bReturn = OnJoinMessage(Message); break; case CMessage::Type::Kick: bReturn = OnKickMessage(Message); break; case CMessage::Type::Mode: bReturn = OnModeMessage(Message); break; case CMessage::Type::Nick: bReturn = OnNickMessage(Message); break; case CMessage::Type::Notice: bReturn = OnNoticeMessage(Message); break; case CMessage::Type::Numeric: bReturn = OnNumericMessage(Message); break; case CMessage::Type::Part: bReturn = OnPartMessage(Message); break; case CMessage::Type::Ping: bReturn = OnPingMessage(Message); break; case CMessage::Type::Pong: bReturn = OnPongMessage(Message); break; case CMessage::Type::Quit: bReturn = OnQuitMessage(Message); break; case CMessage::Type::Text: bReturn = OnTextMessage(Message); break; case CMessage::Type::Topic: bReturn = OnTopicMessage(Message); break; case CMessage::Type::Wallops: bReturn = OnWallopsMessage(Message); break; default: break; } if (bReturn) return; m_pNetwork->PutUser(Message); }
542
0
static const char * default_iconv_charset ( const char * charset ) { if ( charset != NULL && charset [ 0 ] != '\0' ) return charset ; # if HAVE_LOCALE_CHARSET && ! defined ( __APPLE__ ) return locale_charset ( ) ; # elif HAVE_NL_LANGINFO return nl_langinfo ( CODESET ) ; # else return "" ; # endif }
static const char * default_iconv_charset ( const char * charset ) { if ( charset != NULL && charset [ 0 ] != '\0' ) return charset ; # if HAVE_LOCALE_CHARSET && ! defined ( __APPLE__ ) return locale_charset ( ) ; # elif HAVE_NL_LANGINFO return nl_langinfo ( CODESET ) ; # else return "" ; # endif }
543
1
CString CWebSock::GetSkinPath(const CString& sSkinName) { CString sRet = CZNC::Get().GetZNCPath() + "/webskins/" + sSkinName; if (!CFile::IsDir(sRet)) { sRet = CZNC::Get().GetCurPath() + "/webskins/" + sSkinName; if (!CFile::IsDir(sRet)) { sRet = CString(_SKINDIR_) + "/" + sSkinName; } } return sRet + "/"; }
CString CWebSock::GetSkinPath(const CString& sSkinName) { CString sRet = CZNC::Get().GetZNCPath() + "/webskins/" + sSkinName; if (!CFile::IsDir(sRet)) { sRet = CZNC::Get().GetCurPath() + "/webskins/" + sSkinName; if (!CFile::IsDir(sRet)) { sRet = CString(_SKINDIR_) + "/" + sSkinName; } } return sRet + "/"; }
544
1
static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, struct sock *sk, gfp_t gfp) { struct sctp_hmac_algo_param *auth_hmacs = NULL; struct sctp_chunks_param *auth_chunks = NULL; struct sctp_shared_key *null_key; int err; memset(ep, 0, sizeof(struct sctp_endpoint)); ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); if (!ep->digest) return NULL; if (sctp_auth_enable) { /* Allocate space for HMACS and CHUNKS authentication * variables. There are arrays that we encode directly * into parameters to make the rest of the operations easier. */ auth_hmacs = kzalloc(sizeof(sctp_hmac_algo_param_t) + sizeof(__u16) * SCTP_AUTH_NUM_HMACS, gfp); if (!auth_hmacs) goto nomem; auth_chunks = kzalloc(sizeof(sctp_chunks_param_t) + SCTP_NUM_CHUNK_TYPES, gfp); if (!auth_chunks) goto nomem; /* Initialize the HMACS parameter. * SCTP-AUTH: Section 3.3 * Every endpoint supporting SCTP chunk authentication MUST * support the HMAC based on the SHA-1 algorithm. */ auth_hmacs->param_hdr.type = SCTP_PARAM_HMAC_ALGO; auth_hmacs->param_hdr.length = htons(sizeof(sctp_paramhdr_t) + 2); auth_hmacs->hmac_ids[0] = htons(SCTP_AUTH_HMAC_ID_SHA1); /* Initialize the CHUNKS parameter */ auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS; /* If the Add-IP functionality is enabled, we must * authenticate, ASCONF and ASCONF-ACK chunks */ if (sctp_addip_enable) { auth_chunks->chunks[0] = SCTP_CID_ASCONF; auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; auth_chunks->param_hdr.length = htons(sizeof(sctp_paramhdr_t) + 2); } } /* Initialize the base structure. */ /* What type of endpoint are we? */ ep->base.type = SCTP_EP_TYPE_SOCKET; /* Initialize the basic object fields. */ atomic_set(&ep->base.refcnt, 1); ep->base.dead = 0; ep->base.malloced = 1; /* Create an input queue. */ sctp_inq_init(&ep->base.inqueue); /* Set its top-half handler */ sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv); /* Initialize the bind addr area */ sctp_bind_addr_init(&ep->base.bind_addr, 0); /* Remember who we are attached to. */ ep->base.sk = sk; sock_hold(ep->base.sk); /* Create the lists of associations. */ INIT_LIST_HEAD(&ep->asocs); /* Use SCTP specific send buffer space queues. */ ep->sndbuf_policy = sctp_sndbuf_policy; sk->sk_write_space = sctp_write_space; sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); /* Get the receive buffer policy for this endpoint */ ep->rcvbuf_policy = sctp_rcvbuf_policy; /* Initialize the secret key used with cookie. */ get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE); ep->last_key = ep->current_key = 0; ep->key_changed_at = jiffies; /* SCTP-AUTH extensions*/ INIT_LIST_HEAD(&ep->endpoint_shared_keys); null_key = sctp_auth_shkey_create(0, GFP_KERNEL); if (!null_key) goto nomem; list_add(&null_key->key_list, &ep->endpoint_shared_keys); /* Allocate and initialize transorms arrays for suported HMACs. */ err = sctp_auth_init_hmacs(ep, gfp); if (err) goto nomem_hmacs; /* Add the null key to the endpoint shared keys list and * set the hmcas and chunks pointers. */ ep->auth_hmacs_list = auth_hmacs; ep->auth_chunk_list = auth_chunks; return ep; nomem_hmacs: sctp_auth_destroy_keys(&ep->endpoint_shared_keys); nomem: /* Free all allocations */ kfree(auth_hmacs); kfree(auth_chunks); kfree(ep->digest); return NULL; }
static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, struct sock *sk, gfp_t gfp) { struct sctp_hmac_algo_param *auth_hmacs = NULL; struct sctp_chunks_param *auth_chunks = NULL; struct sctp_shared_key *null_key; int err; memset(ep, 0, sizeof(struct sctp_endpoint)); ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); if (!ep->digest) return NULL; if (sctp_auth_enable) { auth_hmacs = kzalloc(sizeof(sctp_hmac_algo_param_t) + sizeof(__u16) * SCTP_AUTH_NUM_HMACS, gfp); if (!auth_hmacs) goto nomem; auth_chunks = kzalloc(sizeof(sctp_chunks_param_t) + SCTP_NUM_CHUNK_TYPES, gfp); if (!auth_chunks) goto nomem; auth_hmacs->param_hdr.type = SCTP_PARAM_HMAC_ALGO; auth_hmacs->param_hdr.length = htons(sizeof(sctp_paramhdr_t) + 2); auth_hmacs->hmac_ids[0] = htons(SCTP_AUTH_HMAC_ID_SHA1); auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS; if (sctp_addip_enable) { auth_chunks->chunks[0] = SCTP_CID_ASCONF; auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; auth_chunks->param_hdr.length = htons(sizeof(sctp_paramhdr_t) + 2); } } ep->base.type = SCTP_EP_TYPE_SOCKET; atomic_set(&ep->base.refcnt, 1); ep->base.dead = 0; ep->base.malloced = 1; sctp_inq_init(&ep->base.inqueue); sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv); sctp_bind_addr_init(&ep->base.bind_addr, 0); ep->base.sk = sk; sock_hold(ep->base.sk); INIT_LIST_HEAD(&ep->asocs); ep->sndbuf_policy = sctp_sndbuf_policy; sk->sk_write_space = sctp_write_space; sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); ep->rcvbuf_policy = sctp_rcvbuf_policy; get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE); ep->last_key = ep->current_key = 0; ep->key_changed_at = jiffies; INIT_LIST_HEAD(&ep->endpoint_shared_keys); null_key = sctp_auth_shkey_create(0, GFP_KERNEL); if (!null_key) goto nomem; list_add(&null_key->key_list, &ep->endpoint_shared_keys); err = sctp_auth_init_hmacs(ep, gfp); if (err) goto nomem_hmacs; ep->auth_hmacs_list = auth_hmacs; ep->auth_chunk_list = auth_chunks; return ep; nomem_hmacs: sctp_auth_destroy_keys(&ep->endpoint_shared_keys); nomem: kfree(auth_hmacs); kfree(auth_chunks); kfree(ep->digest); return NULL; }
546
1
static int update_size(AVCodecContext *ctx, int w, int h) { VP9Context *s = ctx->priv_data; uint8_t *p; if (s->above_partition_ctx && w == ctx->width && h == ctx->height) return 0; ctx->width = w; ctx->height = h; s->sb_cols = (w + 63) >> 6; s->sb_rows = (h + 63) >> 6; s->cols = (w + 7) >> 3; s->rows = (h + 7) >> 3; #define assign(var, type, n) var = (type) p; p += s->sb_cols * n * sizeof(*var) av_free(s->above_partition_ctx); p = av_malloc(s->sb_cols * (240 + sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx) + 64 * s->sb_rows * (1 + sizeof(*s->mv[0]) * 2))); if (!p) return AVERROR(ENOMEM); assign(s->above_partition_ctx, uint8_t *, 8); assign(s->above_skip_ctx, uint8_t *, 8); assign(s->above_txfm_ctx, uint8_t *, 8); assign(s->above_mode_ctx, uint8_t *, 16); assign(s->above_y_nnz_ctx, uint8_t *, 16); assign(s->above_uv_nnz_ctx[0], uint8_t *, 8); assign(s->above_uv_nnz_ctx[1], uint8_t *, 8); assign(s->intra_pred_data[0], uint8_t *, 64); assign(s->intra_pred_data[1], uint8_t *, 32); assign(s->intra_pred_data[2], uint8_t *, 32); assign(s->above_segpred_ctx, uint8_t *, 8); assign(s->above_intra_ctx, uint8_t *, 8); assign(s->above_comp_ctx, uint8_t *, 8); assign(s->above_ref_ctx, uint8_t *, 8); assign(s->above_filter_ctx, uint8_t *, 8); assign(s->lflvl, struct VP9Filter *, 1); assign(s->above_mv_ctx, VP56mv(*)[2], 16); assign(s->segmentation_map, uint8_t *, 64 * s->sb_rows); assign(s->mv[0], struct VP9mvrefPair *, 64 * s->sb_rows); assign(s->mv[1], struct VP9mvrefPair *, 64 * s->sb_rows); #undef assign return 0; }
static int update_size(AVCodecContext *ctx, int w, int h) { VP9Context *s = ctx->priv_data; uint8_t *p; if (s->above_partition_ctx && w == ctx->width && h == ctx->height) return 0; ctx->width = w; ctx->height = h; s->sb_cols = (w + 63) >> 6; s->sb_rows = (h + 63) >> 6; s->cols = (w + 7) >> 3; s->rows = (h + 7) >> 3; #define assign(var, type, n) var = (type) p; p += s->sb_cols * n * sizeof(*var) av_free(s->above_partition_ctx); p = av_malloc(s->sb_cols * (240 + sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx) + 64 * s->sb_rows * (1 + sizeof(*s->mv[0]) * 2))); if (!p) return AVERROR(ENOMEM); assign(s->above_partition_ctx, uint8_t *, 8); assign(s->above_skip_ctx, uint8_t *, 8); assign(s->above_txfm_ctx, uint8_t *, 8); assign(s->above_mode_ctx, uint8_t *, 16); assign(s->above_y_nnz_ctx, uint8_t *, 16); assign(s->above_uv_nnz_ctx[0], uint8_t *, 8); assign(s->above_uv_nnz_ctx[1], uint8_t *, 8); assign(s->intra_pred_data[0], uint8_t *, 64); assign(s->intra_pred_data[1], uint8_t *, 32); assign(s->intra_pred_data[2], uint8_t *, 32); assign(s->above_segpred_ctx, uint8_t *, 8); assign(s->above_intra_ctx, uint8_t *, 8); assign(s->above_comp_ctx, uint8_t *, 8); assign(s->above_ref_ctx, uint8_t *, 8); assign(s->above_filter_ctx, uint8_t *, 8); assign(s->lflvl, struct VP9Filter *, 1); assign(s->above_mv_ctx, VP56mv(*)[2], 16); assign(s->segmentation_map, uint8_t *, 64 * s->sb_rows); assign(s->mv[0], struct VP9mvrefPair *, 64 * s->sb_rows); assign(s->mv[1], struct VP9mvrefPair *, 64 * s->sb_rows); #undef assign return 0; }
547
1
iakerb_gss_delete_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t output_token) { OM_uint32 major_status = GSS_S_COMPLETE; if (output_token != GSS_C_NO_BUFFER) { output_token->length = 0; output_token->value = NULL; } *minor_status = 0; if (*context_handle != GSS_C_NO_CONTEXT) { iakerb_ctx_id_t iakerb_ctx = (iakerb_ctx_id_t)*context_handle; if (iakerb_ctx->magic == KG_IAKERB_CONTEXT) { iakerb_release_context(iakerb_ctx); *context_handle = GSS_C_NO_CONTEXT; } else { assert(iakerb_ctx->magic == KG_CONTEXT); major_status = krb5_gss_delete_sec_context(minor_status, context_handle, output_token); } } return major_status; }
iakerb_gss_delete_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t output_token) { OM_uint32 major_status = GSS_S_COMPLETE; if (output_token != GSS_C_NO_BUFFER) { output_token->length = 0; output_token->value = NULL; } *minor_status = 0; if (*context_handle != GSS_C_NO_CONTEXT) { iakerb_ctx_id_t iakerb_ctx = (iakerb_ctx_id_t)*context_handle; if (iakerb_ctx->magic == KG_IAKERB_CONTEXT) { iakerb_release_context(iakerb_ctx); *context_handle = GSS_C_NO_CONTEXT; } else { assert(iakerb_ctx->magic == KG_CONTEXT); major_status = krb5_gss_delete_sec_context(minor_status, context_handle, output_token); } } return major_status; }
548
1
static int sctp_setsockopt_hmac_ident(struct sock *sk, char __user *optval, int optlen) { struct sctp_hmacalgo *hmacs; int err; if (optlen < sizeof(struct sctp_hmacalgo)) return -EINVAL; hmacs = kmalloc(optlen, GFP_KERNEL); if (!hmacs) return -ENOMEM; if (copy_from_user(hmacs, optval, optlen)) { err = -EFAULT; goto out; } if (hmacs->shmac_num_idents == 0 || hmacs->shmac_num_idents > SCTP_AUTH_NUM_HMACS) { err = -EINVAL; goto out; } err = sctp_auth_ep_set_hmacs(sctp_sk(sk)->ep, hmacs); out: kfree(hmacs); return err; }
static int sctp_setsockopt_hmac_ident(struct sock *sk, char __user *optval, int optlen) { struct sctp_hmacalgo *hmacs; int err; if (optlen < sizeof(struct sctp_hmacalgo)) return -EINVAL; hmacs = kmalloc(optlen, GFP_KERNEL); if (!hmacs) return -ENOMEM; if (copy_from_user(hmacs, optval, optlen)) { err = -EFAULT; goto out; } if (hmacs->shmac_num_idents == 0 || hmacs->shmac_num_idents > SCTP_AUTH_NUM_HMACS) { err = -EINVAL; goto out; } err = sctp_auth_ep_set_hmacs(sctp_sk(sk)->ep, hmacs); out: kfree(hmacs); return err; }
549
1
static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) { SmackerContext *smk = s->priv_data; int flags; int ret; int i; int frame_size = 0; int palchange = 0; if (s->pb->eof_reached || smk->cur_frame >= smk->frames) return AVERROR_EOF; /* if we demuxed all streams, pass another frame */ if(smk->curstream < 0) { avio_seek(s->pb, smk->nextpos, 0); frame_size = smk->frm_size[smk->cur_frame] & (~3); flags = smk->frm_flags[smk->cur_frame]; /* handle palette change event */ if(flags & SMACKER_PAL){ int size, sz, t, off, j, pos; uint8_t *pal = smk->pal; uint8_t oldpal[768]; memcpy(oldpal, pal, 768); size = avio_r8(s->pb); size = size * 4 - 1; frame_size -= size; frame_size--; sz = 0; pos = avio_tell(s->pb) + size; while(sz < 256){ t = avio_r8(s->pb); if(t & 0x80){ /* skip palette entries */ sz += (t & 0x7F) + 1; pal += ((t & 0x7F) + 1) * 3; } else if(t & 0x40){ /* copy with offset */ off = avio_r8(s->pb); j = (t & 0x3F) + 1; if (off + j > 0x100) { av_log(s, AV_LOG_ERROR, "Invalid palette update, offset=%d length=%d extends beyond palette size\n", off, j); return AVERROR_INVALIDDATA; } off *= 3; while(j-- && sz < 256) { *pal++ = oldpal[off + 0]; *pal++ = oldpal[off + 1]; *pal++ = oldpal[off + 2]; sz++; off += 3; } } else { /* new entries */ *pal++ = smk_pal[t]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; sz++; } } avio_seek(s->pb, pos, 0); palchange |= 1; } flags >>= 1; smk->curstream = -1; /* if audio chunks are present, put them to stack and retrieve later */ for(i = 0; i < 7; i++) { if(flags & 1) { uint32_t size; uint8_t *tmpbuf; size = avio_rl32(s->pb) - 4; if (!size || size > frame_size) { av_log(s, AV_LOG_ERROR, "Invalid audio part size\n"); return AVERROR_INVALIDDATA; } frame_size -= size; frame_size -= 4; smk->curstream++; tmpbuf = av_realloc(smk->bufs[smk->curstream], size); if (!tmpbuf) return AVERROR(ENOMEM); smk->bufs[smk->curstream] = tmpbuf; smk->buf_sizes[smk->curstream] = size; ret = avio_read(s->pb, smk->bufs[smk->curstream], size); if(ret != size) return AVERROR(EIO); smk->stream_id[smk->curstream] = smk->indexes[i]; } flags >>= 1; } if (frame_size < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, frame_size + 769)) return AVERROR(ENOMEM); if(smk->frm_size[smk->cur_frame] & 1) palchange |= 2; pkt->data[0] = palchange; memcpy(pkt->data + 1, smk->pal, 768); ret = avio_read(s->pb, pkt->data + 769, frame_size); if(ret != frame_size) return AVERROR(EIO); pkt->stream_index = smk->videoindex; pkt->pts = smk->cur_frame; pkt->size = ret + 769; smk->cur_frame++; smk->nextpos = avio_tell(s->pb); } else { if (smk->stream_id[smk->curstream] < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, smk->buf_sizes[smk->curstream])) return AVERROR(ENOMEM); memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]); pkt->size = smk->buf_sizes[smk->curstream]; pkt->stream_index = smk->stream_id[smk->curstream]; pkt->pts = smk->aud_pts[smk->curstream]; smk->aud_pts[smk->curstream] += AV_RL32(pkt->data); smk->curstream--; } return 0; }
static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) { SmackerContext *smk = s->priv_data; int flags; int ret; int i; int frame_size = 0; int palchange = 0; if (s->pb->eof_reached || smk->cur_frame >= smk->frames) return AVERROR_EOF; if(smk->curstream < 0) { avio_seek(s->pb, smk->nextpos, 0); frame_size = smk->frm_size[smk->cur_frame] & (~3); flags = smk->frm_flags[smk->cur_frame]; if(flags & SMACKER_PAL){ int size, sz, t, off, j, pos; uint8_t *pal = smk->pal; uint8_t oldpal[768]; memcpy(oldpal, pal, 768); size = avio_r8(s->pb); size = size * 4 - 1; frame_size -= size; frame_size--; sz = 0; pos = avio_tell(s->pb) + size; while(sz < 256){ t = avio_r8(s->pb); if(t & 0x80){ sz += (t & 0x7F) + 1; pal += ((t & 0x7F) + 1) * 3; } else if(t & 0x40){ off = avio_r8(s->pb); j = (t & 0x3F) + 1; if (off + j > 0x100) { av_log(s, AV_LOG_ERROR, "Invalid palette update, offset=%d length=%d extends beyond palette size\n", off, j); return AVERROR_INVALIDDATA; } off *= 3; while(j-- && sz < 256) { *pal++ = oldpal[off + 0]; *pal++ = oldpal[off + 1]; *pal++ = oldpal[off + 2]; sz++; off += 3; } } else { *pal++ = smk_pal[t]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; sz++; } } avio_seek(s->pb, pos, 0); palchange |= 1; } flags >>= 1; smk->curstream = -1; for(i = 0; i < 7; i++) { if(flags & 1) { uint32_t size; uint8_t *tmpbuf; size = avio_rl32(s->pb) - 4; if (!size || size > frame_size) { av_log(s, AV_LOG_ERROR, "Invalid audio part size\n"); return AVERROR_INVALIDDATA; } frame_size -= size; frame_size -= 4; smk->curstream++; tmpbuf = av_realloc(smk->bufs[smk->curstream], size); if (!tmpbuf) return AVERROR(ENOMEM); smk->bufs[smk->curstream] = tmpbuf; smk->buf_sizes[smk->curstream] = size; ret = avio_read(s->pb, smk->bufs[smk->curstream], size); if(ret != size) return AVERROR(EIO); smk->stream_id[smk->curstream] = smk->indexes[i]; } flags >>= 1; } if (frame_size < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, frame_size + 769)) return AVERROR(ENOMEM); if(smk->frm_size[smk->cur_frame] & 1) palchange |= 2; pkt->data[0] = palchange; memcpy(pkt->data + 1, smk->pal, 768); ret = avio_read(s->pb, pkt->data + 769, frame_size); if(ret != frame_size) return AVERROR(EIO); pkt->stream_index = smk->videoindex; pkt->pts = smk->cur_frame; pkt->size = ret + 769; smk->cur_frame++; smk->nextpos = avio_tell(s->pb); } else { if (smk->stream_id[smk->curstream] < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, smk->buf_sizes[smk->curstream])) return AVERROR(ENOMEM); memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]); pkt->size = smk->buf_sizes[smk->curstream]; pkt->stream_index = smk->stream_id[smk->curstream]; pkt->pts = smk->aud_pts[smk->curstream]; smk->aud_pts[smk->curstream] += AV_RL32(pkt->data); smk->curstream--; } return 0; }
550
1
static void wm8750_audio_out_cb(void *opaque, int free_b) { struct wm8750_s *s = (struct wm8750_s *) opaque; wm8750_out_flush(s); s->req_out = free_b; s->data_req(s->opaque, free_b >> 2, s->req_in >> 2); }
static void wm8750_audio_out_cb(void *opaque, int free_b) { struct wm8750_s *s = (struct wm8750_s *) opaque; wm8750_out_flush(s); s->req_out = free_b; s->data_req(s->opaque, free_b >> 2, s->req_in >> 2); }
551
0
void Set(const CString& sLine) { const CString sVar = sLine.Token(1).AsLower(); CString sUserName = sLine.Token(2); CString sValue = sLine.Token(3, true); if (sValue.empty()) { PutModule(t_s("Usage: Set <variable> <username> <value>")); return; } CUser* pUser = FindUser(sUserName); if (!pUser) return; if (sVar == "nick") { pUser->SetNick(sValue); PutModule("Nick = " + sValue); } else if (sVar == "altnick") { pUser->SetAltNick(sValue); PutModule("AltNick = " + sValue); } else if (sVar == "ident") { pUser->SetIdent(sValue); PutModule("Ident = " + sValue); } else if (sVar == "realname") { pUser->SetRealName(sValue); PutModule("RealName = " + sValue); } else if (sVar == "bindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { if (sValue.Equals(pUser->GetBindHost())) { PutModule(t_s("This bind host is already set!")); return; } pUser->SetBindHost(sValue); PutModule("BindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "multiclients") { bool b = sValue.ToBool(); pUser->SetMultiClients(b); PutModule("MultiClients = " + CString(b)); } else if (sVar == "denyloadmod") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenyLoadMod(b); PutModule("DenyLoadMod = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "denysetbindhost") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenySetBindHost(b); PutModule("DenySetBindHost = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "defaultchanmodes") { pUser->SetDefaultChanModes(sValue); PutModule("DefaultChanModes = " + sValue); } else if (sVar == "quitmsg") { pUser->SetQuitMsg(sValue); PutModule("QuitMsg = " + sValue); } else if (sVar == "chanbuffersize" || sVar == "buffercount") { unsigned int i = sValue.ToUInt(); // Admins don't have to honour the buffer limit if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) { PutModule("ChanBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "querybuffersize") { unsigned int i = sValue.ToUInt(); // Admins don't have to honour the buffer limit if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) { PutModule("QueryBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "keepbuffer") { // XXX compatibility crap, added in 0.207 bool b = !sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearchanbuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearquerybuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearQueryBuffer(b); PutModule("AutoClearQueryBuffer = " + CString(b)); } else if (sVar == "password") { const CString sSalt = CUtils::GetSalt(); const CString sHash = CUser::SaltedHash(sValue, sSalt); pUser->SetPass(sHash, CUser::HASH_DEFAULT, sSalt); PutModule(t_s("Password has been changed!")); } else if (sVar == "maxjoins") { unsigned int i = sValue.ToUInt(); pUser->SetMaxJoins(i); PutModule("MaxJoins = " + CString(pUser->MaxJoins())); } else if (sVar == "notraffictimeout") { unsigned int i = sValue.ToUInt(); if (i < 30) { PutModule(t_s("Timeout can't be less than 30 seconds!")); } else { pUser->SetNoTrafficTimeout(i); PutModule("NoTrafficTimeout = " + CString(pUser->GetNoTrafficTimeout())); } } else if (sVar == "maxnetworks") { if (GetUser()->IsAdmin()) { unsigned int i = sValue.ToUInt(); pUser->SetMaxNetworks(i); PutModule("MaxNetworks = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "maxquerybuffers") { unsigned int i = sValue.ToUInt(); pUser->SetMaxQueryBuffers(i); PutModule("MaxQueryBuffers = " + sValue); } else if (sVar == "jointries") { unsigned int i = sValue.ToUInt(); pUser->SetJoinTries(i); PutModule("JoinTries = " + CString(pUser->JoinTries())); } else if (sVar == "timezone") { pUser->SetTimezone(sValue); PutModule("Timezone = " + pUser->GetTimezone()); } else if (sVar == "admin") { if (GetUser()->IsAdmin() && pUser != GetUser()) { bool b = sValue.ToBool(); pUser->SetAdmin(b); PutModule("Admin = " + CString(pUser->IsAdmin())); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "prependtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampPrepend(b); PutModule("PrependTimestamp = " + CString(b)); } else if (sVar == "appendtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampAppend(b); PutModule("AppendTimestamp = " + CString(b)); } else if (sVar == "authonlyviamodule") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetAuthOnlyViaModule(b); PutModule("AuthOnlyViaModule = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "timestampformat") { pUser->SetTimestampFormat(sValue); PutModule("TimestampFormat = " + sValue); } else if (sVar == "dccbindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { pUser->SetDCCBindHost(sValue); PutModule("DCCBindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "statusprefix") { if (sVar.find_first_of(" \t\n") == CString::npos) { pUser->SetStatusPrefix(sValue); PutModule("StatusPrefix = " + sValue); } else { PutModule(t_s("That would be a bad idea!")); } } #ifdef HAVE_I18N else if (sVar == "language") { auto mTranslations = CTranslationInfo::GetTranslations(); // TODO: maybe stop special-casing English if (sValue == "en") { pUser->SetLanguage(""); PutModule("Language is set to English"); } else if (mTranslations.count(sValue)) { pUser->SetLanguage(sValue); PutModule("Language = " + sValue); } else { VCString vsCodes = {"en"}; for (const auto it : mTranslations) { vsCodes.push_back(it.first); } PutModule(t_f("Supported languages: {1}")( CString(", ").Join(vsCodes.begin(), vsCodes.end()))); } } #endif #ifdef HAVE_ICU else if (sVar == "clientencoding") { pUser->SetClientEncoding(sValue); PutModule("ClientEncoding = " + pUser->GetClientEncoding()); } #endif else PutModule(t_s("Error: Unknown variable")); }
void Set(const CString& sLine) { const CString sVar = sLine.Token(1).AsLower(); CString sUserName = sLine.Token(2); CString sValue = sLine.Token(3, true); if (sValue.empty()) { PutModule(t_s("Usage: Set <variable> <username> <value>")); return; } CUser* pUser = FindUser(sUserName); if (!pUser) return; if (sVar == "nick") { pUser->SetNick(sValue); PutModule("Nick = " + sValue); } else if (sVar == "altnick") { pUser->SetAltNick(sValue); PutModule("AltNick = " + sValue); } else if (sVar == "ident") { pUser->SetIdent(sValue); PutModule("Ident = " + sValue); } else if (sVar == "realname") { pUser->SetRealName(sValue); PutModule("RealName = " + sValue); } else if (sVar == "bindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { if (sValue.Equals(pUser->GetBindHost())) { PutModule(t_s("This bind host is already set!")); return; } pUser->SetBindHost(sValue); PutModule("BindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "multiclients") { bool b = sValue.ToBool(); pUser->SetMultiClients(b); PutModule("MultiClients = " + CString(b)); } else if (sVar == "denyloadmod") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenyLoadMod(b); PutModule("DenyLoadMod = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "denysetbindhost") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenySetBindHost(b); PutModule("DenySetBindHost = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "defaultchanmodes") { pUser->SetDefaultChanModes(sValue); PutModule("DefaultChanModes = " + sValue); } else if (sVar == "quitmsg") { pUser->SetQuitMsg(sValue); PutModule("QuitMsg = " + sValue); } else if (sVar == "chanbuffersize" || sVar == "buffercount") { unsigned int i = sValue.ToUInt(); if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) { PutModule("ChanBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "querybuffersize") { unsigned int i = sValue.ToUInt(); if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) { PutModule("QueryBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "keepbuffer") { bool b = !sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearchanbuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearquerybuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearQueryBuffer(b); PutModule("AutoClearQueryBuffer = " + CString(b)); } else if (sVar == "password") { const CString sSalt = CUtils::GetSalt(); const CString sHash = CUser::SaltedHash(sValue, sSalt); pUser->SetPass(sHash, CUser::HASH_DEFAULT, sSalt); PutModule(t_s("Password has been changed!")); } else if (sVar == "maxjoins") { unsigned int i = sValue.ToUInt(); pUser->SetMaxJoins(i); PutModule("MaxJoins = " + CString(pUser->MaxJoins())); } else if (sVar == "notraffictimeout") { unsigned int i = sValue.ToUInt(); if (i < 30) { PutModule(t_s("Timeout can't be less than 30 seconds!")); } else { pUser->SetNoTrafficTimeout(i); PutModule("NoTrafficTimeout = " + CString(pUser->GetNoTrafficTimeout())); } } else if (sVar == "maxnetworks") { if (GetUser()->IsAdmin()) { unsigned int i = sValue.ToUInt(); pUser->SetMaxNetworks(i); PutModule("MaxNetworks = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "maxquerybuffers") { unsigned int i = sValue.ToUInt(); pUser->SetMaxQueryBuffers(i); PutModule("MaxQueryBuffers = " + sValue); } else if (sVar == "jointries") { unsigned int i = sValue.ToUInt(); pUser->SetJoinTries(i); PutModule("JoinTries = " + CString(pUser->JoinTries())); } else if (sVar == "timezone") { pUser->SetTimezone(sValue); PutModule("Timezone = " + pUser->GetTimezone()); } else if (sVar == "admin") { if (GetUser()->IsAdmin() && pUser != GetUser()) { bool b = sValue.ToBool(); pUser->SetAdmin(b); PutModule("Admin = " + CString(pUser->IsAdmin())); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "prependtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampPrepend(b); PutModule("PrependTimestamp = " + CString(b)); } else if (sVar == "appendtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampAppend(b); PutModule("AppendTimestamp = " + CString(b)); } else if (sVar == "authonlyviamodule") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetAuthOnlyViaModule(b); PutModule("AuthOnlyViaModule = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "timestampformat") { pUser->SetTimestampFormat(sValue); PutModule("TimestampFormat = " + sValue); } else if (sVar == "dccbindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { pUser->SetDCCBindHost(sValue); PutModule("DCCBindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "statusprefix") { if (sVar.find_first_of(" \t\n") == CString::npos) { pUser->SetStatusPrefix(sValue); PutModule("StatusPrefix = " + sValue); } else { PutModule(t_s("That would be a bad idea!")); } } #ifdef HAVE_I18N else if (sVar == "language") { auto mTranslations = CTranslationInfo::GetTranslations(); if (sValue == "en") { pUser->SetLanguage(""); PutModule("Language is set to English"); } else if (mTranslations.count(sValue)) { pUser->SetLanguage(sValue); PutModule("Language = " + sValue); } else { VCString vsCodes = {"en"}; for (const auto it : mTranslations) { vsCodes.push_back(it.first); } PutModule(t_f("Supported languages: {1}")( CString(", ").Join(vsCodes.begin(), vsCodes.end()))); } } #endif #ifdef HAVE_ICU else if (sVar == "clientencoding") { pUser->SetClientEncoding(sValue); PutModule("ClientEncoding = " + pUser->GetClientEncoding()); } #endif else PutModule(t_s("Error: Unknown variable")); }
552
1
void Set(const CString& sLine) { const CString sVar = sLine.Token(1).AsLower(); CString sUserName = sLine.Token(2); CString sValue = sLine.Token(3, true); if (sValue.empty()) { PutModule(t_s("Usage: Set <variable> <username> <value>")); return; } CUser* pUser = FindUser(sUserName); if (!pUser) return; if (sVar == "nick") { pUser->SetNick(sValue); PutModule("Nick = " + sValue); } else if (sVar == "altnick") { pUser->SetAltNick(sValue); PutModule("AltNick = " + sValue); } else if (sVar == "ident") { pUser->SetIdent(sValue); PutModule("Ident = " + sValue); } else if (sVar == "realname") { pUser->SetRealName(sValue); PutModule("RealName = " + sValue); } else if (sVar == "bindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { if (sValue.Equals(pUser->GetBindHost())) { PutModule(t_s("This bind host is already set!")); return; } pUser->SetBindHost(sValue); PutModule("BindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "multiclients") { bool b = sValue.ToBool(); pUser->SetMultiClients(b); PutModule("MultiClients = " + CString(b)); } else if (sVar == "denyloadmod") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenyLoadMod(b); PutModule("DenyLoadMod = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "denysetbindhost") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenySetBindHost(b); PutModule("DenySetBindHost = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "defaultchanmodes") { pUser->SetDefaultChanModes(sValue); PutModule("DefaultChanModes = " + sValue); } else if (sVar == "quitmsg") { pUser->SetQuitMsg(sValue); PutModule("QuitMsg = " + sValue); } else if (sVar == "chanbuffersize" || sVar == "buffercount") { unsigned int i = sValue.ToUInt(); // Admins don't have to honour the buffer limit if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) { PutModule("ChanBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "querybuffersize") { unsigned int i = sValue.ToUInt(); // Admins don't have to honour the buffer limit if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) { PutModule("QueryBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "keepbuffer") { // XXX compatibility crap, added in 0.207 bool b = !sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearchanbuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearquerybuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearQueryBuffer(b); PutModule("AutoClearQueryBuffer = " + CString(b)); } else if (sVar == "password") { const CString sSalt = CUtils::GetSalt(); const CString sHash = CUser::SaltedHash(sValue, sSalt); pUser->SetPass(sHash, CUser::HASH_DEFAULT, sSalt); PutModule(t_s("Password has been changed!")); } else if (sVar == "maxjoins") { unsigned int i = sValue.ToUInt(); pUser->SetMaxJoins(i); PutModule("MaxJoins = " + CString(pUser->MaxJoins())); } else if (sVar == "notraffictimeout") { unsigned int i = sValue.ToUInt(); if (i < 30) { PutModule(t_s("Timeout can't be less than 30 seconds!")); } else { pUser->SetNoTrafficTimeout(i); PutModule("NoTrafficTimeout = " + CString(pUser->GetNoTrafficTimeout())); } } else if (sVar == "maxnetworks") { if (GetUser()->IsAdmin()) { unsigned int i = sValue.ToUInt(); pUser->SetMaxNetworks(i); PutModule("MaxNetworks = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "maxquerybuffers") { unsigned int i = sValue.ToUInt(); pUser->SetMaxQueryBuffers(i); PutModule("MaxQueryBuffers = " + sValue); } else if (sVar == "jointries") { unsigned int i = sValue.ToUInt(); pUser->SetJoinTries(i); PutModule("JoinTries = " + CString(pUser->JoinTries())); } else if (sVar == "timezone") { pUser->SetTimezone(sValue); PutModule("Timezone = " + pUser->GetTimezone()); } else if (sVar == "admin") { if (GetUser()->IsAdmin() && pUser != GetUser()) { bool b = sValue.ToBool(); pUser->SetAdmin(b); PutModule("Admin = " + CString(pUser->IsAdmin())); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "prependtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampPrepend(b); PutModule("PrependTimestamp = " + CString(b)); } else if (sVar == "appendtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampAppend(b); PutModule("AppendTimestamp = " + CString(b)); } else if (sVar == "authonlyviamodule") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetAuthOnlyViaModule(b); PutModule("AuthOnlyViaModule = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "timestampformat") { pUser->SetTimestampFormat(sValue); PutModule("TimestampFormat = " + sValue); } else if (sVar == "dccbindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { pUser->SetDCCBindHost(sValue); PutModule("DCCBindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "statusprefix") { if (sVar.find_first_of(" \t\n") == CString::npos) { pUser->SetStatusPrefix(sValue); PutModule("StatusPrefix = " + sValue); } else { PutModule(t_s("That would be a bad idea!")); } } #ifdef HAVE_I18N else if (sVar == "language") { auto mTranslations = CTranslationInfo::GetTranslations(); // TODO: maybe stop special-casing English if (sValue == "en") { pUser->SetLanguage(""); PutModule("Language is set to English"); } else if (mTranslations.count(sValue)) { pUser->SetLanguage(sValue); PutModule("Language = " + sValue); } else { VCString vsCodes = {"en"}; for (const auto it : mTranslations) { vsCodes.push_back(it.first); } PutModule(t_f("Supported languages: {1}")( CString(", ").Join(vsCodes.begin(), vsCodes.end()))); } } #endif #ifdef HAVE_ICU else if (sVar == "clientencoding") { pUser->SetClientEncoding(sValue); PutModule("ClientEncoding = " + sValue); } #endif else PutModule(t_s("Error: Unknown variable")); }
void Set(const CString& sLine) { const CString sVar = sLine.Token(1).AsLower(); CString sUserName = sLine.Token(2); CString sValue = sLine.Token(3, true); if (sValue.empty()) { PutModule(t_s("Usage: Set <variable> <username> <value>")); return; } CUser* pUser = FindUser(sUserName); if (!pUser) return; if (sVar == "nick") { pUser->SetNick(sValue); PutModule("Nick = " + sValue); } else if (sVar == "altnick") { pUser->SetAltNick(sValue); PutModule("AltNick = " + sValue); } else if (sVar == "ident") { pUser->SetIdent(sValue); PutModule("Ident = " + sValue); } else if (sVar == "realname") { pUser->SetRealName(sValue); PutModule("RealName = " + sValue); } else if (sVar == "bindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { if (sValue.Equals(pUser->GetBindHost())) { PutModule(t_s("This bind host is already set!")); return; } pUser->SetBindHost(sValue); PutModule("BindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "multiclients") { bool b = sValue.ToBool(); pUser->SetMultiClients(b); PutModule("MultiClients = " + CString(b)); } else if (sVar == "denyloadmod") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenyLoadMod(b); PutModule("DenyLoadMod = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "denysetbindhost") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenySetBindHost(b); PutModule("DenySetBindHost = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "defaultchanmodes") { pUser->SetDefaultChanModes(sValue); PutModule("DefaultChanModes = " + sValue); } else if (sVar == "quitmsg") { pUser->SetQuitMsg(sValue); PutModule("QuitMsg = " + sValue); } else if (sVar == "chanbuffersize" || sVar == "buffercount") { unsigned int i = sValue.ToUInt(); if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) { PutModule("ChanBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "querybuffersize") { unsigned int i = sValue.ToUInt(); if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) { PutModule("QueryBufferSize = " + sValue); } else { PutModule(t_f("Setting failed, limit for buffer size is {1}")( CString(CZNC::Get().GetMaxBufferSize()))); } } else if (sVar == "keepbuffer") { bool b = !sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearchanbuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearChanBuffer(b); PutModule("AutoClearChanBuffer = " + CString(b)); } else if (sVar == "autoclearquerybuffer") { bool b = sValue.ToBool(); pUser->SetAutoClearQueryBuffer(b); PutModule("AutoClearQueryBuffer = " + CString(b)); } else if (sVar == "password") { const CString sSalt = CUtils::GetSalt(); const CString sHash = CUser::SaltedHash(sValue, sSalt); pUser->SetPass(sHash, CUser::HASH_DEFAULT, sSalt); PutModule(t_s("Password has been changed!")); } else if (sVar == "maxjoins") { unsigned int i = sValue.ToUInt(); pUser->SetMaxJoins(i); PutModule("MaxJoins = " + CString(pUser->MaxJoins())); } else if (sVar == "notraffictimeout") { unsigned int i = sValue.ToUInt(); if (i < 30) { PutModule(t_s("Timeout can't be less than 30 seconds!")); } else { pUser->SetNoTrafficTimeout(i); PutModule("NoTrafficTimeout = " + CString(pUser->GetNoTrafficTimeout())); } } else if (sVar == "maxnetworks") { if (GetUser()->IsAdmin()) { unsigned int i = sValue.ToUInt(); pUser->SetMaxNetworks(i); PutModule("MaxNetworks = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "maxquerybuffers") { unsigned int i = sValue.ToUInt(); pUser->SetMaxQueryBuffers(i); PutModule("MaxQueryBuffers = " + sValue); } else if (sVar == "jointries") { unsigned int i = sValue.ToUInt(); pUser->SetJoinTries(i); PutModule("JoinTries = " + CString(pUser->JoinTries())); } else if (sVar == "timezone") { pUser->SetTimezone(sValue); PutModule("Timezone = " + pUser->GetTimezone()); } else if (sVar == "admin") { if (GetUser()->IsAdmin() && pUser != GetUser()) { bool b = sValue.ToBool(); pUser->SetAdmin(b); PutModule("Admin = " + CString(pUser->IsAdmin())); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "prependtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampPrepend(b); PutModule("PrependTimestamp = " + CString(b)); } else if (sVar == "appendtimestamp") { bool b = sValue.ToBool(); pUser->SetTimestampAppend(b); PutModule("AppendTimestamp = " + CString(b)); } else if (sVar == "authonlyviamodule") { if (GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetAuthOnlyViaModule(b); PutModule("AuthOnlyViaModule = " + CString(b)); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "timestampformat") { pUser->SetTimestampFormat(sValue); PutModule("TimestampFormat = " + sValue); } else if (sVar == "dccbindhost") { if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { pUser->SetDCCBindHost(sValue); PutModule("DCCBindHost = " + sValue); } else { PutModule(t_s("Access denied!")); } } else if (sVar == "statusprefix") { if (sVar.find_first_of(" \t\n") == CString::npos) { pUser->SetStatusPrefix(sValue); PutModule("StatusPrefix = " + sValue); } else { PutModule(t_s("That would be a bad idea!")); } } #ifdef HAVE_I18N else if (sVar == "language") { auto mTranslations = CTranslationInfo::GetTranslations(); if (sValue == "en") { pUser->SetLanguage(""); PutModule("Language is set to English"); } else if (mTranslations.count(sValue)) { pUser->SetLanguage(sValue); PutModule("Language = " + sValue); } else { VCString vsCodes = {"en"}; for (const auto it : mTranslations) { vsCodes.push_back(it.first); } PutModule(t_f("Supported languages: {1}")( CString(", ").Join(vsCodes.begin(), vsCodes.end()))); } } #endif #ifdef HAVE_ICU else if (sVar == "clientencoding") { pUser->SetClientEncoding(sValue); PutModule("ClientEncoding = " + sValue); } #endif else PutModule(t_s("Error: Unknown variable")); }
555
0
iakerb_gss_export_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t interprocess_token) { OM_uint32 maj; iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; /* We don't currently support exporting partially established contexts. */ if (!ctx->established) return GSS_S_UNAVAILABLE; maj = krb5_gss_export_sec_context(minor_status, &ctx->gssc, interprocess_token); if (ctx->gssc == GSS_C_NO_CONTEXT) { iakerb_release_context(ctx); *context_handle = GSS_C_NO_CONTEXT; } return maj; }
iakerb_gss_export_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t interprocess_token) { OM_uint32 maj; iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; if (!ctx->established) return GSS_S_UNAVAILABLE; maj = krb5_gss_export_sec_context(minor_status, &ctx->gssc, interprocess_token); if (ctx->gssc == GSS_C_NO_CONTEXT) { iakerb_release_context(ctx); *context_handle = GSS_C_NO_CONTEXT; } return maj; }
556
1
static hb_feature_t * feature_reference ( hb_feature_t * g ) { hb_feature_t * c = ( hb_feature_t * ) calloc ( 1 , sizeof ( hb_feature_t ) ) ; if ( unlikely ( ! c ) ) return NULL ; * c = * g ; return c ; }
static hb_feature_t * feature_reference ( hb_feature_t * g ) { hb_feature_t * c = ( hb_feature_t * ) calloc ( 1 , sizeof ( hb_feature_t ) ) ; if ( unlikely ( ! c ) ) return NULL ; * c = * g ; return c ; }
557
1
static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, char __user *optval, int __user *optlen) { struct sctp_hmac_algo_param *hmacs; __u16 param_len; hmacs = sctp_sk(sk)->ep->auth_hmacs_list; param_len = ntohs(hmacs->param_hdr.length); if (len < param_len) return -EINVAL; if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, hmacs->hmac_ids, len)) return -EFAULT; return 0; }
static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, char __user *optval, int __user *optlen) { struct sctp_hmac_algo_param *hmacs; __u16 param_len; hmacs = sctp_sk(sk)->ep->auth_hmacs_list; param_len = ntohs(hmacs->param_hdr.length); if (len < param_len) return -EINVAL; if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, hmacs->hmac_ids, len)) return -EFAULT; return 0; }
558
1
static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg) { TCPCharDriver *s = chr->opaque; struct cmsghdr *cmsg; for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { int fd; if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) continue; fd = *((int *)CMSG_DATA(cmsg)); if (fd < 0) continue; #ifndef MSG_CMSG_CLOEXEC qemu_set_cloexec(fd); #endif if (s->msgfd != -1) close(s->msgfd); s->msgfd = fd; } }
static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg) { TCPCharDriver *s = chr->opaque; struct cmsghdr *cmsg; for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { int fd; if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) continue; fd = *((int *)CMSG_DATA(cmsg)); if (fd < 0) continue; #ifndef MSG_CMSG_CLOEXEC qemu_set_cloexec(fd); #endif if (s->msgfd != -1) close(s->msgfd); s->msgfd = fd; } }
559
1
static int sctp_setsockopt_active_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkeyid val; struct sctp_association *asoc; if (optlen != sizeof(struct sctp_authkeyid)) return -EINVAL; if (copy_from_user(&val, optval, optlen)) return -EFAULT; asoc = sctp_id2assoc(sk, val.scact_assoc_id); if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) return -EINVAL; return sctp_auth_set_active_key(sctp_sk(sk)->ep, asoc, val.scact_keynumber); }
static int sctp_setsockopt_active_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkeyid val; struct sctp_association *asoc; if (optlen != sizeof(struct sctp_authkeyid)) return -EINVAL; if (copy_from_user(&val, optval, optlen)) return -EFAULT; asoc = sctp_id2assoc(sk, val.scact_assoc_id); if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) return -EINVAL; return sctp_auth_set_active_key(sctp_sk(sk)->ep, asoc, val.scact_keynumber); }
562
0
static Datum ExecEvalConvertRowtype ( ConvertRowtypeExprState * cstate , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) { ConvertRowtypeExpr * convert = ( ConvertRowtypeExpr * ) cstate -> xprstate . expr ; HeapTuple result ; Datum tupDatum ; HeapTupleHeader tuple ; HeapTupleData tmptup ; tupDatum = ExecEvalExpr ( cstate -> arg , econtext , isNull , isDone ) ; if ( * isNull ) return tupDatum ; tuple = DatumGetHeapTupleHeader ( tupDatum ) ; if ( cstate -> indesc == NULL ) { get_cached_rowtype ( exprType ( ( Node * ) convert -> arg ) , - 1 , & cstate -> indesc , econtext ) ; cstate -> initialized = false ; } if ( cstate -> outdesc == NULL ) { get_cached_rowtype ( convert -> resulttype , - 1 , & cstate -> outdesc , econtext ) ; cstate -> initialized = false ; } Assert ( HeapTupleHeaderGetTypeId ( tuple ) == cstate -> indesc -> tdtypeid || HeapTupleHeaderGetTypeId ( tuple ) == RECORDOID ) ; if ( ! cstate -> initialized ) { MemoryContext old_cxt ; old_cxt = MemoryContextSwitchTo ( econtext -> ecxt_per_query_memory ) ; cstate -> map = convert_tuples_by_name ( cstate -> indesc , cstate -> outdesc , gettext_noop ( "could not convert row type" ) ) ; cstate -> initialized = true ; MemoryContextSwitchTo ( old_cxt ) ; } if ( cstate -> map == NULL ) return tupDatum ; tmptup . t_len = HeapTupleHeaderGetDatumLength ( tuple ) ; tmptup . t_data = tuple ; result = do_convert_tuple ( & tmptup , cstate -> map ) ; return HeapTupleGetDatum ( result ) ; }
static Datum ExecEvalConvertRowtype ( ConvertRowtypeExprState * cstate , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) { ConvertRowtypeExpr * convert = ( ConvertRowtypeExpr * ) cstate -> xprstate . expr ; HeapTuple result ; Datum tupDatum ; HeapTupleHeader tuple ; HeapTupleData tmptup ; tupDatum = ExecEvalExpr ( cstate -> arg , econtext , isNull , isDone ) ; if ( * isNull ) return tupDatum ; tuple = DatumGetHeapTupleHeader ( tupDatum ) ; if ( cstate -> indesc == NULL ) { get_cached_rowtype ( exprType ( ( Node * ) convert -> arg ) , - 1 , & cstate -> indesc , econtext ) ; cstate -> initialized = false ; } if ( cstate -> outdesc == NULL ) { get_cached_rowtype ( convert -> resulttype , - 1 , & cstate -> outdesc , econtext ) ; cstate -> initialized = false ; } Assert ( HeapTupleHeaderGetTypeId ( tuple ) == cstate -> indesc -> tdtypeid || HeapTupleHeaderGetTypeId ( tuple ) == RECORDOID ) ; if ( ! cstate -> initialized ) { MemoryContext old_cxt ; old_cxt = MemoryContextSwitchTo ( econtext -> ecxt_per_query_memory ) ; cstate -> map = convert_tuples_by_name ( cstate -> indesc , cstate -> outdesc , gettext_noop ( "could not convert row type" ) ) ; cstate -> initialized = true ; MemoryContextSwitchTo ( old_cxt ) ; } if ( cstate -> map == NULL ) return tupDatum ; tmptup . t_len = HeapTupleHeaderGetDatumLength ( tuple ) ; tmptup . t_data = tuple ; result = do_convert_tuple ( & tmptup , cstate -> map ) ; return HeapTupleGetDatum ( result ) ; }
563
0
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr, Error **errp) { RAMBlock *new_block; ram_addr_t addr; Error *local_err = NULL; size = TARGET_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; new_block->used_length = size; new_block->max_length = max_size; new_block->fd = -1; new_block->host = host; if (host) { new_block->flags |= RAM_PREALLOC; } addr = ram_block_add(new_block, &local_err); if (local_err) { g_free(new_block); error_propagate(errp, local_err); return -1; } return addr; }
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr, Error **errp) { RAMBlock *new_block; ram_addr_t addr; Error *local_err = NULL; size = TARGET_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; new_block->used_length = size; new_block->max_length = max_size; new_block->fd = -1; new_block->host = host; if (host) { new_block->flags |= RAM_PREALLOC; } addr = ram_block_add(new_block, &local_err); if (local_err) { g_free(new_block); error_propagate(errp, local_err); return -1; } return addr; }
564
1
static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, char __user *optval, int __user *optlen) { struct sctp_authchunks __user *p = (void __user *)optval; struct sctp_authchunks val; struct sctp_association *asoc; struct sctp_chunks_param *ch; u32 num_chunks; char __user *to; if (len <= sizeof(struct sctp_authchunks)) return -EINVAL; if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) return -EFAULT; to = p->gauth_chunks; asoc = sctp_id2assoc(sk, val.gauth_assoc_id); if (!asoc) return -EINVAL; ch = asoc->peer.peer_chunks; /* See if the user provided enough room for all the data */ num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); if (len < num_chunks) return -EINVAL; len = num_chunks; if (put_user(len, optlen)) return -EFAULT; if (put_user(num_chunks, &p->gauth_number_of_chunks)) return -EFAULT; if (copy_to_user(to, ch->chunks, len)) return -EFAULT; return 0; }
static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, char __user *optval, int __user *optlen) { struct sctp_authchunks __user *p = (void __user *)optval; struct sctp_authchunks val; struct sctp_association *asoc; struct sctp_chunks_param *ch; u32 num_chunks; char __user *to; if (len <= sizeof(struct sctp_authchunks)) return -EINVAL; if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) return -EFAULT; to = p->gauth_chunks; asoc = sctp_id2assoc(sk, val.gauth_assoc_id); if (!asoc) return -EINVAL; ch = asoc->peer.peer_chunks; num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); if (len < num_chunks) return -EINVAL; len = num_chunks; if (put_user(len, optlen)) return -EFAULT; if (put_user(num_chunks, &p->gauth_number_of_chunks)) return -EFAULT; if (copy_to_user(to, ch->chunks, len)) return -EFAULT; return 0; }
565
1
void CIRCNetwork::SetEncoding(const CString& s) { m_sEncoding = s; if (GetIRCSock()) { GetIRCSock()->SetEncoding(s); } }
void CIRCNetwork::SetEncoding(const CString& s) { m_sEncoding = s; if (GetIRCSock()) { GetIRCSock()->SetEncoding(s); } }
566
0
static int qemuMonitorJSONGetBlockJobInfoOne ( virJSONValuePtr entry , const char * device , virDomainBlockJobInfoPtr info ) { const char * this_dev ; const char * type ; unsigned long long speed_bytes ; if ( ( this_dev = virJSONValueObjectGetString ( entry , "device" ) ) == NULL ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'device'" ) ) ; return - 1 ; } if ( ! STREQ ( this_dev , device ) ) return - 1 ; type = virJSONValueObjectGetString ( entry , "type" ) ; if ( ! type ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'type'" ) ) ; return - 1 ; } if ( STREQ ( type , "stream" ) ) info -> type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL ; else info -> type = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN ; if ( virJSONValueObjectGetNumberUlong ( entry , "speed" , & speed_bytes ) < 0 ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'speed'" ) ) ; return - 1 ; } info -> bandwidth = speed_bytes / 1024ULL / 1024ULL ; if ( virJSONValueObjectGetNumberUlong ( entry , "offset" , & info -> cur ) < 0 ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'offset'" ) ) ; return - 1 ; } if ( virJSONValueObjectGetNumberUlong ( entry , "len" , & info -> end ) < 0 ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'len'" ) ) ; return - 1 ; } return 0 ; }
static int qemuMonitorJSONGetBlockJobInfoOne ( virJSONValuePtr entry , const char * device , virDomainBlockJobInfoPtr info ) { const char * this_dev ; const char * type ; unsigned long long speed_bytes ; if ( ( this_dev = virJSONValueObjectGetString ( entry , "device" ) ) == NULL ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'device'" ) ) ; return - 1 ; } if ( ! STREQ ( this_dev , device ) ) return - 1 ; type = virJSONValueObjectGetString ( entry , "type" ) ; if ( ! type ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'type'" ) ) ; return - 1 ; } if ( STREQ ( type , "stream" ) ) info -> type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL ; else info -> type = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN ; if ( virJSONValueObjectGetNumberUlong ( entry , "speed" , & speed_bytes ) < 0 ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'speed'" ) ) ; return - 1 ; } info -> bandwidth = speed_bytes / 1024ULL / 1024ULL ; if ( virJSONValueObjectGetNumberUlong ( entry , "offset" , & info -> cur ) < 0 ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'offset'" ) ) ; return - 1 ; } if ( virJSONValueObjectGetNumberUlong ( entry , "len" , & info -> end ) < 0 ) { qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "entry was missing 'len'" ) ) ; return - 1 ; } return 0 ; }
567
0
void CUser::SetClientEncoding(const CString& s) { m_sClientEncoding = CZNC::Get().FixupEncoding(s); for (CClient* pClient : GetAllClients()) { pClient->SetEncoding(m_sClientEncoding); } }
void CUser::SetClientEncoding(const CString& s) { m_sClientEncoding = CZNC::Get().FixupEncoding(s); for (CClient* pClient : GetAllClients()) { pClient->SetEncoding(m_sClientEncoding); } }
568
1
static void event_process_active ( struct event_base * base ) { struct event * ev ; struct event_list * activeq = NULL ; int i ; short ncalls ; for ( i = 0 ; i < base -> nactivequeues ; ++ i ) { if ( TAILQ_FIRST ( base -> activequeues [ i ] ) != NULL ) { activeq = base -> activequeues [ i ] ; break ; } } assert ( activeq != NULL ) ; for ( ev = TAILQ_FIRST ( activeq ) ; ev ; ev = TAILQ_FIRST ( activeq ) ) { if ( ev -> ev_events & EV_PERSIST ) event_queue_remove ( base , ev , EVLIST_ACTIVE ) ; else event_del ( ev ) ; ncalls = ev -> ev_ncalls ; ev -> ev_pncalls = & ncalls ; while ( ncalls ) { ncalls -- ; ev -> ev_ncalls = ncalls ; ( * ev -> ev_callback ) ( ( int ) ev -> ev_fd , ev -> ev_res , ev -> ev_arg ) ; if ( base -> event_break ) return ; } } }
static void event_process_active ( struct event_base * base ) { struct event * ev ; struct event_list * activeq = NULL ; int i ; short ncalls ; for ( i = 0 ; i < base -> nactivequeues ; ++ i ) { if ( TAILQ_FIRST ( base -> activequeues [ i ] ) != NULL ) { activeq = base -> activequeues [ i ] ; break ; } } assert ( activeq != NULL ) ; for ( ev = TAILQ_FIRST ( activeq ) ; ev ; ev = TAILQ_FIRST ( activeq ) ) { if ( ev -> ev_events & EV_PERSIST ) event_queue_remove ( base , ev , EVLIST_ACTIVE ) ; else event_del ( ev ) ; ncalls = ev -> ev_ncalls ; ev -> ev_pncalls = & ncalls ; while ( ncalls ) { ncalls -- ; ev -> ev_ncalls = ncalls ; ( * ev -> ev_callback ) ( ( int ) ev -> ev_fd , ev -> ev_res , ev -> ev_arg ) ; if ( base -> event_break ) return ; } } }
569
1
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (!sctp_auth_enable) return -EACCES; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (!sctp_auth_enable) return -EACCES; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
571
0
static void elcr_ioport_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { PICCommonState *s = opaque; s->elcr = val & s->elcr_mask; }
static void elcr_ioport_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { PICCommonState *s = opaque; s->elcr = val & s->elcr_mask; }
572
1
static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp) { struct sctp_auth_bytes *key; /* Allocate the shared key */ key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); if (!key) return NULL; key->len = key_len; atomic_set(&key->refcnt, 1); SCTP_DBG_OBJCNT_INC(keys); return key; }
static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp) { struct sctp_auth_bytes *key; key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); if (!key) return NULL; key->len = key_len; atomic_set(&key->refcnt, 1); SCTP_DBG_OBJCNT_INC(keys); return key; }
574
1
void CUser::SetClientEncoding(const CString& s) { m_sClientEncoding = s; for (CClient* pClient : GetAllClients()) { pClient->SetEncoding(s); } }
void CUser::SetClientEncoding(const CString& s) { m_sClientEncoding = s; for (CClient* pClient : GetAllClients()) { pClient->SetEncoding(s); } }
575
0
int jbig2_decode_generic_region ( Jbig2Ctx * ctx , Jbig2Segment * segment , const Jbig2GenericRegionParams * params , Jbig2ArithState * as , Jbig2Image * image , Jbig2ArithCx * GB_stats ) { const int8_t * gbat = params -> gbat ; if ( image -> stride * image -> height > ( 1 << 24 ) && segment -> data_length < image -> stride * image -> height / 256 ) { return jbig2_error ( ctx , JBIG2_SEVERITY_FATAL , segment -> number , "region is far larger than data provided (%d << %d), aborting to prevent DOS" , segment -> data_length , image -> stride * image -> height ) ; } if ( ! params -> MMR && params -> TPGDON ) return jbig2_decode_generic_region_TPGDON ( ctx , segment , params , as , image , GB_stats ) ; if ( ! params -> MMR && params -> GBTEMPLATE == 0 ) { if ( gbat [ 0 ] == + 3 && gbat [ 1 ] == - 1 && gbat [ 2 ] == - 3 && gbat [ 3 ] == - 1 && gbat [ 4 ] == + 2 && gbat [ 5 ] == - 2 && gbat [ 6 ] == - 2 && gbat [ 7 ] == - 2 ) return jbig2_decode_generic_template0 ( ctx , segment , params , as , image , GB_stats ) ; else return jbig2_decode_generic_template0_unopt ( ctx , segment , params , as , image , GB_stats ) ; } else if ( ! params -> MMR && params -> GBTEMPLATE == 1 ) return jbig2_decode_generic_template1 ( ctx , segment , params , as , image , GB_stats ) ; else if ( ! params -> MMR && params -> GBTEMPLATE == 2 ) { if ( gbat [ 0 ] == 3 && gbat [ 1 ] == - 1 ) return jbig2_decode_generic_template2a ( ctx , segment , params , as , image , GB_stats ) ; else return jbig2_decode_generic_template2 ( ctx , segment , params , as , image , GB_stats ) ; } else if ( ! params -> MMR && params -> GBTEMPLATE == 3 ) { if ( gbat [ 0 ] == 2 && gbat [ 1 ] == - 1 ) return jbig2_decode_generic_template3_unopt ( ctx , segment , params , as , image , GB_stats ) ; else return jbig2_decode_generic_template3_unopt ( ctx , segment , params , as , image , GB_stats ) ; } { int i ; for ( i = 0 ; i < 8 ; i ++ ) jbig2_error ( ctx , JBIG2_SEVERITY_DEBUG , segment -> number , "gbat[%d] = %d" , i , params -> gbat [ i ] ) ; } jbig2_error ( ctx , JBIG2_SEVERITY_WARNING , segment -> number , "decode_generic_region: MMR=%d, GBTEMPLATE=%d NYI" , params -> MMR , params -> GBTEMPLATE ) ; return - 1 ; }
int jbig2_decode_generic_region ( Jbig2Ctx * ctx , Jbig2Segment * segment , const Jbig2GenericRegionParams * params , Jbig2ArithState * as , Jbig2Image * image , Jbig2ArithCx * GB_stats ) { const int8_t * gbat = params -> gbat ; if ( image -> stride * image -> height > ( 1 << 24 ) && segment -> data_length < image -> stride * image -> height / 256 ) { return jbig2_error ( ctx , JBIG2_SEVERITY_FATAL , segment -> number , "region is far larger than data provided (%d << %d), aborting to prevent DOS" , segment -> data_length , image -> stride * image -> height ) ; } if ( ! params -> MMR && params -> TPGDON ) return jbig2_decode_generic_region_TPGDON ( ctx , segment , params , as , image , GB_stats ) ; if ( ! params -> MMR && params -> GBTEMPLATE == 0 ) { if ( gbat [ 0 ] == + 3 && gbat [ 1 ] == - 1 && gbat [ 2 ] == - 3 && gbat [ 3 ] == - 1 && gbat [ 4 ] == + 2 && gbat [ 5 ] == - 2 && gbat [ 6 ] == - 2 && gbat [ 7 ] == - 2 ) return jbig2_decode_generic_template0 ( ctx , segment , params , as , image , GB_stats ) ; else return jbig2_decode_generic_template0_unopt ( ctx , segment , params , as , image , GB_stats ) ; } else if ( ! params -> MMR && params -> GBTEMPLATE == 1 ) return jbig2_decode_generic_template1 ( ctx , segment , params , as , image , GB_stats ) ; else if ( ! params -> MMR && params -> GBTEMPLATE == 2 ) { if ( gbat [ 0 ] == 3 && gbat [ 1 ] == - 1 ) return jbig2_decode_generic_template2a ( ctx , segment , params , as , image , GB_stats ) ; else return jbig2_decode_generic_template2 ( ctx , segment , params , as , image , GB_stats ) ; } else if ( ! params -> MMR && params -> GBTEMPLATE == 3 ) { if ( gbat [ 0 ] == 2 && gbat [ 1 ] == - 1 ) return jbig2_decode_generic_template3_unopt ( ctx , segment , params , as , image , GB_stats ) ; else return jbig2_decode_generic_template3_unopt ( ctx , segment , params , as , image , GB_stats ) ; } { int i ; for ( i = 0 ; i < 8 ; i ++ ) jbig2_error ( ctx , JBIG2_SEVERITY_DEBUG , segment -> number , "gbat[%d] = %d" , i , params -> gbat [ i ] ) ; } jbig2_error ( ctx , JBIG2_SEVERITY_WARNING , segment -> number , "decode_generic_region: MMR=%d, GBTEMPLATE=%d NYI" , params -> MMR , params -> GBTEMPLATE ) ; return - 1 ; }
576
0
static gboolean destroy_srcdsc ( gpointer k _U_ , gpointer v , gpointer p _U_ ) { k12_src_desc_t * rec = ( k12_src_desc_t * ) v ; g_free ( rec -> input_name ) ; g_free ( rec -> stack_file ) ; g_free ( rec ) ; return TRUE ; }
static gboolean destroy_srcdsc ( gpointer k _U_ , gpointer v , gpointer p _U_ ) { k12_src_desc_t * rec = ( k12_src_desc_t * ) v ; g_free ( rec -> input_name ) ; g_free ( rec -> stack_file ) ; g_free ( rec ) ; return TRUE ; }
577
1
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (!sctp_auth_enable) return -EACCES; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } if (authkey->sca_keylength > optlen) { ret = -EINVAL; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (!sctp_auth_enable) return -EACCES; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } if (authkey->sca_keylength > optlen) { ret = -EINVAL; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
578
0
void nonono(const char* file, int line, const char* msg) { fprintf(stderr, "Nonono! %s:%d %s\n", file, line, msg); exit(-5); }
void nonono(const char* file, int line, const char* msg) { fprintf(stderr, "Nonono! %s:%d %s\n", file, line, msg); exit(-5); }
579
0
CString CZNC::FixupEncoding(const CString& sEncoding) const { if (!m_uiForceEncoding) { return sEncoding; } if (sEncoding.empty()) { return "UTF-8"; } const char* sRealEncoding = sEncoding.c_str(); if (sEncoding[0] == '*' || sEncoding[0] == '^') { sRealEncoding++; } if (!*sRealEncoding) { return "UTF-8"; } #ifdef HAVE_ICU UErrorCode e = U_ZERO_ERROR; UConverter* cnv = ucnv_open(sRealEncoding, &e); if (cnv) { ucnv_close(cnv); } if (U_FAILURE(e)) { return "UTF-8"; } #endif return sEncoding; }
CString CZNC::FixupEncoding(const CString& sEncoding) const { if (!m_uiForceEncoding) { return sEncoding; } if (sEncoding.empty()) { return "UTF-8"; } const char* sRealEncoding = sEncoding.c_str(); if (sEncoding[0] == '*' || sEncoding[0] == '^') { sRealEncoding++; } if (!*sRealEncoding) { return "UTF-8"; } #ifdef HAVE_ICU UErrorCode e = U_ZERO_ERROR; UConverter* cnv = ucnv_open(sRealEncoding, &e); if (cnv) { ucnv_close(cnv); } if (U_FAILURE(e)) { return "UTF-8"; } #endif return sEncoding; }
580
0
int proto_get_first_protocol ( void * * cookie ) { protocol_t * protocol ; if ( protocols == NULL ) return - 1 ; * cookie = protocols ; protocol = ( protocol_t * ) protocols -> data ; return protocol -> proto_id ; }
int proto_get_first_protocol ( void * * cookie ) { protocol_t * protocol ; if ( protocols == NULL ) return - 1 ; * cookie = protocols ; protocol = ( protocol_t * ) protocols -> data ; return protocol -> proto_id ; }
581
0
static void spitz_i2c_setup(PXA2xxState *cpu) { /* Attach the CPU on one end of our I2C bus. */ i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]); #ifdef HAS_AUDIO DeviceState *wm; /* Attach a WM8750 to the bus */ wm = i2c_create_slave(bus, "wm8750", 0); spitz_wm8750_addr(wm, 0, 0); pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM, qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]); /* .. and to the sound interface. */ cpu->i2s->opaque = wm; cpu->i2s->codec_out = wm8750_dac_dat; cpu->i2s->codec_in = wm8750_adc_dat; wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s); #endif }
static void spitz_i2c_setup(PXA2xxState *cpu) { i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]); #ifdef HAS_AUDIO DeviceState *wm; wm = i2c_create_slave(bus, "wm8750", 0); spitz_wm8750_addr(wm, 0, 0); pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM, qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]); cpu->i2s->opaque = wm; cpu->i2s->codec_out = wm8750_dac_dat; cpu->i2s->codec_in = wm8750_adc_dat; wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s); #endif }
582
1
CString CZNC::FixupEncoding(const CString& sEncoding) const { if (sEncoding.empty() && m_uiForceEncoding) { return "UTF-8"; } return sEncoding; }
CString CZNC::FixupEncoding(const CString& sEncoding) const { if (sEncoding.empty() && m_uiForceEncoding) { return "UTF-8"; } return sEncoding; }
584
1
static void syscall_vma_close(struct vm_area_struct *vma) { }
static void syscall_vma_close(struct vm_area_struct *vma) { }
585
0
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) { OutputStream *ost = ofilter->ost; AVCodecContext *codec = ost->st->codec; AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; char *sample_fmts, *sample_rates, *channel_layouts; char name[255]; int ret; snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("ffabuffersink"), name, NULL, NULL, fg->graph); if (ret < 0) return ret; #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \ AVFilterContext *filt_ctx; \ \ av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \ "similarly to -af " filter_name "=%s.\n", arg); \ \ ret = avfilter_graph_create_filter(&filt_ctx, \ avfilter_get_by_name(filter_name), \ filter_name, arg, NULL, fg->graph); \ if (ret < 0) \ return ret; \ \ ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \ if (ret < 0) \ return ret; \ \ last_filter = filt_ctx; \ pad_idx = 0; \ } while (0) if (ost->audio_channels_mapped) { int i; AVBPrint pan_buf; av_bprint_init(&pan_buf, 256, 8192); av_bprintf(&pan_buf, "0x%"PRIx64, av_get_default_channel_layout(ost->audio_channels_mapped)); for (i = 0; i < ost->audio_channels_mapped; i++) if (ost->audio_channels_map[i] != -1) av_bprintf(&pan_buf, ":c%d=c%d", i, ost->audio_channels_map[i]); AUTO_INSERT_FILTER("-map_channel", "pan", pan_buf.str); av_bprint_finalize(&pan_buf, NULL); } if (codec->channels && !codec->channel_layout) codec->channel_layout = av_get_default_channel_layout(codec->channels); sample_fmts = choose_sample_fmts(ost); sample_rates = choose_sample_rates(ost); channel_layouts = choose_channel_layouts(ost); if (sample_fmts || sample_rates || channel_layouts) { AVFilterContext *format; char args[256]; int len = 0; if (sample_fmts) len += snprintf(args + len, sizeof(args) - len, "sample_fmts=%s:", sample_fmts); if (sample_rates) len += snprintf(args + len, sizeof(args) - len, "sample_rates=%s:", sample_rates); if (channel_layouts) len += snprintf(args + len, sizeof(args) - len, "channel_layouts=%s:", channel_layouts); args[len - 1] = 0; av_freep(&sample_fmts); av_freep(&sample_rates); av_freep(&channel_layouts); snprintf(name, sizeof(name), "audio format for output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&format, avfilter_get_by_name("aformat"), name, args, NULL, fg->graph); if (ret < 0) return ret; ret = avfilter_link(last_filter, pad_idx, format, 0); if (ret < 0) return ret; last_filter = format; pad_idx = 0; } if (audio_volume != 256 && 0) { char args[256]; snprintf(args, sizeof(args), "%f", audio_volume / 256.); AUTO_INSERT_FILTER("-vol", "volume", args); } if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0) return ret; return 0; }
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) { OutputStream *ost = ofilter->ost; AVCodecContext *codec = ost->st->codec; AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; char *sample_fmts, *sample_rates, *channel_layouts; char name[255]; int ret; snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("ffabuffersink"), name, NULL, NULL, fg->graph); if (ret < 0) return ret; #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \ AVFilterContext *filt_ctx; \ \ av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \ "similarly to -af " filter_name "=%s.\n", arg); \ \ ret = avfilter_graph_create_filter(&filt_ctx, \ avfilter_get_by_name(filter_name), \ filter_name, arg, NULL, fg->graph); \ if (ret < 0) \ return ret; \ \ ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \ if (ret < 0) \ return ret; \ \ last_filter = filt_ctx; \ pad_idx = 0; \ } while (0) if (ost->audio_channels_mapped) { int i; AVBPrint pan_buf; av_bprint_init(&pan_buf, 256, 8192); av_bprintf(&pan_buf, "0x%"PRIx64, av_get_default_channel_layout(ost->audio_channels_mapped)); for (i = 0; i < ost->audio_channels_mapped; i++) if (ost->audio_channels_map[i] != -1) av_bprintf(&pan_buf, ":c%d=c%d", i, ost->audio_channels_map[i]); AUTO_INSERT_FILTER("-map_channel", "pan", pan_buf.str); av_bprint_finalize(&pan_buf, NULL); } if (codec->channels && !codec->channel_layout) codec->channel_layout = av_get_default_channel_layout(codec->channels); sample_fmts = choose_sample_fmts(ost); sample_rates = choose_sample_rates(ost); channel_layouts = choose_channel_layouts(ost); if (sample_fmts || sample_rates || channel_layouts) { AVFilterContext *format; char args[256]; int len = 0; if (sample_fmts) len += snprintf(args + len, sizeof(args) - len, "sample_fmts=%s:", sample_fmts); if (sample_rates) len += snprintf(args + len, sizeof(args) - len, "sample_rates=%s:", sample_rates); if (channel_layouts) len += snprintf(args + len, sizeof(args) - len, "channel_layouts=%s:", channel_layouts); args[len - 1] = 0; av_freep(&sample_fmts); av_freep(&sample_rates); av_freep(&channel_layouts); snprintf(name, sizeof(name), "audio format for output stream %d:%d", ost->file_index, ost->index); ret = avfilter_graph_create_filter(&format, avfilter_get_by_name("aformat"), name, args, NULL, fg->graph); if (ret < 0) return ret; ret = avfilter_link(last_filter, pad_idx, format, 0); if (ret < 0) return ret; last_filter = format; pad_idx = 0; } if (audio_volume != 256 && 0) { char args[256]; snprintf(args, sizeof(args), "%f", audio_volume / 256.); AUTO_INSERT_FILTER("-vol", "volume", args); } if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0) return ret; return 0; }
586
1
void CZNC::ForceEncoding() { m_uiForceEncoding++; #ifdef HAVE_ICU for (Csock* pSock : GetManager()) { if (pSock->GetEncoding().empty()) { pSock->SetEncoding("UTF-8"); } } #endif }
void CZNC::ForceEncoding() { m_uiForceEncoding++; #ifdef HAVE_ICU for (Csock* pSock : GetManager()) { if (pSock->GetEncoding().empty()) { pSock->SetEncoding("UTF-8"); } } #endif }
587
0
static ossl_inline int sk_ ## t1 ## _unshift ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_unshift ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline t2 * sk_ ## t1 ## _pop ( STACK_OF ( t1 ) * sk ) { return ( t2 * ) OPENSSL_sk_pop ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline t2 * sk_ ## t1 ## _shift ( STACK_OF ( t1 ) * sk ) { return ( t2 * ) OPENSSL_sk_shift ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) { OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ; } static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) { return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ; } static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) { return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) { OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) { return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ; } static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) { return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ; } static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) { return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ; } static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) { return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ; } # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ; typedef const char * OPENSSL_CSTRING ; DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char )
static ossl_inline int sk_ ## t1 ## _unshift ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_unshift ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline t2 * sk_ ## t1 ## _pop ( STACK_OF ( t1 ) * sk ) { return ( t2 * ) OPENSSL_sk_pop ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline t2 * sk_ ## t1 ## _shift ( STACK_OF ( t1 ) * sk ) { return ( t2 * ) OPENSSL_sk_shift ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) { OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ; } static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) { return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ; } static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) { return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) { OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) { return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ; } static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) { return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ; } static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) { return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ; } static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) { return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ; } # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ; typedef const char * OPENSSL_CSTRING ; DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char )
588
1
static struct page *syscall_nopage(struct vm_area_struct *vma, unsigned long adr, int *type) { struct page *p = virt_to_page(adr - vma->vm_start + syscall_page); get_page(p); return p; }
static struct page *syscall_nopage(struct vm_area_struct *vma, unsigned long adr, int *type) { struct page *p = virt_to_page(adr - vma->vm_start + syscall_page); get_page(p); return p; }
590
0
void restore_boot_order(void *opaque) { char *normal_boot_order = opaque; static int first = 1; /* Restore boot order and remove ourselves after the first boot */ if (first) { first = 0; return; } qemu_boot_set(normal_boot_order); qemu_unregister_reset(restore_boot_order, normal_boot_order); g_free(normal_boot_order); }
void restore_boot_order(void *opaque) { char *normal_boot_order = opaque; static int first = 1; if (first) { first = 0; return; } qemu_boot_set(normal_boot_order); qemu_unregister_reset(restore_boot_order, normal_boot_order); g_free(normal_boot_order); }
591
0
void CZNC::ForceEncoding() { m_uiForceEncoding++; #ifdef HAVE_ICU for (Csock* pSock : GetManager()) { pSock->SetEncoding(FixupEncoding(pSock->GetEncoding())); } #endif }
void CZNC::ForceEncoding() { m_uiForceEncoding++; #ifdef HAVE_ICU for (Csock* pSock : GetManager()) { pSock->SetEncoding(FixupEncoding(pSock->GetEncoding())); } #endif }
592
1
int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack) { struct vm_area_struct *vma; struct mm_struct *mm = current->mm; unsigned long addr; int ret; down_write(&mm->mmap_sem); addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0); if (IS_ERR_VALUE(addr)) { ret = addr; goto up_fail; } vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); if (!vma) { ret = -ENOMEM; goto up_fail; } vma->vm_start = addr; vma->vm_end = addr + PAGE_SIZE; /* MAYWRITE to allow gdb to COW and set breakpoints */ vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE; /* * Make sure the vDSO gets into every core dump. * Dumping its contents makes post-mortem fully interpretable later * without matching up the same kernel and hardware config to see * what PC values meant. */ vma->vm_flags |= VM_ALWAYSDUMP; vma->vm_flags |= mm->def_flags; vma->vm_page_prot = protection_map[vma->vm_flags & 7]; vma->vm_ops = &syscall_vm_ops; vma->vm_mm = mm; ret = insert_vm_struct(mm, vma); if (unlikely(ret)) { kmem_cache_free(vm_area_cachep, vma); goto up_fail; } current->mm->context.vdso = (void *)addr; current_thread_info()->sysenter_return = (void *)VDSO_SYM(&SYSENTER_RETURN); mm->total_vm++; up_fail: up_write(&mm->mmap_sem); return ret; }
int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack) { struct vm_area_struct *vma; struct mm_struct *mm = current->mm; unsigned long addr; int ret; down_write(&mm->mmap_sem); addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0); if (IS_ERR_VALUE(addr)) { ret = addr; goto up_fail; } vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); if (!vma) { ret = -ENOMEM; goto up_fail; } vma->vm_start = addr; vma->vm_end = addr + PAGE_SIZE; vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE; vma->vm_flags |= VM_ALWAYSDUMP; vma->vm_flags |= mm->def_flags; vma->vm_page_prot = protection_map[vma->vm_flags & 7]; vma->vm_ops = &syscall_vm_ops; vma->vm_mm = mm; ret = insert_vm_struct(mm, vma); if (unlikely(ret)) { kmem_cache_free(vm_area_cachep, vma); goto up_fail; } current->mm->context.vdso = (void *)addr; current_thread_info()->sysenter_return = (void *)VDSO_SYM(&SYSENTER_RETURN); mm->total_vm++; up_fail: up_write(&mm->mmap_sem); return ret; }
594
0
static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) { VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev); VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev, base); VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qdev->parent_bus); int ret, max_nr_ports; bool plugging_port0; port->vser = bus->vser; port->bh = qemu_bh_new(flush_queued_data_bh, port); /* * Is the first console port we're seeing? If so, put it up at * location 0. This is done for backward compatibility (old * kernel, new qemu). */ plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0); if (find_port_by_id(port->vser, port->id)) { error_report("virtio-serial-bus: A port already exists at id %u\n", port->id); return -1; } if (port->id == VIRTIO_CONSOLE_BAD_ID) { if (plugging_port0) { port->id = 0; } else { port->id = find_free_port_id(port->vser); if (port->id == VIRTIO_CONSOLE_BAD_ID) { error_report("virtio-serial-bus: Maximum port limit for this device reached\n"); return -1; } } } max_nr_ports = tswap32(port->vser->config.max_nr_ports); if (port->id >= max_nr_ports) { error_report("virtio-serial-bus: Out-of-range port id specified, max. allowed: %u\n", max_nr_ports - 1); return -1; } port->info = info; ret = info->init(port); if (ret) { return ret; } if (!use_multiport(port->vser)) { /* * Allow writes to guest in this case; we have no way of * knowing if a guest port is connected. */ port->guest_connected = true; } port->elem.out_num = 0; QTAILQ_INSERT_TAIL(&port->vser->ports, port, next); port->ivq = port->vser->ivqs[port->id]; port->ovq = port->vser->ovqs[port->id]; add_port(port->vser, port->id); /* Send an update to the guest about this new port added */ virtio_notify_config(&port->vser->vdev); return ret; }
static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) { VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev); VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev, base); VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qdev->parent_bus); int ret, max_nr_ports; bool plugging_port0; port->vser = bus->vser; port->bh = qemu_bh_new(flush_queued_data_bh, port); plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0); if (find_port_by_id(port->vser, port->id)) { error_report("virtio-serial-bus: A port already exists at id %u\n", port->id); return -1; } if (port->id == VIRTIO_CONSOLE_BAD_ID) { if (plugging_port0) { port->id = 0; } else { port->id = find_free_port_id(port->vser); if (port->id == VIRTIO_CONSOLE_BAD_ID) { error_report("virtio-serial-bus: Maximum port limit for this device reached\n"); return -1; } } } max_nr_ports = tswap32(port->vser->config.max_nr_ports); if (port->id >= max_nr_ports) { error_report("virtio-serial-bus: Out-of-range port id specified, max. allowed: %u\n", max_nr_ports - 1); return -1; } port->info = info; ret = info->init(port); if (ret) { return ret; } if (!use_multiport(port->vser)) { port->guest_connected = true; } port->elem.out_num = 0; QTAILQ_INSERT_TAIL(&port->vser->ports, port, next); port->ivq = port->vser->ivqs[port->id]; port->ovq = port->vser->ovqs[port->id]; add_port(port->vser, port->id); virtio_notify_config(&port->vser->vdev); return ret; }
595
0
int gs_pop_string ( gs_main_instance * minst , gs_string * result ) { i_ctx_t * i_ctx_p = minst -> i_ctx_p ; ref vref ; int code = pop_value ( i_ctx_p , & vref ) ; if ( code < 0 ) return code ; switch ( r_type ( & vref ) ) { case t_name : name_string_ref ( minst -> heap , & vref , & vref ) ; code = 1 ; goto rstr ; case t_string : code = ( r_has_attr ( & vref , a_write ) ? 0 : 1 ) ; rstr : result -> data = vref . value . bytes ; result -> size = r_size ( & vref ) ; break ; default : return_error ( gs_error_typecheck ) ; } ref_stack_pop ( & o_stack , 1 ) ; return code ; }
int gs_pop_string ( gs_main_instance * minst , gs_string * result ) { i_ctx_t * i_ctx_p = minst -> i_ctx_p ; ref vref ; int code = pop_value ( i_ctx_p , & vref ) ; if ( code < 0 ) return code ; switch ( r_type ( & vref ) ) { case t_name : name_string_ref ( minst -> heap , & vref , & vref ) ; code = 1 ; goto rstr ; case t_string : code = ( r_has_attr ( & vref , a_write ) ? 0 : 1 ) ; rstr : result -> data = vref . value . bytes ; result -> size = r_size ( & vref ) ; break ; default : return_error ( gs_error_typecheck ) ; } ref_stack_pop ( & o_stack , 1 ) ; return code ; }
596
1
sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) { struct net_local *nl = (struct net_local *) dev->priv; struct sbni_flags flags; int error = 0; #ifdef CONFIG_SBNI_MULTILINE struct net_device *slave_dev; char slave_name[ 8 ]; #endif switch( cmd ) { case SIOCDEVGETINSTATS : if (copy_to_user( ifr->ifr_data, &nl->in_stats, sizeof(struct sbni_in_stats) )) error = -EFAULT; break; case SIOCDEVRESINSTATS : if( current->euid != 0 ) /* root only */ return -EPERM; memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) ); break; case SIOCDEVGHWSTATE : flags.mac_addr = *(u32 *)(dev->dev_addr + 3); flags.rate = nl->csr1.rate; flags.slow_mode = (nl->state & FL_SLOW_MODE) != 0; flags.rxl = nl->cur_rxl_index; flags.fixed_rxl = nl->delta_rxl == 0; if (copy_to_user( ifr->ifr_data, &flags, sizeof flags )) error = -EFAULT; break; case SIOCDEVSHWSTATE : if( current->euid != 0 ) /* root only */ return -EPERM; spin_lock( &nl->lock ); flags = *(struct sbni_flags*) &ifr->ifr_ifru; if( flags.fixed_rxl ) nl->delta_rxl = 0, nl->cur_rxl_index = flags.rxl; else nl->delta_rxl = DEF_RXL_DELTA, nl->cur_rxl_index = DEF_RXL; nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ]; nl->csr1.rate = flags.rate; outb( *(u8 *)&nl->csr1 | PR_RES, dev->base_addr + CSR1 ); spin_unlock( &nl->lock ); break; #ifdef CONFIG_SBNI_MULTILINE case SIOCDEVENSLAVE : if( current->euid != 0 ) /* root only */ return -EPERM; if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name )) return -EFAULT; slave_dev = dev_get_by_name(&init_net, slave_name ); if( !slave_dev || !(slave_dev->flags & IFF_UP) ) { printk( KERN_ERR "%s: trying to enslave non-active " "device %s\n", dev->name, slave_name ); return -EPERM; } return enslave( dev, slave_dev ); case SIOCDEVEMANSIPATE : if( current->euid != 0 ) /* root only */ return -EPERM; return emancipate( dev ); #endif /* CONFIG_SBNI_MULTILINE */ default : return -EOPNOTSUPP; } return error; }
sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) { struct net_local *nl = (struct net_local *) dev->priv; struct sbni_flags flags; int error = 0; #ifdef CONFIG_SBNI_MULTILINE struct net_device *slave_dev; char slave_name[ 8 ]; #endif switch( cmd ) { case SIOCDEVGETINSTATS : if (copy_to_user( ifr->ifr_data, &nl->in_stats, sizeof(struct sbni_in_stats) )) error = -EFAULT; break; case SIOCDEVRESINSTATS : if( current->euid != 0 ) return -EPERM; memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) ); break; case SIOCDEVGHWSTATE : flags.mac_addr = *(u32 *)(dev->dev_addr + 3); flags.rate = nl->csr1.rate; flags.slow_mode = (nl->state & FL_SLOW_MODE) != 0; flags.rxl = nl->cur_rxl_index; flags.fixed_rxl = nl->delta_rxl == 0; if (copy_to_user( ifr->ifr_data, &flags, sizeof flags )) error = -EFAULT; break; case SIOCDEVSHWSTATE : if( current->euid != 0 ) return -EPERM; spin_lock( &nl->lock ); flags = *(struct sbni_flags*) &ifr->ifr_ifru; if( flags.fixed_rxl ) nl->delta_rxl = 0, nl->cur_rxl_index = flags.rxl; else nl->delta_rxl = DEF_RXL_DELTA, nl->cur_rxl_index = DEF_RXL; nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ]; nl->csr1.rate = flags.rate; outb( *(u8 *)&nl->csr1 | PR_RES, dev->base_addr + CSR1 ); spin_unlock( &nl->lock ); break; #ifdef CONFIG_SBNI_MULTILINE case SIOCDEVENSLAVE : if( current->euid != 0 ) return -EPERM; if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name )) return -EFAULT; slave_dev = dev_get_by_name(&init_net, slave_name ); if( !slave_dev || !(slave_dev->flags & IFF_UP) ) { printk( KERN_ERR "%s: trying to enslave non-active " "device %s\n", dev->name, slave_name ); return -EPERM; } return enslave( dev, slave_dev ); case SIOCDEVEMANSIPATE : if( current->euid != 0 ) return -EPERM; return emancipate( dev ); #endif default : return -EOPNOTSUPP; } return error; }
597
0
static call_list * call_list_append ( call_list * list , guint16 scallno ) { call_list * node = wmem_new0 ( wmem_packet_scope ( ) , call_list ) ; node -> scallno = scallno ; if ( list ) { call_list * cur = list ; while ( cur -> next ) { cur = cur -> next ; } cur -> next = node ; return list ; } else { return node ; } }
static call_list * call_list_append ( call_list * list , guint16 scallno ) { call_list * node = wmem_new0 ( wmem_packet_scope ( ) , call_list ) ; node -> scallno = scallno ; if ( list ) { call_list * cur = list ; while ( cur -> next ) { cur = cur -> next ; } cur -> next = node ; return list ; } else { return node ; } }
599
1
direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, const struct iovec *iov, loff_t offset, unsigned long nr_segs, unsigned blkbits, get_block_t get_block, dio_iodone_t end_io, struct dio *dio) { unsigned long user_addr; unsigned long flags; int seg; ssize_t ret = 0; ssize_t ret2; size_t bytes; dio->bio = NULL; dio->inode = inode; dio->rw = rw; dio->blkbits = blkbits; dio->blkfactor = inode->i_blkbits - blkbits; dio->start_zero_done = 0; dio->size = 0; dio->block_in_file = offset >> blkbits; dio->blocks_available = 0; dio->cur_page = NULL; dio->boundary = 0; dio->reap_counter = 0; dio->get_block = get_block; dio->end_io = end_io; dio->map_bh.b_private = NULL; dio->map_bh.b_state = 0; dio->final_block_in_bio = -1; dio->next_block_for_io = -1; dio->page_errors = 0; dio->io_error = 0; dio->result = 0; dio->iocb = iocb; dio->i_size = i_size_read(inode); spin_lock_init(&dio->bio_lock); dio->refcount = 1; dio->bio_list = NULL; dio->waiter = NULL; /* * In case of non-aligned buffers, we may need 2 more * pages since we need to zero out first and last block. */ if (unlikely(dio->blkfactor)) dio->pages_in_io = 2; else dio->pages_in_io = 0; for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; dio->pages_in_io += ((user_addr+iov[seg].iov_len +PAGE_SIZE-1)/PAGE_SIZE - user_addr/PAGE_SIZE); } for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; dio->size += bytes = iov[seg].iov_len; /* Index into the first page of the first block */ dio->first_block_in_page = (user_addr & ~PAGE_MASK) >> blkbits; dio->final_block_in_request = dio->block_in_file + (bytes >> blkbits); /* Page fetching state */ dio->head = 0; dio->tail = 0; dio->curr_page = 0; dio->total_pages = 0; if (user_addr & (PAGE_SIZE-1)) { dio->total_pages++; bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1)); } dio->total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE; dio->curr_user_address = user_addr; ret = do_direct_IO(dio); dio->result += iov[seg].iov_len - ((dio->final_block_in_request - dio->block_in_file) << blkbits); if (ret) { dio_cleanup(dio); break; } } /* end iovec loop */ if (ret == -ENOTBLK && (rw & WRITE)) { /* * The remaining part of the request will be * be handled by buffered I/O when we return */ ret = 0; } /* * There may be some unwritten disk at the end of a part-written * fs-block-sized block. Go zero that now. */ dio_zero_block(dio, 1); if (dio->cur_page) { ret2 = dio_send_cur_page(dio); if (ret == 0) ret = ret2; page_cache_release(dio->cur_page); dio->cur_page = NULL; } if (dio->bio) dio_bio_submit(dio); /* All IO is now issued, send it on its way */ blk_run_address_space(inode->i_mapping); /* * It is possible that, we return short IO due to end of file. * In that case, we need to release all the pages we got hold on. */ dio_cleanup(dio); /* * All block lookups have been performed. For READ requests * we can let i_mutex go now that its achieved its purpose * of protecting us from looking up uninitialized blocks. */ if ((rw == READ) && (dio->lock_type == DIO_LOCKING)) mutex_unlock(&dio->inode->i_mutex); /* * The only time we want to leave bios in flight is when a successful * partial aio read or full aio write have been setup. In that case * bio completion will call aio_complete. The only time it's safe to * call aio_complete is when we return -EIOCBQUEUED, so we key on that. * This had *better* be the only place that raises -EIOCBQUEUED. */ BUG_ON(ret == -EIOCBQUEUED); if (dio->is_async && ret == 0 && dio->result && ((rw & READ) || (dio->result == dio->size))) ret = -EIOCBQUEUED; if (ret != -EIOCBQUEUED) dio_await_completion(dio); /* * Sync will always be dropping the final ref and completing the * operation. AIO can if it was a broken operation described above or * in fact if all the bios race to complete before we get here. In * that case dio_complete() translates the EIOCBQUEUED into the proper * return code that the caller will hand to aio_complete(). * * This is managed by the bio_lock instead of being an atomic_t so that * completion paths can drop their ref and use the remaining count to * decide to wake the submission path atomically. */ spin_lock_irqsave(&dio->bio_lock, flags); ret2 = --dio->refcount; spin_unlock_irqrestore(&dio->bio_lock, flags); if (ret2 == 0) { ret = dio_complete(dio, offset, ret); kfree(dio); } else BUG_ON(ret != -EIOCBQUEUED); return ret; }
direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, const struct iovec *iov, loff_t offset, unsigned long nr_segs, unsigned blkbits, get_block_t get_block, dio_iodone_t end_io, struct dio *dio) { unsigned long user_addr; unsigned long flags; int seg; ssize_t ret = 0; ssize_t ret2; size_t bytes; dio->bio = NULL; dio->inode = inode; dio->rw = rw; dio->blkbits = blkbits; dio->blkfactor = inode->i_blkbits - blkbits; dio->start_zero_done = 0; dio->size = 0; dio->block_in_file = offset >> blkbits; dio->blocks_available = 0; dio->cur_page = NULL; dio->boundary = 0; dio->reap_counter = 0; dio->get_block = get_block; dio->end_io = end_io; dio->map_bh.b_private = NULL; dio->map_bh.b_state = 0; dio->final_block_in_bio = -1; dio->next_block_for_io = -1; dio->page_errors = 0; dio->io_error = 0; dio->result = 0; dio->iocb = iocb; dio->i_size = i_size_read(inode); spin_lock_init(&dio->bio_lock); dio->refcount = 1; dio->bio_list = NULL; dio->waiter = NULL; if (unlikely(dio->blkfactor)) dio->pages_in_io = 2; else dio->pages_in_io = 0; for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; dio->pages_in_io += ((user_addr+iov[seg].iov_len +PAGE_SIZE-1)/PAGE_SIZE - user_addr/PAGE_SIZE); } for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; dio->size += bytes = iov[seg].iov_len; dio->first_block_in_page = (user_addr & ~PAGE_MASK) >> blkbits; dio->final_block_in_request = dio->block_in_file + (bytes >> blkbits); dio->head = 0; dio->tail = 0; dio->curr_page = 0; dio->total_pages = 0; if (user_addr & (PAGE_SIZE-1)) { dio->total_pages++; bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1)); } dio->total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE; dio->curr_user_address = user_addr; ret = do_direct_IO(dio); dio->result += iov[seg].iov_len - ((dio->final_block_in_request - dio->block_in_file) << blkbits); if (ret) { dio_cleanup(dio); break; } } if (ret == -ENOTBLK && (rw & WRITE)) { ret = 0; } dio_zero_block(dio, 1); if (dio->cur_page) { ret2 = dio_send_cur_page(dio); if (ret == 0) ret = ret2; page_cache_release(dio->cur_page); dio->cur_page = NULL; } if (dio->bio) dio_bio_submit(dio); blk_run_address_space(inode->i_mapping); dio_cleanup(dio); if ((rw == READ) && (dio->lock_type == DIO_LOCKING)) mutex_unlock(&dio->inode->i_mutex); BUG_ON(ret == -EIOCBQUEUED); if (dio->is_async && ret == 0 && dio->result && ((rw & READ) || (dio->result == dio->size))) ret = -EIOCBQUEUED; if (ret != -EIOCBQUEUED) dio_await_completion(dio); spin_lock_irqsave(&dio->bio_lock, flags); ret2 = --dio->refcount; spin_unlock_irqrestore(&dio->bio_lock, flags); if (ret2 == 0) { ret = dio_complete(dio, offset, ret); kfree(dio); } else BUG_ON(ret != -EIOCBQUEUED); return ret; }
602
1
ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, CModInfo& Info, CString& sRetMsg) { // Some sane defaults in case anything errors out below sRetMsg.clear(); for (unsigned int a = 0; a < sModule.length(); a++) { if (((sModule[a] < '0') || (sModule[a] > '9')) && ((sModule[a] < 'a') || (sModule[a] > 'z')) && ((sModule[a] < 'A') || (sModule[a] > 'Z')) && (sModule[a] != '_')) { sRetMsg = t_f("Module names can only contain letters, numbers and " "underscores, [{1}] is invalid")(sModule); return nullptr; } } // The second argument to dlopen() has a long history. It seems clear // that (despite what the man page says) we must include either of // RTLD_NOW and RTLD_LAZY and either of RTLD_GLOBAL and RTLD_LOCAL. // // RTLD_NOW vs. RTLD_LAZY: We use RTLD_NOW to avoid ZNC dying due to // failed symbol lookups later on. Doesn't really seem to have much of a // performance impact. // // RTLD_GLOBAL vs. RTLD_LOCAL: If perl is loaded with RTLD_LOCAL and later // on loads own modules (which it apparently does with RTLD_LAZY), we will // die in a name lookup since one of perl's symbols isn't found. That's // worse than any theoretical issue with RTLD_GLOBAL. ModHandle p = dlopen((sModPath).c_str(), RTLD_NOW | RTLD_GLOBAL); if (!p) { // dlerror() returns pointer to static buffer, which may be overwritten // very soon with another dl call also it may just return null. const char* cDlError = dlerror(); CString sDlError = cDlError ? cDlError : t_s("Unknown error"); sRetMsg = t_f("Unable to open module {1}: {2}")(sModule, sDlError); return nullptr; } const CModuleEntry* (*fpZNCModuleEntry)() = nullptr; // man dlsym(3) explains this *reinterpret_cast<void**>(&fpZNCModuleEntry) = dlsym(p, "ZNCModuleEntry"); if (!fpZNCModuleEntry) { dlclose(p); sRetMsg = t_f("Could not find ZNCModuleEntry in module {1}")(sModule); return nullptr; } const CModuleEntry* pModuleEntry = fpZNCModuleEntry(); if (std::strcmp(pModuleEntry->pcVersion, VERSION_STR) || std::strcmp(pModuleEntry->pcVersionExtra, VERSION_EXTRA)) { sRetMsg = t_f( "Version mismatch for module {1}: core is {2}, module is built for " "{3}. Recompile this module.")( sModule, VERSION_STR VERSION_EXTRA, CString(pModuleEntry->pcVersion) + pModuleEntry->pcVersionExtra); dlclose(p); return nullptr; } if (std::strcmp(pModuleEntry->pcCompileOptions, ZNC_COMPILE_OPTIONS_STRING)) { sRetMsg = t_f( "Module {1} is built incompatibly: core is '{2}', module is '{3}'. " "Recompile this module.")(sModule, ZNC_COMPILE_OPTIONS_STRING, pModuleEntry->pcCompileOptions); dlclose(p); return nullptr; } CTranslationDomainRefHolder translation("znc-" + sModule); pModuleEntry->fpFillModInfo(Info); sRetMsg = ""; return p; }
ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, CModInfo& Info, CString& sRetMsg) { sRetMsg.clear(); for (unsigned int a = 0; a < sModule.length(); a++) { if (((sModule[a] < '0') || (sModule[a] > '9')) && ((sModule[a] < 'a') || (sModule[a] > 'z')) && ((sModule[a] < 'A') || (sModule[a] > 'Z')) && (sModule[a] != '_')) { sRetMsg = t_f("Module names can only contain letters, numbers and " "underscores, [{1}] is invalid")(sModule); return nullptr; } } ModHandle p = dlopen((sModPath).c_str(), RTLD_NOW | RTLD_GLOBAL); if (!p) { const char* cDlError = dlerror(); CString sDlError = cDlError ? cDlError : t_s("Unknown error"); sRetMsg = t_f("Unable to open module {1}: {2}")(sModule, sDlError); return nullptr; } const CModuleEntry* (*fpZNCModuleEntry)() = nullptr; *reinterpret_cast<void**>(&fpZNCModuleEntry) = dlsym(p, "ZNCModuleEntry"); if (!fpZNCModuleEntry) { dlclose(p); sRetMsg = t_f("Could not find ZNCModuleEntry in module {1}")(sModule); return nullptr; } const CModuleEntry* pModuleEntry = fpZNCModuleEntry(); if (std::strcmp(pModuleEntry->pcVersion, VERSION_STR) || std::strcmp(pModuleEntry->pcVersionExtra, VERSION_EXTRA)) { sRetMsg = t_f( "Version mismatch for module {1}: core is {2}, module is built for " "{3}. Recompile this module.")( sModule, VERSION_STR VERSION_EXTRA, CString(pModuleEntry->pcVersion) + pModuleEntry->pcVersionExtra); dlclose(p); return nullptr; } if (std::strcmp(pModuleEntry->pcCompileOptions, ZNC_COMPILE_OPTIONS_STRING)) { sRetMsg = t_f( "Module {1} is built incompatibly: core is '{2}', module is '{3}'. " "Recompile this module.")(sModule, ZNC_COMPILE_OPTIONS_STRING, pModuleEntry->pcCompileOptions); dlclose(p); return nullptr; } CTranslationDomainRefHolder translation("znc-" + sModule); pModuleEntry->fpFillModInfo(Info); sRetMsg = ""; return p; }
603
0
static void handle_new_lock_ctx ( struct xml_ctx * ctx , int tag_closed ) { struct remote_lock * lock = ( struct remote_lock * ) ctx -> userData ; git_SHA_CTX sha_ctx ; unsigned char lock_token_sha1 [ 20 ] ; if ( tag_closed && ctx -> cdata ) { if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_OWNER ) ) { lock -> owner = xstrdup ( ctx -> cdata ) ; } else if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_TIMEOUT ) ) { const char * arg ; if ( skip_prefix ( ctx -> cdata , "Second-" , & arg ) ) lock -> timeout = strtol ( arg , NULL , 10 ) ; } else if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_TOKEN ) ) { lock -> token = xstrdup ( ctx -> cdata ) ; git_SHA1_Init ( & sha_ctx ) ; git_SHA1_Update ( & sha_ctx , lock -> token , strlen ( lock -> token ) ) ; git_SHA1_Final ( lock_token_sha1 , & sha_ctx ) ; lock -> tmpfile_suffix [ 0 ] = '_' ; memcpy ( lock -> tmpfile_suffix + 1 , sha1_to_hex ( lock_token_sha1 ) , 40 ) ; } } }
static void handle_new_lock_ctx ( struct xml_ctx * ctx , int tag_closed ) { struct remote_lock * lock = ( struct remote_lock * ) ctx -> userData ; git_SHA_CTX sha_ctx ; unsigned char lock_token_sha1 [ 20 ] ; if ( tag_closed && ctx -> cdata ) { if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_OWNER ) ) { lock -> owner = xstrdup ( ctx -> cdata ) ; } else if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_TIMEOUT ) ) { const char * arg ; if ( skip_prefix ( ctx -> cdata , "Second-" , & arg ) ) lock -> timeout = strtol ( arg , NULL , 10 ) ; } else if ( ! strcmp ( ctx -> name , DAV_ACTIVELOCK_TOKEN ) ) { lock -> token = xstrdup ( ctx -> cdata ) ; git_SHA1_Init ( & sha_ctx ) ; git_SHA1_Update ( & sha_ctx , lock -> token , strlen ( lock -> token ) ) ; git_SHA1_Final ( lock_token_sha1 , & sha_ctx ) ; lock -> tmpfile_suffix [ 0 ] = '_' ; memcpy ( lock -> tmpfile_suffix + 1 , sha1_to_hex ( lock_token_sha1 ) , 40 ) ; } } }
605
0
static int ppc_fixup_cpu(PowerPCCPU *cpu) { CPUPPCState *env = &cpu->env; /* TCG doesn't (yet) emulate some groups of instructions that * are implemented on some otherwise supported CPUs (e.g. VSX * and decimal floating point instructions on POWER7). We * remove unsupported instruction groups from the cpu state's * instruction masks and hope the guest can cope. For at * least the pseries machine, the unavailability of these * instructions can be advertised to the guest via the device * tree. */ if ((env->insns_flags & ~PPC_TCG_INSNS) || (env->insns_flags2 & ~PPC_TCG_INSNS2)) { fprintf(stderr, "Warning: Disabling some instructions which are not " "emulated by TCG (0x%" PRIx64 ", 0x%" PRIx64 ")\n", env->insns_flags & ~PPC_TCG_INSNS, env->insns_flags2 & ~PPC_TCG_INSNS2); } env->insns_flags &= PPC_TCG_INSNS; env->insns_flags2 &= PPC_TCG_INSNS2; return 0; }
static int ppc_fixup_cpu(PowerPCCPU *cpu) { CPUPPCState *env = &cpu->env; if ((env->insns_flags & ~PPC_TCG_INSNS) || (env->insns_flags2 & ~PPC_TCG_INSNS2)) { fprintf(stderr, "Warning: Disabling some instructions which are not " "emulated by TCG (0x%" PRIx64 ", 0x%" PRIx64 ")\n", env->insns_flags & ~PPC_TCG_INSNS, env->insns_flags2 & ~PPC_TCG_INSNS2); } env->insns_flags &= PPC_TCG_INSNS; env->insns_flags2 &= PPC_TCG_INSNS2; return 0; }
606
1
init_state(struct posix_acl_state *state, int cnt) { int alloc; memset(state, 0, sizeof(struct posix_acl_state)); state->empty = 1; /* * In the worst case, each individual acl could be for a distinct * named user or group, but we don't no which, so we allocate * enough space for either: */ alloc = sizeof(struct posix_ace_state_array) + cnt*sizeof(struct posix_ace_state); state->users = kzalloc(alloc, GFP_KERNEL); if (!state->users) return -ENOMEM; state->groups = kzalloc(alloc, GFP_KERNEL); if (!state->groups) { kfree(state->users); return -ENOMEM; } return 0; }
init_state(struct posix_acl_state *state, int cnt) { int alloc; memset(state, 0, sizeof(struct posix_acl_state)); state->empty = 1; alloc = sizeof(struct posix_ace_state_array) + cnt*sizeof(struct posix_ace_state); state->users = kzalloc(alloc, GFP_KERNEL); if (!state->users) return -ENOMEM; state->groups = kzalloc(alloc, GFP_KERNEL); if (!state->groups) { kfree(state->users); return -ENOMEM; } return 0; }
607
1
static int jas_icctxtdesc_input(jas_iccattrval_t *attrval, jas_stream_t *in, int cnt) { int n; int c; jas_icctxtdesc_t *txtdesc = &attrval->data.txtdesc; txtdesc->ascdata = 0; txtdesc->ucdata = 0; if (jas_iccgetuint32(in, &txtdesc->asclen)) goto error; if (!(txtdesc->ascdata = jas_malloc(txtdesc->asclen))) goto error; if (jas_stream_read(in, txtdesc->ascdata, txtdesc->asclen) != JAS_CAST(int, txtdesc->asclen)) goto error; txtdesc->ascdata[txtdesc->asclen - 1] = '\0'; if (jas_iccgetuint32(in, &txtdesc->uclangcode) || jas_iccgetuint32(in, &txtdesc->uclen)) goto error; if (!(txtdesc->ucdata = jas_malloc(txtdesc->uclen * 2))) goto error; if (jas_stream_read(in, txtdesc->ucdata, txtdesc->uclen * 2) != JAS_CAST(int, txtdesc->uclen * 2)) goto error; if (jas_iccgetuint16(in, &txtdesc->sccode)) goto error; if ((c = jas_stream_getc(in)) == EOF) goto error; txtdesc->maclen = c; if (jas_stream_read(in, txtdesc->macdata, 67) != 67) goto error; txtdesc->asclen = strlen(txtdesc->ascdata) + 1; #define WORKAROUND_BAD_PROFILES #ifdef WORKAROUND_BAD_PROFILES n = txtdesc->asclen + txtdesc->uclen * 2 + 15 + 67; if (n > cnt) { return -1; } if (n < cnt) { if (jas_stream_gobble(in, cnt - n) != cnt - n) goto error; } #else if (txtdesc->asclen + txtdesc->uclen * 2 + 15 + 67 != cnt) return -1; #endif return 0; error: jas_icctxtdesc_destroy(attrval); return -1; }
static int jas_icctxtdesc_input(jas_iccattrval_t *attrval, jas_stream_t *in, int cnt) { int n; int c; jas_icctxtdesc_t *txtdesc = &attrval->data.txtdesc; txtdesc->ascdata = 0; txtdesc->ucdata = 0; if (jas_iccgetuint32(in, &txtdesc->asclen)) goto error; if (!(txtdesc->ascdata = jas_malloc(txtdesc->asclen))) goto error; if (jas_stream_read(in, txtdesc->ascdata, txtdesc->asclen) != JAS_CAST(int, txtdesc->asclen)) goto error; txtdesc->ascdata[txtdesc->asclen - 1] = '\0'; if (jas_iccgetuint32(in, &txtdesc->uclangcode) || jas_iccgetuint32(in, &txtdesc->uclen)) goto error; if (!(txtdesc->ucdata = jas_malloc(txtdesc->uclen * 2))) goto error; if (jas_stream_read(in, txtdesc->ucdata, txtdesc->uclen * 2) != JAS_CAST(int, txtdesc->uclen * 2)) goto error; if (jas_iccgetuint16(in, &txtdesc->sccode)) goto error; if ((c = jas_stream_getc(in)) == EOF) goto error; txtdesc->maclen = c; if (jas_stream_read(in, txtdesc->macdata, 67) != 67) goto error; txtdesc->asclen = strlen(txtdesc->ascdata) + 1; #define WORKAROUND_BAD_PROFILES #ifdef WORKAROUND_BAD_PROFILES n = txtdesc->asclen + txtdesc->uclen * 2 + 15 + 67; if (n > cnt) { return -1; } if (n < cnt) { if (jas_stream_gobble(in, cnt - n) != cnt - n) goto error; } #else if (txtdesc->asclen + txtdesc->uclen * 2 + 15 + 67 != cnt) return -1; #endif return 0; error: jas_icctxtdesc_destroy(attrval); return -1; }
608
0
void main_loop_wait(int timeout) { IOHandlerRecord *ioh; fd_set rfds, wfds, xfds; int ret, nfds; struct timeval tv; qemu_bh_update_timeout(&timeout); host_main_loop_wait(&timeout); /* poll any events */ /* XXX: separate device handlers from system ones */ nfds = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { if (ioh->deleted) continue; if (ioh->fd_read && (!ioh->fd_read_poll || ioh->fd_read_poll(ioh->opaque) != 0)) { FD_SET(ioh->fd, &rfds); if (ioh->fd > nfds) nfds = ioh->fd; } if (ioh->fd_write) { FD_SET(ioh->fd, &wfds); if (ioh->fd > nfds) nfds = ioh->fd; } } tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; slirp_select_fill(&nfds, &rfds, &wfds, &xfds); qemu_mutex_unlock_iothread(); ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); qemu_mutex_lock_iothread(); if (ret > 0) { IOHandlerRecord **pioh; for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { if (!ioh->deleted && ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) { ioh->fd_read(ioh->opaque); } if (!ioh->deleted && ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) { ioh->fd_write(ioh->opaque); } } /* remove deleted IO handlers */ pioh = &first_io_handler; while (*pioh) { ioh = *pioh; if (ioh->deleted) { *pioh = ioh->next; qemu_free(ioh); } else pioh = &ioh->next; } } slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0)); /* rearm timer, if not periodic */ if (alarm_timer->flags & ALARM_FLAG_EXPIRED) { alarm_timer->flags &= ~ALARM_FLAG_EXPIRED; qemu_rearm_alarm_timer(alarm_timer); } /* vm time timers */ if (vm_running) { if (!cur_cpu || likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER))) qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], qemu_get_clock(vm_clock)); } /* real time timers */ qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock)); /* Check bottom-halves last in case any of the earlier events triggered them. */ qemu_bh_poll(); }
void main_loop_wait(int timeout) { IOHandlerRecord *ioh; fd_set rfds, wfds, xfds; int ret, nfds; struct timeval tv; qemu_bh_update_timeout(&timeout); host_main_loop_wait(&timeout); nfds = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { if (ioh->deleted) continue; if (ioh->fd_read && (!ioh->fd_read_poll || ioh->fd_read_poll(ioh->opaque) != 0)) { FD_SET(ioh->fd, &rfds); if (ioh->fd > nfds) nfds = ioh->fd; } if (ioh->fd_write) { FD_SET(ioh->fd, &wfds); if (ioh->fd > nfds) nfds = ioh->fd; } } tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; slirp_select_fill(&nfds, &rfds, &wfds, &xfds); qemu_mutex_unlock_iothread(); ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); qemu_mutex_lock_iothread(); if (ret > 0) { IOHandlerRecord **pioh; for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { if (!ioh->deleted && ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) { ioh->fd_read(ioh->opaque); } if (!ioh->deleted && ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) { ioh->fd_write(ioh->opaque); } } pioh = &first_io_handler; while (*pioh) { ioh = *pioh; if (ioh->deleted) { *pioh = ioh->next; qemu_free(ioh); } else pioh = &ioh->next; } } slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0)); if (alarm_timer->flags & ALARM_FLAG_EXPIRED) { alarm_timer->flags &= ~ALARM_FLAG_EXPIRED; qemu_rearm_alarm_timer(alarm_timer); } if (vm_running) { if (!cur_cpu || likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER))) qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], qemu_get_clock(vm_clock)); } qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock)); qemu_bh_poll(); }
609
0
REGRESSION_TEST ( SDK_API_ENCODING ) ( RegressionTest * test , int , int * pstatus ) { const char * url = "http://www.example.com/foo?fie= \"#%<>[]\\^`{ } ~&bar={ test} &fum=Apache Traffic Server" ; const char * url_encoded = "http://www.example.com/foo?fie=%20%22%23%25%3C%3E%5B%5D%5C%5E%60%7B%7D%7E&bar=%7Btest%7D&fum=Apache%20Traffic%20Server" ; const char * url_base64 = "aHR0cDovL3d3dy5leGFtcGxlLmNvbS9mb28/ZmllPSAiIyU8PltdXF5ge31+JmJhcj17dGVzdH0mZnVtPUFwYWNoZSBUcmFmZmljIFNlcnZlcg==" ; const char * url2 = "http://www.example.com/" ; const char * url3 = "https://www.thisisoneexampleofastringoflengtheightyasciilowercasecharacters.com/" ; char buf [ 1024 ] ; size_t length ; bool success = true ; if ( TS_SUCCESS != TSStringPercentEncode ( url , strlen ( url ) , buf , sizeof ( buf ) , & length , nullptr ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase1" , TC_FAIL , "Failed on %s" , url ) ; success = false ; } else { if ( strcmp ( buf , url_encoded ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url_encoded ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase1" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSStringPercentEncode ( url2 , strlen ( url2 ) , buf , sizeof ( buf ) , & length , nullptr ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase2" , TC_FAIL , "Failed on %s" , url2 ) ; success = false ; } else { if ( strcmp ( buf , url2 ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase2" , TC_FAIL , "Failed on %s != %s" , buf , url2 ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase2" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSStringPercentDecode ( url_encoded , strlen ( url_encoded ) , buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase1" , TC_FAIL , "Failed on %s" , url_encoded ) ; success = false ; } else { if ( length != strlen ( url ) || strcmp ( buf , url ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase1" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSStringPercentDecode ( url2 , strlen ( url2 ) , buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase2" , TC_FAIL , "Failed on %s" , url2 ) ; success = false ; } else { if ( length != strlen ( url2 ) || strcmp ( buf , url2 ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase2" , TC_FAIL , "Failed on %s != %s" , buf , url2 ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase2" , TC_PASS , "ok" ) ; } } const size_t buf_len = strlen ( url3 ) + 1 ; strncpy ( buf , url3 , buf_len - 1 ) ; const char canary = 0xFF ; buf [ buf_len - 1 ] = canary ; const char * url3_clipped = "https://www.thisisoneexampleofastringoflengtheightyasciilowercasecharacters.com" ; if ( TS_SUCCESS != TSStringPercentDecode ( buf , buf_len - 1 , buf , buf_len - 1 , & length ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_FAIL , "Failed on %s" , url3 ) ; success = false ; } else { if ( memcmp ( buf + buf_len - 1 , & canary , 1 ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_FAIL , "Failed on %s overwrites buffer" , url3 ) ; success = false ; } else if ( length != strlen ( url3_clipped ) || strcmp ( buf , url3_clipped ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_FAIL , "Failed on %s != %s" , buf , url3_clipped ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSBase64Encode ( url , strlen ( url ) , buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSBase64Encode" , "TestCase1" , TC_FAIL , "Failed on %s" , url ) ; success = false ; } else { if ( length != strlen ( url_base64 ) || strcmp ( buf , url_base64 ) ) { SDK_RPRINT ( test , "TSBase64Encode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url_base64 ) ; success = false ; } else { SDK_RPRINT ( test , "TSBase64Encode" , "TestCase1" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSBase64Decode ( url_base64 , strlen ( url_base64 ) , ( unsigned char * ) buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSBase64Decode" , "TestCase1" , TC_FAIL , "Failed on %s" , url_base64 ) ; success = false ; } else { if ( length != strlen ( url ) || strcmp ( buf , url ) ) { SDK_RPRINT ( test , "TSBase64Decode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url ) ; success = false ; } else { SDK_RPRINT ( test , "TSBase64Decode" , "TestCase1" , TC_PASS , "ok" ) ; } } * pstatus = success ? REGRESSION_TEST_PASSED : REGRESSION_TEST_FAILED ; return ; }
REGRESSION_TEST ( SDK_API_ENCODING ) ( RegressionTest * test , int , int * pstatus ) { const char * url = "http://www.example.com/foo?fie= \"#%<>[]\\^`{ } ~&bar={ test} &fum=Apache Traffic Server" ; const char * url_encoded = "http://www.example.com/foo?fie=%20%22%23%25%3C%3E%5B%5D%5C%5E%60%7B%7D%7E&bar=%7Btest%7D&fum=Apache%20Traffic%20Server" ; const char * url_base64 = "aHR0cDovL3d3dy5leGFtcGxlLmNvbS9mb28/ZmllPSAiIyU8PltdXF5ge31+JmJhcj17dGVzdH0mZnVtPUFwYWNoZSBUcmFmZmljIFNlcnZlcg==" ; const char * url2 = "http://www.example.com/" ; const char * url3 = "https://www.thisisoneexampleofastringoflengtheightyasciilowercasecharacters.com/" ; char buf [ 1024 ] ; size_t length ; bool success = true ; if ( TS_SUCCESS != TSStringPercentEncode ( url , strlen ( url ) , buf , sizeof ( buf ) , & length , nullptr ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase1" , TC_FAIL , "Failed on %s" , url ) ; success = false ; } else { if ( strcmp ( buf , url_encoded ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url_encoded ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase1" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSStringPercentEncode ( url2 , strlen ( url2 ) , buf , sizeof ( buf ) , & length , nullptr ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase2" , TC_FAIL , "Failed on %s" , url2 ) ; success = false ; } else { if ( strcmp ( buf , url2 ) ) { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase2" , TC_FAIL , "Failed on %s != %s" , buf , url2 ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentEncode" , "TestCase2" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSStringPercentDecode ( url_encoded , strlen ( url_encoded ) , buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase1" , TC_FAIL , "Failed on %s" , url_encoded ) ; success = false ; } else { if ( length != strlen ( url ) || strcmp ( buf , url ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase1" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSStringPercentDecode ( url2 , strlen ( url2 ) , buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase2" , TC_FAIL , "Failed on %s" , url2 ) ; success = false ; } else { if ( length != strlen ( url2 ) || strcmp ( buf , url2 ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase2" , TC_FAIL , "Failed on %s != %s" , buf , url2 ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase2" , TC_PASS , "ok" ) ; } } const size_t buf_len = strlen ( url3 ) + 1 ; strncpy ( buf , url3 , buf_len - 1 ) ; const char canary = 0xFF ; buf [ buf_len - 1 ] = canary ; const char * url3_clipped = "https://www.thisisoneexampleofastringoflengtheightyasciilowercasecharacters.com" ; if ( TS_SUCCESS != TSStringPercentDecode ( buf , buf_len - 1 , buf , buf_len - 1 , & length ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_FAIL , "Failed on %s" , url3 ) ; success = false ; } else { if ( memcmp ( buf + buf_len - 1 , & canary , 1 ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_FAIL , "Failed on %s overwrites buffer" , url3 ) ; success = false ; } else if ( length != strlen ( url3_clipped ) || strcmp ( buf , url3_clipped ) ) { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_FAIL , "Failed on %s != %s" , buf , url3_clipped ) ; success = false ; } else { SDK_RPRINT ( test , "TSStringPercentDecode" , "TestCase3" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSBase64Encode ( url , strlen ( url ) , buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSBase64Encode" , "TestCase1" , TC_FAIL , "Failed on %s" , url ) ; success = false ; } else { if ( length != strlen ( url_base64 ) || strcmp ( buf , url_base64 ) ) { SDK_RPRINT ( test , "TSBase64Encode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url_base64 ) ; success = false ; } else { SDK_RPRINT ( test , "TSBase64Encode" , "TestCase1" , TC_PASS , "ok" ) ; } } if ( TS_SUCCESS != TSBase64Decode ( url_base64 , strlen ( url_base64 ) , ( unsigned char * ) buf , sizeof ( buf ) , & length ) ) { SDK_RPRINT ( test , "TSBase64Decode" , "TestCase1" , TC_FAIL , "Failed on %s" , url_base64 ) ; success = false ; } else { if ( length != strlen ( url ) || strcmp ( buf , url ) ) { SDK_RPRINT ( test , "TSBase64Decode" , "TestCase1" , TC_FAIL , "Failed on %s != %s" , buf , url ) ; success = false ; } else { SDK_RPRINT ( test , "TSBase64Decode" , "TestCase1" , TC_PASS , "ok" ) ; } } * pstatus = success ? REGRESSION_TEST_PASSED : REGRESSION_TEST_FAILED ; return ; }
610
1
void jpc_qmfb_split_row(jpc_fix_t *a, int numcols, int parity) { int bufsize = JPC_CEILDIVPOW2(numcols, 1); jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE]; jpc_fix_t *buf = splitbuf; register jpc_fix_t *srcptr; register jpc_fix_t *dstptr; register int n; register int m; int hstartcol; /* Get a buffer. */ if (bufsize > QMFB_SPLITBUFSIZE) { if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) { /* We have no choice but to commit suicide in this case. */ abort(); } } if (numcols >= 2) { hstartcol = (numcols + 1 - parity) >> 1; m = (parity) ? hstartcol : (numcols - hstartcol); /* Save the samples destined for the highpass channel. */ n = m; dstptr = buf; srcptr = &a[1 - parity]; while (n-- > 0) { *dstptr = *srcptr; ++dstptr; srcptr += 2; } /* Copy the appropriate samples into the lowpass channel. */ dstptr = &a[1 - parity]; srcptr = &a[2 - parity]; n = numcols - m - (!parity); while (n-- > 0) { *dstptr = *srcptr; ++dstptr; srcptr += 2; } /* Copy the saved samples into the highpass channel. */ dstptr = &a[hstartcol]; srcptr = buf; n = m; while (n-- > 0) { *dstptr = *srcptr; ++dstptr; ++srcptr; } } /* If the split buffer was allocated on the heap, free this memory. */ if (buf != splitbuf) { jas_free(buf); } }
void jpc_qmfb_split_row(jpc_fix_t *a, int numcols, int parity) { int bufsize = JPC_CEILDIVPOW2(numcols, 1); jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE]; jpc_fix_t *buf = splitbuf; register jpc_fix_t *srcptr; register jpc_fix_t *dstptr; register int n; register int m; int hstartcol; if (bufsize > QMFB_SPLITBUFSIZE) { if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) { abort(); } } if (numcols >= 2) { hstartcol = (numcols + 1 - parity) >> 1; m = (parity) ? hstartcol : (numcols - hstartcol); n = m; dstptr = buf; srcptr = &a[1 - parity]; while (n-- > 0) { *dstptr = *srcptr; ++dstptr; srcptr += 2; } dstptr = &a[1 - parity]; srcptr = &a[2 - parity]; n = numcols - m - (!parity); while (n-- > 0) { *dstptr = *srcptr; ++dstptr; srcptr += 2; } dstptr = &a[hstartcol]; srcptr = buf; n = m; while (n-- > 0) { *dstptr = *srcptr; ++dstptr; ++srcptr; } } if (buf != splitbuf) { jas_free(buf); } }
611
0
av_cold int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", #if 0 "lastIQP", "lastPQP", "lastBQP", "nextNonBQP", #endif "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (* const func1[])(void *, double) = { (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[] = { "bits2qp", "qp2bits", NULL }; emms_c(); res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq ? s->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); return res; } for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; rcc->pred[i].decay = 0.4; rcc->i_cplx_sum [i] = rcc->p_cplx_sum [i] = rcc->mv_bits_sum[i] = rcc->qscale_sum [i] = rcc->frame_count[i] = 1; // 1 is better because of 1/0 and such rcc->last_qscale_for[i] = FF_QP2LAMBDA * 5; } rcc->buffer_index = s->avctx->rc_initial_buffer_occupancy; if (s->avctx->flags & CODEC_FLAG_PASS2) { int i; char *p; /* find number of pics */ p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); i += s->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); rcc->num_entries = i; /* init all to skipped p frames * (with b frames we might have a not encoded frame at the end FIXME) */ for (i = 0; i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; rce->pict_type = rce->new_pict_type = AV_PICTURE_TYPE_P; rce->qscale = rce->new_qscale = FF_QP2LAMBDA * 2; rce->misc_bits = s->mb_num + 10; rce->mb_var_sum = s->mb_num * 100; } /* read stats */ p = s->avctx->stats_in; for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; char *next; next = strchr(p, ';'); if (next) { (*next) = 0; // sscanf in unbelievably slow on looong strings // FIXME copy / do not write next++; } e = sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce = &rcc->entry[picture_number]; e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if (e != 14) { av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p = next; } if (init_pass2(s) < 0) return -1; // FIXME maybe move to end if ((s->avctx->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #if CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if (!(s->avctx->flags & CODEC_FLAG_PASS2)) { rcc->short_term_qsum = 0.001; rcc->short_term_qcount = 0.001; rcc->pass1_rc_eq_output_sum = 0.001; rcc->pass1_wanted_bits = 0.001; if (s->avctx->qblur > 1.0) { av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } /* init stuff with the user specified complexity */ if (s->rc_initial_cplx) { for (i = 0; i < 60 * 30; i++) { double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; if (i % ((s->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; else if (i % (s->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; rce.new_pict_type = rce.pict_type; rce.mc_mb_var_sum = bits * s->mb_num / 100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits = 1; if (s->pict_type == AV_PICTURE_TYPE_I) { rce.i_count = s->mb_num; rce.i_tex_bits = bits; rce.p_tex_bits = 0; rce.mv_bits = 0; } else { rce.i_count = 0; // FIXME we do know this approx rce.i_tex_bits = 0; rce.p_tex_bits = bits * 0.9; rce.mv_bits = bits * 0.1; } rcc->i_cplx_sum[rce.pict_type] += rce.i_tex_bits * rce.qscale; rcc->p_cplx_sum[rce.pict_type] += rce.p_tex_bits * rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type]++; get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); // FIXME misbehaves a little for variable fps rcc->pass1_wanted_bits += s->bit_rate / (1 / av_q2d(s->avctx->time_base)); } } } return 0; }
av_cold int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", #if 0 "lastIQP", "lastPQP", "lastBQP", "nextNonBQP", #endif "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (* const func1[])(void *, double) = { (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[] = { "bits2qp", "qp2bits", NULL }; emms_c(); res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq ? s->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); return res; } for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; rcc->pred[i].decay = 0.4; rcc->i_cplx_sum [i] = rcc->p_cplx_sum [i] = rcc->mv_bits_sum[i] = rcc->qscale_sum [i] = rcc->frame_count[i] = 1;
612
0
static void pxa2xx_i2c_event ( I2CSlave * i2c , enum i2c_event event ) { PXA2xxI2CSlaveState * slave = FROM_I2C_SLAVE ( PXA2xxI2CSlaveState , i2c ) ; PXA2xxI2CState * s = slave -> host ; switch ( event ) { case I2C_START_SEND : s -> status |= ( 1 << 9 ) ; s -> status &= ~ ( 1 << 0 ) ; break ; case I2C_START_RECV : s -> status |= ( 1 << 9 ) ; s -> status |= 1 << 0 ; break ; case I2C_FINISH : s -> status |= ( 1 << 4 ) ; break ; case I2C_NACK : s -> status |= 1 << 1 ; break ; } pxa2xx_i2c_update ( s ) ; }
static void pxa2xx_i2c_event ( I2CSlave * i2c , enum i2c_event event ) { PXA2xxI2CSlaveState * slave = FROM_I2C_SLAVE ( PXA2xxI2CSlaveState , i2c ) ; PXA2xxI2CState * s = slave -> host ; switch ( event ) { case I2C_START_SEND : s -> status |= ( 1 << 9 ) ; s -> status &= ~ ( 1 << 0 ) ; break ; case I2C_START_RECV : s -> status |= ( 1 << 9 ) ; s -> status |= 1 << 0 ; break ; case I2C_FINISH : s -> status |= ( 1 << 4 ) ; break ; case I2C_NACK : s -> status |= 1 << 1 ; break ; } pxa2xx_i2c_update ( s ) ; }
613
0
xsltDocumentPtr xsltLoadDocument ( xsltTransformContextPtr ctxt , const xmlChar * URI ) { xsltDocumentPtr ret ; xmlDocPtr doc ; if ( ( ctxt == NULL ) || ( URI == NULL ) ) return ( NULL ) ; if ( ctxt -> sec != NULL ) { int res ; res = xsltCheckRead ( ctxt -> sec , ctxt , URI ) ; if ( res == 0 ) { xsltTransformError ( ctxt , NULL , NULL , "xsltLoadDocument: read rights for %s denied\n" , URI ) ; return ( NULL ) ; } } ret = ctxt -> docList ; while ( ret != NULL ) { if ( ( ret -> doc != NULL ) && ( ret -> doc -> URL != NULL ) && ( xmlStrEqual ( ret -> doc -> URL , URI ) ) ) return ( ret ) ; ret = ret -> next ; } doc = xsltDocDefaultLoader ( URI , ctxt -> dict , ctxt -> parserOptions , ( void * ) ctxt , XSLT_LOAD_DOCUMENT ) ; if ( doc == NULL ) return ( NULL ) ; if ( ctxt -> xinclude != 0 ) { # ifdef LIBXML_XINCLUDE_ENABLED # if LIBXML_VERSION >= 20603 xmlXIncludeProcessFlags ( doc , ctxt -> parserOptions ) ; # else xmlXIncludeProcess ( doc ) ; # endif # else xsltTransformError ( ctxt , NULL , NULL , "xsltLoadDocument(%s) : XInclude processing not compiled in\n" , URI ) ; # endif } if ( xsltNeedElemSpaceHandling ( ctxt ) ) xsltApplyStripSpaces ( ctxt , xmlDocGetRootElement ( doc ) ) ; if ( ctxt -> debugStatus == XSLT_DEBUG_NONE ) xmlXPathOrderDocElems ( doc ) ; ret = xsltNewDocument ( ctxt , doc ) ; return ( ret ) ; }
xsltDocumentPtr xsltLoadDocument ( xsltTransformContextPtr ctxt , const xmlChar * URI ) { xsltDocumentPtr ret ; xmlDocPtr doc ; if ( ( ctxt == NULL ) || ( URI == NULL ) ) return ( NULL ) ; if ( ctxt -> sec != NULL ) { int res ; res = xsltCheckRead ( ctxt -> sec , ctxt , URI ) ; if ( res == 0 ) { xsltTransformError ( ctxt , NULL , NULL , "xsltLoadDocument: read rights for %s denied\n" , URI ) ; return ( NULL ) ; } } ret = ctxt -> docList ; while ( ret != NULL ) { if ( ( ret -> doc != NULL ) && ( ret -> doc -> URL != NULL ) && ( xmlStrEqual ( ret -> doc -> URL , URI ) ) ) return ( ret ) ; ret = ret -> next ; } doc = xsltDocDefaultLoader ( URI , ctxt -> dict , ctxt -> parserOptions , ( void * ) ctxt , XSLT_LOAD_DOCUMENT ) ; if ( doc == NULL ) return ( NULL ) ; if ( ctxt -> xinclude != 0 ) { # ifdef LIBXML_XINCLUDE_ENABLED # if LIBXML_VERSION >= 20603 xmlXIncludeProcessFlags ( doc , ctxt -> parserOptions ) ; # else xmlXIncludeProcess ( doc ) ; # endif # else xsltTransformError ( ctxt , NULL , NULL , "xsltLoadDocument(%s) : XInclude processing not compiled in\n" , URI ) ; # endif } if ( xsltNeedElemSpaceHandling ( ctxt ) ) xsltApplyStripSpaces ( ctxt , xmlDocGetRootElement ( doc ) ) ; if ( ctxt -> debugStatus == XSLT_DEBUG_NONE ) xmlXPathOrderDocElems ( doc ) ; ret = xsltNewDocument ( ctxt , doc ) ; return ( ret ) ; }
614
0
av_cold void ff_sws_init_swscale_x86(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); #if HAVE_MMX_INLINE if (INLINE_MMX(cpu_flags)) sws_init_swscale_mmx(c); #endif #if HAVE_MMXEXT_INLINE if (INLINE_MMXEXT(cpu_flags)) sws_init_swscale_mmxext(c); #endif #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \ if (c->srcBpc == 8) { \ hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \ ff_hscale8to19_ ## filtersize ## _ ## opt1; \ } else if (c->srcBpc == 9) { \ hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \ ff_hscale9to19_ ## filtersize ## _ ## opt1; \ } else if (c->srcBpc == 10) { \ hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \ ff_hscale10to19_ ## filtersize ## _ ## opt1; \ } else /* c->srcBpc == 16 */ { \ hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \ ff_hscale16to19_ ## filtersize ## _ ## opt1; \ } \ } while (0) #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ switch (filtersize) { \ case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \ case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \ } #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \ switch(c->dstBpc){ \ case 16: do_16_case; break; \ case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \ default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ } #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \ switch(c->dstBpc){ \ case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \ case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \ default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ } #define case_rgb(x, X, opt) \ case AV_PIX_FMT_ ## X: \ c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \ if (!c->chrSrcHSubSample) \ c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \ break #if ARCH_X86_32 if (EXTERNAL_MMX(cpu_flags)) { ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx); ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx); ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT); switch (c->srcFormat) { case AV_PIX_FMT_YA8: c->lumToYV12 = ff_yuyvToY_mmx; if (c->alpPixBuf) c->alpToYV12 = ff_uyvyToY_mmx; break; case AV_PIX_FMT_YUYV422: c->lumToYV12 = ff_yuyvToY_mmx; c->chrToYV12 = ff_yuyvToUV_mmx; break; case AV_PIX_FMT_UYVY422: c->lumToYV12 = ff_uyvyToY_mmx; c->chrToYV12 = ff_uyvyToUV_mmx; break; case AV_PIX_FMT_NV12: c->chrToYV12 = ff_nv12ToUV_mmx; break; case AV_PIX_FMT_NV21: c->chrToYV12 = ff_nv21ToUV_mmx; break; case_rgb(rgb24, RGB24, mmx); case_rgb(bgr24, BGR24, mmx); case_rgb(bgra, BGRA, mmx); case_rgb(rgba, RGBA, mmx); case_rgb(abgr, ABGR, mmx); case_rgb(argb, ARGB, mmx); default: break; } } if (EXTERNAL_MMXEXT(cpu_flags)) { ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1); } #endif /* ARCH_X86_32 */ #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ switch (filtersize) { \ case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \ case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \ else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \ break; \ } if (EXTERNAL_SSE2(cpu_flags)) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2); ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, , HAVE_ALIGNED_STACK || ARCH_X86_64); ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1); switch (c->srcFormat) { case AV_PIX_FMT_YA8: c->lumToYV12 = ff_yuyvToY_sse2; if (c->alpPixBuf) c->alpToYV12 = ff_uyvyToY_sse2; break; case AV_PIX_FMT_YUYV422: c->lumToYV12 = ff_yuyvToY_sse2; c->chrToYV12 = ff_yuyvToUV_sse2; break; case AV_PIX_FMT_UYVY422: c->lumToYV12 = ff_uyvyToY_sse2; c->chrToYV12 = ff_uyvyToUV_sse2; break; case AV_PIX_FMT_NV12: c->chrToYV12 = ff_nv12ToUV_sse2; break; case AV_PIX_FMT_NV21: c->chrToYV12 = ff_nv21ToUV_sse2; break; case_rgb(rgb24, RGB24, sse2); case_rgb(bgr24, BGR24, sse2); case_rgb(bgra, BGRA, sse2); case_rgb(rgba, RGBA, sse2); case_rgb(abgr, ABGR, sse2); case_rgb(argb, ARGB, sse2); default: break; } } if (EXTERNAL_SSSE3(cpu_flags)) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3); switch (c->srcFormat) { case_rgb(rgb24, RGB24, ssse3); case_rgb(bgr24, BGR24, ssse3); default: break; } } if (EXTERNAL_SSE4(cpu_flags)) { /* Xto15 don't need special sse4 functions */ ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3); ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4, if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4, HAVE_ALIGNED_STACK || ARCH_X86_64); if (c->dstBpc == 16 && !isBE(c->dstFormat)) c->yuv2plane1 = ff_yuv2plane1_16_sse4; } if (EXTERNAL_AVX(cpu_flags)) { ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, , HAVE_ALIGNED_STACK || ARCH_X86_64); ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1); switch (c->srcFormat) { case AV_PIX_FMT_YUYV422: c->chrToYV12 = ff_yuyvToUV_avx; break; case AV_PIX_FMT_UYVY422: c->chrToYV12 = ff_uyvyToUV_avx; break; case AV_PIX_FMT_NV12: c->chrToYV12 = ff_nv12ToUV_avx; break; case AV_PIX_FMT_NV21: c->chrToYV12 = ff_nv21ToUV_avx; break; case_rgb(rgb24, RGB24, avx); case_rgb(bgr24, BGR24, avx); case_rgb(bgra, BGRA, avx); case_rgb(rgba, RGBA, avx); case_rgb(abgr, ABGR, avx); case_rgb(argb, ARGB, avx); default: break; } } }
av_cold void ff_sws_init_swscale_x86(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); #if HAVE_MMX_INLINE if (INLINE_MMX(cpu_flags)) sws_init_swscale_mmx(c); #endif #if HAVE_MMXEXT_INLINE if (INLINE_MMXEXT(cpu_flags)) sws_init_swscale_mmxext(c); #endif #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \ if (c->srcBpc == 8) { \ hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \ ff_hscale8to19_ ## filtersize ## _ ## opt1; \ } else if (c->srcBpc == 9) { \ hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \ ff_hscale9to19_ ## filtersize ## _ ## opt1; \ } else if (c->srcBpc == 10) { \ hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \ ff_hscale10to19_ ## filtersize ## _ ## opt1; \ } else { \ hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \ ff_hscale16to19_ ## filtersize ## _ ## opt1; \ } \ } while (0) #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ switch (filtersize) { \ case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \ case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \ } #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \ switch(c->dstBpc){ \ case 16: do_16_case; break; \ case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \ default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ } #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \ switch(c->dstBpc){ \ case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \ case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \ default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ } #define case_rgb(x, X, opt) \ case AV_PIX_FMT_ ## X: \ c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \ if (!c->chrSrcHSubSample) \ c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \ break #if ARCH_X86_32 if (EXTERNAL_MMX(cpu_flags)) { ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx); ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx); ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT); switch (c->srcFormat) { case AV_PIX_FMT_YA8: c->lumToYV12 = ff_yuyvToY_mmx; if (c->alpPixBuf) c->alpToYV12 = ff_uyvyToY_mmx; break; case AV_PIX_FMT_YUYV422: c->lumToYV12 = ff_yuyvToY_mmx; c->chrToYV12 = ff_yuyvToUV_mmx; break; case AV_PIX_FMT_UYVY422: c->lumToYV12 = ff_uyvyToY_mmx; c->chrToYV12 = ff_uyvyToUV_mmx; break; case AV_PIX_FMT_NV12: c->chrToYV12 = ff_nv12ToUV_mmx; break; case AV_PIX_FMT_NV21: c->chrToYV12 = ff_nv21ToUV_mmx; break; case_rgb(rgb24, RGB24, mmx); case_rgb(bgr24, BGR24, mmx); case_rgb(bgra, BGRA, mmx); case_rgb(rgba, RGBA, mmx); case_rgb(abgr, ABGR, mmx); case_rgb(argb, ARGB, mmx); default: break; } } if (EXTERNAL_MMXEXT(cpu_flags)) { ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1); } #endif #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ switch (filtersize) { \ case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \ case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \ else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \ break; \ } if (EXTERNAL_SSE2(cpu_flags)) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2); ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, , HAVE_ALIGNED_STACK || ARCH_X86_64); ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1); switch (c->srcFormat) { case AV_PIX_FMT_YA8: c->lumToYV12 = ff_yuyvToY_sse2; if (c->alpPixBuf) c->alpToYV12 = ff_uyvyToY_sse2; break; case AV_PIX_FMT_YUYV422: c->lumToYV12 = ff_yuyvToY_sse2; c->chrToYV12 = ff_yuyvToUV_sse2; break; case AV_PIX_FMT_UYVY422: c->lumToYV12 = ff_uyvyToY_sse2; c->chrToYV12 = ff_uyvyToUV_sse2; break; case AV_PIX_FMT_NV12: c->chrToYV12 = ff_nv12ToUV_sse2; break; case AV_PIX_FMT_NV21: c->chrToYV12 = ff_nv21ToUV_sse2; break; case_rgb(rgb24, RGB24, sse2); case_rgb(bgr24, BGR24, sse2); case_rgb(bgra, BGRA, sse2); case_rgb(rgba, RGBA, sse2); case_rgb(abgr, ABGR, sse2); case_rgb(argb, ARGB, sse2); default: break; } } if (EXTERNAL_SSSE3(cpu_flags)) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3); switch (c->srcFormat) { case_rgb(rgb24, RGB24, ssse3); case_rgb(bgr24, BGR24, ssse3); default: break; } } if (EXTERNAL_SSE4(cpu_flags)) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3); ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4, if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4, HAVE_ALIGNED_STACK || ARCH_X86_64); if (c->dstBpc == 16 && !isBE(c->dstFormat)) c->yuv2plane1 = ff_yuv2plane1_16_sse4; } if (EXTERNAL_AVX(cpu_flags)) { ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, , HAVE_ALIGNED_STACK || ARCH_X86_64); ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1); switch (c->srcFormat) { case AV_PIX_FMT_YUYV422: c->chrToYV12 = ff_yuyvToUV_avx; break; case AV_PIX_FMT_UYVY422: c->chrToYV12 = ff_uyvyToUV_avx; break; case AV_PIX_FMT_NV12: c->chrToYV12 = ff_nv12ToUV_avx; break; case AV_PIX_FMT_NV21: c->chrToYV12 = ff_nv21ToUV_avx; break; case_rgb(rgb24, RGB24, avx); case_rgb(bgr24, BGR24, avx); case_rgb(bgra, BGRA, avx); case_rgb(rgba, RGBA, avx); case_rgb(abgr, ABGR, avx); case_rgb(argb, ARGB, avx); default: break; } } }
615
1
static void initial_reordering_non_myanmar_cluster ( const hb_ot_shape_plan_t * plan HB_UNUSED , hb_face_t * face HB_UNUSED , hb_buffer_t * buffer HB_UNUSED , unsigned int start HB_UNUSED , unsigned int end HB_UNUSED ) { }
static void initial_reordering_non_myanmar_cluster ( const hb_ot_shape_plan_t * plan HB_UNUSED , hb_face_t * face HB_UNUSED , hb_buffer_t * buffer HB_UNUSED , unsigned int start HB_UNUSED , unsigned int end HB_UNUSED ) { }
617
1
static int jas_iccprof_gettagtab(jas_stream_t *in, jas_icctagtab_t *tagtab) { int i; jas_icctagtabent_t *tagtabent; if (tagtab->ents) { jas_free(tagtab->ents); tagtab->ents = 0; } if (jas_iccgetuint32(in, &tagtab->numents)) goto error; if (!(tagtab->ents = jas_malloc(tagtab->numents * sizeof(jas_icctagtabent_t)))) goto error; tagtabent = tagtab->ents; for (i = 0; i < JAS_CAST(long, tagtab->numents); ++i) { if (jas_iccgetuint32(in, &tagtabent->tag) || jas_iccgetuint32(in, &tagtabent->off) || jas_iccgetuint32(in, &tagtabent->len)) goto error; ++tagtabent; } return 0; error: if (tagtab->ents) { jas_free(tagtab->ents); tagtab->ents = 0; } return -1; }
static int jas_iccprof_gettagtab(jas_stream_t *in, jas_icctagtab_t *tagtab) { int i; jas_icctagtabent_t *tagtabent; if (tagtab->ents) { jas_free(tagtab->ents); tagtab->ents = 0; } if (jas_iccgetuint32(in, &tagtab->numents)) goto error; if (!(tagtab->ents = jas_malloc(tagtab->numents * sizeof(jas_icctagtabent_t)))) goto error; tagtabent = tagtab->ents; for (i = 0; i < JAS_CAST(long, tagtab->numents); ++i) { if (jas_iccgetuint32(in, &tagtabent->tag) || jas_iccgetuint32(in, &tagtabent->off) || jas_iccgetuint32(in, &tagtabent->len)) goto error; ++tagtabent; } return 0; error: if (tagtab->ents) { jas_free(tagtab->ents); tagtab->ents = 0; } return -1; }
618
0
TEST_F(ZNCTest, StatusEchoMessage) { auto znc = Run(); auto ircd = ConnectIRCd(); auto client = LoginClient(); client.Write("CAP REQ :echo-message"); client.Write("PRIVMSG *status :blah"); client.ReadUntil(":[email protected] PRIVMSG *status :blah"); client.ReadUntil(":*[email protected] PRIVMSG nick :Unknown command"); }
TEST_F(ZNCTest, StatusEchoMessage) { auto znc = Run(); auto ircd = ConnectIRCd(); auto client = LoginClient(); client.Write("CAP REQ :echo-message"); client.Write("PRIVMSG *status :blah"); client.ReadUntil(":[email protected] PRIVMSG *status :blah"); client.ReadUntil(":*[email protected] PRIVMSG nick :Unknown command"); }
619
0
static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); #if 1 int frame_duration = av_rescale(track->timescale, track->enc->time_base.num, track->enc->time_base.den); int nb_frames = ROUNDED_DIV(track->enc->time_base.den, track->enc->time_base.num); AVDictionaryEntry *t = NULL; if (nb_frames > 255) { av_log(NULL, AV_LOG_ERROR, "fps %d is too large\n", nb_frames); return AVERROR(EINVAL); } avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "tmcd"); /* Data format */ avio_wb32(pb, 0); /* Reserved */ avio_wb32(pb, 1); /* Data reference index */ avio_wb32(pb, 0); /* Flags */ avio_wb32(pb, track->timecode_flags); /* Flags (timecode) */ avio_wb32(pb, track->timescale); /* Timescale */ avio_wb32(pb, frame_duration); /* Frame duration */ avio_w8(pb, nb_frames); /* Number of frames */ avio_w8(pb, 0); /* Reserved */ if (track->st) t = av_dict_get(track->st->metadata, "reel_name", NULL, 0); if (t && utf8len(t->value)) mov_write_source_reference_tag(pb, track, t->value); else avio_wb16(pb, 0); /* zero size */ #else avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "tmcd"); /* Data format */ avio_wb32(pb, 0); /* Reserved */ avio_wb32(pb, 1); /* Data reference index */ if (track->enc->extradata_size) avio_write(pb, track->enc->extradata, track->enc->extradata_size); #endif return update_size(pb, pos); }
static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); #if 1 int frame_duration = av_rescale(track->timescale, track->enc->time_base.num, track->enc->time_base.den); int nb_frames = ROUNDED_DIV(track->enc->time_base.den, track->enc->time_base.num); AVDictionaryEntry *t = NULL; if (nb_frames > 255) { av_log(NULL, AV_LOG_ERROR, "fps %d is too large\n", nb_frames); return AVERROR(EINVAL); } avio_wb32(pb, 0); ffio_wfourcc(pb, "tmcd"); avio_wb32(pb, 0); avio_wb32(pb, 1); avio_wb32(pb, 0); avio_wb32(pb, track->timecode_flags); avio_wb32(pb, track->timescale); avio_wb32(pb, frame_duration); avio_w8(pb, nb_frames); avio_w8(pb, 0); if (track->st) t = av_dict_get(track->st->metadata, "reel_name", NULL, 0); if (t && utf8len(t->value)) mov_write_source_reference_tag(pb, track, t->value); else avio_wb16(pb, 0); #else avio_wb32(pb, 0); ffio_wfourcc(pb, "tmcd"); avio_wb32(pb, 0); avio_wb32(pb, 1); if (track->enc->extradata_size) avio_write(pb, track->enc->extradata, track->enc->extradata_size); #endif return update_size(pb, pos); }
620
1
static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in) { jp2_cmap_t *cmap = &box->data.cmap; jp2_cmapent_t *ent; unsigned int i; cmap->numchans = (box->datalen) / 4; if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) { return -1; } for (i = 0; i < cmap->numchans; ++i) { ent = &cmap->ents[i]; if (jp2_getuint16(in, &ent->cmptno) || jp2_getuint8(in, &ent->map) || jp2_getuint8(in, &ent->pcol)) { return -1; } } return 0; }
static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in) { jp2_cmap_t *cmap = &box->data.cmap; jp2_cmapent_t *ent; unsigned int i; cmap->numchans = (box->datalen) / 4; if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) { return -1; } for (i = 0; i < cmap->numchans; ++i) { ent = &cmap->ents[i]; if (jp2_getuint16(in, &ent->cmptno) || jp2_getuint8(in, &ent->map) || jp2_getuint8(in, &ent->pcol)) { return -1; } } return 0; }
621
0
TEST_F ( ProtocolHandlerRegistryTest , TestDisablePreventsHandling ) { ProtocolHandler ph1 = CreateProtocolHandler ( "test" , "test1" ) ; registry ( ) -> OnAcceptRegisterProtocolHandler ( ph1 ) ; ASSERT_TRUE ( registry ( ) -> IsHandledProtocol ( "test" ) ) ; registry ( ) -> Disable ( ) ; ASSERT_FALSE ( registry ( ) -> IsHandledProtocol ( "test" ) ) ; }
TEST_F ( ProtocolHandlerRegistryTest , TestDisablePreventsHandling ) { ProtocolHandler ph1 = CreateProtocolHandler ( "test" , "test1" ) ; registry ( ) -> OnAcceptRegisterProtocolHandler ( ph1 ) ; ASSERT_TRUE ( registry ( ) -> IsHandledProtocol ( "test" ) ) ; registry ( ) -> Disable ( ) ; ASSERT_FALSE ( registry ( ) -> IsHandledProtocol ( "test" ) ) ; }
622
1
jpc_mqdec_t *jpc_mqdec_create(int maxctxs, jas_stream_t *in) { jpc_mqdec_t *mqdec; /* There must be at least one context. */ assert(maxctxs > 0); /* Allocate memory for the MQ decoder. */ if (!(mqdec = jas_malloc(sizeof(jpc_mqdec_t)))) { goto error; } mqdec->in = in; mqdec->maxctxs = maxctxs; /* Allocate memory for the per-context state information. */ if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) { goto error; } /* Set the current context to the first context. */ mqdec->curctx = mqdec->ctxs; /* If an input stream has been associated with the MQ decoder, initialize the decoder state from the stream. */ if (mqdec->in) { jpc_mqdec_init(mqdec); } /* Initialize the per-context state information. */ jpc_mqdec_setctxs(mqdec, 0, 0); return mqdec; error: /* Oops... Something has gone wrong. */ if (mqdec) { jpc_mqdec_destroy(mqdec); } return 0; }
jpc_mqdec_t *jpc_mqdec_create(int maxctxs, jas_stream_t *in) { jpc_mqdec_t *mqdec; assert(maxctxs > 0); if (!(mqdec = jas_malloc(sizeof(jpc_mqdec_t)))) { goto error; } mqdec->in = in; mqdec->maxctxs = maxctxs; if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) { goto error; } mqdec->curctx = mqdec->ctxs; if (mqdec->in) { jpc_mqdec_init(mqdec); } jpc_mqdec_setctxs(mqdec, 0, 0); return mqdec; error: if (mqdec) { jpc_mqdec_destroy(mqdec); } return 0; }
623
0
static gcry_err_code_t pkcs1_encode_for_encryption ( gcry_mpi_t * r_result , unsigned int nbits , const unsigned char * value , size_t valuelen , const unsigned char * random_override , size_t random_override_len ) { gcry_err_code_t rc = 0 ; gcry_error_t err ; unsigned char * frame = NULL ; size_t nframe = ( nbits + 7 ) / 8 ; int i ; size_t n ; unsigned char * p ; if ( valuelen + 7 > nframe || ! nframe ) { return GPG_ERR_TOO_SHORT ; } if ( ! ( frame = gcry_malloc_secure ( nframe ) ) ) return gpg_err_code_from_syserror ( ) ; n = 0 ; frame [ n ++ ] = 0 ; frame [ n ++ ] = 2 ; i = nframe - 3 - valuelen ; gcry_assert ( i > 0 ) ; if ( random_override ) { int j ; if ( random_override_len != i ) { gcry_free ( frame ) ; return GPG_ERR_INV_ARG ; } for ( j = 0 ; j < random_override_len ; j ++ ) if ( ! random_override [ j ] ) { gcry_free ( frame ) ; return GPG_ERR_INV_ARG ; } memcpy ( frame + n , random_override , random_override_len ) ; n += random_override_len ; } else { p = gcry_random_bytes_secure ( i , GCRY_STRONG_RANDOM ) ; for ( ; ; ) { int j , k ; unsigned char * pp ; for ( j = k = 0 ; j < i ; j ++ ) { if ( ! p [ j ] ) k ++ ; } if ( ! k ) break ; k += k / 128 + 3 ; pp = gcry_random_bytes_secure ( k , GCRY_STRONG_RANDOM ) ; for ( j = 0 ; j < i && k ; ) { if ( ! p [ j ] ) p [ j ] = pp [ -- k ] ; if ( p [ j ] ) j ++ ; } gcry_free ( pp ) ; } memcpy ( frame + n , p , i ) ; n += i ; gcry_free ( p ) ; } frame [ n ++ ] = 0 ; memcpy ( frame + n , value , valuelen ) ; n += valuelen ; gcry_assert ( n == nframe ) ; err = gcry_mpi_scan ( r_result , GCRYMPI_FMT_USG , frame , n , & nframe ) ; if ( err ) rc = gcry_err_code ( err ) ; else if ( DBG_CIPHER ) log_mpidump ( "PKCS#1 block type 2 encoded data" , * r_result ) ; gcry_free ( frame ) ; return rc ; }
static gcry_err_code_t pkcs1_encode_for_encryption ( gcry_mpi_t * r_result , unsigned int nbits , const unsigned char * value , size_t valuelen , const unsigned char * random_override , size_t random_override_len ) { gcry_err_code_t rc = 0 ; gcry_error_t err ; unsigned char * frame = NULL ; size_t nframe = ( nbits + 7 ) / 8 ; int i ; size_t n ; unsigned char * p ; if ( valuelen + 7 > nframe || ! nframe ) { return GPG_ERR_TOO_SHORT ; } if ( ! ( frame = gcry_malloc_secure ( nframe ) ) ) return gpg_err_code_from_syserror ( ) ; n = 0 ; frame [ n ++ ] = 0 ; frame [ n ++ ] = 2 ; i = nframe - 3 - valuelen ; gcry_assert ( i > 0 ) ; if ( random_override ) { int j ; if ( random_override_len != i ) { gcry_free ( frame ) ; return GPG_ERR_INV_ARG ; } for ( j = 0 ; j < random_override_len ; j ++ ) if ( ! random_override [ j ] ) { gcry_free ( frame ) ; return GPG_ERR_INV_ARG ; } memcpy ( frame + n , random_override , random_override_len ) ; n += random_override_len ; } else { p = gcry_random_bytes_secure ( i , GCRY_STRONG_RANDOM ) ; for ( ; ; ) { int j , k ; unsigned char * pp ; for ( j = k = 0 ; j < i ; j ++ ) { if ( ! p [ j ] ) k ++ ; } if ( ! k ) break ; k += k / 128 + 3 ; pp = gcry_random_bytes_secure ( k , GCRY_STRONG_RANDOM ) ; for ( j = 0 ; j < i && k ; ) { if ( ! p [ j ] ) p [ j ] = pp [ -- k ] ; if ( p [ j ] ) j ++ ; } gcry_free ( pp ) ; } memcpy ( frame + n , p , i ) ; n += i ; gcry_free ( p ) ; } frame [ n ++ ] = 0 ; memcpy ( frame + n , value , valuelen ) ; n += valuelen ; gcry_assert ( n == nframe ) ; err = gcry_mpi_scan ( r_result , GCRYMPI_FMT_USG , frame , n , & nframe ) ; if ( err ) rc = gcry_err_code ( err ) ; else if ( DBG_CIPHER ) log_mpidump ( "PKCS#1 block type 2 encoded data" , * r_result ) ; gcry_free ( frame ) ; return rc ; }
624
0
static void dv_decode_ac(DVVideoDecodeContext *s, BlockInfo *mb, DCTELEM *block, int last_index) { int last_re_index; int shift_offset = mb->shift_offset; const UINT8 *scan_table = mb->scan_table; const UINT8 *shift_table = mb->shift_table; int pos = mb->pos; int level, pos1, sign, run; int partial_bit_count; OPEN_READER(re, &s->gb); #ifdef VLC_DEBUG printf("start\n"); #endif /* if we must parse a partial vlc, we do it here */ partial_bit_count = mb->partial_bit_count; if (partial_bit_count > 0) { UINT8 buf[4]; UINT32 v; int l, l1; GetBitContext gb1; /* build the dummy bit buffer */ l = 16 - partial_bit_count; UPDATE_CACHE(re, &s->gb); #ifdef VLC_DEBUG printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16)); #endif v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l); buf[0] = v >> 8; buf[1] = v; #ifdef VLC_DEBUG printf("v=%04x cnt=%d %04x\n", v, partial_bit_count, (mb->partial_bit_buffer << l)); #endif /* try to read the codeword */ init_get_bits(&gb1, buf, 4); { OPEN_READER(re1, &gb1); UPDATE_CACHE(re1, &gb1); GET_RL_VLC(level, run, re1, &gb1, dv_rl_vlc[0], TEX_VLC_BITS, 2); l = re1_index; CLOSE_READER(re1, &gb1); } #ifdef VLC_DEBUG printf("****run=%d level=%d size=%d\n", run, level, l); #endif /* compute codeword length */ l1 = (level != 256 && level != 0); /* if too long, we cannot parse */ l -= partial_bit_count; if ((re_index + l + l1) > last_index) return; /* skip read bits */ last_re_index = 0; /* avoid warning */ re_index += l; /* by definition, if we can read the vlc, all partial bits will be read (otherwise we could have read the vlc before) */ mb->partial_bit_count = 0; UPDATE_CACHE(re, &s->gb); goto handle_vlc; } /* get the AC coefficients until last_index is reached */ for(;;) { UPDATE_CACHE(re, &s->gb); #ifdef VLC_DEBUG printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, &s->gb, 16), re_index); #endif last_re_index = re_index; GET_RL_VLC(level, run, re, &s->gb, dv_rl_vlc[0], TEX_VLC_BITS, 2); handle_vlc: #ifdef VLC_DEBUG printf("run=%d level=%d\n", run, level); #endif if (level == 256) { if (re_index > last_index) { cannot_read: /* put position before read code */ re_index = last_re_index; mb->eob_reached = 0; break; } /* EOB */ mb->eob_reached = 1; break; } else if (level != 0) { if ((re_index + 1) > last_index) goto cannot_read; sign = SHOW_SBITS(re, &s->gb, 1); level = (level ^ sign) - sign; LAST_SKIP_BITS(re, &s->gb, 1); pos += run; /* error */ if (pos >= 64) { goto read_error; } pos1 = scan_table[pos]; level = level << (shift_table[pos1] + shift_offset); block[pos1] = level; // printf("run=%d level=%d shift=%d\n", run, level, shift_table[pos1]); } else { if (re_index > last_index) goto cannot_read; /* level is zero: means run without coding. No sign is coded */ pos += run; /* error */ if (pos >= 64) { read_error: #if defined(VLC_DEBUG) || 1 printf("error pos=%d\n", pos); #endif /* for errors, we consider the eob is reached */ mb->eob_reached = 1; break; } } } CLOSE_READER(re, &s->gb); mb->pos = pos; }
static void dv_decode_ac(DVVideoDecodeContext *s, BlockInfo *mb, DCTELEM *block, int last_index) { int last_re_index; int shift_offset = mb->shift_offset; const UINT8 *scan_table = mb->scan_table; const UINT8 *shift_table = mb->shift_table; int pos = mb->pos; int level, pos1, sign, run; int partial_bit_count; OPEN_READER(re, &s->gb); #ifdef VLC_DEBUG printf("start\n"); #endif partial_bit_count = mb->partial_bit_count; if (partial_bit_count > 0) { UINT8 buf[4]; UINT32 v; int l, l1; GetBitContext gb1; l = 16 - partial_bit_count; UPDATE_CACHE(re, &s->gb); #ifdef VLC_DEBUG printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16)); #endif v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l); buf[0] = v >> 8; buf[1] = v; #ifdef VLC_DEBUG printf("v=%04x cnt=%d %04x\n", v, partial_bit_count, (mb->partial_bit_buffer << l)); #endif init_get_bits(&gb1, buf, 4); { OPEN_READER(re1, &gb1); UPDATE_CACHE(re1, &gb1); GET_RL_VLC(level, run, re1, &gb1, dv_rl_vlc[0], TEX_VLC_BITS, 2); l = re1_index; CLOSE_READER(re1, &gb1); } #ifdef VLC_DEBUG printf("****run=%d level=%d size=%d\n", run, level, l); #endif l1 = (level != 256 && level != 0); l -= partial_bit_count; if ((re_index + l + l1) > last_index) return; last_re_index = 0; re_index += l; mb->partial_bit_count = 0; UPDATE_CACHE(re, &s->gb); goto handle_vlc; } for(;;) { UPDATE_CACHE(re, &s->gb); #ifdef VLC_DEBUG printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, &s->gb, 16), re_index); #endif last_re_index = re_index; GET_RL_VLC(level, run, re, &s->gb, dv_rl_vlc[0], TEX_VLC_BITS, 2); handle_vlc: #ifdef VLC_DEBUG printf("run=%d level=%d\n", run, level); #endif if (level == 256) { if (re_index > last_index) { cannot_read: re_index = last_re_index; mb->eob_reached = 0; break; } mb->eob_reached = 1; break; } else if (level != 0) { if ((re_index + 1) > last_index) goto cannot_read; sign = SHOW_SBITS(re, &s->gb, 1); level = (level ^ sign) - sign; LAST_SKIP_BITS(re, &s->gb, 1); pos += run; if (pos >= 64) { goto read_error; } pos1 = scan_table[pos]; level = level << (shift_table[pos1] + shift_offset); block[pos1] = level;
625
1
static bmp_info_t *bmp_getinfo(jas_stream_t *in) { bmp_info_t *info; int i; bmp_palent_t *palent; if (!(info = bmp_info_create())) { return 0; } if (bmp_getint32(in, &info->len) || info->len != 40 || bmp_getint32(in, &info->width) || bmp_getint32(in, &info->height) || bmp_getint16(in, &info->numplanes) || bmp_getint16(in, &info->depth) || bmp_getint32(in, &info->enctype) || bmp_getint32(in, &info->siz) || bmp_getint32(in, &info->hres) || bmp_getint32(in, &info->vres) || bmp_getint32(in, &info->numcolors) || bmp_getint32(in, &info->mincolors)) { bmp_info_destroy(info); return 0; } if (info->height < 0) { info->topdown = 1; info->height = -info->height; } else { info->topdown = 0; } if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) { bmp_info_destroy(info); return 0; } if (info->enctype != BMP_ENC_RGB) { jas_eprintf("unsupported BMP encoding\n"); bmp_info_destroy(info); return 0; } if (info->numcolors > 0) { if (!(info->palents = jas_malloc(info->numcolors * sizeof(bmp_palent_t)))) { bmp_info_destroy(info); return 0; } } else { info->palents = 0; } for (i = 0; i < info->numcolors; ++i) { palent = &info->palents[i]; if ((palent->blu = jas_stream_getc(in)) == EOF || (palent->grn = jas_stream_getc(in)) == EOF || (palent->red = jas_stream_getc(in)) == EOF || (palent->res = jas_stream_getc(in)) == EOF) { bmp_info_destroy(info); return 0; } } return info; }
static bmp_info_t *bmp_getinfo(jas_stream_t *in) { bmp_info_t *info; int i; bmp_palent_t *palent; if (!(info = bmp_info_create())) { return 0; } if (bmp_getint32(in, &info->len) || info->len != 40 || bmp_getint32(in, &info->width) || bmp_getint32(in, &info->height) || bmp_getint16(in, &info->numplanes) || bmp_getint16(in, &info->depth) || bmp_getint32(in, &info->enctype) || bmp_getint32(in, &info->siz) || bmp_getint32(in, &info->hres) || bmp_getint32(in, &info->vres) || bmp_getint32(in, &info->numcolors) || bmp_getint32(in, &info->mincolors)) { bmp_info_destroy(info); return 0; } if (info->height < 0) { info->topdown = 1; info->height = -info->height; } else { info->topdown = 0; } if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) { bmp_info_destroy(info); return 0; } if (info->enctype != BMP_ENC_RGB) { jas_eprintf("unsupported BMP encoding\n"); bmp_info_destroy(info); return 0; } if (info->numcolors > 0) { if (!(info->palents = jas_malloc(info->numcolors * sizeof(bmp_palent_t)))) { bmp_info_destroy(info); return 0; } } else { info->palents = 0; } for (i = 0; i < info->numcolors; ++i) { palent = &info->palents[i]; if ((palent->blu = jas_stream_getc(in)) == EOF || (palent->grn = jas_stream_getc(in)) == EOF || (palent->red = jas_stream_getc(in)) == EOF || (palent->res = jas_stream_getc(in)) == EOF) { bmp_info_destroy(info); return 0; } } return info; }
626
0
struct archive_string * archive_strncat ( struct archive_string * as , const void * _p , size_t n ) { size_t s ; const char * p , * pp ; p = ( const char * ) _p ; s = 0 ; pp = p ; while ( s < n && * pp ) { pp ++ ; s ++ ; } if ( ( as = archive_string_append ( as , p , s ) ) == NULL ) __archive_errx ( 1 , "Out of memory" ) ; return ( as ) ; }
struct archive_string * archive_strncat ( struct archive_string * as , const void * _p , size_t n ) { size_t s ; const char * p , * pp ; p = ( const char * ) _p ; s = 0 ; pp = p ; while ( s < n && * pp ) { pp ++ ; s ++ ; } if ( ( as = archive_string_append ( as , p , s ) ) == NULL ) __archive_errx ( 1 , "Out of memory" ) ; return ( as ) ; }
627
1
build_principal_va(krb5_context context, krb5_principal princ, unsigned int rlen, const char *realm, va_list ap) { krb5_error_code retval = 0; char *r = NULL; krb5_data *data = NULL; krb5_int32 count = 0; krb5_int32 size = 2; /* initial guess at needed space */ char *component = NULL; data = malloc(size * sizeof(krb5_data)); if (!data) { retval = ENOMEM; } if (!retval) { r = strdup(realm); if (!r) { retval = ENOMEM; } } while (!retval && (component = va_arg(ap, char *))) { if (count == size) { krb5_data *new_data = NULL; size *= 2; new_data = realloc(data, size * sizeof(krb5_data)); if (new_data) { data = new_data; } else { retval = ENOMEM; } } if (!retval) { data[count].length = strlen(component); data[count].data = strdup(component); if (!data[count].data) { retval = ENOMEM; } count++; } } if (!retval) { princ->type = KRB5_NT_UNKNOWN; princ->magic = KV5M_PRINCIPAL; princ->realm = make_data(r, rlen); princ->data = data; princ->length = count; r = NULL; /* take ownership */ data = NULL; /* take ownership */ } if (data) { while (--count >= 0) { free(data[count].data); } free(data); } free(r); return retval; }
build_principal_va(krb5_context context, krb5_principal princ, unsigned int rlen, const char *realm, va_list ap) { krb5_error_code retval = 0; char *r = NULL; krb5_data *data = NULL; krb5_int32 count = 0; krb5_int32 size = 2; char *component = NULL; data = malloc(size * sizeof(krb5_data)); if (!data) { retval = ENOMEM; } if (!retval) { r = strdup(realm); if (!r) { retval = ENOMEM; } } while (!retval && (component = va_arg(ap, char *))) { if (count == size) { krb5_data *new_data = NULL; size *= 2; new_data = realloc(data, size * sizeof(krb5_data)); if (new_data) { data = new_data; } else { retval = ENOMEM; } } if (!retval) { data[count].length = strlen(component); data[count].data = strdup(component); if (!data[count].data) { retval = ENOMEM; } count++; } } if (!retval) { princ->type = KRB5_NT_UNKNOWN; princ->magic = KV5M_PRINCIPAL; princ->realm = make_data(r, rlen); princ->data = data; princ->length = count; r = NULL; data = NULL; } if (data) { while (--count >= 0) { free(data[count].data); } free(data); } free(r); return retval; }
628
0
static int expand_rle_row16(SgiState *s, uint16_t *out_buf, int len, int pixelstride) { unsigned short pixel; unsigned char count; unsigned short *orig = out_buf; uint16_t *out_end = out_buf + len; while (out_buf < out_end) { if (bytestream2_get_bytes_left(&s->g) < 2) return AVERROR_INVALIDDATA; pixel = bytestream2_get_be16u(&s->g); if (!(count = (pixel & 0x7f))) break; /* Check for buffer overflow. */ if (pixelstride * (count - 1) >= len) { av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n"); return AVERROR_INVALIDDATA; } if (pixel & 0x80) { while (count--) { pixel = bytestream2_get_ne16(&s->g); AV_WN16A(out_buf, pixel); out_buf += pixelstride; } } else { pixel = bytestream2_get_ne16(&s->g); while (count--) { AV_WN16A(out_buf, pixel); out_buf += pixelstride; } } } return (out_buf - orig) / pixelstride; }
static int expand_rle_row16(SgiState *s, uint16_t *out_buf, int len, int pixelstride) { unsigned short pixel; unsigned char count; unsigned short *orig = out_buf; uint16_t *out_end = out_buf + len; while (out_buf < out_end) { if (bytestream2_get_bytes_left(&s->g) < 2) return AVERROR_INVALIDDATA; pixel = bytestream2_get_be16u(&s->g); if (!(count = (pixel & 0x7f))) break; if (pixelstride * (count - 1) >= len) { av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n"); return AVERROR_INVALIDDATA; } if (pixel & 0x80) { while (count--) { pixel = bytestream2_get_ne16(&s->g); AV_WN16A(out_buf, pixel); out_buf += pixelstride; } } else { pixel = bytestream2_get_ne16(&s->g); while (count--) { AV_WN16A(out_buf, pixel); out_buf += pixelstride; } } } return (out_buf - orig) / pixelstride; }
629
1
void CClient::EchoMessage(const CMessage& Message) { CMessage EchoedMessage = Message; for (CClient* pClient : GetClients()) { if (pClient->HasEchoMessage() || (pClient != this && (m_pNetwork->IsChan(Message.GetParam(0)) || pClient->HasSelfMessage()))) { EchoedMessage.SetNick(GetNickMask()); pClient->PutClient(EchoedMessage); } } }
void CClient::EchoMessage(const CMessage& Message) { CMessage EchoedMessage = Message; for (CClient* pClient : GetClients()) { if (pClient->HasEchoMessage() || (pClient != this && (m_pNetwork->IsChan(Message.GetParam(0)) || pClient->HasSelfMessage()))) { EchoedMessage.SetNick(GetNickMask()); pClient->PutClient(EchoedMessage); } } }
630
1
void *jas_realloc(void *ptr, size_t size) { return realloc(ptr, size); }
void *jas_realloc(void *ptr, size_t size) { return realloc(ptr, size); }
631
1
void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx, void *retaddr) { TranslationBlock *tb; CPUState *saved_env; unsigned long pc; int ret; saved_env = env; ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx); if (unlikely(ret)) { if (retaddr) { /* now we have a real cpu fault */ pc = (unsigned long)retaddr; tb = tb_find_pc(pc); if (tb) { /* the PC is inside the translated code. It means that we have a virtual CPU fault */ cpu_restore_state(tb, env, pc); } } raise_exception(env->exception_index); } env = saved_env; }
void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx, void *retaddr) { TranslationBlock *tb; CPUState *saved_env; unsigned long pc; int ret; saved_env = env; ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx); if (unlikely(ret)) { if (retaddr) { pc = (unsigned long)retaddr; tb = tb_find_pc(pc); if (tb) { cpu_restore_state(tb, env, pc); } } raise_exception(env->exception_index); } env = saved_env; }
632
1
static int combined_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , BLOCK_SIZE bsize , int mi_row , int mi_col , int_mv * tmp_mv , int * rate_mv , int64_t best_rd_sofar ) { MACROBLOCKD * xd = & x -> e_mbd ; MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; struct buf_2d backup_yv12 [ MAX_MB_PLANE ] = { { 0 , 0 } } ; const int step_param = cpi -> sf . mv . fullpel_search_step_param ; const int sadpb = x -> sadperbit16 ; MV mvp_full ; const int ref = mbmi -> ref_frame [ 0 ] ; const MV ref_mv = mbmi -> ref_mvs [ ref ] [ 0 ] . as_mv ; int dis ; int rate_mode ; const int tmp_col_min = x -> mv_col_min ; const int tmp_col_max = x -> mv_col_max ; const int tmp_row_min = x -> mv_row_min ; const int tmp_row_max = x -> mv_row_max ; int rv = 0 ; int sad_list [ 5 ] ; const YV12_BUFFER_CONFIG * scaled_ref_frame = vp9_get_scaled_ref_frame ( cpi , ref ) ; if ( cpi -> common . show_frame && ( x -> pred_mv_sad [ ref ] >> 3 ) > x -> pred_mv_sad [ LAST_FRAME ] ) return rv ; if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) backup_yv12 [ i ] = xd -> plane [ i ] . pre [ 0 ] ; vp9_setup_pre_planes ( xd , 0 , scaled_ref_frame , mi_row , mi_col , NULL ) ; } vp9_set_mv_search_range ( x , & ref_mv ) ; assert ( x -> mv_best_ref_index [ ref ] <= 2 ) ; if ( x -> mv_best_ref_index [ ref ] < 2 ) mvp_full = mbmi -> ref_mvs [ ref ] [ x -> mv_best_ref_index [ ref ] ] . as_mv ; else mvp_full = x -> pred_mv [ ref ] ; mvp_full . col >>= 3 ; mvp_full . row >>= 3 ; vp9_full_pixel_search ( cpi , x , bsize , & mvp_full , step_param , sadpb , cond_sad_list ( cpi , sad_list ) , & ref_mv , & tmp_mv -> as_mv , INT_MAX , 0 ) ; x -> mv_col_min = tmp_col_min ; x -> mv_col_max = tmp_col_max ; x -> mv_row_min = tmp_row_min ; x -> mv_row_max = tmp_row_max ; mvp_full . row = tmp_mv -> as_mv . row * 8 ; mvp_full . col = tmp_mv -> as_mv . col * 8 ; * rate_mv = vp9_mv_bit_cost ( & mvp_full , & ref_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ; rate_mode = cpi -> inter_mode_cost [ mbmi -> mode_context [ ref ] ] [ INTER_OFFSET ( NEWMV ) ] ; rv = ! ( RDCOST ( x -> rdmult , x -> rddiv , ( * rate_mv + rate_mode ) , 0 ) > best_rd_sofar ) ; if ( rv ) { cpi -> find_fractional_mv_step ( x , & tmp_mv -> as_mv , & ref_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] , cpi -> sf . mv . subpel_force_stop , cpi -> sf . mv . subpel_iters_per_step , cond_sad_list ( cpi , sad_list ) , x -> nmvjointcost , x -> mvcost , & dis , & x -> pred_sse [ ref ] , NULL , 0 , 0 ) ; x -> pred_mv [ ref ] = tmp_mv -> as_mv ; } if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) xd -> plane [ i ] . pre [ 0 ] = backup_yv12 [ i ] ; } return rv ; }
static int combined_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , BLOCK_SIZE bsize , int mi_row , int mi_col , int_mv * tmp_mv , int * rate_mv , int64_t best_rd_sofar ) { MACROBLOCKD * xd = & x -> e_mbd ; MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; struct buf_2d backup_yv12 [ MAX_MB_PLANE ] = { { 0 , 0 } } ; const int step_param = cpi -> sf . mv . fullpel_search_step_param ; const int sadpb = x -> sadperbit16 ; MV mvp_full ; const int ref = mbmi -> ref_frame [ 0 ] ; const MV ref_mv = mbmi -> ref_mvs [ ref ] [ 0 ] . as_mv ; int dis ; int rate_mode ; const int tmp_col_min = x -> mv_col_min ; const int tmp_col_max = x -> mv_col_max ; const int tmp_row_min = x -> mv_row_min ; const int tmp_row_max = x -> mv_row_max ; int rv = 0 ; int sad_list [ 5 ] ; const YV12_BUFFER_CONFIG * scaled_ref_frame = vp9_get_scaled_ref_frame ( cpi , ref ) ; if ( cpi -> common . show_frame && ( x -> pred_mv_sad [ ref ] >> 3 ) > x -> pred_mv_sad [ LAST_FRAME ] ) return rv ; if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) backup_yv12 [ i ] = xd -> plane [ i ] . pre [ 0 ] ; vp9_setup_pre_planes ( xd , 0 , scaled_ref_frame , mi_row , mi_col , NULL ) ; } vp9_set_mv_search_range ( x , & ref_mv ) ; assert ( x -> mv_best_ref_index [ ref ] <= 2 ) ; if ( x -> mv_best_ref_index [ ref ] < 2 ) mvp_full = mbmi -> ref_mvs [ ref ] [ x -> mv_best_ref_index [ ref ] ] . as_mv ; else mvp_full = x -> pred_mv [ ref ] ; mvp_full . col >>= 3 ; mvp_full . row >>= 3 ; vp9_full_pixel_search ( cpi , x , bsize , & mvp_full , step_param , sadpb , cond_sad_list ( cpi , sad_list ) , & ref_mv , & tmp_mv -> as_mv , INT_MAX , 0 ) ; x -> mv_col_min = tmp_col_min ; x -> mv_col_max = tmp_col_max ; x -> mv_row_min = tmp_row_min ; x -> mv_row_max = tmp_row_max ; mvp_full . row = tmp_mv -> as_mv . row * 8 ; mvp_full . col = tmp_mv -> as_mv . col * 8 ; * rate_mv = vp9_mv_bit_cost ( & mvp_full , & ref_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ; rate_mode = cpi -> inter_mode_cost [ mbmi -> mode_context [ ref ] ] [ INTER_OFFSET ( NEWMV ) ] ; rv = ! ( RDCOST ( x -> rdmult , x -> rddiv , ( * rate_mv + rate_mode ) , 0 ) > best_rd_sofar ) ; if ( rv ) { cpi -> find_fractional_mv_step ( x , & tmp_mv -> as_mv , & ref_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] , cpi -> sf . mv . subpel_force_stop , cpi -> sf . mv . subpel_iters_per_step , cond_sad_list ( cpi , sad_list ) , x -> nmvjointcost , x -> mvcost , & dis , & x -> pred_sse [ ref ] , NULL , 0 , 0 ) ; x -> pred_mv [ ref ] = tmp_mv -> as_mv ; } if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) xd -> plane [ i ] . pre [ 0 ] = backup_yv12 [ i ] ; } return rv ; }
633
1
static void _UTF7Open ( UConverter * cnv , UConverterLoadArgs * pArgs , UErrorCode * pErrorCode ) { if ( UCNV_GET_VERSION ( cnv ) <= 1 ) { cnv -> fromUnicodeStatus = UCNV_GET_VERSION ( cnv ) << 28 ; _UTF7Reset ( cnv , UCNV_RESET_BOTH ) ; } else { * pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ; } }
static void _UTF7Open ( UConverter * cnv , UConverterLoadArgs * pArgs , UErrorCode * pErrorCode ) { if ( UCNV_GET_VERSION ( cnv ) <= 1 ) { cnv -> fromUnicodeStatus = UCNV_GET_VERSION ( cnv ) << 28 ; _UTF7Reset ( cnv , UCNV_RESET_BOTH ) ; } else { * pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ; } }
634