id stringlengths 22 26 | content stringlengths 72 142k |
|---|---|
devign_test_set_data_14324 | static BlockAIOCB *bdrv_co_aio_rw_vector(BdrvChild *child,
int64_t sector_num,
QEMUIOVector *qiov,
int nb_sectors,
BdrvRequestFlags flags,
BlockCompletionFunc *cb,
void *opaque,
bool is_write)
{
Coroutine *co;
BlockAIOCBCoroutine *acb;
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, child->bs, cb, opaque);
acb->child = child;
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
acb->req.sector = sector_num;
acb->req.nb_sectors = nb_sectors;
acb->req.qiov = qiov;
acb->req.flags = flags;
acb->is_write = is_write;
co = qemu_coroutine_create(bdrv_co_do_rw);
qemu_coroutine_enter(co, acb);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14350 | static int standard_decode_picture_secondary_header(VC9Context *v)
{
GetBitContext *gb = &v->s.gb;
int status = 0, index;
switch (v->s.pict_type)
{
case P_TYPE: status = decode_p_picture_secondary_header(v); break;
case B_TYPE: status = decode_b_picture_secondary_header(v); break;
case BI_TYPE:
case I_TYPE: break; //Nothing needed as it's done in the epilog
}
if (status < 0) return FRAME_SKIPED;
/* AC Syntax */
v->ac_table_level = decode012(gb);
if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)
{
v->ac2_table_level = decode012(gb);
}
/* DC Syntax */
index = decode012(gb);
v->luma_dc_vlc = &ff_msmp4_dc_luma_vlc[index];
v->chroma_dc_vlc = &ff_msmp4_dc_chroma_vlc[index];
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14356 | static void ccw_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
NMIClass *nc = NMI_CLASS(oc);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
s390mc->ri_allowed = true;
s390mc->cpu_model_allowed = true;
s390mc->css_migration_enabled = true;
s390mc->gs_allowed = true;
mc->init = ccw_init;
mc->reset = s390_machine_reset;
mc->hot_add_cpu = s390_hot_add_cpu;
mc->block_default_type = IF_VIRTIO;
mc->no_cdrom = 1;
mc->no_floppy = 1;
mc->no_serial = 1;
mc->no_parallel = 1;
mc->no_sdcard = 1;
mc->use_sclp = 1;
mc->max_cpus = S390_MAX_CPUS;
mc->has_hotpluggable_cpus = true;
mc->get_hotplug_handler = s390_get_hotplug_handler;
mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
/* it is overridden with 'host' cpu *in kvm_arch_init* */
mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
hc->plug = s390_machine_device_plug;
hc->unplug_request = s390_machine_device_unplug_request;
nc->nmi_monitor_handler = s390_nmi;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14359 | static int write_cvid_header(CinepakEncContext *s, unsigned char *buf, int num_strips, int data_size)
{
buf[0] = 0;
AV_WB24(&buf[1], data_size + CVID_HEADER_SIZE);
AV_WB16(&buf[4], s->w);
AV_WB16(&buf[6], s->h);
AV_WB16(&buf[8], num_strips);
return CVID_HEADER_SIZE;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14362 | static av_cold int mpeg4video_parse_init(AVCodecParserContext *s)
{
ParseContext1 *pc = s->priv_data;
pc->enc = av_mallocz(sizeof(MpegEncContext));
if (!pc->enc)
return -1;
pc->first_picture = 1;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14366 | const AVOption *av_opt_next(void *obj, const AVOption *last)
{
AVClass *class = *(AVClass**)obj;
if (!last && class->option[0].name) return class->option;
if (last && last[1].name) return ++last;
return NULL;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14372 | static void do_audio_out(AVFormatContext *s, OutputStream *ost,
InputStream *ist, AVFrame *decoded_frame)
{
uint8_t *buftmp;
int size_out, frame_bytes, resample_changed, ret;
AVCodecContext *enc = ost->st->codec;
AVCodecContext *dec = ist->st->codec;
int osize = av_get_bytes_per_sample(enc->sample_fmt);
int isize = av_get_bytes_per_sample(dec->sample_fmt);
uint8_t *buf = decoded_frame->data[0];
int size = decoded_frame->nb_samples * dec->channels * isize;
int out_linesize = 0;
int buf_linesize = decoded_frame->linesize[0];
get_default_channel_layouts(ost, ist);
if (alloc_audio_output_buf(dec, enc, decoded_frame->nb_samples, &out_linesize) < 0) {
av_log(NULL, AV_LOG_FATAL, "Error allocating audio buffer\n");
exit_program(1);
}
if (audio_sync_method > 1 ||
enc->channels != dec->channels ||
enc->channel_layout != dec->channel_layout ||
enc->sample_rate != dec->sample_rate ||
dec->sample_fmt != enc->sample_fmt)
ost->audio_resample = 1;
resample_changed = ost->resample_sample_fmt != dec->sample_fmt ||
ost->resample_channels != dec->channels ||
ost->resample_channel_layout != dec->channel_layout ||
ost->resample_sample_rate != dec->sample_rate;
if ((ost->audio_resample && !ost->avr) || resample_changed) {
if (resample_changed) {
av_log(NULL, AV_LOG_INFO, "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:0x%"PRIx64" to rate:%d fmt:%s ch:%d chl:0x%"PRIx64"\n",
ist->file_index, ist->st->index,
ost->resample_sample_rate, av_get_sample_fmt_name(ost->resample_sample_fmt),
ost->resample_channels, ost->resample_channel_layout,
dec->sample_rate, av_get_sample_fmt_name(dec->sample_fmt),
dec->channels, dec->channel_layout);
ost->resample_sample_fmt = dec->sample_fmt;
ost->resample_channels = dec->channels;
ost->resample_channel_layout = dec->channel_layout;
ost->resample_sample_rate = dec->sample_rate;
if (ost->avr)
avresample_close(ost->avr);
}
/* if audio_sync_method is >1 the resampler is needed for audio drift compensation */
if (audio_sync_method <= 1 &&
ost->resample_sample_fmt == enc->sample_fmt &&
ost->resample_channels == enc->channels &&
ost->resample_channel_layout == enc->channel_layout &&
ost->resample_sample_rate == enc->sample_rate) {
ost->audio_resample = 0;
} else if (ost->audio_resample) {
if (!ost->avr) {
ost->avr = avresample_alloc_context();
if (!ost->avr) {
av_log(NULL, AV_LOG_FATAL, "Error allocating context for libavresample\n");
exit_program(1);
}
}
av_opt_set_int(ost->avr, "in_channel_layout", dec->channel_layout, 0);
av_opt_set_int(ost->avr, "in_sample_fmt", dec->sample_fmt, 0);
av_opt_set_int(ost->avr, "in_sample_rate", dec->sample_rate, 0);
av_opt_set_int(ost->avr, "out_channel_layout", enc->channel_layout, 0);
av_opt_set_int(ost->avr, "out_sample_fmt", enc->sample_fmt, 0);
av_opt_set_int(ost->avr, "out_sample_rate", enc->sample_rate, 0);
if (audio_sync_method > 1)
av_opt_set_int(ost->avr, "force_resampling", 1, 0);
/* if both the input and output formats are s16 or u8, use s16 as
the internal sample format */
if (av_get_bytes_per_sample(dec->sample_fmt) <= 2 &&
av_get_bytes_per_sample(enc->sample_fmt) <= 2) {
av_opt_set_int(ost->avr, "internal_sample_fmt", AV_SAMPLE_FMT_S16P, 0);
}
ret = avresample_open(ost->avr);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error opening libavresample\n");
exit_program(1);
}
}
}
if (audio_sync_method > 0) {
double delta = get_sync_ipts(ost, ist->last_dts) * enc->sample_rate - ost->sync_opts -
av_fifo_size(ost->fifo) / (enc->channels * osize);
int idelta = delta * dec->sample_rate / enc->sample_rate;
int byte_delta = idelta * isize * dec->channels;
// FIXME resample delay
if (fabs(delta) > 50) {
if (ist->is_start || fabs(delta) > audio_drift_threshold*enc->sample_rate) {
if (byte_delta < 0) {
byte_delta = FFMAX(byte_delta, -size);
size += byte_delta;
buf -= byte_delta;
av_log(NULL, AV_LOG_VERBOSE, "discarding %d audio samples\n",
-byte_delta / (isize * dec->channels));
if (!size)
return;
ist->is_start = 0;
} else {
av_fast_malloc(&async_buf, &allocated_async_buf_size,
byte_delta + size);
if (!async_buf) {
av_log(NULL, AV_LOG_FATAL, "Out of memory in do_audio_out\n");
exit_program(1);
}
if (alloc_audio_output_buf(dec, enc, decoded_frame->nb_samples + idelta, &out_linesize) < 0) {
av_log(NULL, AV_LOG_FATAL, "Error allocating audio buffer\n");
exit_program(1);
}
ist->is_start = 0;
generate_silence(async_buf, dec->sample_fmt, byte_delta);
memcpy(async_buf + byte_delta, buf, size);
buf = async_buf;
size += byte_delta;
buf_linesize = allocated_async_buf_size;
av_log(NULL, AV_LOG_VERBOSE, "adding %d audio samples of silence\n", idelta);
}
} else if (audio_sync_method > 1) {
int comp = av_clip(delta, -audio_sync_method, audio_sync_method);
av_log(NULL, AV_LOG_VERBOSE, "compensating audio timestamp drift:%f compensation:%d in:%d\n",
delta, comp, enc->sample_rate);
// fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2));
avresample_set_compensation(ost->avr, comp, enc->sample_rate);
}
}
} else if (audio_sync_method == 0)
ost->sync_opts = lrintf(get_sync_ipts(ost, ist->last_dts) * enc->sample_rate) -
av_fifo_size(ost->fifo) / (enc->channels * osize); // FIXME wrong
if (ost->audio_resample) {
buftmp = audio_buf;
size_out = avresample_convert(ost->avr, (void **)&buftmp,
allocated_audio_buf_size, out_linesize,
(void **)&buf, buf_linesize,
size / (dec->channels * isize));
size_out = size_out * enc->channels * osize;
} else {
buftmp = buf;
size_out = size;
}
/* now encode as many frames as possible */
if (!(enc->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
/* output resampled raw samples */
if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
av_log(NULL, AV_LOG_FATAL, "av_fifo_realloc2() failed\n");
exit_program(1);
}
av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL);
frame_bytes = enc->frame_size * osize * enc->channels;
while (av_fifo_size(ost->fifo) >= frame_bytes) {
av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
encode_audio_frame(s, ost, audio_buf, frame_bytes);
}
} else {
encode_audio_frame(s, ost, buftmp, size_out);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14376 | static inline void gen_arm_shift_im(TCGv var, int shiftop, int shift, int flags)
{
switch (shiftop) {
case 0: /* LSL */
if (shift != 0) {
if (flags)
shifter_out_im(var, 32 - shift);
tcg_gen_shli_i32(var, var, shift);
}
break;
case 1: /* LSR */
if (shift == 0) {
if (flags) {
tcg_gen_shri_i32(var, var, 31);
gen_set_CF(var);
}
tcg_gen_movi_i32(var, 0);
} else {
if (flags)
shifter_out_im(var, shift - 1);
tcg_gen_shri_i32(var, var, shift);
}
break;
case 2: /* ASR */
if (shift == 0)
shift = 32;
if (flags)
shifter_out_im(var, shift - 1);
if (shift == 32)
shift = 31;
tcg_gen_sari_i32(var, var, shift);
break;
case 3: /* ROR/RRX */
if (shift != 0) {
if (flags)
shifter_out_im(var, shift - 1);
tcg_gen_rotri_i32(var, var, shift); break;
} else {
TCGv tmp = load_cpu_field(CF);
if (flags)
shifter_out_im(var, 0);
tcg_gen_shri_i32(var, var, 1);
tcg_gen_shli_i32(tmp, tmp, 31);
tcg_gen_or_i32(var, var, tmp);
dead_tmp(tmp);
}
}
};
The vulnerability label is: Vulnerable |
devign_test_set_data_14379 | static void vmxnet3_update_vlan_filters(VMXNET3State *s)
{
int i;
/* Copy configuration from shared memory */
VMXNET3_READ_DRV_SHARED(s->drv_shmem,
devRead.rxFilterConf.vfTable,
s->vlan_table,
sizeof(s->vlan_table));
/* Invert byte order when needed */
for (i = 0; i < ARRAY_SIZE(s->vlan_table); i++) {
s->vlan_table[i] = le32_to_cpu(s->vlan_table[i]);
}
/* Dump configuration for debugging purposes */
VMW_CFPRN("Configured VLANs:");
for (i = 0; i < sizeof(s->vlan_table) * 8; i++) {
if (VMXNET3_VFTABLE_ENTRY_IS_SET(s->vlan_table, i)) {
VMW_CFPRN("\tVLAN %d is present", i);
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14387 | static void arm_timer_recalibrate(arm_timer_state *s, int reload)
{
uint32_t limit;
if ((s->control & TIMER_CTRL_PERIODIC) == 0) {
/* Free running. */
if (s->control & TIMER_CTRL_32BIT)
limit = 0xffffffff;
else
limit = 0xffff;
} else {
/* Periodic. */
limit = s->limit;
}
ptimer_set_limit(s->timer, limit, reload);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14388 | static void term_down_char(void)
{
if (term_hist_entry == TERM_MAX_CMDS - 1 || term_hist_entry == -1)
return;
if (term_history[++term_hist_entry] != NULL) {
pstrcpy(term_cmd_buf, sizeof(term_cmd_buf),
term_history[term_hist_entry]);
} else {
term_hist_entry = -1;
}
term_cmd_buf_index = term_cmd_buf_size = strlen(term_cmd_buf);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14393 | int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size)
{
return kvm_dirty_pages_log_change(phys_addr, size,
KVM_MEM_LOG_DIRTY_PAGES,
KVM_MEM_LOG_DIRTY_PAGES);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14413 | static void do_log(int argc, const char **argv)
{
int mask;
if (argc != 2)
goto help;
if (!strcmp(argv[1], "none")) {
mask = 0;
} else {
mask = cpu_str_to_log_mask(argv[1]);
if (!mask) {
help:
help_cmd(argv[0]);
return;
}
}
cpu_set_log(mask);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14442 | static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
{
HEVCContext *s = avctxt->priv_data;
int ctb_size = 1 << s->sps->log2_ctb_size;
int more_data = 1;
int x_ctb = 0;
int y_ctb = 0;
int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) {
av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n");
return AVERROR_INVALIDDATA;
}
if (s->sh.dependent_slice_segment_flag) {
int prev_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
if (s->tab_slice_address[prev_rs] == -1) {
av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
return AVERROR_INVALIDDATA;
}
}
while (more_data && ctb_addr_ts < s->sps->ctb_size) {
int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
x_ctb = (ctb_addr_rs % ((s->sps->width + ctb_size - 1) >> s->sps->log2_ctb_size)) << s->sps->log2_ctb_size;
y_ctb = (ctb_addr_rs / ((s->sps->width + ctb_size - 1) >> s->sps->log2_ctb_size)) << s->sps->log2_ctb_size;
hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts);
ff_hevc_cabac_init(s, ctb_addr_ts);
hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size);
s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset;
s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset;
s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
if (more_data < 0) {
s->tab_slice_address[ctb_addr_rs] = -1;
return more_data;
}
ctb_addr_ts++;
ff_hevc_save_states(s, ctb_addr_ts);
ff_hevc_hls_filters(s, x_ctb, y_ctb, ctb_size);
}
if (x_ctb + ctb_size >= s->sps->width &&
y_ctb + ctb_size >= s->sps->height)
ff_hevc_hls_filter(s, x_ctb, y_ctb);
return ctb_addr_ts;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14459 | static int decode_header(MPADecodeContext *s, UINT32 header)
{
int sample_rate, frame_size, mpeg25, padding;
int sample_rate_index, bitrate_index;
if (header & (1<<20)) {
s->lsf = (header & (1<<19)) ? 0 : 1;
mpeg25 = 0;
} else {
s->lsf = 1;
mpeg25 = 1;
}
s->layer = 4 - ((header >> 17) & 3);
/* extract frequency */
sample_rate_index = (header >> 10) & 3;
sample_rate = mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
if (sample_rate == 0)
return 1;
sample_rate_index += 3 * (s->lsf + mpeg25);
s->sample_rate_index = sample_rate_index;
s->error_protection = ((header >> 16) & 1) ^ 1;
bitrate_index = (header >> 12) & 0xf;
padding = (header >> 9) & 1;
//extension = (header >> 8) & 1;
s->mode = (header >> 6) & 3;
s->mode_ext = (header >> 4) & 3;
//copyright = (header >> 3) & 1;
//original = (header >> 2) & 1;
//emphasis = header & 3;
if (s->mode == MPA_MONO)
s->nb_channels = 1;
else
s->nb_channels = 2;
if (bitrate_index != 0) {
frame_size = mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
s->bit_rate = frame_size * 1000;
switch(s->layer) {
case 1:
frame_size = (frame_size * 12000) / sample_rate;
frame_size = (frame_size + padding) * 4;
break;
case 2:
frame_size = (frame_size * 144000) / sample_rate;
frame_size += padding;
break;
default:
case 3:
frame_size = (frame_size * 144000) / (sample_rate << s->lsf);
frame_size += padding;
break;
}
s->frame_size = frame_size;
} else {
/* if no frame size computed, signal it */
if (!s->free_format_frame_size)
return 1;
/* free format: compute bitrate and real frame size from the
frame size we extracted by reading the bitstream */
s->frame_size = s->free_format_frame_size;
switch(s->layer) {
case 1:
s->frame_size += padding * 4;
s->bit_rate = (s->frame_size * sample_rate) / 48000;
break;
case 2:
s->frame_size += padding;
s->bit_rate = (s->frame_size * sample_rate) / 144000;
break;
default:
case 3:
s->frame_size += padding;
s->bit_rate = (s->frame_size * (sample_rate << s->lsf)) / 144000;
break;
}
}
s->sample_rate = sample_rate;
#if defined(DEBUG)
printf("layer%d, %d Hz, %d kbits/s, ",
s->layer, s->sample_rate, s->bit_rate);
if (s->nb_channels == 2) {
if (s->layer == 3) {
if (s->mode_ext & MODE_EXT_MS_STEREO)
printf("ms-");
if (s->mode_ext & MODE_EXT_I_STEREO)
printf("i-");
}
printf("stereo");
} else {
printf("mono");
}
printf("\n");
#endif
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14469 | static av_cold int init(AVFilterContext *ctx, const char *args)
{
GradFunContext *gf = ctx->priv;
float thresh = 1.2;
int radius = 16;
if (args)
sscanf(args, "%f:%d", &thresh, &radius);
thresh = av_clipf(thresh, 0.51, 255);
gf->thresh = (1 << 15) / thresh;
gf->radius = av_clip((radius + 1) & ~1, 4, 32);
gf->blur_line = ff_gradfun_blur_line_c;
gf->filter_line = ff_gradfun_filter_line_c;
if (ARCH_X86)
ff_gradfun_init_x86(gf);
av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", thresh, gf->radius);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14476 | static int kvm_client_migration_log(struct CPUPhysMemoryClient *client,
int enable)
{
return kvm_set_migration_log(enable);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14499 | static int64_t rtmp_read_seek(URLContext *s, int stream_index,
int64_t timestamp, int flags)
{
RTMP *r = s->priv_data;
if (flags & AVSEEK_FLAG_BYTE)
return AVERROR(ENOSYS);
/* seeks are in milliseconds */
timestamp = av_rescale(timestamp, AV_TIME_BASE, 1000);
if (!RTMP_SendSeek(r, timestamp))
return -1;
return timestamp;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14508 | static av_cold int mace_decode_init(AVCodecContext * avctx)
{
MACEContext *ctx = avctx->priv_data;
if (avctx->channels > 2)
return -1;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avcodec_get_frame_defaults(&ctx->frame);
avctx->coded_frame = &ctx->frame;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14521 | float16 float32_to_float16(float32 a, flag ieee STATUS_PARAM)
{
flag aSign;
int_fast16_t aExp;
uint32_t aSig;
uint32_t mask;
uint32_t increment;
int8 roundingMode;
a = float32_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat32Frac( a );
aExp = extractFloat32Exp( a );
aSign = extractFloat32Sign( a );
if ( aExp == 0xFF ) {
if (aSig) {
/* Input is a NaN */
float16 r = commonNaNToFloat16( float32ToCommonNaN( a STATUS_VAR ) STATUS_VAR );
if (!ieee) {
return packFloat16(aSign, 0, 0);
}
return r;
}
/* Infinity */
if (!ieee) {
float_raise(float_flag_invalid STATUS_VAR);
return packFloat16(aSign, 0x1f, 0x3ff);
}
return packFloat16(aSign, 0x1f, 0);
}
if (aExp == 0 && aSig == 0) {
return packFloat16(aSign, 0, 0);
}
/* Decimal point between bits 22 and 23. */
aSig |= 0x00800000;
aExp -= 0x7f;
if (aExp < -14) {
mask = 0x00ffffff;
if (aExp >= -24) {
mask >>= 25 + aExp;
}
} else {
mask = 0x00001fff;
}
if (aSig & mask) {
float_raise( float_flag_underflow STATUS_VAR );
roundingMode = STATUS(float_rounding_mode);
switch (roundingMode) {
case float_round_nearest_even:
increment = (mask + 1) >> 1;
if ((aSig & mask) == increment) {
increment = aSig & (increment << 1);
}
break;
case float_round_up:
increment = aSign ? 0 : mask;
break;
case float_round_down:
increment = aSign ? mask : 0;
break;
default: /* round_to_zero */
increment = 0;
break;
}
aSig += increment;
if (aSig >= 0x01000000) {
aSig >>= 1;
aExp++;
}
} else if (aExp < -14
&& STATUS(float_detect_tininess) == float_tininess_before_rounding) {
float_raise( float_flag_underflow STATUS_VAR);
}
if (ieee) {
if (aExp > 15) {
float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);
return packFloat16(aSign, 0x1f, 0);
}
} else {
if (aExp > 16) {
float_raise(float_flag_invalid | float_flag_inexact STATUS_VAR);
return packFloat16(aSign, 0x1f, 0x3ff);
}
}
if (aExp < -24) {
return packFloat16(aSign, 0, 0);
}
if (aExp < -14) {
aSig >>= -14 - aExp;
aExp = -14;
}
return packFloat16(aSign, aExp + 14, aSig >> 13);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14531 | int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes)
{
unsigned int idx;
unsigned int total_bufs, in_total, out_total;
idx = vq->last_avail_idx;
total_bufs = in_total = out_total = 0;
while (virtqueue_num_heads(vq, idx)) {
unsigned int max, num_bufs, indirect = 0;
target_phys_addr_t desc_pa;
int i;
max = vq->vring.num;
num_bufs = total_bufs;
i = virtqueue_get_head(vq, idx++);
desc_pa = vq->vring.desc;
if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_INDIRECT) {
if (vring_desc_len(desc_pa, i) % sizeof(VRingDesc)) {
error_report("Invalid size for indirect buffer table");
exit(1);
}
/* If we've got too many, that implies a descriptor loop. */
if (num_bufs >= max) {
error_report("Looped descriptor");
exit(1);
}
/* loop over the indirect descriptor table */
indirect = 1;
max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
num_bufs = i = 0;
desc_pa = vring_desc_addr(desc_pa, i);
}
do {
/* If we've got too many, that implies a descriptor loop. */
if (++num_bufs > max) {
error_report("Looped descriptor");
exit(1);
}
if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) {
if (in_bytes > 0 &&
(in_total += vring_desc_len(desc_pa, i)) >= in_bytes)
return 1;
} else {
if (out_bytes > 0 &&
(out_total += vring_desc_len(desc_pa, i)) >= out_bytes)
return 1;
}
} while ((i = virtqueue_next_desc(desc_pa, i, max)) != max);
if (!indirect)
total_bufs = num_bufs;
else
total_bufs++;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14557 | static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
{
CharDriverState *chr;
FDCharDriver *s;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(FDCharDriver));
s->fd_in = io_channel_from_fd(fd_in);
s->fd_out = io_channel_from_fd(fd_out);
fcntl(fd_out, F_SETFL, O_NONBLOCK);
s->chr = chr;
chr->opaque = s;
chr->chr_add_watch = fd_chr_add_watch;
chr->chr_write = fd_chr_write;
chr->chr_update_read_handler = fd_chr_update_read_handler;
chr->chr_close = fd_chr_close;
qemu_chr_be_generic_open(chr);
return chr;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14566 | static int g722_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
G722Context *c = avctx->priv_data;
const int16_t *samples = (const int16_t *)frame->data[0];
int nb_samples, out_size, ret;
out_size = (frame->nb_samples + 1) / 2;
if ((ret = ff_alloc_packet2(avctx, avpkt, out_size)))
return ret;
nb_samples = frame->nb_samples - (frame->nb_samples & 1);
if (avctx->trellis)
g722_encode_trellis(c, avctx->trellis, avpkt->data, nb_samples, samples);
else
g722_encode_no_trellis(c, avpkt->data, nb_samples, samples);
/* handle last frame with odd frame_size */
if (nb_samples < frame->nb_samples) {
int16_t last_samples[2] = { samples[nb_samples], samples[nb_samples] };
encode_byte(c, &avpkt->data[nb_samples >> 1], last_samples);
}
if (frame->pts != AV_NOPTS_VALUE)
avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);
*got_packet_ptr = 1;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14588 | static int gif_image_write_image(AVCodecContext *avctx,
uint8_t **bytestream, uint8_t *end,
const uint32_t *palette,
const uint8_t *buf, const int linesize,
AVPacket *pkt)
{
GIFContext *s = avctx->priv_data;
int len = 0, height = avctx->height, width = avctx->width, x, y;
int x_start = 0, y_start = 0, trans = s->transparent_index;
int honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame;
const uint8_t *ptr;
/* Crop image */
if ((s->flags & GF_OFFSETTING) && s->last_frame && !palette) {
const uint8_t *ref = s->last_frame->data[0];
const int ref_linesize = s->last_frame->linesize[0];
int x_end = avctx->width - 1,
y_end = avctx->height - 1;
/* skip common lines */
while (y_start < y_end) {
if (memcmp(ref + y_start*ref_linesize, buf + y_start*linesize, width))
break;
y_start++;
}
while (y_end > y_start) {
if (memcmp(ref + y_end*ref_linesize, buf + y_end*linesize, width))
break;
y_end--;
}
height = y_end + 1 - y_start;
/* skip common columns */
while (x_start < x_end) {
int same_column = 1;
for (y = y_start; y <= y_end; y++) {
if (ref[y*ref_linesize + x_start] != buf[y*linesize + x_start]) {
same_column = 0;
break;
}
}
if (!same_column)
break;
x_start++;
}
while (x_end > x_start) {
int same_column = 1;
for (y = y_start; y <= y_end; y++) {
if (ref[y*ref_linesize + x_end] != buf[y*linesize + x_end]) {
same_column = 0;
break;
}
}
if (!same_column)
break;
x_end--;
}
width = x_end + 1 - x_start;
av_log(avctx, AV_LOG_DEBUG,"%dx%d image at pos (%d;%d) [area:%dx%d]\n",
width, height, x_start, y_start, avctx->width, avctx->height);
}
/* image block */
bytestream_put_byte(bytestream, GIF_IMAGE_SEPARATOR);
bytestream_put_le16(bytestream, x_start);
bytestream_put_le16(bytestream, y_start);
bytestream_put_le16(bytestream, width);
bytestream_put_le16(bytestream, height);
if (!palette) {
bytestream_put_byte(bytestream, 0x00); /* flags */
} else {
unsigned i;
bytestream_put_byte(bytestream, 1<<7 | 0x7); /* flags */
for (i = 0; i < AVPALETTE_COUNT; i++) {
const uint32_t v = palette[i];
bytestream_put_be24(bytestream, v);
}
}
if (honor_transparency && trans < 0) {
trans = pick_palette_entry(buf + y_start*linesize + x_start,
linesize, width, height);
if (trans < 0) { // TODO, patch welcome
av_log(avctx, AV_LOG_DEBUG, "No available color, can not use transparency\n");
} else {
uint8_t *pal_exdata = s->pal_exdata;
if (!pal_exdata)
pal_exdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal_exdata)
return AVERROR(ENOMEM);
memcpy(pal_exdata, s->palette, AVPALETTE_SIZE);
pal_exdata[trans*4 + 3*!HAVE_BIGENDIAN] = 0x00;
}
}
if (trans < 0)
honor_transparency = 0;
bytestream_put_byte(bytestream, 0x08);
ff_lzw_encode_init(s->lzw, s->buf, 2 * width * height,
12, FF_LZW_GIF, put_bits);
ptr = buf + y_start*linesize + x_start;
if (honor_transparency) {
const int ref_linesize = s->last_frame->linesize[0];
const uint8_t *ref = s->last_frame->data[0] + y_start*ref_linesize + x_start;
for (y = 0; y < height; y++) {
memcpy(s->tmpl, ptr, width);
for (x = 0; x < width; x++)
if (ref[x] == ptr[x])
s->tmpl[x] = trans;
len += ff_lzw_encode(s->lzw, s->tmpl, width);
ptr += linesize;
ref += ref_linesize;
}
} else {
for (y = 0; y < height; y++) {
len += ff_lzw_encode(s->lzw, ptr, width);
ptr += linesize;
}
}
len += ff_lzw_encode_flush(s->lzw, flush_put_bits);
ptr = s->buf;
while (len > 0) {
int size = FFMIN(255, len);
bytestream_put_byte(bytestream, size);
if (end - *bytestream < size)
return -1;
bytestream_put_buffer(bytestream, ptr, size);
ptr += size;
len -= size;
}
bytestream_put_byte(bytestream, 0x00); /* end of image block */
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14589 | static int openfile(char *name, int flags)
{
if (bs) {
fprintf(stderr, "file open already, try 'help close'\n");
return 1;
}
bs = bdrv_new("hda");
if (!bs)
return 1;
if (bdrv_open(bs, name, flags) == -1) {
fprintf(stderr, "%s: can't open device %s\n", progname, name);
bs = NULL;
return 1;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14591 | static void e500_pcihost_bridge_realize(PCIDevice *d, Error **errp)
{
PPCE500PCIBridgeState *b = PPC_E500_PCI_BRIDGE(d);
PPCE500CCSRState *ccsr = CCSR(container_get(qdev_get_machine(),
"/e500-ccsr"));
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI);
d->config[PCI_HEADER_TYPE] =
(d->config[PCI_HEADER_TYPE] & PCI_HEADER_TYPE_MULTI_FUNCTION) |
PCI_HEADER_TYPE_BRIDGE;
memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", &ccsr->ccsr_space,
0, int128_get64(ccsr->ccsr_space.size));
pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &b->bar0);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14599 | void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
{
int i;
for (i=0; i < in->n; i++) {
int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
do {
out[x] = 0.0;
x += in->pitch_lag;
} while (x < size && repeats);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14612 | static int film_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
FilmDemuxContext *film = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
unsigned char scratch[256];
int i;
unsigned int data_offset;
unsigned int audio_frame_counter;
film->sample_table = NULL;
film->stereo_buffer = NULL;
film->stereo_buffer_size = 0;
/* load the main FILM header */
if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
data_offset = AV_RB32(&scratch[4]);
film->version = AV_RB32(&scratch[8]);
/* load the FDSC chunk */
if (film->version == 0) {
/* special case for Lemmings .film files; 20-byte header */
if (avio_read(pb, scratch, 20) != 20)
return AVERROR(EIO);
/* make some assumptions about the audio parameters */
film->audio_type = CODEC_ID_PCM_S8;
film->audio_samplerate = 22050;
film->audio_channels = 1;
film->audio_bits = 8;
} else {
/* normal Saturn .cpk files; 32-byte header */
if (avio_read(pb, scratch, 32) != 32)
return AVERROR(EIO);
film->audio_samplerate = AV_RB16(&scratch[24]);
film->audio_channels = scratch[21];
film->audio_bits = scratch[22];
if (scratch[23] == 2)
film->audio_type = CODEC_ID_ADPCM_ADX;
else if (film->audio_bits == 8)
film->audio_type = CODEC_ID_PCM_S8;
else if (film->audio_bits == 16)
film->audio_type = CODEC_ID_PCM_S16BE;
else
film->audio_type = CODEC_ID_NONE;
}
if (AV_RB32(&scratch[0]) != FDSC_TAG)
return AVERROR_INVALIDDATA;
if (AV_RB32(&scratch[8]) == CVID_TAG) {
film->video_type = CODEC_ID_CINEPAK;
} else
film->video_type = CODEC_ID_NONE;
/* initialize the decoder streams */
if (film->video_type) {
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
film->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = film->video_type;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = AV_RB32(&scratch[16]);
st->codec->height = AV_RB32(&scratch[12]);
}
if (film->audio_type) {
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
film->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = film->audio_type;
st->codec->codec_tag = 1;
st->codec->channels = film->audio_channels;
st->codec->sample_rate = film->audio_samplerate;
if (film->audio_type == CODEC_ID_ADPCM_ADX) {
st->codec->bits_per_coded_sample = 18 * 8 / 32;
st->codec->block_align = st->codec->channels * 18;
} else {
st->codec->bits_per_coded_sample = film->audio_bits;
st->codec->block_align = st->codec->channels *
st->codec->bits_per_coded_sample / 8;
}
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec->bits_per_coded_sample;
}
/* load the sample table */
if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
if (AV_RB32(&scratch[0]) != STAB_TAG)
return AVERROR_INVALIDDATA;
film->base_clock = AV_RB32(&scratch[8]);
film->sample_count = AV_RB32(&scratch[12]);
if(film->sample_count >= UINT_MAX / sizeof(film_sample))
return -1;
film->sample_table = av_malloc(film->sample_count * sizeof(film_sample));
if (!film->sample_table)
return AVERROR(ENOMEM);
for(i=0; i<s->nb_streams; i++)
av_set_pts_info(s->streams[i], 33, 1, film->base_clock);
audio_frame_counter = 0;
for (i = 0; i < film->sample_count; i++) {
/* load the next sample record and transfer it to an internal struct */
if (avio_read(pb, scratch, 16) != 16) {
av_free(film->sample_table);
return AVERROR(EIO);
}
film->sample_table[i].sample_offset =
data_offset + AV_RB32(&scratch[0]);
film->sample_table[i].sample_size = AV_RB32(&scratch[4]);
if (AV_RB32(&scratch[8]) == 0xFFFFFFFF) {
film->sample_table[i].stream = film->audio_stream_index;
film->sample_table[i].pts = audio_frame_counter;
film->sample_table[i].pts *= film->base_clock;
film->sample_table[i].pts /= film->audio_samplerate;
if (film->audio_type == CODEC_ID_ADPCM_ADX)
audio_frame_counter += (film->sample_table[i].sample_size * 32 /
(18 * film->audio_channels));
else
audio_frame_counter += (film->sample_table[i].sample_size /
(film->audio_channels * film->audio_bits / 8));
} else {
film->sample_table[i].stream = film->video_stream_index;
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
}
}
film->current_sample = 0;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14639 | static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
{
int16_t *block = ctx->dct_block;
unsigned int pos;
ctx->bdsp.clear_block(block);
block[0] = get_bits(&ctx->gb, 8) << 3;
for (pos = 1; pos < num_coeffs; pos++) {
uint32_t vlc, num_bits;
int value;
int coeff;
vlc = get_vlc2(&ctx->gb, ctx->vlc.table, ctx->vlc.bits, 3);
if (!vlc) /* end-of-block code */
return 0;
if (vlc == -1)
return AVERROR_INVALIDDATA;
/* pos_add and num_bits are coded in the vlc code */
pos += vlc & 15; // pos_add
num_bits = vlc >> 4; // num_bits
if (pos >= 64)
return AVERROR_INVALIDDATA;
value = get_bits(&ctx->gb, num_bits);
/* FFmpeg's IDCT behaves somewhat different from the original code, so
* a factor of 4 was added to the input */
coeff = vlcdec_lookup[num_bits][value];
if (pos < 3)
coeff *= 16;
else /* TODO Use >> 10 instead of / 1001 */
coeff = (coeff * qscale) / 1001;
block[ctx->scantable.permutated[pos]] = coeff;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14654 | static int svq3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *const s = avctx->priv_data;
H264Context *const h = avctx->priv_data;
int m, mb_type;
/* special case for last picture */
if (buf_size == 0) {
if (s->next_picture_ptr && !s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->next_picture;
s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
init_get_bits (&s->gb, buf, 8*buf_size);
s->mb_x = s->mb_y = h->mb_xy = 0;
if (svq3_decode_slice_header(h))
return -1;
s->pict_type = h->slice_type;
s->picture_number = h->slice_num;
if (avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\n",
av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,
s->adaptive_quant, s->qscale, h->slice_num);
}
/* for hurry_up == 5 */
s->current_picture.pict_type = s->pict_type;
s->current_picture.key_frame = (s->pict_type == FF_I_TYPE);
/* Skip B-frames if we do not have reference frames. */
if (s->last_picture_ptr == NULL && s->pict_type == FF_B_TYPE)
return 0;
/* Skip B-frames if we are in a hurry. */
if (avctx->hurry_up && s->pict_type == FF_B_TYPE)
return 0;
/* Skip everything if we are in a hurry >= 5. */
if (avctx->hurry_up >= 5)
return 0;
if ( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == FF_B_TYPE)
||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != FF_I_TYPE)
|| avctx->skip_frame >= AVDISCARD_ALL)
return 0;
if (s->next_p_frame_damaged) {
if (s->pict_type == FF_B_TYPE)
return 0;
else
s->next_p_frame_damaged = 0;
}
if (frame_start(h) < 0)
return -1;
if (s->pict_type == FF_B_TYPE) {
h->frame_num_offset = (h->slice_num - h->prev_frame_num);
if (h->frame_num_offset < 0) {
h->frame_num_offset += 256;
}
if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {
av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n");
return -1;
}
} else {
h->prev_frame_num = h->frame_num;
h->frame_num = h->slice_num;
h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);
if (h->prev_frame_num_offset < 0) {
h->prev_frame_num_offset += 256;
}
}
for (m = 0; m < 2; m++){
int i;
for (i = 0; i < 4; i++){
int j;
for (j = -1; j < 4; j++)
h->ref_cache[m][scan8[0] + 8*i + j]= 1;
if (i < 3)
h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE;
}
}
for (s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for (s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&
((get_bits_count(&s->gb) & 7) == 0 || show_bits(&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) {
skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb));
s->gb.size_in_bits = 8*buf_size;
if (svq3_decode_slice_header(h))
return -1;
/* TODO: support s->mb_skip_run */
}
mb_type = svq3_get_ue_golomb(&s->gb);
if (s->pict_type == FF_I_TYPE) {
mb_type += 8;
} else if (s->pict_type == FF_B_TYPE && mb_type >= 4) {
mb_type += 4;
}
if (mb_type > 33 || svq3_decode_mb(h, mb_type)) {
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if (mb_type != 0) {
hl_decode_mb (h);
}
if (s->pict_type != FF_B_TYPE && !s->low_delay) {
s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
(s->pict_type == FF_P_TYPE && mb_type < 8) ? (mb_type - 1) : -1;
}
}
ff_draw_horiz_band(s, 16*s->mb_y, 16);
}
MPV_frame_end(s);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->current_picture;
} else {
*(AVFrame *) data = *(AVFrame *) &s->last_picture;
}
avctx->frame_number = s->picture_number - 1;
/* Do not output the last pic after seeking. */
if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame);
}
return buf_size;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14658 | static av_cold int rl2_decode_init(AVCodecContext *avctx)
{
Rl2Context *s = avctx->priv_data;
int back_size;
int i;
s->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
avcodec_get_frame_defaults(&s->frame);
/** parse extra data */
if(!avctx->extradata || avctx->extradata_size < EXTRADATA1_SIZE){
av_log(avctx, AV_LOG_ERROR, "invalid extradata size\n");
return -1;
}
/** get frame_offset */
s->video_base = AV_RL16(&avctx->extradata[0]);
s->clr_count = AV_RL32(&avctx->extradata[2]);
if(s->video_base >= avctx->width * avctx->height){
av_log(avctx, AV_LOG_ERROR, "invalid video_base\n");
return -1;
}
/** initialize palette */
for(i=0;i<AVPALETTE_COUNT;i++)
s->palette[i] = 0xFF << 24 | AV_RB24(&avctx->extradata[6 + i * 3]);
/** decode background frame if present */
back_size = avctx->extradata_size - EXTRADATA1_SIZE;
if(back_size > 0){
unsigned char* back_frame = av_mallocz(avctx->width*avctx->height);
if(!back_frame)
return -1;
rl2_rle_decode(s,avctx->extradata + EXTRADATA1_SIZE,back_size,
back_frame,avctx->width,0);
s->back_frame = back_frame;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14665 | static void picmemset(PicContext *s, AVFrame *frame, int value, int run,
int *x, int *y, int *plane, int bits_per_plane)
{
uint8_t *d;
int shift = *plane * bits_per_plane;
int mask = ((1 << bits_per_plane) - 1) << shift;
value <<= shift;
while (run > 0) {
int j;
for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
d = frame->data[0] + *y * frame->linesize[0];
d[*x] |= (value >> j) & mask;
*x += 1;
if (*x == s->width) {
*y -= 1;
*x = 0;
if (*y < 0) {
*y = s->height - 1;
*plane += 1;
if (*plane >= s->nb_planes)
return;
value <<= bits_per_plane;
mask <<= bits_per_plane;
}
}
}
run--;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14673 | static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
{
int pass, i;
for (pass = 0; pass < 20; pass++) {
int k, min_diff = 0;
for (i = 0; i < order+1; i++) {
int low = i != 0 ? nlsf[i-1] : 0;
int high = i != order ? nlsf[i] : 32768;
int diff = (high - low) - (min_delta[i]);
if (diff < min_diff) {
min_diff = diff;
k = i;
if (pass == 20)
break;
}
}
if (min_diff == 0) /* no issues; stabilized */
return;
/* wiggle one or two LSFs */
if (k == 0) {
/* repel away from lower bound */
nlsf[0] = min_delta[0];
} else if (k == order) {
/* repel away from higher bound */
nlsf[order-1] = 32768 - min_delta[order];
} else {
/* repel away from current position */
int min_center = 0, max_center = 32768, center_val;
/* lower extent */
for (i = 0; i < k; i++)
min_center += min_delta[i];
min_center += min_delta[k] >> 1;
/* upper extent */
for (i = order; i > k; i--)
max_center -= min_delta[k];
max_center -= min_delta[k] >> 1;
/* move apart */
center_val = nlsf[k - 1] + nlsf[k];
center_val = (center_val >> 1) + (center_val & 1); // rounded divide by 2
center_val = FFMIN(max_center, FFMAX(min_center, center_val));
nlsf[k - 1] = center_val - (min_delta[k] >> 1);
nlsf[k] = nlsf[k - 1] + min_delta[k];
}
}
/* resort to the fall-back method, the standard method for LSF stabilization */
/* sort; as the LSFs should be nearly sorted, use insertion sort */
for (i = 1; i < order; i++) {
int j, value = nlsf[i];
for (j = i - 1; j >= 0 && nlsf[j] > value; j--)
nlsf[j + 1] = nlsf[j];
nlsf[j + 1] = value;
}
/* push forwards to increase distance */
if (nlsf[0] < min_delta[0])
nlsf[0] = min_delta[0];
for (i = 1; i < order; i++)
if (nlsf[i] < nlsf[i - 1] + min_delta[i])
nlsf[i] = nlsf[i - 1] + min_delta[i];
/* push backwards to increase distance */
if (nlsf[order-1] > 32768 - min_delta[order])
nlsf[order-1] = 32768 - min_delta[order];
for (i = order-2; i >= 0; i--)
if (nlsf[i] > nlsf[i + 1] - min_delta[i+1])
nlsf[i] = nlsf[i + 1] - min_delta[i+1];
return;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14679 | static void pci_unin_main_config_writel (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
UNINState *s = opaque;
UNIN_DPRINTF("config_writel addr " TARGET_FMT_plx " val %x\n", addr, val);
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap32(val);
#endif
s->config_reg = val;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14680 | vubr_set_vring_addr_exec(VubrDev *dev, VhostUserMsg *vmsg)
{
struct vhost_vring_addr *vra = &vmsg->payload.addr;
unsigned int index = vra->index;
VubrVirtq *vq = &dev->vq[index];
DPRINT("vhost_vring_addr:\n");
DPRINT(" index: %d\n", vra->index);
DPRINT(" flags: %d\n", vra->flags);
DPRINT(" desc_user_addr: 0x%016llx\n", vra->desc_user_addr);
DPRINT(" used_user_addr: 0x%016llx\n", vra->used_user_addr);
DPRINT(" avail_user_addr: 0x%016llx\n", vra->avail_user_addr);
DPRINT(" log_guest_addr: 0x%016llx\n", vra->log_guest_addr);
vq->desc = (struct vring_desc *)(uintptr_t)qva_to_va(dev, vra->desc_user_addr);
vq->used = (struct vring_used *)(uintptr_t)qva_to_va(dev, vra->used_user_addr);
vq->avail = (struct vring_avail *)(uintptr_t)qva_to_va(dev, vra->avail_user_addr);
vq->log_guest_addr = vra->log_guest_addr;
DPRINT("Setting virtq addresses:\n");
DPRINT(" vring_desc at %p\n", vq->desc);
DPRINT(" vring_used at %p\n", vq->used);
DPRINT(" vring_avail at %p\n", vq->avail);
vq->last_used_index = vq->used->idx;
return 0;
The vulnerability label is: Vulnerable |
devign_test_set_data_14694 | void ff_get_unscaled_swscale(SwsContext *c)
{
const enum PixelFormat srcFormat = c->srcFormat;
const enum PixelFormat dstFormat = c->dstFormat;
const int flags = c->flags;
const int dstH = c->dstH;
int needsDither;
needsDither = isAnyRGB(dstFormat) &&
c->dstFormatBpp < 24 &&
(c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
/* yv12_to_nv12 */
if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) &&
(dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) {
c->swScale = planarToNv12Wrapper;
}
/* yuv2bgr */
if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUV422P ||
srcFormat == PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
!(flags & SWS_ACCURATE_RND) && !(dstH & 1)) {
c->swScale = ff_yuv2rgb_get_func_ptr(c);
}
if (srcFormat == PIX_FMT_YUV410P &&
(dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P) &&
!(flags & SWS_BITEXACT)) {
c->swScale = yvu9ToYv12Wrapper;
}
/* bgr24toYV12 */
if (srcFormat == PIX_FMT_BGR24 &&
(dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P) &&
!(flags & SWS_ACCURATE_RND))
c->swScale = bgr24ToYv12Wrapper;
/* RGB/BGR -> RGB/BGR (no dither needed forms) */
if ( isAnyRGB(srcFormat)
&& isAnyRGB(dstFormat)
&& srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8
&& srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8
&& srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4
&& srcFormat != PIX_FMT_RGB4 && dstFormat != PIX_FMT_RGB4
&& srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE
&& srcFormat != PIX_FMT_RGB4_BYTE && dstFormat != PIX_FMT_RGB4_BYTE
&& srcFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_MONOBLACK
&& srcFormat != PIX_FMT_MONOWHITE && dstFormat != PIX_FMT_MONOWHITE
&& srcFormat != PIX_FMT_RGB48LE && dstFormat != PIX_FMT_RGB48LE
&& srcFormat != PIX_FMT_RGB48BE && dstFormat != PIX_FMT_RGB48BE
&& srcFormat != PIX_FMT_BGR48LE && dstFormat != PIX_FMT_BGR48LE
&& srcFormat != PIX_FMT_BGR48BE && dstFormat != PIX_FMT_BGR48BE
&& (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))
c->swScale= rgbToRgbWrapper;
/* bswap 16 bits per pixel/component packed formats */
if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR444) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR48) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR555) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_BGR565) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_GRAY16) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB444) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB48) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB555) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, PIX_FMT_RGB565))
c->swScale = packed_16bpc_bswap;
if ((usePal(srcFormat) && (
dstFormat == PIX_FMT_RGB32 ||
dstFormat == PIX_FMT_RGB32_1 ||
dstFormat == PIX_FMT_RGB24 ||
dstFormat == PIX_FMT_BGR32 ||
dstFormat == PIX_FMT_BGR32_1 ||
dstFormat == PIX_FMT_BGR24)))
c->swScale = palToRgbWrapper;
if (srcFormat == PIX_FMT_YUV422P) {
if (dstFormat == PIX_FMT_YUYV422)
c->swScale = yuv422pToYuy2Wrapper;
else if (dstFormat == PIX_FMT_UYVY422)
c->swScale = yuv422pToUyvyWrapper;
}
/* LQ converters if -sws 0 or -sws 4*/
if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
/* yv12_to_yuy2 */
if (srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) {
if (dstFormat == PIX_FMT_YUYV422)
c->swScale = planarToYuy2Wrapper;
else if (dstFormat == PIX_FMT_UYVY422)
c->swScale = planarToUyvyWrapper;
}
}
if (srcFormat == PIX_FMT_YUYV422 &&
(dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P))
c->swScale = yuyvToYuv420Wrapper;
if (srcFormat == PIX_FMT_UYVY422 &&
(dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P))
c->swScale = uyvyToYuv420Wrapper;
if (srcFormat == PIX_FMT_YUYV422 && dstFormat == PIX_FMT_YUV422P)
c->swScale = yuyvToYuv422Wrapper;
if (srcFormat == PIX_FMT_UYVY422 && dstFormat == PIX_FMT_YUV422P)
c->swScale = uyvyToYuv422Wrapper;
/* simple copy */
if ( srcFormat == dstFormat ||
(srcFormat == PIX_FMT_YUVA420P && dstFormat == PIX_FMT_YUV420P) ||
(srcFormat == PIX_FMT_YUV420P && dstFormat == PIX_FMT_YUVA420P) ||
(isPlanarYUV(srcFormat) && isGray(dstFormat)) ||
(isPlanarYUV(dstFormat) && isGray(srcFormat)) ||
(isGray(dstFormat) && isGray(srcFormat)) ||
(isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
c->chrDstHSubSample == c->chrSrcHSubSample &&
c->chrDstVSubSample == c->chrSrcVSubSample &&
dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21 &&
srcFormat != PIX_FMT_NV12 && srcFormat != PIX_FMT_NV21))
{
if (isPacked(c->srcFormat))
c->swScale = packedCopyWrapper;
else /* Planar YUV or gray */
c->swScale = planarCopyWrapper;
}
if (ARCH_BFIN)
ff_bfin_get_unscaled_swscale(c);
if (HAVE_ALTIVEC)
ff_swscale_get_unscaled_altivec(c);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14716 | static PCIBridgeWindows *pci_bridge_region_init(PCIBridge *br)
{
PCIDevice *pd = PCI_DEVICE(br);
PCIBus *parent = pd->bus;
PCIBridgeWindows *w = g_new(PCIBridgeWindows, 1);
uint16_t cmd = pci_get_word(pd->config + PCI_COMMAND);
pci_bridge_init_alias(br, &w->alias_pref_mem,
PCI_BASE_ADDRESS_MEM_PREFETCH,
"pci_bridge_pref_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &w->alias_mem,
PCI_BASE_ADDRESS_SPACE_MEMORY,
"pci_bridge_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &w->alias_io,
PCI_BASE_ADDRESS_SPACE_IO,
"pci_bridge_io",
&br->address_space_io,
parent->address_space_io,
cmd & PCI_COMMAND_IO);
pci_bridge_init_vga_aliases(br, parent, w->alias_vga);
return w;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14723 | static void hls_transform_tree(HEVCContext *s, int x0, int y0,
int xBase, int yBase, int cb_xBase, int cb_yBase,
int log2_cb_size, int log2_trafo_size,
int trafo_depth, int blk_idx)
{
HEVCLocalContext *lc = &s->HEVClc;
uint8_t split_transform_flag;
if (trafo_depth > 0 && log2_trafo_size == 2) {
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth - 1], xBase, yBase);
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0) =
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth - 1], xBase, yBase);
} else {
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0) = 0;
}
if (lc->cu.intra_split_flag) {
if (trafo_depth == 1)
lc->tu.cur_intra_pred_mode = lc->pu.intra_pred_mode[blk_idx];
} else {
lc->tu.cur_intra_pred_mode = lc->pu.intra_pred_mode[0];
}
lc->tt.cbf_luma = 1;
lc->tt.inter_split_flag = s->sps->max_transform_hierarchy_depth_inter == 0 &&
lc->cu.pred_mode == MODE_INTER &&
lc->cu.part_mode != PART_2Nx2N &&
trafo_depth == 0;
if (log2_trafo_size <= s->sps->log2_max_trafo_size &&
log2_trafo_size > s->sps->log2_min_tb_size &&
trafo_depth < lc->cu.max_trafo_depth &&
!(lc->cu.intra_split_flag && trafo_depth == 0)) {
split_transform_flag = ff_hevc_split_transform_flag_decode(s, log2_trafo_size);
} else {
split_transform_flag = log2_trafo_size > s->sps->log2_max_trafo_size ||
(lc->cu.intra_split_flag && trafo_depth == 0) ||
lc->tt.inter_split_flag;
}
if (log2_trafo_size > 2) {
if (trafo_depth == 0 ||
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth - 1], xBase, yBase)) {
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
ff_hevc_cbf_cb_cr_decode(s, trafo_depth);
}
if (trafo_depth == 0 ||
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth - 1], xBase, yBase)) {
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0) =
ff_hevc_cbf_cb_cr_decode(s, trafo_depth);
}
}
if (split_transform_flag) {
int x1 = x0 + ((1 << log2_trafo_size) >> 1);
int y1 = y0 + ((1 << log2_trafo_size) >> 1);
hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
log2_trafo_size - 1, trafo_depth + 1, 0);
hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
log2_trafo_size - 1, trafo_depth + 1, 1);
hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
log2_trafo_size - 1, trafo_depth + 1, 2);
hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
log2_trafo_size - 1, trafo_depth + 1, 3);
} else {
int min_tu_size = 1 << s->sps->log2_min_tb_size;
int log2_min_tu_size = s->sps->log2_min_tb_size;
int min_tu_width = s->sps->min_tb_width;
if (lc->cu.pred_mode == MODE_INTRA || trafo_depth != 0 ||
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) ||
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0)) {
lc->tt.cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth);
}
hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
log2_cb_size, log2_trafo_size, trafo_depth, blk_idx);
// TODO: store cbf_luma somewhere else
if (lc->tt.cbf_luma) {
int i, j;
for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
int x_tu = (x0 + j) >> log2_min_tu_size;
int y_tu = (y0 + i) >> log2_min_tu_size;
s->cbf_luma[y_tu * min_tu_width + x_tu] = 1;
}
}
if (!s->sh.disable_deblocking_filter_flag) {
ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_trafo_size,
lc->slice_or_tiles_up_boundary,
lc->slice_or_tiles_left_boundary);
if (s->pps->transquant_bypass_enable_flag &&
lc->cu.cu_transquant_bypass_flag)
set_deblocking_bypass(s, x0, y0, log2_trafo_size);
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14741 | static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb,
int block_idx, AMRFixed *fcb)
{
uint16_t use_mask_mem[9]; // only 5 are used, rest is padding
uint16_t *use_mask = use_mask_mem + 2;
/* in this function, idx is the index in the 80-bit (+ padding) use_mask
* bit-array. Since use_mask consists of 16-bit values, the lower 4 bits
* of idx are the position of the bit within a particular item in the
* array (0 being the most significant bit, and 15 being the least
* significant bit), and the remainder (>> 4) is the index in the
* use_mask[]-array. This is faster and uses less memory than using a
* 80-byte/80-int array. */
int pulse_off = s->aw_first_pulse_off[block_idx],
pulse_start, n, idx, range, aidx, start_off = 0;
/* set offset of first pulse to within this block */
if (s->aw_n_pulses[block_idx] > 0)
while (pulse_off + s->aw_pulse_range < 1)
pulse_off += fcb->pitch_lag;
/* find range per pulse */
if (s->aw_n_pulses[0] > 0) {
if (block_idx == 0) {
range = 32;
} else /* block_idx = 1 */ {
range = 8;
if (s->aw_n_pulses[block_idx] > 0)
pulse_off = s->aw_next_pulse_off_cache;
}
} else
range = 16;
pulse_start = s->aw_n_pulses[block_idx] > 0 ? pulse_off - range / 2 : 0;
/* aw_pulse_set1() already applies pulses around pulse_off (to be exactly,
* in the range of [pulse_off, pulse_off + s->aw_pulse_range], and thus
* we exclude that range from being pulsed again in this function. */
memset(&use_mask[-2], 0, 2 * sizeof(use_mask[0]));
memset( use_mask, -1, 5 * sizeof(use_mask[0]));
memset(&use_mask[5], 0, 2 * sizeof(use_mask[0]));
if (s->aw_n_pulses[block_idx] > 0)
for (idx = pulse_off; idx < MAX_FRAMESIZE / 2; idx += fcb->pitch_lag) {
int excl_range = s->aw_pulse_range; // always 16 or 24
uint16_t *use_mask_ptr = &use_mask[idx >> 4];
int first_sh = 16 - (idx & 15);
*use_mask_ptr++ &= 0xFFFF << first_sh;
excl_range -= first_sh;
if (excl_range >= 16) {
*use_mask_ptr++ = 0;
*use_mask_ptr &= 0xFFFF >> (excl_range - 16);
} else
*use_mask_ptr &= 0xFFFF >> excl_range;
}
/* find the 'aidx'th offset that is not excluded */
aidx = get_bits(gb, s->aw_n_pulses[0] > 0 ? 5 - 2 * block_idx : 4);
for (n = 0; n <= aidx; pulse_start++) {
for (idx = pulse_start; idx < 0; idx += fcb->pitch_lag) ;
if (idx >= MAX_FRAMESIZE / 2) { // find from zero
if (use_mask[0]) idx = 0x0F;
else if (use_mask[1]) idx = 0x1F;
else if (use_mask[2]) idx = 0x2F;
else if (use_mask[3]) idx = 0x3F;
else if (use_mask[4]) idx = 0x4F;
else return;
idx -= av_log2_16bit(use_mask[idx >> 4]);
}
if (use_mask[idx >> 4] & (0x8000 >> (idx & 15))) {
use_mask[idx >> 4] &= ~(0x8000 >> (idx & 15));
n++;
start_off = idx;
}
}
fcb->x[fcb->n] = start_off;
fcb->y[fcb->n] = get_bits1(gb) ? -1.0 : 1.0;
fcb->n++;
/* set offset for next block, relative to start of that block */
n = (MAX_FRAMESIZE / 2 - start_off) % fcb->pitch_lag;
s->aw_next_pulse_off_cache = n ? fcb->pitch_lag - n : 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14745 | static void asf_build_simple_index(AVFormatContext *s, int stream_index)
{
ff_asf_guid g;
ASFContext *asf = s->priv_data;
int64_t current_pos = avio_tell(s->pb);
int i;
avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
ff_get_guid(s->pb, &g);
/* the data object can be followed by other top-level objects,
* skip them until the simple index object is reached */
while (ff_guidcmp(&g, &index_guid)) {
int64_t gsize = avio_rl64(s->pb);
if (gsize < 24 || s->pb->eof_reached) {
avio_seek(s->pb, current_pos, SEEK_SET);
return;
}
avio_skip(s->pb, gsize - 24);
ff_get_guid(s->pb, &g);
}
{
int64_t itime, last_pos = -1;
int pct, ict;
int64_t av_unused gsize = avio_rl64(s->pb);
ff_get_guid(s->pb, &g);
itime = avio_rl64(s->pb);
pct = avio_rl32(s->pb);
ict = avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG,
"itime:0x%"PRIx64", pct:%d, ict:%d\n", itime, pct, ict);
for (i = 0; i < ict; i++) {
int pktnum = avio_rl32(s->pb);
int pktct = avio_rl16(s->pb);
int64_t pos = s->data_offset + s->packet_size * (int64_t)pktnum;
int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
if (pos != last_pos) {
av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n",
pktnum, pktct, index_pts);
av_add_index_entry(s->streams[stream_index], pos, index_pts,
s->packet_size, 0, AVINDEX_KEYFRAME);
last_pos = pos;
}
}
asf->index_read = ict > 0;
}
avio_seek(s->pb, current_pos, SEEK_SET);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14750 | static void bdrv_qed_drain(BlockDriverState *bs)
{
BDRVQEDState *s = bs->opaque;
/* Cancel timer and start doing I/O that were meant to happen as if it
* fired, that way we get bdrv_drain() taking care of the ongoing requests
* correctly. */
qed_cancel_need_check_timer(s);
qed_plug_allocating_write_reqs(s);
bdrv_aio_flush(s->bs, qed_clear_need_check, s);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14774 | static void test_qemu_strtol_invalid(void)
{
const char *str = " xxxx \t abc";
char f = 'X';
const char *endptr = &f;
long res = 999;
int err;
err = qemu_strtol(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14775 | static int check_bind(const char *hostname, bool *has_proto)
{
int fd = -1;
struct addrinfo ai, *res = NULL;
int rc;
int ret = -1;
memset(&ai, 0, sizeof(ai));
ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
ai.ai_family = AF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
/* lookup */
rc = getaddrinfo(hostname, NULL, &ai, &res);
if (rc != 0) {
if (rc == EAI_ADDRFAMILY ||
rc == EAI_FAMILY) {
*has_proto = false;
goto done;
}
goto cleanup;
}
fd = qemu_socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (fd < 0) {
goto cleanup;
}
if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {
if (errno == EADDRNOTAVAIL) {
*has_proto = false;
goto done;
}
goto cleanup;
}
*has_proto = true;
done:
ret = 0;
cleanup:
if (fd != -1) {
close(fd);
}
if (res) {
freeaddrinfo(res);
}
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14777 | static bool run_poll_handlers(AioContext *ctx, int64_t max_ns)
{
bool progress = false;
int64_t end_time;
assert(ctx->notify_me);
assert(ctx->walking_handlers > 0);
assert(ctx->poll_disable_cnt == 0);
trace_run_poll_handlers_begin(ctx, max_ns);
end_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + max_ns;
do {
AioHandler *node;
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->io_poll &&
node->io_poll(node->opaque)) {
progress = true;
}
/* Caller handles freeing deleted nodes. Don't do it here. */
}
} while (!progress && qemu_clock_get_ns(QEMU_CLOCK_REALTIME) < end_time);
trace_run_poll_handlers_end(ctx, progress);
return progress;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14813 | static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
ScreenpressoContext *ctx = avctx->priv_data;
AVFrame *frame = data;
int keyframe;
int ret;
/* Size check */
if (avpkt->size < 3) {
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
return AVERROR_INVALIDDATA;
}
/* Basic sanity check, but not really harmful */
if ((avpkt->data[0] != 0x73 && avpkt->data[0] != 0x72) ||
avpkt->data[1] != 8) { // bpp probably
av_log(avctx, AV_LOG_WARNING, "Unknown header 0x%02X%02X\n",
avpkt->data[0], avpkt->data[1]);
}
keyframe = (avpkt->data[0] == 0x73);
/* Resize deflate buffer and frame on resolution change */
if (ctx->inflated_size != avctx->width * avctx->height * 3) {
av_frame_unref(ctx->current);
ret = ff_get_buffer(avctx, ctx->current, AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
return ret;
/* If malloc fails, reset len to avoid preserving an invalid value */
ctx->inflated_size = avctx->width * avctx->height * 3;
ret = av_reallocp(&ctx->inflated_buf, ctx->inflated_size);
if (ret < 0) {
ctx->inflated_size = 0;
return ret;
}
}
/* Inflate the frame after the 2 byte header */
ret = uncompress(ctx->inflated_buf, &ctx->inflated_size,
avpkt->data + 2, avpkt->size - 2);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Deflate error %d.\n", ret);
return AVERROR_UNKNOWN;
}
/* When a keyframe is found, copy it (flipped) */
if (keyframe)
av_image_copy_plane(ctx->current->data[0] +
ctx->current->linesize[0] * (avctx->height - 1),
-1 * ctx->current->linesize[0],
ctx->inflated_buf, avctx->width * 3,
avctx->width * 3, avctx->height);
/* Otherwise sum the delta on top of the current frame */
else
sum_delta_flipped(ctx->current->data[0], ctx->current->linesize[0],
ctx->inflated_buf, avctx->width * 3,
avctx->width * 3, avctx->height);
/* Frame is ready to be output */
ret = av_frame_ref(frame, ctx->current);
if (ret < 0)
return ret;
/* Usual properties */
if (keyframe) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
}
*got_frame = 1;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14814 | static inline TCGv iwmmxt_load_creg(int reg)
{
TCGv var = new_tmp();
tcg_gen_ld_i32(var, cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));
return var;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14816 | void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value)
{
const ARMCPRegInfo *ri = rip;
ri->writefn(env, ri, value);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14822 | static void vhost_scsi_stop(VHostSCSI *s)
{
VirtIODevice *vdev = VIRTIO_DEVICE(s);
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
int ret = 0;
if (!k->set_guest_notifiers) {
ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
if (ret < 0) {
error_report("vhost guest notifier cleanup failed: %d\n", ret);
}
}
assert(ret >= 0);
vhost_scsi_clear_endpoint(s);
vhost_dev_stop(&s->dev, vdev);
vhost_dev_disable_notifiers(&s->dev, vdev);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14823 | static void start_tco(const TestData *d)
{
uint32_t val;
val = qpci_io_readw(d->dev, d->tco_io_base + TCO1_CNT);
val &= ~TCO_TMR_HLT;
qpci_io_writew(d->dev, d->tco_io_base + TCO1_CNT, val);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14840 | void memory_global_dirty_log_stop(void)
{
global_dirty_log = false;
/* Refresh DIRTY_LOG_MIGRATION bit. */
memory_region_transaction_begin();
memory_region_update_pending = true;
memory_region_transaction_commit();
MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14842 | static inline int open_by_handle(int mountfd, const char *fh, int flags)
{
errno = ENOSYS;
return -1;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14846 | static void cmd_get_event_status_notification(IDEState *s,
uint8_t *buf)
{
const uint8_t *packet = buf;
struct {
uint8_t opcode;
uint8_t polled; /* lsb bit is polled; others are reserved */
uint8_t reserved2[2];
uint8_t class;
uint8_t reserved3[2];
uint16_t len;
uint8_t control;
} __attribute__((packed)) *gesn_cdb;
struct {
uint16_t len;
uint8_t notification_class;
uint8_t supported_events;
} __attribute((packed)) *gesn_event_header;
enum notification_class_request_type {
NCR_RESERVED1 = 1 << 0,
NCR_OPERATIONAL_CHANGE = 1 << 1,
NCR_POWER_MANAGEMENT = 1 << 2,
NCR_EXTERNAL_REQUEST = 1 << 3,
NCR_MEDIA = 1 << 4,
NCR_MULTI_HOST = 1 << 5,
NCR_DEVICE_BUSY = 1 << 6,
NCR_RESERVED2 = 1 << 7,
};
enum event_notification_class_field {
ENC_NO_EVENTS = 0,
ENC_OPERATIONAL_CHANGE,
ENC_POWER_MANAGEMENT,
ENC_EXTERNAL_REQUEST,
ENC_MEDIA,
ENC_MULTIPLE_HOSTS,
ENC_DEVICE_BUSY,
ENC_RESERVED,
};
unsigned int max_len, used_len;
gesn_cdb = (void *)packet;
gesn_event_header = (void *)buf;
max_len = be16_to_cpu(gesn_cdb->len);
/* It is fine by the MMC spec to not support async mode operations */
if (!(gesn_cdb->polled & 0x01)) { /* asynchronous mode */
/* Only polling is supported, asynchronous mode is not. */
ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST,
ASC_INV_FIELD_IN_CMD_PACKET);
return;
}
/* polling mode operation */
/*
* These are the supported events.
*
* We currently only support requests of the 'media' type.
*/
gesn_event_header->supported_events = NCR_MEDIA;
/*
* We use |= below to set the class field; other bits in this byte
* are reserved now but this is useful to do if we have to use the
* reserved fields later.
*/
gesn_event_header->notification_class = 0;
/*
* Responses to requests are to be based on request priority. The
* notification_class_request_type enum above specifies the
* priority: upper elements are higher prio than lower ones.
*/
if (gesn_cdb->class & NCR_MEDIA) {
gesn_event_header->notification_class |= ENC_MEDIA;
used_len = event_status_media(s, buf);
} else {
gesn_event_header->notification_class = 0x80; /* No event available */
used_len = sizeof(*gesn_event_header);
}
gesn_event_header->len = cpu_to_be16(used_len
- sizeof(*gesn_event_header));
ide_atapi_cmd_reply(s, used_len, max_len);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14848 | static int decode_plane(UtvideoContext *c, int plane_no,
uint8_t *dst, int step, ptrdiff_t stride,
int width, int height,
const uint8_t *src, int use_pred)
{
int i, j, slice, pix;
int sstart, send;
VLC vlc;
GetBitContext gb;
int prev, fsym;
const int cmask = c->interlaced ? ~(1 + 2 * (!plane_no && c->avctx->pix_fmt == AV_PIX_FMT_YUV420P)) : ~(!plane_no && c->avctx->pix_fmt == AV_PIX_FMT_YUV420P);
if (build_huff(src, &vlc, &fsym)) {
av_log(c->avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
return AVERROR_INVALIDDATA;
}
if (fsym >= 0) { // build_huff reported a symbol to fill slices with
send = 0;
for (slice = 0; slice < c->slices; slice++) {
uint8_t *dest;
sstart = send;
send = (height * (slice + 1) / c->slices) & cmask;
dest = dst + sstart * stride;
prev = 0x80;
for (j = sstart; j < send; j++) {
for (i = 0; i < width * step; i += step) {
pix = fsym;
if (use_pred) {
prev += pix;
pix = prev;
}
dest[i] = pix;
}
dest += stride;
}
}
return 0;
}
src += 256;
send = 0;
for (slice = 0; slice < c->slices; slice++) {
uint8_t *dest;
int slice_data_start, slice_data_end, slice_size;
sstart = send;
send = (height * (slice + 1) / c->slices) & cmask;
dest = dst + sstart * stride;
// slice offset and size validation was done earlier
slice_data_start = slice ? AV_RL32(src + slice * 4 - 4) : 0;
slice_data_end = AV_RL32(src + slice * 4);
slice_size = slice_data_end - slice_data_start;
if (!slice_size) {
av_log(c->avctx, AV_LOG_ERROR, "Plane has more than one symbol "
"yet a slice has a length of zero.\n");
goto fail;
}
memset(c->slice_bits + slice_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
c->bdsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *)(src + slice_data_start + c->slices * 4),
(slice_data_end - slice_data_start + 3) >> 2);
init_get_bits(&gb, c->slice_bits, slice_size * 8);
prev = 0x80;
for (j = sstart; j < send; j++) {
for (i = 0; i < width * step; i += step) {
pix = get_vlc2(&gb, vlc.table, VLC_BITS, 3);
if (pix < 0) {
av_log(c->avctx, AV_LOG_ERROR, "Decoding error\n");
goto fail;
}
if (use_pred) {
prev += pix;
pix = prev;
}
dest[i] = pix;
}
if (get_bits_left(&gb) < 0) {
av_log(c->avctx, AV_LOG_ERROR,
"Slice decoding ran out of bits\n");
goto fail;
}
dest += stride;
}
if (get_bits_left(&gb) > 32)
av_log(c->avctx, AV_LOG_WARNING,
"%d bits left after decoding slice\n", get_bits_left(&gb));
}
ff_free_vlc(&vlc);
return 0;
fail:
ff_free_vlc(&vlc);
return AVERROR_INVALIDDATA;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14865 | static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
uint8_t *data, unsigned size, int64_t granule,
int header)
{
OGGStreamContext *oggstream = st->priv_data;
OGGContext *ogg = s->priv_data;
int total_segments = size / 255 + 1;
uint8_t *p = data;
int i, segments, len, flush = 0;
// Handles VFR by flushing page because this frame needs to have a timestamp
// For theora, keyframes also need to have a timestamp to correctly mark
// them as such, otherwise seeking will not work correctly at the very
// least with old libogg versions.
// Do not try to flush header packets though, that will create broken files.
if (st->codec->codec_id == AV_CODEC_ID_THEORA && !header &&
(ogg_granule_to_timestamp(oggstream, granule) >
ogg_granule_to_timestamp(oggstream, oggstream->last_granule) + 1 ||
ogg_key_granule(oggstream, granule))) {
if (oggstream->page.granule != -1)
ogg_buffer_page(s, oggstream);
flush = 1;
}
// avoid a continued page
if (!header && oggstream->page.size > 0 &&
MAX_PAGE_SIZE - oggstream->page.size < size) {
ogg_buffer_page(s, oggstream);
}
for (i = 0; i < total_segments; ) {
OGGPage *page = &oggstream->page;
segments = FFMIN(total_segments - i, 255 - page->segments_count);
if (i && !page->segments_count)
page->flags |= 1; // continued packet
memset(page->segments+page->segments_count, 255, segments - 1);
page->segments_count += segments - 1;
len = FFMIN(size, segments*255);
page->segments[page->segments_count++] = len - (segments-1)*255;
memcpy(page->data+page->size, p, len);
p += len;
size -= len;
i += segments;
page->size += len;
if (i == total_segments)
page->granule = granule;
if (!header) {
AVStream *st = s->streams[page->stream_index];
int64_t start = av_rescale_q(page->start_granule, st->time_base,
AV_TIME_BASE_Q);
int64_t next = av_rescale_q(page->granule, st->time_base,
AV_TIME_BASE_Q);
if (page->segments_count == 255 ||
(ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
(ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
ogg_buffer_page(s, oggstream);
}
}
}
if (flush && oggstream->page.granule != -1)
ogg_buffer_page(s, oggstream);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14872 | void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
{
int time_incr;
int time_div, time_mod;
if(s->pict_type==AV_PICTURE_TYPE_I){
if(!(s->flags&CODEC_FLAG_GLOBAL_HEADER)){
if(s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) //HACK, the reference sw is buggy
mpeg4_encode_visual_object_header(s);
if(s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number==0) //HACK, the reference sw is buggy
mpeg4_encode_vol_header(s, 0, 0);
}
if(!(s->workaround_bugs & FF_BUG_MS))
mpeg4_encode_gop_header(s);
}
s->partitioned_frame= s->data_partitioning && s->pict_type!=AV_PICTURE_TYPE_B;
put_bits(&s->pb, 16, 0); /* vop header */
put_bits(&s->pb, 16, VOP_STARTCODE); /* vop header */
put_bits(&s->pb, 2, s->pict_type - 1); /* pict type: I = 0 , P = 1 */
assert(s->time>=0);
time_div= s->time/s->avctx->time_base.den;
time_mod= s->time%s->avctx->time_base.den;
time_incr= time_div - s->last_time_base;
assert(time_incr >= 0);
while(time_incr--)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 1); /* marker */
put_bits(&s->pb, s->time_increment_bits, time_mod); /* time increment */
put_bits(&s->pb, 1, 1); /* marker */
put_bits(&s->pb, 1, 1); /* vop coded */
if ( s->pict_type == AV_PICTURE_TYPE_P
|| (s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE)) {
put_bits(&s->pb, 1, s->no_rounding); /* rounding type */
}
put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */
if(!s->progressive_sequence){
put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
put_bits(&s->pb, 1, s->alternate_scan);
}
//FIXME sprite stuff
put_bits(&s->pb, 5, s->qscale);
if (s->pict_type != AV_PICTURE_TYPE_I)
put_bits(&s->pb, 3, s->f_code); /* fcode_for */
if (s->pict_type == AV_PICTURE_TYPE_B)
put_bits(&s->pb, 3, s->b_code); /* fcode_back */
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14884 | static void build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table,
int nb_codes)
{
uint8_t huff_size[256];
uint16_t huff_code[256];
memset(huff_size, 0, sizeof(huff_size));
build_huffman_codes(huff_size, huff_code, bits_table, val_table);
init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14904 | void qemu_coroutine_adjust_pool_size(int n)
{
qemu_mutex_lock(&pool_lock);
pool_max_size += n;
/* Callers should never take away more than they added */
assert(pool_max_size >= POOL_DEFAULT_SIZE);
/* Trim oversized pool down to new max */
while (pool_size > pool_max_size) {
Coroutine *co = QSLIST_FIRST(&pool);
QSLIST_REMOVE_HEAD(&pool, pool_next);
pool_size--;
qemu_coroutine_delete(co);
}
qemu_mutex_unlock(&pool_lock);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14911 | static void rndis_clear_responsequeue(USBNetState *s)
{
struct rndis_response *r;
while ((r = s->rndis_resp.tqh_first)) {
TAILQ_REMOVE(&s->rndis_resp, r, entries);
qemu_free(r);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14913 | av_cold void ff_vp56dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec)
{
#if HAVE_YASM
int mm_flags = av_get_cpu_flags();
if (CONFIG_VP6_DECODER && codec == AV_CODEC_ID_VP6) {
#if ARCH_X86_32
if (mm_flags & AV_CPU_FLAG_MMX) {
c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx;
}
#endif
if (mm_flags & AV_CPU_FLAG_SSE2) {
c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
}
}
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14936 | int cpu_ppc_handle_mmu_fault (CPUState *env, uint32_t address, int rw,
int is_user, int is_softmmu)
{
uint32_t physical;
int prot;
int exception = 0, error_code = 0;
int access_type;
int ret = 0;
// printf("%s 0\n", __func__);
access_type = env->access_type;
if (env->user_mode_only) {
/* user mode only emulation */
ret = -2;
goto do_fault;
}
/* NASTY BUG workaround */
if (access_type == ACCESS_CODE && rw) {
printf("%s: ERROR WRITE CODE ACCESS\n", __func__);
access_type = ACCESS_INT;
}
ret = get_physical_address(env, &physical, &prot,
address, rw, access_type);
if (ret == 0) {
ret = tlb_set_page(env, address & ~0xFFF, physical, prot,
is_user, is_softmmu);
} else if (ret < 0) {
do_fault:
#if defined (DEBUG_MMU)
if (loglevel > 0)
cpu_ppc_dump_state(env, logfile, 0);
#endif
if (access_type == ACCESS_CODE) {
exception = EXCP_ISI;
switch (ret) {
case -1:
/* No matches in page tables */
error_code = EXCP_ISI_TRANSLATE;
break;
case -2:
/* Access rights violation */
error_code = EXCP_ISI_PROT;
break;
case -3:
/* No execute protection violation */
error_code = EXCP_ISI_NOEXEC;
break;
case -4:
/* Direct store exception */
/* No code fetch is allowed in direct-store areas */
error_code = EXCP_ISI_DIRECT;
break;
}
} else {
exception = EXCP_DSI;
switch (ret) {
case -1:
/* No matches in page tables */
error_code = EXCP_DSI_TRANSLATE;
break;
case -2:
/* Access rights violation */
error_code = EXCP_DSI_PROT;
break;
case -4:
/* Direct store exception */
switch (access_type) {
case ACCESS_FLOAT:
/* Floating point load/store */
exception = EXCP_ALIGN;
error_code = EXCP_ALIGN_FP;
break;
case ACCESS_RES:
/* lwarx, ldarx or srwcx. */
exception = EXCP_DSI;
error_code = EXCP_DSI_NOTSUP | EXCP_DSI_DIRECT;
break;
case ACCESS_EXT:
/* eciwx or ecowx */
exception = EXCP_DSI;
error_code = EXCP_DSI_NOTSUP | EXCP_DSI_DIRECT |
EXCP_DSI_ECXW;
break;
default:
printf("DSI: invalid exception (%d)\n", ret);
exception = EXCP_PROGRAM;
error_code = EXCP_INVAL | EXCP_INVAL_INVAL;
break;
}
}
if (rw)
error_code |= EXCP_DSI_STORE;
/* Store fault address */
env->spr[DAR] = address;
}
#if 0
printf("%s: set exception to %d %02x\n",
__func__, exception, error_code);
#endif
env->exception_index = exception;
env->error_code = error_code;
ret = 1;
}
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14942 | static void spatial_decompose53i(DWTELEM *buffer, int width, int height, int stride){
int y;
DWTELEM *b0= buffer + mirror(-2-1, height-1)*stride;
DWTELEM *b1= buffer + mirror(-2 , height-1)*stride;
for(y=-2; y<height; y+=2){
DWTELEM *b2= buffer + mirror(y+1, height-1)*stride;
DWTELEM *b3= buffer + mirror(y+2, height-1)*stride;
{START_TIMER
if(b1 <= b3) horizontal_decompose53i(b2, width);
if(y+2 < height) horizontal_decompose53i(b3, width);
STOP_TIMER("horizontal_decompose53i")}
{START_TIMER
if(b1 <= b3) vertical_decompose53iH0(b1, b2, b3, width);
if(b0 <= b2) vertical_decompose53iL0(b0, b1, b2, width);
STOP_TIMER("vertical_decompose53i*")}
b0=b2;
b1=b3;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14951 | static int sd_truncate(BlockDriverState *bs, int64_t offset)
{
BDRVSheepdogState *s = bs->opaque;
int ret, fd;
unsigned int datalen;
if (offset < s->inode.vdi_size) {
error_report("shrinking is not supported");
return -EINVAL;
} else if (offset > SD_MAX_VDI_SIZE) {
error_report("too big image size");
return -EINVAL;
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
return fd;
}
/* we don't need to update entire object */
datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
s->inode.vdi_size = offset;
ret = write_object(fd, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id),
s->inode.nr_copies, datalen, 0, false, s->cache_enabled);
close(fd);
if (ret < 0) {
error_report("failed to update an inode.");
}
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14982 | static int rndis_parse(USBNetState *s, uint8_t *data, int length)
{
uint32_t msg_type;
le32 *tmp = (le32 *) data;
msg_type = le32_to_cpup(tmp);
switch (msg_type) {
case RNDIS_INITIALIZE_MSG:
s->rndis_state = RNDIS_INITIALIZED;
return rndis_init_response(s, (rndis_init_msg_type *) data);
case RNDIS_HALT_MSG:
s->rndis_state = RNDIS_UNINITIALIZED;
return 0;
case RNDIS_QUERY_MSG:
return rndis_query_response(s, (rndis_query_msg_type *) data, length);
case RNDIS_SET_MSG:
return rndis_set_response(s, (rndis_set_msg_type *) data, length);
case RNDIS_RESET_MSG:
rndis_clear_responsequeue(s);
s->out_ptr = s->in_ptr = s->in_len = 0;
return rndis_reset_response(s, (rndis_reset_msg_type *) data);
case RNDIS_KEEPALIVE_MSG:
/* For USB: host does this every 5 seconds */
return rndis_keepalive_response(s, (rndis_keepalive_msg_type *) data);
}
return USB_RET_STALL;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15001 | static int sap_write_header(AVFormatContext *s)
{
struct SAPState *sap = s->priv_data;
char host[1024], path[1024], url[1024], announce_addr[50] = "";
char *option_list;
int port = 9875, base_port = 5004, i, pos = 0, same_port = 0, ttl = 255;
AVFormatContext **contexts = NULL;
int ret = 0;
struct sockaddr_storage localaddr;
socklen_t addrlen = sizeof(localaddr);
int udp_fd;
AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0);
if (!ff_network_init())
return AVERROR(EIO);
/* extract hostname and port */
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &base_port,
path, sizeof(path), s->filename);
if (base_port < 0)
base_port = 5004;
/* search for options */
option_list = strrchr(path, '?');
if (option_list) {
char buf[50];
if (av_find_info_tag(buf, sizeof(buf), "announce_port", option_list)) {
port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "same_port", option_list)) {
same_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", option_list)) {
ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "announce_addr", option_list)) {
av_strlcpy(announce_addr, buf, sizeof(announce_addr));
}
}
if (!announce_addr[0]) {
struct addrinfo hints = { 0 }, *ai = NULL;
hints.ai_family = AF_UNSPEC;
if (getaddrinfo(host, NULL, &hints, &ai)) {
av_log(s, AV_LOG_ERROR, "Unable to resolve %s\n", host);
ret = AVERROR(EIO);
goto fail;
}
if (ai->ai_family == AF_INET) {
/* Also known as sap.mcast.net */
av_strlcpy(announce_addr, "224.2.127.254", sizeof(announce_addr));
#if HAVE_STRUCT_SOCKADDR_IN6
} else if (ai->ai_family == AF_INET6) {
/* With IPv6, you can use the same destination in many different
* multicast subnets, to choose how far you want it routed.
* This one is intended to be routed globally. */
av_strlcpy(announce_addr, "ff0e::2:7ffe", sizeof(announce_addr));
#endif
} else {
freeaddrinfo(ai);
av_log(s, AV_LOG_ERROR, "Host %s resolved to unsupported "
"address family\n", host);
ret = AVERROR(EIO);
goto fail;
}
freeaddrinfo(ai);
}
sap->protocols = ffurl_get_protocols(NULL, NULL);
if (!sap->protocols) {
ret = AVERROR(ENOMEM);
goto fail;
}
contexts = av_mallocz(sizeof(AVFormatContext*) * s->nb_streams);
if (!contexts) {
ret = AVERROR(ENOMEM);
goto fail;
}
s->start_time_realtime = av_gettime();
for (i = 0; i < s->nb_streams; i++) {
URLContext *fd;
ff_url_join(url, sizeof(url), "rtp", NULL, host, base_port,
"?ttl=%d", ttl);
if (!same_port)
base_port += 2;
ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL,
sap->protocols);
if (ret) {
ret = AVERROR(EIO);
goto fail;
}
ret = ff_rtp_chain_mux_open(&contexts[i], s, s->streams[i], fd, 0, i);
if (ret < 0)
goto fail;
s->streams[i]->priv_data = contexts[i];
s->streams[i]->time_base = contexts[i]->streams[0]->time_base;
av_strlcpy(contexts[i]->filename, url, sizeof(contexts[i]->filename));
}
if (s->nb_streams > 0 && title)
av_dict_set(&contexts[0]->metadata, "title", title->value, 0);
ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port,
"?ttl=%d&connect=1", ttl);
ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL, sap->protocols);
if (ret) {
ret = AVERROR(EIO);
goto fail;
}
udp_fd = ffurl_get_file_handle(sap->ann_fd);
if (getsockname(udp_fd, (struct sockaddr*) &localaddr, &addrlen)) {
ret = AVERROR(EIO);
goto fail;
}
if (localaddr.ss_family != AF_INET
#if HAVE_STRUCT_SOCKADDR_IN6
&& localaddr.ss_family != AF_INET6
#endif
) {
av_log(s, AV_LOG_ERROR, "Unsupported protocol family\n");
ret = AVERROR(EIO);
goto fail;
}
sap->ann_size = 8192;
sap->ann = av_mallocz(sap->ann_size);
if (!sap->ann) {
ret = AVERROR(EIO);
goto fail;
}
sap->ann[pos] = (1 << 5);
#if HAVE_STRUCT_SOCKADDR_IN6
if (localaddr.ss_family == AF_INET6)
sap->ann[pos] |= 0x10;
#endif
pos++;
sap->ann[pos++] = 0; /* Authentication length */
AV_WB16(&sap->ann[pos], av_get_random_seed());
pos += 2;
if (localaddr.ss_family == AF_INET) {
memcpy(&sap->ann[pos], &((struct sockaddr_in*)&localaddr)->sin_addr,
sizeof(struct in_addr));
pos += sizeof(struct in_addr);
#if HAVE_STRUCT_SOCKADDR_IN6
} else {
memcpy(&sap->ann[pos], &((struct sockaddr_in6*)&localaddr)->sin6_addr,
sizeof(struct in6_addr));
pos += sizeof(struct in6_addr);
#endif
}
av_strlcpy(&sap->ann[pos], "application/sdp", sap->ann_size - pos);
pos += strlen(&sap->ann[pos]) + 1;
if (av_sdp_create(contexts, s->nb_streams, &sap->ann[pos],
sap->ann_size - pos)) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
av_freep(&contexts);
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", &sap->ann[pos]);
pos += strlen(&sap->ann[pos]);
sap->ann_size = pos;
if (sap->ann_size > sap->ann_fd->max_packet_size) {
av_log(s, AV_LOG_ERROR, "Announcement too large to send in one "
"packet\n");
goto fail;
}
return 0;
fail:
av_free(contexts);
sap_write_close(s);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15002 | static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
int nPbW, int nPbH,
int log2_cb_size, int partIdx, int idx)
{
#define POS(c_idx, x, y) \
&s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
(((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
HEVCLocalContext *lc = s->HEVClc;
int merge_idx = 0;
struct MvField current_mv = {{{ 0 }}};
int min_pu_width = s->sps->min_pu_width;
MvField *tab_mvf = s->ref->tab_mvf;
RefPicList *refPicList = s->ref->refPicList;
HEVCFrame *ref0, *ref1;
uint8_t *dst0 = POS(0, x0, y0);
uint8_t *dst1 = POS(1, x0, y0);
uint8_t *dst2 = POS(2, x0, y0);
int log2_min_cb_size = s->sps->log2_min_cb_size;
int min_cb_width = s->sps->min_cb_width;
int x_cb = x0 >> log2_min_cb_size;
int y_cb = y0 >> log2_min_cb_size;
int x_pu, y_pu;
int i, j;
int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb);
if (!skip_flag)
lc->pu.merge_flag = ff_hevc_merge_flag_decode(s);
if (skip_flag || lc->pu.merge_flag) {
if (s->sh.max_num_merge_cand > 1)
merge_idx = ff_hevc_merge_idx_decode(s);
else
merge_idx = 0;
ff_hevc_luma_mv_merge_mode(s, x0, y0, nPbW, nPbH, log2_cb_size,
partIdx, merge_idx, ¤t_mv);
} else {
hevc_luma_mv_mpv_mode(s, x0, y0, nPbW, nPbH, log2_cb_size,
partIdx, merge_idx, ¤t_mv);
}
x_pu = x0 >> s->sps->log2_min_pu_size;
y_pu = y0 >> s->sps->log2_min_pu_size;
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
if (current_mv.pred_flag & PF_L0) {
ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
if (!ref0)
return;
hevc_await_progress(s, ref0, ¤t_mv.mv[0], y0, nPbH);
}
if (current_mv.pred_flag & PF_L1) {
ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
if (!ref1)
return;
hevc_await_progress(s, ref1, ¤t_mv.mv[1], y0, nPbH);
}
if (current_mv.pred_flag == PF_L0) {
int x0_c = x0 >> s->sps->hshift[1];
int y0_c = y0 >> s->sps->vshift[1];
int nPbW_c = nPbW >> s->sps->hshift[1];
int nPbH_c = nPbH >> s->sps->vshift[1];
luma_mc_uni(s, dst0, s->frame->linesize[0], ref0->frame,
¤t_mv.mv[0], x0, y0, nPbW, nPbH,
s->sh.luma_weight_l0[current_mv.ref_idx[0]],
s->sh.luma_offset_l0[current_mv.ref_idx[0]]);
chroma_mc_uni(s, dst1, s->frame->linesize[1], ref0->frame->data[1], ref0->frame->linesize[1],
0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]);
chroma_mc_uni(s, dst2, s->frame->linesize[2], ref0->frame->data[2], ref0->frame->linesize[2],
0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]);
} else if (current_mv.pred_flag == PF_L1) {
int x0_c = x0 >> s->sps->hshift[1];
int y0_c = y0 >> s->sps->vshift[1];
int nPbW_c = nPbW >> s->sps->hshift[1];
int nPbH_c = nPbH >> s->sps->vshift[1];
luma_mc_uni(s, dst0, s->frame->linesize[0], ref1->frame,
¤t_mv.mv[1], x0, y0, nPbW, nPbH,
s->sh.luma_weight_l1[current_mv.ref_idx[1]],
s->sh.luma_offset_l1[current_mv.ref_idx[1]]);
chroma_mc_uni(s, dst1, s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1],
1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]);
chroma_mc_uni(s, dst2, s->frame->linesize[2], ref1->frame->data[2], ref1->frame->linesize[2],
1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]);
} else if (current_mv.pred_flag == PF_BI) {
int x0_c = x0 >> s->sps->hshift[1];
int y0_c = y0 >> s->sps->vshift[1];
int nPbW_c = nPbW >> s->sps->hshift[1];
int nPbH_c = nPbH >> s->sps->vshift[1];
luma_mc_bi(s, dst0, s->frame->linesize[0], ref0->frame,
¤t_mv.mv[0], x0, y0, nPbW, nPbH,
ref1->frame, ¤t_mv.mv[1], ¤t_mv);
chroma_mc_bi(s, dst1, s->frame->linesize[1], ref0->frame, ref1->frame,
x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
chroma_mc_bi(s, dst2, s->frame->linesize[2], ref0->frame, ref1->frame,
x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15016 | static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
VirtIOBlockReq *req;
MultiReqBuffer mrb = {};
/* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
* dataplane here instead of waiting for .set_status().
*/
if (s->dataplane) {
virtio_blk_data_plane_start(s->dataplane);
return;
}
blk_io_plug(s->blk);
while ((req = virtio_blk_get_request(s))) {
virtio_blk_handle_request(req, &mrb);
}
if (mrb.num_reqs) {
virtio_blk_submit_multireq(s->blk, &mrb);
}
blk_io_unplug(s->blk);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15051 | static void av_noinline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0]];
tc[1] = tc0_table[index_a][bS[1]];
tc[2] = tc0_table[index_a][bS[2]];
tc[3] = tc0_table[index_a][bS[3]];
h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15055 | static void realize(DeviceState *d, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
Object *root_container;
char link_name[256];
gchar *child_name;
Error *err = NULL;
trace_spapr_drc_realize(spapr_drc_index(drc));
/* NOTE: we do this as part of realize/unrealize due to the fact
* that the guest will communicate with the DRC via RTAS calls
* referencing the global DRC index. By unlinking the DRC
* from DRC_CONTAINER_PATH/<drc_index> we effectively make it
* inaccessible by the guest, since lookups rely on this path
* existing in the composition tree
*/
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
snprintf(link_name, sizeof(link_name), "%x", spapr_drc_index(drc));
child_name = object_get_canonical_path_component(OBJECT(drc));
trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
object_property_add_alias(root_container, link_name,
drc->owner, child_name, &err);
g_free(child_name);
if (err) {
error_propagate(errp, err);
return;
}
vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
drc);
qemu_register_reset(drc_reset, drc);
trace_spapr_drc_realize_complete(spapr_drc_index(drc));
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15061 | static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr,
int insn, int size, int sign)
{
TCGv_i32 r_asi, r_size, r_sign;
r_asi = gen_get_asi(dc, insn);
r_size = tcg_const_i32(size);
r_sign = tcg_const_i32(sign);
#ifdef TARGET_SPARC64
gen_helper_ld_asi(dst, cpu_env, addr, r_asi, r_size, r_sign);
#else
{
TCGv_i64 t64 = tcg_temp_new_i64();
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
tcg_gen_trunc_i64_tl(dst, t64);
tcg_temp_free_i64(t64);
}
#endif
tcg_temp_free_i32(r_sign);
tcg_temp_free_i32(r_size);
tcg_temp_free_i32(r_asi);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15066 | static inline float64 ucf64_itod(uint64_t i)
{
union {
uint64_t i;
float64 d;
} v;
v.i = i;
return v.d;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15067 | int tcg_gen_code(TCGContext *s, tcg_insn_unit *gen_code_buf)
{
int i, oi, oi_next, num_insns;
#ifdef CONFIG_PROFILER
{
int n;
n = s->gen_last_op_idx + 1;
s->op_count += n;
if (n > s->op_count_max) {
s->op_count_max = n;
}
n = s->nb_temps;
s->temp_count += n;
if (n > s->temp_count_max) {
s->temp_count_max = n;
}
}
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {
qemu_log("OP:\n");
tcg_dump_ops(s);
qemu_log("\n");
}
#endif
#ifdef CONFIG_PROFILER
s->opt_time -= profile_getclock();
#endif
#ifdef USE_TCG_OPTIMIZATIONS
tcg_optimize(s);
#endif
#ifdef CONFIG_PROFILER
s->opt_time += profile_getclock();
s->la_time -= profile_getclock();
#endif
tcg_liveness_analysis(s);
#ifdef CONFIG_PROFILER
s->la_time += profile_getclock();
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT))) {
qemu_log("OP after optimization and liveness analysis:\n");
tcg_dump_ops(s);
qemu_log("\n");
}
#endif
tcg_reg_alloc_start(s);
s->code_buf = gen_code_buf;
s->code_ptr = gen_code_buf;
tcg_out_tb_init(s);
num_insns = -1;
for (oi = s->gen_first_op_idx; oi >= 0; oi = oi_next) {
TCGOp * const op = &s->gen_op_buf[oi];
TCGArg * const args = &s->gen_opparam_buf[op->args];
TCGOpcode opc = op->opc;
const TCGOpDef *def = &tcg_op_defs[opc];
uint16_t dead_args = s->op_dead_args[oi];
uint8_t sync_args = s->op_sync_args[oi];
oi_next = op->next;
#ifdef CONFIG_PROFILER
tcg_table_op_count[opc]++;
#endif
switch (opc) {
case INDEX_op_mov_i32:
case INDEX_op_mov_i64:
tcg_reg_alloc_mov(s, def, args, dead_args, sync_args);
break;
case INDEX_op_movi_i32:
case INDEX_op_movi_i64:
tcg_reg_alloc_movi(s, args, dead_args, sync_args);
break;
case INDEX_op_insn_start:
if (num_insns >= 0) {
s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);
}
num_insns++;
for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {
target_ulong a;
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
a = ((target_ulong)args[i * 2 + 1] << 32) | args[i * 2];
#else
a = args[i];
#endif
s->gen_insn_data[num_insns][i] = a;
}
break;
case INDEX_op_discard:
temp_dead(s, args[0]);
break;
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(s, s->reserved_regs);
tcg_out_label(s, arg_label(args[0]), s->code_ptr);
break;
case INDEX_op_call:
tcg_reg_alloc_call(s, op->callo, op->calli, args,
dead_args, sync_args);
break;
default:
/* Sanity check that we've not introduced any unhandled opcodes. */
if (def->flags & TCG_OPF_NOT_PRESENT) {
tcg_abort();
}
/* Note: in order to speed up the code, it would be much
faster to have specialized register allocator functions for
some common argument patterns */
tcg_reg_alloc_op(s, def, opc, args, dead_args, sync_args);
break;
}
#ifndef NDEBUG
check_regs(s);
#endif
/* Test for (pending) buffer overflow. The assumption is that any
one operation beginning below the high water mark cannot overrun
the buffer completely. Thus we can test for overflow after
generating code without having to check during generation. */
if (unlikely((void *)s->code_ptr > s->code_gen_highwater)) {
return -1;
}
}
tcg_debug_assert(num_insns >= 0);
s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);
/* Generate TB finalization at the end of block */
tcg_out_tb_finalize(s);
/* flush instruction cache */
flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr);
return tcg_current_code_size(s);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15077 | static int ehci_process_itd(EHCIState *ehci,
EHCIitd *itd)
{
USBPort *port;
USBDevice *dev;
int ret;
uint32_t i, j, len, pid, dir, devaddr, endp;
uint32_t pg, off, ptr1, ptr2, max, mult;
dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT);
mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT);
for(i = 0; i < 8; i++) {
if (itd->transact[i] & ITD_XACT_ACTIVE) {
pg = get_field(itd->transact[i], ITD_XACT_PGSEL);
off = itd->transact[i] & ITD_XACT_OFFSET_MASK;
ptr1 = (itd->bufptr[pg] & ITD_BUFPTR_MASK);
ptr2 = (itd->bufptr[pg+1] & ITD_BUFPTR_MASK);
len = get_field(itd->transact[i], ITD_XACT_LENGTH);
if (len > max * mult) {
len = max * mult;
}
if (len > BUFF_SIZE) {
return USB_RET_PROCERR;
}
qemu_sglist_init(&ehci->isgl, 2);
if (off + len > 4096) {
/* transfer crosses page border */
uint32_t len2 = off + len - 4096;
uint32_t len1 = len - len2;
qemu_sglist_add(&ehci->isgl, ptr1 + off, len1);
qemu_sglist_add(&ehci->isgl, ptr2, len2);
} else {
qemu_sglist_add(&ehci->isgl, ptr1 + off, len);
}
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
usb_packet_setup(&ehci->ipacket, pid, devaddr, endp);
usb_packet_map(&ehci->ipacket, &ehci->isgl);
ret = USB_RET_NODEV;
for (j = 0; j < NB_PORTS; j++) {
port = &ehci->ports[j];
dev = port->dev;
if (!(ehci->portsc[j] &(PORTSC_CONNECT))) {
continue;
}
ret = usb_handle_packet(dev, &ehci->ipacket);
if (ret != USB_RET_NODEV) {
break;
}
}
usb_packet_unmap(&ehci->ipacket);
qemu_sglist_destroy(&ehci->isgl);
#if 0
/* In isoch, there is no facility to indicate a NAK so let's
* instead just complete a zero-byte transaction. Setting
* DBERR seems too draconian.
*/
if (ret == USB_RET_NAK) {
if (ehci->isoch_pause > 0) {
DPRINTF("ISOCH: received a NAK but paused so returning\n");
ehci->isoch_pause--;
return 0;
} else if (ehci->isoch_pause == -1) {
DPRINTF("ISOCH: recv NAK & isoch pause inactive, setting\n");
// Pause frindex for up to 50 msec waiting for data from
// remote
ehci->isoch_pause = 50;
return 0;
} else {
DPRINTF("ISOCH: isoch pause timeout! return 0\n");
ret = 0;
}
} else {
DPRINTF("ISOCH: received ACK, clearing pause\n");
ehci->isoch_pause = -1;
}
#else
if (ret == USB_RET_NAK) {
ret = 0;
}
#endif
if (ret >= 0) {
if (!dir) {
/* OUT */
set_field(&itd->transact[i], len - ret, ITD_XACT_LENGTH);
} else {
/* IN */
set_field(&itd->transact[i], ret, ITD_XACT_LENGTH);
}
if (itd->transact[i] & ITD_XACT_IOC) {
ehci_record_interrupt(ehci, USBSTS_INT);
}
}
itd->transact[i] &= ~ITD_XACT_ACTIVE;
}
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15082 | static void qmp_input_pop(Visitor *v, void **obj)
{
QmpInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && tos->qapi == obj);
QSLIST_REMOVE_HEAD(&qiv->stack, node);
qmp_input_stack_object_free(tos);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15094 | static int vmd_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
VmdDemuxContext *vmd = (VmdDemuxContext *)s->priv_data;
ByteIOContext *pb = &s->pb;
AVStream *st;
unsigned int toc_offset;
unsigned char *raw_frame_table;
int raw_frame_table_size;
offset_t current_offset;
int i, j;
unsigned int total_frames;
int64_t video_pts_inc = 0;
int64_t current_video_pts = 0;
unsigned char chunk[BYTES_PER_FRAME_RECORD];
int lastframe = 0;
/* fetch the main header, including the 2 header length bytes */
url_fseek(pb, 0, SEEK_SET);
if (get_buffer(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
return AVERROR_IO;
vmd->audio_sample_counter = 0;
vmd->audio_frame_divisor = 1;
vmd->audio_block_align = 1;
/* start up the decoders */
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000);
vmd->video_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_VMDVIDEO;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = LE_16(&vmd->vmd_header[12]);
st->codec->height = LE_16(&vmd->vmd_header[14]);
st->codec->time_base.num = 1;
st->codec->time_base.den = 10;
st->codec->extradata_size = VMD_HEADER_SIZE;
st->codec->extradata = av_mallocz(VMD_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(st->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
/* if sample rate is 0, assume no audio */
vmd->sample_rate = LE_16(&vmd->vmd_header[804]);
if (vmd->sample_rate) {
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000);
vmd->audio_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_VMDAUDIO;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->channels = vmd->audio_channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1;
st->codec->sample_rate = vmd->sample_rate;
st->codec->block_align = vmd->audio_block_align =
LE_16(&vmd->vmd_header[806]);
if (st->codec->block_align & 0x8000) {
st->codec->bits_per_sample = 16;
st->codec->block_align = -(st->codec->block_align - 0x10000);
vmd->audio_block_align = -(vmd->audio_block_align - 0x10000);
} else {
st->codec->bits_per_sample = 8;
st->codec->bit_rate = st->codec->sample_rate *
st->codec->bits_per_sample * st->codec->channels;
/* for calculating pts */
vmd->audio_frame_divisor = st->codec->channels;
video_pts_inc = 90000;
video_pts_inc *= st->codec->block_align;
video_pts_inc /= st->codec->sample_rate;
video_pts_inc /= st->codec->channels;
} else {
/* if no audio, assume 10 frames/second */
video_pts_inc = 90000 / 10;
toc_offset = LE_32(&vmd->vmd_header[812]);
vmd->frame_count = LE_16(&vmd->vmd_header[6]);
vmd->frames_per_block = LE_16(&vmd->vmd_header[18]);
url_fseek(pb, toc_offset, SEEK_SET);
raw_frame_table = NULL;
vmd->frame_table = NULL;
raw_frame_table_size = vmd->frame_count * 6;
raw_frame_table = av_malloc(raw_frame_table_size);
vmd->frame_table = av_malloc(vmd->frame_count * vmd->frames_per_block * sizeof(vmd_frame_t));
if (!raw_frame_table || !vmd->frame_table) {
av_free(raw_frame_table);
av_free(vmd->frame_table);
return AVERROR_NOMEM;
if (get_buffer(pb, raw_frame_table, raw_frame_table_size) !=
raw_frame_table_size) {
av_free(raw_frame_table);
av_free(vmd->frame_table);
return AVERROR_IO;
total_frames = 0;
for (i = 0; i < vmd->frame_count; i++) {
current_offset = LE_32(&raw_frame_table[6 * i + 2]);
/* handle each entry in index block */
for (j = 0; j < vmd->frames_per_block; j++) {
int type;
uint32_t size;
get_buffer(pb, chunk, BYTES_PER_FRAME_RECORD);
type = chunk[0];
size = LE_32(&chunk[2]);
if(!size)
continue;
switch(type) {
case 1: /* Audio Chunk */
vmd->frame_table[total_frames].frame_offset = current_offset;
vmd->frame_table[total_frames].stream_index = vmd->audio_stream_index;
vmd->frame_table[total_frames].frame_size = size;
memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD);
total_frames++;
break;
case 2: /* Video Chunk */
vmd->frame_table[total_frames].frame_offset = current_offset;
vmd->frame_table[total_frames].frame_size = size;
vmd->frame_table[total_frames].stream_index = vmd->video_stream_index;
memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD);
vmd->frame_table[total_frames].pts = current_video_pts;
if (lastframe) {
vmd->frame_table[lastframe].pts = current_video_pts - video_pts_inc;
lastframe = total_frames;
total_frames++;
break;
current_offset += size;
current_video_pts += video_pts_inc;
av_free(raw_frame_table);
vmd->current_frame = 0;
vmd->frame_count = total_frames;
return 0;
The vulnerability label is: Vulnerable |
devign_test_set_data_15106 | void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
{
int idct_algo= avctx->idct_algo;
ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_pixels_clamped;
if (avctx->lowres == 0) {
if(idct_algo == FF_IDCT_AUTO){
#if HAVE_IPP
idct_algo = FF_IDCT_IPP;
#elif HAVE_NEON
idct_algo = FF_IDCT_SIMPLENEON;
#elif HAVE_ARMV6
idct_algo = FF_IDCT_SIMPLEARMV6;
#elif HAVE_ARMV5TE
idct_algo = FF_IDCT_SIMPLEARMV5TE;
#else
idct_algo = FF_IDCT_ARM;
#endif
}
if(idct_algo==FF_IDCT_ARM){
c->idct_put= j_rev_dct_ARM_put;
c->idct_add= j_rev_dct_ARM_add;
c->idct = j_rev_dct_ARM;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
} else if (idct_algo==FF_IDCT_SIMPLEARM){
c->idct_put= simple_idct_ARM_put;
c->idct_add= simple_idct_ARM_add;
c->idct = simple_idct_ARM;
c->idct_permutation_type= FF_NO_IDCT_PERM;
#if HAVE_ARMV6
} else if (idct_algo==FF_IDCT_SIMPLEARMV6){
c->idct_put= ff_simple_idct_put_armv6;
c->idct_add= ff_simple_idct_add_armv6;
c->idct = ff_simple_idct_armv6;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
#endif
#if HAVE_ARMV5TE
} else if (idct_algo==FF_IDCT_SIMPLEARMV5TE){
c->idct_put= simple_idct_put_armv5te;
c->idct_add= simple_idct_add_armv5te;
c->idct = simple_idct_armv5te;
c->idct_permutation_type = FF_NO_IDCT_PERM;
#endif
#if HAVE_IPP
} else if (idct_algo==FF_IDCT_IPP){
c->idct_put= simple_idct_ipp_put;
c->idct_add= simple_idct_ipp_add;
c->idct = simple_idct_ipp;
c->idct_permutation_type= FF_NO_IDCT_PERM;
#endif
#if HAVE_NEON
} else if (idct_algo==FF_IDCT_SIMPLENEON){
c->idct_put= ff_simple_idct_put_neon;
c->idct_add= ff_simple_idct_add_neon;
c->idct = ff_simple_idct_neon;
c->idct_permutation_type = FF_PARTTRANS_IDCT_PERM;
} else if ((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER || CONFIG_THEORA_DECODER) &&
idct_algo==FF_IDCT_VP3){
c->idct_put= ff_vp3_idct_put_neon;
c->idct_add= ff_vp3_idct_add_neon;
c->idct = ff_vp3_idct_neon;
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
#endif
}
}
c->put_pixels_tab[0][0] = put_pixels16_arm;
c->put_pixels_tab[0][1] = put_pixels16_x2_arm;
c->put_pixels_tab[0][2] = put_pixels16_y2_arm;
c->put_pixels_tab[0][3] = put_pixels16_xy2_arm;
c->put_no_rnd_pixels_tab[0][0] = put_pixels16_arm;
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_arm;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_arm;
c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_arm;
c->put_pixels_tab[1][0] = put_pixels8_arm;
c->put_pixels_tab[1][1] = put_pixels8_x2_arm;
c->put_pixels_tab[1][2] = put_pixels8_y2_arm;
c->put_pixels_tab[1][3] = put_pixels8_xy2_arm;
c->put_no_rnd_pixels_tab[1][0] = put_pixels8_arm;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_arm;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_arm;
c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_arm;
#if HAVE_ARMV5TE
c->prefetch = ff_prefetch_arm;
#endif
#if HAVE_IWMMXT
dsputil_init_iwmmxt(c, avctx);
#endif
#if HAVE_ARMVFP
ff_float_init_arm_vfp(c, avctx);
#endif
#if HAVE_NEON
ff_dsputil_init_neon(c, avctx);
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15108 | av_cold void ff_h264_free_context(H264Context *h)
{
int i;
ff_h264_free_tables(h);
if (h->DPB) {
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
ff_h264_unref_picture(h, &h->DPB[i]);
av_freep(&h->DPB);
}
h->cur_pic_ptr = NULL;
for (i = 0; i < h->nb_slice_ctx; i++)
av_freep(&h->slice_ctx[i].rbsp_buffer);
av_freep(&h->slice_ctx);
h->nb_slice_ctx = 0;
for (i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
for (i = 0; i < MAX_PPS_COUNT; i++)
av_freep(h->pps_buffers + i);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15115 | bool aio_poll(AioContext *ctx, bool blocking)
{
AioHandler *node;
int i, ret;
bool progress;
int64_t timeout;
aio_context_acquire(ctx);
progress = false;
/* aio_notify can avoid the expensive event_notifier_set if
* everything (file descriptors, bottom halves, timers) will
* be re-evaluated before the next blocking poll(). This is
* already true when aio_poll is called with blocking == false;
* if blocking == true, it is only true after poll() returns,
* so disable the optimization now.
*/
if (blocking) {
atomic_add(&ctx->notify_me, 2);
}
ctx->walking_handlers++;
assert(npfd == 0);
/* fill pollfds */
if (!aio_epoll_enabled(ctx)) {
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->pfd.events
&& aio_node_check(ctx, node->is_external)) {
add_pollfd(node);
}
}
}
timeout = blocking ? aio_compute_timeout(ctx) : 0;
/* wait until next event */
if (timeout) {
aio_context_release(ctx);
}
if (aio_epoll_check_poll(ctx, pollfds, npfd, timeout)) {
AioHandler epoll_handler;
epoll_handler.pfd.fd = ctx->epollfd;
epoll_handler.pfd.events = G_IO_IN | G_IO_OUT | G_IO_HUP | G_IO_ERR;
npfd = 0;
add_pollfd(&epoll_handler);
ret = aio_epoll(ctx, pollfds, npfd, timeout);
} else {
ret = qemu_poll_ns(pollfds, npfd, timeout);
}
if (blocking) {
atomic_sub(&ctx->notify_me, 2);
}
if (timeout) {
aio_context_acquire(ctx);
}
aio_notify_accept(ctx);
/* if we have any readable fds, dispatch event */
if (ret > 0) {
for (i = 0; i < npfd; i++) {
nodes[i]->pfd.revents = pollfds[i].revents;
}
}
npfd = 0;
ctx->walking_handlers--;
/* Run dispatch even if there were no readable fds to run timers */
if (aio_dispatch(ctx, ret > 0)) {
progress = true;
}
aio_context_release(ctx);
return progress;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15124 | int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic)
{
av_assert0(0);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15125 | static int latm_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
PutBitContext bs;
int i, len;
uint8_t loas_header[] = "\x56\xe0\x00";
uint8_t *buf = NULL;
if (s->streams[0]->codec->codec_id == CODEC_ID_AAC_LATM)
return ff_raw_write_packet(s, pkt);
if (pkt->size > 2 && pkt->data[0] == 0xff && (pkt->data[1] >> 4) == 0xf) {
av_log(s, AV_LOG_ERROR, "ADTS header detected - ADTS will not be incorrectly muxed into LATM\n");
return AVERROR_INVALIDDATA;
}
if (pkt->size > 0x1fff)
goto too_large;
buf = av_malloc(pkt->size+1024);
if (!buf)
return AVERROR(ENOMEM);
init_put_bits(&bs, buf, pkt->size+1024);
latm_write_frame_header(s, &bs);
/* PayloadLengthInfo() */
for (i = 0; i <= pkt->size-255; i+=255)
put_bits(&bs, 8, 255);
put_bits(&bs, 8, pkt->size-i);
/* The LATM payload is written unaligned */
/* PayloadMux() */
if (pkt->size && (pkt->data[0] & 0xe1) == 0x81) {
// Convert byte-aligned DSE to non-aligned.
// Due to the input format encoding we know that
// it is naturally byte-aligned in the input stream,
// so there are no padding bits to account for.
// To avoid having to add padding bits and rearrange
// the whole stream we just remove the byte-align flag.
// This allows us to remux our FATE AAC samples into latm
// files that are still playable with minimal effort.
put_bits(&bs, 8, pkt->data[0] & 0xfe);
avpriv_copy_bits(&bs, pkt->data + 1, 8*pkt->size - 8);
} else
avpriv_copy_bits(&bs, pkt->data, 8*pkt->size);
avpriv_align_put_bits(&bs);
flush_put_bits(&bs);
len = put_bits_count(&bs) >> 3;
if (len > 0x1fff)
goto too_large;
loas_header[1] |= (len >> 8) & 0x1f;
loas_header[2] |= len & 0xff;
avio_write(pb, loas_header, 3);
avio_write(pb, buf, len);
av_free(buf);
return 0;
too_large:
av_log(s, AV_LOG_ERROR, "LATM packet size larger than maximum size 0x1fff\n");
av_free(buf);
return AVERROR_INVALIDDATA;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15132 | static void aio_read_done(void *opaque, int ret)
{
struct aio_ctx *ctx = opaque;
struct timeval t2;
gettimeofday(&t2, NULL);
if (ret < 0) {
printf("readv failed: %s\n", strerror(-ret));
goto out;
}
if (ctx->Pflag) {
void *cmp_buf = g_malloc(ctx->qiov.size);
memset(cmp_buf, ctx->pattern, ctx->qiov.size);
if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) {
printf("Pattern verification failed at offset %"
PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size);
}
g_free(cmp_buf);
}
if (ctx->qflag) {
goto out;
}
if (ctx->vflag) {
dump_buffer(ctx->buf, ctx->offset, ctx->qiov.size);
}
/* Finally, report back -- -C gives a parsable format */
t2 = tsub(t2, ctx->t1);
print_report("read", &t2, ctx->offset, ctx->qiov.size,
ctx->qiov.size, 1, ctx->Cflag);
out:
qemu_io_free(ctx->buf);
g_free(ctx);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15133 | static const char *read_ts(const char *buf, int *ts_start, int *ts_end,
int *x1, int *y1, int *x2, int *y2)
{
int i, hs, ms, ss, he, me, se;
for (i=0; i<2; i++) {
/* try to read timestamps in either the first or second line */
int c = sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d"
"%*[ ]X1:%u X2:%u Y1:%u Y2:%u",
&hs, &ms, &ss, ts_start, &he, &me, &se, ts_end,
x1, x2, y1, y2);
buf += strcspn(buf, "\n") + 1;
if (c >= 8) {
*ts_start = 100*(ss + 60*(ms + 60*hs)) + *ts_start/10;
*ts_end = 100*(se + 60*(me + 60*he)) + *ts_end /10;
return buf;
}
}
return NULL;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15136 | target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
{
target_ulong pde_addr, pte_addr;
uint64_t pte;
target_phys_addr_t paddr;
uint32_t page_offset;
int page_size;
if (env->cr[4] & CR4_PAE_MASK) {
target_ulong pdpe_addr;
uint64_t pde, pdpe;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint64_t pml4e_addr, pml4e;
int32_t sext;
/* test virtual address sign extension */
sext = (int64_t)addr >> 47;
if (sext != 0 && sext != -1)
return -1;
pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK))
return -1;
pdpe_addr = ((pml4e & ~0xfff) + (((addr >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK))
return -1;
} else
#endif
{
pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK))
return -1;
}
pde_addr = ((pdpe & ~0xfff) + (((addr >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
return -1;
}
if (pde & PG_PSE_MASK) {
/* 2 MB page */
page_size = 2048 * 1024;
pte = pde & ~( (page_size - 1) & ~0xfff); /* align to page_size */
} else {
/* 4 KB page */
pte_addr = ((pde & ~0xfff) + (((addr >> 12) & 0x1ff) << 3)) &
env->a20_mask;
page_size = 4096;
pte = ldq_phys(pte_addr);
}
if (!(pte & PG_PRESENT_MASK))
return -1;
} else {
uint32_t pde;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
page_size = 4096;
} else {
/* page directory entry */
pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask;
pde = ldl_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK))
return -1;
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
pte = pde & ~0x003ff000; /* align to 4MB */
page_size = 4096 * 1024;
} else {
/* page directory entry */
pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask;
pte = ldl_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK))
return -1;
page_size = 4096;
}
}
pte = pte & env->a20_mask;
}
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
return paddr;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15147 | void spapr_pci_rtas_init(void)
{
spapr_rtas_register("read-pci-config", rtas_read_pci_config);
spapr_rtas_register("write-pci-config", rtas_write_pci_config);
spapr_rtas_register("ibm,read-pci-config", rtas_ibm_read_pci_config);
spapr_rtas_register("ibm,write-pci-config", rtas_ibm_write_pci_config);
if (msi_supported) {
spapr_rtas_register("ibm,query-interrupt-source-number",
rtas_ibm_query_interrupt_source_number);
spapr_rtas_register("ibm,change-msi", rtas_ibm_change_msi);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15173 | static void compare_sec_rs_finalize(SocketReadState *sec_rs)
{
CompareState *s = container_of(sec_rs, CompareState, sec_rs);
if (packet_enqueue(s, SECONDARY_IN)) {
trace_colo_compare_main("secondary: unsupported packet in");
} else {
/* compare connection */
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15201 | FDCtrl *fdctrl_init_isa(DriveInfo **fds)
{
ISADevice *dev;
dev = isa_create("isa-fdc");
if (fds[0]) {
qdev_prop_set_drive_nofail(&dev->qdev, "driveA", fds[0]->bdrv);
}
if (fds[1]) {
qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv);
}
if (qdev_init(&dev->qdev) < 0)
return NULL;
return &(DO_UPCAST(FDCtrlISABus, busdev, dev)->state);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15206 | static int asf_read_picture(AVFormatContext *s, int len)
{
ASFContext *asf = s->priv_data;
AVPacket pkt = { 0 };
const CodecMime *mime = ff_id3v2_mime_tags;
enum AVCodecID id = AV_CODEC_ID_NONE;
char mimetype[64];
uint8_t *desc = NULL;
AVStream *st = NULL;
int ret, type, picsize, desc_len;
ASFStream *asf_st;
/* type + picsize + mime + desc */
if (len < 1 + 4 + 2 + 2) {
av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len);
return AVERROR_INVALIDDATA;
}
/* picture type */
type = avio_r8(s->pb);
len--;
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_WARNING, "Unknown attached picture type: %d.\n", type);
type = 0;
}
/* picture data size */
picsize = avio_rl32(s->pb);
len -= 4;
/* picture MIME type */
len -= avio_get_str16le(s->pb, len, mimetype, sizeof(mimetype));
while (mime->id != AV_CODEC_ID_NONE) {
if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
id = mime->id;
break;
}
mime++;
}
if (id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
return 0;
}
if (picsize >= len) {
av_log(s, AV_LOG_ERROR, "Invalid attached picture data size: %d >= %d.\n",
picsize, len);
return AVERROR_INVALIDDATA;
}
/* picture description */
desc_len = (len - picsize) * 2 + 1;
desc = av_malloc(desc_len);
if (!desc)
return AVERROR(ENOMEM);
len -= avio_get_str16le(s->pb, len - picsize, desc, desc_len);
ret = av_get_packet(s->pb, &pkt, picsize);
if (ret < 0)
goto fail;
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));
asf_st = asf->asf_st[asf->nb_streams];
if (!asf_st)
return AVERROR(ENOMEM);
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = asf_st->type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->attached_pic = pkt;
st->attached_pic.stream_index = asf_st->index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
asf->nb_streams++;
if (*desc) {
if (av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
} else
av_freep(&desc);
if (av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
return 0;
fail:
av_freep(&desc);
av_free_packet(&pkt);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15209 | void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome)
{
const ARMCPRegInfo *ri = rip;
switch (ri->accessfn(env, ri)) {
case CP_ACCESS_OK:
case CP_ACCESS_TRAP:
break;
case CP_ACCESS_TRAP_UNCATEGORIZED:
env->exception.syndrome = syn_uncategorized();
break;
default:
g_assert_not_reached();
The vulnerability label is: Vulnerable |
devign_test_set_data_15239 | static char *scsibus_get_dev_path(DeviceState *dev)
{
SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev);
DeviceState *hba = dev->parent_bus->parent;
char *id = NULL;
if (hba && hba->parent_bus && hba->parent_bus->info->get_dev_path) {
id = hba->parent_bus->info->get_dev_path(hba);
}
if (id) {
return g_strdup_printf("%s/%d:%d:%d", id, d->channel, d->id, d->lun);
} else {
return g_strdup_printf("%d:%d:%d", d->channel, d->id, d->lun);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15249 | static int eval_lpc_coeffs(const float *in, float *tgt, int n)
{
int x, y;
double f0, f1, f2;
if (in[n] == 0)
return 0;
if ((f0 = *in) <= 0)
return 0;
in--; // To avoid a -1 subtraction in the inner loop
for (x=1; x <= n; x++) {
f1 = in[x+1];
for (y=0; y < x - 1; y++)
f1 += in[x-y]*tgt[y];
tgt[x-1] = f2 = -f1/f0;
for (y=0; y < x >> 1; y++) {
float temp = tgt[y] + tgt[x-y-2]*f2;
tgt[x-y-2] += tgt[y]*f2;
tgt[y] = temp;
}
if ((f0 += f1*f2) < 0)
return 0;
}
return 1;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15252 | int swr_init(struct SwrContext *s){
s->in_buffer_index= 0;
s->in_buffer_count= 0;
s->resample_in_constraint= 0;
free_temp(&s->postin);
free_temp(&s->midbuf);
free_temp(&s->preout);
free_temp(&s->in_buffer);
free_temp(&s->dither);
swri_audio_convert_free(&s-> in_convert);
swri_audio_convert_free(&s->out_convert);
swri_audio_convert_free(&s->full_convert);
swri_rematrix_free(s);
s->flushed = 0;
if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
return AVERROR(EINVAL);
}
if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested output sample format %d is invalid\n", s->out_sample_fmt);
return AVERROR(EINVAL);
}
//FIXME should we allow/support using FLT on material that doesnt need it ?
if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P || s->int_sample_fmt==AV_SAMPLE_FMT_S16P){
s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
}else
s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&&s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, S16/S32/FLT is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
return AVERROR(EINVAL);
}
set_audiodata_fmt(&s-> in, s-> in_sample_fmt);
set_audiodata_fmt(&s->out, s->out_sample_fmt);
if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
s->resample = swri_resample_init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt);
}else
swri_resample_free(&s->resample);
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P
&& s->int_sample_fmt != AV_SAMPLE_FMT_S32P
&& s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
&& s->resample){
av_log(s, AV_LOG_ERROR, "Resampling only supported with internal s16/s32/flt\n");
return -1;
}
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){
av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n");
s-> in_ch_layout= 0;
}
if(!s-> in_ch_layout)
s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count);
if(!s->out_ch_layout)
s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);
s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 ||
s->rematrix_custom;
#define RSC 1 //FIXME finetune
if(!s-> in.ch_count)
s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(!s->out.ch_count)
s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
if(!s-> in.ch_count){
av_assert0(!s->in_ch_layout);
av_log(s, AV_LOG_ERROR, "Input channel count and layout are unset\n");
return -1;
}
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
av_log(s, AV_LOG_ERROR, "Rematrix is needed but there is not enough information to do it\n");
return -1;
}
av_assert0(s->used_ch_count);
av_assert0(s->out.ch_count);
s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s->in_buffer= s->in;
if(!s->resample && !s->rematrix && !s->channel_map && !s->dither_method){
s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
return 0;
}
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
s->int_sample_fmt, s->out.ch_count, NULL, 0);
s->postin= s->in;
s->preout= s->out;
s->midbuf= s->in;
if(s->channel_map){
s->postin.ch_count=
s->midbuf.ch_count= s->used_ch_count;
if(s->resample)
s->in_buffer.ch_count= s->used_ch_count;
}
if(!s->resample_first){
s->midbuf.ch_count= s->out.ch_count;
if(s->resample)
s->in_buffer.ch_count = s->out.ch_count;
}
set_audiodata_fmt(&s->postin, s->int_sample_fmt);
set_audiodata_fmt(&s->midbuf, s->int_sample_fmt);
set_audiodata_fmt(&s->preout, s->int_sample_fmt);
if(s->resample){
set_audiodata_fmt(&s->in_buffer, s->int_sample_fmt);
}
s->dither = s->preout;
if(s->rematrix || s->dither_method)
return swri_rematrix_init(s);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15260 | void pc_hot_add_cpu(const int64_t id, Error **errp)
{
DeviceState *icc_bridge;
int64_t apic_id = x86_cpu_apic_id_from_index(id);
if (cpu_exists(apic_id)) {
error_setg(errp, "Unable to add CPU: %" PRIi64
", it already exists", id);
if (id >= max_cpus) {
error_setg(errp, "Unable to add CPU: %" PRIi64
", max allowed: %d", id, max_cpus - 1);
icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
TYPE_ICC_BRIDGE, NULL));
pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
The vulnerability label is: Vulnerable |
devign_test_set_data_15288 | static void xlnx_ep108_init(MachineState *machine)
{
XlnxEP108 *s = g_new0(XlnxEP108, 1);
Error *err = NULL;
object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
&error_abort);
object_property_set_bool(OBJECT(&s->soc), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
if (machine->ram_size > EP108_MAX_RAM_SIZE) {
error_report("WARNING: RAM size " RAM_ADDR_FMT " above max supported, "
"reduced to %llx", machine->ram_size, EP108_MAX_RAM_SIZE);
machine->ram_size = EP108_MAX_RAM_SIZE;
}
if (machine->ram_size <= 0x08000000) {
qemu_log("WARNING: RAM size " RAM_ADDR_FMT " is small for EP108",
machine->ram_size);
}
memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram",
machine->ram_size);
memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram);
xlnx_ep108_binfo.ram_size = machine->ram_size;
xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
xlnx_ep108_binfo.initrd_filename = machine->initrd_filename;
xlnx_ep108_binfo.loader_start = 0;
arm_load_kernel(s->soc.boot_cpu_ptr, &xlnx_ep108_binfo);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15290 | static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs,
AVFilterInOut **open_outputs, AVClass *log_ctx)
{
int pad = 0;
while (**buf == '[') {
char *name = parse_link_name(buf, log_ctx);
AVFilterInOut *match;
if (!name)
return AVERROR(EINVAL);
/* First check if the label is not in the open_outputs list */
match = extract_inout(name, open_outputs);
if (match) {
av_free(name);
} else {
/* Not in the list, so add it as an input */
match = av_mallocz(sizeof(AVFilterInOut));
match->name = name;
match->pad_idx = pad;
}
insert_inout(curr_inputs, match);
*buf += strspn(*buf, WHITESPACES);
pad++;
}
return pad;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15301 | void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1, uint8_t *dst2,
ThreadFrame *ref, const VP56mv *mv, int x_off, int y_off,
int block_w, int block_h, int width, int height, int linesize,
vp8_mc_func mc_func[3][3])
{
uint8_t *src1 = ref->f->data[1], *src2 = ref->f->data[2];
if (AV_RN32A(mv)) {
int mx = mv->x&7, mx_idx = subpel_idx[0][mx];
int my = mv->y&7, my_idx = subpel_idx[0][my];
x_off += mv->x >> 3;
y_off += mv->y >> 3;
// edge emulation
src1 += y_off * linesize + x_off;
src2 += y_off * linesize + x_off;
ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 3, 0);
if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
s->vdsp.emulated_edge_mc(td->edge_emu_buffer, src1 - my_idx * linesize - mx_idx, linesize,
block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
x_off - mx_idx, y_off - my_idx, width, height);
src1 = td->edge_emu_buffer + mx_idx + linesize * my_idx;
mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
s->vdsp.emulated_edge_mc(td->edge_emu_buffer, src2 - my_idx * linesize - mx_idx, linesize,
block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
x_off - mx_idx, y_off - my_idx, width, height);
src2 = td->edge_emu_buffer + mx_idx + linesize * my_idx;
mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
} else {
mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
}
} else {
ff_thread_await_progress(ref, (3 + y_off + block_h) >> 3, 0);
mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15321 | static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,
int width, int height)
{
int src_wrap, x, y;
int r, g, b;
uint8_t *lum, *cb, *cr;
const uint8_t *p;
lum = dst->data[0];
cb = dst->data[1];
cr = dst->data[2];
src_wrap = src->linesize[0] - width * BPP;
p = src->data[0];
for(y=0;y<height;y++) {
for(x=0;x<width;x++) {
RGB_IN(r, g, b, p);
lum[0] = RGB_TO_Y_CCIR(r, g, b);
cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
cb++;
cr++;
lum++;
}
p += src_wrap;
lum += dst->linesize[0] - width;
cb += dst->linesize[1] - width;
cr += dst->linesize[2] - width;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15341 | static char *pcibus_get_fw_dev_path(DeviceState *dev)
{
PCIDevice *d = (PCIDevice *)dev;
char path[50], name[33];
int off;
off = snprintf(path, sizeof(path), "%s@%x",
pci_dev_fw_name(dev, name, sizeof name),
PCI_SLOT(d->devfn));
if (PCI_FUNC(d->devfn))
snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
return strdup(path);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_15368 | static int qio_channel_websock_handshake_send_response(QIOChannelWebsock *ioc,
const char *key,
Error **errp)
{
char combined_key[QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN + 1];
char *accept = NULL, *response = NULL;
size_t responselen;
g_strlcpy(combined_key, key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1);
g_strlcat(combined_key, QIO_CHANNEL_WEBSOCK_GUID,
QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN + 1);
/* hash and encode it */
if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,
combined_key,
QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN,
&accept,
errp) < 0) {
return -1;
}
response = g_strdup_printf(QIO_CHANNEL_WEBSOCK_HANDSHAKE_RESPONSE, accept);
responselen = strlen(response);
buffer_reserve(&ioc->encoutput, responselen);
buffer_append(&ioc->encoutput, response, responselen);
g_free(accept);
g_free(response);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15373 | void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
int dst_x, int dst_y, int w, int h)
{
DisplayState *s = con->ds;
DisplayChangeListener *dcl;
if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
if (con != (dcl->con ? dcl->con : active_console)) {
continue;
}
if (dcl->ops->dpy_gfx_copy) {
dcl->ops->dpy_gfx_copy(dcl, src_x, src_y, dst_x, dst_y, w, h);
} else { /* TODO */
dcl->ops->dpy_gfx_update(dcl, dst_x, dst_y, w, h);
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_15388 | static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
TCGArg *args, TCGOpDef *tcg_op_defs)
{
int i, nb_ops, op_index, nb_temps, nb_globals, nb_call_args;
TCGOpcode op;
const TCGOpDef *def;
TCGArg *gen_args;
TCGArg tmp;
TCGCond cond;
/* Array VALS has an element for each temp.
If this temp holds a constant then its value is kept in VALS' element.
If this temp is a copy of other ones then the other copies are
available through the doubly linked circular list. */
nb_temps = s->nb_temps;
nb_globals = s->nb_globals;
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
nb_ops = tcg_opc_ptr - gen_opc_buf;
gen_args = args;
for (op_index = 0; op_index < nb_ops; op_index++) {
op = gen_opc_buf[op_index];
def = &tcg_op_defs[op];
/* Do copy propagation */
if (op == INDEX_op_call) {
int nb_oargs = args[0] >> 16;
int nb_iargs = args[0] & 0xffff;
for (i = nb_oargs + 1; i < nb_oargs + nb_iargs + 1; i++) {
if (temps[args[i]].state == TCG_TEMP_COPY) {
args[i] = find_better_copy(s, args[i]);
} else {
for (i = def->nb_oargs; i < def->nb_oargs + def->nb_iargs; i++) {
if (temps[args[i]].state == TCG_TEMP_COPY) {
args[i] = find_better_copy(s, args[i]);
/* For commutative operations make constant second argument */
CASE_OP_32_64(add):
CASE_OP_32_64(mul):
CASE_OP_32_64(and):
CASE_OP_32_64(or):
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
if (temps[args[1]].state == TCG_TEMP_CONST) {
tmp = args[1];
args[1] = args[2];
args[2] = tmp;
CASE_OP_32_64(brcond):
if (temps[args[0]].state == TCG_TEMP_CONST
&& temps[args[1]].state != TCG_TEMP_CONST) {
tmp = args[0];
args[0] = args[1];
args[1] = tmp;
args[2] = tcg_swap_cond(args[2]);
CASE_OP_32_64(setcond):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state != TCG_TEMP_CONST) {
tmp = args[1];
args[1] = args[2];
args[2] = tmp;
args[3] = tcg_swap_cond(args[3]);
CASE_OP_32_64(movcond):
cond = args[5];
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state != TCG_TEMP_CONST) {
tmp = args[1];
args[1] = args[2];
args[2] = tmp;
cond = tcg_swap_cond(cond);
/* For movcond, we canonicalize the "false" input reg to match
the destination reg so that the tcg backend can implement
a "move if true" operation. */
if (args[0] == args[3]) {
tmp = args[3];
args[3] = args[4];
args[4] = tmp;
cond = tcg_invert_cond(cond);
args[5] = cond;
/* Simplify expressions for "shift/rot r, 0, a => movi r, 0" */
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[1]].val == 0) {
/* Simplify expression for "op r, a, 0 => mov r, a" cases */
CASE_OP_32_64(add):
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
CASE_OP_32_64(or):
if (temps[args[1]].state == TCG_TEMP_CONST) {
/* Proceed with possible constant folding. */
if (temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0) {
if (temps_are_copies(args[0], args[1])) {
gen_opc_buf[op_index] = INDEX_op_nop;
} else {
gen_opc_buf[op_index] = op_to_mov(op);
tcg_opt_gen_mov(s, gen_args, args[0], args[1]);
/* Simplify expression for "op r, a, 0 => movi r, 0" cases */
CASE_OP_32_64(and):
CASE_OP_32_64(mul):
if ((temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0)) {
/* Simplify expression for "op r, a, a => mov r, a" cases */
CASE_OP_32_64(or):
CASE_OP_32_64(and):
if (temps_are_copies(args[0], args[1])) {
gen_opc_buf[op_index] = INDEX_op_nop;
} else {
gen_opc_buf[op_index] = op_to_mov(op);
tcg_opt_gen_mov(s, gen_args, args[0], args[1]);
/* Propagate constants through copy operations and do constant
folding. Constants will be substituted to arguments by register
allocator where needed and possible. Also detect copies. */
CASE_OP_32_64(mov):
if (temps_are_copies(args[0], args[1])) {
args += 2;
gen_opc_buf[op_index] = INDEX_op_nop;
if (temps[args[1]].state != TCG_TEMP_CONST) {
tcg_opt_gen_mov(s, gen_args, args[0], args[1]);
args += 2;
/* Source argument is constant. Rewrite the operation and
let movi case handle it. */
op = op_to_movi(op);
gen_opc_buf[op_index] = op;
args[1] = temps[args[1]].val;
/* fallthrough */
CASE_OP_32_64(movi):
tcg_opt_gen_movi(gen_args, args[0], args[1]);
args += 2;
CASE_OP_32_64(not):
CASE_OP_32_64(neg):
CASE_OP_32_64(ext8s):
CASE_OP_32_64(ext8u):
CASE_OP_32_64(ext16s):
CASE_OP_32_64(ext16u):
case INDEX_op_ext32s_i64:
case INDEX_op_ext32u_i64:
if (temps[args[1]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding(op, temps[args[1]].val, 0);
tcg_opt_gen_movi(gen_args, args[0], tmp);
} else {
reset_temp(args[0]);
gen_args[0] = args[0];
gen_args[1] = args[1];
args += 2;
CASE_OP_32_64(add):
CASE_OP_32_64(mul):
CASE_OP_32_64(or):
CASE_OP_32_64(and):
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
CASE_OP_32_64(andc):
CASE_OP_32_64(orc):
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding(op, temps[args[1]].val,
temps[args[2]].val);
tcg_opt_gen_movi(gen_args, args[0], tmp);
} else {
reset_temp(args[0]);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args += 3;
CASE_OP_32_64(setcond):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding_cond(op, temps[args[1]].val,
temps[args[2]].val, args[3]);
tcg_opt_gen_movi(gen_args, args[0], tmp);
} else {
reset_temp(args[0]);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args[3] = args[3];
gen_args += 4;
args += 4;
CASE_OP_32_64(brcond):
if (temps[args[0]].state == TCG_TEMP_CONST
&& temps[args[1]].state == TCG_TEMP_CONST) {
if (do_constant_folding_cond(op, temps[args[0]].val,
temps[args[1]].val, args[2])) {
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
gen_opc_buf[op_index] = INDEX_op_br;
gen_args[0] = args[3];
gen_args += 1;
} else {
gen_opc_buf[op_index] = INDEX_op_nop;
} else {
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
reset_temp(args[0]);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args[3] = args[3];
gen_args += 4;
args += 4;
CASE_OP_32_64(movcond):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding_cond(op, temps[args[1]].val,
temps[args[2]].val, args[5]);
if (temps_are_copies(args[0], args[4-tmp])) {
gen_opc_buf[op_index] = INDEX_op_nop;
} else if (temps[args[4-tmp]].state == TCG_TEMP_CONST) {
tcg_opt_gen_movi(gen_args, args[0], temps[args[4-tmp]].val);
} else {
gen_opc_buf[op_index] = op_to_mov(op);
tcg_opt_gen_mov(s, gen_args, args[0], args[4-tmp]);
} else {
reset_temp(args[0]);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args[3] = args[3];
gen_args[4] = args[4];
gen_args[5] = args[5];
gen_args += 6;
args += 6;
case INDEX_op_call:
nb_call_args = (args[0] >> 16) + (args[0] & 0xffff);
if (!(args[nb_call_args + 1] & (TCG_CALL_CONST | TCG_CALL_PURE))) {
for (i = 0; i < nb_globals; i++) {
reset_temp(i);
for (i = 0; i < (args[0] >> 16); i++) {
reset_temp(args[i + 1]);
i = nb_call_args + 3;
while (i) {
*gen_args = *args;
args++;
gen_args++;
i--;
/* Default case: we do know nothing about operation so no
propagation is done. We trash everything if the operation
is the end of a basic block, otherwise we only trash the
output args. */
if (def->flags & TCG_OPF_BB_END) {
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
} else {
for (i = 0; i < def->nb_oargs; i++) {
reset_temp(args[i]);
for (i = 0; i < def->nb_args; i++) {
gen_args[i] = args[i];
args += def->nb_args;
gen_args += def->nb_args;
return gen_args;
The vulnerability label is: Vulnerable |
devign_test_set_data_15389 | static void vnc_connect(VncDisplay *vd, int csock,
bool skipauth, bool websocket)
{
VncState *vs = g_malloc0(sizeof(VncState));
int i;
vs->csock = csock;
vs->vd = vd;
if (skipauth) {
vs->auth = VNC_AUTH_NONE;
vs->subauth = VNC_AUTH_INVALID;
} else {
if (websocket) {
vs->auth = vd->ws_auth;
vs->subauth = VNC_AUTH_INVALID;
} else {
vs->auth = vd->auth;
vs->subauth = vd->subauth;
}
}
VNC_DEBUG("Client sock=%d ws=%d auth=%d subauth=%d\n",
csock, websocket, vs->auth, vs->subauth);
vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
for (i = 0; i < VNC_STAT_ROWS; ++i) {
vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));
}
VNC_DEBUG("New client on socket %d\n", csock);
update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);
qemu_set_nonblock(vs->csock);
if (websocket) {
vs->websocket = 1;
if (vd->ws_tls) {
qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs);
} else {
qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs);
}
} else
{
qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs);
}
vnc_client_cache_addr(vs);
vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED);
vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING);
if (!vs->websocket) {
vnc_init_state(vs);
}
if (vd->num_connecting > vd->connections_limit) {
QTAILQ_FOREACH(vs, &vd->clients, next) {
if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) {
vnc_disconnect_start(vs);
return;
}
}
}
}
The vulnerability label is: Vulnerable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.