id stringlengths 22 26 | content stringlengths 72 142k |
|---|---|
devign_test_set_data_3184 | uint32_t HELPER(shr_cc)(CPUM68KState *env, uint32_t val, uint32_t shift)
{
uint64_t temp;
uint32_t result;
shift &= 63;
temp = (uint64_t)val << 32 >> shift;
result = temp >> 32;
env->cc_c = (temp >> 31) & 1;
env->cc_n = result;
env->cc_z = result;
env->cc_v = 0;
env->cc_x = shift ? env->cc_c : env->cc_x;
return result;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3205 | 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) {
strcpy(term_cmd_buf, term_history[term_hist_entry]);
} else {
term_hist_entry = -1;
}
term_printf("\n");
term_print_cmdline(term_cmd_buf);
term_cmd_buf_index = term_cmd_buf_size = strlen(term_cmd_buf);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3211 | static int decode_cabac_mb_cbp_luma( H264Context *h) {
int cbp_b, cbp_a, ctx, cbp = 0;
cbp_a = h->slice_table[h->left_mb_xy[0]] == h->slice_num ? h->left_cbp : -1;
cbp_b = h->slice_table[h->top_mb_xy] == h->slice_num ? h->top_cbp : -1;
ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04);
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]);
ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08);
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1;
ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01);
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2;
ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02);
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3;
return cbp;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3227 | void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)
{
QSVFrame *cur;
AVPacket pkt;
int ret = 0;
mfxVideoParam param = { { 0 } };
if (q->reinit_pending) {
close_decoder(q);
} else if (q->engine_ready) {
ret = MFXVideoDECODE_GetVideoParam(q->session, ¶m);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "MFX decode get param error %d\n", ret);
}
ret = MFXVideoDECODE_Reset(q->session, ¶m);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "MFX decode reset error %d\n", ret);
}
/* Free all frames*/
cur = q->work_frames;
while (cur) {
q->work_frames = cur->next;
av_frame_free(&cur->frame);
av_freep(&cur);
cur = q->work_frames;
}
}
/* Reset output surfaces */
av_fifo_reset(q->async_fifo);
/* Reset input packets fifo */
while (av_fifo_size(q->pkt_fifo)) {
av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);
av_packet_unref(&pkt);
}
/* Reset input bitstream fifo */
av_fifo_reset(q->input_fifo);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3228 | target_ulong helper_sdiv(target_ulong a, target_ulong b)
{
int64_t x0;
int32_t x1;
x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32);
x1 = (b & 0xffffffff);
if (x1 == 0) {
raise_exception(TT_DIV_ZERO);
}
x0 = x0 / x1;
if ((int32_t) x0 != x0) {
env->cc_src2 = 1;
return x0 < 0? 0x80000000: 0x7fffffff;
} else {
env->cc_src2 = 0;
return x0;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3236 | static void xhci_reset(DeviceState *dev)
{
XHCIState *xhci = XHCI(dev);
int i;
trace_usb_xhci_reset();
if (!(xhci->usbsts & USBSTS_HCH)) {
DPRINTF("xhci: reset while running!\n");
}
xhci->usbcmd = 0;
xhci->usbsts = USBSTS_HCH;
xhci->dnctrl = 0;
xhci->crcr_low = 0;
xhci->crcr_high = 0;
xhci->dcbaap_low = 0;
xhci->dcbaap_high = 0;
xhci->config = 0;
for (i = 0; i < xhci->numslots; i++) {
xhci_disable_slot(xhci, i+1);
}
for (i = 0; i < xhci->numports; i++) {
xhci_port_update(xhci->ports + i, 0);
}
for (i = 0; i < xhci->numintrs; i++) {
xhci->intr[i].iman = 0;
xhci->intr[i].imod = 0;
xhci->intr[i].erstsz = 0;
xhci->intr[i].erstba_low = 0;
xhci->intr[i].erstba_high = 0;
xhci->intr[i].erdp_low = 0;
xhci->intr[i].erdp_high = 0;
xhci->intr[i].msix_used = 0;
xhci->intr[i].er_ep_idx = 0;
xhci->intr[i].er_pcs = 1;
xhci->intr[i].er_full = 0;
xhci->intr[i].ev_buffer_put = 0;
xhci->intr[i].ev_buffer_get = 0;
}
xhci->mfindex_start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
xhci_mfwrap_update(xhci);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3237 | int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def)
{
int i, ret;
ret = -1;
*def = NULL;
for (i = 0; ppc_defs[i].name != NULL; i++) {
if ((pvr & ppc_defs[i].pvr_mask) ==
(ppc_defs[i].pvr & ppc_defs[i].pvr_mask)) {
*def = &ppc_defs[i];
ret = 0;
break;
}
}
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3256 | void helper_tlb_update(uint32_t T0)
{
#if !defined(CONFIG_USER_ONLY)
uint32_t vaddr;
uint32_t srs = env->pregs[PR_SRS];
if (srs != 1 && srs != 2)
return;
vaddr = cris_mmu_tlb_latest_update(env, T0);
D(printf("flush old_vaddr=%x vaddr=%x T0=%x\n", vaddr,
env->sregs[SFR_R_MM_CAUSE] & TARGET_PAGE_MASK, T0));
tlb_flush_page(env, vaddr);
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3266 | static void patch_pcihp(int slot, uint8_t *ssdt_ptr, uint32_t eject)
{
ssdt_ptr[ACPI_PCIHP_OFFSET_HEX] = acpi_get_hex(slot >> 4);
ssdt_ptr[ACPI_PCIHP_OFFSET_HEX + 1] = acpi_get_hex(slot);
ssdt_ptr[ACPI_PCIHP_OFFSET_ID] = slot;
ssdt_ptr[ACPI_PCIHP_OFFSET_ADR + 2] = slot;
/* Runtime patching of ACPI_EJ0: to disable hotplug for a slot,
* replace the method name: _EJ0 by ACPI_EJ0_.
*/
/* Sanity check */
assert(!memcmp(ssdt_ptr + ACPI_PCIHP_OFFSET_EJ0, "_EJ0", 4));
if (!eject) {
memcpy(ssdt_ptr + ACPI_PCIHP_OFFSET_EJ0, "EJ0_", 4);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3274 | static float ssim_plane(uint8_t *main, int main_stride,
uint8_t *ref, int ref_stride,
int width, int height, void *temp)
{
int z = 0;
int x, y;
float ssim = 0.0;
int (*sum0)[4] = temp;
int (*sum1)[4] = sum0 + (width >> 2) + 3;
width >>= 2;
height >>= 2;
for (y = 1; y < height; y++) {
for (; z <= y; z++) {
FFSWAP(void*, sum0, sum1);
for (x = 0; x < width; x+=2)
ssim_4x4x2_core(&main[4 * (x + z * main_stride)], main_stride,
&ref[4 * (x + z * ref_stride)], ref_stride,
&sum0[x]);
}
ssim += ssim_endn(sum0, sum1, width - 1);
}
return ssim / ((height - 1) * (width - 1));
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3278 | static void nvme_instance_init(Object *obj)
{
object_property_add(obj, "bootindex", "int32",
nvme_get_bootindex,
nvme_set_bootindex, NULL, NULL, NULL);
object_property_set_int(obj, -1, "bootindex", NULL);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3279 | static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVBlkverifyState *s = bs->opaque;
QemuOpts *opts;
Error *local_err = NULL;
int ret;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
/* Open the raw file */
bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw",
bs, &child_file, false, &local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
/* Open the test file */
s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
"test", bs, &child_format, false,
&local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
ret = 0;
fail:
qemu_opts_del(opts);
return ret;
The vulnerability label is: Vulnerable |
devign_test_set_data_3288 | static void tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi,
int s_bits, int tlb_offset)
{
TCGReg base = TCG_AREG0;
/* Should generate something like the following:
* pre-v7:
* shr tmp, addr_reg, #TARGET_PAGE_BITS (1)
* add r2, env, #off & 0xff00
* and r0, tmp, #(CPU_TLB_SIZE - 1) (2)
* add r2, r2, r0, lsl #CPU_TLB_ENTRY_BITS (3)
* ldr r0, [r2, #off & 0xff]! (4)
* tst addr_reg, #s_mask
* cmpeq r0, tmp, lsl #TARGET_PAGE_BITS (5)
*
* v7 (not implemented yet):
* ubfx r2, addr_reg, #TARGET_PAGE_BITS, #CPU_TLB_BITS (1)
* movw tmp, #~TARGET_PAGE_MASK & ~s_mask
* movw r0, #off
* add r2, env, r2, lsl #CPU_TLB_ENTRY_BITS (2)
* bic tmp, addr_reg, tmp
* ldr r0, [r2, r0]! (3)
* cmp r0, tmp (4)
*/
# if CPU_TLB_BITS > 8
# error
# endif
tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP,
0, addrlo, SHIFT_IMM_LSR(TARGET_PAGE_BITS));
/* We assume that the offset is contained within 16 bits. */
assert((tlb_offset & ~0xffff) == 0);
if (tlb_offset > 0xff) {
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R2, base,
(24 << 7) | (tlb_offset >> 8));
tlb_offset &= 0xff;
base = TCG_REG_R2;
}
tcg_out_dat_imm(s, COND_AL, ARITH_AND,
TCG_REG_R0, TCG_REG_TMP, CPU_TLB_SIZE - 1);
tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R2, base,
TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS));
/* Load the tlb comparator. Use ldrd if needed and available,
but due to how the pointer needs setting up, ldm isn't useful.
Base arm5 doesn't have ldrd, but armv5te does. */
if (use_armv6_instructions && TARGET_LONG_BITS == 64) {
tcg_out_memop_8(s, COND_AL, INSN_LDRD_IMM, TCG_REG_R0,
TCG_REG_R2, tlb_offset, 1, 1);
} else {
tcg_out_memop_12(s, COND_AL, INSN_LDR_IMM, TCG_REG_R0,
TCG_REG_R2, tlb_offset, 1, 1);
if (TARGET_LONG_BITS == 64) {
tcg_out_memop_12(s, COND_AL, INSN_LDR_IMM, TCG_REG_R1,
TCG_REG_R2, 4, 1, 0);
}
}
/* Check alignment. */
if (s_bits) {
tcg_out_dat_imm(s, COND_AL, ARITH_TST,
0, addrlo, (1 << s_bits) - 1);
}
tcg_out_dat_reg(s, (s_bits ? COND_EQ : COND_AL), ARITH_CMP, 0,
TCG_REG_R0, TCG_REG_TMP, SHIFT_IMM_LSL(TARGET_PAGE_BITS));
if (TARGET_LONG_BITS == 64) {
tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0,
TCG_REG_R1, addrhi, SHIFT_IMM_LSL(0));
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3290 | static void qdm2_decode_super_block(QDM2Context *q)
{
GetBitContext gb;
QDM2SubPacket header, *packet;
int i, packet_bytes, sub_packet_size, sub_packets_D;
unsigned int next_index = 0;
memset(q->tone_level_idx_hi1, 0, sizeof(q->tone_level_idx_hi1));
memset(q->tone_level_idx_mid, 0, sizeof(q->tone_level_idx_mid));
memset(q->tone_level_idx_hi2, 0, sizeof(q->tone_level_idx_hi2));
q->sub_packets_B = 0;
sub_packets_D = 0;
average_quantized_coeffs(q); // average elements in quantized_coeffs[max_ch][10][8]
init_get_bits(&gb, q->compressed_data, q->compressed_size * 8);
qdm2_decode_sub_packet_header(&gb, &header);
if (header.type < 2 || header.type >= 8) {
q->has_errors = 1;
av_log(NULL, AV_LOG_ERROR, "bad superblock type\n");
return;
}
q->superblocktype_2_3 = (header.type == 2 || header.type == 3);
packet_bytes = (q->compressed_size - get_bits_count(&gb) / 8);
init_get_bits(&gb, header.data, header.size * 8);
if (header.type == 2 || header.type == 4 || header.type == 5) {
int csum = 257 * get_bits(&gb, 8);
csum += 2 * get_bits(&gb, 8);
csum = qdm2_packet_checksum(q->compressed_data, q->checksum_size, csum);
if (csum != 0) {
q->has_errors = 1;
av_log(NULL, AV_LOG_ERROR, "bad packet checksum\n");
return;
}
}
q->sub_packet_list_B[0].packet = NULL;
q->sub_packet_list_D[0].packet = NULL;
for (i = 0; i < 6; i++)
if (--q->fft_level_exp[i] < 0)
q->fft_level_exp[i] = 0;
for (i = 0; packet_bytes > 0; i++) {
int j;
if (i >= FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
SAMPLES_NEEDED_2("too many packet bytes");
return;
}
q->sub_packet_list_A[i].next = NULL;
if (i > 0) {
q->sub_packet_list_A[i - 1].next = &q->sub_packet_list_A[i];
/* seek to next block */
init_get_bits(&gb, header.data, header.size * 8);
skip_bits(&gb, next_index * 8);
if (next_index >= header.size)
break;
}
/* decode subpacket */
packet = &q->sub_packets[i];
qdm2_decode_sub_packet_header(&gb, packet);
next_index = packet->size + get_bits_count(&gb) / 8;
sub_packet_size = ((packet->size > 0xff) ? 1 : 0) + packet->size + 2;
if (packet->type == 0)
break;
if (sub_packet_size > packet_bytes) {
if (packet->type != 10 && packet->type != 11 && packet->type != 12)
break;
packet->size += packet_bytes - sub_packet_size;
}
packet_bytes -= sub_packet_size;
/* add subpacket to 'all subpackets' list */
q->sub_packet_list_A[i].packet = packet;
/* add subpacket to related list */
if (packet->type == 8) {
SAMPLES_NEEDED_2("packet type 8");
return;
} else if (packet->type >= 9 && packet->type <= 12) {
/* packets for MPEG Audio like Synthesis Filter */
QDM2_LIST_ADD(q->sub_packet_list_D, sub_packets_D, packet);
} else if (packet->type == 13) {
for (j = 0; j < 6; j++)
q->fft_level_exp[j] = get_bits(&gb, 6);
} else if (packet->type == 14) {
for (j = 0; j < 6; j++)
q->fft_level_exp[j] = qdm2_get_vlc(&gb, &fft_level_exp_vlc, 0, 2);
} else if (packet->type == 15) {
SAMPLES_NEEDED_2("packet type 15")
return;
} else if (packet->type >= 16 && packet->type < 48 &&
!fft_subpackets[packet->type - 16]) {
/* packets for FFT */
QDM2_LIST_ADD(q->sub_packet_list_B, q->sub_packets_B, packet);
}
} // Packet bytes loop
if (q->sub_packet_list_D[0].packet != NULL) {
process_synthesis_subpackets(q, q->sub_packet_list_D);
q->do_synth_filter = 1;
} else if (q->do_synth_filter) {
process_subpacket_10(q, NULL);
process_subpacket_11(q, NULL);
process_subpacket_12(q, NULL);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3293 | static void hScale8To15_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src,
const int16_t *filter, const int16_t *filterPos,
int filterSize)
{
int i;
for (i=0; i<dstW; i++) {
int j;
int srcPos= filterPos[i];
int val=0;
for (j=0; j<filterSize; j++) {
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
//filter += hFilterSize;
dst[i] = FFMIN(val>>7, (1<<15)-1); // the cubic equation does overflow ...
//dst[i] = val>>7;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3320 | MigrationState *migrate_get_current(void)
{
static MigrationState current_migration = {
.state = MIG_STATE_NONE,
.bandwidth_limit = MAX_THROTTLE,
.xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
.mbps = -1,
};
return ¤t_migration;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3322 | qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
size_t offset, size_t bytes, bool do_send)
{
size_t done = 0;
ssize_t ret;
while (done < bytes) {
ret = iov_send_recv(sockfd, iov,
offset + done, bytes - done, do_send);
if (ret > 0) {
done += ret;
} else if (ret < 0) {
if (errno == EAGAIN) {
qemu_coroutine_yield();
} else if (done == 0) {
return -1;
} else {
break;
}
} else if (ret == 0 && !do_send) {
/* write (send) should never return 0.
* read (recv) returns 0 for end-of-file (-data).
* In both cases there's little point retrying,
* but we do for write anyway, just in case */
break;
}
}
return done;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3327 | static int qcow2_change_backing_file(BlockDriverState *bs,
const char *backing_file, const char *backing_fmt)
{
return qcow2_update_ext_header(bs, backing_file, backing_fmt);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3330 | static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = beta_table[qp - qp_bd_offset + 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]]+1;
tc[1] = tc0_table[index_a][bS[1]]+1;
tc[2] = tc0_table[index_a][bS[2]]+1;
tc[3] = tc0_table[index_a][bS[3]]+1;
h->h264dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3333 | static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
const char *boot_device,
DisplayState *ds, const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env, *envs[MAX_CPUS];
unsigned int i;
void *iounits[MAX_IOUNITS], *espdma, *ledma, *main_esp, *nvram, *sbi;
qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq,
*espdma_irq, *ledma_irq;
qemu_irq *esp_reset, *le_reset;
ram_addr_t ram_offset, prom_offset, tcx_offset;
unsigned long kernel_size;
int ret;
char buf[1024];
int drive_index;
void *fw_cfg;
/* init CPUs */
if (!cpu_model)
cpu_model = hwdef->default_cpu_model;
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
exit(1);
}
cpu_sparc_set_id(env, i);
envs[i] = env;
if (i == 0) {
qemu_register_reset(main_cpu_reset, env);
} else {
qemu_register_reset(secondary_cpu_reset, env);
env->halted = 1;
}
cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
env->prom_addr = hwdef->slavio_base;
}
for (i = smp_cpus; i < MAX_CPUS; i++)
cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
/* allocate RAM */
if ((uint64_t)RAM_size > hwdef->max_mem) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d, maximum %d\n",
(unsigned int)(RAM_size / (1024 * 1024)),
(unsigned int)(hwdef->max_mem / (1024 * 1024)));
exit(1);
}
ram_offset = qemu_ram_alloc(RAM_size);
cpu_register_physical_memory(0, RAM_size, ram_offset);
/* load boot prom */
prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
cpu_register_physical_memory(hwdef->slavio_base,
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
TARGET_PAGE_MASK,
prom_offset | IO_MEM_ROM);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
if (ret < 0 || ret > PROM_SIZE_MAX) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
exit(1);
}
/* set up devices */
sbi = sbi_init(hwdef->sbi_base, &sbi_irq, &sbi_cpu_irq, cpu_irqs);
for (i = 0; i < MAX_IOUNITS; i++)
if (hwdef->iounit_bases[i] != (target_phys_addr_t)-1)
iounits[i] = iommu_init(hwdef->iounit_bases[i],
hwdef->iounit_version,
sbi_irq[hwdef->me_irq]);
espdma = sparc32_dma_init(hwdef->espdma_base, sbi_irq[hwdef->esp_irq],
iounits[0], &espdma_irq, &esp_reset);
ledma = sparc32_dma_init(hwdef->ledma_base, sbi_irq[hwdef->le_irq],
iounits[0], &ledma_irq, &le_reset);
if (graphic_depth != 8 && graphic_depth != 24) {
fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
exit (1);
}
tcx_offset = qemu_ram_alloc(hwdef->vram_size);
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
if (nd_table[0].model == NULL)
nd_table[0].model = "lance";
if (strcmp(nd_table[0].model, "lance") == 0) {
lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
} else if (strcmp(nd_table[0].model, "?") == 0) {
fprintf(stderr, "qemu: Supported NICs: lance\n");
exit (1);
} else {
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
exit (1);
}
nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 8);
slavio_timer_init_all(hwdef->counter_base, sbi_irq[hwdef->clock1_irq],
sbi_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[hwdef->ms_kb_irq],
nographic, ESCC_CLOCK, 1);
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
escc_init(hwdef->serial_base, sbi_irq[hwdef->ser_irq], serial_hds[1],
serial_hds[0], ESCC_CLOCK, 1);
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
main_esp = esp_init(hwdef->esp_base, 2,
espdma_memory_read, espdma_memory_write,
espdma, *espdma_irq, esp_reset);
for (i = 0; i < ESP_MAX_DEVS; i++) {
drive_index = drive_get_index(IF_SCSI, 0, i);
if (drive_index == -1)
continue;
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
}
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
RAM_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
boot_device, RAM_size, kernel_size, graphic_width,
graphic_height, graphic_depth, hwdef->nvram_machine_id,
"Sun4d");
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3348 | static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested)
{
int num_cq_events = 0, ret = 0;
struct ibv_cq *cq;
void *cq_ctx;
uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
if (ibv_req_notify_cq(rdma->cq, 0)) {
return -1;
}
/* poll cq first */
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in);
if (ret < 0) {
return ret;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("A Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested),
wrid_requested, print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
return 0;
}
while (1) {
/*
* Coroutine doesn't start until process_incoming_migration()
* so don't yield unless we know we're running inside of a coroutine.
*/
if (rdma->migration_started_on_destination) {
yield_until_fd_readable(rdma->comp_channel->fd);
}
if (ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx)) {
perror("ibv_get_cq_event");
goto err_block_for_wrid;
}
num_cq_events++;
if (ibv_req_notify_cq(cq, 0)) {
goto err_block_for_wrid;
}
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in);
if (ret < 0) {
goto err_block_for_wrid;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("B Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested), wrid_requested,
print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
goto success_block_for_wrid;
}
}
success_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return 0;
err_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3375 | static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint16_t *end;
const uint16_t *mm_end;
uint8_t *d = dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
__asm__ volatile("pxor %%mm7,%%mm7 \n\t":::"memory");
__asm__ volatile("pcmpeqd %%mm6,%%mm6 \n\t":::"memory");
mm_end = end - 3;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $2, %%mm1 \n\t"
"psrlq $7, %%mm2 \n\t"
PACK_RGB32
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r)
:"memory");
d += 16;
s += 4;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x7C00)>>7;
*d++ = 255;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3392 | static int mux_chr_can_read(void *opaque)
{
CharDriverState *chr = opaque;
MuxDriver *d = chr->opaque;
if ((d->prod - d->cons) < MUX_BUFFER_SIZE)
return 1;
if (d->chr_can_read[chr->focus])
return d->chr_can_read[chr->focus](d->ext_opaque[chr->focus]);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3394 | static inline bool vtd_queued_inv_enable_check(IntelIOMMUState *s)
{
return s->iq_tail == 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3397 | static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth,
const uint8_t *src_in[4],
int srcW, int xInc, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
uint8_t *formatConvBuffer, uint32_t *pal)
{
const uint8_t *src1 = src_in[1], *src2 = src_in[2];
if (c->chrToYV12) {
uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * FFALIGN(c->srcBpc, 8) >> 3, 16);
c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= buf2;
} else if (c->readChrPlanar) {
uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * FFALIGN(c->srcBpc, 8) >> 3, 16);
c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW);
src1= formatConvBuffer;
src2= buf2;
}
if (!c->hcscale_fast) {
c->hcScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hcScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize);
} else { // fast bilinear upscale / crap downscale
c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc);
}
if (c->chrConvertRange)
c->chrConvertRange(dst1, dst2, dstWidth);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3398 | static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
{
BlockDriverState *bs = child->bs;
/* Perform I/O through a temporary buffer so that users who scribble over
* their read buffer while the operation is in progress do not end up
* modifying the image file. This is critical for zero-copy guest I/O
* where anything might happen inside guest memory.
*/
void *bounce_buffer;
BlockDriver *drv = bs->drv;
struct iovec iov;
QEMUIOVector local_qiov;
int64_t cluster_offset;
int64_t cluster_bytes;
size_t skip_bytes;
int ret;
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
BDRV_REQUEST_MAX_BYTES);
unsigned int progress = 0;
/* FIXME We cannot require callers to have write permissions when all they
* are doing is a read request. If we did things right, write permissions
* would be obtained anyway, but internally by the copy-on-read code. As
* long as it is implemented here rather than in a separate filter driver,
* the copy-on-read code doesn't have its own BdrvChild, however, for which
* it could request permissions. Therefore we have to bypass the permission
* system for the moment. */
// assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
/* Cover entire cluster so no additional backing file I/O is required when
* allocating cluster in the image file. Note that this value may exceed
* BDRV_REQUEST_MAX_BYTES (even when the original read did not), which
* is one reason we loop rather than doing it all at once.
*/
bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes);
skip_bytes = offset - cluster_offset;
trace_bdrv_co_do_copy_on_readv(bs, offset, bytes,
cluster_offset, cluster_bytes);
bounce_buffer = qemu_try_blockalign(bs,
MIN(MIN(max_transfer, cluster_bytes),
MAX_BOUNCE_BUFFER));
if (bounce_buffer == NULL) {
ret = -ENOMEM;
goto err;
while (cluster_bytes) {
int64_t pnum;
ret = bdrv_is_allocated(bs, cluster_offset,
MIN(cluster_bytes, max_transfer), &pnum);
if (ret < 0) {
/* Safe to treat errors in querying allocation as if
* unallocated; we'll probably fail again soon on the
* read, but at least that will set a decent errno.
*/
pnum = MIN(cluster_bytes, max_transfer);
assert(skip_bytes < pnum);
if (ret <= 0) {
/* Must copy-on-read; use the bounce buffer */
iov.iov_base = bounce_buffer;
iov.iov_len = pnum = MIN(pnum, MAX_BOUNCE_BUFFER);
qemu_iovec_init_external(&local_qiov, &iov, 1);
ret = bdrv_driver_preadv(bs, cluster_offset, pnum,
&local_qiov, 0);
if (ret < 0) {
goto err;
bdrv_debug_event(bs, BLKDBG_COR_WRITE);
if (drv->bdrv_co_pwrite_zeroes &&
buffer_is_zero(bounce_buffer, pnum)) {
/* FIXME: Should we (perhaps conditionally) be setting
* BDRV_REQ_MAY_UNMAP, if it will allow for a sparser copy
* that still correctly reads as zero? */
ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, pnum, 0);
} else {
/* This does not change the data on the disk, it is not
* necessary to flush even in cache=writethrough mode.
*/
ret = bdrv_driver_pwritev(bs, cluster_offset, pnum,
&local_qiov, 0);
if (ret < 0) {
/* It might be okay to ignore write errors for guest
* requests. If this is a deliberate copy-on-read
* then we don't want to ignore the error. Simply
* report it in all cases.
*/
goto err;
qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_bytes,
pnum - skip_bytes);
} else {
/* Read directly into the destination */
qemu_iovec_init(&local_qiov, qiov->niov);
qemu_iovec_concat(&local_qiov, qiov, progress, pnum - skip_bytes);
ret = bdrv_driver_preadv(bs, offset + progress, local_qiov.size,
&local_qiov, 0);
qemu_iovec_destroy(&local_qiov);
if (ret < 0) {
goto err;
cluster_offset += pnum;
cluster_bytes -= pnum;
progress += pnum - skip_bytes;
skip_bytes = 0;
ret = 0;
err:
qemu_vfree(bounce_buffer);
return ret;
The vulnerability label is: Vulnerable |
devign_test_set_data_3399 | static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp)
{
virtio_scsi_common_unrealize(dev, errp);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3401 | static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
{
char buf[1024];
VncShareMode mode;
int size;
mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;
switch (vs->vd->share_policy) {
case VNC_SHARE_POLICY_IGNORE:
/*
* Ignore the shared flag. Nothing to do here.
*
* Doesn't conform to the rfb spec but is traditional qemu
* behavior, thus left here as option for compatibility
* reasons.
*/
break;
case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:
/*
* Policy: Allow clients ask for exclusive access.
*
* Implementation: When a client asks for exclusive access,
* disconnect all others. Shared connects are allowed as long
* as no exclusive connection exists.
*
* This is how the rfb spec suggests to handle the shared flag.
*/
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
VncState *client;
QTAILQ_FOREACH(client, &vs->vd->clients, next) {
if (vs == client) {
continue;
}
if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&
client->share_mode != VNC_SHARE_MODE_SHARED) {
continue;
}
vnc_disconnect_start(client);
}
}
if (mode == VNC_SHARE_MODE_SHARED) {
if (vs->vd->num_exclusive > 0) {
vnc_disconnect_start(vs);
return 0;
}
}
break;
case VNC_SHARE_POLICY_FORCE_SHARED:
/*
* Policy: Shared connects only.
* Implementation: Disallow clients asking for exclusive access.
*
* Useful for shared desktop sessions where you don't want
* someone forgetting to say -shared when running the vnc
* client disconnect everybody else.
*/
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
vnc_disconnect_start(vs);
return 0;
}
break;
}
vnc_set_share_mode(vs, mode);
vs->client_width = surface_width(vs->vd->ds);
vs->client_height = surface_height(vs->vd->ds);
vnc_write_u16(vs, vs->client_width);
vnc_write_u16(vs, vs->client_height);
pixel_format_message(vs);
if (qemu_name)
size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
else
size = snprintf(buf, sizeof(buf), "QEMU");
vnc_write_u32(vs, size);
vnc_write(vs, buf, size);
vnc_flush(vs);
vnc_client_cache_auth(vs);
vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED);
vnc_read_when(vs, protocol_client_msg, 1);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3416 | static void avc_luma_hv_qrt_and_aver_dst_4x4_msa(const uint8_t *src_x,
const uint8_t *src_y,
int32_t src_stride,
uint8_t *dst,
int32_t dst_stride)
{
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16u8 dst0, dst1, dst2, dst3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, vert_out0, vert_out1;
v8i16 res0, res1;
v16u8 res;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
src_y += (5 * src_stride);
src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1);
src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2);
src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3);
src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3);
LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0, src_hz1,
mask0, mask1, mask2);
hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2, src_hz3,
mask0, mask1, mask2);
SRARI_H2_SH(hz_out0, hz_out1, 5);
SAT_SH2_SH(hz_out0, hz_out1, 7);
LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8);
src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5);
src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6);
src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7);
src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
/* filter calc */
vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1, src_vt2,
src_vt3, src_vt4, src_vt5);
vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3, src_vt4,
src_vt5, src_vt6, src_vt7);
SRARI_H2_SH(vert_out0, vert_out1, 5);
SAT_SH2_SH(vert_out0, vert_out1, 7);
res1 = __msa_srari_h((hz_out1 + vert_out1), 1);
res0 = __msa_srari_h((hz_out0 + vert_out0), 1);
SAT_SH2_SH(res0, res1, 7);
res = PCKEV_XORI128_UB(res0, res1);
dst0 = (v16u8) __msa_insve_w((v4i32) dst0, 1, (v4i32) dst1);
dst1 = (v16u8) __msa_insve_w((v4i32) dst2, 1, (v4i32) dst3);
dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
dst0 = __msa_aver_u_b(res, dst0);
ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dst, dst_stride);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3440 | static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVRawState *s = bs->opaque;
return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
cb, opaque, QEMU_AIO_READ);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3449 | static void tcx_blit_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
uint32_t adsr, len;
int i;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
adsr = val & 0xffffff;
len = ((val >> 24) & 0x1f) + 1;
if (adsr == 0xffffff) {
memset(&s->vram[addr], s->tmpblit, len);
if (s->depth == 24) {
val = s->tmpblit & 0xffffff;
val = cpu_to_be32(val);
for (i = 0; i < len; i++) {
s->vram24[addr + i] = val;
}
}
} else {
memcpy(&s->vram[addr], &s->vram[adsr], len);
if (s->depth == 24) {
memcpy(&s->vram24[addr], &s->vram24[adsr], len * 4);
}
}
memory_region_set_dirty(&s->vram_mem, addr, len);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3452 | static void avc_loopfilter_cb_or_cr_intra_edge_ver_msa(uint8_t *data_cb_or_cr,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
uint16_t out0, out1, out2, out3;
v8i16 tmp1;
v16u8 alpha, beta, is_less_than;
v8i16 p0_or_q0, q0_or_p0;
v16u8 p1_or_q1_org, p0_or_q0_org, q0_or_p0_org, q1_or_p1_org;
v16i8 zero = { 0 };
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than_alpha, is_less_than_beta;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
{
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
LOAD_8VECS_UB((data_cb_or_cr - 2), img_width,
row0, row1, row2, row3, row4, row5, row6, row7);
TRANSPOSE8x4_B_UB(row0, row1, row2, row3, row4, row5, row6, row7,
p1_or_q1_org, p0_or_q0_org,
q0_or_p0_org, q1_or_p1_org);
}
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
p0_asub_q0 = __msa_asub_u_b(p0_or_q0_org, q0_or_p0_org);
p1_asub_p0 = __msa_asub_u_b(p1_or_q1_org, p0_or_q0_org);
q1_asub_q0 = __msa_asub_u_b(q1_or_p1_org, q0_or_p0_org);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_or_q1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_or_q0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_or_p0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_or_p1_org);
AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_or_q0);
AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_or_p0);
/* convert 16 bit output into 8 bit output */
p0_or_q0 = (v8i16) __msa_pckev_b(zero, (v16i8) p0_or_q0);
q0_or_p0 = (v8i16) __msa_pckev_b(zero, (v16i8) q0_or_p0);
p0_or_q0_org =
__msa_bmnz_v(p0_or_q0_org, (v16u8) p0_or_q0, is_less_than);
q0_or_p0_org =
__msa_bmnz_v(q0_or_p0_org, (v16u8) q0_or_p0, is_less_than);
tmp1 = (v8i16) __msa_ilvr_b((v16i8) q0_or_p0_org, (v16i8) p0_or_q0_org);
data_cb_or_cr -= 1;
out0 = __msa_copy_u_h(tmp1, 0);
out1 = __msa_copy_u_h(tmp1, 1);
out2 = __msa_copy_u_h(tmp1, 2);
out3 = __msa_copy_u_h(tmp1, 3);
STORE_HWORD(data_cb_or_cr, out0);
data_cb_or_cr += img_width;
STORE_HWORD(data_cb_or_cr, out1);
data_cb_or_cr += img_width;
STORE_HWORD(data_cb_or_cr, out2);
data_cb_or_cr += img_width;
STORE_HWORD(data_cb_or_cr, out3);
data_cb_or_cr += img_width;
out0 = __msa_copy_u_h(tmp1, 4);
out1 = __msa_copy_u_h(tmp1, 5);
out2 = __msa_copy_u_h(tmp1, 6);
out3 = __msa_copy_u_h(tmp1, 7);
STORE_HWORD(data_cb_or_cr, out0);
data_cb_or_cr += img_width;
STORE_HWORD(data_cb_or_cr, out1);
data_cb_or_cr += img_width;
STORE_HWORD(data_cb_or_cr, out2);
data_cb_or_cr += img_width;
STORE_HWORD(data_cb_or_cr, out3);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3456 | int ff_h261_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq, int flags)
{
int sbit, ebit, gobn, mbap, quant;
int res;
//av_log(ctx, AV_LOG_DEBUG, "got h261 RTP packet with time: %u\n", timestamp);
/* drop data of previous packets in case of non-continuous (loss) packet stream */
if (data->buf && data->timestamp != *timestamp) {
h261_free_dyn_buffer(&data->buf);
}
/* sanity check for size of input packet */
if (len < 5 /* 4 bytes header and 1 byte payload at least */) {
av_log(ctx, AV_LOG_ERROR, "Too short H.261 RTP packet\n");
return AVERROR_INVALIDDATA;
}
/*
decode the H.261 payload header according to section 4.1 of RFC 4587:
(uses 4 bytes between RTP header and H.261 stream per packet)
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|SBIT |EBIT |I|V| GOBN | MBAP | QUANT | HMVD | VMVD |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Start bit position (SBIT): 3 bits
End bit position (EBIT): 3 bits
INTRA-frame encoded data (I): 1 bit
Motion Vector flag (V): 1 bit
GOB number (GOBN): 4 bits
Macroblock address predictor (MBAP): 5 bits
Quantizer (QUANT): 5 bits
Horizontal motion vector data (HMVD): 5 bits
Vertical motion vector data (VMVD): 5 bits
*/
sbit = (buf[0] >> 5) & 0x07;
ebit = (buf[0] >> 2) & 0x07;
gobn = (buf[1] >> 4) & 0x0f;
mbap = ((buf[1] << 1) & 0x1e) | ((buf[1] >> 7) & 0x01);
quant = (buf[1] >> 4) & 0x0f;
/* pass the H.261 payload header and continue with the actual payload */
buf += RTP_H261_PAYLOAD_HEADER_SIZE;
len -= RTP_H261_PAYLOAD_HEADER_SIZE;
/* start frame buffering with new dynamic buffer */
if (!data->buf) {
/* sanity check: a new frame starts with gobn=0, sbit=0, mbap=0, uqnat=0 */
if (!gobn && !sbit && !mbap && !quant){
res = avio_open_dyn_buf(&data->buf);
if (res < 0)
return res;
/* update the timestamp in the frame packet with the one from the RTP packet */
data->timestamp = *timestamp;
} else {
/* frame not started yet, need more packets */
return AVERROR(EAGAIN);
}
}
/* do the "byte merging" at the boundaries of two consecutive frame fragments */
if (data->endbyte_bits || sbit) {
if (data->endbyte_bits == sbit) {
data->endbyte |= buf[0] & (0xff >> sbit);
data->endbyte_bits = 0;
buf++;
len--;
avio_w8(data->buf, data->endbyte);
} else {
/* ebit/sbit values inconsistent, assuming packet loss */
GetBitContext gb;
init_get_bits(&gb, buf, len*8 - ebit);
skip_bits(&gb, sbit);
if (data->endbyte_bits) {
data->endbyte |= get_bits(&gb, 8 - data->endbyte_bits);
avio_w8(data->buf, data->endbyte);
}
while (get_bits_left(&gb) >= 8)
avio_w8(data->buf, get_bits(&gb, 8));
data->endbyte_bits = get_bits_left(&gb);
if (data->endbyte_bits)
data->endbyte = get_bits(&gb, data->endbyte_bits) <<
(8 - data->endbyte_bits);
ebit = 0;
len = 0;
}
}
if (ebit) {
if (len > 0)
avio_write(data->buf, buf, len - 1);
data->endbyte_bits = 8 - ebit;
data->endbyte = buf[len - 1] & (0xff << ebit);
} else {
avio_write(data->buf, buf, len);
}
/* RTP marker bit means: last fragment of current frame was received;
otherwise, an additional fragment is needed for the current frame */
if (!(flags & RTP_FLAG_MARKER))
return AVERROR(EAGAIN);
/* write the completed last byte from the "byte merging" */
if (data->endbyte_bits)
avio_w8(data->buf, data->endbyte);
data->endbyte_bits = 0;
/* close frame buffering and create resulting A/V packet */
res = ff_rtp_finalize_packet(pkt, &data->buf, st->index);
if (res < 0)
return res;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3460 | static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
MpegEncContext * const s = avctx->priv_data;
Picture *pic = s->current_picture_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
VdpPictureInfoMPEG1Or2 *info = &pic_ctx->info.mpeg;
VdpVideoSurface ref;
int i;
/* fill VdpPictureInfoMPEG1Or2 struct */
info->forward_reference = VDP_INVALID_HANDLE;
info->backward_reference = VDP_INVALID_HANDLE;
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
ref = ff_vdpau_get_surface_id(&s->next_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->backward_reference = ref;
/* fall through to forward prediction */
case AV_PICTURE_TYPE_P:
ref = ff_vdpau_get_surface_id(&s->last_picture.f);
info->forward_reference = ref;
}
info->slice_count = 0;
info->picture_structure = s->picture_structure;
info->picture_coding_type = s->pict_type;
info->intra_dc_precision = s->intra_dc_precision;
info->frame_pred_frame_dct = s->frame_pred_frame_dct;
info->concealment_motion_vectors = s->concealment_motion_vectors;
info->intra_vlc_format = s->intra_vlc_format;
info->alternate_scan = s->alternate_scan;
info->q_scale_type = s->q_scale_type;
info->top_field_first = s->top_field_first;
// Both for MPEG-1 only, zero for MPEG-2:
info->full_pel_forward_vector = s->full_pel[0];
info->full_pel_backward_vector = s->full_pel[1];
// For MPEG-1 fill both horizontal & vertical:
info->f_code[0][0] = s->mpeg_f_code[0][0];
info->f_code[0][1] = s->mpeg_f_code[0][1];
info->f_code[1][0] = s->mpeg_f_code[1][0];
info->f_code[1][1] = s->mpeg_f_code[1][1];
for (i = 0; i < 64; ++i) {
info->intra_quantizer_matrix[i] = s->intra_matrix[i];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
}
return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3476 | void h263_decode_init_vlc(MpegEncContext *s)
{
static int done = 0;
if (!done) {
done = 1;
init_vlc(&intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
intra_MCBPC_bits, 1, 1,
intra_MCBPC_code, 1, 1);
init_vlc(&inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
inter_MCBPC_bits, 1, 1,
inter_MCBPC_code, 1, 1);
init_vlc(&cbpy_vlc, CBPY_VLC_BITS, 16,
&cbpy_tab[0][1], 2, 1,
&cbpy_tab[0][0], 2, 1);
init_vlc(&mv_vlc, MV_VLC_BITS, 33,
&mvtab[0][1], 2, 1,
&mvtab[0][0], 2, 1);
init_rl(&rl_inter);
init_rl(&rl_intra);
init_rl(&rvlc_rl_inter);
init_rl(&rvlc_rl_intra);
init_rl(&rl_intra_aic);
init_vlc_rl(&rl_inter);
init_vlc_rl(&rl_intra);
init_vlc_rl(&rvlc_rl_inter);
init_vlc_rl(&rvlc_rl_intra);
init_vlc_rl(&rl_intra_aic);
init_vlc(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
&DCtab_lum[0][1], 2, 1,
&DCtab_lum[0][0], 2, 1);
init_vlc(&dc_chrom, DC_VLC_BITS, 10 /* 13 */,
&DCtab_chrom[0][1], 2, 1,
&DCtab_chrom[0][0], 2, 1);
init_vlc(&sprite_trajectory, SPRITE_TRAJ_VLC_BITS, 15,
&sprite_trajectory_tab[0][1], 4, 2,
&sprite_trajectory_tab[0][0], 4, 2);
init_vlc(&mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
&mb_type_b_tab[0][1], 2, 1,
&mb_type_b_tab[0][0], 2, 1);
init_vlc(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
&h263_mbtype_b_tab[0][1], 2, 1,
&h263_mbtype_b_tab[0][0], 2, 1);
init_vlc(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
&cbpc_b_tab[0][1], 2, 1,
&cbpc_b_tab[0][0], 2, 1);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3484 | static uint64_t icp_pit_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
icp_pit_state *s = (icp_pit_state *)opaque;
int n;
/* ??? Don't know the PrimeCell ID for this device. */
n = offset >> 8;
if (n > 3) {
hw_error("sp804_read: Bad timer %d\n", n);
}
return arm_timer_read(s->timer[n], offset & 0xff);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3499 | static int mpeg1_decode_sequence(AVCodecContext *avctx,
UINT8 *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int width, height, i, v, j;
init_get_bits(&s->gb, buf, buf_size);
width = get_bits(&s->gb, 12);
height = get_bits(&s->gb, 12);
skip_bits(&s->gb, 4);
s->frame_rate_index = get_bits(&s->gb, 4);
if (s->frame_rate_index == 0)
return -1;
s->bit_rate = get_bits(&s->gb, 18) * 400;
if (get_bits1(&s->gb) == 0) /* marker */
return -1;
if (width <= 0 || height <= 0 ||
(width % 2) != 0 || (height % 2) != 0)
return -1;
if (width != s->width ||
height != s->height) {
/* start new mpeg1 context decoding */
s->out_format = FMT_MPEG1;
if (s1->mpeg_enc_ctx_allocated) {
MPV_common_end(s);
}
s->width = width;
s->height = height;
s->has_b_frames = 1;
s->avctx = avctx;
avctx->width = width;
avctx->height = height;
avctx->frame_rate = frame_rate_tab[s->frame_rate_index];
s->frame_rate = avctx->frame_rate;
avctx->bit_rate = s->bit_rate;
if (MPV_common_init(s) < 0)
return -1;
mpeg1_init_vlc(s);
s1->mpeg_enc_ctx_allocated = 1;
}
skip_bits(&s->gb, 10); /* vbv_buffer_size */
skip_bits(&s->gb, 1);
/* get matrix */
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
v = get_bits(&s->gb, 8);
j = zigzag_direct[i];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
}
#ifdef DEBUG
dprintf("intra matrix present\n");
for(i=0;i<64;i++)
dprintf(" %d", s->intra_matrix[zigzag_direct[i]]);
printf("\n");
#endif
} else {
for(i=0;i<64;i++) {
v = default_intra_matrix[i];
s->intra_matrix[i] = v;
s->chroma_intra_matrix[i] = v;
}
}
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
v = get_bits(&s->gb, 8);
j = zigzag_direct[i];
s->non_intra_matrix[j] = v;
s->chroma_non_intra_matrix[j] = v;
}
#ifdef DEBUG
dprintf("non intra matrix present\n");
for(i=0;i<64;i++)
dprintf(" %d", s->non_intra_matrix[zigzag_direct[i]]);
printf("\n");
#endif
} else {
for(i=0;i<64;i++) {
v = default_non_intra_matrix[i];
s->non_intra_matrix[i] = v;
s->chroma_non_intra_matrix[i] = v;
}
}
/* we set mpeg2 parameters so that it emulates mpeg1 */
s->progressive_sequence = 1;
s->progressive_frame = 1;
s->picture_structure = PICT_FRAME;
s->frame_pred_frame_dct = 1;
s->mpeg2 = 0;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3502 | void ff_rfps_calculate(AVFormatContext *ic)
{
int i, j;
for (i = 0; i<ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
// the check for tb_unreliable() is not completely correct, since this is not about handling
// a unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
// ipmovie.c produces.
if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > FFMAX(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);
if (st->info->duration_count>1 && !st->r_frame_rate.num
&& tb_unreliable(st->codec)) {
int num = 0;
double best_error= 0.01;
for (j=0; j<MAX_STD_TIMEBASES; j++) {
int k;
if(st->info->codec_info_duration && st->info->codec_info_duration*av_q2d(st->time_base) < (1001*12.0)/get_std_framerate(j))
if(!st->info->codec_info_duration && 1.0 < (1001*12.0)/get_std_framerate(j))
for(k=0; k<2; k++){
int n= st->info->duration_count;
double a= st->info->duration_error[k][0][j] / n;
double error= st->info->duration_error[k][1][j]/n - a*a;
if(error < best_error && best_error> 0.000000001){
best_error= error;
num = get_std_framerate(j);
}
if(error < 0.02)
av_log(NULL, AV_LOG_DEBUG, "rfps: %f %f\n", get_std_framerate(j) / 12.0/1001, error);
}
}
// do not increase frame rate by more than 1 % in order to match a standard rate.
if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate)))
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
}
av_freep(&st->info->duration_error);
st->info->last_dts = AV_NOPTS_VALUE;
st->info->duration_count = 0;
st->info->rfps_duration_sum = 0;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3513 | static void gen_compute_eflags_o(DisasContext *s, TCGv reg)
{
gen_compute_eflags(s);
tcg_gen_shri_tl(reg, cpu_cc_src, 11);
tcg_gen_andi_tl(reg, reg, 1);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3517 | static void pred_spatial_direct_motion(const H264Context *const h, H264SliceContext *sl,
int *mb_type)
{
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = sl->mb_xy, mb_y = sl->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type = MB_TYPE_L0L1;
int i8, i4;
int ref[2];
int mv[2];
int list;
assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, sl->ref_list[1][0].parent,
sl->mb_y + !!IS_INTERLACED(*mb_type));
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
/* ref = min(neighbors) */
for (list = 0; list < 2; list++) {
int left_ref = sl->ref_cache[list][scan8[0] - 1];
int top_ref = sl->ref_cache[list][scan8[0] - 8];
int refc = sl->ref_cache[list][scan8[0] - 8 + 4];
const int16_t *C = sl->mv_cache[list][scan8[0] - 8 + 4];
if (refc == PART_NOT_AVAILABLE) {
refc = sl->ref_cache[list][scan8[0] - 8 - 1];
C = sl->mv_cache[list][scan8[0] - 8 - 1];
}
ref[list] = FFMIN3((unsigned)left_ref,
(unsigned)top_ref,
(unsigned)refc);
if (ref[list] >= 0) {
/* This is just pred_motion() but with the cases removed that
* cannot happen for direct blocks. */
const int16_t *const A = sl->mv_cache[list][scan8[0] - 1];
const int16_t *const B = sl->mv_cache[list][scan8[0] - 8];
int match_count = (left_ref == ref[list]) +
(top_ref == ref[list]) +
(refc == ref[list]);
if (match_count > 1) { // most common
mv[list] = pack16to32(mid_pred(A[0], B[0], C[0]),
mid_pred(A[1], B[1], C[1]));
} else {
assert(match_count == 1);
if (left_ref == ref[list])
mv[list] = AV_RN32A(A);
else if (top_ref == ref[list])
mv[list] = AV_RN32A(B);
else
mv[list] = AV_RN32A(C);
}
} else {
int mask = ~(MB_TYPE_L0 << (2 * list));
mv[list] = 0;
ref[list] = -1;
if (!is_b8x8)
*mb_type &= mask;
sub_mb_type &= mask;
}
}
if (ref[0] < 0 && ref[1] < 0) {
ref[0] = ref[1] = 0;
if (!is_b8x8)
*mb_type |= MB_TYPE_L0L1;
sub_mb_type |= MB_TYPE_L0L1;
}
if (!(is_b8x8 | mv[0] | mv[1])) {
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
*mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 |
MB_TYPE_P1L0 | MB_TYPE_P1L1)) |
MB_TYPE_16x16 | MB_TYPE_DIRECT2;
return;
}
if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = sl->mb_x +
((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0;
} else {
mb_y += sl->col_fieldoff;
mb_xy += h->mb_stride * sl->col_fieldoff; // non-zero for FL -> FL & differ parity
}
goto single_col;
} else { // AFL/AFR/FR/FL -> AFR/FR
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = sl->mb_y & ~1;
mb_xy = (sl->mb_y & ~1) * h->mb_stride + sl->mb_x;
mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) !=
IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED;
mb_type_col[1] &= ~MB_TYPE_INTERLACED;
}
sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) &&
(mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) &&
!is_b8x8) {
*mb_type |= MB_TYPE_16x8 | MB_TYPE_DIRECT2; /* B_16x8 */
} else {
*mb_type |= MB_TYPE_8x8;
}
} else { // AFR/FR -> AFR/FR
single_col:
mb_type_col[0] =
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy];
sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) {
*mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_16x16 */
} else if (!is_b8x8 &&
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {
*mb_type |= MB_TYPE_DIRECT2 |
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));
} else {
if (!h->sps.direct_8x8_inference_flag) {
/* FIXME: Save sub mb types from previous frames (or derive
* from MVs) so we know exactly what block size to use. */
sub_mb_type += (MB_TYPE_8x8 - MB_TYPE_16x16); /* B_SUB_4x4 */
}
*mb_type |= MB_TYPE_8x8;
}
}
}
await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
l1mv0 = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy];
if (!b8_stride) {
if (sl->mb_y & 1) {
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2 * b4_stride;
l1mv1 += 2 * b4_stride;
}
}
if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
int n = 0;
for (i8 = 0; i8 < 4; i8++) {
int x8 = i8 & 1;
int y8 = i8 >> 1;
int xy8 = x8 + y8 * b8_stride;
int xy4 = x8 * 3 + y8 * b4_stride;
int a, b;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[1], 1);
if (!IS_INTRA(mb_type_col[y8]) && !sl->ref_list[1][0].parent->long_ref &&
((l1ref0[xy8] == 0 &&
FFABS(l1mv0[xy4][0]) <= 1 &&
FFABS(l1mv0[xy4][1]) <= 1) ||
(l1ref0[xy8] < 0 &&
l1ref1[xy8] == 0 &&
FFABS(l1mv1[xy4][0]) <= 1 &&
FFABS(l1mv1[xy4][1]) <= 1))) {
a =
b = 0;
if (ref[0] > 0)
a = mv[0];
if (ref[1] > 0)
b = mv[1];
n++;
} else {
a = mv[0];
b = mv[1];
}
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, a, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, b, 4);
}
if (!is_b8x8 && !(n & 3))
*mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 |
MB_TYPE_P1L0 | MB_TYPE_P1L1)) |
MB_TYPE_16x16 | MB_TYPE_DIRECT2;
} else if (IS_16X16(*mb_type)) {
int a, b;
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].parent->long_ref &&
((l1ref0[0] == 0 &&
FFABS(l1mv0[0][0]) <= 1 &&
FFABS(l1mv0[0][1]) <= 1) ||
(l1ref0[0] < 0 && !l1ref1[0] &&
FFABS(l1mv1[0][0]) <= 1 &&
FFABS(l1mv1[0][1]) <= 1 &&
h->x264_build > 33U))) {
a = b = 0;
if (ref[0] > 0)
a = mv[0];
if (ref[1] > 0)
b = mv[1];
} else {
a = mv[0];
b = mv[1];
}
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, a, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, b, 4);
} else {
int n = 0;
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, mv[0], 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, mv[1], 4);
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[1], 1);
assert(b8_stride == 2);
/* col_zero_flag */
if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].parent->long_ref &&
(l1ref0[i8] == 0 ||
(l1ref0[i8] < 0 &&
l1ref1[i8] == 0 &&
h->x264_build > 33U))) {
const int16_t (*l1mv)[2] = l1ref0[i8] == 0 ? l1mv0 : l1mv1;
if (IS_SUB_8X8(sub_mb_type)) {
const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
if (FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1) {
if (ref[0] == 0)
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2,
8, 0, 4);
if (ref[1] == 0)
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2,
8, 0, 4);
n += 4;
}
} else {
int m = 0;
for (i4 = 0; i4 < 4; i4++) {
const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
(y8 * 2 + (i4 >> 1)) * b4_stride];
if (FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1) {
if (ref[0] == 0)
AV_ZERO32(sl->mv_cache[0][scan8[i8 * 4 + i4]]);
if (ref[1] == 0)
AV_ZERO32(sl->mv_cache[1][scan8[i8 * 4 + i4]]);
m++;
}
}
if (!(m & 3))
sl->sub_mb_type[i8] += MB_TYPE_16x16 - MB_TYPE_8x8;
n += m;
}
}
}
if (!is_b8x8 && !(n & 15))
*mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 |
MB_TYPE_P1L0 | MB_TYPE_P1L1)) |
MB_TYPE_16x16 | MB_TYPE_DIRECT2;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3521 | static void gem_write(void *opaque, target_phys_addr_t offset, uint64_t val,
unsigned size)
{
GemState *s = (GemState *)opaque;
uint32_t readonly;
DB_PRINT("offset: 0x%04x write: 0x%08x ", offset, (unsigned)val);
offset >>= 2;
/* Squash bits which are read only in write value */
val &= ~(s->regs_ro[offset]);
/* Preserve (only) bits which are read only in register */
readonly = s->regs[offset];
readonly &= s->regs_ro[offset];
/* Squash bits which are write 1 to clear */
val &= ~(s->regs_w1c[offset] & val);
/* Copy register write to backing store */
s->regs[offset] = val | readonly;
/* Handle register write side effects */
switch (offset) {
case GEM_NWCTRL:
if (val & GEM_NWCTRL_TXSTART) {
gem_transmit(s);
}
if (!(val & GEM_NWCTRL_TXENA)) {
/* Reset to start of Q when transmit disabled. */
s->tx_desc_addr = s->regs[GEM_TXQBASE];
}
if (!(val & GEM_NWCTRL_RXENA)) {
/* Reset to start of Q when receive disabled. */
s->rx_desc_addr = s->regs[GEM_RXQBASE];
}
break;
case GEM_TXSTATUS:
gem_update_int_status(s);
break;
case GEM_RXQBASE:
s->rx_desc_addr = val;
break;
case GEM_TXQBASE:
s->tx_desc_addr = val;
break;
case GEM_RXSTATUS:
gem_update_int_status(s);
break;
case GEM_IER:
s->regs[GEM_IMR] &= ~val;
gem_update_int_status(s);
break;
case GEM_IDR:
s->regs[GEM_IMR] |= val;
gem_update_int_status(s);
break;
case GEM_PHYMNTNC:
if (val & GEM_PHYMNTNC_OP_W) {
uint32_t phy_addr, reg_num;
phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
if (phy_addr == BOARD_PHY_ADDRESS) {
reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
gem_phy_write(s, reg_num, val);
}
}
break;
}
DB_PRINT("newval: 0x%08x\n", s->regs[offset]);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3540 | void cpu_loop(CPUMIPSState *env)
{
target_siginfo_t info;
int trapnr, ret;
unsigned int syscall_num;
for(;;) {
trapnr = cpu_mips_exec(env);
switch(trapnr) {
case EXCP_SYSCALL:
syscall_num = env->active_tc.gpr[2] - 4000;
env->active_tc.PC += 4;
if (syscall_num >= sizeof(mips_syscall_args)) {
ret = -ENOSYS;
} else {
int nb_args;
abi_ulong sp_reg;
abi_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0;
nb_args = mips_syscall_args[syscall_num];
sp_reg = env->active_tc.gpr[29];
switch (nb_args) {
/* these arguments are taken from the stack */
/* FIXME - what to do if get_user() fails? */
case 8: get_user_ual(arg8, sp_reg + 28);
case 7: get_user_ual(arg7, sp_reg + 24);
case 6: get_user_ual(arg6, sp_reg + 20);
case 5: get_user_ual(arg5, sp_reg + 16);
default:
ret = do_syscall(env, env->active_tc.gpr[2],
env->active_tc.gpr[4],
env->active_tc.gpr[5],
env->active_tc.gpr[6],
env->active_tc.gpr[7],
arg5, arg6/*, arg7, arg8*/);
if ((unsigned int)ret >= (unsigned int)(-1133)) {
env->active_tc.gpr[7] = 1; /* error flag */
ret = -ret;
} else {
env->active_tc.gpr[7] = 0; /* error flag */
env->active_tc.gpr[2] = ret;
case EXCP_TLBL:
case EXCP_TLBS:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
/* XXX: check env->error_code */
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->CP0_BadVAddr;
queue_signal(env, info.si_signo, &info);
case EXCP_CpU:
case EXCP_RI:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = 0;
queue_signal(env, info.si_signo, &info);
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
default:
// error:
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
abort();
process_pending_signals(env);
The vulnerability label is: Vulnerable |
devign_test_set_data_3551 | static int tmv_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
TMVContext *tmv = s->priv_data;
int64_t pos;
if (stream_index)
return -1;
pos = timestamp *
(tmv->audio_chunk_size + tmv->video_chunk_size + tmv->padding);
avio_seek(s->pb, pos + TMV_HEADER_SIZE, SEEK_SET);
tmv->stream_index = 0;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3555 | static void bonito_ldma_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
PCIBonitoState *s = opaque;
((uint32_t *)(&s->bonldma))[addr/sizeof(uint32_t)] = val & 0xffffffff;
The vulnerability label is: Vulnerable |
devign_test_set_data_3561 | static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index,
Jpeg2000CodingStyle *codsty,
Jpeg2000ResLevel *rlevel, int precno,
int layno, uint8_t *expn, int numgbits)
{
int bandno, cblkno, ret, nb_code_blocks;
int cwsno;
if (layno < rlevel->band[0].prec[precno].decoded_layers)
return 0;
rlevel->band[0].prec[precno].decoded_layers = layno + 1;
if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
s->g = tile->tile_part[++(*tp_index)].tpg;
}
}
if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
if (!(ret = get_bits(s, 1))) {
jpeg2000_flush(s);
return 0;
} else if (ret < 0)
return ret;
for (bandno = 0; bandno < rlevel->nbands; bandno++) {
Jpeg2000Band *band = rlevel->band + bandno;
Jpeg2000Prec *prec = band->prec + precno;
if (band->coord[0][0] == band->coord[0][1] ||
band->coord[1][0] == band->coord[1][1])
continue;
nb_code_blocks = prec->nb_codeblocks_height *
prec->nb_codeblocks_width;
for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
int incl, newpasses, llen;
if (cblk->npasses)
incl = get_bits(s, 1);
else
incl = tag_tree_decode(s, prec->cblkincl + cblkno, layno + 1) == layno;
if (!incl)
continue;
else if (incl < 0)
return incl;
if (!cblk->npasses) {
int v = expn[bandno] + numgbits - 1 -
tag_tree_decode(s, prec->zerobits + cblkno, 100);
if (v < 0 || v > 30) {
av_log(s->avctx, AV_LOG_ERROR,
"nonzerobits %d invalid or unsupported\n", v);
return AVERROR_INVALIDDATA;
}
cblk->nonzerobits = v;
}
if ((newpasses = getnpasses(s)) < 0)
return newpasses;
av_assert2(newpasses > 0);
if (cblk->npasses + newpasses >= JPEG2000_MAX_PASSES) {
avpriv_request_sample(s->avctx, "Too many passes");
return AVERROR_PATCHWELCOME;
}
if ((llen = getlblockinc(s)) < 0)
return llen;
if (cblk->lblock + llen + av_log2(newpasses) > 16) {
avpriv_request_sample(s->avctx,
"Block with length beyond 16 bits");
return AVERROR_PATCHWELCOME;
}
cblk->lblock += llen;
cblk->nb_lengthinc = 0;
cblk->nb_terminationsinc = 0;
do {
int newpasses1 = 0;
while (newpasses1 < newpasses) {
newpasses1 ++;
if (needs_termination(codsty->cblk_style, cblk->npasses + newpasses1 - 1)) {
cblk->nb_terminationsinc ++;
break;
}
}
if ((ret = get_bits(s, av_log2(newpasses1) + cblk->lblock)) < 0)
return ret;
if (ret > sizeof(cblk->data)) {
avpriv_request_sample(s->avctx,
"Block with lengthinc greater than %"SIZE_SPECIFIER"",
sizeof(cblk->data));
return AVERROR_PATCHWELCOME;
}
cblk->lengthinc[cblk->nb_lengthinc++] = ret;
cblk->npasses += newpasses1;
newpasses -= newpasses1;
} while(newpasses);
}
}
jpeg2000_flush(s);
if (codsty->csty & JPEG2000_CSTY_EPH) {
if (bytestream2_peek_be16(&s->g) == JPEG2000_EPH)
bytestream2_skip(&s->g, 2);
else
av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead %X\n", bytestream2_peek_be32(&s->g));
}
for (bandno = 0; bandno < rlevel->nbands; bandno++) {
Jpeg2000Band *band = rlevel->band + bandno;
Jpeg2000Prec *prec = band->prec + precno;
nb_code_blocks = prec->nb_codeblocks_height * prec->nb_codeblocks_width;
for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
for (cwsno = 0; cwsno < cblk->nb_lengthinc; cwsno ++) {
if ( bytestream2_get_bytes_left(&s->g) < cblk->lengthinc[cwsno]
|| sizeof(cblk->data) < cblk->length + cblk->lengthinc[cwsno] + 4
) {
av_log(s->avctx, AV_LOG_ERROR,
"Block length %"PRIu16" or lengthinc %d is too large, left %d\n",
cblk->length, cblk->lengthinc[cwsno], bytestream2_get_bytes_left(&s->g));
return AVERROR_INVALIDDATA;
}
bytestream2_get_bufferu(&s->g, cblk->data + cblk->length, cblk->lengthinc[cwsno]);
cblk->length += cblk->lengthinc[cwsno];
cblk->lengthinc[cwsno] = 0;
if (cblk->nb_terminationsinc) {
cblk->nb_terminationsinc--;
cblk->nb_terminations++;
cblk->data[cblk->length++] = 0xFF;
cblk->data[cblk->length++] = 0xFF;
cblk->data_start[cblk->nb_terminations] = cblk->length;
}
}
}
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3582 | static void curses_refresh(DisplayChangeListener *dcl)
{
int chr, nextchr, keysym, keycode, keycode_alt;
curses_winch_check();
if (invalidate) {
clear();
refresh();
curses_calc_pad();
graphic_hw_invalidate(NULL);
invalidate = 0;
}
graphic_hw_text_update(NULL, screen);
nextchr = ERR;
while (1) {
/* while there are any pending key strokes to process */
if (nextchr == ERR)
chr = getch();
else {
chr = nextchr;
nextchr = ERR;
}
if (chr == ERR)
break;
#ifdef KEY_RESIZE
/* this shouldn't occur when we use a custom SIGWINCH handler */
if (chr == KEY_RESIZE) {
clear();
refresh();
curses_calc_pad();
curses_update(dcl, 0, 0, width, height);
continue;
}
#endif
keycode = curses2keycode[chr];
keycode_alt = 0;
/* alt key */
if (keycode == 1) {
nextchr = getch();
if (nextchr != ERR) {
chr = nextchr;
keycode_alt = ALT;
keycode = curses2keycode[nextchr];
nextchr = ERR;
if (keycode != -1) {
keycode |= ALT;
/* process keys reserved for qemu */
if (keycode >= QEMU_KEY_CONSOLE0 &&
keycode < QEMU_KEY_CONSOLE0 + 9) {
erase();
wnoutrefresh(stdscr);
console_select(keycode - QEMU_KEY_CONSOLE0);
invalidate = 1;
continue;
}
}
}
}
if (kbd_layout) {
keysym = -1;
if (chr < CURSES_KEYS)
keysym = curses2keysym[chr];
if (keysym == -1) {
if (chr < ' ') {
keysym = chr + '@';
if (keysym >= 'A' && keysym <= 'Z')
keysym += 'a' - 'A';
keysym |= KEYSYM_CNTRL;
} else
keysym = chr;
}
keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK);
if (keycode == 0)
continue;
keycode |= (keysym & ~KEYSYM_MASK) >> 16;
keycode |= keycode_alt;
}
if (keycode == -1)
continue;
if (qemu_console_is_graphic(NULL)) {
/* since terminals don't know about key press and release
* events, we need to emit both for each key received */
if (keycode & SHIFT) {
qemu_input_event_send_key_number(NULL, SHIFT_CODE, true);
qemu_input_event_send_key_delay(0);
}
if (keycode & CNTRL) {
qemu_input_event_send_key_number(NULL, CNTRL_CODE, true);
qemu_input_event_send_key_delay(0);
}
if (keycode & ALT) {
qemu_input_event_send_key_number(NULL, ALT_CODE, true);
qemu_input_event_send_key_delay(0);
}
if (keycode & ALTGR) {
qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, true);
qemu_input_event_send_key_delay(0);
}
qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, true);
qemu_input_event_send_key_delay(0);
qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, false);
qemu_input_event_send_key_delay(0);
if (keycode & ALTGR) {
qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, false);
qemu_input_event_send_key_delay(0);
}
if (keycode & ALT) {
qemu_input_event_send_key_number(NULL, ALT_CODE, false);
qemu_input_event_send_key_delay(0);
}
if (keycode & CNTRL) {
qemu_input_event_send_key_number(NULL, CNTRL_CODE, false);
qemu_input_event_send_key_delay(0);
}
if (keycode & SHIFT) {
qemu_input_event_send_key_number(NULL, SHIFT_CODE, false);
qemu_input_event_send_key_delay(0);
}
} else {
keysym = curses2qemu[chr];
if (keysym == -1)
keysym = chr;
kbd_put_keysym(keysym);
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3596 | static int64_t read_ts(char **line, int *duration)
{
int64_t start, end;
if (sscanf(*line, "%"SCNd64",%"SCNd64, &start, &end) == 2) {
*line += strcspn(*line, "\"") + 1;
*duration = end - start;
return start;
}
return AV_NOPTS_VALUE;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3598 | static void raven_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
k->init = raven_init;
k->vendor_id = PCI_VENDOR_ID_MOTOROLA;
k->device_id = PCI_DEVICE_ID_MOTOROLA_RAVEN;
k->revision = 0x00;
k->class_id = PCI_CLASS_BRIDGE_HOST;
dc->desc = "PReP Host Bridge - Motorola Raven";
dc->vmsd = &vmstate_raven;
dc->no_user = 1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3602 | static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
Error **errp)
{
int size;
char *path;
void *ptr;
char name[32];
const VMStateDescription *vmsd;
if (!pdev->romfile)
return;
if (strlen(pdev->romfile) == 0)
return;
if (!pdev->rom_bar) {
/*
* Load rom via fw_cfg instead of creating a rom bar,
* for 0.11 compatibility.
*/
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
/*
* Hot-plugged devices can't use the option ROM
* if the rom bar is disabled.
*/
if (DEVICE(pdev)->hotplugged) {
error_setg(errp, "Hot-plugged device without ROM bar"
" can't have an option ROM");
return;
}
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {
rom_add_option(pdev->romfile, -1);
}
return;
}
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
path = g_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_setg(errp, "failed to find romfile \"%s\"", pdev->romfile);
g_free(path);
return;
} else if (size == 0) {
error_setg(errp, "romfile \"%s\" is empty", pdev->romfile);
g_free(path);
return;
}
size = pow2ceil(size);
vmsd = qdev_get_vmsd(DEVICE(pdev));
if (vmsd) {
snprintf(name, sizeof(name), "%s.rom", vmsd->name);
} else {
snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev)));
}
pdev->has_rom = true;
memory_region_init_ram(&pdev->rom, OBJECT(pdev), name, size, &error_abort);
vmstate_register_ram(&pdev->rom, &pdev->qdev);
ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
g_free(path);
if (is_default_rom) {
/* Only the default rom images will be patched (if needed). */
pci_patch_ids(pdev, ptr, size);
}
pci_register_bar(pdev, PCI_ROM_SLOT, 0, &pdev->rom);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3610 | static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
{
AVStream *video_st = s->streams[0];
AVCodecParameters *video_par = s->streams[0]->codecpar;
AVCodecParameters *audio_par = s->streams[1]->codecpar;
int audio_rate = audio_par->sample_rate;
// TODO: should be avg_frame_rate
int frame_rate = ((video_st->time_base.den) * (0x10000)) / (video_st->time_base.num);
int audio_kbitrate = audio_par->bit_rate / 1000;
int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);
avio_wb32(pb, 0x94); /* size */
ffio_wfourcc(pb, "uuid");
ffio_wfourcc(pb, "PROF");
avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */
avio_wb32(pb, 0xbb88695c);
avio_wb32(pb, 0xfac9c740);
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x3); /* 3 sections ? */
avio_wb32(pb, 0x14); /* size */
ffio_wfourcc(pb, "FPRF");
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x2c); /* size */
ffio_wfourcc(pb, "APRF"); /* audio */
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x2); /* TrackID */
ffio_wfourcc(pb, "mp4a");
avio_wb32(pb, 0x20f);
avio_wb32(pb, 0x0);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_rate);
avio_wb32(pb, audio_par->channels);
avio_wb32(pb, 0x34); /* size */
ffio_wfourcc(pb, "VPRF"); /* video */
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x1); /* TrackID */
if (video_par->codec_id == AV_CODEC_ID_H264) {
ffio_wfourcc(pb, "avc1");
avio_wb16(pb, 0x014D);
avio_wb16(pb, 0x0015);
} else {
ffio_wfourcc(pb, "mp4v");
avio_wb16(pb, 0x0000);
avio_wb16(pb, 0x0103);
}
avio_wb32(pb, 0x0);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, frame_rate);
avio_wb32(pb, frame_rate);
avio_wb16(pb, video_par->width);
avio_wb16(pb, video_par->height);
avio_wb32(pb, 0x010001); /* ? */
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3611 | static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
{
char *path = NULL, *buf = NULL, *host = NULL;
/* Get the PCI VFIO host id */
host = object_property_get_str(OBJECT(pdev), "host", NULL);
if (!host) {
goto err_out;
}
/* Construct the path of the file that will give us the DT location */
path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);
g_free(host);
if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
goto err_out;
}
g_free(path);
/* Construct and read from host device tree the loc-code */
path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);
g_free(buf);
if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
goto err_out;
}
return buf;
err_out:
g_free(path);
return NULL;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3621 | static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat)
{
//FIXME Optimize (just quickly writen not opti..)
int i;
for (i=0; i<dstW; i++)
{
int val=1<<18;
int j;
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if (!uDest)
return;
if (dstFormat == PIX_FMT_NV12)
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(u>>19);
uDest[2*i+1]= av_clip_uint8(v>>19);
}
else
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(v>>19);
uDest[2*i+1]= av_clip_uint8(u>>19);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3634 | static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
{
uint32_t qid;
if (addr & ((1 << 2) - 1)) {
return;
}
if (((addr - 0x1000) >> 2) & 1) {
uint16_t new_head = val & 0xffff;
int start_sqs;
NvmeCQueue *cq;
qid = (addr - (0x1000 + (1 << 2))) >> 3;
if (nvme_check_cqid(n, qid)) {
return;
}
cq = n->cq[qid];
if (new_head >= cq->size) {
return;
}
start_sqs = nvme_cq_full(cq) ? 1 : 0;
cq->head = new_head;
if (start_sqs) {
NvmeSQueue *sq;
QTAILQ_FOREACH(sq, &cq->sq_list, entry) {
timer_mod(sq->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 500);
}
timer_mod(cq->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 500);
}
if (cq->tail != cq->head) {
nvme_isr_notify(n, cq);
}
} else {
uint16_t new_tail = val & 0xffff;
NvmeSQueue *sq;
qid = (addr - 0x1000) >> 3;
if (nvme_check_sqid(n, qid)) {
return;
}
sq = n->sq[qid];
if (new_tail >= sq->size) {
return;
}
sq->tail = new_tail;
timer_mod(sq->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 500);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3658 | static av_cold void build_modpred(Indeo3DecodeContext *s)
{
int i, j;
s->ModPred = av_malloc(8 * 128);
for (i=0; i < 128; ++i) {
s->ModPred[i+0*128] = i > 126 ? 254 : 2*(i + 1 - ((i + 1) % 2));
s->ModPred[i+1*128] = i == 7 ? 20 :
i == 119 ||
i == 120 ? 236 : 2*(i + 2 - ((i + 1) % 3));
s->ModPred[i+2*128] = i > 125 ? 248 : 2*(i + 2 - ((i + 2) % 4));
s->ModPred[i+3*128] = 2*(i + 1 - ((i - 3) % 5));
s->ModPred[i+4*128] = i == 8 ? 20 : 2*(i + 1 - ((i - 3) % 6));
s->ModPred[i+5*128] = 2*(i + 4 - ((i + 3) % 7));
s->ModPred[i+6*128] = i > 123 ? 240 : 2*(i + 4 - ((i + 4) % 8));
s->ModPred[i+7*128] = 2*(i + 5 - ((i + 4) % 9));
}
s->corrector_type = av_malloc(24 * 256);
for (i=0; i < 24; ++i) {
for (j=0; j < 256; ++j) {
s->corrector_type[i*256+j] = j < corrector_type_0[i] ? 1 :
j < 248 || (i == 16 && j == 248) ? 0 :
corrector_type_2[j - 248];
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3681 | static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val)
{
TCGv tmp;
tmp = new_tmp();
tcg_gen_trunc_i64_i32(tmp, val);
store_reg(s, rlow, tmp);
tmp = new_tmp();
tcg_gen_shri_i64(val, val, 32);
tcg_gen_trunc_i64_i32(tmp, val);
store_reg(s, rhigh, tmp);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3691 | static int ccid_bulk_in_copy_to_guest(USBCCIDState *s, uint8_t *data, int len)
{
int ret = 0;
assert(len > 0);
ccid_bulk_in_get(s);
if (s->current_bulk_in != NULL) {
ret = MIN(s->current_bulk_in->len - s->current_bulk_in->pos, len);
memcpy(data, s->current_bulk_in->data + s->current_bulk_in->pos, ret);
s->current_bulk_in->pos += ret;
if (s->current_bulk_in->pos == s->current_bulk_in->len) {
ccid_bulk_in_release(s);
}
} else {
/* return when device has no data - usb 2.0 spec Table 8-4 */
ret = USB_RET_NAK;
}
if (ret > 0) {
DPRINTF(s, D_MORE_INFO,
"%s: %d/%d req/act to guest (BULK_IN)\n", __func__, len, ret);
}
if (ret != USB_RET_NAK && ret < len) {
DPRINTF(s, 1,
"%s: returning short (EREMOTEIO) %d < %d\n", __func__, ret, len);
}
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3714 | static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int16_t input, int16_t pred)
{
int16_t icoef;
int recent = s->cdlms[ich][ilms].recent;
int16_t range = 1 << (s->bits_per_sample - 1);
int bps = s->bits_per_sample > 16 ? 4 : 2; // bytes per sample
if (input > pred) {
for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
s->cdlms[ich][ilms].coefs[icoef] +=
s->cdlms[ich][ilms].lms_updates[icoef + recent];
} else {
for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
s->cdlms[ich][ilms].coefs[icoef] -=
s->cdlms[ich][ilms].lms_updates[icoef]; // XXX: [icoef + recent] ?
}
s->cdlms[ich][ilms].recent--;
s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
if (input > pred)
s->cdlms[ich][ilms].lms_updates[recent] = s->update_speed[ich];
else if (input < pred)
s->cdlms[ich][ilms].lms_updates[recent] = -s->update_speed[ich];
/* XXX: spec says:
cdlms[iCh][ilms].updates[iRecent + cdlms[iCh][ilms].order >> 4] >>= 2;
lms_updates[iCh][ilms][iRecent + cdlms[iCh][ilms].order >> 3] >>= 1;
Questions is - are cdlms[iCh][ilms].updates[] and lms_updates[][][] two
seperate buffers? Here I've assumed that the two are same which makes
more sense to me.
*/
s->cdlms[ich][ilms].lms_updates[recent + s->cdlms[ich][ilms].order >> 4] >>= 2;
s->cdlms[ich][ilms].lms_updates[recent + s->cdlms[ich][ilms].order >> 3] >>= 1;
/* XXX: recent + (s->cdlms[ich][ilms].order >> 4) ? */
if (s->cdlms[ich][ilms].recent == 0) {
/* XXX: This memcpy()s will probably fail if a fixed 32-bit buffer is used.
follow kshishkov's suggestion of using a union. */
memcpy(s->cdlms[ich][ilms].lms_prevvalues + s->cdlms[ich][ilms].order,
s->cdlms[ich][ilms].lms_prevvalues,
bps * s->cdlms[ich][ilms].order);
memcpy(s->cdlms[ich][ilms].lms_updates + s->cdlms[ich][ilms].order,
s->cdlms[ich][ilms].lms_updates,
bps * s->cdlms[ich][ilms].order);
s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3721 | static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
const char *filt_name, const char *args, AVClass *log_ctx)
{
AVFilter *filt;
char inst_name[30];
char tmp_args[256];
int ret;
snprintf(inst_name, sizeof(inst_name), "Parsed filter %d %s", index, filt_name);
filt = avfilter_get_by_name(filt_name);
if (!filt) {
av_log(log_ctx, AV_LOG_ERROR,
"No such filter: '%s'\n", filt_name);
return AVERROR(EINVAL);
}
ret = avfilter_open(filt_ctx, filt, inst_name);
if (!*filt_ctx) {
av_log(log_ctx, AV_LOG_ERROR,
"Error creating filter '%s'\n", filt_name);
return ret;
}
if ((ret = avfilter_graph_add_filter(ctx, *filt_ctx)) < 0) {
avfilter_free(*filt_ctx);
return ret;
}
if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) {
snprintf(tmp_args, sizeof(tmp_args), "%s:%s",
args, ctx->scale_sws_opts);
args = tmp_args;
}
if ((ret = avfilter_init_filter(*filt_ctx, args, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Error initializing filter '%s' with args '%s'\n", filt_name, args);
return ret;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3722 | static void decode_mclms(WmallDecodeCtx *s)
{
s->mclms_order = (get_bits(&s->gb, 4) + 1) * 2;
s->mclms_scaling = get_bits(&s->gb, 4);
if(get_bits1(&s->gb)) {
// mclms_send_coef
int i;
int send_coef_bits;
int cbits = av_log2(s->mclms_scaling + 1);
assert(cbits == my_log2(s->mclms_scaling + 1));
if(1 << cbits < s->mclms_scaling + 1)
cbits++;
send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
for(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) {
s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);
}
for(i = 0; i < s->num_channels; i++) {
int c;
for(c = 0; c < i; c++) {
s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);
}
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3731 | static void ppc_spapr_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
PowerPCCPU *cpu;
CPUPPCState *env;
int i;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
target_phys_addr_t rma_alloc_size, rma_size;
uint32_t initrd_base = 0;
long kernel_size = 0, initrd_size = 0;
long load_limit, rtas_limit, fw_size;
long pteg_shift = 17;
char *filename;
spapr = g_malloc0(sizeof(*spapr));
QLIST_INIT(&spapr->phbs);
cpu_ppc_hypercall = emulate_spapr_hypercall;
/* Allocate RMA if necessary */
rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem);
if (rma_alloc_size == -1) {
hw_error("qemu: Unable to create RMA\n");
exit(1);
}
if (rma_alloc_size && (rma_alloc_size < ram_size)) {
rma_size = rma_alloc_size;
} else {
rma_size = ram_size;
}
/* We place the device tree and RTAS just below either the top of the RMA,
* or just below 2GB, whichever is lowere, so that it can be
* processed with 32-bit real mode code if necessary */
rtas_limit = MIN(rma_size, 0x80000000);
spapr->rtas_addr = rtas_limit - RTAS_MAX_SIZE;
spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE;
load_limit = spapr->fdt_addr - FW_OVERHEAD;
/* init CPUs */
if (cpu_model == NULL) {
cpu_model = kvm_enabled() ? "host" : "POWER7";
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_ppc_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
env = &cpu->env;
/* Set time-base frequency to 512 MHz */
cpu_ppc_tb_init(env, TIMEBASE_FREQ);
qemu_register_reset(spapr_cpu_reset, cpu);
env->hreset_vector = 0x60;
env->hreset_excp_prefix = 0;
env->gpr[3] = env->cpu_index;
}
/* allocate RAM */
spapr->ram_limit = ram_size;
if (spapr->ram_limit > rma_alloc_size) {
ram_addr_t nonrma_base = rma_alloc_size;
ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size;
memory_region_init_ram(ram, "ppc_spapr.ram", nonrma_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, nonrma_base, ram);
}
/* allocate hash page table. For now we always make this 16mb,
* later we should probably make it scale to the size of guest
* RAM */
spapr->htab_size = 1ULL << (pteg_shift + 7);
spapr->htab = qemu_memalign(spapr->htab_size, spapr->htab_size);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
env->external_htab = spapr->htab;
env->htab_base = -1;
env->htab_mask = spapr->htab_size - 1;
/* Tell KVM that we're in PAPR mode */
env->spr[SPR_SDR1] = (unsigned long)spapr->htab |
((pteg_shift + 7) - 18);
env->spr[SPR_HIOR] = 0;
if (kvm_enabled()) {
kvmppc_set_papr(env);
}
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr,
rtas_limit - spapr->rtas_addr);
if (spapr->rtas_size < 0) {
hw_error("qemu: could not load LPAR rtas '%s'\n", filename);
exit(1);
}
if (spapr->rtas_size > RTAS_MAX_SIZE) {
hw_error("RTAS too big ! 0x%lx bytes (max is 0x%x)\n",
spapr->rtas_size, RTAS_MAX_SIZE);
exit(1);
}
g_free(filename);
/* Set up Interrupt Controller */
spapr->icp = xics_system_init(XICS_IRQS);
spapr->next_irq = 16;
/* Set up VIO bus */
spapr->vio_bus = spapr_vio_bus_init();
for (i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
spapr_vty_create(spapr->vio_bus, serial_hds[i]);
}
}
/* Set up PCI */
spapr_create_phb(spapr, "pci", SPAPR_PCI_BUID,
SPAPR_PCI_MEM_WIN_ADDR,
SPAPR_PCI_MEM_WIN_SIZE,
SPAPR_PCI_IO_WIN_ADDR);
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!nd->model) {
nd->model = g_strdup("ibmveth");
}
if (strcmp(nd->model, "ibmveth") == 0) {
spapr_vlan_create(spapr->vio_bus, nd);
} else {
pci_nic_init_nofail(&nd_table[i], nd->model, NULL);
}
}
for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) {
spapr_vscsi_create(spapr->vio_bus);
}
if (rma_size < (MIN_RMA_SLOF << 20)) {
fprintf(stderr, "qemu: pSeries SLOF firmware requires >= "
"%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF);
exit(1);
}
fprintf(stderr, "sPAPR memory map:\n");
fprintf(stderr, "RTAS : 0x%08lx..%08lx\n",
(unsigned long)spapr->rtas_addr,
(unsigned long)(spapr->rtas_addr + spapr->rtas_size - 1));
fprintf(stderr, "FDT : 0x%08lx..%08lx\n",
(unsigned long)spapr->fdt_addr,
(unsigned long)(spapr->fdt_addr + FDT_MAX_SIZE - 1));
if (kernel_filename) {
uint64_t lowaddr = 0;
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename,
KERNEL_LOAD_ADDR,
load_limit - KERNEL_LOAD_ADDR);
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
fprintf(stderr, "Kernel : 0x%08x..%08lx\n",
KERNEL_LOAD_ADDR, KERNEL_LOAD_ADDR + kernel_size - 1);
/* load initrd */
if (initrd_filename) {
/* Try to locate the initrd in the gap between the kernel
* and the firmware. Add a bit of space just in case
*/
initrd_base = (KERNEL_LOAD_ADDR + kernel_size + 0x1ffff) & ~0xffff;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
load_limit - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
fprintf(stderr, "Ramdisk : 0x%08lx..%08lx\n",
(long)initrd_base, (long)(initrd_base + initrd_size - 1));
} else {
initrd_base = 0;
initrd_size = 0;
}
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME);
fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);
if (fw_size < 0) {
hw_error("qemu: could not load LPAR rtas '%s'\n", filename);
exit(1);
}
g_free(filename);
fprintf(stderr, "Firmware load : 0x%08x..%08lx\n",
0, fw_size);
fprintf(stderr, "Firmware runtime : 0x%08lx..%08lx\n",
load_limit, (unsigned long)spapr->fdt_addr);
spapr->entry_point = 0x100;
/* SLOF will startup the secondary CPUs using RTAS */
for (env = first_cpu; env != NULL; env = env->next_cpu) {
env->halted = 1;
}
/* Prepare the device tree */
spapr->fdt_skel = spapr_create_fdt_skel(cpu_model, rma_size,
initrd_base, initrd_size,
kernel_size,
boot_device, kernel_cmdline,
pteg_shift + 7);
assert(spapr->fdt_skel != NULL);
qemu_register_reset(spapr_reset, spapr);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3743 | static av_cold int sonic_encode_init(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
PutBitContext pb;
int i, version = 0;
if (avctx->channels > MAX_CHANNELS)
{
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
return AVERROR(EINVAL); /* only stereo or mono for now */
}
if (avctx->channels == 2)
s->decorrelation = MID_SIDE;
else
s->decorrelation = 3;
if (avctx->codec->id == AV_CODEC_ID_SONIC_LS)
{
s->lossless = 1;
s->num_taps = 32;
s->downsampling = 1;
s->quantization = 0.0;
}
else
{
s->num_taps = 128;
s->downsampling = 2;
s->quantization = 1.0;
}
// max tap 2048
if ((s->num_taps < 32) || (s->num_taps > 1024) ||
((s->num_taps>>5)<<5 != s->num_taps))
{
av_log(avctx, AV_LOG_ERROR, "Invalid number of taps\n");
return AVERROR_INVALIDDATA;
}
// generate taps
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
for (i = 0; i < s->num_taps; i++)
s->tap_quant[i] = ff_sqrt(i+1);
s->channels = avctx->channels;
s->samplerate = avctx->sample_rate;
s->block_align = 2048LL*s->samplerate/(44100*s->downsampling);
s->frame_size = s->channels*s->block_align*s->downsampling;
s->tail_size = s->num_taps*s->channels;
s->tail = av_calloc(s->tail_size, sizeof(*s->tail));
if (!s->tail)
return AVERROR(ENOMEM);
s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k) );
if (!s->predictor_k)
return AVERROR(ENOMEM);
for (i = 0; i < s->channels; i++)
{
s->coded_samples[i] = av_calloc(s->block_align, sizeof(**s->coded_samples));
if (!s->coded_samples[i])
return AVERROR(ENOMEM);
}
s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples));
s->window_size = ((2*s->tail_size)+s->frame_size);
s->window = av_calloc(s->window_size, sizeof(*s->window));
if (!s->window)
return AVERROR(ENOMEM);
avctx->extradata = av_mallocz(16);
if (!avctx->extradata)
return AVERROR(ENOMEM);
init_put_bits(&pb, avctx->extradata, 16*8);
put_bits(&pb, 2, version); // version
if (version == 1)
{
put_bits(&pb, 2, s->channels);
put_bits(&pb, 4, code_samplerate(s->samplerate));
}
put_bits(&pb, 1, s->lossless);
if (!s->lossless)
put_bits(&pb, 3, SAMPLE_SHIFT); // XXX FIXME: sample precision
put_bits(&pb, 2, s->decorrelation);
put_bits(&pb, 2, s->downsampling);
put_bits(&pb, 5, (s->num_taps >> 5)-1); // 32..1024
put_bits(&pb, 1, 0); // XXX FIXME: no custom tap quant table
flush_put_bits(&pb);
avctx->extradata_size = put_bits_count(&pb)/8;
av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
avctx->frame_size = s->block_align*s->downsampling;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3748 | int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
{
static const int8_t top[7] = { LEFT_DC_PRED8x8, 1, -1, -1 };
static const int8_t left[7] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
if (mode > 6U) {
av_log(h->avctx, AV_LOG_ERROR,
"out of range intra chroma pred mode at %d %d\n",
h->mb_x, h->mb_y);
return -1;
}
if (!(h->top_samples_available & 0x8000)) {
mode = top[mode];
if (mode < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"top block unavailable for requested intra mode at %d %d\n",
h->mb_x, h->mb_y);
return -1;
}
}
if ((h->left_samples_available & 0x8080) != 0x8080) {
mode = left[mode];
if (is_chroma && (h->left_samples_available & 0x8080)) {
// mad cow disease mode, aka MBAFF + constrained_intra_pred
mode = ALZHEIMER_DC_L0T_PRED8x8 +
(!(h->left_samples_available & 0x8000)) +
2 * (mode == DC_128_PRED8x8);
}
if (mode < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"left block unavailable for requested intra mode at %d %d\n",
h->mb_x, h->mb_y);
return -1;
}
}
return mode;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3755 | void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as)
{
int bits = 8, sign = 0, shift = 0;
switch (as->fmt) {
case AUD_FMT_S8:
sign = 1;
case AUD_FMT_U8:
break;
case AUD_FMT_S16:
sign = 1;
case AUD_FMT_U16:
bits = 16;
shift = 1;
break;
case AUD_FMT_S32:
sign = 1;
case AUD_FMT_U32:
bits = 32;
shift = 2;
break;
}
info->freq = as->freq;
info->bits = bits;
info->sign = sign;
info->nchannels = as->nchannels;
info->shift = (as->nchannels == 2) + shift;
info->align = (1 << info->shift) - 1;
info->bytes_per_second = info->freq << info->shift;
info->swap_endianness = (as->endianness != AUDIO_HOST_ENDIANNESS);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3763 | static void block_job_completed_txn_abort(BlockJob *job)
{
AioContext *ctx;
BlockJobTxn *txn = job->txn;
BlockJob *other_job, *next;
if (txn->aborting) {
/*
* We are cancelled by another job, which will handle everything.
*/
return;
}
txn->aborting = true;
/* We are the first failed job. Cancel other jobs. */
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
ctx = blk_get_aio_context(other_job->blk);
aio_context_acquire(ctx);
}
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
if (other_job == job || other_job->completed) {
/* Other jobs are "effectively" cancelled by us, set the status for
* them; this job, however, may or may not be cancelled, depending
* on the caller, so leave it. */
if (other_job != job) {
block_job_cancel_async(other_job);
}
continue;
}
block_job_cancel_sync(other_job);
assert(other_job->completed);
}
QLIST_FOREACH_SAFE(other_job, &txn->jobs, txn_list, next) {
ctx = blk_get_aio_context(other_job->blk);
block_job_completed_single(other_job);
aio_context_release(ctx);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3766 | void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
{
memory_region_init_io(mr, &isa_mmio_ops, NULL, "isa-mmio", size);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3770 | int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
SocketAddressLegacy *localAddr,
SocketAddressLegacy *remoteAddr,
Error **errp)
{
int fd;
trace_qio_channel_socket_dgram_sync(ioc, localAddr, remoteAddr);
fd = socket_dgram(remoteAddr, localAddr, errp);
if (fd < 0) {
trace_qio_channel_socket_dgram_fail(ioc);
return -1;
}
trace_qio_channel_socket_dgram_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3778 | static void dec_bit(DisasContext *dc)
{
TCGv t0, t1;
unsigned int op;
int mem_index = cpu_mmu_index(dc->env);
op = dc->ir & ((1 << 9) - 1);
switch (op) {
case 0x21:
/* src. */
t0 = tcg_temp_new();
LOG_DIS("src r%d r%d\n", dc->rd, dc->ra);
tcg_gen_andi_tl(t0, cpu_R[dc->ra], 1);
if (dc->rd) {
t1 = tcg_temp_new();
read_carry(dc, t1);
tcg_gen_shli_tl(t1, t1, 31);
tcg_gen_shri_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);
tcg_gen_or_tl(cpu_R[dc->rd], cpu_R[dc->rd], t1);
tcg_temp_free(t1);
}
/* Update carry. */
write_carry(dc, t0);
tcg_temp_free(t0);
break;
case 0x1:
case 0x41:
/* srl. */
t0 = tcg_temp_new();
LOG_DIS("srl r%d r%d\n", dc->rd, dc->ra);
/* Update carry. */
tcg_gen_andi_tl(t0, cpu_R[dc->ra], 1);
write_carry(dc, t0);
tcg_temp_free(t0);
if (dc->rd) {
if (op == 0x41)
tcg_gen_shri_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);
else
tcg_gen_sari_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);
}
break;
case 0x60:
LOG_DIS("ext8s r%d r%d\n", dc->rd, dc->ra);
tcg_gen_ext8s_i32(cpu_R[dc->rd], cpu_R[dc->ra]);
break;
case 0x61:
LOG_DIS("ext16s r%d r%d\n", dc->rd, dc->ra);
tcg_gen_ext16s_i32(cpu_R[dc->rd], cpu_R[dc->ra]);
break;
case 0x64:
case 0x66:
case 0x74:
case 0x76:
/* wdc. */
LOG_DIS("wdc r%d\n", dc->ra);
if ((dc->tb_flags & MSR_EE_FLAG)
&& mem_index == MMU_USER_IDX) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_PRIVINSN);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
break;
case 0x68:
/* wic. */
LOG_DIS("wic r%d\n", dc->ra);
if ((dc->tb_flags & MSR_EE_FLAG)
&& mem_index == MMU_USER_IDX) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_PRIVINSN);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
break;
case 0xe0:
if ((dc->tb_flags & MSR_EE_FLAG)
&& (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !((dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR))) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
}
if (dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR) {
gen_helper_clz(cpu_R[dc->rd], cpu_R[dc->ra]);
}
break;
case 0x1e0:
/* swapb */
LOG_DIS("swapb r%d r%d\n", dc->rd, dc->ra);
tcg_gen_bswap32_i32(cpu_R[dc->rd], cpu_R[dc->ra]);
break;
case 0x1e2:
/*swaph */
LOG_DIS("swaph r%d r%d\n", dc->rd, dc->ra);
tcg_gen_rotri_i32(cpu_R[dc->rd], cpu_R[dc->ra], 16);
break;
default:
cpu_abort(dc->env, "unknown bit oc=%x op=%x rd=%d ra=%d rb=%d\n",
dc->pc, op, dc->rd, dc->ra, dc->rb);
break;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3795 | int memory_region_get_fd(MemoryRegion *mr)
{
if (mr->alias) {
return memory_region_get_fd(mr->alias);
}
assert(mr->terminates);
return qemu_get_ram_fd(mr->ram_addr & TARGET_PAGE_MASK);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3811 | static void tcg_out_insn_3314(TCGContext *s, AArch64Insn insn,
TCGReg r1, TCGReg r2, TCGReg rn,
tcg_target_long ofs, bool pre, bool w)
{
insn |= 1u << 31; /* ext */
insn |= pre << 24;
insn |= w << 23;
assert(ofs >= -0x200 && ofs < 0x200 && (ofs & 7) == 0);
insn |= (ofs & (0x7f << 3)) << (15 - 3);
tcg_out32(s, insn | r2 << 10 | rn << 5 | r1);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3815 | static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
X86CPU *cpu = X86_CPU(obj);
const int64_t min = 0;
const int64_t max = INT_MAX;
int64_t value;
visit_type_int(v, &value, name, errp);
if (error_is_set(errp)) {
return;
}
if (value < min || value > max) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
return;
}
cpu->env.tsc_khz = value / 1000;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3824 | static int cow_create(const char *filename, QemuOpts *opts, Error **errp)
{
struct cow_header_v2 cow_header;
struct stat st;
int64_t image_sectors = 0;
char *image_filename = NULL;
Error *local_err = NULL;
int ret;
BlockDriverState *cow_bs;
/* Read out options */
image_sectors = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / 512;
image_filename = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
ret = bdrv_create_file(filename, opts, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
cow_bs = NULL;
ret = bdrv_open(&cow_bs, filename, NULL, NULL,
BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
memset(&cow_header, 0, sizeof(cow_header));
cow_header.magic = cpu_to_be32(COW_MAGIC);
cow_header.version = cpu_to_be32(COW_VERSION);
if (image_filename) {
/* Note: if no file, we put a dummy mtime */
cow_header.mtime = cpu_to_be32(0);
if (stat(image_filename, &st) != 0) {
goto mtime_fail;
}
cow_header.mtime = cpu_to_be32(st.st_mtime);
mtime_fail:
pstrcpy(cow_header.backing_file, sizeof(cow_header.backing_file),
image_filename);
}
cow_header.sectorsize = cpu_to_be32(512);
cow_header.size = cpu_to_be64(image_sectors * 512);
ret = bdrv_pwrite(cow_bs, 0, &cow_header, sizeof(cow_header));
if (ret < 0) {
goto exit;
}
/* resize to include at least all the bitmap */
ret = bdrv_truncate(cow_bs,
sizeof(cow_header) + ((image_sectors + 7) >> 3));
if (ret < 0) {
goto exit;
}
exit:
g_free(image_filename);
bdrv_unref(cow_bs);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3832 | static av_cold int check_format(AVCodecContext *avctx)
{
AVCodecParserContext *parser;
uint8_t *pout;
int psize;
int index;
H264Context *h;
int ret = -1;
/* init parser & parse file */
parser = av_parser_init(avctx->codec->id);
if (!parser) {
av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 parser.\n");
goto final;
}
parser->flags = PARSER_FLAG_COMPLETE_FRAMES;
index = av_parser_parse2(parser, avctx, &pout, &psize, NULL, 0, 0, 0, 0);
if (index < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to parse this file.\n");
goto release_parser;
}
/* check if support */
h = parser->priv_data;
switch (h->sps.bit_depth_luma) {
case 8:
if (!CHROMA444(h) && !CHROMA422(h)) {
// only this will H.264 decoder switch to hwaccel
ret = 0;
break;
}
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported file.\n");
}
release_parser:
av_parser_close(parser);
final:
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3834 | static unsigned int dec_move_mr(DisasContext *dc)
{
int memsize = memsize_zz(dc);
int insn_len;
DIS(fprintf (logfile, "move.%c [$r%u%s, $r%u\n",
memsize_char(memsize),
dc->op1, dc->postinc ? "+]" : "]",
dc->op2));
if (memsize == 4) {
insn_len = dec_prep_move_m(dc, 0, 4, cpu_R[dc->op2]);
cris_cc_mask(dc, CC_MASK_NZ);
cris_update_cc_op(dc, CC_OP_MOVE, 4);
cris_update_cc_x(dc);
cris_update_result(dc, cpu_R[dc->op2]);
}
else {
TCGv t0;
t0 = tcg_temp_new(TCG_TYPE_TL);
insn_len = dec_prep_move_m(dc, 0, memsize, t0);
cris_cc_mask(dc, CC_MASK_NZ);
cris_alu(dc, CC_OP_MOVE,
cpu_R[dc->op2], cpu_R[dc->op2], t0, memsize);
tcg_temp_free(t0);
}
do_postinc(dc, memsize);
return insn_len;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3838 | static int rtc_initfn(ISADevice *dev)
{
RTCState *s = DO_UPCAST(RTCState, dev, dev);
int base = 0x70;
int isairq = 8;
isa_init_irq(dev, &s->irq, isairq);
s->cmos_data[RTC_REG_A] = 0x26;
s->cmos_data[RTC_REG_B] = 0x02;
s->cmos_data[RTC_REG_C] = 0x00;
s->cmos_data[RTC_REG_D] = 0x80;
rtc_set_date_from_host(s);
s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);
#ifdef TARGET_I386
if (rtc_td_hack)
s->coalesced_timer =
qemu_new_timer(rtc_clock, rtc_coalesced_timer, s);
#endif
s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s);
s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s);
s->next_second_time =
qemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100;
qemu_mod_timer(s->second_timer2, s->next_second_time);
register_ioport_write(base, 2, 1, cmos_ioport_write, s);
register_ioport_read(base, 2, 1, cmos_ioport_read, s);
register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
#ifdef TARGET_I386
if (rtc_td_hack)
register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s);
#endif
qemu_register_reset(rtc_reset, s);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3845 | static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
return virtio_load(vdev, f, version_id);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3901 | static int read_packet(AVFormatContext *s1, AVPacket *pkt)
{
VideoDemuxData *s = s1->priv_data;
char filename_bytes[1024];
char *filename = filename_bytes;
int i;
int size[3]={0}, ret[3]={0};
AVIOContext *f[3] = {NULL};
AVCodecContext *codec= s1->streams[0]->codec;
if (!s->is_pipe) {
/* loop over input */
if (s->loop && s->img_number > s->img_last) {
s->img_number = s->img_first;
}
if (s->img_number > s->img_last)
return AVERROR_EOF;
if (s->use_glob) {
#if HAVE_GLOB
filename = s->globstate.gl_pathv[s->img_number];
#endif
} else {
if (av_get_frame_filename(filename_bytes, sizeof(filename_bytes),
s->path, s->img_number)<0 && s->img_number > 1)
return AVERROR(EIO);
}
for(i=0; i<3; i++){
if (avio_open2(&f[i], filename, AVIO_FLAG_READ,
&s1->interrupt_callback, NULL) < 0) {
if(i>=1)
break;
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
}
size[i]= avio_size(f[i]);
if(!s->split_planes)
break;
filename[ strlen(filename) - 1 ]= 'U' + i;
}
if(codec->codec_id == AV_CODEC_ID_RAWVIDEO && !codec->width)
infer_size(&codec->width, &codec->height, size[0]);
} else {
f[0] = s1->pb;
if (url_feof(f[0]))
return AVERROR(EIO);
size[0]= 4096;
}
av_new_packet(pkt, size[0] + size[1] + size[2]);
pkt->stream_index = 0;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->size= 0;
for(i=0; i<3; i++){
if(f[i]){
ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
if (!s->is_pipe)
avio_close(f[i]);
if(ret[i]>0)
pkt->size += ret[i];
}
}
if (ret[0] <= 0 || ret[1]<0 || ret[2]<0) {
av_free_packet(pkt);
return AVERROR(EIO); /* signal EOF */
} else {
s->img_count++;
s->img_number++;
return 0;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3913 | static int smacker_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
SmackerContext *smk = s->priv_data;
AVStream *st, *ast[7];
int i, ret;
int tbase;
/* read and check header */
smk->magic = avio_rl32(pb);
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
smk->width = avio_rl32(pb);
smk->height = avio_rl32(pb);
smk->frames = avio_rl32(pb);
smk->pts_inc = (int32_t)avio_rl32(pb);
smk->flags = avio_rl32(pb);
if(smk->flags & SMACKER_FLAG_RING_FRAME)
smk->frames++;
for(i = 0; i < 7; i++)
smk->audio[i] = avio_rl32(pb);
smk->treesize = avio_rl32(pb);
if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (this check is probably redundant)
av_log(s, AV_LOG_ERROR, "treesize too large\n");
//FIXME remove extradata "rebuilding"
smk->mmap_size = avio_rl32(pb);
smk->mclr_size = avio_rl32(pb);
smk->full_size = avio_rl32(pb);
smk->type_size = avio_rl32(pb);
for(i = 0; i < 7; i++) {
smk->rates[i] = avio_rl24(pb);
smk->aflags[i] = avio_r8(pb);
smk->pad = avio_rl32(pb);
/* setup data */
if(smk->frames > 0xFFFFFF) {
av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", smk->frames);
smk->frm_size = av_malloc_array(smk->frames, sizeof(*smk->frm_size));
smk->frm_flags = av_malloc(smk->frames);
if (!smk->frm_size || !smk->frm_flags) {
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);
return AVERROR(ENOMEM);
smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2'));
/* read frame info */
for(i = 0; i < smk->frames; i++) {
smk->frm_size[i] = avio_rl32(pb);
for(i = 0; i < smk->frames; i++) {
smk->frm_flags[i] = avio_r8(pb);
/* init video codec */
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
smk->videoindex = st->index;
st->codec->width = smk->width;
st->codec->height = smk->height;
st->codec->pix_fmt = AV_PIX_FMT_PAL8;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_SMACKVIDEO;
st->codec->codec_tag = smk->magic;
/* Smacker uses 100000 as internal timebase */
if(smk->pts_inc < 0)
smk->pts_inc = -smk->pts_inc;
else
smk->pts_inc *= 100;
tbase = 100000;
av_reduce(&tbase, &smk->pts_inc, tbase, smk->pts_inc, (1UL<<31)-1);
avpriv_set_pts_info(st, 33, smk->pts_inc, tbase);
st->duration = smk->frames;
/* handle possible audio streams */
for(i = 0; i < 7; i++) {
smk->indexes[i] = -1;
if (smk->rates[i]) {
ast[i] = avformat_new_stream(s, NULL);
if (!ast[i])
return AVERROR(ENOMEM);
smk->indexes[i] = ast[i]->index;
ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO;
if (smk->aflags[i] & SMK_AUD_BINKAUD) {
ast[i]->codec->codec_id = AV_CODEC_ID_BINKAUDIO_RDFT;
} else if (smk->aflags[i] & SMK_AUD_USEDCT) {
ast[i]->codec->codec_id = AV_CODEC_ID_BINKAUDIO_DCT;
} else if (smk->aflags[i] & SMK_AUD_PACKED){
ast[i]->codec->codec_id = AV_CODEC_ID_SMACKAUDIO;
ast[i]->codec->codec_tag = MKTAG('S', 'M', 'K', 'A');
} else {
ast[i]->codec->codec_id = AV_CODEC_ID_PCM_U8;
if (smk->aflags[i] & SMK_AUD_STEREO) {
ast[i]->codec->channels = 2;
ast[i]->codec->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
ast[i]->codec->channels = 1;
ast[i]->codec->channel_layout = AV_CH_LAYOUT_MONO;
ast[i]->codec->sample_rate = smk->rates[i];
ast[i]->codec->bits_per_coded_sample = (smk->aflags[i] & SMK_AUD_16BITS) ? 16 : 8;
if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == AV_CODEC_ID_PCM_U8)
ast[i]->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
avpriv_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate
* ast[i]->codec->channels * ast[i]->codec->bits_per_coded_sample / 8);
/* load trees to extradata, they will be unpacked by decoder */
if(ff_alloc_extradata(st->codec, smk->treesize + 16)){
av_log(s, AV_LOG_ERROR,
"Cannot allocate %"PRIu32" bytes of extradata\n",
smk->treesize + 16);
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);
return AVERROR(ENOMEM);
ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
if(ret != st->codec->extradata_size - 16){
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);
return AVERROR(EIO);
((int32_t*)st->codec->extradata)[0] = av_le2ne32(smk->mmap_size);
((int32_t*)st->codec->extradata)[1] = av_le2ne32(smk->mclr_size);
((int32_t*)st->codec->extradata)[2] = av_le2ne32(smk->full_size);
((int32_t*)st->codec->extradata)[3] = av_le2ne32(smk->type_size);
smk->curstream = -1;
smk->nextpos = avio_tell(pb);
return 0;
The vulnerability label is: Vulnerable |
devign_test_set_data_3920 | static int coroutine_fn raw_co_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors)
{
return bdrv_co_discard(bs->file->bs, sector_num, nb_sectors);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3924 | BlockAIOCB *bdrv_aio_write_zeroes(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, BdrvRequestFlags flags,
BlockCompletionFunc *cb, void *opaque)
{
trace_bdrv_aio_write_zeroes(bs, sector_num, nb_sectors, flags, opaque);
return bdrv_co_aio_rw_vector(bs, sector_num, NULL, nb_sectors,
BDRV_REQ_ZERO_WRITE | flags,
cb, opaque, true);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3926 | static void virtio_pci_reset(DeviceState *d)
{
VirtIOPCIProxy *proxy = container_of(d, VirtIOPCIProxy, pci_dev.qdev);
virtio_reset(proxy->vdev);
msix_reset(&proxy->pci_dev);
proxy->flags = 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3933 | static void tcg_out_dat_rIK(TCGContext *s, int cond, int opc, int opinv,
TCGReg dst, TCGReg lhs, TCGArg rhs,
bool rhs_is_const)
{
/* Emit either the reg,imm or reg,reg form of a data-processing insn.
* rhs must satisfy the "rIK" constraint.
*/
if (rhs_is_const) {
int rot = encode_imm(rhs);
if (rot < 0) {
rhs = ~rhs;
rot = encode_imm(rhs);
assert(rot >= 0);
opc = opinv;
}
tcg_out_dat_imm(s, cond, opc, dst, lhs, rotl(rhs, rot) | (rot << 7));
} else {
tcg_out_dat_reg(s, cond, opc, dst, lhs, rhs, SHIFT_IMM_LSL(0));
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3946 | static int twl92230_init(i2c_slave *i2c)
{
MenelausState *s = FROM_I2C_SLAVE(MenelausState, i2c);
s->rtc.hz_tm = qemu_new_timer(rt_clock, menelaus_rtc_hz, s);
/* Three output pins plus one interrupt pin. */
qdev_init_gpio_out(&i2c->qdev, s->out, 4);
qdev_init_gpio_in(&i2c->qdev, menelaus_gpio_set, 3);
s->pwrbtn = qemu_allocate_irqs(menelaus_pwrbtn_set, s, 1)[0];
menelaus_reset(&s->i2c);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3956 | static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVContext *mov = s->priv_data;
ByteIOContext *pb = s->pb;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecContext *enc = trk->enc;
unsigned int samplesInChunk = 0;
int size= pkt->size;
if (url_is_streamed(s->pb)) return 0; /* Can't handle that */
if (!size) return 0; /* Discard 0 sized packets */
if (enc->codec_id == CODEC_ID_AMR_NB) {
/* We must find out how many AMR blocks there are in one packet */
static uint16_t packed_size[16] =
{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0};
int len = 0;
while (len < size && samplesInChunk < 100) {
len += packed_size[(pkt->data[len] >> 3) & 0x0F];
samplesInChunk++;
}
if(samplesInChunk > 1){
av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
return -1;
}
} else if (trk->sampleSize)
samplesInChunk = size/trk->sampleSize;
else
samplesInChunk = 1;
/* copy extradata if it exists */
if (trk->vosLen == 0 && enc->extradata_size > 0) {
trk->vosLen = enc->extradata_size;
trk->vosData = av_malloc(trk->vosLen);
memcpy(trk->vosData, enc->extradata, trk->vosLen);
}
if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) {
/* from x264 or from bytestream h264 */
/* nal reformating needed */
int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
if (ret < 0)
return ret;
assert(pkt->size);
size = pkt->size;
} else if (enc->codec_id == CODEC_ID_DNXHD && !trk->vosLen) {
/* copy frame to create needed atoms */
trk->vosLen = size;
trk->vosData = av_malloc(size);
memcpy(trk->vosData, pkt->data, size);
}
if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) {
trk->cluster = av_realloc(trk->cluster, (trk->entry + MOV_INDEX_CLUSTER_SIZE) * sizeof(*trk->cluster));
if (!trk->cluster)
return -1;
}
trk->cluster[trk->entry].pos = url_ftell(pb);
trk->cluster[trk->entry].samplesInChunk = samplesInChunk;
trk->cluster[trk->entry].size = size;
trk->cluster[trk->entry].entries = samplesInChunk;
trk->cluster[trk->entry].dts = pkt->dts;
trk->trackDuration = pkt->dts - trk->cluster[0].dts + pkt->duration;
if (pkt->pts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_WARNING, "pts has no value\n");
pkt->pts = pkt->dts;
}
if (pkt->dts != pkt->pts)
trk->hasBframes = 1;
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
trk->cluster[trk->entry].key_frame = !!(pkt->flags & PKT_FLAG_KEY);
if(trk->cluster[trk->entry].key_frame)
trk->hasKeyframes++;
trk->entry++;
trk->sampleCount += samplesInChunk;
mov->mdat_size += size;
put_buffer(pb, pkt->data, size);
put_flush_packet(pb);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3960 | static void gen_st_cond (DisasContext *ctx, uint32_t opc, int rt,
int base, int16_t offset)
{
const char *opn = "st_cond";
TCGv t0, t1;
t0 = tcg_temp_local_new();
gen_base_offset_addr(ctx, t0, base, offset);
/* Don't do NOP if destination is zero: we must perform the actual
memory access. */
t1 = tcg_temp_local_new();
gen_load_gpr(t1, rt);
switch (opc) {
#if defined(TARGET_MIPS64)
case OPC_SCD:
save_cpu_state(ctx, 0);
op_st_scd(t1, t0, rt, ctx);
opn = "scd";
break;
#endif
case OPC_SC:
save_cpu_state(ctx, 1);
op_st_sc(t1, t0, rt, ctx);
opn = "sc";
break;
}
(void)opn; /* avoid a compiler warning */
MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]);
tcg_temp_free(t1);
tcg_temp_free(t0);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3970 | static int32_t bmdma_prepare_buf(IDEDMA *dma, int is_write)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} prd;
int l, len;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
/* end of table (with a fail safe of one page) */
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) {
return s->io_buffer_size;
}
pci_dma_read(pci_dev, bm->cur_addr, &prd, 8);
bm->cur_addr += 8;
prd.addr = le32_to_cpu(prd.addr);
prd.size = le32_to_cpu(prd.size);
len = prd.size & 0xfffe;
if (len == 0)
len = 0x10000;
bm->cur_prd_len = len;
bm->cur_prd_addr = prd.addr;
bm->cur_prd_last = (prd.size & 0x80000000);
}
l = bm->cur_prd_len;
if (l > 0) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, l);
/* Note: We limit the max transfer to be 2GiB.
* This should accommodate the largest ATA transaction
* for LBA48 (65,536 sectors) and 32K sector sizes. */
if (s->sg.size > INT32_MAX) {
error_report("IDE: sglist describes more than 2GiB.");
break;
}
bm->cur_prd_addr += l;
bm->cur_prd_len -= l;
s->io_buffer_size += l;
}
}
qemu_sglist_destroy(&s->sg);
s->io_buffer_size = 0;
return -1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3971 | static int apply_window_and_mdct(vorbis_enc_context *venc,
float *audio, int samples)
{
int channel;
const float * win = venc->win[0];
int window_len = 1 << (venc->log2_blocksize[0] - 1);
float n = (float)(1 << venc->log2_blocksize[0]) / 4.0;
AVFloatDSPContext *fdsp = venc->fdsp;
if (!venc->have_saved && !samples)
return 0;
if (venc->have_saved) {
for (channel = 0; channel < venc->channels; channel++)
memcpy(venc->samples + channel * window_len * 2,
venc->saved + channel * window_len, sizeof(float) * window_len);
} else {
for (channel = 0; channel < venc->channels; channel++)
memset(venc->samples + channel * window_len * 2, 0,
sizeof(float) * window_len);
}
if (samples) {
for (channel = 0; channel < venc->channels; channel++) {
float *offset = venc->samples + channel * window_len * 2 + window_len;
fdsp->vector_fmul_reverse(offset, audio + channel * window_len, win, samples);
fdsp->vector_fmul_scalar(offset, offset, 1/n, samples);
}
} else {
for (channel = 0; channel < venc->channels; channel++)
memset(venc->samples + channel * window_len * 2 + window_len,
0, sizeof(float) * window_len);
}
for (channel = 0; channel < venc->channels; channel++)
venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len,
venc->samples + channel * window_len * 2);
if (samples) {
for (channel = 0; channel < venc->channels; channel++) {
float *offset = venc->saved + channel * window_len;
fdsp->vector_fmul(offset, audio + channel * window_len, win, samples);
fdsp->vector_fmul_scalar(offset, offset, 1/n, samples);
}
venc->have_saved = 1;
} else {
venc->have_saved = 0;
}
return 1;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_3977 | static inline int popcountl(unsigned long l)
{
return BITS_PER_LONG == 32 ? ctpop32(l) : ctpop64(l);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3984 | static int32_t parse_gain(const char *gain)
{
char *fraction;
int scale = 10000;
int32_t mb = 0;
int sign = 1;
int db;
if (!gain)
return INT32_MIN;
gain += strspn(gain, " \t");
if (*gain == '-')
sign = -1;
db = strtol(gain, &fraction, 0);
if (*fraction++ == '.') {
while (av_isdigit(*fraction) && scale) {
mb += scale * (*fraction - '0');
scale /= 10;
fraction++;
}
}
if (abs(db) > (INT32_MAX - mb) / 100000)
return INT32_MIN;
return db * 100000 + sign * mb;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_3988 | static inline void ide_dma_submit_check(IDEState *s,
BlockDriverCompletionFunc *dma_cb)
{
if (s->bus->dma->aiocb)
return;
dma_cb(s, -1);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4006 | static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
bool query_backing)
{
BlockStats *s = NULL;
s = g_malloc0(sizeof(*s));
s->stats = g_malloc0(sizeof(*s->stats));
if (!bs) {
return s;
}
if (bdrv_get_node_name(bs)[0]) {
s->has_node_name = true;
s->node_name = g_strdup(bdrv_get_node_name(bs));
}
s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset);
if (bs->file) {
s->has_parent = true;
s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing);
}
if (query_backing && bs->backing) {
s->has_backing = true;
s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);
}
return s;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4009 | static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
const uint8_t *src, const uint8_t *src_end,
int width, int esc_count)
{
int i = 0;
int count;
uint8_t zero_run = 0;
const uint8_t *src_start = src;
uint8_t mask1 = -(esc_count < 2);
uint8_t mask2 = -(esc_count < 3);
uint8_t *end = dst + (width - 2);
avpriv_request_sample(l->avctx, "zero_run_line");
return AVERROR_PATCHWELCOME;
output_zeros:
if (l->zeros_rem) {
count = FFMIN(l->zeros_rem, width - i);
if (end - dst < count) {
av_log(l->avctx, AV_LOG_ERROR, "Too many zeros remaining.\n");
return AVERROR_INVALIDDATA;
}
memset(dst, 0, count);
l->zeros_rem -= count;
dst += count;
}
while (dst < end) {
i = 0;
while (!zero_run && dst + i < end) {
i++;
if (i+2 >= src_end - src)
return AVERROR_INVALIDDATA;
zero_run =
!(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));
}
if (zero_run) {
zero_run = 0;
i += esc_count;
memcpy(dst, src, i);
dst += i;
l->zeros_rem = lag_calc_zero_run(src[i]);
src += i + 1;
goto output_zeros;
} else {
memcpy(dst, src, i);
src += i;
dst += i;
}
}
return src - src_start;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4017 | static int ram_init_all(RAMState **rsp)
{
Error *local_err = NULL;
if (ram_state_init(rsp)) {
return -1;
}
if (migrate_use_xbzrle()) {
XBZRLE_cache_lock();
XBZRLE.zero_target_page = g_malloc0(TARGET_PAGE_SIZE);
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size(),
TARGET_PAGE_SIZE, &local_err);
if (!XBZRLE.cache) {
XBZRLE_cache_unlock();
error_report_err(local_err);
g_free(*rsp);
*rsp = NULL;
return -1;
}
XBZRLE_cache_unlock();
/* We prefer not to abort if there is no memory */
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
if (!XBZRLE.encoded_buf) {
error_report("Error allocating encoded_buf");
g_free(*rsp);
*rsp = NULL;
return -1;
}
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
if (!XBZRLE.current_buf) {
error_report("Error allocating current_buf");
g_free(XBZRLE.encoded_buf);
XBZRLE.encoded_buf = NULL;
g_free(*rsp);
*rsp = NULL;
return -1;
}
}
/* For memory_global_dirty_log_start below. */
qemu_mutex_lock_iothread();
qemu_mutex_lock_ramlist();
rcu_read_lock();
/* Skip setting bitmap if there is no RAM */
if (ram_bytes_total()) {
RAMBlock *block;
QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
unsigned long pages = block->max_length >> TARGET_PAGE_BITS;
block->bmap = bitmap_new(pages);
bitmap_set(block->bmap, 0, pages);
if (migrate_postcopy_ram()) {
block->unsentmap = bitmap_new(pages);
bitmap_set(block->unsentmap, 0, pages);
}
}
}
memory_global_dirty_log_start();
migration_bitmap_sync(*rsp);
qemu_mutex_unlock_ramlist();
qemu_mutex_unlock_iothread();
rcu_read_unlock();
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4025 | static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
const unsigned int index_a = qp + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = beta_table[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]]+1;
tc[1] = tc0_table[index_a][bS[1]]+1;
tc[2] = tc0_table[index_a][bS[2]]+1;
tc[3] = tc0_table[index_a][bS[3]]+1;
h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_4029 | static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
int w, int h)
{
ImageContext *img;
HuffReader *hg;
int i, j, ret, x, y, width;
img = &s->image[role];
img->role = role;
if (!img->frame) {
img->frame = av_frame_alloc();
if (!img->frame)
return AVERROR(ENOMEM);
}
img->frame->format = AV_PIX_FMT_ARGB;
img->frame->width = w;
img->frame->height = h;
if (role == IMAGE_ROLE_ARGB && !img->is_alpha_primary) {
ThreadFrame pt = { .f = img->frame };
ret = ff_thread_get_buffer(s->avctx, &pt, 0);
} else
ret = av_frame_get_buffer(img->frame, 1);
if (ret < 0)
return ret;
if (get_bits1(&s->gb)) {
img->color_cache_bits = get_bits(&s->gb, 4);
if (img->color_cache_bits < 1 || img->color_cache_bits > 11) {
av_log(s->avctx, AV_LOG_ERROR, "invalid color cache bits: %d\n",
img->color_cache_bits);
return AVERROR_INVALIDDATA;
}
img->color_cache = av_mallocz_array(1 << img->color_cache_bits,
sizeof(*img->color_cache));
if (!img->color_cache)
return AVERROR(ENOMEM);
} else {
img->color_cache_bits = 0;
}
img->nb_huffman_groups = 1;
if (role == IMAGE_ROLE_ARGB && get_bits1(&s->gb)) {
ret = decode_entropy_image(s);
if (ret < 0)
return ret;
img->nb_huffman_groups = s->nb_huffman_groups;
}
img->huffman_groups = av_mallocz_array(img->nb_huffman_groups *
HUFFMAN_CODES_PER_META_CODE,
sizeof(*img->huffman_groups));
if (!img->huffman_groups)
return AVERROR(ENOMEM);
for (i = 0; i < img->nb_huffman_groups; i++) {
hg = &img->huffman_groups[i * HUFFMAN_CODES_PER_META_CODE];
for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; j++) {
int alphabet_size = alphabet_sizes[j];
if (!j && img->color_cache_bits > 0)
alphabet_size += 1 << img->color_cache_bits;
if (get_bits1(&s->gb)) {
read_huffman_code_simple(s, &hg[j]);
} else {
ret = read_huffman_code_normal(s, &hg[j], alphabet_size);
if (ret < 0)
return ret;
}
}
}
width = img->frame->width;
if (role == IMAGE_ROLE_ARGB && s->reduced_width > 0)
width = s->reduced_width;
x = 0; y = 0;
while (y < img->frame->height) {
int v;
hg = get_huffman_group(s, img, x, y);
v = huff_reader_get_symbol(&hg[HUFF_IDX_GREEN], &s->gb);
if (v < NUM_LITERAL_CODES) {
/* literal pixel values */
uint8_t *p = GET_PIXEL(img->frame, x, y);
p[2] = v;
p[1] = huff_reader_get_symbol(&hg[HUFF_IDX_RED], &s->gb);
p[3] = huff_reader_get_symbol(&hg[HUFF_IDX_BLUE], &s->gb);
p[0] = huff_reader_get_symbol(&hg[HUFF_IDX_ALPHA], &s->gb);
if (img->color_cache_bits)
color_cache_put(img, AV_RB32(p));
x++;
if (x == width) {
x = 0;
y++;
}
} else if (v < NUM_LITERAL_CODES + NUM_LENGTH_CODES) {
/* LZ77 backwards mapping */
int prefix_code, length, distance, ref_x, ref_y;
/* parse length and distance */
prefix_code = v - NUM_LITERAL_CODES;
if (prefix_code < 4) {
length = prefix_code + 1;
} else {
int extra_bits = (prefix_code - 2) >> 1;
int offset = 2 + (prefix_code & 1) << extra_bits;
length = offset + get_bits(&s->gb, extra_bits) + 1;
}
prefix_code = huff_reader_get_symbol(&hg[HUFF_IDX_DIST], &s->gb);
if (prefix_code > 39) {
av_log(s->avctx, AV_LOG_ERROR,
"distance prefix code too large: %d\n", prefix_code);
return AVERROR_INVALIDDATA;
}
if (prefix_code < 4) {
distance = prefix_code + 1;
} else {
int extra_bits = prefix_code - 2 >> 1;
int offset = 2 + (prefix_code & 1) << extra_bits;
distance = offset + get_bits(&s->gb, extra_bits) + 1;
}
/* find reference location */
if (distance <= NUM_SHORT_DISTANCES) {
int xi = lz77_distance_offsets[distance - 1][0];
int yi = lz77_distance_offsets[distance - 1][1];
distance = FFMAX(1, xi + yi * width);
} else {
distance -= NUM_SHORT_DISTANCES;
}
ref_x = x;
ref_y = y;
if (distance <= x) {
ref_x -= distance;
distance = 0;
} else {
ref_x = 0;
distance -= x;
}
while (distance >= width) {
ref_y--;
distance -= width;
}
if (distance > 0) {
ref_x = width - distance;
ref_y--;
}
ref_x = FFMAX(0, ref_x);
ref_y = FFMAX(0, ref_y);
/* copy pixels
* source and dest regions can overlap and wrap lines, so just
* copy per-pixel */
for (i = 0; i < length; i++) {
uint8_t *p_ref = GET_PIXEL(img->frame, ref_x, ref_y);
uint8_t *p = GET_PIXEL(img->frame, x, y);
AV_COPY32(p, p_ref);
if (img->color_cache_bits)
color_cache_put(img, AV_RB32(p));
x++;
ref_x++;
if (x == width) {
x = 0;
y++;
}
if (ref_x == width) {
ref_x = 0;
ref_y++;
}
if (y == img->frame->height || ref_y == img->frame->height)
break;
}
} else {
/* read from color cache */
uint8_t *p = GET_PIXEL(img->frame, x, y);
int cache_idx = v - (NUM_LITERAL_CODES + NUM_LENGTH_CODES);
if (!img->color_cache_bits) {
av_log(s->avctx, AV_LOG_ERROR, "color cache not found\n");
return AVERROR_INVALIDDATA;
}
if (cache_idx >= 1 << img->color_cache_bits) {
av_log(s->avctx, AV_LOG_ERROR,
"color cache index out-of-bounds\n");
return AVERROR_INVALIDDATA;
}
AV_WB32(p, img->color_cache[cache_idx]);
x++;
if (x == width) {
x = 0;
y++;
}
}
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4041 | void ff_mspel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h)
{
Wmv2Context * const w= (Wmv2Context*)s;
uint8_t *ptr;
int dxy, offset, mx, my, src_x, src_y, v_edge_pos, linesize, uvlinesize;
int emu=0;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
dxy = 2*dxy + w->hshift;
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = s->mb_y * 16 + (motion_y >> 1);
/* WARNING: do no forget half pels */
v_edge_pos = s->v_edge_pos;
src_x = av_clip(src_x, -16, s->width);
src_y = av_clip(src_y, -16, s->height);
if(src_x<=-16 || src_x >= s->width)
dxy &= ~3;
if(src_y<=-16 || src_y >= s->height)
dxy &= ~4;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0] + (src_y * linesize) + src_x;
if(src_x<1 || src_y<1 || src_x + 17 >= s->h_edge_pos
|| src_y + h+1 >= v_edge_pos){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr - 1 - s->linesize, s->linesize, 19, 19,
src_x-1, src_y-1, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer + 1 + s->linesize;
emu=1;
}
s->dsp.put_mspel_pixels_tab[dxy](dest_y , ptr , linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y+8 , ptr+8 , linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y +8*linesize, ptr +8*linesize, linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y+8+8*linesize, ptr+8+8*linesize, linesize);
if(s->flags&CODEC_FLAG_GRAY) return;
if (s->out_format == FMT_H263) {
dxy = 0;
if ((motion_x & 3) != 0)
dxy |= 1;
if ((motion_y & 3) != 0)
dxy |= 2;
mx = motion_x >> 2;
my = motion_y >> 2;
} else {
mx = motion_x / 2;
my = motion_y / 2;
dxy = ((my & 1) << 1) | (mx & 1);
mx >>= 1;
my >>= 1;
}
src_x = s->mb_x * 8 + mx;
src_y = s->mb_y * 8 + my;
src_x = av_clip(src_x, -8, s->width >> 1);
if (src_x == (s->width >> 1))
dxy &= ~1;
src_y = av_clip(src_y, -8, s->height >> 1);
if (src_y == (s->height >> 1))
dxy &= ~2;
offset = (src_y * uvlinesize) + src_x;
ptr = ref_picture[1] + offset;
if(emu){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[1][dxy](dest_cb, ptr, uvlinesize, h >> 1);
ptr = ref_picture[2] + offset;
if(emu){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4062 | static int svq1_encode_plane(SVQ1Context *s, int plane,
unsigned char *src_plane,
unsigned char *ref_plane,
unsigned char *decoded_plane,
int width, int height, int src_stride, int stride)
{
const AVFrame *f = s->avctx->coded_frame;
int x, y;
int i;
int block_width, block_height;
int level;
int threshold[6];
uint8_t *src = s->scratchbuf + stride * 16;
const int lambda = (f->quality * f->quality) >>
(2 * FF_LAMBDA_SHIFT);
/* figure out the acceptable level thresholds in advance */
threshold[5] = QUALITY_THRESHOLD;
for (level = 4; level >= 0; level--)
threshold[level] = threshold[level + 1] * THRESHOLD_MULTIPLIER;
block_width = (width + 15) / 16;
block_height = (height + 15) / 16;
if (f->pict_type == AV_PICTURE_TYPE_P) {
s->m.avctx = s->avctx;
s->m.current_picture_ptr = &s->m.current_picture;
s->m.last_picture_ptr = &s->m.last_picture;
s->m.last_picture.f.data[0] = ref_plane;
s->m.linesize =
s->m.last_picture.f.linesize[0] =
s->m.new_picture.f.linesize[0] =
s->m.current_picture.f.linesize[0] = stride;
s->m.width = width;
s->m.height = height;
s->m.mb_width = block_width;
s->m.mb_height = block_height;
s->m.mb_stride = s->m.mb_width + 1;
s->m.b8_stride = 2 * s->m.mb_width + 1;
s->m.f_code = 1;
s->m.pict_type = f->pict_type;
s->m.me_method = s->avctx->me_method;
s->m.me.scene_change_score = 0;
s->m.flags = s->avctx->flags;
// s->m.out_format = FMT_H263;
// s->m.unrestricted_mv = 1;
s->m.lambda = f->quality;
s->m.qscale = s->m.lambda * 139 +
FF_LAMBDA_SCALE * 64 >>
FF_LAMBDA_SHIFT + 7;
s->m.lambda2 = s->m.lambda * s->m.lambda +
FF_LAMBDA_SCALE / 2 >>
FF_LAMBDA_SHIFT;
if (!s->motion_val8[plane]) {
s->motion_val8[plane] = av_mallocz((s->m.b8_stride *
block_height * 2 + 2) *
2 * sizeof(int16_t));
s->motion_val16[plane] = av_mallocz((s->m.mb_stride *
(block_height + 2) + 1) *
2 * sizeof(int16_t));
}
s->m.mb_type = s->mb_type;
// dummies, to avoid segfaults
s->m.current_picture.mb_mean = (uint8_t *)s->dummy;
s->m.current_picture.mb_var = (uint16_t *)s->dummy;
s->m.current_picture.mc_mb_var = (uint16_t *)s->dummy;
s->m.current_picture.mb_type = s->dummy;
s->m.current_picture.motion_val[0] = s->motion_val8[plane] + 2;
s->m.p_mv_table = s->motion_val16[plane] +
s->m.mb_stride + 1;
s->m.dsp = s->dsp; // move
ff_init_me(&s->m);
s->m.me.dia_size = s->avctx->dia_size;
s->m.first_slice_line = 1;
for (y = 0; y < block_height; y++) {
s->m.new_picture.f.data[0] = src - y * 16 * stride; // ugly
s->m.mb_y = y;
for (i = 0; i < 16 && i + 16 * y < height; i++) {
memcpy(&src[i * stride], &src_plane[(i + 16 * y) * src_stride],
width);
for (x = width; x < 16 * block_width; x++)
src[i * stride + x] = src[i * stride + x - 1];
}
for (; i < 16 && i + 16 * y < 16 * block_height; i++)
memcpy(&src[i * stride], &src[(i - 1) * stride],
16 * block_width);
for (x = 0; x < block_width; x++) {
s->m.mb_x = x;
ff_init_block_index(&s->m);
ff_update_block_index(&s->m);
ff_estimate_p_frame_motion(&s->m, x, y);
}
s->m.first_slice_line = 0;
}
ff_fix_long_p_mvs(&s->m);
ff_fix_long_mvs(&s->m, NULL, 0, s->m.p_mv_table, s->m.f_code,
CANDIDATE_MB_TYPE_INTER, 0);
}
s->m.first_slice_line = 1;
for (y = 0; y < block_height; y++) {
for (i = 0; i < 16 && i + 16 * y < height; i++) {
memcpy(&src[i * stride], &src_plane[(i + 16 * y) * src_stride],
width);
for (x = width; x < 16 * block_width; x++)
src[i * stride + x] = src[i * stride + x - 1];
}
for (; i < 16 && i + 16 * y < 16 * block_height; i++)
memcpy(&src[i * stride], &src[(i - 1) * stride], 16 * block_width);
s->m.mb_y = y;
for (x = 0; x < block_width; x++) {
uint8_t reorder_buffer[3][6][7 * 32];
int count[3][6];
int offset = y * 16 * stride + x * 16;
uint8_t *decoded = decoded_plane + offset;
uint8_t *ref = ref_plane + offset;
int score[4] = { 0, 0, 0, 0 }, best;
uint8_t *temp = s->scratchbuf;
if (s->pb.buf_end - s->pb.buf -
(put_bits_count(&s->pb) >> 3) < 3000) { // FIXME: check size
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
s->m.mb_x = x;
ff_init_block_index(&s->m);
ff_update_block_index(&s->m);
if (f->pict_type == AV_PICTURE_TYPE_I ||
(s->m.mb_type[x + y * s->m.mb_stride] &
CANDIDATE_MB_TYPE_INTRA)) {
for (i = 0; i < 6; i++)
init_put_bits(&s->reorder_pb[i], reorder_buffer[0][i],
7 * 32);
if (f->pict_type == AV_PICTURE_TYPE_P) {
const uint8_t *vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_INTRA];
put_bits(&s->reorder_pb[5], vlc[1], vlc[0]);
score[0] = vlc[1] * lambda;
}
score[0] += encode_block(s, src + 16 * x, NULL, temp, stride,
5, 64, lambda, 1);
for (i = 0; i < 6; i++) {
count[0][i] = put_bits_count(&s->reorder_pb[i]);
flush_put_bits(&s->reorder_pb[i]);
}
} else
score[0] = INT_MAX;
best = 0;
if (f->pict_type == AV_PICTURE_TYPE_P) {
const uint8_t *vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_INTER];
int mx, my, pred_x, pred_y, dxy;
int16_t *motion_ptr;
motion_ptr = ff_h263_pred_motion(&s->m, 0, 0, &pred_x, &pred_y);
if (s->m.mb_type[x + y * s->m.mb_stride] &
CANDIDATE_MB_TYPE_INTER) {
for (i = 0; i < 6; i++)
init_put_bits(&s->reorder_pb[i], reorder_buffer[1][i],
7 * 32);
put_bits(&s->reorder_pb[5], vlc[1], vlc[0]);
s->m.pb = s->reorder_pb[5];
mx = motion_ptr[0];
my = motion_ptr[1];
assert(mx >= -32 && mx <= 31);
assert(my >= -32 && my <= 31);
assert(pred_x >= -32 && pred_x <= 31);
assert(pred_y >= -32 && pred_y <= 31);
ff_h263_encode_motion(&s->m, mx - pred_x, 1);
ff_h263_encode_motion(&s->m, my - pred_y, 1);
s->reorder_pb[5] = s->m.pb;
score[1] += lambda * put_bits_count(&s->reorder_pb[5]);
dxy = (mx & 1) + 2 * (my & 1);
s->hdsp.put_pixels_tab[0][dxy](temp + 16,
ref + (mx >> 1) +
stride * (my >> 1),
stride, 16);
score[1] += encode_block(s, src + 16 * x, temp + 16,
decoded, stride, 5, 64, lambda, 0);
best = score[1] <= score[0];
vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_SKIP];
score[2] = s->dsp.sse[0](NULL, src + 16 * x, ref,
stride, 16);
score[2] += vlc[1] * lambda;
if (score[2] < score[best] && mx == 0 && my == 0) {
best = 2;
s->hdsp.put_pixels_tab[0][0](decoded, ref, stride, 16);
for (i = 0; i < 6; i++)
count[2][i] = 0;
put_bits(&s->pb, vlc[1], vlc[0]);
}
}
if (best == 1) {
for (i = 0; i < 6; i++) {
count[1][i] = put_bits_count(&s->reorder_pb[i]);
flush_put_bits(&s->reorder_pb[i]);
}
} else {
motion_ptr[0] =
motion_ptr[1] =
motion_ptr[2] =
motion_ptr[3] =
motion_ptr[0 + 2 * s->m.b8_stride] =
motion_ptr[1 + 2 * s->m.b8_stride] =
motion_ptr[2 + 2 * s->m.b8_stride] =
motion_ptr[3 + 2 * s->m.b8_stride] = 0;
}
}
s->rd_total += score[best];
for (i = 5; i >= 0; i--)
avpriv_copy_bits(&s->pb, reorder_buffer[best][i],
count[best][i]);
if (best == 0)
s->hdsp.put_pixels_tab[0][0](decoded, temp, stride, 16);
}
s->m.first_slice_line = 0;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4064 | static int ffmmal_add_packet(AVCodecContext *avctx, AVPacket *avpkt,
int is_extradata)
{
MMALDecodeContext *ctx = avctx->priv_data;
AVBufferRef *buf = NULL;
int size = 0;
uint8_t *data = (uint8_t *)"";
uint8_t *start;
int ret = 0;
if (avpkt->size) {
if (avpkt->buf) {
buf = av_buffer_ref(avpkt->buf);
size = avpkt->size;
data = avpkt->data;
} else {
buf = av_buffer_alloc(avpkt->size);
if (buf) {
memcpy(buf->data, avpkt->data, avpkt->size);
size = buf->size;
data = buf->data;
}
}
if (!buf) {
ret = AVERROR(ENOMEM);
goto done;
}
if (!is_extradata)
ctx->packets_sent++;
} else {
if (!ctx->packets_sent) {
// Short-cut the flush logic to avoid upsetting MMAL.
ctx->eos_sent = 1;
ctx->eos_received = 1;
goto done;
}
}
start = data;
do {
FFBufferEntry *buffer = av_mallocz(sizeof(*buffer));
if (!buffer) {
ret = AVERROR(ENOMEM);
goto done;
}
buffer->data = data;
buffer->length = FFMIN(size, ctx->decoder->input[0]->buffer_size);
if (is_extradata)
buffer->flags |= MMAL_BUFFER_HEADER_FLAG_CONFIG;
if (data == start)
buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_START;
data += buffer->length;
size -= buffer->length;
buffer->pts = avpkt->pts == AV_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : avpkt->pts;
buffer->dts = avpkt->dts == AV_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : avpkt->dts;
if (!size)
buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_END;
if (!buffer->length) {
buffer->flags |= MMAL_BUFFER_HEADER_FLAG_EOS;
ctx->eos_sent = 1;
}
if (buf) {
buffer->ref = av_buffer_ref(buf);
if (!buffer->ref) {
av_free(buffer);
ret = AVERROR(ENOMEM);
goto done;
}
}
// Insert at end of the list
if (!ctx->waiting_buffers)
ctx->waiting_buffers = buffer;
if (ctx->waiting_buffers_tail)
ctx->waiting_buffers_tail->next = buffer;
ctx->waiting_buffers_tail = buffer;
} while (size);
done:
av_buffer_unref(&buf);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4070 | static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
{
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
AVCodecContext *avctx = ost->st->codec;
int ret;
if ((avctx->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) ||
(avctx->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) {
int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
if (ost->st->cur_dts && ost->st->cur_dts != AV_NOPTS_VALUE && max > pkt->dts) {
av_log(s, max - pkt->dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt->dts, max);
pkt->pts = pkt->dts = max;
/*
* Audio encoders may split the packets -- #frames in != #packets out.
* But there is no reordering, so we can limit the number of output packets
* by simply dropping them here.
* Counting encoded video frames needs to be done separately because of
* reordering, see do_video_out()
*/
if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
if (ost->frame_number >= ost->max_frames) {
av_free_packet(pkt);
return;
ost->frame_number++;
while (bsfc) {
AVPacket new_pkt = *pkt;
int a = av_bitstream_filter_filter(bsfc, avctx, NULL,
&new_pkt.data, &new_pkt.size,
pkt->data, pkt->size,
pkt->flags & AV_PKT_FLAG_KEY);
if (a > 0) {
av_free_packet(pkt);
new_pkt.destruct = av_destruct_packet;
} else if (a < 0) {
av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for stream %d with codec %s",
bsfc->filter->name, pkt->stream_index,
avctx->codec ? avctx->codec->name : "copy");
print_error("", a);
if (exit_on_error)
exit_program(1);
*pkt = new_pkt;
bsfc = bsfc->next;
pkt->stream_index = ost->index;
ret = av_interleaved_write_frame(s, pkt);
if (ret < 0) {
print_error("av_interleaved_write_frame()", ret);
exit_program(1);
The vulnerability label is: Vulnerable |
devign_test_set_data_4080 | void qed_commit_l2_cache_entry(L2TableCache *l2_cache, CachedL2Table *l2_table)
{
CachedL2Table *entry;
entry = qed_find_l2_cache_entry(l2_cache, l2_table->offset);
if (entry) {
qed_unref_l2_cache_entry(entry);
qed_unref_l2_cache_entry(l2_table);
return;
}
if (l2_cache->n_entries >= MAX_L2_CACHE_SIZE) {
entry = QTAILQ_FIRST(&l2_cache->entries);
QTAILQ_REMOVE(&l2_cache->entries, entry, node);
l2_cache->n_entries--;
qed_unref_l2_cache_entry(entry);
}
l2_cache->n_entries++;
QTAILQ_INSERT_TAIL(&l2_cache->entries, l2_table, node);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_4091 | av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
AVCodecContext *avctx,
unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_MMX(cpu_flags)) {
if (!high_bit_depth)
c->get_pixels = ff_get_pixels_mmx;
c->diff_pixels = ff_diff_pixels_mmx;
}
if (EXTERNAL_SSE2(cpu_flags)) {
if (!high_bit_depth)
c->get_pixels = ff_get_pixels_sse2;
c->diff_pixels = ff_diff_pixels_sse2;
}
}
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.