idx
int64 | func
string | target
int64 |
|---|---|---|
509,968
|
prepare_JPEGTables(TIFF* tif)
{
JPEGState* sp = JState(tif);
/* Initialize quant tables for current quality setting */
if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
return (0);
/* Mark only the tables we want for output */
/* NB: chrominance tables are currently used only with YCbCr */
if (!TIFFjpeg_suppress_tables(sp, TRUE))
return (0);
if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) {
unsuppress_quant_table(sp, 0);
if (sp->photometric == PHOTOMETRIC_YCBCR)
unsuppress_quant_table(sp, 1);
}
if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) {
unsuppress_huff_table(sp, 0);
if (sp->photometric == PHOTOMETRIC_YCBCR)
unsuppress_huff_table(sp, 1);
}
/* Direct libjpeg output into jpegtables */
if (!TIFFjpeg_tables_dest(sp, tif))
return (0);
/* Emit tables-only datastream */
if (!TIFFjpeg_write_tables(sp))
return (0);
return (1);
}
| 0
|
211,813
|
void RenderWidgetHostViewAura::ScrollOffsetChanged() {
aura::Window* root = window_->GetRootWindow();
if (!root)
return;
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root);
if (cursor_client && !cursor_client->IsCursorVisible())
cursor_client->DisableMouseEvents();
}
| 0
|
295,396
|
check_symlinks(struct archive_write_disk *a)
{
struct archive_string error_string;
int error_number;
int rc;
archive_string_init(&error_string);
rc = check_symlinks_fsobj(a->name, &error_number, &error_string, a->flags);
if (rc != ARCHIVE_OK) {
archive_set_error(&a->archive, error_number, "%s", error_string.s);
}
archive_string_free(&error_string);
a->pst = NULL; /* to be safe */
return rc;
}
| 0
|
130,874
|
int enc_untrusted_fsetxattr(int fd, const char *name, const void *value,
size_t size, int flags) {
return EnsureInitializedAndDispatchSyscall(asylo::system_call::kSYS_fsetxattr,
fd, name, value, size, flags);
}
| 0
|
319,802
|
static void dss_sp_scale_vector(int32_t *vec, int bits, int size)
{
int i;
if (bits < 0)
for (i = 0; i < size; i++)
vec[i] = vec[i] >> -bits;
else
for (i = 0; i < size; i++)
vec[i] = vec[i] << bits;
}
| 1
|
108,771
|
*/
static int wddx_stack_destroy(wddx_stack *stack)
{
register int i;
if (stack->elements) {
for (i = 0; i < stack->top; i++) {
if (Z_TYPE(((st_entry *)stack->elements[i])->data) != IS_UNDEF
&& ((st_entry *)stack->elements[i])->type != ST_FIELD) {
zval_ptr_dtor(&((st_entry *)stack->elements[i])->data);
}
if (((st_entry *)stack->elements[i])->varname) {
efree(((st_entry *)stack->elements[i])->varname);
}
efree(stack->elements[i]);
}
efree(stack->elements);
}
return SUCCESS;
| 0
|
35,418
|
poly_overabove(PG_FUNCTION_ARGS)
{
POLYGON *polya = PG_GETARG_POLYGON_P(0);
POLYGON *polyb = PG_GETARG_POLYGON_P(1);
bool result;
result = polya->boundbox.low.y >= polyb->boundbox.low.y;
/*
* Avoid leaking memory for toasted inputs ... needed for rtree indexes
*/
PG_FREE_IF_COPY(polya, 0);
PG_FREE_IF_COPY(polyb, 1);
PG_RETURN_BOOL(result);
}
| 0
|
182,060
|
mux_master_control_cleanup_cb(int cid, void *unused)
{
Channel *sc, *c = channel_by_id(cid);
debug3("%s: entering for channel %d", __func__, cid);
if (c == NULL)
fatal("%s: channel_by_id(%i) == NULL", __func__, cid);
if (c->remote_id != -1) {
if ((sc = channel_by_id(c->remote_id)) == NULL)
fatal("%s: channel %d missing session channel %d",
__func__, c->self, c->remote_id);
c->remote_id = -1;
sc->ctl_chan = -1;
if (sc->type != SSH_CHANNEL_OPEN &&
sc->type != SSH_CHANNEL_OPENING) {
debug2("%s: channel %d: not open", __func__, sc->self);
chan_mark_dead(sc);
} else {
if (sc->istate == CHAN_INPUT_OPEN)
chan_read_failed(sc);
if (sc->ostate == CHAN_OUTPUT_OPEN)
chan_write_failed(sc);
}
}
channel_cancel_cleanup(c->self);
}
| 0
|
148,831
|
void msre_engine_reqbody_processor_register(msre_engine *engine,
const char *name, void *fn_init, void *fn_process, void *fn_complete)
{
msre_reqbody_processor_metadata *metadata =
(msre_reqbody_processor_metadata *)apr_pcalloc(engine->mp,
sizeof(msre_reqbody_processor_metadata));
if (metadata == NULL) return;
metadata->name = name;
metadata->init = fn_init;
metadata->process = fn_process;
metadata->complete = fn_complete;
apr_table_setn(engine->reqbody_processors, name, (void *)metadata);
}
| 0
|
12,521
|
void HostPortAllocatorSession::SendSessionRequest(const std::string& host,
int port) {
GURL url("https://" + host + ":" + base::IntToString(port) +
GetSessionRequestUrl() + "&sn=1");
scoped_ptr<UrlFetcher> url_fetcher(new UrlFetcher(url, UrlFetcher::GET));
url_fetcher->SetRequestContext(url_context_);
url_fetcher->SetHeader("X-Talk-Google-Relay-Auth", relay_token());
url_fetcher->SetHeader("X-Google-Relay-Auth", relay_token());
url_fetcher->SetHeader("X-Stream-Type", "chromoting");
url_fetcher->Start(base::Bind(&HostPortAllocatorSession::OnSessionRequestDone,
base::Unretained(this), url_fetcher.get()));
url_fetchers_.insert(url_fetcher.release());
}
| 1
|
306,608
|
int jemalloc_purge() {
return 0;
}
| 0
|
235,806
|
void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) {
extension_pref_value_map_->UnregisterExtension(extension_id);
content_settings_store_->UnregisterExtension(extension_id);
DictionaryPrefUpdate update(prefs_, kExtensionsPref);
DictionaryValue* dict = update.Get();
if (dict->HasKey(extension_id)) {
dict->Remove(extension_id, NULL);
SavePrefs();
}
}
| 0
|
444,079
|
TEST_F(HttpConnectionManagerImplTest, StartAndFinishSpanNormalFlowEgressDecoratorPropagateFalse) {
setup(false, "");
envoy::type::v3::FractionalPercent percent1;
percent1.set_numerator(100);
envoy::type::v3::FractionalPercent percent2;
percent2.set_numerator(10000);
percent2.set_denominator(envoy::type::v3::FractionalPercent::TEN_THOUSAND);
tracing_config_ = std::make_unique<TracingConnectionManagerConfig>(
TracingConnectionManagerConfig{Tracing::OperationName::Egress,
{{":method", requestHeaderCustomTag(":method")}},
percent1,
percent2,
percent1,
false,
256});
auto* span = new NiceMock<Tracing::MockSpan>();
EXPECT_CALL(*tracer_, startSpan_(_, _, _, _))
.WillOnce(
Invoke([&](const Tracing::Config& config, const HeaderMap&, const StreamInfo::StreamInfo&,
const Tracing::Decision) -> Tracing::Span* {
EXPECT_EQ(Tracing::OperationName::Egress, config.operationName());
return span;
}));
route_config_provider_.route_config_->route_->decorator_.operation_ = "testOp";
ON_CALL(route_config_provider_.route_config_->route_->decorator_, propagate())
.WillByDefault(Return(false));
EXPECT_CALL(*route_config_provider_.route_config_->route_, decorator()).Times(2);
EXPECT_CALL(route_config_provider_.route_config_->route_->decorator_, apply(_))
.WillOnce(Invoke(
[&](const Tracing::Span& apply_to_span) -> void { EXPECT_EQ(span, &apply_to_span); }));
EXPECT_CALL(*span, finishSpan());
EXPECT_CALL(*span, setTag(_, _)).Times(testing::AnyNumber());
EXPECT_CALL(
runtime_.snapshot_,
featureEnabled("tracing.global_enabled", An<const envoy::type::v3::FractionalPercent&>(), _))
.WillOnce(Return(true));
EXPECT_CALL(*span, setOperation(_)).Times(0);
std::shared_ptr<MockStreamDecoderFilter> filter(new NiceMock<MockStreamDecoderFilter>());
EXPECT_CALL(filter_factory_, createFilterChain(_))
.WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void {
callbacks.addStreamDecoderFilter(filter);
}));
// Treat request as internal, otherwise x-request-id header will be overwritten.
use_remote_address_ = false;
EXPECT_CALL(random_, uuid()).Times(0);
NiceMock<MockResponseEncoder> encoder;
EXPECT_CALL(*codec_, dispatch(_))
.WillRepeatedly(Invoke([&](Buffer::Instance& data) -> Http::Status {
RequestDecoder* decoder = &conn_manager_->newStream(encoder);
RequestHeaderMapPtr headers{
new TestRequestHeaderMapImpl{{":method", "GET"},
{":authority", "host"},
{":path", "/"},
{"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}};
decoder->decodeHeaders(std::move(headers), true);
ResponseHeaderMapPtr response_headers{new TestResponseHeaderMapImpl{{":status", "200"}}};
filter->callbacks_->encodeHeaders(std::move(response_headers), true);
filter->callbacks_->activeSpan().setTag("service-cluster", "scoobydoo");
data.drain(4);
return Http::okStatus();
}));
// Verify that decorator operation has NOT been set as request header (propagate is false)
EXPECT_CALL(*filter, decodeHeaders(_, true))
.WillOnce(Invoke([](RequestHeaderMap& headers, bool) -> FilterHeadersStatus {
EXPECT_EQ(nullptr, headers.EnvoyDecoratorOperation());
return FilterHeadersStatus::StopIteration;
}));
Buffer::OwnedImpl fake_input("1234");
conn_manager_->onData(fake_input, false);
}
| 0
|
20,635
|
static int32_t U_CALLCONV uprv_copyArray64 ( const UDataSwapper * ds , const void * inData , int32_t length , void * outData , UErrorCode * pErrorCode ) {
if ( pErrorCode == NULL || U_FAILURE ( * pErrorCode ) ) {
return 0 ;
}
if ( ds == NULL || inData == NULL || length < 0 || ( length & 7 ) != 0 || outData == NULL ) {
* pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ;
return 0 ;
}
if ( length > 0 && inData != outData ) {
uprv_memcpy ( outData , inData , length ) ;
}
return length ;
}
| 0
|
140,594
|
QPDF::resolve(int objid, int generation)
{
// Check object cache before checking xref table. This allows us
// to insert things into the object cache that don't actually
// exist in the file.
QPDFObjGen og(objid, generation);
if (this->m->resolving.count(og))
{
// This can happen if an object references itself directly or
// indirectly in some key that has to be resolved during
// object parsing, such as stream length.
QTC::TC("qpdf", "QPDF recursion loop in resolve");
warn(QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(),
"", this->m->file->getLastOffset(),
"loop detected resolving object " +
QUtil::int_to_string(objid) + " " +
QUtil::int_to_string(generation)));
return new QPDF_Null;
}
ResolveRecorder rr(this, og);
if (! this->m->obj_cache.count(og))
{
if (! this->m->xref_table.count(og))
{
// PDF spec says unknown objects resolve to the null object.
return new QPDF_Null;
}
QPDFXRefEntry const& entry = this->m->xref_table[og];
bool success = false;
try
{
switch (entry.getType())
{
case 1:
{
qpdf_offset_t offset = entry.getOffset();
// Object stored in cache by readObjectAtOffset
int aobjid;
int ageneration;
QPDFObjectHandle oh =
readObjectAtOffset(true, offset, "", objid, generation,
aobjid, ageneration);
}
break;
case 2:
resolveObjectsInStream(entry.getObjStreamNumber());
break;
default:
throw QPDFExc(qpdf_e_damaged_pdf,
this->m->file->getName(), "", 0,
"object " +
QUtil::int_to_string(objid) + "/" +
QUtil::int_to_string(generation) +
" has unexpected xref entry type");
}
success = true;
}
catch (QPDFExc& e)
{
warn(e);
}
catch (std::exception& e)
{
warn(QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(), "", 0,
"object " +
QUtil::int_to_string(objid) + "/" +
QUtil::int_to_string(generation) +
": error reading object: " + e.what()));
}
if (! success)
{
QTC::TC("qpdf", "QPDF resolve failure to null");
QPDFObjectHandle oh = QPDFObjectHandle::newNull();
this->m->obj_cache[og] =
ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
}
}
return this->m->obj_cache[og].object;
}
| 0
|
133,818
|
void xen_netbk_queue_tx_skb(struct xenvif *vif, struct sk_buff *skb)
{
struct xen_netbk *netbk = vif->netbk;
skb_queue_tail(&netbk->rx_queue, skb);
xen_netbk_kick_thread(netbk);
}
| 0
|
336,090
|
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant;
int status;
int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */
int field_mode, fcm;
v->numref = 0;
v->p_frame_skipped = 0;
if (v->second_field) {
v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4)
v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
v->s.current_picture_ptr->f.pict_type = v->s.pict_type;
if (!v->pic_header_flag)
goto parse_common_info;
}
field_mode = 0;
if (v->interlace) {
fcm = decode012(gb);
if (fcm) {
if (fcm == ILACE_FIELD)
field_mode = 1;
}
} else {
fcm = PROGRESSIVE;
}
if (!v->first_pic_header_flag && v->field_mode != field_mode)
return AVERROR_INVALIDDATA;
v->field_mode = field_mode;
v->fcm = fcm;
if (v->field_mode) {
v->s.mb_height = FFALIGN(v->s.height + 15 >> 4, 2);
v->fptype = get_bits(gb, 3);
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4) // B-picture
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
} else {
v->s.mb_height = v->s.height + 15 >> 4;
switch (get_unary(gb, 0, 4)) {
case 0:
v->s.pict_type = AV_PICTURE_TYPE_P;
break;
case 1:
v->s.pict_type = AV_PICTURE_TYPE_B;
break;
case 2:
v->s.pict_type = AV_PICTURE_TYPE_I;
break;
case 3:
v->s.pict_type = AV_PICTURE_TYPE_BI;
break;
case 4:
v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic
v->p_frame_skipped = 1;
break;
}
}
if (v->tfcntrflag)
skip_bits(gb, 8);
if (v->broadcast) {
if (!v->interlace || v->psf) {
v->rptfrm = get_bits(gb, 2);
} else {
v->tff = get_bits1(gb);
v->rff = get_bits1(gb);
}
}
if (v->panscanflag) {
avpriv_report_missing_feature(v->s.avctx, "Pan-scan");
//...
}
if (v->p_frame_skipped) {
return 0;
}
v->rnd = get_bits1(gb);
if (v->interlace)
v->uvsamp = get_bits1(gb);
if (v->field_mode) {
if (!v->refdist_flag)
v->refdist = 0;
else if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) {
v->refdist = get_bits(gb, 2);
if (v->refdist == 3)
v->refdist += get_unary(gb, 0, 16);
}
if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
v->frfd = (v->bfraction * v->refdist) >> 8;
v->brfd = v->refdist - v->frfd - 1;
if (v->brfd < 0)
v->brfd = 0;
}
goto parse_common_info;
}
if (v->fcm == PROGRESSIVE) {
if (v->finterpflag)
v->interpfrm = get_bits1(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */
}
}
}
parse_common_info:
if (v->field_mode)
v->cur_field_type = !(v->tff ^ v->second_field);
pqindex = get_bits(gb, 5);
if (!pqindex)
return -1;
v->pqindex = pqindex;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = ff_vc1_pquant_table[0][pqindex];
else
v->pq = ff_vc1_pquant_table[1][pqindex];
v->pquantizer = 1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pquantizer = pqindex < 9;
if (v->quantizer_mode == QUANT_NON_UNIFORM)
v->pquantizer = 0;
v->pqindex = pqindex;
if (pqindex < 9)
v->halfpq = get_bits1(gb);
else
v->halfpq = 0;
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits1(gb);
if (v->postprocflag)
v->postproc = get_bits(gb, 2);
if (v->parse_only)
return 0;
if (v->first_pic_header_flag)
rotate_luts(v);
switch (v->s.pict_type) {
case AV_PICTURE_TYPE_I:
case AV_PICTURE_TYPE_BI:
if (v->fcm == ILACE_FRAME) { //interlace frame picture
status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
}
status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->condover = CONDOVER_NONE;
if (v->overlap && v->pq <= 8) {
v->condover = decode012(gb);
if (v->condover == CONDOVER_SELECT) {
status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
}
}
break;
case AV_PICTURE_TYPE_P:
if (v->field_mode) {
v->numref = get_bits1(gb);
if (!v->numref) {
v->reffield = get_bits1(gb);
v->ref_field_type[0] = v->reffield ^ !v->cur_field_type;
}
}
if (v->extended_mv)
v->mvrange = get_unary(gb, 0, 3);
else
v->mvrange = 0;
if (v->interlace) {
if (v->extended_dmv)
v->dmvrange = get_unary(gb, 0, 3);
else
v->dmvrange = 0;
if (v->fcm == ILACE_FRAME) { // interlaced frame picture
v->fourmvswitch = get_bits1(gb);
v->intcomp = get_bits1(gb);
if (v->intcomp) {
v->lumscale = get_bits(gb, 6);
v->lumshift = get_bits(gb, 6);
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1);
v->last_use_ic = 1;
}
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
mbmodetab = get_bits(gb, 2);
if (v->fourmvswitch)
v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab];
else
v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];
imvtab = get_bits(gb, 2);
v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
// interlaced p-picture cbpcy range is [1, 63]
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
twomvbptab = get_bits(gb, 2);
v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];
if (v->fourmvswitch) {
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
}
}
}
v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
v->range_x = 1 << (v->k_x - 1);
v->range_y = 1 << (v->k_y - 1);
if (v->pq < 5)
v->tt_index = 0;
else if (v->pq < 13)
v->tt_index = 1;
else
v->tt_index = 2;
if (v->fcm != ILACE_FRAME) {
int mvmode;
mvmode = get_unary(gb, 1, 4);
lowquant = (v->pq > 12) ? 0 : 1;
v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode];
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
int mvmode2;
mvmode2 = get_unary(gb, 1, 3);
v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2];
if (v->field_mode) {
v->intcompfield = decode210(gb) ^ 3;
} else
v->intcompfield = 3;
v->lumscale2 = v->lumscale = 32;
v->lumshift2 = v->lumshift = 0;
if (v->intcompfield & 1) {
v->lumscale = get_bits(gb, 6);
v->lumshift = get_bits(gb, 6);
}
if ((v->intcompfield & 2) && v->field_mode) {
v->lumscale2 = get_bits(gb, 6);
v->lumshift2 = get_bits(gb, 6);
} else if(!v->field_mode) {
v->lumscale2 = v->lumscale;
v->lumshift2 = v->lumshift;
}
if (v->field_mode && v->second_field) {
if (v->cur_field_type) {
INIT_LUT(v->lumscale , v->lumshift , v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);
INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[v->cur_field_type ], v->last_lutuv[v->cur_field_type ], 1);
} else {
INIT_LUT(v->lumscale2, v->lumshift2, v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);
INIT_LUT(v->lumscale , v->lumshift , v->last_luty[v->cur_field_type ], v->last_lutuv[v->cur_field_type ], 1);
}
v->next_use_ic = v->curr_use_ic = 1;
} else {
INIT_LUT(v->lumscale , v->lumshift , v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[1], v->last_lutuv[1], 1);
}
v->last_use_ic = 1;
}
v->qs_last = v->s.quarter_sample;
if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else
v->s.quarter_sample = 1;
} else
v->s.quarter_sample = 1;
v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN
|| (v->mv_mode == MV_PMODE_INTENSITY_COMP
&& v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
}
if (v->fcm == PROGRESSIVE) { // progressive
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV)
|| v->mv_mode == MV_PMODE_MIXED_MV) {
status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
} else {
v->mv_type_is_raw = 0;
memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
}
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
/* Hopefully this is correct for P frames */
v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
} else if (v->fcm == ILACE_FRAME) { // frame interlaced
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = 1;
v->s.mspel = 1;
} else { // field interlaced
mbmodetab = get_bits(gb, 3);
imvtab = get_bits(gb, 2 + v->numref);
if (!v->numref)
v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
else
v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) {
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
} else {
v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
}
}
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0; //FIXME Is that so ?
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
case AV_PICTURE_TYPE_B:
if (v->fcm == ILACE_FRAME) {
v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
if (v->bfraction == 0) {
return -1;
}
}
if (v->extended_mv)
v->mvrange = get_unary(gb, 0, 3);
else
v->mvrange = 0;
v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
v->range_x = 1 << (v->k_x - 1);
v->range_y = 1 << (v->k_y - 1);
if (v->pq < 5)
v->tt_index = 0;
else if (v->pq < 13)
v->tt_index = 1;
else
v->tt_index = 2;
if (v->field_mode) {
int mvmode;
if (v->extended_dmv)
v->dmvrange = get_unary(gb, 0, 3);
mvmode = get_unary(gb, 1, 3);
lowquant = (v->pq > 12) ? 0 : 1;
v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode];
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV);
v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL);
status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
mbmodetab = get_bits(gb, 3);
if (v->mv_mode == MV_PMODE_MIXED_MV)
v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
else
v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
imvtab = get_bits(gb, 3);
v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
if (v->mv_mode == MV_PMODE_MIXED_MV) {
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
}
v->numref = 1; // interlaced field B pictures are always 2-ref
} else if (v->fcm == ILACE_FRAME) {
if (v->extended_dmv)
v->dmvrange = get_unary(gb, 0, 3);
if (get_bits1(gb)) /* intcomp - present but shall always be 0 */
av_log(v->s.avctx, AV_LOG_WARNING, "Intensity compensation set for B picture\n");
v->intcomp = 0;
v->mv_mode = MV_PMODE_1MV;
v->fourmvswitch = 0;
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = 1;
v->s.mspel = 1;
status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
mbmodetab = get_bits(gb, 2);
v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];
imvtab = get_bits(gb, 2);
v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
// interlaced p/b-picture cbpcy range is [1, 63]
icbptab = get_bits(gb, 3);
v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
twomvbptab = get_bits(gb, 2);
v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];
fourmvbptab = get_bits(gb, 2);
v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
} else {
v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
v->s.mspel = v->s.quarter_sample;
status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
}
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0;
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
}
if (v->fcm != PROGRESSIVE && !v->s.quarter_sample) {
v->range_x <<= 1;
v->range_y <<= 1;
}
/* AC Syntax */
v->c_ac_table_index = decode012(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->y_ac_table_index = decode012(gb);
}
/* DC Syntax */
v->s.dc_table_index = get_bits1(gb);
if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
&& v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->bi_type = 0;
if (v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->s.pict_type = AV_PICTURE_TYPE_B;
v->bi_type = 1;
}
return 0;
}
| 1
|
139,577
|
static int git_tcp_connect_sock(char *host, int flags)
{
struct strbuf error_message = STRBUF_INIT;
int sockfd = -1;
const char *port = STR(DEFAULT_GIT_PORT);
char *ep;
struct hostent *he;
struct sockaddr_in sa;
char **ap;
unsigned int nport;
int cnt;
get_host_and_port(&host, &port);
if (flags & CONNECT_VERBOSE)
fprintf(stderr, _("Looking up %s ... "), host);
he = gethostbyname(host);
if (!he)
die(_("unable to look up %s (%s)"), host, hstrerror(h_errno));
nport = strtoul(port, &ep, 10);
if ( ep == port || *ep ) {
/* Not numeric */
struct servent *se = getservbyname(port,"tcp");
if ( !se )
die(_("unknown port %s"), port);
nport = se->s_port;
}
if (flags & CONNECT_VERBOSE)
/* TRANSLATORS: this is the end of "Looking up %s ... " */
fprintf(stderr, _("done.\nConnecting to %s (port %s) ... "), host, port);
for (cnt = 0, ap = he->h_addr_list; *ap; ap++, cnt++) {
memset(&sa, 0, sizeof sa);
sa.sin_family = he->h_addrtype;
sa.sin_port = htons(nport);
memcpy(&sa.sin_addr, *ap, he->h_length);
sockfd = socket(he->h_addrtype, SOCK_STREAM, 0);
if ((sockfd < 0) ||
connect(sockfd, (struct sockaddr *)&sa, sizeof sa) < 0) {
strbuf_addf(&error_message, "%s[%d: %s]: errno=%s\n",
host,
cnt,
inet_ntoa(*(struct in_addr *)&sa.sin_addr),
strerror(errno));
if (0 <= sockfd)
close(sockfd);
sockfd = -1;
continue;
}
if (flags & CONNECT_VERBOSE)
fprintf(stderr, "%s ",
inet_ntoa(*(struct in_addr *)&sa.sin_addr));
break;
}
if (sockfd < 0)
die(_("unable to connect to %s:\n%s"), host, error_message.buf);
enable_keepalive(sockfd);
if (flags & CONNECT_VERBOSE)
/* TRANSLATORS: this is the end of "Connecting to %s (port %s) ... " */
fprintf_ln(stderr, _("done."));
return sockfd;
}
| 0
|
354,402
|
static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf)
{
if (sizeof ubuf->f_blocks == 4) {
if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) &
0xffffffff00000000ULL)
return -EOVERFLOW;
/* f_files and f_ffree may be -1; it's okay
* to stuff that into 32 bits */
if (kbuf->f_files != 0xffffffffffffffffULL
&& (kbuf->f_files & 0xffffffff00000000ULL))
return -EOVERFLOW;
if (kbuf->f_ffree != 0xffffffffffffffffULL
&& (kbuf->f_ffree & 0xffffffff00000000ULL))
return -EOVERFLOW;
}
if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
__put_user(kbuf->f_type, &ubuf->f_type) ||
__put_user(kbuf->f_bsize, &ubuf->f_bsize) ||
__put_user(kbuf->f_blocks, &ubuf->f_blocks) ||
__put_user(kbuf->f_bfree, &ubuf->f_bfree) ||
__put_user(kbuf->f_bavail, &ubuf->f_bavail) ||
__put_user(kbuf->f_files, &ubuf->f_files) ||
__put_user(kbuf->f_ffree, &ubuf->f_ffree) ||
__put_user(kbuf->f_namelen, &ubuf->f_namelen) ||
__put_user(kbuf->f_fsid.val[0], &ubuf->f_fsid.val[0]) ||
__put_user(kbuf->f_fsid.val[1], &ubuf->f_fsid.val[1]) ||
__put_user(kbuf->f_frsize, &ubuf->f_frsize))
return -EFAULT;
return 0;
}
| 0
|
106,177
|
void preproc_clean_run(void) {
int max_pids=32769;
int start_pid = 100;
// extract real max_pids
FILE *fp = fopen("/proc/sys/kernel/pid_max", "r");
if (fp) {
int val;
if (fscanf(fp, "%d", &val) == 1) {
if (val > 4194304) // this is the max value supported on 64 bit Linux kernels
val = 4194304;
if (val >= max_pids)
max_pids = val + 1;
}
fclose(fp);
}
int *pidarr = malloc(max_pids * sizeof(int));
if (!pidarr)
errExit("malloc");
memset(pidarr, 0, max_pids * sizeof(int));
// open /proc directory
DIR *dir;
if (!(dir = opendir("/proc"))) {
// sleep 2 seconds and try again
sleep(2);
if (!(dir = opendir("/proc"))) {
fprintf(stderr, "Error: cannot open /proc directory\n");
exit(1);
}
}
// read /proc and populate pidarr with all active processes
struct dirent *entry;
char *end;
while ((entry = readdir(dir)) != NULL) {
pid_t pid = strtol(entry->d_name, &end, 10);
pid %= max_pids;
if (end == entry->d_name || *end)
continue;
if (pid < start_pid)
continue;
pidarr[pid] = 1;
}
closedir(dir);
// clean profile and name directories
clean_dir(RUN_FIREJAIL_PROFILE_DIR, pidarr, start_pid, max_pids);
clean_dir(RUN_FIREJAIL_NAME_DIR, pidarr, start_pid, max_pids);
free(pidarr);
}
| 0
|
23,290
|
static UBool CnvExtAddTable ( NewConverter * cnvData , UCMTable * table , UConverterStaticData * staticData ) {
CnvExtData * extData ;
if ( table -> unicodeMask & UCNV_HAS_SURROGATES ) {
fprintf ( stderr , "error: contains mappings for surrogate code points\n" ) ;
return FALSE ;
}
staticData -> conversionType = UCNV_MBCS ;
extData = ( CnvExtData * ) cnvData ;
return makeToUTable ( extData , table ) && makeFromUTable ( extData , table ) ;
}
| 0
|
45,115
|
static void f2fs_dio_submit_bio(struct bio *bio, struct inode *inode,
loff_t file_offset)
{
struct f2fs_private_dio *dio;
bool write = (bio_op(bio) == REQ_OP_WRITE);
dio = f2fs_kzalloc(F2FS_I_SB(inode),
sizeof(struct f2fs_private_dio), GFP_NOFS);
if (!dio)
goto out;
dio->inode = inode;
dio->orig_end_io = bio->bi_end_io;
dio->orig_private = bio->bi_private;
dio->write = write;
bio->bi_end_io = f2fs_dio_end_io;
bio->bi_private = dio;
inc_page_count(F2FS_I_SB(inode),
write ? F2FS_DIO_WRITE : F2FS_DIO_READ);
submit_bio(bio);
return;
out:
bio->bi_status = BLK_STS_IOERR;
bio_endio(bio);
}
| 0
|
159,851
|
double ytr(
image_desc_t *im,
double value)
{
static double pixie;
double yval;
if (isnan(value)) {
if (!im->logarithmic)
pixie = (double) im->ysize / (im->maxval - im->minval);
else
pixie =
(double) im->ysize / (log10(im->maxval) - log10(im->minval));
yval = im->yorigin;
} else if (!im->logarithmic) {
yval = im->yorigin - pixie * (value - im->minval);
} else {
if (value < im->minval) {
yval = im->yorigin;
} else {
yval = im->yorigin - pixie * (log10(value) - log10(im->minval));
}
}
return yval;
}
| 0
|
228,793
|
void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) {
if ((type() & TYPE_POPUP) == 0) {
NOTREACHED() << "moving invalid browser type";
return;
}
window_->SetBounds(pos);
}
| 0
|
396,213
|
int stop_lru_maintainer_thread(void) {
int ret;
pthread_mutex_lock(&lru_maintainer_lock);
/* LRU thread is a sleep loop, will die on its own */
do_run_lru_maintainer_thread = 0;
pthread_mutex_unlock(&lru_maintainer_lock);
if ((ret = pthread_join(lru_maintainer_tid, NULL)) != 0) {
fprintf(stderr, "Failed to stop LRU maintainer thread: %s\n", strerror(ret));
return -1;
}
settings.lru_maintainer_thread = false;
return 0;
}
| 0
|
306,662
|
DECLARESepPutFunc(putRGBseparate16bittile)
{
uint16 *wr = (uint16*) r;
uint16 *wg = (uint16*) g;
uint16 *wb = (uint16*) b;
(void) img; (void) y; (void) a;
for( ; h > 0; --h) {
for (x = 0; x < w; x++)
*cp++ = PACK(img->Bitdepth16To8[*wr++],
img->Bitdepth16To8[*wg++],
img->Bitdepth16To8[*wb++]);
SKEW(wr, wg, wb, fromskew);
cp += toskew;
}
}
| 0
|
464,766
|
static void v4l_print_ext_controls(const void *arg, bool write_only)
{
const struct v4l2_ext_controls *p = arg;
int i;
pr_cont("which=0x%x, count=%d, error_idx=%d, request_fd=%d",
p->which, p->count, p->error_idx, p->request_fd);
for (i = 0; i < p->count; i++) {
unsigned int id = p->controls[i].id;
const char *name = v4l2_ctrl_get_name(id);
if (name)
pr_cont(", name=%s", name);
if (!p->controls[i].size)
pr_cont(", id/val=0x%x/0x%x", id, p->controls[i].value);
else
pr_cont(", id/size=0x%x/%u", id, p->controls[i].size);
}
pr_cont("\n");
}
| 0
|
205,091
|
CStarter::ShutdownFast( void )
{
bool jobRunning = false;
UserProc *job;
dprintf(D_ALWAYS, "ShutdownFast all jobs.\n");
if ( this->deferral_tid != -1 ) {
this->removeDeferredJobs();
}
m_job_list.Rewind();
while ((job = m_job_list.Next()) != NULL) {
if ( job->ShutdownFast() ) {
m_job_list.DeleteCurrent();
delete job;
} else {
jobRunning = true;
}
}
ShuttingDown = TRUE;
if (!jobRunning) {
dprintf(D_FULLDEBUG,
"Got ShutdownFast when no jobs running.\n");
return ( this->allJobsDone() );
}
return ( false );
}
| 0
|
208,663
|
void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Stream *maskStr,
int maskWidth, int maskHeight,
GBool maskInvert)
{
cairo_t *cr;
cairo_surface_t *surface;
double x1, y1, x2, y2;
double *ctm;
double mat[6];
CairoImage *image;
ctm = state->getCTM();
mat[0] = ctm[0];
mat[1] = ctm[1];
mat[2] = -ctm[2];
mat[3] = -ctm[3];
mat[4] = ctm[2] + ctm[4];
mat[5] = ctm[3] + ctm[5];
x1 = mat[4];
y1 = mat[5];
x2 = x1 + width;
y2 = y1 + height;
image = new CairoImage (x1, y1, x2, y2);
saveImage (image);
if (imgDrawCbk && imgDrawCbk (numImages - 1, imgDrawCbkData)) {
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
cr = cairo_create (surface);
setCairo (cr);
cairo_translate (cr, 0, height);
cairo_scale (cr, width, -height);
CairoOutputDev::drawMaskedImage(state, ref, str, width, height, colorMap,
maskStr, maskWidth, maskHeight, maskInvert);
image->setImage (surface);
setCairo (NULL);
cairo_surface_destroy (surface);
cairo_destroy (cr);
}
}
| 0
|
87,354
|
int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
u32 result)
{
struct sk_buff *msg;
void *hdr;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
NFC_CMD_FW_DOWNLOAD);
if (!hdr)
goto free_msg;
if (nla_put_string(msg, NFC_ATTR_FIRMWARE_NAME, firmware_name) ||
nla_put_u32(msg, NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, result) ||
nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
goto nla_put_failure;
genlmsg_end(msg, hdr);
genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
return 0;
nla_put_failure:
free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
}
| 0
|
200,404
|
WallpaperManagerBrowserTest() : controller_(NULL),
local_state_(NULL) {
}
| 0
|
311,770
|
void Clipboard::WriteWebSmartPaste() {
InsertMapping(kMimeTypeWebkitSmartPaste, NULL, 0);
}
| 0
|
286,507
|
limit_bandwidth (wgint bytes, struct ptimer *timer)
{
double delta_t = ptimer_read (timer) - limit_data.chunk_start;
double expected;
limit_data.chunk_bytes += bytes;
/* Calculate the amount of time we expect downloading the chunk
should take. If in reality it took less time, sleep to
compensate for the difference. */
expected = (double) limit_data.chunk_bytes / opt.limit_rate;
if (expected > delta_t)
{
double slp = expected - delta_t + limit_data.sleep_adjust;
double t0, t1;
if (slp < 0.2)
{
DEBUGP (("deferring a %.2f ms sleep (%s/%.2f).\n",
slp * 1000, number_to_static_string (limit_data.chunk_bytes),
delta_t));
return;
}
DEBUGP (("\nsleeping %.2f ms for %s bytes, adjust %.2f ms\n",
slp * 1000, number_to_static_string (limit_data.chunk_bytes),
limit_data.sleep_adjust));
t0 = ptimer_read (timer);
xsleep (slp);
t1 = ptimer_measure (timer);
/* Due to scheduling, we probably slept slightly longer (or
shorter) than desired. Calculate the difference between the
desired and the actual sleep, and adjust the next sleep by
that amount. */
limit_data.sleep_adjust = slp - (t1 - t0);
/* If sleep_adjust is very large, it's likely due to suspension
and not clock inaccuracy. Don't enforce those. */
if (limit_data.sleep_adjust > 0.5)
limit_data.sleep_adjust = 0.5;
else if (limit_data.sleep_adjust < -0.5)
limit_data.sleep_adjust = -0.5;
}
limit_data.chunk_bytes = 0;
limit_data.chunk_start = ptimer_read (timer);
}
| 0
|
233,550
|
static int aesni_cbc_hmac_sha256_cipher(EVP_CIPHER_CTX *ctx,
unsigned char *out,
const unsigned char *in, size_t len)
{
EVP_AES_HMAC_SHA256 *key = data(ctx);
unsigned int l;
size_t plen = key->payload_length, iv = 0, /* explicit IV in TLS 1.1 and
* later */
sha_off = 0;
# if defined(STITCHED_CALL)
size_t aes_off = 0, blocks;
sha_off = SHA256_CBLOCK - key->md.num;
# endif
key->payload_length = NO_PAYLOAD_LENGTH;
if (len % AES_BLOCK_SIZE)
return 0;
if (ctx->encrypt) {
if (plen == NO_PAYLOAD_LENGTH)
plen = len;
else if (len !=
((plen + SHA256_DIGEST_LENGTH +
AES_BLOCK_SIZE) & -AES_BLOCK_SIZE))
return 0;
else if (key->aux.tls_ver >= TLS1_1_VERSION)
iv = AES_BLOCK_SIZE;
# if defined(STITCHED_CALL)
/*
* Assembly stitch handles AVX-capable processors, but its
* performance is not optimal on AMD Jaguar, ~40% worse, for
* unknown reasons. Incidentally processor in question supports
* AVX, but not AMD-specific XOP extension, which can be used
* to identify it and avoid stitch invocation. So that after we
* establish that current CPU supports AVX, we even see if it's
* either even XOP-capable Bulldozer-based or GenuineIntel one.
*/
if (OPENSSL_ia32cap_P[1] & (1 << (60 - 32)) && /* AVX? */
((OPENSSL_ia32cap_P[1] & (1 << (43 - 32))) /* XOP? */
| (OPENSSL_ia32cap_P[0] & (1<<30))) && /* "Intel CPU"? */
plen > (sha_off + iv) &&
(blocks = (plen - (sha_off + iv)) / SHA256_CBLOCK)) {
SHA256_Update(&key->md, in + iv, sha_off);
(void)aesni_cbc_sha256_enc(in, out, blocks, &key->ks,
ctx->iv, &key->md, in + iv + sha_off);
blocks *= SHA256_CBLOCK;
aes_off += blocks;
sha_off += blocks;
key->md.Nh += blocks >> 29;
key->md.Nl += blocks <<= 3;
if (key->md.Nl < (unsigned int)blocks)
key->md.Nh++;
} else {
sha_off = 0;
}
# endif
sha_off += iv;
SHA256_Update(&key->md, in + sha_off, plen - sha_off);
if (plen != len) { /* "TLS" mode of operation */
if (in != out)
memcpy(out + aes_off, in + aes_off, plen - aes_off);
/* calculate HMAC and append it to payload */
SHA256_Final(out + plen, &key->md);
key->md = key->tail;
SHA256_Update(&key->md, out + plen, SHA256_DIGEST_LENGTH);
SHA256_Final(out + plen, &key->md);
/* pad the payload|hmac */
plen += SHA256_DIGEST_LENGTH;
for (l = len - plen - 1; plen < len; plen++)
out[plen] = l;
/* encrypt HMAC|padding at once */
aesni_cbc_encrypt(out + aes_off, out + aes_off, len - aes_off,
&key->ks, ctx->iv, 1);
} else {
aesni_cbc_encrypt(in + aes_off, out + aes_off, len - aes_off,
&key->ks, ctx->iv, 1);
}
} else {
union {
unsigned int u[SHA256_DIGEST_LENGTH / sizeof(unsigned int)];
unsigned char c[64 + SHA256_DIGEST_LENGTH];
} mac, *pmac;
/* arrange cache line alignment */
pmac = (void *)(((size_t)mac.c + 63) & ((size_t)0 - 64));
/* decrypt HMAC|padding at once */
aesni_cbc_encrypt(in, out, len, &key->ks, ctx->iv, 0);
if (plen != NO_PAYLOAD_LENGTH) { /* "TLS" mode of operation */
size_t inp_len, mask, j, i;
unsigned int res, maxpad, pad, bitlen;
int ret = 1;
union {
unsigned int u[SHA_LBLOCK];
unsigned char c[SHA256_CBLOCK];
} *data = (void *)key->md.data;
if ((key->aux.tls_aad[plen - 4] << 8 | key->aux.tls_aad[plen - 3])
>= TLS1_1_VERSION)
iv = AES_BLOCK_SIZE;
if (len < (iv + SHA256_DIGEST_LENGTH + 1))
return 0;
/* omit explicit iv */
out += iv;
len -= iv;
/* figure out payload length */
pad = out[len - 1];
maxpad = len - (SHA256_DIGEST_LENGTH + 1);
maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8);
maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8);
maxpad &= 255;
ret &= constant_time_ge(maxpad, pad);
inp_len = len - (SHA256_DIGEST_LENGTH + pad + 1);
mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1)));
inp_len &= mask;
key->aux.tls_aad[plen - 1] = inp_len;
/* calculate HMAC */
key->md = key->head;
SHA256_Update(&key->md, key->aux.tls_aad, plen);
# if 1
len -= SHA256_DIGEST_LENGTH; /* amend mac */
if (len >= (256 + SHA256_CBLOCK)) {
j = (len - (256 + SHA256_CBLOCK)) & (0 - SHA256_CBLOCK);
j += SHA256_CBLOCK - key->md.num;
SHA256_Update(&key->md, out, j);
out += j;
len -= j;
inp_len -= j;
}
/* but pretend as if we hashed padded payload */
bitlen = key->md.Nl + (inp_len << 3); /* at most 18 bits */
# ifdef BSWAP4
bitlen = BSWAP4(bitlen);
# else
mac.c[0] = 0;
mac.c[1] = (unsigned char)(bitlen >> 16);
mac.c[2] = (unsigned char)(bitlen >> 8);
mac.c[3] = (unsigned char)bitlen;
bitlen = mac.u[0];
# endif
pmac->u[0] = 0;
pmac->u[1] = 0;
pmac->u[2] = 0;
pmac->u[3] = 0;
pmac->u[4] = 0;
pmac->u[5] = 0;
pmac->u[6] = 0;
pmac->u[7] = 0;
for (res = key->md.num, j = 0; j < len; j++) {
size_t c = out[j];
mask = (j - inp_len) >> (sizeof(j) * 8 - 8);
c &= mask;
c |= 0x80 & ~mask & ~((inp_len - j) >> (sizeof(j) * 8 - 8));
data->c[res++] = (unsigned char)c;
if (res != SHA256_CBLOCK)
continue;
/* j is not incremented yet */
mask = 0 - ((inp_len + 7 - j) >> (sizeof(j) * 8 - 1));
data->u[SHA_LBLOCK - 1] |= bitlen & mask;
sha256_block_data_order(&key->md, data, 1);
mask &= 0 - ((j - inp_len - 72) >> (sizeof(j) * 8 - 1));
pmac->u[0] |= key->md.h[0] & mask;
pmac->u[1] |= key->md.h[1] & mask;
pmac->u[2] |= key->md.h[2] & mask;
pmac->u[3] |= key->md.h[3] & mask;
pmac->u[4] |= key->md.h[4] & mask;
pmac->u[5] |= key->md.h[5] & mask;
pmac->u[6] |= key->md.h[6] & mask;
pmac->u[7] |= key->md.h[7] & mask;
res = 0;
}
for (i = res; i < SHA256_CBLOCK; i++, j++)
data->c[i] = 0;
if (res > SHA256_CBLOCK - 8) {
mask = 0 - ((inp_len + 8 - j) >> (sizeof(j) * 8 - 1));
data->u[SHA_LBLOCK - 1] |= bitlen & mask;
sha256_block_data_order(&key->md, data, 1);
mask &= 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1));
pmac->u[0] |= key->md.h[0] & mask;
pmac->u[1] |= key->md.h[1] & mask;
pmac->u[2] |= key->md.h[2] & mask;
pmac->u[3] |= key->md.h[3] & mask;
pmac->u[4] |= key->md.h[4] & mask;
pmac->u[5] |= key->md.h[5] & mask;
pmac->u[6] |= key->md.h[6] & mask;
pmac->u[7] |= key->md.h[7] & mask;
memset(data, 0, SHA256_CBLOCK);
j += 64;
}
data->u[SHA_LBLOCK - 1] = bitlen;
sha256_block_data_order(&key->md, data, 1);
mask = 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1));
pmac->u[0] |= key->md.h[0] & mask;
pmac->u[1] |= key->md.h[1] & mask;
pmac->u[2] |= key->md.h[2] & mask;
pmac->u[3] |= key->md.h[3] & mask;
pmac->u[4] |= key->md.h[4] & mask;
pmac->u[5] |= key->md.h[5] & mask;
pmac->u[6] |= key->md.h[6] & mask;
pmac->u[7] |= key->md.h[7] & mask;
# ifdef BSWAP4
pmac->u[0] = BSWAP4(pmac->u[0]);
pmac->u[1] = BSWAP4(pmac->u[1]);
pmac->u[2] = BSWAP4(pmac->u[2]);
pmac->u[3] = BSWAP4(pmac->u[3]);
pmac->u[4] = BSWAP4(pmac->u[4]);
pmac->u[5] = BSWAP4(pmac->u[5]);
pmac->u[6] = BSWAP4(pmac->u[6]);
pmac->u[7] = BSWAP4(pmac->u[7]);
# else
for (i = 0; i < 8; i++) {
res = pmac->u[i];
pmac->c[4 * i + 0] = (unsigned char)(res >> 24);
pmac->c[4 * i + 1] = (unsigned char)(res >> 16);
pmac->c[4 * i + 2] = (unsigned char)(res >> 8);
pmac->c[4 * i + 3] = (unsigned char)res;
}
# endif
len += SHA256_DIGEST_LENGTH;
# else
SHA256_Update(&key->md, out, inp_len);
res = key->md.num;
SHA256_Final(pmac->c, &key->md);
{
unsigned int inp_blocks, pad_blocks;
/* but pretend as if we hashed padded payload */
inp_blocks =
1 + ((SHA256_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1));
res += (unsigned int)(len - inp_len);
pad_blocks = res / SHA256_CBLOCK;
res %= SHA256_CBLOCK;
pad_blocks +=
1 + ((SHA256_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1));
for (; inp_blocks < pad_blocks; inp_blocks++)
sha1_block_data_order(&key->md, data, 1);
}
# endif
key->md = key->tail;
SHA256_Update(&key->md, pmac->c, SHA256_DIGEST_LENGTH);
SHA256_Final(pmac->c, &key->md);
/* verify HMAC */
out += inp_len;
len -= inp_len;
# if 1
{
unsigned char *p =
out + len - 1 - maxpad - SHA256_DIGEST_LENGTH;
size_t off = out - p;
unsigned int c, cmask;
maxpad += SHA256_DIGEST_LENGTH;
for (res = 0, i = 0, j = 0; j < maxpad; j++) {
c = p[j];
cmask =
((int)(j - off - SHA256_DIGEST_LENGTH)) >>
(sizeof(int) * 8 - 1);
res |= (c ^ pad) & ~cmask; /* ... and padding */
cmask &= ((int)(off - 1 - j)) >> (sizeof(int) * 8 - 1);
res |= (c ^ pmac->c[i]) & cmask;
i += 1 & cmask;
}
maxpad -= SHA256_DIGEST_LENGTH;
res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1));
ret &= (int)~res;
}
# else
for (res = 0, i = 0; i < SHA256_DIGEST_LENGTH; i++)
res |= out[i] ^ pmac->c[i];
res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1));
ret &= (int)~res;
/* verify padding */
pad = (pad & ~res) | (maxpad & res);
out = out + len - 1 - pad;
for (res = 0, i = 0; i < pad; i++)
res |= out[i] ^ pad;
res = (0 - res) >> (sizeof(res) * 8 - 1);
ret &= (int)~res;
# endif
return ret;
} else {
SHA256_Update(&key->md, out, len);
}
}
return 1;
}
| 0
|
118,386
|
static unsigned long xen_get_debugreg(int reg)
{
return HYPERVISOR_get_debugreg(reg);
}
| 0
|
324,758
|
static uint16_t pci_req_id_cache_extract(PCIReqIDCache *cache)
{
uint8_t bus_n;
uint16_t result;
switch (cache->type) {
case PCI_REQ_ID_BDF:
result = pci_get_bdf(cache->dev);
break;
case PCI_REQ_ID_SECONDARY_BUS:
bus_n = pci_bus_num(cache->dev->bus);
result = PCI_BUILD_BDF(bus_n, 0);
break;
default:
error_printf("Invalid PCI requester ID cache type: %d\n",
cache->type);
exit(1);
break;
}
return result;
}
| 0
|
419,165
|
format_defaults_winlink(struct format_tree *ft, struct winlink *wl)
{
struct client *c = ft->c;
struct session *s = wl->session;
struct window *w = wl->window;
int flag;
u_int ox, oy, sx, sy;
if (ft->w == NULL)
ft->w = wl->window;
ft->wl = wl;
format_defaults_window(ft, w);
if (c != NULL) {
flag = tty_window_offset(&c->tty, &ox, &oy, &sx, &sy);
format_add(ft, "window_bigger", "%d", flag);
if (flag) {
format_add(ft, "window_offset_x", "%u", ox);
format_add(ft, "window_offset_y", "%u", oy);
}
}
format_add(ft, "window_index", "%d", wl->idx);
format_add_cb(ft, "window_stack_index", format_cb_window_stack_index);
format_add(ft, "window_flags", "%s", window_printable_flags(wl));
format_add(ft, "window_active", "%d", wl == s->curw);
format_add(ft, "window_bell_flag", "%d",
!!(wl->flags & WINLINK_BELL));
format_add(ft, "window_activity_flag", "%d",
!!(wl->flags & WINLINK_ACTIVITY));
format_add(ft, "window_silence_flag", "%d",
!!(wl->flags & WINLINK_SILENCE));
format_add(ft, "window_last_flag", "%d",
!!(wl == TAILQ_FIRST(&s->lastw)));
format_add(ft, "window_linked", "%d", session_is_linked(s, wl->window));
}
| 0
|
469,430
|
void udp_detach(struct socket *so)
{
so->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);
closesocket(so->s);
sofree(so);
}
| 0
|
440,381
|
PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
{
const char *p;
const char *endptr = val + vallen;
int namelen;
zend_string *name;
php_unserialize_data_t var_hash;
zval *current, rv;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
for (p = val; p < endptr; ) {
namelen = ((unsigned char)(*p)) & (~PS_BIN_UNDEF);
if (namelen < 0 || namelen > PS_BIN_MAX || (p + namelen) >= endptr) {
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return FAILURE;
}
name = zend_string_init(p + 1, namelen, 0);
p += namelen + 1;
current = var_tmp_var(&var_hash);
if (php_var_unserialize(current, (const unsigned char **) &p, (const unsigned char *) endptr, &var_hash)) {
ZVAL_PTR(&rv, current);
php_set_session_var(name, &rv, &var_hash);
} else {
zend_string_release(name);
php_session_normalize_vars();
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return FAILURE;
}
zend_string_release(name);
}
php_session_normalize_vars();
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return SUCCESS;
}
| 0
|
172,213
|
static void coin_cleanup(void* c)
{
uivector_cleanup(&((Coin*)c)->symbols);
}
| 0
|
205,402
|
native_handle* Parcel::readNativeHandle() const
{
int numFds, numInts;
status_t err;
err = readInt32(&numFds);
if (err != NO_ERROR) return 0;
err = readInt32(&numInts);
if (err != NO_ERROR) return 0;
native_handle* h = native_handle_create(numFds, numInts);
if (!h) {
return 0;
}
for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
h->data[i] = dup(readFileDescriptor());
if (h->data[i] < 0) err = BAD_VALUE;
}
err = read(h->data + numFds, sizeof(int)*numInts);
if (err != NO_ERROR) {
native_handle_close(h);
native_handle_delete(h);
h = 0;
}
return h;
}
| 0
|
40,490
|
ASC_setPresentationAddresses(T_ASC_Parameters * params,
const char* callingPresentationAddress,
const char* calledPresentationAddress)
{
if (callingPresentationAddress)
OFStandard::strlcpy(params->DULparams.callingPresentationAddress,
callingPresentationAddress,
sizeof(params->DULparams.callingPresentationAddress));
if (calledPresentationAddress)
OFStandard::strlcpy(params->DULparams.calledPresentationAddress,
calledPresentationAddress,
sizeof(params->DULparams.calledPresentationAddress));
return EC_Normal;
}
| 0
|
238,839
|
png_get_rows(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->row_pointers);
else
return(0);
}
| 0
|
275,543
|
PHP_FUNCTION(openssl_x509_fingerprint)
{
X509 *cert;
zval **zcert;
long certresource;
zend_bool raw_output = 0;
char *method = "sha1";
int method_len;
char *fingerprint;
int fingerprint_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|sb", &zcert, &method, &method_len, &raw_output) == FAILURE) {
return;
}
cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);
if (cert == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1");
RETURN_FALSE;
}
if (php_openssl_x509_fingerprint(cert, method, raw_output, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) {
RETVAL_STRINGL(fingerprint, fingerprint_len, 0);
} else {
RETVAL_FALSE;
}
if (certresource == -1 && cert) {
X509_free(cert);
}
}
| 0
|
315,215
|
virtual bool ShouldRemoveSelectOnChange() const { return false; }
| 0
|
157,559
|
static ZIPARCHIVE_METHOD(renameName)
{
struct zip *intern;
zval *self = getThis();
struct zip_stat sb;
char *name, *new_name;
size_t name_len, new_name_len;
if (!self) {
RETURN_FALSE;
}
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &new_name, &new_name_len) == FAILURE) {
return;
}
if (new_name_len < 1) {
php_error_docref(NULL, E_NOTICE, "Empty string as new entry name");
RETURN_FALSE;
}
PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb);
if (zip_rename(intern, sb.index, (const char *)new_name)) {
RETURN_FALSE;
}
RETURN_TRUE;
}
| 0
|
78,050
|
userauth_pubkey(Authctxt *authctxt)
{
Identity *id;
int sent = 0;
while ((id = TAILQ_FIRST(&authctxt->keys))) {
if (id->tried++)
return (0);
/* move key to the end of the queue */
TAILQ_REMOVE(&authctxt->keys, id, next);
TAILQ_INSERT_TAIL(&authctxt->keys, id, next);
/*
* send a test message if we have the public key. for
* encrypted keys we cannot do this and have to load the
* private key instead
*/
if (id->key != NULL) {
if (try_identity(id)) {
debug("Offering %s public key: %s",
key_type(id->key), id->filename);
sent = send_pubkey_test(authctxt, id);
}
} else {
debug("Trying private key: %s", id->filename);
id->key = load_identity_file(id);
if (id->key != NULL) {
if (try_identity(id)) {
id->isprivate = 1;
sent = sign_and_send_pubkey(
authctxt, id);
}
key_free(id->key);
id->key = NULL;
}
}
if (sent)
return (sent);
}
return (0);
}
| 0
|
30,676
|
static void remap_codebooks ( RoqContext * enc , RoqTempdata * tempData ) {
int i , j , idx = 0 ;
for ( i = 0 ;
i < MAX_CBS_4x4 ;
i ++ ) {
if ( tempData -> codebooks . usedCB4 [ i ] ) {
tempData -> i2f4 [ i ] = idx ;
tempData -> f2i4 [ idx ] = i ;
for ( j = 0 ;
j < 4 ;
j ++ ) tempData -> codebooks . usedCB2 [ enc -> cb4x4 [ i ] . idx [ j ] ] ++ ;
idx ++ ;
}
}
tempData -> numCB4 = idx ;
idx = 0 ;
for ( i = 0 ;
i < MAX_CBS_2x2 ;
i ++ ) {
if ( tempData -> codebooks . usedCB2 [ i ] ) {
tempData -> i2f2 [ i ] = idx ;
tempData -> f2i2 [ idx ] = i ;
idx ++ ;
}
}
tempData -> numCB2 = idx ;
}
| 0
|
171,506
|
status_t ProCamera2Client::getCameraInfo(int cameraId,
/*out*/
camera_metadata** info)
{
if (cameraId != mCameraId) {
return INVALID_OPERATION;
}
Mutex::Autolock icl(mBinderSerializationLock);
if (!mDevice.get()) return DEAD_OBJECT;
CameraMetadata deviceInfo = mDevice->info();
*info = deviceInfo.release();
return OK;
}
| 0
|
293,923
|
static unsigned int comedi_poll(struct file *file, poll_table * wait)
{
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device *dev = dev_file_info->device;
struct comedi_subdevice *read_subdev;
struct comedi_subdevice *write_subdev;
mutex_lock(&dev->mutex);
if (!dev->attached) {
DPRINTK("no driver configured on comedi%i\n", dev->minor);
mutex_unlock(&dev->mutex);
return 0;
}
mask = 0;
read_subdev = comedi_get_read_subdevice(dev_file_info);
if (read_subdev) {
poll_wait(file, &read_subdev->async->wait_head, wait);
if (!read_subdev->busy
|| comedi_buf_read_n_available(read_subdev->async) > 0
|| !(comedi_get_subdevice_runflags(read_subdev) &
SRF_RUNNING)) {
mask |= POLLIN | POLLRDNORM;
}
}
write_subdev = comedi_get_write_subdevice(dev_file_info);
if (write_subdev) {
poll_wait(file, &write_subdev->async->wait_head, wait);
comedi_buf_write_alloc(write_subdev->async,
write_subdev->async->prealloc_bufsz);
if (!write_subdev->busy
|| !(comedi_get_subdevice_runflags(write_subdev) &
SRF_RUNNING)
|| comedi_buf_write_n_allocated(write_subdev->async) >=
bytes_per_sample(write_subdev->async->subdevice)) {
mask |= POLLOUT | POLLWRNORM;
}
}
mutex_unlock(&dev->mutex);
return mask;
}
| 0
|
159,870
|
static inline void set_page_pfmemalloc(struct page *page)
{
page->index = -1UL;
}
| 0
|
71,582
|
static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
{
int r;
bool req_int_win =
dm_request_for_irq_injection(vcpu) &&
kvm_cpu_accept_dm_intr(vcpu);
fastpath_t exit_fastpath;
bool req_immediate_exit = false;
/* Forbid vmenter if vcpu dirty ring is soft-full */
if (unlikely(vcpu->kvm->dirty_ring_size &&
kvm_dirty_ring_soft_full(&vcpu->dirty_ring))) {
vcpu->run->exit_reason = KVM_EXIT_DIRTY_RING_FULL;
trace_kvm_dirty_ring_exit(vcpu);
r = 0;
goto out;
}
if (kvm_request_pending(vcpu)) {
if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) {
r = -EIO;
goto out;
}
if (kvm_check_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu)) {
if (unlikely(!kvm_x86_ops.nested_ops->get_nested_state_pages(vcpu))) {
r = 0;
goto out;
}
}
if (kvm_check_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu))
kvm_mmu_free_obsolete_roots(vcpu);
if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu))
__kvm_migrate_timers(vcpu);
if (kvm_check_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu))
kvm_update_masterclock(vcpu->kvm);
if (kvm_check_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu))
kvm_gen_kvmclock_update(vcpu);
if (kvm_check_request(KVM_REQ_CLOCK_UPDATE, vcpu)) {
r = kvm_guest_time_update(vcpu);
if (unlikely(r))
goto out;
}
if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu))
kvm_mmu_sync_roots(vcpu);
if (kvm_check_request(KVM_REQ_LOAD_MMU_PGD, vcpu))
kvm_mmu_load_pgd(vcpu);
if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) {
kvm_vcpu_flush_tlb_all(vcpu);
/* Flushing all ASIDs flushes the current ASID... */
kvm_clear_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu);
}
kvm_service_local_tlb_flush_requests(vcpu);
if (kvm_check_request(KVM_REQ_REPORT_TPR_ACCESS, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS;
r = 0;
goto out;
}
if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
if (is_guest_mode(vcpu)) {
kvm_x86_ops.nested_ops->triple_fault(vcpu);
} else {
vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;
vcpu->mmio_needed = 0;
r = 0;
goto out;
}
}
if (kvm_check_request(KVM_REQ_APF_HALT, vcpu)) {
/* Page is swapped out. Do synthetic halt */
vcpu->arch.apf.halted = true;
r = 1;
goto out;
}
if (kvm_check_request(KVM_REQ_STEAL_UPDATE, vcpu))
record_steal_time(vcpu);
if (kvm_check_request(KVM_REQ_SMI, vcpu))
process_smi(vcpu);
if (kvm_check_request(KVM_REQ_NMI, vcpu))
process_nmi(vcpu);
if (kvm_check_request(KVM_REQ_PMU, vcpu))
kvm_pmu_handle_event(vcpu);
if (kvm_check_request(KVM_REQ_PMI, vcpu))
kvm_pmu_deliver_pmi(vcpu);
if (kvm_check_request(KVM_REQ_IOAPIC_EOI_EXIT, vcpu)) {
BUG_ON(vcpu->arch.pending_ioapic_eoi > 255);
if (test_bit(vcpu->arch.pending_ioapic_eoi,
vcpu->arch.ioapic_handled_vectors)) {
vcpu->run->exit_reason = KVM_EXIT_IOAPIC_EOI;
vcpu->run->eoi.vector =
vcpu->arch.pending_ioapic_eoi;
r = 0;
goto out;
}
}
if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu))
vcpu_scan_ioapic(vcpu);
if (kvm_check_request(KVM_REQ_LOAD_EOI_EXITMAP, vcpu))
vcpu_load_eoi_exitmap(vcpu);
if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))
kvm_vcpu_reload_apic_access_page(vcpu);
if (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH;
vcpu->run->system_event.ndata = 0;
r = 0;
goto out;
}
if (kvm_check_request(KVM_REQ_HV_RESET, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
vcpu->run->system_event.type = KVM_SYSTEM_EVENT_RESET;
vcpu->run->system_event.ndata = 0;
r = 0;
goto out;
}
if (kvm_check_request(KVM_REQ_HV_EXIT, vcpu)) {
struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
vcpu->run->exit_reason = KVM_EXIT_HYPERV;
vcpu->run->hyperv = hv_vcpu->exit;
r = 0;
goto out;
}
/*
* KVM_REQ_HV_STIMER has to be processed after
* KVM_REQ_CLOCK_UPDATE, because Hyper-V SynIC timers
* depend on the guest clock being up-to-date
*/
if (kvm_check_request(KVM_REQ_HV_STIMER, vcpu))
kvm_hv_process_stimers(vcpu);
if (kvm_check_request(KVM_REQ_APICV_UPDATE, vcpu))
kvm_vcpu_update_apicv(vcpu);
if (kvm_check_request(KVM_REQ_APF_READY, vcpu))
kvm_check_async_pf_completion(vcpu);
if (kvm_check_request(KVM_REQ_MSR_FILTER_CHANGED, vcpu))
static_call(kvm_x86_msr_filter_changed)(vcpu);
if (kvm_check_request(KVM_REQ_UPDATE_CPU_DIRTY_LOGGING, vcpu))
static_call(kvm_x86_update_cpu_dirty_logging)(vcpu);
}
if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win ||
kvm_xen_has_interrupt(vcpu)) {
++vcpu->stat.req_event;
r = kvm_apic_accept_events(vcpu);
if (r < 0) {
r = 0;
goto out;
}
if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
r = 1;
goto out;
}
r = inject_pending_event(vcpu, &req_immediate_exit);
if (r < 0) {
r = 0;
goto out;
}
if (req_int_win)
static_call(kvm_x86_enable_irq_window)(vcpu);
if (kvm_lapic_enabled(vcpu)) {
update_cr8_intercept(vcpu);
kvm_lapic_sync_to_vapic(vcpu);
}
}
r = kvm_mmu_reload(vcpu);
if (unlikely(r)) {
goto cancel_injection;
}
preempt_disable();
static_call(kvm_x86_prepare_switch_to_guest)(vcpu);
/*
* Disable IRQs before setting IN_GUEST_MODE. Posted interrupt
* IPI are then delayed after guest entry, which ensures that they
* result in virtual interrupt delivery.
*/
local_irq_disable();
/* Store vcpu->apicv_active before vcpu->mode. */
smp_store_release(&vcpu->mode, IN_GUEST_MODE);
kvm_vcpu_srcu_read_unlock(vcpu);
/*
* 1) We should set ->mode before checking ->requests. Please see
* the comment in kvm_vcpu_exiting_guest_mode().
*
* 2) For APICv, we should set ->mode before checking PID.ON. This
* pairs with the memory barrier implicit in pi_test_and_set_on
* (see vmx_deliver_posted_interrupt).
*
* 3) This also orders the write to mode from any reads to the page
* tables done while the VCPU is running. Please see the comment
* in kvm_flush_remote_tlbs.
*/
smp_mb__after_srcu_read_unlock();
/*
* Process pending posted interrupts to handle the case where the
* notification IRQ arrived in the host, or was never sent (because the
* target vCPU wasn't running). Do this regardless of the vCPU's APICv
* status, KVM doesn't update assigned devices when APICv is inhibited,
* i.e. they can post interrupts even if APICv is temporarily disabled.
*/
if (kvm_lapic_enabled(vcpu))
static_call_cond(kvm_x86_sync_pir_to_irr)(vcpu);
if (kvm_vcpu_exit_request(vcpu)) {
vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb();
local_irq_enable();
preempt_enable();
kvm_vcpu_srcu_read_lock(vcpu);
r = 1;
goto cancel_injection;
}
if (req_immediate_exit) {
kvm_make_request(KVM_REQ_EVENT, vcpu);
static_call(kvm_x86_request_immediate_exit)(vcpu);
}
fpregs_assert_state_consistent();
if (test_thread_flag(TIF_NEED_FPU_LOAD))
switch_fpu_return();
if (vcpu->arch.guest_fpu.xfd_err)
wrmsrl(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err);
if (unlikely(vcpu->arch.switch_db_regs)) {
set_debugreg(0, 7);
set_debugreg(vcpu->arch.eff_db[0], 0);
set_debugreg(vcpu->arch.eff_db[1], 1);
set_debugreg(vcpu->arch.eff_db[2], 2);
set_debugreg(vcpu->arch.eff_db[3], 3);
} else if (unlikely(hw_breakpoint_active())) {
set_debugreg(0, 7);
}
guest_timing_enter_irqoff();
for (;;) {
/*
* Assert that vCPU vs. VM APICv state is consistent. An APICv
* update must kick and wait for all vCPUs before toggling the
* per-VM state, and responsing vCPUs must wait for the update
* to complete before servicing KVM_REQ_APICV_UPDATE.
*/
WARN_ON_ONCE(kvm_vcpu_apicv_activated(vcpu) != kvm_vcpu_apicv_active(vcpu));
exit_fastpath = static_call(kvm_x86_vcpu_run)(vcpu);
if (likely(exit_fastpath != EXIT_FASTPATH_REENTER_GUEST))
break;
if (kvm_lapic_enabled(vcpu))
static_call_cond(kvm_x86_sync_pir_to_irr)(vcpu);
if (unlikely(kvm_vcpu_exit_request(vcpu))) {
exit_fastpath = EXIT_FASTPATH_EXIT_HANDLED;
break;
}
}
/*
* Do this here before restoring debug registers on the host. And
* since we do this before handling the vmexit, a DR access vmexit
* can (a) read the correct value of the debug registers, (b) set
* KVM_DEBUGREG_WONT_EXIT again.
*/
if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {
WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
static_call(kvm_x86_sync_dirty_debug_regs)(vcpu);
kvm_update_dr0123(vcpu);
kvm_update_dr7(vcpu);
}
/*
* If the guest has used debug registers, at least dr7
* will be disabled while returning to the host.
* If we don't have active breakpoints in the host, we don't
* care about the messed up debug address registers. But if
* we have some of them active, restore the old state.
*/
if (hw_breakpoint_active())
hw_breakpoint_restore();
vcpu->arch.last_vmentry_cpu = vcpu->cpu;
vcpu->arch.last_guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc());
vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb();
/*
* Sync xfd before calling handle_exit_irqoff() which may
* rely on the fact that guest_fpu::xfd is up-to-date (e.g.
* in #NM irqoff handler).
*/
if (vcpu->arch.xfd_no_write_intercept)
fpu_sync_guest_vmexit_xfd_state();
static_call(kvm_x86_handle_exit_irqoff)(vcpu);
if (vcpu->arch.guest_fpu.xfd_err)
wrmsrl(MSR_IA32_XFD_ERR, 0);
/*
* Consume any pending interrupts, including the possible source of
* VM-Exit on SVM and any ticks that occur between VM-Exit and now.
* An instruction is required after local_irq_enable() to fully unblock
* interrupts on processors that implement an interrupt shadow, the
* stat.exits increment will do nicely.
*/
kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ);
local_irq_enable();
++vcpu->stat.exits;
local_irq_disable();
kvm_after_interrupt(vcpu);
/*
* Wait until after servicing IRQs to account guest time so that any
* ticks that occurred while running the guest are properly accounted
* to the guest. Waiting until IRQs are enabled degrades the accuracy
* of accounting via context tracking, but the loss of accuracy is
* acceptable for all known use cases.
*/
guest_timing_exit_irqoff();
local_irq_enable();
preempt_enable();
kvm_vcpu_srcu_read_lock(vcpu);
/*
* Profile KVM exit RIPs:
*/
if (unlikely(prof_on == KVM_PROFILING)) {
unsigned long rip = kvm_rip_read(vcpu);
profile_hit(KVM_PROFILING, (void *)rip);
}
if (unlikely(vcpu->arch.tsc_always_catchup))
kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
if (vcpu->arch.apic_attention)
kvm_lapic_sync_from_vapic(vcpu);
r = static_call(kvm_x86_handle_exit)(vcpu, exit_fastpath);
return r;
cancel_injection:
if (req_immediate_exit)
kvm_make_request(KVM_REQ_EVENT, vcpu);
static_call(kvm_x86_cancel_injection)(vcpu);
if (unlikely(vcpu->arch.apic_attention))
kvm_lapic_sync_from_vapic(vcpu);
out:
return r;
}
| 0
|
303,837
|
size_t node_def_count() const override { return graph_def_.node().size(); }
| 0
|
194,455
|
void AudioRendererHost::OnCreateStream(
int stream_id, const media::AudioParameters& params, int input_channels) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// media::AudioParameters is validated in the deserializer.
if (input_channels < 0 ||
input_channels > media::limits::kMaxChannels ||
LookupById(stream_id) != NULL) {
SendErrorMessage(stream_id);
return;
}
media::AudioParameters audio_params(params);
int output_memory_size = AudioBus::CalculateMemorySize(audio_params);
int frames = audio_params.frames_per_buffer();
int input_memory_size =
AudioBus::CalculateMemorySize(input_channels, frames);
scoped_ptr<AudioEntry> entry(new AudioEntry());
uint32 io_buffer_size = output_memory_size + input_memory_size;
uint32 shared_memory_size =
media::TotalSharedMemorySizeInBytes(io_buffer_size);
if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) {
SendErrorMessage(stream_id);
return;
}
scoped_ptr<AudioSyncReader> reader(
new AudioSyncReader(&entry->shared_memory, params, input_channels));
if (!reader->Init()) {
SendErrorMessage(stream_id);
return;
}
entry->reader.reset(reader.release());
entry->controller = media::AudioOutputController::Create(
audio_manager_, this, audio_params, entry->reader.get());
if (!entry->controller) {
SendErrorMessage(stream_id);
return;
}
entry->stream_id = stream_id;
audio_entries_.insert(std::make_pair(stream_id, entry.release()));
if (media_observer_)
media_observer_->OnSetAudioStreamStatus(this, stream_id, "created");
}
| 0
|
284,325
|
int ssl3_get_server_hello(SSL *s)
{
STACK_OF(SSL_CIPHER) *sk;
const SSL_CIPHER *c;
CERT *ct = s->cert;
unsigned char *p,*d;
int i,al=SSL_AD_INTERNAL_ERROR,ok;
unsigned int j;
long n;
#ifndef OPENSSL_NO_COMP
SSL_COMP *comp;
#endif
/* Hello verify request and/or server hello version may not
* match so set first packet if we're negotiating version.
*/
if (SSL_IS_DTLS(s))
s->first_packet = 1;
n=s->method->ssl_get_message(s,
SSL3_ST_CR_SRVR_HELLO_A,
SSL3_ST_CR_SRVR_HELLO_B,
-1,
20000, /* ?? */
&ok);
if (!ok) return((int)n);
if (SSL_IS_DTLS(s))
{
s->first_packet = 0;
if ( s->s3->tmp.message_type == DTLS1_MT_HELLO_VERIFY_REQUEST)
{
if ( s->d1->send_cookie == 0)
{
s->s3->tmp.reuse_message = 1;
return 1;
}
else /* already sent a cookie */
{
al=SSL_AD_UNEXPECTED_MESSAGE;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_MESSAGE_TYPE);
goto f_err;
}
}
}
if ( s->s3->tmp.message_type != SSL3_MT_SERVER_HELLO)
{
al=SSL_AD_UNEXPECTED_MESSAGE;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_MESSAGE_TYPE);
goto f_err;
}
d=p=(unsigned char *)s->init_msg;
if (s->method->version == DTLS_ANY_VERSION)
{
/* Work out correct protocol version to use */
int hversion = (p[0] << 8)|p[1];
int options = s->options;
if (hversion == DTLS1_2_VERSION
&& !(options & SSL_OP_NO_DTLSv1_2))
s->method = DTLSv1_2_client_method();
else if (tls1_suiteb(s))
{
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
s->version = hversion;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
else if (hversion == DTLS1_VERSION
&& !(options & SSL_OP_NO_DTLSv1))
s->method = DTLSv1_client_method();
else
{
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION);
s->version = hversion;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
s->version = s->method->version;
}
if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff)))
{
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION);
s->version=(s->version&0xff00)|p[1];
al=SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
p+=2;
/* load the server hello data */
/* load the server random */
memcpy(s->s3->server_random,p,SSL3_RANDOM_SIZE);
p+=SSL3_RANDOM_SIZE;
s->hit = 0;
/* get the session-id */
j= *(p++);
if ((j > sizeof s->session->session_id) || (j > SSL3_SESSION_ID_SIZE))
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_LONG);
goto f_err;
}
#ifndef OPENSSL_NO_TLSEXT
/* check if we want to resume the session based on external pre-shared secret */
if (s->version >= TLS1_VERSION && s->tls_session_secret_cb)
{
SSL_CIPHER *pref_cipher=NULL;
s->session->master_key_length=sizeof(s->session->master_key);
if (s->tls_session_secret_cb(s, s->session->master_key,
&s->session->master_key_length,
NULL, &pref_cipher,
s->tls_session_secret_cb_arg))
{
s->session->cipher = pref_cipher ?
pref_cipher : ssl_get_cipher_by_char(s, p+j);
s->hit = 1;
}
}
#endif /* OPENSSL_NO_TLSEXT */
if (!s->hit && j != 0 && j == s->session->session_id_length
&& memcmp(p,s->session->session_id,j) == 0)
{
if(s->sid_ctx_length != s->session->sid_ctx_length
|| memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length))
{
/* actually a client application bug */
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
goto f_err;
}
s->hit=1;
}
/* a miss or crap from the other end */
if (!s->hit)
{
/* If we were trying for session-id reuse, make a new
* SSL_SESSION so we don't stuff up other people */
if (s->session->session_id_length > 0)
{
if (!ssl_get_new_session(s,0))
{
goto f_err;
}
}
s->session->session_id_length=j;
memcpy(s->session->session_id,p,j); /* j could be 0 */
}
p+=j;
c=ssl_get_cipher_by_char(s,p);
if (c == NULL)
{
/* unknown cipher */
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNKNOWN_CIPHER_RETURNED);
goto f_err;
}
/* Set version disabled mask now we know version */
if (!SSL_USE_TLS1_2_CIPHERS(s))
ct->mask_ssl = SSL_TLSV1_2;
else
ct->mask_ssl = 0;
/* If it is a disabled cipher we didn't send it in client hello,
* so return an error.
*/
if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK))
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED);
goto f_err;
}
p+=ssl_put_cipher_by_char(s,NULL,NULL);
sk=ssl_get_ciphers_by_id(s);
i=sk_SSL_CIPHER_find(sk,c);
if (i < 0)
{
/* we did not say we would use this cipher */
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED);
goto f_err;
}
/* Depending on the session caching (internal/external), the cipher
and/or cipher_id values may not be set. Make sure that
cipher_id is set and use it for comparison. */
if (s->session->cipher)
s->session->cipher_id = s->session->cipher->id;
if (s->hit && (s->session->cipher_id != c->id))
{
/* Workaround is now obsolete */
#if 0
if (!(s->options &
SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG))
#endif
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED);
goto f_err;
}
}
s->s3->tmp.new_cipher=c;
/* Don't digest cached records if no sigalgs: we may need them for
* client authentication.
*/
if (!SSL_USE_SIGALGS(s) && !ssl3_digest_cached_records(s))
goto f_err;
/* lets get the compression algorithm */
/* COMPRESSION */
#ifdef OPENSSL_NO_COMP
if (*(p++) != 0)
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);
goto f_err;
}
/* If compression is disabled we'd better not try to resume a session
* using compression.
*/
if (s->session->compress_meth != 0)
{
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_INCONSISTENT_COMPRESSION);
goto f_err;
}
#else
j= *(p++);
if (s->hit && j != s->session->compress_meth)
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED);
goto f_err;
}
if (j == 0)
comp=NULL;
else if (!ssl_allow_compression(s))
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_COMPRESSION_DISABLED);
goto f_err;
}
else
comp=ssl3_comp_find(s->ctx->comp_methods,j);
if ((j != 0) && (comp == NULL))
{
al=SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);
goto f_err;
}
else
{
s->s3->tmp.new_compression=comp;
}
#endif
#ifndef OPENSSL_NO_TLSEXT
/* TLS extensions*/
if (!ssl_parse_serverhello_tlsext(s,&p,d,n))
{
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_PARSE_TLSEXT);
goto err;
}
#endif
if (p != (d+n))
{
/* wrong packet length */
al=SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_PACKET_LENGTH);
goto f_err;
}
return(1);
f_err:
ssl3_send_alert(s,SSL3_AL_FATAL,al);
err:
return(-1);
}
| 0
|
219,980
|
void TabStripModel::RemoveObserver(TabStripModelObserver* observer) {
observers_.RemoveObserver(observer);
}
| 0
|
313,181
|
static void WriteBodyHTMLTable( SQLHSTMT hStmt )
{
SQLINTEGER nCol = 0;
SQLSMALLINT nColumns = 0;
SQLLEN nIndicator = 0;
SQLTCHAR szColumnValue[MAX_DATA_WIDTH+1];
SQLRETURN nReturn = 0;
SQLRETURN ret;
szColumnValue[ 0 ] = 0;
if ( SQLNumResultCols( hStmt, &nColumns ) != SQL_SUCCESS )
nColumns = -1;
while ( (ret = SQLFetch( hStmt )) == SQL_SUCCESS ) /* ROWS */
{
printf( "<tr>\n" );
for ( nCol = 1; nCol <= nColumns; nCol++ ) /* COLS */
{
printf( "<td>\n" );
printf( "<font face=Arial,Helvetica>\n" );
nReturn = SQLGetData( hStmt, nCol, SQL_C_WCHAR, (SQLPOINTER)szColumnValue, sizeof(szColumnValue), &nIndicator );
if ( nReturn == SQL_SUCCESS && nIndicator != SQL_NULL_DATA )
{
uc_to_ascii( szColumnValue );
fputs((char*) szColumnValue, stdout );
}
else if ( nReturn == SQL_ERROR )
{
ret = SQL_ERROR;
break;
}
else
printf( "%s\n", "" );
printf( "</font>\n" );
printf( "</td>\n" );
}
if (ret != SQL_SUCCESS)
break;
printf( "</tr>\n" );
}
}
| 0
|
178,556
|
static int adev_open(const hw_module_t* module, const char* name,
hw_device_t** device)
{
struct a2dp_audio_device *adev;
int ret;
INFO(" adev_open in A2dp_hw module");
FNLOG();
if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)
{
ERROR("interface %s not matching [%s]", name, AUDIO_HARDWARE_INTERFACE);
return -EINVAL;
}
adev = calloc(1, sizeof(struct a2dp_audio_device));
if (!adev)
return -ENOMEM;
adev->device.common.tag = HARDWARE_DEVICE_TAG;
adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
adev->device.common.module = (struct hw_module_t *) module;
adev->device.common.close = adev_close;
adev->device.init_check = adev_init_check;
adev->device.set_voice_volume = adev_set_voice_volume;
adev->device.set_master_volume = adev_set_master_volume;
adev->device.set_mode = adev_set_mode;
adev->device.set_mic_mute = adev_set_mic_mute;
adev->device.get_mic_mute = adev_get_mic_mute;
adev->device.set_parameters = adev_set_parameters;
adev->device.get_parameters = adev_get_parameters;
adev->device.get_input_buffer_size = adev_get_input_buffer_size;
adev->device.open_output_stream = adev_open_output_stream;
adev->device.close_output_stream = adev_close_output_stream;
adev->device.open_input_stream = adev_open_input_stream;
adev->device.close_input_stream = adev_close_input_stream;
adev->device.dump = adev_dump;
adev->output = NULL;
*device = &adev->device.common;
return 0;
}
| 0
|
37,628
|
void fsck_set_msg_types(struct fsck_options *options, const char *values)
{
char *buf = xstrdup(values), *to_free = buf;
int done = 0;
while (!done) {
int len = strcspn(buf, " ,|"), equal;
done = !buf[len];
if (!len) {
buf++;
continue;
}
buf[len] = '\0';
for (equal = 0;
equal < len && buf[equal] != '=' && buf[equal] != ':';
equal++)
buf[equal] = tolower(buf[equal]);
buf[equal] = '\0';
if (!strcmp(buf, "skiplist")) {
if (equal == len)
die("skiplist requires a path");
init_skiplist(options, buf + equal + 1);
buf += len + 1;
continue;
}
if (equal == len)
die("Missing '=': '%s'", buf);
fsck_set_msg_type(options, buf, buf + equal + 1);
buf += len + 1;
}
free(to_free);
}
| 0
|
499,200
|
static void hevc_await_progress(HEVCContext *s, HEVCFrame *ref,
const Mv *mv, int y0, int height)
{
int y = (mv->y >> 2) + y0 + height + 9;
ff_thread_await_progress(&ref->tf, y, 0);
}
| 0
|
380,940
|
static CURLcode parse_url_login(struct SessionHandle *data,
struct connectdata *conn,
char **user, char **passwd, char **options)
{
CURLcode result = CURLE_OK;
char *userp = NULL;
char *passwdp = NULL;
char *optionsp = NULL;
/* At this point, we're hoping all the other special cases have
* been taken care of, so conn->host.name is at most
* [user[:password][;options]]@]hostname
*
* We need somewhere to put the embedded details, so do that first.
*/
char *ptr = strchr(conn->host.name, '@');
char *login = conn->host.name;
DEBUGASSERT(!**user);
DEBUGASSERT(!**passwd);
DEBUGASSERT(!**options);
if(!ptr)
goto out;
/* We will now try to extract the
* possible login information in a string like:
* ftp://user:password@ftp.my.site:8021/README */
conn->host.name = ++ptr;
/* So the hostname is sane. Only bother interpreting the
* results if we could care. It could still be wasted
* work because it might be overtaken by the programmatically
* set user/passwd, but doing that first adds more cases here :-(
*/
if(data->set.use_netrc == CURL_NETRC_REQUIRED)
goto out;
/* We could use the login information in the URL so extract it */
result = parse_login_details(login, ptr - login - 1,
&userp, &passwdp, &optionsp);
if(result)
goto out;
if(userp) {
char *newname;
/* We have a user in the URL */
conn->bits.userpwd_in_url = TRUE;
conn->bits.user_passwd = TRUE; /* enable user+password */
/* Decode the user */
newname = curl_easy_unescape(data, userp, 0, NULL);
if(!newname) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
free(*user);
*user = newname;
}
if(passwdp) {
/* We have a password in the URL so decode it */
char *newpasswd = curl_easy_unescape(data, passwdp, 0, NULL);
if(!newpasswd) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
free(*passwd);
*passwd = newpasswd;
}
if(optionsp) {
/* We have an options list in the URL so decode it */
char *newoptions = curl_easy_unescape(data, optionsp, 0, NULL);
if(!newoptions) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
free(*options);
*options = newoptions;
}
out:
Curl_safefree(userp);
Curl_safefree(passwdp);
Curl_safefree(optionsp);
return result;
}
| 0
|
106,551
|
file_printedlen(const struct magic_set *ms)
{
return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
}
| 0
|
69,749
|
static void *sysvipc_proc_next(struct seq_file *s, void *it, loff_t *pos)
{
struct ipc_proc_iter *iter = s->private;
struct ipc_proc_iface *iface = iter->iface;
struct kern_ipc_perm *ipc = it;
/* If we had an ipc id locked before, unlock it */
if (ipc && ipc != SEQ_START_TOKEN)
ipc_unlock(ipc);
return sysvipc_find_ipc(&iter->ns->ids[iface->ids], *pos, pos);
}
| 0
|
33,238
|
md_analyze_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode)
{
int ret;
/* Reset the previously collected stack of marks. */
ctx->n_marks = 0;
/* Collect all marks. */
MD_CHECK(md_collect_marks(ctx, lines, n_lines, table_mode));
/* We analyze marks in few groups to handle their precedence. */
/* (1) Entities; code spans; autolinks; raw HTML. */
md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T("&"));
/* (2) Links. */
md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T("[]!"));
MD_CHECK(md_resolve_links(ctx, lines, n_lines));
BRACKET_OPENERS.head = -1;
BRACKET_OPENERS.tail = -1;
ctx->unresolved_link_head = -1;
ctx->unresolved_link_tail = -1;
if(table_mode) {
/* (3) Analyze table cell boundaries.
* Note we reset TABLECELLBOUNDARIES chain prior to the call md_analyze_marks(),
* not after, because caller may need it. */
MD_ASSERT(n_lines == 1);
TABLECELLBOUNDARIES.head = -1;
TABLECELLBOUNDARIES.tail = -1;
ctx->n_table_cell_boundaries = 0;
md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T("|"));
return ret;
}
/* (4) Emphasis and strong emphasis; permissive autolinks. */
md_analyze_link_contents(ctx, lines, n_lines, 0, ctx->n_marks);
abort:
return ret;
}
| 0
|
89,238
|
static void find_good_pkt_pointers(struct bpf_verifier_state *vstate,
struct bpf_reg_state *dst_reg,
enum bpf_reg_type type,
bool range_right_open)
{
u16 new_range;
int i;
if (dst_reg->off < 0 ||
(dst_reg->off == 0 && range_right_open))
/* This doesn't give us any range */
return;
if (dst_reg->umax_value > MAX_PACKET_OFF ||
dst_reg->umax_value + dst_reg->off > MAX_PACKET_OFF)
/* Risk of overflow. For instance, ptr + (1<<63) may be less
* than pkt_end, but that's because it's also less than pkt.
*/
return;
new_range = dst_reg->off;
if (range_right_open)
new_range--;
/* Examples for register markings:
*
* pkt_data in dst register:
*
* r2 = r3;
* r2 += 8;
* if (r2 > pkt_end) goto <handle exception>
* <access okay>
*
* r2 = r3;
* r2 += 8;
* if (r2 < pkt_end) goto <access okay>
* <handle exception>
*
* Where:
* r2 == dst_reg, pkt_end == src_reg
* r2=pkt(id=n,off=8,r=0)
* r3=pkt(id=n,off=0,r=0)
*
* pkt_data in src register:
*
* r2 = r3;
* r2 += 8;
* if (pkt_end >= r2) goto <access okay>
* <handle exception>
*
* r2 = r3;
* r2 += 8;
* if (pkt_end <= r2) goto <handle exception>
* <access okay>
*
* Where:
* pkt_end == dst_reg, r2 == src_reg
* r2=pkt(id=n,off=8,r=0)
* r3=pkt(id=n,off=0,r=0)
*
* Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8)
* or r3=pkt(id=n,off=0,r=8-1), so that range of bytes [r3, r3 + 8)
* and [r3, r3 + 8-1) respectively is safe to access depending on
* the check.
*/
/* If our ids match, then we must have the same max_value. And we
* don't care about the other reg's fixed offset, since if it's too big
* the range won't allow anything.
* dst_reg->off is known < MAX_PACKET_OFF, therefore it fits in a u16.
*/
for (i = 0; i <= vstate->curframe; i++)
__find_good_pkt_pointers(vstate->frame[i], dst_reg, type,
new_range);
}
| 0
|
11,045
|
std::string SanitizeFrontendPath(const std::string& path) {
for (size_t i = 0; i < path.length(); i++) {
if (path[i] != '/' && path[i] != '-' && path[i] != '_'
&& path[i] != '.' && path[i] != '@'
&& !(path[i] >= '0' && path[i] <= '9')
&& !(path[i] >= 'a' && path[i] <= 'z')
&& !(path[i] >= 'A' && path[i] <= 'Z')) {
return std::string();
}
}
return path;
}
| 1
|
31,390
|
HeaderTableRecord::HeaderTableRecord(const char *n) :
name(n), id(HdrType::BAD_HDR), type(HdrFieldType::ftInvalid),
list(false), request(false), reply(false), hopbyhop(false), denied304(false)
{}
| 0
|
40,965
|
QPDFWriter::writeStringNoQDF(std::string const& str)
{
if (! this->qdf_mode)
{
writeString(str);
}
}
| 0
|
299,729
|
static void dtls1_set_handshake_header(SSL *s, int htype, unsigned long len)
{
unsigned char *p = (unsigned char *)s->init_buf->data;
dtls1_set_message_header(s, p, htype, len, 0, len);
s->init_num = (int)len + DTLS1_HM_HEADER_LENGTH;
s->init_off = 0;
/* Buffer the message to handle re-xmits */
dtls1_buffer_message(s, 0);
}
| 0
|
411,699
|
CImg<T>& _load_pandore(std::FILE *const file, const char *const filename) {
#define __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,ndim,stype) \
cimg::fread(dims,nbdim,nfile); \
if (endian) cimg::invert_endianness(dims,nbdim); \
assign(nwidth,nheight,ndepth,ndim); \
const size_t siz = size(); \
stype *buffer = new stype[siz]; \
cimg::fread(buffer,siz,nfile); \
if (endian) cimg::invert_endianness(buffer,siz); \
T *ptrd = _data; \
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \
buffer-=siz; \
delete[] buffer
#define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \
if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \
else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \
else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \
else throw CImgIOException(_cimg_instance \
"load_pandore(): Unknown pixel datatype in file '%s'.", \
cimg_instance, \
filename?filename:"(FILE*)"); }
if (!file && !filename)
throw CImgArgumentException(_cimg_instance
"load_pandore(): Specified filename is (null).",
cimg_instance);
std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
CImg<charT> header(32);
cimg::fread(header._data,12,nfile);
if (cimg::strncasecmp("PANDORE",header,7)) {
if (!file) cimg::fclose(nfile);
throw CImgIOException(_cimg_instance
"load_pandore(): PANDORE header not found in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
}
unsigned int imageid, dims[8] = { 0 };
int ptbuf[4] = { 0 };
cimg::fread(&imageid,1,nfile);
const bool endian = imageid>255;
if (endian) cimg::invert_endianness(imageid);
cimg::fread(header._data,20,nfile);
switch (imageid) {
case 2 : _cimg_load_pandore_case(2,dims[1],1,1,1,unsigned char,unsigned char,unsigned char,1); break;
case 3 : _cimg_load_pandore_case(2,dims[1],1,1,1,long,int,short,4); break;
case 4 : _cimg_load_pandore_case(2,dims[1],1,1,1,double,float,float,4); break;
case 5 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,unsigned char,unsigned char,unsigned char,1); break;
case 6 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,long,int,short,4); break;
case 7 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,double,float,float,4); break;
case 8 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,unsigned char,unsigned char,unsigned char,1); break;
case 9 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,long,int,short,4); break;
case 10 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,double,float,float,4); break;
case 11 : { // Region 1d
cimg::fread(dims,3,nfile);
if (endian) cimg::invert_endianness(dims,3);
assign(dims[1],1,1,1);
const unsigned siz = size();
if (dims[2]<256) {
unsigned char *buffer = new unsigned char[siz];
cimg::fread(buffer,siz,nfile);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
} else {
if (dims[2]<65536) {
unsigned short *buffer = new unsigned short[siz];
cimg::fread(buffer,siz,nfile);
if (endian) cimg::invert_endianness(buffer,siz);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
} else {
unsigned int *buffer = new unsigned int[siz];
cimg::fread(buffer,siz,nfile);
if (endian) cimg::invert_endianness(buffer,siz);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
}
}
}
break;
case 12 : { // Region 2d
cimg::fread(dims,4,nfile);
if (endian) cimg::invert_endianness(dims,4);
assign(dims[2],dims[1],1,1);
const size_t siz = size();
if (dims[3]<256) {
unsigned char *buffer = new unsigned char[siz];
cimg::fread(buffer,siz,nfile);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
} else {
if (dims[3]<65536) {
unsigned short *buffer = new unsigned short[siz];
cimg::fread(buffer,siz,nfile);
if (endian) cimg::invert_endianness(buffer,siz);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
} else {
unsigned int *buffer = new unsigned int[siz];
cimg::fread(buffer,siz,nfile);
if (endian) cimg::invert_endianness(buffer,siz);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
}
}
}
break;
case 13 : { // Region 3d
cimg::fread(dims,5,nfile);
if (endian) cimg::invert_endianness(dims,5);
assign(dims[3],dims[2],dims[1],1);
const size_t siz = size();
if (dims[4]<256) {
unsigned char *buffer = new unsigned char[siz];
cimg::fread(buffer,siz,nfile);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
} else {
if (dims[4]<65536) {
unsigned short *buffer = new unsigned short[siz];
cimg::fread(buffer,siz,nfile);
if (endian) cimg::invert_endianness(buffer,siz);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
} else {
unsigned int *buffer = new unsigned int[siz];
cimg::fread(buffer,siz,nfile);
if (endian) cimg::invert_endianness(buffer,siz);
T *ptrd = _data;
cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
buffer-=siz;
delete[] buffer;
}
}
}
break;
case 16 : _cimg_load_pandore_case(4,dims[2],dims[1],1,3,unsigned char,unsigned char,unsigned char,1); break;
case 17 : _cimg_load_pandore_case(4,dims[2],dims[1],1,3,long,int,short,4); break;
case 18 : _cimg_load_pandore_case(4,dims[2],dims[1],1,3,double,float,float,4); break;
case 19 : _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,unsigned char,unsigned char,unsigned char,1); break;
case 20 : _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,long,int,short,4); break;
case 21 : _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,double,float,float,4); break;
case 22 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],unsigned char,unsigned char,unsigned char,1); break;
case 23 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],long,int,short,4); break;
case 24 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],unsigned long,unsigned int,unsigned short,4); break;
case 25 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],double,float,float,4); break;
case 26 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],unsigned char,unsigned char,unsigned char,1); break;
case 27 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],long,int,short,4); break;
case 28 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],unsigned long,unsigned int,unsigned short,4); break;
case 29 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],double,float,float,4); break;
case 30 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],unsigned char,unsigned char,unsigned char,1);
break;
case 31 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],long,int,short,4); break;
case 32 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],unsigned long,unsigned int,unsigned short,4);
break;
case 33 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],double,float,float,4); break;
case 34 : { // Points 1d
cimg::fread(ptbuf,1,nfile);
if (endian) cimg::invert_endianness(ptbuf,1);
assign(1); (*this)(0) = (T)ptbuf[0];
} break;
case 35 : { // Points 2d
cimg::fread(ptbuf,2,nfile);
if (endian) cimg::invert_endianness(ptbuf,2);
assign(2); (*this)(0) = (T)ptbuf[1]; (*this)(1) = (T)ptbuf[0];
} break;
case 36 : { // Points 3d
cimg::fread(ptbuf,3,nfile);
if (endian) cimg::invert_endianness(ptbuf,3);
assign(3); (*this)(0) = (T)ptbuf[2]; (*this)(1) = (T)ptbuf[1]; (*this)(2) = (T)ptbuf[0];
} break;
default :
if (!file) cimg::fclose(nfile);
throw CImgIOException(_cimg_instance
"load_pandore(): Unable to load data with ID_type %u in file '%s'.",
cimg_instance,
imageid,filename?filename:"(FILE*)");
}
if (!file) cimg::fclose(nfile);
return *this;
| 0
|
43,023
|
static void io_free_file_tables(struct io_file_table *table)
{
kvfree(table->files);
table->files = NULL;
| 0
|
121,140
|
int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn)
{
return _snd_ctl_unregister_ioctl(fcn, &snd_control_ioctls);
}
| 0
|
317,079
|
RenderFrameHost* WebContentsImpl::GetFocusedFrameIncludingInnerWebContents() {
WebContentsImpl* contents = this;
FrameTreeNode* focused_node = contents->frame_tree_.GetFocusedFrame();
if (!focused_node)
return nullptr;
while (true) {
contents = contents->node_.GetInnerWebContentsInFrame(focused_node);
if (!contents)
return focused_node->current_frame_host();
focused_node = contents->frame_tree_.GetFocusedFrame();
if (!focused_node)
return contents->GetMainFrame();
}
}
| 0
|
23,235
|
char * add_var ( struct ctl_var * * kv , u_long size , u_short def ) {
u_short c ;
struct ctl_var * k ;
char * buf ;
c = count_var ( * kv ) ;
* kv = erealloc ( * kv , ( c + 2 ) * sizeof ( * * kv ) ) ;
k = * kv ;
buf = emalloc ( size ) ;
k [ c ] . code = c ;
k [ c ] . text = buf ;
k [ c ] . flags = def ;
k [ c + 1 ] . code = 0 ;
k [ c + 1 ] . text = NULL ;
k [ c + 1 ] . flags = EOV ;
return buf ;
}
| 0
|
274,687
|
void add_map_inc_bl(epoch_t e, bufferlist& bl) {
return service.add_map_inc_bl(e, bl);
}
| 0
|
280,624
|
void PrintPreviewDataService::RemoveEntry(
void PrintPreviewDataService::RemoveEntry(int32 preview_ui_id) {
data_store_map_.erase(preview_ui_id);
}
| 0
|
268,923
|
static u16 llcp_tlv_wks(u8 *tlv)
{
return llcp_tlv16(tlv, LLCP_TLV_WKS);
}
| 0
|
439,913
|
ipmi_lan_set_vlan_id(struct ipmi_intf *intf, uint8_t chan, char *string)
{
struct lan_param *p;
uint8_t data[2];
int rc = -1;
if (!string) { /* request to disable VLAN */
lprintf(LOG_DEBUG, "Get current VLAN ID from BMC.");
p = get_lan_param(intf, chan, IPMI_LANP_VLAN_ID);
if (p && p->data && p->data_len > 1) {
int id = ((p->data[1] & 0x0f) << 8) + p->data[0];
if (IPMI_LANP_VLAN_DISABLE == id) {
printf("VLAN is already disabled for channel %"
PRIu8 "\n", chan);
rc = 0;
goto out;
}
if (!IPMI_LANP_IS_VLAN_VALID(id)) {
lprintf(LOG_ERR,
"Retrieved VLAN ID %i is out of "
"range <%d..%d>.",
id,
IPMI_LANP_VLAN_ID_MIN,
IPMI_LANP_VLAN_ID_MAX);
goto out;
}
data[0] = p->data[0];
data[1] = p->data[1] & 0x0F;
} else {
data[0] = 0;
data[1] = 0;
}
}
else {
int id = 0;
if (str2int(string, &id) != 0) {
lprintf(LOG_ERR,
"Given VLAN ID '%s' is invalid.",
string);
goto out;
}
if (!IPMI_LANP_IS_VLAN_VALID(id)) {
lprintf(LOG_NOTICE,
"VLAN ID must be between %d and %d.",
IPMI_LANP_VLAN_ID_MIN,
IPMI_LANP_VLAN_ID_MAX);
goto out;
}
else {
data[0] = (uint8_t)id;
data[1] = (uint8_t)(id >> 8) | 0x80;
}
}
rc = set_lan_param(intf, chan, IPMI_LANP_VLAN_ID, data, 2);
out:
return rc;
}
| 0
|
513,757
|
napi_status napi_get_named_property(napi_env env,
napi_value object,
const char* utf8name,
napi_value* result) {
NAPI_PREAMBLE(env);
CHECK_ARG(env, result);
v8::Local<v8::Context> context = env->context();
v8::Local<v8::Name> key;
CHECK_NEW_FROM_UTF8(env, key, utf8name);
v8::Local<v8::Object> obj;
CHECK_TO_OBJECT(env, context, obj, object);
auto get_maybe = obj->Get(context, key);
CHECK_MAYBE_EMPTY(env, get_maybe, napi_generic_failure);
v8::Local<v8::Value> val = get_maybe.ToLocalChecked();
*result = v8impl::JsValueFromV8LocalValue(val);
return GET_RETURN_STATUS(env);
}
| 0
|
114,742
|
static int sctp_listen_start(struct sock *sk, int backlog)
{
struct sctp_sock *sp = sctp_sk(sk);
struct sctp_endpoint *ep = sp->ep;
struct crypto_hash *tfm = NULL;
char alg[32];
/* Allocate HMAC for generating cookie. */
if (!sp->hmac && sp->sctp_hmac_alg) {
sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
tfm = crypto_alloc_hash(alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
net_info_ratelimited("failed to load transform for %s: %ld\n",
sp->sctp_hmac_alg, PTR_ERR(tfm));
return -ENOSYS;
}
sctp_sk(sk)->hmac = tfm;
}
/*
* If a bind() or sctp_bindx() is not called prior to a listen()
* call that allows new associations to be accepted, the system
* picks an ephemeral port and will choose an address set equivalent
* to binding with a wildcard address.
*
* This is not currently spelled out in the SCTP sockets
* extensions draft, but follows the practice as seen in TCP
* sockets.
*
*/
sk->sk_state = SCTP_SS_LISTENING;
if (!ep->base.bind_addr.port) {
if (sctp_autobind(sk))
return -EAGAIN;
} else {
if (sctp_get_port(sk, inet_sk(sk)->inet_num)) {
sk->sk_state = SCTP_SS_CLOSED;
return -EADDRINUSE;
}
}
sk->sk_max_ack_backlog = backlog;
sctp_hash_endpoint(ep);
return 0;
}
| 0
|
386,363
|
PHP_FUNCTION(xsl_xsltprocessor_get_parameter)
{
zval *id;
int name_len = 0, namespace_len = 0;
char *name, *namespace;
zval **value;
xsl_object *intern;
DOM_GET_THIS(id);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &namespace, &namespace_len, &name, &name_len) == FAILURE) {
RETURN_FALSE;
}
intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
if ( zend_hash_find(intern->parameter, name, name_len + 1, (void**) &value) == SUCCESS) {
convert_to_string_ex(value);
RETVAL_STRING(Z_STRVAL_PP(value),1);
} else {
RETURN_FALSE;
}
}
| 0
|
405,470
|
void zone_pcp_reset(struct zone *zone)
{
unsigned long flags;
int cpu;
struct per_cpu_pageset *pset;
/* avoid races with drain_pages() */
local_irq_save(flags);
if (zone->pageset != &boot_pageset) {
for_each_online_cpu(cpu) {
pset = per_cpu_ptr(zone->pageset, cpu);
drain_zonestat(zone, pset);
}
free_percpu(zone->pageset);
zone->pageset = &boot_pageset;
}
local_irq_restore(flags);
}
| 0
|
453,652
|
postalAddressValidate(
Syntax *syntax,
struct berval *in )
{
struct berval bv = *in;
ber_len_t c;
for ( c = 0; c < in->bv_len; c++ ) {
if ( in->bv_val[c] == '\\' ) {
c++;
if ( strncasecmp( &in->bv_val[c], "24", STRLENOF( "24" ) ) != 0
&& strncasecmp( &in->bv_val[c], "5C", STRLENOF( "5C" ) ) != 0 )
{
return LDAP_INVALID_SYNTAX;
}
continue;
}
if ( in->bv_val[c] == '$' ) {
bv.bv_len = &in->bv_val[c] - bv.bv_val;
if ( UTF8StringValidate( NULL, &bv ) != LDAP_SUCCESS ) {
return LDAP_INVALID_SYNTAX;
}
bv.bv_val = &in->bv_val[c] + 1;
}
}
bv.bv_len = &in->bv_val[c] - bv.bv_val;
return UTF8StringValidate( NULL, &bv );
}
| 0
|
150,405
|
Buf EncryptedWriteRecordLayer::getBufToEncrypt(folly::IOBufQueue& queue) const {
if (queue.front()->length() > maxRecord_) {
return queue.splitAtMost(maxRecord_);
} else if (queue.front()->length() >= desiredMinRecord_) {
return queue.pop_front();
} else {
return queue.splitAtMost(desiredMinRecord_);
}
}
| 0
|
1,245
|
static int vc1_decode_p_mb ( VC1Context * v ) {
MpegEncContext * s = & v -> s ;
GetBitContext * gb = & s -> gb ;
int i , j ;
int mb_pos = s -> mb_x + s -> mb_y * s -> mb_stride ;
int cbp ;
int mqdiff , mquant ;
int ttmb = v -> ttfrm ;
int mb_has_coeffs = 1 ;
int dmv_x , dmv_y ;
int index , index1 ;
int val , sign ;
int first_block = 1 ;
int dst_idx , off ;
int skipped , fourmv ;
int block_cbp = 0 , pat , block_tt = 0 , block_intra = 0 ;
mquant = v -> pq ;
if ( v -> mv_type_is_raw ) fourmv = get_bits1 ( gb ) ;
else fourmv = v -> mv_type_mb_plane [ mb_pos ] ;
if ( v -> skip_is_raw ) skipped = get_bits1 ( gb ) ;
else skipped = v -> s . mbskip_table [ mb_pos ] ;
if ( ! fourmv ) {
if ( ! skipped ) {
GET_MVDATA ( dmv_x , dmv_y ) ;
if ( s -> mb_intra ) {
s -> current_picture . f . motion_val [ 1 ] [ s -> block_index [ 0 ] ] [ 0 ] = 0 ;
s -> current_picture . f . motion_val [ 1 ] [ s -> block_index [ 0 ] ] [ 1 ] = 0 ;
}
s -> current_picture . f . mb_type [ mb_pos ] = s -> mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16 ;
vc1_pred_mv ( v , 0 , dmv_x , dmv_y , 1 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;
if ( s -> mb_intra && ! mb_has_coeffs ) {
GET_MQUANT ( ) ;
s -> ac_pred = get_bits1 ( gb ) ;
cbp = 0 ;
}
else if ( mb_has_coeffs ) {
if ( s -> mb_intra ) s -> ac_pred = get_bits1 ( gb ) ;
cbp = get_vlc2 ( & v -> s . gb , v -> cbpcy_vlc -> table , VC1_CBPCY_P_VLC_BITS , 2 ) ;
GET_MQUANT ( ) ;
}
else {
mquant = v -> pq ;
cbp = 0 ;
}
s -> current_picture . f . qscale_table [ mb_pos ] = mquant ;
if ( ! v -> ttmbf && ! s -> mb_intra && mb_has_coeffs ) ttmb = get_vlc2 ( gb , ff_vc1_ttmb_vlc [ v -> tt_index ] . table , VC1_TTMB_VLC_BITS , 2 ) ;
if ( ! s -> mb_intra ) vc1_mc_1mv ( v , 0 ) ;
dst_idx = 0 ;
for ( i = 0 ;
i < 6 ;
i ++ ) {
s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;
dst_idx += i >> 2 ;
val = ( ( cbp >> ( 5 - i ) ) & 1 ) ;
off = ( i & 4 ) ? 0 : ( ( i & 1 ) * 8 + ( i & 2 ) * 4 * s -> linesize ) ;
v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = s -> mb_intra ;
if ( s -> mb_intra ) {
v -> a_avail = v -> c_avail = 0 ;
if ( i == 2 || i == 3 || ! s -> first_slice_line ) v -> a_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - s -> block_wrap [ i ] ] ;
if ( i == 1 || i == 3 || s -> mb_x ) v -> c_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - 1 ] ;
vc1_decode_intra_block ( v , s -> block [ i ] , i , val , mquant , ( i & 4 ) ? v -> codingset2 : v -> codingset ) ;
if ( ( i > 3 ) && ( s -> flags & CODEC_FLAG_GRAY ) ) continue ;
v -> vc1dsp . vc1_inv_trans_8x8 ( s -> block [ i ] ) ;
if ( v -> rangeredfrm ) for ( j = 0 ;
j < 64 ;
j ++ ) s -> block [ i ] [ j ] <<= 1 ;
s -> dsp . put_signed_pixels_clamped ( s -> block [ i ] , s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;
if ( v -> pq >= 9 && v -> overlap ) {
if ( v -> c_avail ) v -> vc1dsp . vc1_h_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;
if ( v -> a_avail ) v -> vc1dsp . vc1_v_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;
}
block_cbp |= 0xF << ( i << 2 ) ;
block_intra |= 1 << i ;
}
else if ( val ) {
pat = vc1_decode_p_block ( v , s -> block [ i ] , i , mquant , ttmb , first_block , s -> dest [ dst_idx ] + off , ( i & 4 ) ? s -> uvlinesize : s -> linesize , ( i & 4 ) && ( s -> flags & CODEC_FLAG_GRAY ) , & block_tt ) ;
block_cbp |= pat << ( i << 2 ) ;
if ( ! v -> ttmbf && ttmb < 8 ) ttmb = - 1 ;
first_block = 0 ;
}
}
}
else {
s -> mb_intra = 0 ;
for ( i = 0 ;
i < 6 ;
i ++ ) {
v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = 0 ;
s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;
}
s -> current_picture . f . mb_type [ mb_pos ] = MB_TYPE_SKIP ;
s -> current_picture . f . qscale_table [ mb_pos ] = 0 ;
vc1_pred_mv ( v , 0 , 0 , 0 , 1 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;
vc1_mc_1mv ( v , 0 ) ;
}
}
else {
if ( ! skipped ) {
int intra_count = 0 , coded_inter = 0 ;
int is_intra [ 6 ] , is_coded [ 6 ] ;
cbp = get_vlc2 ( & v -> s . gb , v -> cbpcy_vlc -> table , VC1_CBPCY_P_VLC_BITS , 2 ) ;
for ( i = 0 ;
i < 6 ;
i ++ ) {
val = ( ( cbp >> ( 5 - i ) ) & 1 ) ;
s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;
s -> mb_intra = 0 ;
if ( i < 4 ) {
dmv_x = dmv_y = 0 ;
s -> mb_intra = 0 ;
mb_has_coeffs = 0 ;
if ( val ) {
GET_MVDATA ( dmv_x , dmv_y ) ;
}
vc1_pred_mv ( v , i , dmv_x , dmv_y , 0 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;
if ( ! s -> mb_intra ) vc1_mc_4mv_luma ( v , i , 0 ) ;
intra_count += s -> mb_intra ;
is_intra [ i ] = s -> mb_intra ;
is_coded [ i ] = mb_has_coeffs ;
}
if ( i & 4 ) {
is_intra [ i ] = ( intra_count >= 3 ) ;
is_coded [ i ] = val ;
}
if ( i == 4 ) vc1_mc_4mv_chroma ( v , 0 ) ;
v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = is_intra [ i ] ;
if ( ! coded_inter ) coded_inter = ! is_intra [ i ] & is_coded [ i ] ;
}
dst_idx = 0 ;
if ( ! intra_count && ! coded_inter ) goto end ;
GET_MQUANT ( ) ;
s -> current_picture . f . qscale_table [ mb_pos ] = mquant ;
{
int intrapred = 0 ;
for ( i = 0 ;
i < 6 ;
i ++ ) if ( is_intra [ i ] ) {
if ( ( ( ! s -> first_slice_line || ( i == 2 || i == 3 ) ) && v -> mb_type [ 0 ] [ s -> block_index [ i ] - s -> block_wrap [ i ] ] ) || ( ( s -> mb_x || ( i == 1 || i == 3 ) ) && v -> mb_type [ 0 ] [ s -> block_index [ i ] - 1 ] ) ) {
intrapred = 1 ;
break ;
}
}
if ( intrapred ) s -> ac_pred = get_bits1 ( gb ) ;
else s -> ac_pred = 0 ;
}
if ( ! v -> ttmbf && coded_inter ) ttmb = get_vlc2 ( gb , ff_vc1_ttmb_vlc [ v -> tt_index ] . table , VC1_TTMB_VLC_BITS , 2 ) ;
for ( i = 0 ;
i < 6 ;
i ++ ) {
dst_idx += i >> 2 ;
off = ( i & 4 ) ? 0 : ( ( i & 1 ) * 8 + ( i & 2 ) * 4 * s -> linesize ) ;
s -> mb_intra = is_intra [ i ] ;
if ( is_intra [ i ] ) {
v -> a_avail = v -> c_avail = 0 ;
if ( i == 2 || i == 3 || ! s -> first_slice_line ) v -> a_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - s -> block_wrap [ i ] ] ;
if ( i == 1 || i == 3 || s -> mb_x ) v -> c_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - 1 ] ;
vc1_decode_intra_block ( v , s -> block [ i ] , i , is_coded [ i ] , mquant , ( i & 4 ) ? v -> codingset2 : v -> codingset ) ;
if ( ( i > 3 ) && ( s -> flags & CODEC_FLAG_GRAY ) ) continue ;
v -> vc1dsp . vc1_inv_trans_8x8 ( s -> block [ i ] ) ;
if ( v -> rangeredfrm ) for ( j = 0 ;
j < 64 ;
j ++ ) s -> block [ i ] [ j ] <<= 1 ;
s -> dsp . put_signed_pixels_clamped ( s -> block [ i ] , s -> dest [ dst_idx ] + off , ( i & 4 ) ? s -> uvlinesize : s -> linesize ) ;
if ( v -> pq >= 9 && v -> overlap ) {
if ( v -> c_avail ) v -> vc1dsp . vc1_h_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;
if ( v -> a_avail ) v -> vc1dsp . vc1_v_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;
}
block_cbp |= 0xF << ( i << 2 ) ;
block_intra |= 1 << i ;
}
else if ( is_coded [ i ] ) {
pat = vc1_decode_p_block ( v , s -> block [ i ] , i , mquant , ttmb , first_block , s -> dest [ dst_idx ] + off , ( i & 4 ) ? s -> uvlinesize : s -> linesize , ( i & 4 ) && ( s -> flags & CODEC_FLAG_GRAY ) , & block_tt ) ;
block_cbp |= pat << ( i << 2 ) ;
if ( ! v -> ttmbf && ttmb < 8 ) ttmb = - 1 ;
first_block = 0 ;
}
}
}
else {
s -> mb_intra = 0 ;
s -> current_picture . f . qscale_table [ mb_pos ] = 0 ;
for ( i = 0 ;
i < 6 ;
i ++ ) {
v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = 0 ;
s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;
}
for ( i = 0 ;
i < 4 ;
i ++ ) {
vc1_pred_mv ( v , i , 0 , 0 , 0 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;
vc1_mc_4mv_luma ( v , i , 0 ) ;
}
vc1_mc_4mv_chroma ( v , 0 ) ;
s -> current_picture . f . qscale_table [ mb_pos ] = 0 ;
}
}
end : v -> cbp [ s -> mb_x ] = block_cbp ;
v -> ttblk [ s -> mb_x ] = block_tt ;
v -> is_intra [ s -> mb_x ] = block_intra ;
return 0 ;
}
| 1
|
311,947
|
ecc_generate (const gcry_sexp_t genparms, gcry_sexp_t *r_skey)
{
gpg_err_code_t rc;
unsigned int nbits;
elliptic_curve_t E;
ECC_secret_key sk;
gcry_mpi_t Gx = NULL;
gcry_mpi_t Gy = NULL;
gcry_mpi_t Qx = NULL;
gcry_mpi_t Qy = NULL;
char *curve_name = NULL;
gcry_sexp_t l1;
mpi_ec_t ctx = NULL;
gcry_sexp_t curve_info = NULL;
gcry_sexp_t curve_flags = NULL;
gcry_mpi_t base = NULL;
gcry_mpi_t public = NULL;
gcry_mpi_t secret = NULL;
int flags = 0;
memset (&E, 0, sizeof E);
memset (&sk, 0, sizeof sk);
rc = _gcry_pk_util_get_nbits (genparms, &nbits);
if (rc)
return rc;
/* Parse the optional "curve" parameter. */
l1 = sexp_find_token (genparms, "curve", 0);
if (l1)
{
curve_name = _gcry_sexp_nth_string (l1, 1);
sexp_release (l1);
if (!curve_name)
return GPG_ERR_INV_OBJ; /* No curve name or value too large. */
}
/* Parse the optional flags list. */
l1 = sexp_find_token (genparms, "flags", 0);
if (l1)
{
rc = _gcry_pk_util_parse_flaglist (l1, &flags, NULL);
sexp_release (l1);
if (rc)
goto leave;
}
/* Parse the deprecated optional transient-key flag. */
l1 = sexp_find_token (genparms, "transient-key", 0);
if (l1)
{
flags |= PUBKEY_FLAG_TRANSIENT_KEY;
sexp_release (l1);
}
/* NBITS is required if no curve name has been given. */
if (!nbits && !curve_name)
return GPG_ERR_NO_OBJ; /* No NBITS parameter. */
rc = _gcry_ecc_fill_in_curve (nbits, curve_name, &E, &nbits);
if (rc)
goto leave;
if (DBG_CIPHER)
{
log_debug ("ecgen curve info: %s/%s\n",
_gcry_ecc_model2str (E.model),
_gcry_ecc_dialect2str (E.dialect));
if (E.name)
log_debug ("ecgen curve used: %s\n", E.name);
log_printmpi ("ecgen curve p", E.p);
log_printmpi ("ecgen curve a", E.a);
log_printmpi ("ecgen curve b", E.b);
log_printmpi ("ecgen curve n", E.n);
log_printmpi ("ecgen curve h", E.h);
log_printpnt ("ecgen curve G", &E.G, NULL);
}
ctx = _gcry_mpi_ec_p_internal_new (E.model, E.dialect, flags, E.p, E.a, E.b);
if (E.model == MPI_EC_MONTGOMERY)
rc = nist_generate_key (&sk, &E, ctx, flags, nbits, &Qx, NULL);
else if ((flags & PUBKEY_FLAG_EDDSA))
rc = _gcry_ecc_eddsa_genkey (&sk, &E, ctx, flags);
else
rc = nist_generate_key (&sk, &E, ctx, flags, nbits, &Qx, &Qy);
if (rc)
goto leave;
/* Copy data to the result. */
Gx = mpi_new (0);
Gy = mpi_new (0);
if (E.model != MPI_EC_MONTGOMERY)
{
if (_gcry_mpi_ec_get_affine (Gx, Gy, &sk.E.G, ctx))
log_fatal ("ecgen: Failed to get affine coordinates for %s\n", "G");
base = _gcry_ecc_ec2os (Gx, Gy, sk.E.p);
}
if ((sk.E.dialect == ECC_DIALECT_ED25519 || E.model == MPI_EC_MONTGOMERY)
&& !(flags & PUBKEY_FLAG_NOCOMP))
{
unsigned char *encpk;
unsigned int encpklen;
if (E.model != MPI_EC_MONTGOMERY)
/* (Gx and Gy are used as scratch variables) */
rc = _gcry_ecc_eddsa_encodepoint (&sk.Q, ctx, Gx, Gy,
!!(flags & PUBKEY_FLAG_COMP),
&encpk, &encpklen);
else
{
encpk = _gcry_mpi_get_buffer_extra (Qx, nbits/8,
-1, &encpklen, NULL);
if (encpk == NULL)
rc = gpg_err_code_from_syserror ();
else
{
encpk[0] = 0x40;
encpklen++;
}
}
if (rc)
goto leave;
public = mpi_new (0);
mpi_set_opaque (public, encpk, encpklen*8);
}
else
{
if (!Qx)
{
/* This is the case for a key from _gcry_ecc_eddsa_generate
with no compression. */
Qx = mpi_new (0);
Qy = mpi_new (0);
if (_gcry_mpi_ec_get_affine (Qx, Qy, &sk.Q, ctx))
log_fatal ("ecgen: Failed to get affine coordinates for %s\n", "Q");
}
public = _gcry_ecc_ec2os (Qx, Qy, sk.E.p);
}
secret = sk.d; sk.d = NULL;
if (E.name)
{
rc = sexp_build (&curve_info, NULL, "(curve %s)", E.name);
if (rc)
goto leave;
}
if ((flags & PUBKEY_FLAG_PARAM) || (flags & PUBKEY_FLAG_EDDSA)
|| (flags & PUBKEY_FLAG_DJB_TWEAK))
{
rc = sexp_build
(&curve_flags, NULL,
((flags & PUBKEY_FLAG_PARAM) && (flags & PUBKEY_FLAG_EDDSA))?
"(flags param eddsa)" :
((flags & PUBKEY_FLAG_PARAM) && (flags & PUBKEY_FLAG_EDDSA))?
"(flags param djb-tweak)" :
((flags & PUBKEY_FLAG_PARAM))?
"(flags param)" : ((flags & PUBKEY_FLAG_EDDSA))?
"(flags eddsa)" : "(flags djb-tweak)" );
if (rc)
goto leave;
}
if ((flags & PUBKEY_FLAG_PARAM) && E.name)
rc = sexp_build (r_skey, NULL,
"(key-data"
" (public-key"
" (ecc%S%S(p%m)(a%m)(b%m)(g%m)(n%m)(h%m)(q%m)))"
" (private-key"
" (ecc%S%S(p%m)(a%m)(b%m)(g%m)(n%m)(h%m)(q%m)(d%m)))"
" )",
curve_info, curve_flags,
sk.E.p, sk.E.a, sk.E.b, base, sk.E.n, sk.E.h, public,
curve_info, curve_flags,
sk.E.p, sk.E.a, sk.E.b, base, sk.E.n, sk.E.h, public,
secret);
else
rc = sexp_build (r_skey, NULL,
"(key-data"
" (public-key"
" (ecc%S%S(q%m)))"
" (private-key"
" (ecc%S%S(q%m)(d%m)))"
" )",
curve_info, curve_flags,
public,
curve_info, curve_flags,
public, secret);
if (rc)
goto leave;
if (DBG_CIPHER)
{
log_printmpi ("ecgen result p", sk.E.p);
log_printmpi ("ecgen result a", sk.E.a);
log_printmpi ("ecgen result b", sk.E.b);
log_printmpi ("ecgen result G", base);
log_printmpi ("ecgen result n", sk.E.n);
log_printmpi ("ecgen result h", sk.E.h);
log_printmpi ("ecgen result Q", public);
log_printmpi ("ecgen result d", secret);
if ((flags & PUBKEY_FLAG_EDDSA))
log_debug ("ecgen result using Ed25519+EdDSA\n");
}
leave:
mpi_free (secret);
mpi_free (public);
mpi_free (base);
{
_gcry_ecc_curve_free (&sk.E);
point_free (&sk.Q);
mpi_free (sk.d);
}
_gcry_ecc_curve_free (&E);
mpi_free (Gx);
mpi_free (Gy);
mpi_free (Qx);
mpi_free (Qy);
_gcry_mpi_ec_free (ctx);
xfree (curve_name);
sexp_release (curve_flags);
sexp_release (curve_info);
return rc;
}
| 0
|
287,658
|
static int find_high_bit(unsigned int x)
{
int i;
for(i=31;i>=0;i--) {
if(x&(1<<i)) return i;
}
return 0;
}
| 1
|
195,390
|
bool RenderViewImpl::Send(IPC::Message* message) {
return RenderWidget::Send(message);
}
| 0
|
467,665
|
Client::noteMoreBodyDataAvailable(BodyPipe::Pointer bp)
{
#if USE_ADAPTATION
if (adaptedBodySource == bp) {
handleMoreAdaptedBodyAvailable();
return;
}
#endif
if (requestBodySource == bp)
handleMoreRequestBodyAvailable();
}
| 0
|
338,650
|
dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
enum dshowDeviceType devtype, enum dshowSourceFilterType sourcetype, IBaseFilter **pfilter)
{
struct dshow_ctx *ctx = avctx->priv_data;
IBaseFilter *device_filter = NULL;
IEnumMoniker *classenum = NULL;
IMoniker *m = NULL;
const char *device_name = ctx->device_name[devtype];
int skip = (devtype == VideoDevice) ? ctx->video_device_number
: ctx->audio_device_number;
int r;
const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
&CLSID_AudioInputDeviceCategory };
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio only";
const char *sourcetypename = (sourcetype == VideoSourceDevice) ? "video" : "audio";
r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[sourcetype],
(IEnumMoniker **) &classenum, 0);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not enumerate %s devices (or none found).\n",
devtypename);
return AVERROR(EIO);
}
while (!device_filter && IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK) {
IPropertyBag *bag = NULL;
char *friendly_name = NULL;
char *unique_name = NULL;
VARIANT var;
IBindCtx *bind_ctx = NULL;
LPOLESTR olestr = NULL;
LPMALLOC co_malloc = NULL;
int i;
r = CoGetMalloc(1, &co_malloc);
if (r = S_OK)
goto fail1;
r = CreateBindCtx(0, &bind_ctx);
if (r != S_OK)
goto fail1;
/* GetDisplayname works for both video and audio, DevicePath doesn't */
r = IMoniker_GetDisplayName(m, bind_ctx, NULL, &olestr);
if (r != S_OK)
goto fail1;
unique_name = dup_wchar_to_utf8(olestr);
/* replace ':' with '_' since we use : to delineate between sources */
for (i = 0; i < strlen(unique_name); i++) {
if (unique_name[i] == ':')
unique_name[i] = '_';
}
r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag);
if (r != S_OK)
goto fail1;
var.vt = VT_BSTR;
r = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL);
if (r != S_OK)
goto fail1;
friendly_name = dup_wchar_to_utf8(var.bstrVal);
if (pfilter) {
if (strcmp(device_name, friendly_name) && strcmp(device_name, unique_name))
goto fail1;
if (!skip--) {
r = IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to BindToObject for %s\n", device_name);
goto fail1;
}
}
} else {
av_log(avctx, AV_LOG_INFO, " \"%s\"\n", friendly_name);
av_log(avctx, AV_LOG_INFO, " Alternative name \"%s\"\n", unique_name);
}
fail1:
if (olestr && co_malloc)
IMalloc_Free(co_malloc, olestr);
if (bind_ctx)
IBindCtx_Release(bind_ctx);
av_free(friendly_name);
av_free(unique_name);
if (bag)
IPropertyBag_Release(bag);
IMoniker_Release(m);
}
IEnumMoniker_Release(classenum);
if (pfilter) {
if (!device_filter) {
av_log(avctx, AV_LOG_ERROR, "Could not find %s device with name [%s] among source devices of type %s.\n",
devtypename, device_name, sourcetypename);
return AVERROR(EIO);
}
*pfilter = device_filter;
}
return 0;
}
| 0
|
398,179
|
get_eventloop_weight(self)
VALUE self;
{
return rb_ary_new3(2, INT2NUM(event_loop_max), INT2NUM(no_event_tick));
}
| 0
|
8,113
|
void Compute(OpKernelContext* ctx) override {
const Tensor& input_0 = ctx->input(0);
const Tensor& input_1 = ctx->input(1);
const Device& eigen_device = ctx->eigen_device<Device>();
bool error = false;
bool* const error_ptr = Functor::has_errors ? &error : nullptr;
// NOTE: Handle three simple cases before building the BinaryOpState, which
// is relatively expensive for small operations.
if (input_0.shape() == input_1.shape()) {
// tensor op tensor with no broadcasting.
Tensor* out;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{0, 1}, 0, input_0.shape(), &out));
functor::BinaryFunctor<Device, Functor, 1>()(
eigen_device, out->template flat<Tout>(),
input_0.template flat<Tin>(), input_1.template flat<Tin>(),
error_ptr);
if (Functor::has_errors && error) {
SetComputeError(ctx);
}
return;
} else if (input_0.shape().dims() == 0) {
// scalar op tensor.
Tensor* out;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{1}, 0, input_1.shape(), &out));
functor::BinaryFunctor<Device, Functor, 1>().Left(
eigen_device, out->template flat<Tout>(),
input_0.template scalar<Tin>(), input_1.template flat<Tin>(),
error_ptr);
if (Functor::has_errors && error) {
SetComputeError(ctx);
}
return;
} else if (input_1.shape().dims() == 0) {
// tensor op scalar.
Tensor* out;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{0}, 0, input_0.shape(), &out));
functor::BinaryFunctor<Device, Functor, 1>().Right(
eigen_device, out->template flat<Tout>(),
input_0.template flat<Tin>(), input_1.template scalar<Tin>(),
error_ptr);
if (Functor::has_errors && error) {
SetComputeError(ctx);
}
return;
}
// 'state': Shared helper not dependent on T to reduce code size
BinaryOpState state(ctx);
if (ctx->status().code() == error::RESOURCE_EXHAUSTED) {
// Stop when BinaryOpState's constructor failed due to OOM.
return;
}
auto& bcast = state.bcast;
Tensor* out = state.out;
if (!bcast.IsValid()) {
if (ctx->status().ok()) {
if (state.result) {
functor::SetOneFunctor<Device, bool>()(eigen_device,
out->flat<bool>());
} else {
functor::SetZeroFunctor<Device, bool>()(eigen_device,
out->flat<bool>());
}
}
return;
}
auto& in0 = state.in0;
auto& in1 = state.in1;
if (state.out_num_elements == 0) {
return;
}
const int ndims = state.ndims;
if (ndims <= 1) {
auto out_flat = out->flat<Tout>();
if (state.in1_num_elements == 1) {
// tensor op scalar
functor::BinaryFunctor<Device, Functor, 1>().Right(
eigen_device, out_flat, in0.template flat<Tin>(),
in1.template scalar<Tin>(), error_ptr);
} else if (state.in0_num_elements == 1) {
// scalar op tensor
functor::BinaryFunctor<Device, Functor, 1>().Left(
eigen_device, out_flat, in0.template scalar<Tin>(),
in1.template flat<Tin>(), error_ptr);
} else {
functor::BinaryFunctor<Device, Functor, 1>()(
eigen_device, out_flat, in0.template flat<Tin>(),
in1.template flat<Tin>(), error_ptr);
}
} else if (ndims == 2) {
functor::BinaryFunctor<Device, Functor, 2>().BCast(
eigen_device, out->shaped<Tout, 2>(bcast.result_shape()),
in0.template shaped<Tin, 2>(bcast.x_reshape()),
BCast::ToIndexArray<2>(bcast.x_bcast()),
in1.template shaped<Tin, 2>(bcast.y_reshape()),
BCast::ToIndexArray<2>(bcast.y_bcast()), error_ptr);
} else if (ndims == 3) {
functor::BinaryFunctor<Device, Functor, 3>().BCast(
eigen_device, out->shaped<Tout, 3>(bcast.result_shape()),
in0.template shaped<Tin, 3>(bcast.x_reshape()),
BCast::ToIndexArray<3>(bcast.x_bcast()),
in1.template shaped<Tin, 3>(bcast.y_reshape()),
BCast::ToIndexArray<3>(bcast.y_bcast()), error_ptr);
} else if (ndims == 4) {
functor::BinaryFunctor<Device, Functor, 4>().BCast(
eigen_device, out->shaped<Tout, 4>(bcast.result_shape()),
in0.template shaped<Tin, 4>(bcast.x_reshape()),
BCast::ToIndexArray<4>(bcast.x_bcast()),
in1.template shaped<Tin, 4>(bcast.y_reshape()),
BCast::ToIndexArray<4>(bcast.y_bcast()), error_ptr);
} else if (ndims == 5) {
functor::BinaryFunctor<Device, Functor, 5>().BCast(
eigen_device, out->shaped<Tout, 5>(bcast.result_shape()),
in0.template shaped<Tin, 5>(bcast.x_reshape()),
BCast::ToIndexArray<5>(bcast.x_bcast()),
in1.template shaped<Tin, 5>(bcast.y_reshape()),
BCast::ToIndexArray<5>(bcast.y_bcast()), error_ptr);
} else {
SetUnimplementedError(ctx);
}
if (Functor::has_errors && error) {
SetComputeError(ctx);
}
}
| 1
|
116,644
|
int Jsi_HexStr(const uchar *data, int len, Jsi_DString *dStr, bool decode) {
int olen = (decode?(len/2+1):(len*2+1));
Jsi_DSSetLength(dStr, olen);
if (!decode)
return jsi_FromHexStr((const char*)data, (uchar*)Jsi_DSValue(dStr));
jsi_ToHexStr((const uchar*)data, len, Jsi_DSValue(dStr));
return olen-1;
}
| 0
|
275,358
|
void DownloadItemImpl::DestinationError(
DownloadInterruptReason reason,
int64_t bytes_so_far,
std::unique_ptr<crypto::SecureHash> secure_hash) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL);
DVLOG(20) << __func__
<< "() reason:" << DownloadInterruptReasonToString(reason)
<< " this:" << DebugString(true);
InterruptWithPartialState(bytes_so_far, std::move(secure_hash), reason);
UpdateObservers();
}
| 0
|
146,274
|
megasas_fire_cmd_xscale(struct megasas_instance *instance,
dma_addr_t frame_phys_addr,
u32 frame_count,
struct megasas_register_set __iomem *regs)
{
unsigned long flags;
spin_lock_irqsave(&instance->hba_lock, flags);
writel((frame_phys_addr >> 3)|(frame_count),
&(regs)->inbound_queue_port);
spin_unlock_irqrestore(&instance->hba_lock, flags);
}
| 0
|
252,444
|
nfs4_check_delegmode(struct nfs4_delegation *dp, int flags)
{
if ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ))
return nfserr_openmode;
else
return nfs_ok;
}
| 0
|
461,721
|
EXPORT_SYMBOL_GPL(iscsi_session_event);
static int
iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep,
struct iscsi_uevent *ev, pid_t pid,
uint32_t initial_cmdsn, uint16_t cmds_max,
uint16_t queue_depth)
{
struct iscsi_transport *transport = priv->iscsi_transport;
struct iscsi_cls_session *session;
struct Scsi_Host *shost;
session = transport->create_session(ep, cmds_max, queue_depth,
initial_cmdsn);
if (!session)
return -ENOMEM;
session->creator = pid;
shost = iscsi_session_to_shost(session);
ev->r.c_session_ret.host_no = shost->host_no;
ev->r.c_session_ret.sid = session->sid;
ISCSI_DBG_TRANS_SESSION(session,
| 0
|
501,603
|
TEST_F(HttpHealthCheckerImplTest, ServiceNameMismatch) {
setupServiceNameValidationHC("locations");
EXPECT_CALL(event_logger_, logUnhealthy(_, _, _, true));
EXPECT_CALL(runtime_.snapshot_, featureEnabled("health_check.verify_cluster", 100))
.WillOnce(Return(true));
EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed));
EXPECT_CALL(event_logger_, logEjectUnhealthy(_, _, _));
cluster_->prioritySet().getMockHostSet(0)->hosts_ = {
makeTestHost(cluster_->info_, "tcp://127.0.0.1:80", simTime())};
cluster_->info_->stats().upstream_cx_total_.inc();
expectSessionCreate();
expectStreamCreate(0);
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _));
health_checker_->start();
EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _));
EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _))
.WillOnce(Return(45000));
EXPECT_CALL(*test_sessions_[0]->interval_timer_,
enableTimer(std::chrono::milliseconds(45000), _));
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer());
absl::optional<std::string> health_checked_cluster("api-production-iad");
respond(0, "200", false, false, true, false, health_checked_cluster);
EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet(
Host::HealthFlag::FAILED_ACTIVE_HC));
EXPECT_EQ(Host::Health::Unhealthy,
cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health());
}
| 0
|
399,607
|
static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx)
{
int node;
/* all pwqs have been created successfully, let's install'em */
mutex_lock(&ctx->wq->mutex);
copy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs);
/* save the previous pwq and install the new one */
for_each_node(node)
ctx->pwq_tbl[node] = numa_pwq_tbl_install(ctx->wq, node,
ctx->pwq_tbl[node]);
/* @dfl_pwq might not have been used, ensure it's linked */
link_pwq(ctx->dfl_pwq);
swap(ctx->wq->dfl_pwq, ctx->dfl_pwq);
mutex_unlock(&ctx->wq->mutex);
}
| 0
|
279,099
|
void RenderView::OnSetDOMUIProperty(const std::string& name,
const std::string& value) {
DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_));
dom_ui_bindings_.SetProperty(name, value);
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.