id stringlengths 22 26 | content stringlengths 72 142k |
|---|---|
devign_test_set_data_10327 | static void ivshmem_io_writel(void *opaque, target_phys_addr_t addr,
uint32_t val)
{
IVShmemState *s = opaque;
uint64_t write_one = 1;
uint16_t dest = val >> 16;
uint16_t vector = val & 0xff;
addr &= 0xfc;
IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);
switch (addr)
{
case INTRMASK:
ivshmem_IntrMask_write(s, val);
break;
case INTRSTATUS:
ivshmem_IntrStatus_write(s, val);
break;
case DOORBELL:
/* check that dest VM ID is reasonable */
if ((dest < 0) || (dest > s->max_peer)) {
IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);
break;
}
/* check doorbell range */
if ((vector >= 0) && (vector < s->peers[dest].nb_eventfds)) {
IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n",
write_one, dest, vector);
if (write(s->peers[dest].eventfds[vector],
&(write_one), 8) != 8) {
IVSHMEM_DPRINTF("error writing to eventfd\n");
}
}
break;
default:
IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10333 | static inline void gen_outs(DisasContext *s, TCGMemOp ot)
{
if (use_icount)
gen_io_start();
gen_string_movl_A0_ESI(s);
gen_op_ld_v(s, ot, cpu_T[0], cpu_A0);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_EDX]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[0]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
gen_op_movl_T0_Dshift(ot);
gen_op_add_reg_T0(s->aflag, R_ESI);
if (use_icount)
gen_io_end();
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10338 | void test_fcmp(double a, double b)
{
long eflags, fpus;
fpu_clear_exceptions();
asm("fcom %2\n"
"fstsw %%ax\n"
: "=a" (fpus)
: "t" (a), "u" (b));
printf("fcom(%f %f)=%04lx \n",
a, b, fpus & (0x4500 | FPUS_EMASK));
fpu_clear_exceptions();
asm("fucom %2\n"
"fstsw %%ax\n"
: "=a" (fpus)
: "t" (a), "u" (b));
printf("fucom(%f %f)=%04lx\n",
a, b, fpus & (0x4500 | FPUS_EMASK));
if (TEST_FCOMI) {
/* test f(u)comi instruction */
fpu_clear_exceptions();
asm("fcomi %3, %2\n"
"fstsw %%ax\n"
"pushf\n"
"pop %0\n"
: "=r" (eflags), "=a" (fpus)
: "t" (a), "u" (b));
printf("fcomi(%f %f)=%04lx %02lx\n",
a, b, fpus & FPUS_EMASK, eflags & (CC_Z | CC_P | CC_C));
fpu_clear_exceptions();
asm("fucomi %3, %2\n"
"fstsw %%ax\n"
"pushf\n"
"pop %0\n"
: "=r" (eflags), "=a" (fpus)
: "t" (a), "u" (b));
printf("fucomi(%f %f)=%04lx %02lx\n",
a, b, fpus & FPUS_EMASK, eflags & (CC_Z | CC_P | CC_C));
}
fpu_clear_exceptions();
asm volatile("fxam\n"
"fstsw %%ax\n"
: "=a" (fpus)
: "t" (a));
printf("fxam(%f)=%04lx\n", a, fpus & 0x4700);
fpu_clear_exceptions();
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10351 | void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr,
hwaddr paddr, MemTxAttrs attrs, int prot,
int mmu_idx, target_ulong size)
{
CPUArchState *env = cpu->env_ptr;
MemoryRegionSection *section;
unsigned int index;
target_ulong address;
target_ulong code_address;
uintptr_t addend;
CPUTLBEntry *te;
hwaddr iotlb, xlat, sz;
unsigned vidx = env->vtlb_index++ % CPU_VTLB_SIZE;
int asidx = cpu_asidx_from_attrs(cpu, attrs);
assert_cpu_is_self(cpu);
assert(size >= TARGET_PAGE_SIZE);
if (size != TARGET_PAGE_SIZE) {
tlb_add_large_page(env, vaddr, size);
}
sz = size;
section = address_space_translate_for_iotlb(cpu, asidx, paddr, &xlat, &sz);
assert(sz >= TARGET_PAGE_SIZE);
tlb_debug("vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx
" prot=%x idx=%d\n",
vaddr, paddr, prot, mmu_idx);
address = vaddr;
if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) {
/* IO memory case */
address |= TLB_MMIO;
addend = 0;
} else {
/* TLB_MMIO for rom/romd handled below */
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + xlat;
}
code_address = address;
iotlb = memory_region_section_get_iotlb(cpu, section, vaddr, paddr, xlat,
prot, &address);
index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
te = &env->tlb_table[mmu_idx][index];
/* do not discard the translation in te, evict it into a victim tlb */
env->tlb_v_table[mmu_idx][vidx] = *te;
env->iotlb_v[mmu_idx][vidx] = env->iotlb[mmu_idx][index];
/* refill the tlb */
env->iotlb[mmu_idx][index].addr = iotlb - vaddr;
env->iotlb[mmu_idx][index].attrs = attrs;
te->addend = addend - vaddr;
if (prot & PAGE_READ) {
te->addr_read = address;
} else {
te->addr_read = -1;
}
if (prot & PAGE_EXEC) {
te->addr_code = code_address;
} else {
te->addr_code = -1;
}
if (prot & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
|| memory_region_is_romd(section->mr)) {
/* Write access calls the I/O callback. */
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& cpu_physical_memory_is_clean(
memory_region_get_ram_addr(section->mr) + xlat)) {
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
}
} else {
te->addr_write = -1;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10355 | static int qcrypto_cipher_init_des_rfb(QCryptoCipher *cipher,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipherBuiltin *ctxt;
if (cipher->mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(errp, "Unsupported cipher mode %d", cipher->mode);
return -1;
}
ctxt = g_new0(QCryptoCipherBuiltin, 1);
ctxt->state.desrfb.key = g_new0(uint8_t, nkey);
memcpy(ctxt->state.desrfb.key, key, nkey);
ctxt->state.desrfb.nkey = nkey;
ctxt->free = qcrypto_cipher_free_des_rfb;
ctxt->setiv = qcrypto_cipher_setiv_des_rfb;
ctxt->encrypt = qcrypto_cipher_encrypt_des_rfb;
ctxt->decrypt = qcrypto_cipher_decrypt_des_rfb;
cipher->opaque = ctxt;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10364 | static int virtio_ccw_handle_set_vq(SubchDev *sch, CCW1 ccw, bool check_len,
bool is_legacy)
{
int ret;
VqInfoBlock info;
VqInfoBlockLegacy linfo;
size_t info_len = is_legacy ? sizeof(linfo) : sizeof(info);
if (check_len) {
if (ccw.count != info_len) {
return -EINVAL;
}
} else if (ccw.count < info_len) {
/* Can't execute command. */
return -EINVAL;
}
if (!ccw.cda) {
return -EFAULT;
}
if (is_legacy) {
linfo.queue = address_space_ldq_be(&address_space_memory, ccw.cda,
MEMTXATTRS_UNSPECIFIED, NULL);
linfo.align = address_space_ldl_be(&address_space_memory,
ccw.cda + sizeof(linfo.queue),
MEMTXATTRS_UNSPECIFIED,
NULL);
linfo.index = address_space_lduw_be(&address_space_memory,
ccw.cda + sizeof(linfo.queue)
+ sizeof(linfo.align),
MEMTXATTRS_UNSPECIFIED,
NULL);
linfo.num = address_space_lduw_be(&address_space_memory,
ccw.cda + sizeof(linfo.queue)
+ sizeof(linfo.align)
+ sizeof(linfo.index),
MEMTXATTRS_UNSPECIFIED,
NULL);
ret = virtio_ccw_set_vqs(sch, NULL, &linfo);
} else {
info.desc = address_space_ldq_be(&address_space_memory, ccw.cda,
MEMTXATTRS_UNSPECIFIED, NULL);
info.index = address_space_lduw_be(&address_space_memory,
ccw.cda + sizeof(info.desc)
+ sizeof(info.res0),
MEMTXATTRS_UNSPECIFIED, NULL);
info.num = address_space_lduw_be(&address_space_memory,
ccw.cda + sizeof(info.desc)
+ sizeof(info.res0)
+ sizeof(info.index),
MEMTXATTRS_UNSPECIFIED, NULL);
info.avail = address_space_ldq_be(&address_space_memory,
ccw.cda + sizeof(info.desc)
+ sizeof(info.res0)
+ sizeof(info.index)
+ sizeof(info.num),
MEMTXATTRS_UNSPECIFIED, NULL);
info.used = address_space_ldq_be(&address_space_memory,
ccw.cda + sizeof(info.desc)
+ sizeof(info.res0)
+ sizeof(info.index)
+ sizeof(info.num)
+ sizeof(info.avail),
MEMTXATTRS_UNSPECIFIED, NULL);
ret = virtio_ccw_set_vqs(sch, &info, NULL);
}
sch->curr_status.scsw.count = 0;
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10370 | static void vnc_client_cache_addr(VncState *client)
{
Error *err = NULL;
client->info = g_malloc0(sizeof(*client->info));
client->info->base = g_malloc0(sizeof(*client->info->base));
vnc_init_basic_info_from_remote_addr(client->csock, client->info->base,
&err);
if (err) {
qapi_free_VncClientInfo(client->info);
client->info = NULL;
error_free(err);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10374 | int kvm_irqchip_add_irqfd(KVMState *s, int fd, int virq)
{
return kvm_irqchip_assign_irqfd(s, fd, virq, true);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10385 | static gboolean udp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
NetCharDriver *s = chr->opaque;
gsize bytes_read = 0;
GIOStatus status;
if (s->max_size == 0)
return FALSE;
status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),
&bytes_read, NULL);
s->bufcnt = bytes_read;
s->bufptr = s->bufcnt;
if (status != G_IO_STATUS_NORMAL) {
return FALSE;
}
s->bufptr = 0;
while (s->max_size > 0 && s->bufptr < s->bufcnt) {
qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);
s->bufptr++;
s->max_size = qemu_chr_be_can_write(chr);
}
return TRUE;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10406 | PCIBus *pci_prep_init(qemu_irq *pic)
{
PREPPCIState *s;
PCIDevice *d;
int PPC_io_memory;
s = qemu_mallocz(sizeof(PREPPCIState));
s->bus = pci_register_bus(prep_set_irq, prep_map_irq, pic, 0, 2);
register_ioport_write(0xcf8, 4, 4, pci_prep_addr_writel, s);
register_ioport_read(0xcf8, 4, 4, pci_prep_addr_readl, s);
register_ioport_write(0xcfc, 4, 1, pci_host_data_writeb, s);
register_ioport_write(0xcfc, 4, 2, pci_host_data_writew, s);
register_ioport_write(0xcfc, 4, 4, pci_host_data_writel, s);
register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s);
register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s);
register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s);
PPC_io_memory = cpu_register_io_memory(0, PPC_PCIIO_read,
PPC_PCIIO_write, s);
cpu_register_physical_memory(0x80800000, 0x00400000, PPC_io_memory);
/* PCI host bridge */
d = pci_register_device(s->bus, "PREP Host Bridge - Motorola Raven",
sizeof(PCIDevice), 0, NULL, NULL);
d->config[0x00] = 0x57; // vendor_id : Motorola
d->config[0x01] = 0x10;
d->config[0x02] = 0x01; // device_id : Raven
d->config[0x03] = 0x48;
d->config[0x08] = 0x00; // revision
d->config[0x0A] = 0x00; // class_sub = pci host
d->config[0x0B] = 0x06; // class_base = PCI_bridge
d->config[0x0C] = 0x08; // cache_line_size
d->config[0x0D] = 0x10; // latency_timer
d->config[0x0E] = 0x00; // header_type
d->config[0x34] = 0x00; // capabilities_pointer
return s->bus;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10410 | static int raw_init_encoder(AVCodecContext *avctx)
{
avctx->coded_frame = (AVFrame *)avctx->priv_data;
avctx->coded_frame->pict_type = FF_I_TYPE;
avctx->coded_frame->key_frame = 1;
avctx->codec_tag = findFourCC(avctx->pix_fmt);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10414 | static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
{
v->res_rtm_flag = 1;
v->level = get_bits(gb, 3);
if(v->level >= 5)
{
av_log(v->s.avctx, AV_LOG_ERROR, "Reserved LEVEL %i\n",v->level);
}
v->chromaformat = get_bits(gb, 2);
if (v->chromaformat != 1)
{
av_log(v->s.avctx, AV_LOG_ERROR,
"Only 4:2:0 chroma format supported\n");
return -1;
}
// (fps-2)/4 (->30)
v->frmrtq_postproc = get_bits(gb, 3); //common
// (bitrate-32kbps)/64kbps
v->bitrtq_postproc = get_bits(gb, 5); //common
v->postprocflag = get_bits(gb, 1); //common
v->s.avctx->coded_width = (get_bits(gb, 12) + 1) << 1;
v->s.avctx->coded_height = (get_bits(gb, 12) + 1) << 1;
v->broadcast = get_bits1(gb);
v->interlace = get_bits1(gb);
if(v->interlace){
av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced mode not supported (yet)\n");
return -1;
}
v->tfcntrflag = get_bits1(gb);
v->finterpflag = get_bits1(gb);
get_bits1(gb); // reserved
v->psf = get_bits1(gb);
if(v->psf) { //PsF, 6.1.13
av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n");
return -1;
}
if(get_bits1(gb)) { //Display Info - decoding is not affected by it
int w, h, ar = 0;
av_log(v->s.avctx, AV_LOG_INFO, "Display extended info:\n");
w = get_bits(gb, 14);
h = get_bits(gb, 14);
av_log(v->s.avctx, AV_LOG_INFO, "Display dimensions: %ix%i\n", w, h);
//TODO: store aspect ratio in AVCodecContext
if(get_bits1(gb))
ar = get_bits(gb, 4);
if(ar == 15) {
w = get_bits(gb, 8);
h = get_bits(gb, 8);
}
if(get_bits1(gb)){ //framerate stuff
if(get_bits1(gb)) {
get_bits(gb, 16);
} else {
get_bits(gb, 8);
get_bits(gb, 4);
}
}
if(get_bits1(gb)){
v->color_prim = get_bits(gb, 8);
v->transfer_char = get_bits(gb, 8);
v->matrix_coef = get_bits(gb, 8);
}
}
v->hrd_param_flag = get_bits1(gb);
if(v->hrd_param_flag) {
int i;
v->hrd_num_leaky_buckets = get_bits(gb, 5);
get_bits(gb, 4); //bitrate exponent
get_bits(gb, 4); //buffer size exponent
for(i = 0; i < v->hrd_num_leaky_buckets; i++) {
get_bits(gb, 16); //hrd_rate[n]
get_bits(gb, 16); //hrd_buffer[n]
}
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10416 | int page_unprotect(target_ulong address, uintptr_t pc, void *puc)
{
unsigned int prot;
PageDesc *p;
target_ulong host_start, host_end, addr;
/* Technically this isn't safe inside a signal handler. However we
know this only ever happens in a synchronous SEGV handler, so in
practice it seems to be ok. */
mmap_lock();
p = page_find(address >> TARGET_PAGE_BITS);
if (!p) {
mmap_unlock();
return 0;
}
/* if the page was really writable, then we change its
protection back to writable */
if ((p->flags & PAGE_WRITE_ORG) && !(p->flags & PAGE_WRITE)) {
host_start = address & qemu_host_page_mask;
host_end = host_start + qemu_host_page_size;
prot = 0;
for (addr = host_start ; addr < host_end ; addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
p->flags |= PAGE_WRITE;
prot |= p->flags;
/* and since the content will be modified, we must invalidate
the corresponding translated code. */
tb_invalidate_phys_page(addr, pc, puc);
#ifdef DEBUG_TB_CHECK
tb_invalidate_check(addr);
#endif
}
mprotect((void *)g2h(host_start), qemu_host_page_size,
prot & PAGE_BITS);
mmap_unlock();
return 1;
}
mmap_unlock();
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10429 | void ff_put_h264_qpel8_mc23_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midv_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 1);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10449 | static int film_probe(AVProbeData *p)
{
if (p->buf_size < 4)
return 0;
if (AV_RB32(&p->buf[0]) != FILM_TAG)
return 0;
return AVPROBE_SCORE_MAX;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10478 | static void gen_store_v10_conditional(DisasContext *dc, TCGv addr, TCGv val,
unsigned int size, int mem_index)
{
int l1 = gen_new_label();
TCGv taddr = tcg_temp_local_new();
TCGv tval = tcg_temp_local_new();
TCGv t1 = tcg_temp_local_new();
dc->postinc = 0;
cris_evaluate_flags(dc);
tcg_gen_mov_tl(taddr, addr);
tcg_gen_mov_tl(tval, val);
/* Store only if F flag isn't set */
tcg_gen_andi_tl(t1, cpu_PR[PR_CCS], F_FLAG_V10);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, 0, l1);
if (size == 1) {
tcg_gen_qemu_st8(tval, taddr, mem_index);
} else if (size == 2) {
tcg_gen_qemu_st16(tval, taddr, mem_index);
} else {
tcg_gen_qemu_st32(tval, taddr, mem_index);
}
gen_set_label(l1);
tcg_gen_shri_tl(t1, t1, 1); /* shift F to P position */
tcg_gen_or_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], t1); /*P=F*/
tcg_temp_free(t1);
tcg_temp_free(tval);
tcg_temp_free(taddr);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10480 | static void ide_trim_bh_cb(void *opaque)
{
TrimAIOCB *iocb = opaque;
iocb->common.cb(iocb->common.opaque, iocb->ret);
qemu_bh_delete(iocb->bh);
iocb->bh = NULL;
qemu_aio_unref(iocb);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10485 | static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
abi_long cmd, abi_long arg)
{
void *argptr;
struct dm_ioctl *host_dm;
abi_long guest_data;
uint32_t guest_data_size;
int target_size;
const argtype *arg_type = ie->arg_type;
abi_long ret;
void *big_buf = NULL;
char *host_data;
arg_type++;
target_size = thunk_type_size(arg_type, 0);
argptr = lock_user(VERIFY_READ, arg, target_size, 1);
if (!argptr) {
ret = -TARGET_EFAULT;
goto out;
}
thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
unlock_user(argptr, arg, 0);
/* buf_temp is too small, so fetch things into a bigger buffer */
big_buf = g_malloc0(((struct dm_ioctl*)buf_temp)->data_size * 2);
memcpy(big_buf, buf_temp, target_size);
buf_temp = big_buf;
host_dm = big_buf;
guest_data = arg + host_dm->data_start;
if ((guest_data - arg) < 0) {
ret = -EINVAL;
goto out;
}
guest_data_size = host_dm->data_size - host_dm->data_start;
host_data = (char*)host_dm + host_dm->data_start;
argptr = lock_user(VERIFY_READ, guest_data, guest_data_size, 1);
switch (ie->host_cmd) {
case DM_REMOVE_ALL:
case DM_LIST_DEVICES:
case DM_DEV_CREATE:
case DM_DEV_REMOVE:
case DM_DEV_SUSPEND:
case DM_DEV_STATUS:
case DM_DEV_WAIT:
case DM_TABLE_STATUS:
case DM_TABLE_CLEAR:
case DM_TABLE_DEPS:
case DM_LIST_VERSIONS:
/* no input data */
break;
case DM_DEV_RENAME:
case DM_DEV_SET_GEOMETRY:
/* data contains only strings */
memcpy(host_data, argptr, guest_data_size);
break;
case DM_TARGET_MSG:
memcpy(host_data, argptr, guest_data_size);
*(uint64_t*)host_data = tswap64(*(uint64_t*)argptr);
break;
case DM_TABLE_LOAD:
{
void *gspec = argptr;
void *cur_data = host_data;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
int spec_size = thunk_type_size(arg_type, 0);
int i;
for (i = 0; i < host_dm->target_count; i++) {
struct dm_target_spec *spec = cur_data;
uint32_t next;
int slen;
thunk_convert(spec, gspec, arg_type, THUNK_HOST);
slen = strlen((char*)gspec + spec_size) + 1;
next = spec->next;
spec->next = sizeof(*spec) + slen;
strcpy((char*)&spec[1], gspec + spec_size);
gspec += next;
cur_data += spec->next;
}
break;
}
default:
ret = -TARGET_EINVAL;
goto out;
}
unlock_user(argptr, guest_data, 0);
ret = get_errno(ioctl(fd, ie->host_cmd, buf_temp));
if (!is_error(ret)) {
guest_data = arg + host_dm->data_start;
guest_data_size = host_dm->data_size - host_dm->data_start;
argptr = lock_user(VERIFY_WRITE, guest_data, guest_data_size, 0);
switch (ie->host_cmd) {
case DM_REMOVE_ALL:
case DM_DEV_CREATE:
case DM_DEV_REMOVE:
case DM_DEV_RENAME:
case DM_DEV_SUSPEND:
case DM_DEV_STATUS:
case DM_TABLE_LOAD:
case DM_TABLE_CLEAR:
case DM_TARGET_MSG:
case DM_DEV_SET_GEOMETRY:
/* no return data */
break;
case DM_LIST_DEVICES:
{
struct dm_name_list *nl = (void*)host_dm + host_dm->data_start;
uint32_t remaining_data = guest_data_size;
void *cur_data = argptr;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) };
int nl_size = 12; /* can't use thunk_size due to alignment */
while (1) {
uint32_t next = nl->next;
if (next) {
nl->next = nl_size + (strlen(nl->name) + 1);
}
if (remaining_data < nl->next) {
host_dm->flags |= DM_BUFFER_FULL_FLAG;
break;
}
thunk_convert(cur_data, nl, arg_type, THUNK_TARGET);
strcpy(cur_data + nl_size, nl->name);
cur_data += nl->next;
remaining_data -= nl->next;
if (!next) {
break;
}
nl = (void*)nl + next;
}
break;
}
case DM_DEV_WAIT:
case DM_TABLE_STATUS:
{
struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start;
void *cur_data = argptr;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
int spec_size = thunk_type_size(arg_type, 0);
int i;
for (i = 0; i < host_dm->target_count; i++) {
uint32_t next = spec->next;
int slen = strlen((char*)&spec[1]) + 1;
spec->next = (cur_data - argptr) + spec_size + slen;
if (guest_data_size < spec->next) {
host_dm->flags |= DM_BUFFER_FULL_FLAG;
break;
}
thunk_convert(cur_data, spec, arg_type, THUNK_TARGET);
strcpy(cur_data + spec_size, (char*)&spec[1]);
cur_data = argptr + spec->next;
spec = (void*)host_dm + host_dm->data_start + next;
}
break;
}
case DM_TABLE_DEPS:
{
void *hdata = (void*)host_dm + host_dm->data_start;
int count = *(uint32_t*)hdata;
uint64_t *hdev = hdata + 8;
uint64_t *gdev = argptr + 8;
int i;
*(uint32_t*)argptr = tswap32(count);
for (i = 0; i < count; i++) {
*gdev = tswap64(*hdev);
gdev++;
hdev++;
}
break;
}
case DM_LIST_VERSIONS:
{
struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start;
uint32_t remaining_data = guest_data_size;
void *cur_data = argptr;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) };
int vers_size = thunk_type_size(arg_type, 0);
while (1) {
uint32_t next = vers->next;
if (next) {
vers->next = vers_size + (strlen(vers->name) + 1);
}
if (remaining_data < vers->next) {
host_dm->flags |= DM_BUFFER_FULL_FLAG;
break;
}
thunk_convert(cur_data, vers, arg_type, THUNK_TARGET);
strcpy(cur_data + vers_size, vers->name);
cur_data += vers->next;
remaining_data -= vers->next;
if (!next) {
break;
}
vers = (void*)vers + next;
}
break;
}
default:
ret = -TARGET_EINVAL;
goto out;
}
unlock_user(argptr, guest_data, guest_data_size);
argptr = lock_user(VERIFY_WRITE, arg, target_size, 0);
if (!argptr) {
ret = -TARGET_EFAULT;
goto out;
}
thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET);
unlock_user(argptr, arg, target_size);
}
out:
if (big_buf) {
free(big_buf);
}
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10498 | static int dxva2_retrieve_data(AVCodecContext *s, AVFrame *frame)
{
InputStream *ist = s->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
int ret;
ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0);
if (ret < 0)
return ret;
ret = av_frame_copy_props(ctx->tmp_frame, frame);
if (ret < 0) {
av_frame_unref(ctx->tmp_frame);
return ret;
}
av_frame_unref(frame);
av_frame_move_ref(frame, ctx->tmp_frame);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10502 | void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
uint8_t *segment, uint8_t *ref, int layout)
{
VP56RangeCoder *c = &s->c;
if (s->segmentation.update_map)
*segment = vp8_rac_get_tree(c, vp8_segmentid_tree, s->prob->segmentid);
else if (s->segmentation.enabled)
*segment = ref ? *ref : *segment;
mb->segment = *segment;
mb->skip = s->mbskip_enabled ? vp56_rac_get_prob(c, s->prob->mbskip) : 0;
if (s->keyframe) {
mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra,
vp8_pred16x16_prob_intra);
if (mb->mode == MODE_I4x4) {
decode_intra4x4_modes(s, c, mb, mb_x, 1, layout);
} else {
const uint32_t modes = vp8_pred4x4_mode[mb->mode] * 0x01010101u;
if (s->mb_layout == 1)
AV_WN32A(mb->intra4x4_pred_mode_top, modes);
else
AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);
AV_WN32A(s->intra4x4_pred_mode_left, modes);
}
mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,
vp8_pred8x8c_prob_intra);
mb->ref_frame = VP56_FRAME_CURRENT;
} else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) {
// inter MB, 16.2
if (vp56_rac_get_prob_branchy(c, s->prob->last))
mb->ref_frame =
vp56_rac_get_prob(c, s->prob->golden) ? VP56_FRAME_GOLDEN2 /* altref */
: VP56_FRAME_GOLDEN;
else
mb->ref_frame = VP56_FRAME_PREVIOUS;
s->ref_count[mb->ref_frame - 1]++;
// motion vectors, 16.3
decode_mvs(s, mb, mb_x, mb_y, layout);
} else {
// intra MB, 16.1
mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);
if (mb->mode == MODE_I4x4)
decode_intra4x4_modes(s, c, mb, mb_x, 0, layout);
mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,
s->prob->pred8x8c);
mb->ref_frame = VP56_FRAME_CURRENT;
mb->partitioning = VP8_SPLITMVMODE_NONE;
AV_ZERO32(&mb->bmv[0]);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10504 | static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)
{
uint32_t op;
/* make sure instructions are on a halfword boundary */
if (ctx->pc & 0x1) {
env->CP0_BadVAddr = ctx->pc;
generate_exception(ctx, EXCP_AdEL);
ctx->bstate = BS_STOP;
return 2;
}
op = (ctx->opcode >> 10) & 0x3f;
/* Enforce properly-sized instructions in a delay slot */
if (ctx->hflags & MIPS_HFLAG_BMASK) {
int bits = ctx->hflags & MIPS_HFLAG_BMASK_EXT;
switch (op) {
case POOL32A:
case POOL32B:
case POOL32I:
case POOL32C:
case ADDI32:
case ADDIU32:
case ORI32:
case XORI32:
case SLTI32:
case SLTIU32:
case ANDI32:
case JALX32:
case LBU32:
case LHU32:
case POOL32F:
case JALS32:
case BEQ32:
case BNE32:
case J32:
case JAL32:
case SB32:
case SH32:
case POOL32S:
case ADDIUPC:
case SWC132:
case SDC132:
case SD32:
case SW32:
case LB32:
case LH32:
case DADDIU32:
case LWC132:
case LDC132:
case LD32:
case LW32:
if (bits & MIPS_HFLAG_BDS16) {
generate_exception(ctx, EXCP_RI);
/* Just stop translation; the user is confused. */
ctx->bstate = BS_STOP;
return 2;
}
break;
case POOL16A:
case POOL16B:
case POOL16C:
case LWGP16:
case POOL16F:
case LBU16:
case LHU16:
case LWSP16:
case LW16:
case SB16:
case SH16:
case SWSP16:
case SW16:
case MOVE16:
case ANDI16:
case POOL16D:
case POOL16E:
case BEQZ16:
case BNEZ16:
case B16:
case LI16:
if (bits & MIPS_HFLAG_BDS32) {
generate_exception(ctx, EXCP_RI);
/* Just stop translation; the user is confused. */
ctx->bstate = BS_STOP;
return 2;
}
break;
default:
break;
}
}
switch (op) {
case POOL16A:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rs1 = mmreg(uMIPS_RS1(ctx->opcode));
int rs2 = mmreg(uMIPS_RS2(ctx->opcode));
uint32_t opc = 0;
switch (ctx->opcode & 0x1) {
case ADDU16:
opc = OPC_ADDU;
break;
case SUBU16:
opc = OPC_SUBU;
break;
}
gen_arith(ctx, opc, rd, rs1, rs2);
}
break;
case POOL16B:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rs = mmreg(uMIPS_RS(ctx->opcode));
int amount = (ctx->opcode >> 1) & 0x7;
uint32_t opc = 0;
amount = amount == 0 ? 8 : amount;
switch (ctx->opcode & 0x1) {
case SLL16:
opc = OPC_SLL;
break;
case SRL16:
opc = OPC_SRL;
break;
}
gen_shift_imm(ctx, opc, rd, rs, amount);
}
break;
case POOL16C:
gen_pool16c_insn(ctx, is_branch);
break;
case LWGP16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = 28; /* GP */
int16_t offset = SIMM(ctx->opcode, 0, 7) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case POOL16F:
if (ctx->opcode & 1) {
generate_exception(ctx, EXCP_RI);
} else {
/* MOVEP */
int enc_dest = uMIPS_RD(ctx->opcode);
int enc_rt = uMIPS_RS2(ctx->opcode);
int enc_rs = uMIPS_RS1(ctx->opcode);
int rd, rs, re, rt;
static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
rd = rd_enc[enc_dest];
re = re_enc[enc_dest];
rs = rs_rt_enc[enc_rs];
rt = rs_rt_enc[enc_rt];
gen_arith_imm(ctx, OPC_ADDIU, rd, rs, 0);
gen_arith_imm(ctx, OPC_ADDIU, re, rt, 0);
}
break;
case LBU16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4);
offset = (offset == 0xf ? -1 : offset);
gen_ld(ctx, OPC_LBU, rd, rb, offset);
}
break;
case LHU16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 1;
gen_ld(ctx, OPC_LHU, rd, rb, offset);
}
break;
case LWSP16:
{
int rd = (ctx->opcode >> 5) & 0x1f;
int rb = 29; /* SP */
int16_t offset = ZIMM(ctx->opcode, 0, 5) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case LW16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case SB16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4);
gen_st(ctx, OPC_SB, rd, rb, offset);
}
break;
case SH16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 1;
gen_st(ctx, OPC_SH, rd, rb, offset);
}
break;
case SWSP16:
{
int rd = (ctx->opcode >> 5) & 0x1f;
int rb = 29; /* SP */
int16_t offset = ZIMM(ctx->opcode, 0, 5) << 2;
gen_st(ctx, OPC_SW, rd, rb, offset);
}
break;
case SW16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 2;
gen_st(ctx, OPC_SW, rd, rb, offset);
}
break;
case MOVE16:
{
int rd = uMIPS_RD5(ctx->opcode);
int rs = uMIPS_RS5(ctx->opcode);
gen_arith_imm(ctx, OPC_ADDIU, rd, rs, 0);
}
break;
case ANDI16:
gen_andi16(ctx);
break;
case POOL16D:
switch (ctx->opcode & 0x1) {
case ADDIUS5:
gen_addius5(ctx);
break;
case ADDIUSP:
gen_addiusp(ctx);
break;
}
break;
case POOL16E:
switch (ctx->opcode & 0x1) {
case ADDIUR2:
gen_addiur2(ctx);
break;
case ADDIUR1SP:
gen_addiur1sp(ctx);
break;
}
break;
case B16:
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0,
SIMM(ctx->opcode, 0, 10) << 1);
*is_branch = 1;
break;
case BNEZ16:
case BEQZ16:
gen_compute_branch(ctx, op == BNEZ16 ? OPC_BNE : OPC_BEQ, 2,
mmreg(uMIPS_RD(ctx->opcode)),
0, SIMM(ctx->opcode, 0, 7) << 1);
*is_branch = 1;
break;
case LI16:
{
int reg = mmreg(uMIPS_RD(ctx->opcode));
int imm = ZIMM(ctx->opcode, 0, 7);
imm = (imm == 0x7f ? -1 : imm);
tcg_gen_movi_tl(cpu_gpr[reg], imm);
}
break;
case RES_20:
case RES_28:
case RES_29:
case RES_30:
case RES_31:
case RES_38:
case RES_39:
generate_exception(ctx, EXCP_RI);
break;
default:
decode_micromips32_opc (env, ctx, op, is_branch);
return 4;
}
return 2;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10513 | static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
{
int i;
int vlc = get_bits1(&q->gb);
int start = cplband[p->js_subband_start];
int end = cplband[p->subbands - 1];
int length = end - start + 1;
if (start > end)
return;
if (vlc)
for (i = 0; i < length; i++)
decouple_tab[start + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2);
else
for (i = 0; i < length; i++)
decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10520 | static int prepare_packet(AVPacket *pkt,const FailingMuxerPacketData *pkt_data, int64_t pts)
{
int ret;
FailingMuxerPacketData *data = av_malloc(sizeof(*data));
memcpy(data, pkt_data, sizeof(FailingMuxerPacketData));
ret = av_packet_from_data(pkt, (uint8_t*) data, sizeof(*data));
pkt->pts = pkt->dts = pts;
pkt->duration = 1;
return ret;
The vulnerability label is: Vulnerable |
devign_test_set_data_10539 | static void find_best_state(uint8_t best_state[256][256], const uint8_t one_state[256]){
int i,j,k,m;
double l2tab[256];
for(i=1; i<256; i++)
l2tab[i]= log2(i/256.0);
for(i=0; i<256; i++){
double best_len[256];
double p= i/256.0;
for(j=0; j<256; j++)
best_len[j]= 1<<30;
for(j=FFMAX(i-10,1); j<FFMIN(i+11,256); j++){
double occ[256]={0};
double len=0;
occ[j]=1.0;
for(k=0; k<256; k++){
double newocc[256]={0};
for(m=0; m<256; m++){
if(occ[m]){
len -=occ[m]*( p *l2tab[ m]
+ (1-p)*l2tab[256-m]);
}
}
if(len < best_len[k]){
best_len[k]= len;
best_state[i][k]= j;
}
for(m=0; m<256; m++){
if(occ[m]){
newocc[ one_state[ m]] += occ[m]* p ;
newocc[256-one_state[256-m]] += occ[m]*(1-p);
}
}
memcpy(occ, newocc, sizeof(occ));
}
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10547 | static int get_pcm(HEVCContext *s, int x, int y)
{
int log2_min_pu_size = s->sps->log2_min_pu_size;
int x_pu = x >> log2_min_pu_size;
int y_pu = y >> log2_min_pu_size;
if (x < 0 || x_pu >= s->sps->min_pu_width ||
y < 0 || y_pu >= s->sps->min_pu_height)
return 2;
return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu];
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10554 | static int h264_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
int ret;
const uint8_t *new_extradata;
int new_extradata_size;
h->flags = avctx->flags;
h->setup_finished = 0;
/* end of stream, output what is still in the buffers */
out:
if (buf_size == 0) {
H264Picture *out;
int i, out_idx;
h->cur_pic_ptr = NULL;
// FIXME factorize this with the output code below
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
!h->delayed_pic[i]->f->key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
}
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
if (out) {
ret = output_frame(h, pict, out->f);
if (ret < 0)
return ret;
*got_frame = 1;
}
return buf_index;
}
new_extradata_size = 0;
new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
&new_extradata_size);
if (new_extradata_size > 0 && new_extradata) {
ret = ff_h264_decode_extradata(new_extradata, new_extradata_size,
&h->ps, &h->is_avc, &h->nal_length_size,
avctx->err_recognition, avctx);
if (ret < 0)
return ret;
}
buf_index = decode_nal_units(h, buf, buf_size);
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
buf_size = 0;
goto out;
}
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (avctx->skip_frame >= AVDISCARD_NONREF)
return 0;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
}
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
ff_h264_field_end(h, &h->slice_ctx[0], 0);
*got_frame = 0;
if (h->next_output_pic && ((avctx->flags & AV_CODEC_FLAG_OUTPUT_CORRUPT) ||
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;
ret = output_frame(h, pict, h->next_output_pic->f);
if (ret < 0)
return ret;
*got_frame = 1;
}
}
assert(pict->buf[0] || !*got_frame);
return get_consumed_bytes(buf_index, buf_size);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10556 | static inline int16_t calc_lowcomp(int16_t a, int16_t b0, int16_t b1, uint8_t bin)
{
if (bin < 7) {
if ((b0 + 256) == b1)
a = 384;
else if (b0 > b1)
a = FFMAX(0, a - 64);
}
else if (bin < 20) {
if ((b0 + 256) == b1)
a = 320;
else if (b0 > b1)
a = FFMAX(0, a - 64);
}
else {
a = FFMAX(0, a - 128);
}
return a;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10564 | static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const x86_reg chromWidth= width>>1;
for (y=0; y<height; y+=2) {
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $8, %%mm7 \n\t" // FF,00,FF,00...
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_a", 4) \n\t"
"movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
"movq 8(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(4)
"movq %%mm0, %%mm2 \n\t" // YUYV YUYV(0)
"movq %%mm1, %%mm3 \n\t" // YUYV YUYV(4)
"psrlw $8, %%mm0 \n\t" // U0V0 U0V0(0)
"psrlw $8, %%mm1 \n\t" // U0V0 U0V0(4)
"pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(0)
"pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(4)
"packuswb %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
"packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(0)
MOVNTQ" %%mm2, (%1, %%"REG_a", 2) \n\t"
"movq 16(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(8)
"movq 24(%0, %%"REG_a", 4), %%mm2 \n\t" // YUYV YUYV(12)
"movq %%mm1, %%mm3 \n\t" // YUYV YUYV(8)
"movq %%mm2, %%mm4 \n\t" // YUYV YUYV(12)
"psrlw $8, %%mm1 \n\t" // U0V0 U0V0(8)
"psrlw $8, %%mm2 \n\t" // U0V0 U0V0(12)
"pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(8)
"pand %%mm7, %%mm4 \n\t" // Y0Y0 Y0Y0(12)
"packuswb %%mm2, %%mm1 \n\t" // UVUV UVUV(8)
"packuswb %%mm4, %%mm3 \n\t" // YYYY YYYY(8)
MOVNTQ" %%mm3, 8(%1, %%"REG_a", 2) \n\t"
"movq %%mm0, %%mm2 \n\t" // UVUV UVUV(0)
"movq %%mm1, %%mm3 \n\t" // UVUV UVUV(8)
"psrlw $8, %%mm0 \n\t" // V0V0 V0V0(0)
"psrlw $8, %%mm1 \n\t" // V0V0 V0V0(8)
"pand %%mm7, %%mm2 \n\t" // U0U0 U0U0(0)
"pand %%mm7, %%mm3 \n\t" // U0U0 U0U0(8)
"packuswb %%mm1, %%mm0 \n\t" // VVVV VVVV(0)
"packuswb %%mm3, %%mm2 \n\t" // UUUU UUUU(0)
MOVNTQ" %%mm0, (%3, %%"REG_a") \n\t"
MOVNTQ" %%mm2, (%2, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
: "memory", "%"REG_a
);
ydst += lumStride;
src += srcStride;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_a", 4) \n\t"
"movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
"movq 8(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(4)
"movq 16(%0, %%"REG_a", 4), %%mm2 \n\t" // YUYV YUYV(8)
"movq 24(%0, %%"REG_a", 4), %%mm3 \n\t" // YUYV YUYV(12)
"pand %%mm7, %%mm0 \n\t" // Y0Y0 Y0Y0(0)
"pand %%mm7, %%mm1 \n\t" // Y0Y0 Y0Y0(4)
"pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(8)
"pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(12)
"packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0)
"packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8)
MOVNTQ" %%mm0, (%1, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm2, 8(%1, %%"REG_a", 2) \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
: "memory", "%"REG_a
);
#else
long i;
for (i=0; i<chromWidth; i++) {
ydst[2*i+0] = src[4*i+0];
udst[i] = src[4*i+1];
ydst[2*i+1] = src[4*i+2];
vdst[i] = src[4*i+3];
}
ydst += lumStride;
src += srcStride;
for (i=0; i<chromWidth; i++) {
ydst[2*i+0] = src[4*i+0];
ydst[2*i+1] = src[4*i+2];
}
#endif
udst += chromStride;
vdst += chromStride;
ydst += lumStride;
src += srcStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10583 | static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
const char *name,
BlockDriverState **pbs,
AioContext **paio,
Error **errp)
{
BlockDriverState *bs;
BdrvDirtyBitmap *bitmap;
AioContext *aio_context;
if (!node) {
error_setg(errp, "Node cannot be NULL");
return NULL;
}
if (!name) {
error_setg(errp, "Bitmap name cannot be NULL");
return NULL;
}
bs = bdrv_lookup_bs(node, node, NULL);
if (!bs) {
error_setg(errp, "Node '%s' not found", node);
return NULL;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
bitmap = bdrv_find_dirty_bitmap(bs, name);
if (!bitmap) {
error_setg(errp, "Dirty bitmap '%s' not found", name);
goto fail;
}
if (pbs) {
*pbs = bs;
}
if (paio) {
*paio = aio_context;
} else {
aio_context_release(aio_context);
}
return bitmap;
fail:
aio_context_release(aio_context);
return NULL;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10594 | void ppce500_init(MachineState *machine, PPCE500Params *params)
{
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
CPUPPCState *env = NULL;
uint64_t loadaddr;
hwaddr kernel_base = -1LL;
int kernel_size = 0;
hwaddr dt_base = 0;
hwaddr initrd_base = 0;
int initrd_size = 0;
hwaddr cur_base = 0;
char *filename;
hwaddr bios_entry = 0;
target_long bios_size;
struct boot_info *boot_info;
int dt_size;
int i;
/* irq num for pin INTA, INTB, INTC and INTD is 1, 2, 3 and
* 4 respectively */
unsigned int pci_irq_nrs[PCI_NUM_PINS] = {1, 2, 3, 4};
qemu_irq **irqs, *mpic;
DeviceState *dev;
CPUPPCState *firstenv = NULL;
MemoryRegion *ccsr_addr_space;
SysBusDevice *s;
PPCE500CCSRState *ccsr;
/* Setup CPUs */
if (machine->cpu_model == NULL) {
machine->cpu_model = "e500v2_v30";
}
irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
PowerPCCPU *cpu;
CPUState *cs;
qemu_irq *input;
cpu = cpu_ppc_init(machine->cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
env = &cpu->env;
cs = CPU(cpu);
if (!firstenv) {
firstenv = env;
}
irqs[i] = irqs[0] + (i * OPENPIC_OUTPUT_NB);
input = (qemu_irq *)env->irq_inputs;
irqs[i][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
irqs[i][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
env->spr_cb[SPR_BOOKE_PIR].default_value = cs->cpu_index = i;
env->mpic_iack = params->ccsrbar_base +
MPC8544_MPIC_REGS_OFFSET + 0xa0;
ppc_booke_timers_init(cpu, 400000000, PPC_TIMER_E500);
/* Register reset handler */
if (!i) {
/* Primary CPU */
struct boot_info *boot_info;
boot_info = g_malloc0(sizeof(struct boot_info));
qemu_register_reset(ppce500_cpu_reset, cpu);
env->load_info = boot_info;
} else {
/* Secondary CPUs */
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
}
}
env = firstenv;
/* Fixup Memory size on a alignment boundary */
ram_size &= ~(RAM_SIZES_ALIGN - 1);
machine->ram_size = ram_size;
/* Register Memory */
memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0, ram);
dev = qdev_create(NULL, "e500-ccsr");
object_property_add_child(qdev_get_machine(), "e500-ccsr",
OBJECT(dev), NULL);
qdev_init_nofail(dev);
ccsr = CCSR(dev);
ccsr_addr_space = &ccsr->ccsr_space;
memory_region_add_subregion(address_space_mem, params->ccsrbar_base,
ccsr_addr_space);
mpic = ppce500_init_mpic(params, ccsr_addr_space, irqs);
/* Serial */
if (serial_hds[0]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[0], DEVICE_BIG_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[1], DEVICE_BIG_ENDIAN);
}
/* General Utility device */
dev = qdev_create(NULL, "mpc8544-guts");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,
sysbus_mmio_get_region(s, 0));
/* PCI */
dev = qdev_create(NULL, "e500-pcihost");
qdev_prop_set_uint32(dev, "first_slot", params->pci_first_slot);
qdev_prop_set_uint32(dev, "first_pin_irq", pci_irq_nrs[0]);
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
for (i = 0; i < PCI_NUM_PINS; i++) {
sysbus_connect_irq(s, i, mpic[pci_irq_nrs[i]]);
}
memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,
sysbus_mmio_get_region(s, 0));
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pci_bus)
printf("couldn't create PCI controller!\n");
if (pci_bus) {
/* Register network interfaces. */
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "virtio", NULL);
}
}
/* Register spinning region */
sysbus_create_simple("e500-spin", params->spin_base, NULL);
if (cur_base < (32 * 1024 * 1024)) {
/* u-boot occupies memory up to 32MB, so load blobs above */
cur_base = (32 * 1024 * 1024);
}
if (params->has_mpc8xxx_gpio) {
qemu_irq poweroff_irq;
dev = qdev_create(NULL, "mpc8xxx_gpio");
s = SYS_BUS_DEVICE(dev);
qdev_init_nofail(dev);
sysbus_connect_irq(s, 0, mpic[MPC8XXX_GPIO_IRQ]);
memory_region_add_subregion(ccsr_addr_space, MPC8XXX_GPIO_OFFSET,
sysbus_mmio_get_region(s, 0));
/* Power Off GPIO at Pin 0 */
poweroff_irq = qemu_allocate_irq(ppce500_power_off, NULL, 0);
qdev_connect_gpio_out(dev, 0, poweroff_irq);
}
/* Platform Bus Device */
if (params->has_platform_bus) {
dev = qdev_create(NULL, TYPE_PLATFORM_BUS_DEVICE);
dev->id = TYPE_PLATFORM_BUS_DEVICE;
qdev_prop_set_uint32(dev, "num_irqs", params->platform_bus_num_irqs);
qdev_prop_set_uint32(dev, "mmio_size", params->platform_bus_size);
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
for (i = 0; i < params->platform_bus_num_irqs; i++) {
int irqn = params->platform_bus_first_irq + i;
sysbus_connect_irq(s, i, mpic[irqn]);
}
memory_region_add_subregion(address_space_mem,
params->platform_bus_base,
sysbus_mmio_get_region(s, 0));
}
/* Load kernel. */
if (machine->kernel_filename) {
kernel_base = cur_base;
kernel_size = load_image_targphys(machine->kernel_filename,
cur_base,
ram_size - cur_base);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
machine->kernel_filename);
exit(1);
}
cur_base += kernel_size;
}
/* Load initrd. */
if (machine->initrd_filename) {
initrd_base = (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK;
initrd_size = load_image_targphys(machine->initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
machine->initrd_filename);
exit(1);
}
cur_base = initrd_base + initrd_size;
}
/*
* Smart firmware defaults ahead!
*
* We follow the following table to select which payload we execute.
*
* -kernel | -bios | payload
* ---------+-------+---------
* N | Y | u-boot
* N | N | u-boot
* Y | Y | u-boot
* Y | N | kernel
*
* This ensures backwards compatibility with how we used to expose
* -kernel to users but allows them to run through u-boot as well.
*/
if (bios_name == NULL) {
if (machine->kernel_filename) {
bios_name = machine->kernel_filename;
} else {
bios_name = "u-boot.e500";
}
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
1, ELF_MACHINE, 0);
if (bios_size < 0) {
/*
* Hrm. No ELF image? Try a uImage, maybe someone is giving us an
* ePAPR compliant kernel
*/
kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL,
NULL, NULL);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load firmware '%s'\n", filename);
exit(1);
}
}
/* Reserve space for dtb */
dt_base = (loadaddr + bios_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
dt_size = ppce500_prep_device_tree(machine, params, dt_base,
initrd_base, initrd_size,
kernel_base, kernel_size);
if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
assert(dt_size < DTB_MAX_SIZE);
boot_info = env->load_info;
boot_info->entry = bios_entry;
boot_info->dt_base = dt_base;
boot_info->dt_size = dt_size;
if (kvm_enabled()) {
kvmppc_init();
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10609 | static av_always_inline int coeff_abs_level_remaining_decode(HEVCContext *s, int rc_rice_param)
{
int prefix = 0;
int suffix = 0;
int last_coeff_abs_level_remaining;
int i;
while (prefix < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc))
prefix++;
if (prefix < 3) {
for (i = 0; i < rc_rice_param; i++)
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
last_coeff_abs_level_remaining = (prefix << rc_rice_param) + suffix;
} else {
int prefix_minus3 = prefix - 3;
if (prefix == CABAC_MAX_BIN) {
av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", prefix);
return 0;
}
for (i = 0; i < prefix_minus3 + rc_rice_param; i++)
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
last_coeff_abs_level_remaining = (((1 << prefix_minus3) + 3 - 1)
<< rc_rice_param) + suffix;
}
return last_coeff_abs_level_remaining;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10620 | static int segment_hls_window(AVFormatContext *s, int last)
{
SegmentContext *seg = s->priv_data;
int i, ret = 0;
char buf[1024];
if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
avio_printf(seg->pb, "#EXTM3U\n");
avio_printf(seg->pb, "#EXT-X-VERSION:3\n");
avio_printf(seg->pb, "#EXT-X-TARGETDURATION:%d\n", (int)seg->time);
avio_printf(seg->pb, "#EXT-X-MEDIA-SEQUENCE:%d\n",
FFMAX(0, seg->number - seg->size));
av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%d\n",
FFMAX(0, seg->number - seg->size));
for (i = FFMAX(0, seg->number - seg->size);
i < seg->number; i++) {
avio_printf(seg->pb, "#EXTINF:%d,\n", (int)seg->time);
if (seg->entry_prefix) {
avio_printf(seg->pb, "%s", seg->entry_prefix);
}
ret = av_get_frame_filename(buf, sizeof(buf), s->filename, i);
if (ret < 0) {
ret = AVERROR(EINVAL);
goto fail;
}
avio_printf(seg->pb, "%s\n", buf);
}
if (last)
avio_printf(seg->pb, "#EXT-X-ENDLIST\n");
fail:
avio_closep(&seg->pb);
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10640 | static inline int cris_addc_pi_m(int a, int **b)
{
asm volatile ("addc [%1+], %0\n" : "+r" (a), "+b" (*b));
return a;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10648 | static void vmgenid_query_monitor_test(void)
{
QemuUUID expected, measured;
gchar *cmd;
g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);
cmd = g_strdup_printf("-machine accel=tcg -device vmgenid,id=testvgid,"
"guid=%s", VGID_GUID);
qtest_start(cmd);
/* Read the GUID via the monitor */
read_guid_from_monitor(&measured);
g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) == 0);
qtest_quit(global_qtest);
g_free(cmd);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10665 | static int decode_frame_byterun1(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
IffContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL;
const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0;
const uint8_t *buf_end = buf+buf_size;
int y, plane, res;
if ((res = extract_header(avctx, avpkt)) < 0)
return res;
if (s->init) {
if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return res;
}
} else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return res;
} else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) {
if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
return res;
}
s->init = 1;
if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memset(row, 0, avctx->width);
for (plane = 0; plane < s->bpp; plane++) {
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
decodeplane8(row, s->planebuf, s->planesize, plane);
}
}
} else if (s->ham) { // HAM to PIX_FMT_BGR32
for (y = 0; y < avctx->height ; y++) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
memset(s->ham_buf, 0, avctx->width);
for (plane = 0; plane < s->bpp; plane++) {
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
decodeplane8(s->ham_buf, s->planebuf, s->planesize, plane);
}
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else { //PIX_FMT_BGR32
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
memset(row, 0, avctx->width << 2);
for (plane = 0; plane < s->bpp; plane++) {
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
decodeplane32((uint32_t *) row, s->planebuf, s->planesize, plane);
}
}
}
} else if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) { // IFF-PBM
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
buf += decode_byterun(row, avctx->width, buf, buf_end);
}
} else { // IFF-PBM: HAM to PIX_FMT_BGR32
for (y = 0; y < avctx->height ; y++) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end);
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, avctx->width);
}
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10670 | int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
const int big_mb_num= s->mb_stride*(s->mb_height+1) + 1; //the +1 is needed so memset(,,stride*height) does not sig11
const int mb_array_size= s->mb_stride*s->mb_height;
const int b8_array_size= s->b8_stride*s->mb_height*2;
const int b4_array_size= s->b4_stride*s->mb_height*4;
int i;
if(shared){
assert(pic->data[0]);
assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
pic->type= FF_BUFFER_TYPE_SHARED;
}else{
int r;
assert(!pic->data[0]);
r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
if(r<0 || !pic->age || !pic->type || !pic->data[0]){
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
return -1;
}
if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
return -1;
}
if(pic->linesize[1] != pic->linesize[2]){
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
return -1;
}
s->linesize = pic->linesize[0];
s->uvlinesize= pic->linesize[1];
}
if(pic->qscale_table==NULL){
if (s->encoding) {
CHECKED_ALLOCZ(pic->mb_var , mb_array_size * sizeof(int16_t))
CHECKED_ALLOCZ(pic->mc_mb_var, mb_array_size * sizeof(int16_t))
CHECKED_ALLOCZ(pic->mb_mean , mb_array_size * sizeof(int8_t))
}
CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check
CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t))
CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(uint32_t))
pic->mb_type= pic->mb_type_base + s->mb_stride+1;
if(s->out_format == FMT_H264){
for(i=0; i<2; i++){
CHECKED_ALLOCZ(pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t))
pic->motion_val[i]= pic->motion_val_base[i]+4;
CHECKED_ALLOCZ(pic->ref_index[i], b8_array_size * sizeof(uint8_t))
}
pic->motion_subsample_log2= 2;
}else if(s->out_format == FMT_H263 || s->encoding || (s->avctx->debug&FF_DEBUG_MV) || (s->avctx->debug_mv)){
for(i=0; i<2; i++){
CHECKED_ALLOCZ(pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t))
pic->motion_val[i]= pic->motion_val_base[i]+4;
CHECKED_ALLOCZ(pic->ref_index[i], b8_array_size * sizeof(uint8_t))
}
pic->motion_subsample_log2= 3;
}
if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
CHECKED_ALLOCZ(pic->dct_coeff, 64 * mb_array_size * sizeof(DCTELEM)*6)
}
pic->qstride= s->mb_stride;
CHECKED_ALLOCZ(pic->pan_scan , 1 * sizeof(AVPanScan))
}
/* It might be nicer if the application would keep track of these
* but it would require an API change. */
memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
s->prev_pict_types[0]= s->pict_type;
if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == B_TYPE)
pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
return 0;
fail: //for the CHECKED_ALLOCZ macro
return -1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10671 | static int decode_pic_hdr(IVI5DecContext *ctx, AVCodecContext *avctx)
{
if (get_bits(&ctx->gb, 5) != 0x1F) {
av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
return -1;
ctx->prev_frame_type = ctx->frame_type;
ctx->frame_type = get_bits(&ctx->gb, 3);
if (ctx->frame_type >= 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
return -1;
ctx->frame_num = get_bits(&ctx->gb, 8);
if (ctx->frame_type == FRAMETYPE_INTRA) {
ctx->gop_invalid = 1;
if (decode_gop_header(ctx, avctx))
return -1;
ctx->gop_invalid = 0;
if (ctx->frame_type != FRAMETYPE_NULL) {
ctx->frame_flags = get_bits(&ctx->gb, 8);
ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits_long(&ctx->gb, 24) : 0;
ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
/* skip unknown extension if any */
if (ctx->frame_flags & 0x20)
skip_hdr_extension(&ctx->gb); /* XXX: untested */
/* decode macroblock huffman codebook */
if (ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40, IVI_MB_HUFF, &ctx->mb_vlc, avctx))
return -1;
skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
align_get_bits(&ctx->gb);
return 0;
The vulnerability label is: Vulnerable |
devign_test_set_data_10672 | static int mpegts_write_header(AVFormatContext *s)
{
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st;
MpegTSService *service;
AVStream *st, *pcr_st = NULL;
AVDictionaryEntry *title, *provider;
int i, j;
const char *service_name;
const char *provider_name;
int *pids;
int ret;
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = 0;
// round up to a whole number of TS packets
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
ts->tsid = ts->transport_stream_id;
ts->onid = ts->original_network_id;
/* allocate a single DVB service */
title = av_dict_get(s->metadata, "service_name", NULL, 0);
if (!title)
title = av_dict_get(s->metadata, "title", NULL, 0);
service_name = title ? title->value : DEFAULT_SERVICE_NAME;
provider = av_dict_get(s->metadata, "service_provider", NULL, 0);
provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
service = mpegts_add_service(ts, ts->service_id,
provider_name, service_name);
if (!service)
return AVERROR(ENOMEM);
service->pmt.write_packet = section_write_packet;
service->pmt.opaque = s;
service->pmt.cc = 15;
ts->pat.pid = PAT_PID;
/* Initialize at 15 so that it wraps and is equal to 0 for the
* first packet we write. */
ts->pat.cc = 15;
ts->pat.write_packet = section_write_packet;
ts->pat.opaque = s;
ts->sdt.pid = SDT_PID;
ts->sdt.cc = 15;
ts->sdt.write_packet = section_write_packet;
ts->sdt.opaque = s;
pids = av_malloc_array(s->nb_streams, sizeof(*pids));
if (!pids) {
ret = AVERROR(ENOMEM);
goto fail;
}
/* assign pids to each stream */
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
ts_st = av_mallocz(sizeof(MpegTSWriteStream));
if (!ts_st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->priv_data = ts_st;
ts_st->user_tb = st->time_base;
avpriv_set_pts_info(st, 33, 1, 90000);
ts_st->payload = av_mallocz(ts->pes_payload_size);
if (!ts_st->payload) {
ret = AVERROR(ENOMEM);
goto fail;
}
ts_st->service = service;
/* MPEG pid values < 16 are reserved. Applications which set st->id in
* this range are assigned a calculated pid. */
if (st->id < 16) {
ts_st->pid = ts->start_pid + i;
} else if (st->id < 0x1FFF) {
ts_st->pid = st->id;
} else {
av_log(s, AV_LOG_ERROR,
"Invalid stream id %d, must be less than 8191\n", st->id);
ret = AVERROR(EINVAL);
goto fail;
}
if (ts_st->pid == service->pmt.pid) {
av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
for (j = 0; j < i; j++) {
if (pids[j] == ts_st->pid) {
av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
ret = AVERROR(EINVAL);
goto fail;
}
}
pids[i] = ts_st->pid;
ts_st->payload_pts = AV_NOPTS_VALUE;
ts_st->payload_dts = AV_NOPTS_VALUE;
ts_st->first_pts_check = 1;
ts_st->cc = 15;
/* update PCR pid by using the first video stream */
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
service->pcr_pid == 0x1fff) {
service->pcr_pid = ts_st->pid;
pcr_st = st;
}
if (st->codec->codec_id == AV_CODEC_ID_AAC &&
st->codec->extradata_size > 0) {
AVStream *ast;
ts_st->amux = avformat_alloc_context();
if (!ts_st->amux) {
ret = AVERROR(ENOMEM);
goto fail;
}
ts_st->amux->oformat =
av_guess_format((ts->flags & MPEGTS_FLAG_AAC_LATM) ? "latm" : "adts",
NULL, NULL);
if (!ts_st->amux->oformat) {
ret = AVERROR(EINVAL);
goto fail;
}
if (!(ast = avformat_new_stream(ts_st->amux, NULL))) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = avcodec_copy_context(ast->codec, st->codec);
if (ret != 0)
goto fail;
ast->time_base = st->time_base;
ret = avformat_write_header(ts_st->amux, NULL);
if (ret < 0)
goto fail;
}
if (st->codec->codec_id == AV_CODEC_ID_OPUS) {
ts_st->opus_pending_trim_start = st->codec->initial_padding * 48000 / st->codec->sample_rate;
}
}
av_freep(&pids);
/* if no video stream, use the first stream as PCR */
if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
pcr_st = s->streams[0];
ts_st = pcr_st->priv_data;
service->pcr_pid = ts_st->pid;
} else
ts_st = pcr_st->priv_data;
if (ts->mux_rate > 1) {
service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) /
(TS_PACKET_SIZE * 8 * 1000);
ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) /
(TS_PACKET_SIZE * 8 * 1000);
ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) /
(TS_PACKET_SIZE * 8 * 1000);
if (ts->copyts < 1)
ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
} else {
/* Arbitrary values, PAT/PMT will also be written on video key frames */
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
if (pcr_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (!pcr_st->codec->frame_size) {
av_log(s, AV_LOG_WARNING, "frame size not set\n");
service->pcr_packet_period =
pcr_st->codec->sample_rate / (10 * 512);
} else {
service->pcr_packet_period =
pcr_st->codec->sample_rate / (10 * pcr_st->codec->frame_size);
}
} else {
// max delta PCR 0.1s
// TODO: should be avg_frame_rate
service->pcr_packet_period =
ts_st->user_tb.den / (10 * ts_st->user_tb.num);
}
if (!service->pcr_packet_period)
service->pcr_packet_period = 1;
}
ts->last_pat_ts = AV_NOPTS_VALUE;
ts->last_sdt_ts = AV_NOPTS_VALUE;
// The user specified a period, use only it
if (ts->pat_period < INT_MAX/2) {
ts->pat_packet_period = INT_MAX;
}
if (ts->sdt_period < INT_MAX/2) {
ts->sdt_packet_period = INT_MAX;
}
// output a PCR as soon as possible
service->pcr_packet_count = service->pcr_packet_period;
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
if (ts->mux_rate == 1)
av_log(s, AV_LOG_VERBOSE, "muxrate VBR, ");
else
av_log(s, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate);
av_log(s, AV_LOG_VERBOSE,
"pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\n",
service->pcr_packet_period,
ts->sdt_packet_period, ts->pat_packet_period);
if (ts->m2ts_mode == -1) {
if (av_match_ext(s->filename, "m2ts")) {
ts->m2ts_mode = 1;
} else {
ts->m2ts_mode = 0;
}
}
return 0;
fail:
av_freep(&pids);
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
ts_st = st->priv_data;
if (ts_st) {
av_freep(&ts_st->payload);
if (ts_st->amux) {
avformat_free_context(ts_st->amux);
ts_st->amux = NULL;
}
}
av_freep(&st->priv_data);
}
for (i = 0; i < ts->nb_services; i++) {
service = ts->services[i];
av_freep(&service->provider_name);
av_freep(&service->name);
av_freep(&service);
}
av_freep(&ts->services);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10699 | void dct32(INTFLOAT *out, const INTFLOAT *tab)
{
INTFLOAT tmp0, tmp1;
INTFLOAT val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 ,
val8 , val9 , val10, val11, val12, val13, val14, val15,
val16, val17, val18, val19, val20, val21, val22, val23,
val24, val25, val26, val27, val28, val29, val30, val31;
/* pass 1 */
BF0( 0, 31, COS0_0 , 1);
BF0(15, 16, COS0_15, 5);
/* pass 2 */
BF( 0, 15, COS1_0 , 1);
BF(16, 31,-COS1_0 , 1);
/* pass 1 */
BF0( 7, 24, COS0_7 , 1);
BF0( 8, 23, COS0_8 , 1);
/* pass 2 */
BF( 7, 8, COS1_7 , 4);
BF(23, 24,-COS1_7 , 4);
/* pass 3 */
BF( 0, 7, COS2_0 , 1);
BF( 8, 15,-COS2_0 , 1);
BF(16, 23, COS2_0 , 1);
BF(24, 31,-COS2_0 , 1);
/* pass 1 */
BF0( 3, 28, COS0_3 , 1);
BF0(12, 19, COS0_12, 2);
/* pass 2 */
BF( 3, 12, COS1_3 , 1);
BF(19, 28,-COS1_3 , 1);
/* pass 1 */
BF0( 4, 27, COS0_4 , 1);
BF0(11, 20, COS0_11, 2);
/* pass 2 */
BF( 4, 11, COS1_4 , 1);
BF(20, 27,-COS1_4 , 1);
/* pass 3 */
BF( 3, 4, COS2_3 , 3);
BF(11, 12,-COS2_3 , 3);
BF(19, 20, COS2_3 , 3);
BF(27, 28,-COS2_3 , 3);
/* pass 4 */
BF( 0, 3, COS3_0 , 1);
BF( 4, 7,-COS3_0 , 1);
BF( 8, 11, COS3_0 , 1);
BF(12, 15,-COS3_0 , 1);
BF(16, 19, COS3_0 , 1);
BF(20, 23,-COS3_0 , 1);
BF(24, 27, COS3_0 , 1);
BF(28, 31,-COS3_0 , 1);
/* pass 1 */
BF0( 1, 30, COS0_1 , 1);
BF0(14, 17, COS0_14, 3);
/* pass 2 */
BF( 1, 14, COS1_1 , 1);
BF(17, 30,-COS1_1 , 1);
/* pass 1 */
BF0( 6, 25, COS0_6 , 1);
BF0( 9, 22, COS0_9 , 1);
/* pass 2 */
BF( 6, 9, COS1_6 , 2);
BF(22, 25,-COS1_6 , 2);
/* pass 3 */
BF( 1, 6, COS2_1 , 1);
BF( 9, 14,-COS2_1 , 1);
BF(17, 22, COS2_1 , 1);
BF(25, 30,-COS2_1 , 1);
/* pass 1 */
BF0( 2, 29, COS0_2 , 1);
BF0(13, 18, COS0_13, 3);
/* pass 2 */
BF( 2, 13, COS1_2 , 1);
BF(18, 29,-COS1_2 , 1);
/* pass 1 */
BF0( 5, 26, COS0_5 , 1);
BF0(10, 21, COS0_10, 1);
/* pass 2 */
BF( 5, 10, COS1_5 , 2);
BF(21, 26,-COS1_5 , 2);
/* pass 3 */
BF( 2, 5, COS2_2 , 1);
BF(10, 13,-COS2_2 , 1);
BF(18, 21, COS2_2 , 1);
BF(26, 29,-COS2_2 , 1);
/* pass 4 */
BF( 1, 2, COS3_1 , 2);
BF( 5, 6,-COS3_1 , 2);
BF( 9, 10, COS3_1 , 2);
BF(13, 14,-COS3_1 , 2);
BF(17, 18, COS3_1 , 2);
BF(21, 22,-COS3_1 , 2);
BF(25, 26, COS3_1 , 2);
BF(29, 30,-COS3_1 , 2);
/* pass 5 */
BF1( 0, 1, 2, 3);
BF2( 4, 5, 6, 7);
BF1( 8, 9, 10, 11);
BF2(12, 13, 14, 15);
BF1(16, 17, 18, 19);
BF2(20, 21, 22, 23);
BF1(24, 25, 26, 27);
BF2(28, 29, 30, 31);
/* pass 6 */
ADD( 8, 12);
ADD(12, 10);
ADD(10, 14);
ADD(14, 9);
ADD( 9, 13);
ADD(13, 11);
ADD(11, 15);
out[ 0] = val0;
out[16] = val1;
out[ 8] = val2;
out[24] = val3;
out[ 4] = val4;
out[20] = val5;
out[12] = val6;
out[28] = val7;
out[ 2] = val8;
out[18] = val9;
out[10] = val10;
out[26] = val11;
out[ 6] = val12;
out[22] = val13;
out[14] = val14;
out[30] = val15;
ADD(24, 28);
ADD(28, 26);
ADD(26, 30);
ADD(30, 25);
ADD(25, 29);
ADD(29, 27);
ADD(27, 31);
out[ 1] = val16 + val24;
out[17] = val17 + val25;
out[ 9] = val18 + val26;
out[25] = val19 + val27;
out[ 5] = val20 + val28;
out[21] = val21 + val29;
out[13] = val22 + val30;
out[29] = val23 + val31;
out[ 3] = val24 + val20;
out[19] = val25 + val21;
out[11] = val26 + val22;
out[27] = val27 + val23;
out[ 7] = val28 + val18;
out[23] = val29 + val19;
out[15] = val30 + val17;
out[31] = val31;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10721 | static inline void gen_op_movl_seg_T0_vm(int seg_reg)
{
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xffff);
tcg_gen_st32_tl(cpu_T[0], cpu_env,
offsetof(CPUX86State,segs[seg_reg].selector));
tcg_gen_shli_tl(cpu_T[0], cpu_T[0], 4);
tcg_gen_st_tl(cpu_T[0], cpu_env,
offsetof(CPUX86State,segs[seg_reg].base));
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10723 | static void vc1_v_overlap_c(uint8_t* src, int stride)
{
int i;
int a, b, c, d;
int d1, d2;
int rnd = 1;
for(i = 0; i < 8; i++) {
a = src[-2*stride];
b = src[-stride];
c = src[0];
d = src[stride];
d1 = (a - d + 3 + rnd) >> 3;
d2 = (a - d + b - c + 4 - rnd) >> 3;
src[-2*stride] = a - d1;
src[-stride] = b - d2;
src[0] = c + d2;
src[stride] = d + d1;
src++;
rnd = !rnd;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10727 | void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
QGuestAllocator *alloc, uint16_t entry)
{
uint16_t vector;
uint32_t control;
void *addr;
g_assert(d->pdev->msix_enabled);
addr = d->pdev->msix_table + (entry * 16);
g_assert_cmpint(entry, >=, 0);
g_assert_cmpint(entry, <, qpci_msix_table_size(d->pdev));
d->config_msix_entry = entry;
d->config_msix_data = 0x12345678;
d->config_msix_addr = guest_alloc(alloc, 4);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_LOWER_ADDR,
d->config_msix_addr & ~0UL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_UPPER_ADDR,
(d->config_msix_addr >> 32) & ~0UL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_DATA, d->config_msix_data);
control = qpci_io_readl(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL,
control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);
qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_CONFIG_VECTOR, entry);
vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_CONFIG_VECTOR);
g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10730 | static void gen_rdhwr(DisasContext *ctx, int rt, int rd)
{
TCGv t0;
#if !defined(CONFIG_USER_ONLY)
/* The Linux kernel will emulate rdhwr if it's not supported natively.
Therefore only check the ISA in system mode. */
check_insn(ctx, ISA_MIPS32R2);
#endif
t0 = tcg_temp_new();
switch (rd) {
case 0:
save_cpu_state(ctx, 1);
gen_helper_rdhwr_cpunum(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 1:
save_cpu_state(ctx, 1);
gen_helper_rdhwr_synci_step(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 2:
save_cpu_state(ctx, 1);
gen_helper_rdhwr_cc(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 3:
save_cpu_state(ctx, 1);
gen_helper_rdhwr_ccres(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 29:
#if defined(CONFIG_USER_ONLY)
tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUMIPSState, tls_value));
gen_store_gpr(t0, rt);
break;
#else
/* XXX: Some CPUs implement this in hardware.
Not supported yet. */
#endif
default: /* Invalid */
MIPS_INVAL("rdhwr");
generate_exception(ctx, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10735 | static void usb_msd_realize_bot(USBDevice *dev, Error **errp)
{
MSDState *s = DO_UPCAST(MSDState, dev, dev);
usb_desc_create_serial(dev);
usb_desc_init(dev);
scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
&usb_msd_scsi_info_bot, NULL);
s->bus.qbus.allow_hotplug = 0;
usb_msd_handle_reset(dev);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10738 | static int decode_slice_header(FFV1Context *f, FFV1Context *fs)
{
RangeCoder *c = &fs->c;
uint8_t state[CONTEXT_SIZE];
unsigned ps, i, context_count;
memset(state, 128, sizeof(state));
if (fs->ac > 1) {
for (i = 1; i < 256; i++) {
fs->c.one_state[i] = f->state_transition[i];
fs->c.zero_state[256 - i] = 256 - fs->c.one_state[i];
}
}
fs->slice_x = get_symbol(c, state, 0) * f->width;
fs->slice_y = get_symbol(c, state, 0) * f->height;
fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x;
fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
fs->slice_x /= f->num_h_slices;
fs->slice_y /= f->num_v_slices;
fs->slice_width = fs->slice_width / f->num_h_slices - fs->slice_x;
fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y;
if ((unsigned)fs->slice_width > f->width ||
(unsigned)fs->slice_height > f->height)
return AVERROR_INVALIDDATA;
if ((unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width ||
(unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
return AVERROR_INVALIDDATA;
for (i = 0; i < f->plane_count; i++) {
PlaneContext *const p = &fs->plane[i];
int idx = get_symbol(c, state, 0);
if (idx > (unsigned)f->quant_table_count) {
av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
return AVERROR_INVALIDDATA;
}
p->quant_table_index = idx;
memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table));
context_count = f->context_count[idx];
if (p->context_count < context_count) {
av_freep(&p->state);
av_freep(&p->vlc_state);
}
p->context_count = context_count;
}
ps = get_symbol(c, state, 0);
if (ps == 1) {
f->cur->interlaced_frame = 1;
f->cur->top_field_first = 1;
} else if (ps == 2) {
f->cur->interlaced_frame = 1;
f->cur->top_field_first = 0;
} else if (ps == 3) {
f->cur->interlaced_frame = 0;
}
f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0);
f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0);
if (av_image_check_sar(f->width, f->height,
f->cur->sample_aspect_ratio) < 0) {
av_log(f->avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
f->cur->sample_aspect_ratio.num,
f->cur->sample_aspect_ratio.den);
f->cur->sample_aspect_ratio = (AVRational){ 0, 1 };
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10741 | int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn,
sizeof(diag_501), 0) ||
cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)diag_501,
sizeof(diag_501), 1)) {
return -EINVAL;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10744 | static inline uint8_t *ram_chunk_start(const RDMALocalBlock *rdma_ram_block,
uint64_t i)
{
return (uint8_t *) (((uintptr_t) rdma_ram_block->local_host_addr)
+ (i << RDMA_REG_CHUNK_SHIFT));
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10750 | static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
int channels)
{
ALACContext *alac = avctx->priv_data;
int has_size, bps, is_compressed, decorr_shift, decorr_left_weight, ret;
uint32_t output_samples;
int i, ch;
skip_bits(&alac->gb, 4); /* element instance tag */
skip_bits(&alac->gb, 12); /* unused header bits */
/* the number of output samples is stored in the frame */
has_size = get_bits1(&alac->gb);
alac->extra_bits = get_bits(&alac->gb, 2) << 3;
bps = alac->sample_size - alac->extra_bits + channels - 1;
if (bps > 32) {
av_log(avctx, AV_LOG_ERROR, "bps is unsupported: %d\n", bps);
return AVERROR_PATCHWELCOME;
}
/* whether the frame is compressed */
is_compressed = !get_bits1(&alac->gb);
if (has_size)
output_samples = get_bits_long(&alac->gb, 32);
else
output_samples = alac->max_samples_per_frame;
if (!output_samples || output_samples > alac->max_samples_per_frame) {
av_log(avctx, AV_LOG_ERROR, "invalid samples per frame: %d\n",
output_samples);
return AVERROR_INVALIDDATA;
}
if (!alac->nb_samples) {
/* get output buffer */
alac->frame.nb_samples = output_samples;
if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
} else if (output_samples != alac->nb_samples) {
av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %u != %d\n",
output_samples, alac->nb_samples);
return AVERROR_INVALIDDATA;
}
alac->nb_samples = output_samples;
if (alac->direct_output) {
for (ch = 0; ch < channels; ch++)
alac->output_samples_buffer[ch] = (int32_t *)alac->frame.extended_data[ch_index + ch];
}
if (is_compressed) {
int16_t lpc_coefs[2][32];
int lpc_order[2];
int prediction_type[2];
int lpc_quant[2];
int rice_history_mult[2];
decorr_shift = get_bits(&alac->gb, 8);
decorr_left_weight = get_bits(&alac->gb, 8);
for (ch = 0; ch < channels; ch++) {
prediction_type[ch] = get_bits(&alac->gb, 4);
lpc_quant[ch] = get_bits(&alac->gb, 4);
rice_history_mult[ch] = get_bits(&alac->gb, 3);
lpc_order[ch] = get_bits(&alac->gb, 5);
/* read the predictor table */
for (i = lpc_order[ch] - 1; i >= 0; i--)
lpc_coefs[ch][i] = get_sbits(&alac->gb, 16);
}
if (alac->extra_bits) {
for (i = 0; i < alac->nb_samples; i++) {
if(get_bits_left(&alac->gb) <= 0)
return -1;
for (ch = 0; ch < channels; ch++)
alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits);
}
}
for (ch = 0; ch < channels; ch++) {
int ret=rice_decompress(alac, alac->predict_error_buffer[ch],
alac->nb_samples, bps,
rice_history_mult[ch] * alac->rice_history_mult / 4);
if(ret<0)
return ret;
/* adaptive FIR filter */
if (prediction_type[ch] == 15) {
/* Prediction type 15 runs the adaptive FIR twice.
* The first pass uses the special-case coef_num = 31, while
* the second pass uses the coefs from the bitstream.
*
* However, this prediction type is not currently used by the
* reference encoder.
*/
lpc_prediction(alac->predict_error_buffer[ch],
alac->predict_error_buffer[ch],
alac->nb_samples, bps, NULL, 31, 0);
} else if (prediction_type[ch] > 0) {
av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\n",
prediction_type[ch]);
}
lpc_prediction(alac->predict_error_buffer[ch],
alac->output_samples_buffer[ch], alac->nb_samples,
bps, lpc_coefs[ch], lpc_order[ch], lpc_quant[ch]);
}
} else {
/* not compressed, easy case */
for (i = 0; i < alac->nb_samples; i++) {
if(get_bits_left(&alac->gb) <= 0)
return -1;
for (ch = 0; ch < channels; ch++) {
alac->output_samples_buffer[ch][i] =
get_sbits_long(&alac->gb, alac->sample_size);
}
}
alac->extra_bits = 0;
decorr_shift = 0;
decorr_left_weight = 0;
}
if (channels == 2 && decorr_left_weight) {
decorrelate_stereo(alac->output_samples_buffer, alac->nb_samples,
decorr_shift, decorr_left_weight);
}
if (alac->extra_bits) {
append_extra_bits(alac->output_samples_buffer, alac->extra_bits_buffer,
alac->extra_bits, channels, alac->nb_samples);
}
if(av_sample_fmt_is_planar(avctx->sample_fmt)) {
switch(alac->sample_size) {
case 16: {
for (ch = 0; ch < channels; ch++) {
int16_t *outbuffer = (int16_t *)alac->frame.extended_data[ch_index + ch];
for (i = 0; i < alac->nb_samples; i++)
*outbuffer++ = alac->output_samples_buffer[ch][i];
}}
break;
case 24: {
for (ch = 0; ch < channels; ch++) {
for (i = 0; i < alac->nb_samples; i++)
alac->output_samples_buffer[ch][i] <<= 8;
}}
break;
}
}else{
switch(alac->sample_size) {
case 16: {
int16_t *outbuffer = ((int16_t *)alac->frame.extended_data[0]) + ch_index;
for (i = 0; i < alac->nb_samples; i++) {
for (ch = 0; ch < channels; ch++)
*outbuffer++ = alac->output_samples_buffer[ch][i];
outbuffer += alac->channels - channels;
}
}
break;
case 24: {
int32_t *outbuffer = ((int32_t *)alac->frame.extended_data[0]) + ch_index;
for (i = 0; i < alac->nb_samples; i++) {
for (ch = 0; ch < channels; ch++)
*outbuffer++ = alac->output_samples_buffer[ch][i] << 8;
outbuffer += alac->channels - channels;
}
}
break;
case 32: {
int32_t *outbuffer = ((int32_t *)alac->frame.extended_data[0]) + ch_index;
for (i = 0; i < alac->nb_samples; i++) {
for (ch = 0; ch < channels; ch++)
*outbuffer++ = alac->output_samples_buffer[ch][i];
outbuffer += alac->channels - channels;
}
}
break;
}
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10765 | static av_always_inline float quantize_and_encode_band_cost_template(
struct AACEncContext *s,
PutBitContext *pb, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits, int BT_ZERO, int BT_UNSIGNED,
int BT_PAIR, int BT_ESC)
{
const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float CLIPPED_ESCAPE = 165140.0f*IQ;
int i, j, k;
float cost = 0;
const int dim = BT_PAIR ? 2 : 4;
int resbits = 0;
const float Q34 = sqrtf(Q * sqrtf(Q));
const int range = aac_cb_range[cb];
const int maxval = aac_cb_maxval[cb];
int off;
if (BT_ZERO) {
for (i = 0; i < size; i++)
cost += in[i]*in[i];
if (bits)
*bits = 0;
return cost * lambda;
}
if (!scaled) {
abs_pow34_v(s->scoefs, in, size);
scaled = s->scoefs;
}
quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED, maxval);
if (BT_UNSIGNED) {
off = 0;
} else {
off = maxval;
}
for (i = 0; i < size; i += dim) {
const float *vec;
int *quants = s->qcoefs + i;
int curidx = 0;
int curbits;
float rd = 0.0f;
for (j = 0; j < dim; j++) {
curidx *= range;
curidx += quants[j] + off;
}
curbits = ff_aac_spectral_bits[cb-1][curidx];
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
if (BT_UNSIGNED) {
for (k = 0; k < dim; k++) {
float t = fabsf(in[i+k]);
float di;
if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow
if (t >= CLIPPED_ESCAPE) {
di = t - CLIPPED_ESCAPE;
curbits += 21;
} else {
int c = av_clip(quant(t, Q), 0, 8191);
di = t - c*cbrtf(c)*IQ;
curbits += av_log2(c)*2 - 4 + 1;
}
} else {
di = t - vec[k]*IQ;
}
if (vec[k] != 0.0f)
curbits++;
rd += di*di;
}
} else {
for (k = 0; k < dim; k++) {
float di = in[i+k] - vec[k]*IQ;
rd += di*di;
}
}
cost += rd * lambda + curbits;
resbits += curbits;
if (cost >= uplim)
return uplim;
if (pb) {
put_bits(pb, ff_aac_spectral_bits[cb-1][curidx], ff_aac_spectral_codes[cb-1][curidx]);
if (BT_UNSIGNED)
for (j = 0; j < dim; j++)
if (ff_aac_codebook_vectors[cb-1][curidx*dim+j] != 0.0f)
put_bits(pb, 1, in[i+j] < 0.0f);
if (BT_ESC) {
for (j = 0; j < 2; j++) {
if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) {
int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191);
int len = av_log2(coef);
put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
put_bits(pb, len, coef & ((1 << len) - 1));
}
}
}
}
}
if (bits)
*bits = resbits;
return cost;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10767 | static void event_loop(VideoState *cur_stream)
{
SDL_Event event;
double incr, pos, frac;
for(;;) {
double x;
SDL_WaitEvent(&event);
switch(event.type) {
case SDL_KEYDOWN:
if (exit_on_keydown) {
do_exit(cur_stream);
break;
}
switch(event.key.keysym.sym) {
case SDLK_ESCAPE:
case SDLK_q:
do_exit(cur_stream);
break;
case SDLK_f:
toggle_full_screen(cur_stream);
break;
case SDLK_p:
case SDLK_SPACE:
if (cur_stream)
toggle_pause(cur_stream);
break;
case SDLK_s: //S: Step to next frame
if (cur_stream)
step_to_next_frame(cur_stream);
break;
case SDLK_a:
if (cur_stream)
stream_cycle_channel(cur_stream, AVMEDIA_TYPE_AUDIO);
break;
case SDLK_v:
if (cur_stream)
stream_cycle_channel(cur_stream, AVMEDIA_TYPE_VIDEO);
break;
case SDLK_t:
if (cur_stream)
stream_cycle_channel(cur_stream, AVMEDIA_TYPE_SUBTITLE);
break;
case SDLK_w:
if (cur_stream)
toggle_audio_display(cur_stream);
break;
case SDLK_LEFT:
incr = -10.0;
goto do_seek;
case SDLK_RIGHT:
incr = 10.0;
goto do_seek;
case SDLK_UP:
incr = 60.0;
goto do_seek;
case SDLK_DOWN:
incr = -60.0;
do_seek:
if (cur_stream) {
if (seek_by_bytes) {
if (cur_stream->video_stream >= 0 && cur_stream->video_current_pos>=0){
pos= cur_stream->video_current_pos;
}else if(cur_stream->audio_stream >= 0 && cur_stream->audio_pkt.pos>=0){
pos= cur_stream->audio_pkt.pos;
}else
pos = avio_tell(cur_stream->ic->pb);
if (cur_stream->ic->bit_rate)
incr *= cur_stream->ic->bit_rate / 8.0;
else
incr *= 180000.0;
pos += incr;
stream_seek(cur_stream, pos, incr, 1);
} else {
pos = get_master_clock(cur_stream);
pos += incr;
stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);
}
}
break;
default:
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
if (exit_on_mousedown) {
do_exit(cur_stream);
break;
}
case SDL_MOUSEMOTION:
if(event.type ==SDL_MOUSEBUTTONDOWN){
x= event.button.x;
}else{
if(event.motion.state != SDL_PRESSED)
break;
x= event.motion.x;
}
if (cur_stream) {
if(seek_by_bytes || cur_stream->ic->duration<=0){
uint64_t size= avio_size(cur_stream->ic->pb);
stream_seek(cur_stream, size*x/cur_stream->width, 0, 1);
}else{
int64_t ts;
int ns, hh, mm, ss;
int tns, thh, tmm, tss;
tns = cur_stream->ic->duration/1000000LL;
thh = tns/3600;
tmm = (tns%3600)/60;
tss = (tns%60);
frac = x/cur_stream->width;
ns = frac*tns;
hh = ns/3600;
mm = (ns%3600)/60;
ss = (ns%60);
fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100,
hh, mm, ss, thh, tmm, tss);
ts = frac*cur_stream->ic->duration;
if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
ts += cur_stream->ic->start_time;
stream_seek(cur_stream, ts, 0, 0);
}
}
break;
case SDL_VIDEORESIZE:
if (cur_stream) {
screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);
screen_width = cur_stream->width = event.resize.w;
screen_height= cur_stream->height= event.resize.h;
}
break;
case SDL_QUIT:
case FF_QUIT_EVENT:
do_exit(cur_stream);
break;
case FF_ALLOC_EVENT:
video_open(event.user.data1);
alloc_picture(event.user.data1);
break;
case FF_REFRESH_EVENT:
video_refresh(event.user.data1);
cur_stream->refresh=0;
break;
default:
break;
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10772 | static int sox_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
int ret, size;
if (url_feof(s->pb))
return AVERROR_EOF;
size = SOX_SAMPLES*s->streams[0]->codec->block_align;
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
return AVERROR(EIO);
pkt->stream_index = 0;
pkt->size = ret;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10773 | static av_cold int svq1_encode_init(AVCodecContext *avctx)
{
SVQ1Context * const s = avctx->priv_data;
dsputil_init(&s->dsp, avctx);
avctx->coded_frame= (AVFrame*)&s->picture;
s->frame_width = avctx->width;
s->frame_height = avctx->height;
s->y_block_width = (s->frame_width + 15) / 16;
s->y_block_height = (s->frame_height + 15) / 16;
s->c_block_width = (s->frame_width / 4 + 15) / 16;
s->c_block_height = (s->frame_height / 4 + 15) / 16;
s->avctx= avctx;
s->m.avctx= avctx;
s->m.me.scratchpad= av_mallocz((avctx->width+64)*2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->mb_type = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int16_t));
s->dummy = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int32_t));
h263_encode_init(&s->m); //mv_penalty
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10801 | static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
uint64_t prdt_addr = le64_to_cpu(cmd->tbl_addr) + 0x80;
int sglist_alloc_hint = opts >> AHCI_CMD_HDR_PRDT_LEN;
dma_addr_t prdt_len = (sglist_alloc_hint * sizeof(AHCI_SG));
dma_addr_t real_prdt_len = prdt_len;
uint8_t *prdt;
int i;
int r = 0;
int sum = 0;
int off_idx = -1;
int off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
}
/* map PRDT */
if (!(prdt = dma_memory_map(ad->hba->as, prdt_addr, &prdt_len,
DMA_DIRECTION_TO_DEVICE))){
DPRINTF(ad->port_no, "map failed\n");
return -1;
}
if (prdt_len < real_prdt_len) {
DPRINTF(ad->port_no, "mapped less than expected\n");
r = -1;
goto out;
}
/* Get entries in the PRDT, init a qemu sglist accordingly */
if (sglist_alloc_hint > 0) {
AHCI_SG *tbl = (AHCI_SG *)prdt;
sum = 0;
for (i = 0; i < sglist_alloc_hint; i++) {
/* flags_size is zero-based */
tbl_entry_size = (le32_to_cpu(tbl[i].flags_size) + 1);
if (offset <= (sum + tbl_entry_size)) {
off_idx = i;
off_pos = offset - sum;
break;
}
sum += tbl_entry_size;
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
"off_idx: %d, off_pos: %d\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
}
qemu_sglist_init(sglist, qbus->parent, (sglist_alloc_hint - off_idx),
ad->hba->as);
qemu_sglist_add(sglist, le64_to_cpu(tbl[off_idx].addr + off_pos),
le32_to_cpu(tbl[off_idx].flags_size) + 1 - off_pos);
for (i = off_idx + 1; i < sglist_alloc_hint; i++) {
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
le32_to_cpu(tbl[i].flags_size) + 1);
}
}
out:
dma_memory_unmap(ad->hba->as, prdt, prdt_len,
DMA_DIRECTION_TO_DEVICE, prdt_len);
return r;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10836 | static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int field_based,
int bottom_field,
int field_select,
uint8_t **ref_picture,
h264_chroma_mc_func *pix_op,
int motion_x, int motion_y,
int h, int mb_y)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy,
uvsx, uvsy;
const int lowres = s->avctx->lowres;
const int op_index = FFMIN(lowres, 2);
const int block_s = 8>>lowres;
const int s_mask = (2 << lowres) - 1;
const int h_edge_pos = s->h_edge_pos >> lowres;
const int v_edge_pos = s->v_edge_pos >> lowres;
linesize = s->current_picture.f.linesize[0] << field_based;
uvlinesize = s->current_picture.f.linesize[1] << field_based;
// FIXME obviously not perfect but qpel will not work in lowres anyway
if (s->quarter_sample) {
motion_x /= 2;
motion_y /= 2;
}
if (field_based) {
motion_y += (bottom_field - field_select) * (1 << lowres - 1);
}
sx = motion_x & s_mask;
sy = motion_y & s_mask;
src_x = s->mb_x * 2 * block_s + (motion_x >> lowres + 1);
src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
if (s->out_format == FMT_H263) {
uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
uvsrc_x = src_x >> 1;
uvsrc_y = src_y >> 1;
} else if (s->out_format == FMT_H261) {
// even chroma mv's are full pel in H261
mx = motion_x / 4;
my = motion_y / 4;
uvsx = (2 * mx) & s_mask;
uvsy = (2 * my) & s_mask;
uvsrc_x = s->mb_x * block_s + (mx >> lowres);
uvsrc_y = mb_y * block_s + (my >> lowres);
} else {
mx = motion_x / 2;
my = motion_y / 2;
uvsx = mx & s_mask;
uvsy = my & s_mask;
uvsrc_x = s->mb_x * block_s + (mx >> lowres + 1);
uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
}
ptr_y = ref_picture[0] + src_y * linesize + src_x;
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if ((unsigned) src_x > h_edge_pos - (!!sx) - 2 * block_s ||
(unsigned) src_y > (v_edge_pos >> field_based) - (!!sy) - h) {
s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y,
s->linesize, 17, 17 + field_based,
src_x, src_y << field_based, h_edge_pos,
v_edge_pos);
ptr_y = s->edge_emu_buffer;
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->edge_emu_buffer + 18 * s->linesize;
s->dsp.emulated_edge_mc(uvbuf , ptr_cb, s->uvlinesize, 9,
9 + field_based,
uvsrc_x, uvsrc_y << field_based,
h_edge_pos >> 1, v_edge_pos >> 1);
s->dsp.emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize, 9,
9 + field_based,
uvsrc_x, uvsrc_y << field_based,
h_edge_pos >> 1, v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
// FIXME use this for field pix too instead of the obnoxious hack which changes picture.f.data
if (bottom_field) {
dest_y += s->linesize;
dest_cb += s->uvlinesize;
dest_cr += s->uvlinesize;
}
if (field_select) {
ptr_y += s->linesize;
ptr_cb += s->uvlinesize;
ptr_cr += s->uvlinesize;
}
sx = (sx << 2) >> lowres;
sy = (sy << 2) >> lowres;
pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
uvsx = (uvsx << 2) >> lowres;
uvsy = (uvsy << 2) >> lowres;
pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift,
uvsx, uvsy);
pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift,
uvsx, uvsy);
}
// FIXME h261 lowres loop filter
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10842 | static int decode_frame(AVCodecContext *avctx,
void *data,
int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
unsigned int buf_size = avpkt->size;
const uint8_t *buf_end = buf + buf_size;
const AVPixFmtDescriptor *desc;
EXRContext *const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *const p = &s->picture;
uint8_t *ptr;
int i, x, y, stride, magic_number, version, flags, ret;
int w = 0;
int h = 0;
unsigned int xmin = ~0;
unsigned int xmax = ~0;
unsigned int ymin = ~0;
unsigned int ymax = ~0;
unsigned int xdelta = ~0;
int out_line_size;
int bxmin, axmax;
int scan_lines_per_block;
unsigned long scan_line_size;
unsigned long uncompressed_size;
unsigned int current_channel_offset = 0;
s->channel_offsets[0] = -1;
s->channel_offsets[1] = -1;
s->channel_offsets[2] = -1;
s->channel_offsets[3] = -1;
s->bits_per_color_id = -1;
s->compr = -1;
if (buf_size < 10) {
av_log(avctx, AV_LOG_ERROR, "Too short header to parse\n");
return AVERROR_INVALIDDATA;
}
magic_number = bytestream_get_le32(&buf);
if (magic_number != 20000630) { // As per documentation of OpenEXR it's supposed to be int 20000630 little-endian
av_log(avctx, AV_LOG_ERROR, "Wrong magic number %d\n", magic_number);
return AVERROR_INVALIDDATA;
}
version = bytestream_get_byte(&buf);
if (version != 2) {
av_log(avctx, AV_LOG_ERROR, "Unsupported version %d\n", version);
return AVERROR_PATCHWELCOME;
}
flags = bytestream_get_le24(&buf);
if (flags & 0x2) {
av_log(avctx, AV_LOG_ERROR, "Tile based images are not supported\n");
return AVERROR_PATCHWELCOME;
}
// Parse the header
while (buf < buf_end && buf[0]) {
unsigned int variable_buffer_data_size;
// Process the channel list
if (check_header_variable(avctx, &buf, buf_end, "channels", "chlist", 38, &variable_buffer_data_size) >= 0) {
const uint8_t *channel_list_end;
if (!variable_buffer_data_size)
return AVERROR_INVALIDDATA;
channel_list_end = buf + variable_buffer_data_size;
while (channel_list_end - buf >= 19) {
int current_bits_per_color_id = -1;
int channel_index = -1;
if (!strcmp(buf, "R"))
channel_index = 0;
else if (!strcmp(buf, "G"))
channel_index = 1;
else if (!strcmp(buf, "B"))
channel_index = 2;
else if (!strcmp(buf, "A"))
channel_index = 3;
else
av_log(avctx, AV_LOG_WARNING, "Unsupported channel %.256s\n", buf);
while (bytestream_get_byte(&buf) && buf < channel_list_end)
continue; /* skip */
if (channel_list_end - * &buf < 4) {
av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
return AVERROR_INVALIDDATA;
}
current_bits_per_color_id = bytestream_get_le32(&buf);
if (current_bits_per_color_id > 2) {
av_log(avctx, AV_LOG_ERROR, "Unknown color format\n");
return AVERROR_INVALIDDATA;
}
if (channel_index >= 0) {
if (s->bits_per_color_id != -1 && s->bits_per_color_id != current_bits_per_color_id) {
av_log(avctx, AV_LOG_ERROR, "RGB channels not of the same depth\n");
return AVERROR_INVALIDDATA;
}
s->bits_per_color_id = current_bits_per_color_id;
s->channel_offsets[channel_index] = current_channel_offset;
}
current_channel_offset += 1 << current_bits_per_color_id;
buf += 12;
}
/* Check if all channels are set with an offset or if the channels
* are causing an overflow */
if (FFMIN3(s->channel_offsets[0],
s->channel_offsets[1],
s->channel_offsets[2]) < 0) {
if (s->channel_offsets[0] < 0)
av_log(avctx, AV_LOG_ERROR, "Missing red channel\n");
if (s->channel_offsets[1] < 0)
av_log(avctx, AV_LOG_ERROR, "Missing green channel\n");
if (s->channel_offsets[2] < 0)
av_log(avctx, AV_LOG_ERROR, "Missing blue channel\n");
return AVERROR_INVALIDDATA;
}
buf = channel_list_end;
continue;
} else if (check_header_variable(avctx, &buf, buf_end, "dataWindow", "box2i", 31, &variable_buffer_data_size) >= 0) {
if (!variable_buffer_data_size)
return AVERROR_INVALIDDATA;
xmin = AV_RL32(buf);
ymin = AV_RL32(buf + 4);
xmax = AV_RL32(buf + 8);
ymax = AV_RL32(buf + 12);
xdelta = (xmax-xmin) + 1;
buf += variable_buffer_data_size;
continue;
} else if (check_header_variable(avctx, &buf, buf_end, "displayWindow", "box2i", 34, &variable_buffer_data_size) >= 0) {
if (!variable_buffer_data_size)
return AVERROR_INVALIDDATA;
w = AV_RL32(buf + 8) + 1;
h = AV_RL32(buf + 12) + 1;
buf += variable_buffer_data_size;
continue;
} else if (check_header_variable(avctx, &buf, buf_end, "lineOrder", "lineOrder", 25, &variable_buffer_data_size) >= 0) {
if (!variable_buffer_data_size)
return AVERROR_INVALIDDATA;
if (*buf) {
av_log(avctx, AV_LOG_ERROR, "Doesn't support this line order : %d\n", *buf);
return AVERROR_PATCHWELCOME;
}
buf += variable_buffer_data_size;
continue;
} else if (check_header_variable(avctx, &buf, buf_end, "pixelAspectRatio", "float", 31, &variable_buffer_data_size) >= 0) {
if (!variable_buffer_data_size)
return AVERROR_INVALIDDATA;
avctx->sample_aspect_ratio = av_d2q(av_int2float(AV_RL32(buf)), 255);
buf += variable_buffer_data_size;
continue;
} else if (check_header_variable(avctx, &buf, buf_end, "compression", "compression", 29, &variable_buffer_data_size) >= 0) {
if (!variable_buffer_data_size)
return AVERROR_INVALIDDATA;
if (s->compr == -1)
s->compr = *buf;
else
av_log(avctx, AV_LOG_WARNING, "Found more than one compression attribute\n");
buf += variable_buffer_data_size;
continue;
}
// Check if there is enough bytes for a header
if (buf_end - buf <= 9) {
av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
return AVERROR_INVALIDDATA;
}
// Process unknown variables
for (i = 0; i < 2; i++) {
// Skip variable name/type
while (++buf < buf_end)
if (buf[0] == 0x0)
break;
}
buf++;
// Skip variable length
if (buf_end - buf >= 5) {
variable_buffer_data_size = get_header_variable_length(&buf, buf_end);
if (!variable_buffer_data_size) {
av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
return AVERROR_INVALIDDATA;
}
buf += variable_buffer_data_size;
}
}
if (s->compr == -1) {
av_log(avctx, AV_LOG_ERROR, "Missing compression attribute\n");
return AVERROR_INVALIDDATA;
}
if (buf >= buf_end) {
av_log(avctx, AV_LOG_ERROR, "Incomplete frame\n");
return AVERROR_INVALIDDATA;
}
buf++;
switch (s->bits_per_color_id) {
case 2: // 32-bit
case 1: // 16-bit
if (s->channel_offsets[3] >= 0)
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
else
avctx->pix_fmt = AV_PIX_FMT_RGB48;
break;
// 8-bit
case 0:
av_log_missing_feature(avctx, "8-bit OpenEXR", 1);
return AVERROR_PATCHWELCOME;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown color format : %d\n", s->bits_per_color_id);
return AVERROR_INVALIDDATA;
}
switch (s->compr) {
case EXR_RAW:
case EXR_RLE:
case EXR_ZIP1:
scan_lines_per_block = 1;
break;
case EXR_ZIP16:
scan_lines_per_block = 16;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Compression type %d is not supported\n", s->compr);
return AVERROR_PATCHWELCOME;
}
if (s->picture.data[0])
ff_thread_release_buffer(avctx, &s->picture);
if (av_image_check_size(w, h, 0, avctx))
return AVERROR_INVALIDDATA;
// Verify the xmin, xmax, ymin, ymax and xdelta before setting the actual image size
if (xmin > xmax || ymin > ymax || xdelta != xmax - xmin + 1 || xmax >= w || ymax >= h) {
av_log(avctx, AV_LOG_ERROR, "Wrong sizing or missing size information\n");
return AVERROR_INVALIDDATA;
}
if (w != avctx->width || h != avctx->height) {
avcodec_set_dimensions(avctx, w, h);
}
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
bxmin = xmin * 2 * desc->nb_components;
axmax = (avctx->width - (xmax + 1)) * 2 * desc->nb_components;
out_line_size = avctx->width * 2 * desc->nb_components;
scan_line_size = xdelta * current_channel_offset;
uncompressed_size = scan_line_size * scan_lines_per_block;
if (s->compr != EXR_RAW) {
av_fast_padded_malloc(&s->uncompressed_data, &s->uncompressed_size, uncompressed_size);
av_fast_padded_malloc(&s->tmp, &s->tmp_size, uncompressed_size);
if (!s->uncompressed_data || !s->tmp)
return AVERROR(ENOMEM);
}
if ((ret = ff_thread_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
ptr = p->data[0];
stride = p->linesize[0];
// Zero out the start if ymin is not 0
for (y = 0; y < ymin; y++) {
memset(ptr, 0, out_line_size);
ptr += stride;
}
// Process the actual scan line blocks
for (y = ymin; y <= ymax; y += scan_lines_per_block) {
uint16_t *ptr_x = (uint16_t *)ptr;
if (buf_end - buf > 8) {
/* Read the lineoffset from the line offset table and add 8 bytes
to skip the coordinates and data size fields */
const uint64_t line_offset = bytestream_get_le64(&buf) + 8;
int32_t data_size;
// Check if the buffer has the required bytes needed from the offset
if ((line_offset > buf_size) ||
(s->compr == EXR_RAW && line_offset > avpkt->size - xdelta * current_channel_offset) ||
(s->compr != EXR_RAW && line_offset > buf_size - (data_size = AV_RL32(avpkt->data + line_offset - 4)))) {
// Line offset is probably wrong and not inside the buffer
av_log(avctx, AV_LOG_WARNING, "Line offset for line %d is out of reach setting it to black\n", y);
for (i = 0; i < scan_lines_per_block && y + i <= ymax; i++, ptr += stride) {
ptr_x = (uint16_t *)ptr;
memset(ptr_x, 0, out_line_size);
}
} else {
const uint8_t *red_channel_buffer, *green_channel_buffer, *blue_channel_buffer, *alpha_channel_buffer = 0;
if (scan_lines_per_block > 1)
uncompressed_size = scan_line_size * FFMIN(scan_lines_per_block, ymax - y + 1);
if ((s->compr == EXR_ZIP1 || s->compr == EXR_ZIP16) && data_size < uncompressed_size) {
unsigned long dest_len = uncompressed_size;
if (uncompress(s->tmp, &dest_len, avpkt->data + line_offset, data_size) != Z_OK ||
dest_len != uncompressed_size) {
av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
return AVERROR(EINVAL);
}
} else if (s->compr == EXR_RLE && data_size < uncompressed_size) {
if (rle_uncompress(avpkt->data + line_offset, data_size, s->tmp, uncompressed_size)) {
av_log(avctx, AV_LOG_ERROR, "error during rle decompression\n");
return AVERROR(EINVAL);
}
}
if (s->compr != EXR_RAW && data_size < uncompressed_size) {
predictor(s->tmp, uncompressed_size);
reorder_pixels(s->tmp, s->uncompressed_data, uncompressed_size);
red_channel_buffer = s->uncompressed_data + xdelta * s->channel_offsets[0];
green_channel_buffer = s->uncompressed_data + xdelta * s->channel_offsets[1];
blue_channel_buffer = s->uncompressed_data + xdelta * s->channel_offsets[2];
if (s->channel_offsets[3] >= 0)
alpha_channel_buffer = s->uncompressed_data + xdelta * s->channel_offsets[3];
} else {
red_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[0];
green_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[1];
blue_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[2];
if (s->channel_offsets[3] >= 0)
alpha_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[3];
}
for (i = 0; i < scan_lines_per_block && y + i <= ymax; i++, ptr += stride) {
const uint8_t *r, *g, *b, *a;
r = red_channel_buffer;
g = green_channel_buffer;
b = blue_channel_buffer;
if (alpha_channel_buffer)
a = alpha_channel_buffer;
ptr_x = (uint16_t *)ptr;
// Zero out the start if xmin is not 0
memset(ptr_x, 0, bxmin);
ptr_x += xmin * desc->nb_components;
if (s->bits_per_color_id == 2) {
// 32-bit
for (x = 0; x < xdelta; x++) {
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&r));
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&g));
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&b));
if (alpha_channel_buffer)
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&a));
}
} else {
// 16-bit
for (x = 0; x < xdelta; x++) {
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&r));
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&g));
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&b));
if (alpha_channel_buffer)
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&a));
}
}
// Zero out the end if xmax+1 is not w
memset(ptr_x, 0, axmax);
red_channel_buffer += scan_line_size;
green_channel_buffer += scan_line_size;
blue_channel_buffer += scan_line_size;
if (alpha_channel_buffer)
alpha_channel_buffer += scan_line_size;
}
}
}
}
// Zero out the end if ymax+1 is not h
for (y = ymax + 1; y < avctx->height; y++) {
memset(ptr, 0, out_line_size);
ptr += stride;
}
*picture = s->picture;
*got_frame = 1;
return buf_size;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10847 | static void csrhci_reset(struct csrhci_s *s)
{
s->out_len = 0;
s->out_size = FIFO_LEN;
s->in_len = 0;
s->baud_delay = NANOSECONDS_PER_SECOND;
s->enable = 0;
s->in_hdr = INT_MAX;
s->in_data = INT_MAX;
s->modem_state = 0;
/* After a while... (but sooner than 10ms) */
s->modem_state |= CHR_TIOCM_CTS;
memset(&s->bd_addr, 0, sizeof(bdaddr_t));
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10849 | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
unsigned i;
unsigned num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x3E0)>>5;
b = (rgb&0x7C00)>>10;
dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10857 | int net_init_vhost_user(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp)
{
int queues;
const NetdevVhostUserOptions *vhost_user_opts;
CharDriverState *chr;
assert(netdev->type == NET_CLIENT_DRIVER_VHOST_USER);
vhost_user_opts = &netdev->u.vhost_user;
chr = net_vhost_parse_chardev(vhost_user_opts, errp);
if (!chr) {
return -1;
}
/* verify net frontend */
if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net,
(char *)name, errp)) {
return -1;
}
queues = vhost_user_opts->has_queues ? vhost_user_opts->queues : 1;
if (queues < 1 || queues > MAX_QUEUE_NUM) {
error_setg(errp,
"vhost-user number of queues must be in range [1, %d]",
MAX_QUEUE_NUM);
return -1;
}
return net_vhost_user_init(peer, "vhost_user", name, chr, queues);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10868 | static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
{
static const uint8_t series[] = { 1, 2, 3, 5, 8, 13, 21 };
int i;
int bit = 0;
int bits = 0;
int prevbit = 0;
unsigned val;
for (i = 0; i < 7; i++) {
if (prevbit && bit)
break;
prevbit = bit;
bit = get_bits1(gb);
if (bit && !prevbit)
bits += series[i];
}
bits--;
if (bits < 0 || bits > 31) {
*value = 0;
return -1;
} else if (bits == 0) {
*value = 0;
return 0;
}
val = get_bits_long(gb, bits);
val |= 1 << bits;
*value = val - 1;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10869 | static void check_add_res(HEVCDSPContext h, int bit_depth)
{
int i;
LOCAL_ALIGNED_32(int16_t, res0, [32 * 32]);
LOCAL_ALIGNED_32(int16_t, res1, [32 * 32]);
LOCAL_ALIGNED_32(uint8_t, dst0, [32 * 32 * 2]);
LOCAL_ALIGNED_32(uint8_t, dst1, [32 * 32 * 2]);
for (i = 2; i <= 5; i++) {
int block_size = 1 << i;
int size = block_size * block_size;
ptrdiff_t stride = block_size << (bit_depth > 8);
declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *res, ptrdiff_t stride);
randomize_buffers(res0, size);
randomize_buffers2(dst0, size);
memcpy(res1, res0, sizeof(*res0) * size);
memcpy(dst1, dst0, size);
if (check_func(h.add_residual[i - 2], "add_res_%dx%d_%d", block_size, block_size, bit_depth)) {
call_ref(dst0, res0, stride);
call_new(dst1, res1, stride);
if (memcmp(dst0, dst1, size))
fail();
bench_new(dst1, res1, stride);
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10875 | static void test_validate_fail_union_flat(TestInputVisitorData *data,
const void *unused)
{
UserDefFlatUnion *tmp = NULL;
Error *errp = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }");
visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp);
g_assert(error_is_set(&errp));
qapi_free_UserDefFlatUnion(tmp);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10877 | void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)
{
#if defined(DEBUG_MMU)
printf("CR4 update: CR4=%08x\n", (uint32_t)env->cr[4]);
#endif
if ((new_cr4 & (CR4_PGE_MASK | CR4_PAE_MASK | CR4_PSE_MASK)) !=
(env->cr[4] & (CR4_PGE_MASK | CR4_PAE_MASK | CR4_PSE_MASK))) {
tlb_flush(env, 1);
}
/* SSE handling */
if (!(env->cpuid_features & CPUID_SSE))
new_cr4 &= ~CR4_OSFXSR_MASK;
if (new_cr4 & CR4_OSFXSR_MASK)
env->hflags |= HF_OSFXSR_MASK;
else
env->hflags &= ~HF_OSFXSR_MASK;
env->cr[4] = new_cr4;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10899 | int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
{
char buf[128];
char file[1024];
char devname[128];
char serial[21];
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
QEMUMachine *machine = opaque;
int max_devs;
int index;
int cache;
int bdrv_flags, onerror;
int drives_table_idx;
char *str = arg->opt;
static const char * const params[] = { "bus", "unit", "if", "index",
"cyls", "heads", "secs", "trans",
"media", "snapshot", "file",
"cache", "format", "serial", "werror",
NULL };
if (check_params(buf, sizeof(buf), params, str) < 0) {
fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",
buf, str);
return -1;
}
file[0] = 0;
cyls = heads = secs = 0;
bus_id = 0;
unit_id = -1;
translation = BIOS_ATA_TRANSLATION_AUTO;
index = -1;
cache = 3;
if (machine->use_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
/* extract parameters */
if (get_param_value(buf, sizeof(buf), "bus", str)) {
bus_id = strtol(buf, NULL, 0);
if (bus_id < 0) {
fprintf(stderr, "qemu: '%s' invalid bus id\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "unit", str)) {
unit_id = strtol(buf, NULL, 0);
if (unit_id < 0) {
fprintf(stderr, "qemu: '%s' invalid unit id\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "if", str)) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else if (!strcmp(buf, "xen")) {
type = IF_XEN;
max_devs = 0;
} else {
fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "index", str)) {
index = strtol(buf, NULL, 0);
if (index < 0) {
fprintf(stderr, "qemu: '%s' invalid index\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "cyls", str)) {
cyls = strtol(buf, NULL, 0);
}
if (get_param_value(buf, sizeof(buf), "heads", str)) {
heads = strtol(buf, NULL, 0);
}
if (get_param_value(buf, sizeof(buf), "secs", str)) {
secs = strtol(buf, NULL, 0);
}
if (cyls || heads || secs) {
if (cyls < 1 || cyls > 16383) {
fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", str);
return -1;
}
if (heads < 1 || heads > 16) {
fprintf(stderr, "qemu: '%s' invalid physical heads number\n", str);
return -1;
}
if (secs < 1 || secs > 63) {
fprintf(stderr, "qemu: '%s' invalid physical secs number\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "trans", str)) {
if (!cyls) {
fprintf(stderr,
"qemu: '%s' trans must be used with cyls,heads and secs\n",
str);
return -1;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
fprintf(stderr, "qemu: '%s' invalid translation type\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "media", str)) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
fprintf(stderr,
"qemu: '%s' invalid physical CHS format\n", str);
return -1;
}
media = MEDIA_CDROM;
} else {
fprintf(stderr, "qemu: '%s' invalid media\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "snapshot", str)) {
if (!strcmp(buf, "on"))
snapshot = 1;
else if (!strcmp(buf, "off"))
snapshot = 0;
else {
fprintf(stderr, "qemu: '%s' invalid snapshot option\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "cache", str)) {
if (!strcmp(buf, "off") || !strcmp(buf, "none"))
cache = 0;
else if (!strcmp(buf, "writethrough"))
cache = 1;
else if (!strcmp(buf, "writeback"))
cache = 2;
else {
fprintf(stderr, "qemu: invalid cache option\n");
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "format", str)) {
if (strcmp(buf, "?") == 0) {
fprintf(stderr, "qemu: Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
fprintf(stderr, "\n");
return -1;
}
drv = bdrv_find_format(buf);
if (!drv) {
fprintf(stderr, "qemu: '%s' invalid format\n", buf);
return -1;
}
}
if (arg->file == NULL)
get_param_value(file, sizeof(file), "file", str);
else
pstrcpy(file, sizeof(file), arg->file);
if (!get_param_value(serial, sizeof(serial), "serial", str))
memset(serial, 0, sizeof(serial));
onerror = BLOCK_ERR_STOP_ENOSPC;
if (get_param_value(buf, sizeof(serial), "werror", str)) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
fprintf(stderr, "werror is no supported by this format\n");
return -1;
}
if (!strcmp(buf, "ignore"))
onerror = BLOCK_ERR_IGNORE;
else if (!strcmp(buf, "enospc"))
onerror = BLOCK_ERR_STOP_ENOSPC;
else if (!strcmp(buf, "stop"))
onerror = BLOCK_ERR_STOP_ANY;
else if (!strcmp(buf, "report"))
onerror = BLOCK_ERR_REPORT;
else {
fprintf(stderr, "qemu: '%s' invalid write error action\n", buf);
return -1;
}
}
/* compute bus and unit according index */
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
fprintf(stderr,
"qemu: '%s' index cannot be used with bus and unit\n", str);
return -1;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
/* if user doesn't specify a unit_id,
* try to find the first free
*/
if (unit_id == -1) {
unit_id = 0;
while (drive_get_index(type, bus_id, unit_id) != -1) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
/* check unit id */
if (max_devs && unit_id >= max_devs) {
fprintf(stderr, "qemu: '%s' unit %d too big (max is %d)\n",
str, unit_id, max_devs - 1);
return -1;
}
/*
* ignore multiple definitions
*/
if (drive_get_index(type, bus_id, unit_id) != -1)
return -2;
/* init */
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(buf, sizeof(buf), "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(buf, sizeof(buf), "%s%s%i",
devname, mediastr, unit_id);
bdrv = bdrv_new(buf);
drives_table_idx = drive_get_free_idx();
drives_table[drives_table_idx].bdrv = bdrv;
drives_table[drives_table_idx].type = type;
drives_table[drives_table_idx].bus = bus_id;
drives_table[drives_table_idx].unit = unit_id;
drives_table[drives_table_idx].onerror = onerror;
drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt;
strncpy(drives_table[nb_drives].serial, serial, sizeof(serial));
nb_drives++;
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(bdrv, cyls, heads, secs);
bdrv_set_translation_hint(bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
/* FIXME: This isn't really a floppy, but it's a reasonable
approximation. */
case IF_FLOPPY:
bdrv_set_type_hint(bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
case IF_VIRTIO:
break;
}
if (!file[0])
return -2;
bdrv_flags = 0;
if (snapshot) {
bdrv_flags |= BDRV_O_SNAPSHOT;
cache = 2; /* always use write-back with snapshot */
}
if (cache == 0) /* no caching */
bdrv_flags |= BDRV_O_NOCACHE;
else if (cache == 2) /* write-back */
bdrv_flags |= BDRV_O_CACHE_WB;
else if (cache == 3) /* not specified */
bdrv_flags |= BDRV_O_CACHE_DEF;
if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s\n",
file);
return -1;
}
if (bdrv_key_required(bdrv))
autostart = 0;
return drives_table_idx;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10914 | static void unix_wait_for_connect(int fd, Error *err, void *opaque)
{
MigrationState *s = opaque;
if (fd < 0) {
DPRINTF("migrate connect error: %s\n", error_get_pretty(err));
s->file = NULL;
migrate_fd_error(s);
} else {
DPRINTF("migrate connect success\n");
s->file = qemu_fopen_socket(fd, "wb");
migrate_fd_connect(s);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10950 | static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
LJpegEncContext *s = avctx->priv_data;
PutBitContext pb;
const int width = avctx->width;
const int height = avctx->height;
const int mb_width = (width + s->hsample[0] - 1) / s->hsample[0];
const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0];
int max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE;
int ret, header_bits;
if (avctx->pix_fmt == AV_PIX_FMT_BGR24)
max_pkt_size += width * height * 3 * 3;
else {
max_pkt_size += mb_width * mb_height * 3 * 4
* s->hsample[0] * s->vsample[0];
}
if ((ret = ff_alloc_packet(pkt, max_pkt_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", max_pkt_size);
return ret;
}
init_put_bits(&pb, pkt->data, pkt->size);
ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable,
s->matrix);
header_bits = put_bits_count(&pb);
if (avctx->pix_fmt == AV_PIX_FMT_BGR24)
ret = ljpeg_encode_bgr(avctx, &pb, pict);
else
ret = ljpeg_encode_yuv(avctx, &pb, pict);
if (ret < 0)
return ret;
emms_c();
ff_mjpeg_encode_picture_trailer(&pb, header_bits);
flush_put_bits(&pb);
pkt->size = put_bits_ptr(&pb) - pb.buf;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10962 | int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilterBufferRef *picref)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterLink *outlink = buffer_filter->outputs[0];
int ret;
if (c->picref) {
av_log(buffer_filter, AV_LOG_ERROR,
"Buffering several frames is not supported. "
"Please consume all available frames before adding a new one.\n"
);
//return -1;
}
if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
AVFilterContext *scale = buffer_filter->outputs[0]->dst;
AVFilterLink *link;
char scale_param[1024];
av_log(buffer_filter, AV_LOG_INFO,
"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
picref->video->w, picref->video->h, av_pix_fmt_descriptors[picref->format].name);
if (!scale || strcmp(scale->filter->name, "scale")) {
AVFilter *f = avfilter_get_by_name("scale");
av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n");
if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
return ret;
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
avfilter_free(scale);
return ret;
}
if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
avfilter_free(scale);
return ret;
}
scale->outputs[0]->time_base = scale->inputs[0]->time_base;
scale->outputs[0]->format= c->pix_fmt;
} else if (!strcmp(scale->filter->name, "scale")) {
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s",
scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
scale->filter->init(scale, scale_param, NULL);
}
c->pix_fmt = scale->inputs[0]->format = picref->format;
c->w = scale->inputs[0]->w = picref->video->w;
c->h = scale->inputs[0]->h = picref->video->h;
link = scale->outputs[0];
if ((ret = link->srcpad->config_props(link)) < 0)
return ret;
}
c->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
picref->video->w, picref->video->h);
av_image_copy(c->picref->data, c->picref->linesize,
picref->data, picref->linesize,
picref->format, picref->video->w, picref->video->h);
avfilter_copy_buffer_ref_props(c->picref, picref);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10971 | int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
H264ParamSets *ps, int bit_length)
{
AVBufferRef *pps_buf;
const SPS *sps;
unsigned int pps_id = get_ue_golomb(gb);
PPS *pps;
int qp_bd_offset;
int bits_left;
int ret;
if (pps_id >= MAX_PPS_COUNT) {
av_log(avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
pps_buf = av_buffer_allocz(sizeof(*pps));
if (!pps_buf)
return AVERROR(ENOMEM);
pps = (PPS*)pps_buf->data;
pps->data_size = gb->buffer_end - gb->buffer;
if (pps->data_size > sizeof(pps->data)) {
av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized PPS "
"(%"SIZE_SPECIFIER" > %"SIZE_SPECIFIER")\n",
pps->data_size, sizeof(pps->data));
pps->data_size = sizeof(pps->data);
memcpy(pps->data, gb->buffer, pps->data_size);
pps->sps_id = get_ue_golomb_31(gb);
if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
!ps->sps_list[pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", pps->sps_id);
sps = (const SPS*)ps->sps_list[pps->sps_id]->data;
if (sps->bit_depth_luma > 14) {
av_log(avctx, AV_LOG_ERROR,
"Invalid luma bit depth=%d\n",
sps->bit_depth_luma);
} else if (sps->bit_depth_luma == 11 || sps->bit_depth_luma == 13) {
av_log(avctx, AV_LOG_ERROR,
"Unimplemented luma bit depth=%d\n",
sps->bit_depth_luma);
ret = AVERROR_PATCHWELCOME;
pps->cabac = get_bits1(gb);
pps->pic_order_present = get_bits1(gb);
pps->slice_group_count = get_ue_golomb(gb) + 1;
if (pps->slice_group_count > 1) {
pps->mb_slice_group_map_type = get_ue_golomb(gb);
av_log(avctx, AV_LOG_ERROR, "FMO not supported\n");
switch (pps->mb_slice_group_map_type) {
case 0:
#if 0
| for (i = 0; i <= num_slice_groups_minus1; i++) | | |
| run_length[i] |1 |ue(v) |
#endif
break;
case 2:
#if 0
| for (i = 0; i < num_slice_groups_minus1; i++) { | | |
| top_left_mb[i] |1 |ue(v) |
| bottom_right_mb[i] |1 |ue(v) |
| } | | |
#endif
break;
case 3:
case 4:
case 5:
#if 0
| slice_group_change_direction_flag |1 |u(1) |
| slice_group_change_rate_minus1 |1 |ue(v) |
#endif
break;
case 6:
#if 0
| slice_group_id_cnt_minus1 |1 |ue(v) |
| for (i = 0; i <= slice_group_id_cnt_minus1; i++)| | |
| slice_group_id[i] |1 |u(v) |
#endif
break;
pps->ref_count[0] = get_ue_golomb(gb) + 1;
pps->ref_count[1] = get_ue_golomb(gb) + 1;
if (pps->ref_count[0] - 1 > 32 - 1 || pps->ref_count[1] - 1 > 32 - 1) {
av_log(avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
qp_bd_offset = 6 * (sps->bit_depth_luma - 8);
pps->weighted_pred = get_bits1(gb);
pps->weighted_bipred_idc = get_bits(gb, 2);
pps->init_qp = get_se_golomb(gb) + 26 + qp_bd_offset;
pps->init_qs = get_se_golomb(gb) + 26 + qp_bd_offset;
pps->chroma_qp_index_offset[0] = get_se_golomb(gb);
pps->deblocking_filter_parameters_present = get_bits1(gb);
pps->constrained_intra_pred = get_bits1(gb);
pps->redundant_pic_cnt_present = get_bits1(gb);
pps->transform_8x8_mode = 0;
memcpy(pps->scaling_matrix4, sps->scaling_matrix4,
sizeof(pps->scaling_matrix4));
memcpy(pps->scaling_matrix8, sps->scaling_matrix8,
sizeof(pps->scaling_matrix8));
bits_left = bit_length - get_bits_count(gb);
if (bits_left > 0 && more_rbsp_data_in_pps(sps, avctx)) {
pps->transform_8x8_mode = get_bits1(gb);
decode_scaling_matrices(gb, sps, pps, 0,
pps->scaling_matrix4, pps->scaling_matrix8);
// second_chroma_qp_index_offset
pps->chroma_qp_index_offset[1] = get_se_golomb(gb);
if (pps->chroma_qp_index_offset[1] < -12 || pps->chroma_qp_index_offset[1] > 12) {
} else {
pps->chroma_qp_index_offset[1] = pps->chroma_qp_index_offset[0];
build_qp_table(pps, 0, pps->chroma_qp_index_offset[0],
sps->bit_depth_luma);
build_qp_table(pps, 1, pps->chroma_qp_index_offset[1],
sps->bit_depth_luma);
init_dequant_tables(pps, sps);
if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])
pps->chroma_qp_diff = 1;
if (avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(avctx, AV_LOG_DEBUG,
"pps:%u sps:%u %s slice_groups:%d ref:%u/%u %s qp:%d/%d/%d/%d %s %s %s %s\n",
pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count,
pps->ref_count[0], pps->ref_count[1],
pps->weighted_pred ? "weighted" : "",
pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1],
pps->deblocking_filter_parameters_present ? "LPAR" : "",
pps->constrained_intra_pred ? "CONSTR" : "",
pps->redundant_pic_cnt_present ? "REDU" : "",
pps->transform_8x8_mode ? "8x8DCT" : "");
remove_pps(ps, pps_id);
ps->pps_list[pps_id] = pps_buf;
return 0;
fail:
av_buffer_unref(&pps_buf);
return ret;
The vulnerability label is: Vulnerable |
devign_test_set_data_10974 | static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
{
trace_qxl_spice_monitors_config(qxl->id);
if (replay) {
/*
* don't use QXL_COOKIE_TYPE_IO:
* - we are not running yet (post_load), we will assert
* in send_events
* - this is not a guest io, but a reply, so async_io isn't set.
*/
spice_qxl_monitors_config_async(&qxl->ssd.qxl,
qxl->guest_monitors_config,
MEMSLOT_GROUP_GUEST,
(uintptr_t)qxl_cookie_new(
QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
0));
} else {
#if SPICE_SERVER_VERSION >= 0x000c06 /* release 0.12.6 */
if (qxl->max_outputs) {
spice_qxl_set_monitors_config_limit(&qxl->ssd.qxl,
qxl->max_outputs);
}
#endif
qxl->guest_monitors_config = qxl->ram->monitors_config;
spice_qxl_monitors_config_async(&qxl->ssd.qxl,
qxl->ram->monitors_config,
MEMSLOT_GROUP_GUEST,
(uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
QXL_IO_MONITORS_CONFIG_ASYNC));
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_10982 | static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
{
VirtIODevice *vdev = VIRTIO_DEVICE(n);
NetClientState *nc = qemu_get_queue(n->nic);
int queues = n->multiqueue ? n->max_queues : 1;
if (!get_vhost_net(nc->peer)) {
return;
}
if (!!n->vhost_started ==
(virtio_net_started(n, status) && !nc->peer->link_down)) {
return;
}
if (!n->vhost_started) {
int r;
if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {
return;
}
n->vhost_started = 1;
r = vhost_net_start(vdev, n->nic->ncs, queues);
if (r < 0) {
error_report("unable to start vhost net: %d: "
"falling back on userspace virtio", -r);
n->vhost_started = 0;
}
} else {
vhost_net_stop(vdev, n->nic->ncs, queues);
n->vhost_started = 0;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10984 | static void spapr_cpu_core_host_initfn(Object *obj)
{
sPAPRCPUCore *core = SPAPR_CPU_CORE(obj);
char *name = g_strdup_printf("%s-" TYPE_POWERPC_CPU, "host");
ObjectClass *oc = object_class_by_name(name);
g_assert(oc);
g_free((void *)name);
core->cpu_class = oc;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10992 | static void init_block_mapping(Vp3DecodeContext *s)
{
int i, j;
signed int hilbert_walk_y[16];
signed int hilbert_walk_c[16];
signed int hilbert_walk_mb[4];
int current_fragment = 0;
int current_width = 0;
int current_height = 0;
int right_edge = 0;
int bottom_edge = 0;
int superblock_row_inc = 0;
int *hilbert = NULL;
int mapping_index = 0;
int current_macroblock;
int c_fragment;
signed char travel_width[16] = {
1, 1, 0, -1,
0, 0, 1, 0,
1, 0, 1, 0,
0, -1, 0, 1
};
signed char travel_height[16] = {
0, 0, 1, 0,
1, 1, 0, -1,
0, 1, 0, -1,
-1, 0, -1, 0
};
signed char travel_width_mb[4] = {
1, 0, 1, 0
};
signed char travel_height_mb[4] = {
0, 1, 0, -1
};
debug_vp3(" vp3: initialize block mapping tables\n");
/* figure out hilbert pattern per these frame dimensions */
hilbert_walk_y[0] = 1;
hilbert_walk_y[1] = 1;
hilbert_walk_y[2] = s->fragment_width;
hilbert_walk_y[3] = -1;
hilbert_walk_y[4] = s->fragment_width;
hilbert_walk_y[5] = s->fragment_width;
hilbert_walk_y[6] = 1;
hilbert_walk_y[7] = -s->fragment_width;
hilbert_walk_y[8] = 1;
hilbert_walk_y[9] = s->fragment_width;
hilbert_walk_y[10] = 1;
hilbert_walk_y[11] = -s->fragment_width;
hilbert_walk_y[12] = -s->fragment_width;
hilbert_walk_y[13] = -1;
hilbert_walk_y[14] = -s->fragment_width;
hilbert_walk_y[15] = 1;
hilbert_walk_c[0] = 1;
hilbert_walk_c[1] = 1;
hilbert_walk_c[2] = s->fragment_width / 2;
hilbert_walk_c[3] = -1;
hilbert_walk_c[4] = s->fragment_width / 2;
hilbert_walk_c[5] = s->fragment_width / 2;
hilbert_walk_c[6] = 1;
hilbert_walk_c[7] = -s->fragment_width / 2;
hilbert_walk_c[8] = 1;
hilbert_walk_c[9] = s->fragment_width / 2;
hilbert_walk_c[10] = 1;
hilbert_walk_c[11] = -s->fragment_width / 2;
hilbert_walk_c[12] = -s->fragment_width / 2;
hilbert_walk_c[13] = -1;
hilbert_walk_c[14] = -s->fragment_width / 2;
hilbert_walk_c[15] = 1;
hilbert_walk_mb[0] = 1;
hilbert_walk_mb[1] = s->macroblock_width;
hilbert_walk_mb[2] = 1;
hilbert_walk_mb[3] = -s->macroblock_width;
/* iterate through each superblock (all planes) and map the fragments */
for (i = 0; i < s->superblock_count; i++) {
debug_init(" superblock %d (u starts @ %d, v starts @ %d)\n",
i, s->u_superblock_start, s->v_superblock_start);
/* time to re-assign the limits? */
if (i == 0) {
/* start of Y superblocks */
right_edge = s->fragment_width;
bottom_edge = s->fragment_height;
current_width = 0;
current_height = 0;
superblock_row_inc = 3 * s->fragment_width;
hilbert = hilbert_walk_y;
/* the first operation for this variable is to advance by 1 */
current_fragment = -1;
} else if (i == s->u_superblock_start) {
/* start of U superblocks */
right_edge = s->fragment_width / 2;
bottom_edge = s->fragment_height / 2;
current_width = 0;
current_height = 0;
superblock_row_inc = 3 * (s->fragment_width / 2);
hilbert = hilbert_walk_c;
/* the first operation for this variable is to advance by 1 */
current_fragment = s->u_fragment_start - 1;
} else if (i == s->v_superblock_start) {
/* start of V superblocks */
right_edge = s->fragment_width / 2;
bottom_edge = s->fragment_height / 2;
current_width = 0;
current_height = 0;
superblock_row_inc = 3 * (s->fragment_width / 2);
hilbert = hilbert_walk_c;
/* the first operation for this variable is to advance by 1 */
current_fragment = s->v_fragment_start - 1;
}
if (current_width >= right_edge) {
/* reset width and move to next superblock row */
current_width = 0;
current_height += 4;
/* fragment is now at the start of a new superblock row */
current_fragment += superblock_row_inc;
}
/* iterate through all 16 fragments in a superblock */
for (j = 0; j < 16; j++) {
current_fragment += hilbert[j];
current_height += travel_height[j];
/* check if the fragment is in bounds */
if ((current_width <= right_edge) &&
(current_height < bottom_edge)) {
s->superblock_fragments[mapping_index] = current_fragment;
debug_init(" mapping fragment %d to superblock %d, position %d\n",
s->superblock_fragments[mapping_index], i, j);
} else {
s->superblock_fragments[mapping_index] = -1;
debug_init(" superblock %d, position %d has no fragment\n",
i, j);
}
current_width += travel_width[j];
mapping_index++;
}
}
/* initialize the superblock <-> macroblock mapping; iterate through
* all of the Y plane superblocks to build this mapping */
right_edge = s->macroblock_width;
bottom_edge = s->macroblock_height;
current_width = 0;
current_height = 0;
superblock_row_inc = s->macroblock_width;
hilbert = hilbert_walk_mb;
mapping_index = 0;
current_macroblock = -1;
for (i = 0; i < s->u_superblock_start; i++) {
if (current_width >= right_edge) {
/* reset width and move to next superblock row */
current_width = 0;
current_height += 2;
/* macroblock is now at the start of a new superblock row */
current_macroblock += superblock_row_inc;
}
/* iterate through each potential macroblock in the superblock */
for (j = 0; j < 4; j++) {
current_macroblock += hilbert_walk_mb[j];
current_height += travel_height_mb[j];
/* check if the macroblock is in bounds */
if ((current_width <= right_edge) &&
(current_height < bottom_edge)) {
s->superblock_macroblocks[mapping_index] = current_macroblock;
debug_init(" mapping macroblock %d to superblock %d, position %d\n",
s->superblock_macroblocks[mapping_index], i, j);
} else {
s->superblock_macroblocks[mapping_index] = -1;
debug_init(" superblock %d, position %d has no macroblock\n",
i, j);
}
current_width += travel_width_mb[j];
mapping_index++;
}
}
/* initialize the macroblock <-> fragment mapping */
current_fragment = 0;
current_macroblock = 0;
mapping_index = 0;
for (i = 0; i < s->fragment_height; i += 2) {
for (j = 0; j < s->fragment_width; j += 2) {
debug_init(" macroblock %d contains fragments: ", current_macroblock);
s->all_fragments[current_fragment].macroblock = current_macroblock;
s->macroblock_fragments[mapping_index++] = current_fragment;
debug_init("%d ", current_fragment);
if (j + 1 < s->fragment_width) {
s->all_fragments[current_fragment + 1].macroblock = current_macroblock;
s->macroblock_fragments[mapping_index++] = current_fragment + 1;
debug_init("%d ", current_fragment + 1);
} else
s->macroblock_fragments[mapping_index++] = -1;
if (i + 1 < s->fragment_height) {
s->all_fragments[current_fragment + s->fragment_width].macroblock =
current_macroblock;
s->macroblock_fragments[mapping_index++] =
current_fragment + s->fragment_width;
debug_init("%d ", current_fragment + s->fragment_width);
} else
s->macroblock_fragments[mapping_index++] = -1;
if ((j + 1 < s->fragment_width) && (i + 1 < s->fragment_height)) {
s->all_fragments[current_fragment + s->fragment_width + 1].macroblock =
current_macroblock;
s->macroblock_fragments[mapping_index++] =
current_fragment + s->fragment_width + 1;
debug_init("%d ", current_fragment + s->fragment_width + 1);
} else
s->macroblock_fragments[mapping_index++] = -1;
/* C planes */
c_fragment = s->u_fragment_start +
(i * s->fragment_width / 4) + (j / 2);
s->all_fragments[c_fragment].macroblock = s->macroblock_count;
s->macroblock_fragments[mapping_index++] = c_fragment;
debug_init("%d ", c_fragment);
c_fragment = s->v_fragment_start +
(i * s->fragment_width / 4) + (j / 2);
s->all_fragments[c_fragment].macroblock = s->macroblock_count;
s->macroblock_fragments[mapping_index++] = c_fragment;
debug_init("%d ", c_fragment);
debug_init("\n");
if (j + 2 <= s->fragment_width)
current_fragment += 2;
else
current_fragment++;
current_macroblock++;
}
current_fragment += s->fragment_width;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_10999 | void m68k_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
unsigned int i;
for (i = 0; m68k_cpu_defs[i].name; i++) {
(*cpu_fprintf)(f, "%s\n", m68k_cpu_defs[i].name);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11016 | int acpi_pcihp_device_hotplug(AcpiPciHpState *s, PCIDevice *dev,
PCIHotplugState state)
{
int slot = PCI_SLOT(dev->devfn);
int bsel = acpi_pcihp_get_bsel(dev->bus);
if (bsel < 0) {
return -1;
}
/* Don't send event when device is enabled during qemu machine creation:
* it is present on boot, no hotplug event is necessary. We do send an
* event when the device is disabled later. */
if (state == PCI_COLDPLUG_ENABLED) {
s->acpi_pcihp_pci_status[bsel].device_present |= (1U << slot);
return 0;
}
if (state == PCI_HOTPLUG_ENABLED) {
enable_device(s, bsel, slot);
} else {
disable_device(s, bsel, slot);
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11026 | static void frame_start(H264Context *h){
MpegEncContext * const s = &h->s;
int i;
MPV_frame_start(s, s->avctx);
ff_er_frame_start(s);
assert(s->linesize && s->uvlinesize);
for(i=0; i<16; i++){
h->block_offset[i]= 4*((scan8[i] - scan8[0])&7) + 4*s->linesize*((scan8[i] - scan8[0])>>3);
h->block_offset[24+i]= 4*((scan8[i] - scan8[0])&7) + 8*s->linesize*((scan8[i] - scan8[0])>>3);
}
for(i=0; i<4; i++){
h->block_offset[16+i]=
h->block_offset[20+i]= 4*((scan8[i] - scan8[0])&7) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3);
h->block_offset[24+16+i]=
h->block_offset[24+20+i]= 4*((scan8[i] - scan8[0])&7) + 8*s->uvlinesize*((scan8[i] - scan8[0])>>3);
}
/* can't be in alloc_tables because linesize isn't known there.
* FIXME: redo bipred weight to not require extra buffer? */
if(!s->obmc_scratchpad)
s->obmc_scratchpad = av_malloc(16*s->linesize + 2*8*s->uvlinesize);
// s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11046 | static void test_flush_nodev(void)
{
QPCIDevice *dev;
QPCIBar bmdma_bar, ide_bar;
ide_test_start("");
dev = get_pci_device(&bmdma_bar, &ide_bar);
/* FLUSH CACHE command on device 0*/
qpci_io_writeb(dev, ide_bar, reg_device, 0);
qpci_io_writeb(dev, ide_bar, reg_command, CMD_FLUSH_CACHE);
/* Just testing that qemu doesn't crash... */
ide_test_quit();
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11070 | void qmp_guest_file_flush(int64_t handle, Error **errp)
{
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
FILE *fh;
int ret;
if (!gfh) {
return;
}
fh = gfh->fh;
ret = fflush(fh);
if (ret == EOF) {
error_setg_errno(errp, errno, "failed to flush file");
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11080 | static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){
MpegEncContext * const s = &h->s;
Picture * const ref1 = &h->ref_list[1][0];
int j, old_ref, rfield;
int start= mbafi ? 16 : 0;
int end = mbafi ? 16+2*h->ref_count[0] : h->ref_count[0];
int interl= mbafi || s->picture_structure != PICT_FRAME;
/* bogus; fills in for missing frames */
memset(map[list], 0, sizeof(map[list]));
for(rfield=0; rfield<2; rfield++){
for(old_ref=0; old_ref<ref1->ref_count[colfield][list]; old_ref++){
int poc = ref1->ref_poc[colfield][list][old_ref];
if (!interl)
poc |= 3;
else if( interl && (poc&3) == 3) //FIXME store all MBAFF references so this isnt needed
poc= (poc&~3) + rfield + 1;
for(j=start; j<end; j++){
if (4 * h->ref_list[0][j].frame_num + (h->ref_list[0][j].f.reference & 3) == poc) {
int cur_ref= mbafi ? (j-16)^field : j;
map[list][2*old_ref + (rfield^field) + 16] = cur_ref;
if(rfield == field || !interl)
map[list][old_ref] = cur_ref;
break;
}
}
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11084 | static void compute_frame_duration(int *pnum, int *pden,
AVFormatContext *s, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
int frame_size;
*pnum = 0;
*pden = 0;
switch(st->codec.codec_type) {
case CODEC_TYPE_VIDEO:
*pnum = st->codec.frame_rate_base;
*pden = st->codec.frame_rate;
if (pc && pc->repeat_pict) {
*pden *= 2;
*pnum = (*pnum) * (2 + pc->repeat_pict);
}
break;
case CODEC_TYPE_AUDIO:
frame_size = get_audio_frame_size(&st->codec, pkt->size);
if (frame_size < 0)
break;
*pnum = frame_size;
*pden = st->codec.sample_rate;
break;
default:
break;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11113 | static int os_host_main_loop_wait(int64_t timeout)
{
GMainContext *context = g_main_context_default();
GPollFD poll_fds[1024 * 2]; /* this is probably overkill */
int select_ret = 0;
int g_poll_ret, ret, i, n_poll_fds;
PollingEntry *pe;
WaitObjects *w = &wait_objects;
gint poll_timeout;
int64_t poll_timeout_ns;
static struct timeval tv0;
fd_set rfds, wfds, xfds;
int nfds;
/* XXX: need to suppress polling by better using win32 events */
ret = 0;
for (pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
if (ret != 0) {
return ret;
}
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
if (nfds >= 0) {
select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
if (select_ret != 0) {
timeout = 0;
}
if (select_ret > 0) {
pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
}
}
g_main_context_prepare(context, &max_priority);
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
poll_fds, ARRAY_SIZE(poll_fds));
g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
for (i = 0; i < w->num; i++) {
poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
poll_fds[n_poll_fds + i].events = G_IO_IN;
}
if (poll_timeout < 0) {
poll_timeout_ns = -1;
} else {
poll_timeout_ns = (int64_t)poll_timeout * (int64_t)SCALE_MS;
}
poll_timeout_ns = qemu_soonest_timeout(poll_timeout_ns, timeout);
qemu_mutex_unlock_iothread();
g_poll_ret = qemu_poll_ns(poll_fds, n_poll_fds + w->num, poll_timeout_ns);
qemu_mutex_lock_iothread();
if (g_poll_ret > 0) {
for (i = 0; i < w->num; i++) {
w->revents[i] = poll_fds[n_poll_fds + i].revents;
}
for (i = 0; i < w->num; i++) {
if (w->revents[i] && w->func[i]) {
w->func[i](w->opaque[i]);
}
}
}
if (g_main_context_check(context, max_priority, poll_fds, n_poll_fds)) {
g_main_context_dispatch(context);
}
return select_ret || g_poll_ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11117 | int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
{
BlockDriver *drv = bs->drv;
if (!drv) {
return -ENOMEDIUM;
}
if (drv->bdrv_snapshot_delete) {
return drv->bdrv_snapshot_delete(bs, snapshot_id);
}
if (bs->file) {
return bdrv_snapshot_delete(bs->file, snapshot_id);
}
return -ENOTSUP;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11126 | static uint32_t pci_apb_ioreadl (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = bswap32(cpu_inl(addr & IOPORTS_MASK));
return val;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11127 | static void qemu_fill_buffer(QEMUFile *f)
{
int len;
if (f->is_writable)
return;
if (f->is_file) {
fseek(f->outfile, f->buf_offset, SEEK_SET);
len = fread(f->buf, 1, IO_BUF_SIZE, f->outfile);
if (len < 0)
len = 0;
} else {
len = bdrv_pread(f->bs, f->base_offset + f->buf_offset,
f->buf, IO_BUF_SIZE);
if (len < 0)
len = 0;
}
f->buf_index = 0;
f->buf_size = len;
f->buf_offset += len;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11128 | void net_hub_check_clients(void)
{
NetHub *hub;
NetHubPort *port;
NetClientState *peer;
QLIST_FOREACH(hub, &hubs, next) {
int has_nic = 0, has_host_dev = 0;
QLIST_FOREACH(port, &hub->ports, next) {
peer = port->nc.peer;
if (!peer) {
fprintf(stderr, "Warning: hub port %s has no peer\n",
port->nc.name);
continue;
}
switch (peer->info->type) {
case NET_CLIENT_DRIVER_NIC:
has_nic = 1;
break;
case NET_CLIENT_DRIVER_USER:
case NET_CLIENT_DRIVER_TAP:
case NET_CLIENT_DRIVER_SOCKET:
case NET_CLIENT_DRIVER_VDE:
case NET_CLIENT_DRIVER_VHOST_USER:
has_host_dev = 1;
break;
default:
break;
}
}
if (has_host_dev && !has_nic) {
warn_report("vlan %d with no nics", hub->id);
}
if (has_nic && !has_host_dev) {
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
hub->id);
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11140 | DVDemuxContext* dv_init_demux(AVFormatContext *s)
{
DVDemuxContext *c;
c = av_mallocz(sizeof(DVDemuxContext));
if (!c)
return NULL;
c->vst = av_new_stream(s, 0);
c->ast[0] = av_new_stream(s, 0);
if (!c->vst || !c->ast[0])
goto fail;
av_set_pts_info(c->vst, 64, 1, 30000);
av_set_pts_info(c->ast[0], 64, 1, 30000);
c->fctx = s;
c->ast[1] = NULL;
c->ach = 0;
c->frames = 0;
c->abytes = 0;
c->audio_pkt[0].size = 0;
c->audio_pkt[1].size = 0;
c->vst->codec.codec_type = CODEC_TYPE_VIDEO;
c->vst->codec.codec_id = CODEC_ID_DVVIDEO;
c->vst->codec.bit_rate = 25000000;
c->ast[0]->codec.codec_type = CODEC_TYPE_AUDIO;
c->ast[0]->codec.codec_id = CODEC_ID_PCM_S16LE;
s->ctx_flags |= AVFMTCTX_NOHEADER;
return c;
fail:
if (c->vst)
av_free(c->vst);
if (c->ast[0])
av_free(c->ast[0]);
av_free(c);
return NULL;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11141 | static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment,
bs->bl.request_alignment);
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
MAX_WRITE_ZEROES_BOUNCE_BUFFER);
assert(alignment % bs->bl.request_alignment == 0);
head = offset % alignment;
tail = (offset + bytes) % alignment;
max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
assert(max_write_zeroes >= bs->bl.request_alignment);
while (bytes > 0 && !ret) {
int num = bytes;
/* Align request. Block drivers can expect the "bulk" of the request
* to be aligned, and that unaligned requests do not cross cluster
* boundaries.
*/
if (head) {
/* Make a small request up to the first aligned sector. For
* convenience, limit this request to max_transfer even if
* we don't need to fall back to writes. */
num = MIN(MIN(bytes, max_transfer), alignment - head);
head = (head + num) % alignment;
assert(num < max_write_zeroes);
} else if (tail && num > alignment) {
/* Shorten the request to the last aligned sector. */
num -= tail;
}
/* limit request size */
if (num > max_write_zeroes) {
num = max_write_zeroes;
}
ret = -ENOTSUP;
/* First try the efficient write zeroes operation */
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
}
} else {
assert(!bs->supported_zero_flags);
}
if (ret == -ENOTSUP) {
/* Fall back to bounce buffer if write zeroes is unsupported */
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
/* No need for bdrv_driver_pwrite() to do a fallback
* flush on each chunk; use just one at the end */
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
}
num = MIN(num, max_transfer);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
}
memset(iov.iov_base, 0, num);
}
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
/* Keep bounce buffer around if it is big enough for all
* all future requests.
*/
if (num < max_transfer) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
}
}
offset += num;
bytes -= num;
}
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
}
qemu_vfree(iov.iov_base);
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11142 | static void openpic_save_IRQ_queue(QEMUFile* f, IRQQueue *q)
{
unsigned int i;
for (i = 0; i < BF_WIDTH(MAX_IRQ); i++)
qemu_put_be32s(f, &q->queue[i]);
qemu_put_sbe32s(f, &q->next);
qemu_put_sbe32s(f, &q->priority);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11143 | static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
{
uint32_t entry;
EHCIQueue *q;
int reload;
entry = ehci_get_fetch_addr(ehci, async);
q = ehci_find_queue_by_qh(ehci, entry);
if (NULL == q) {
q = ehci_alloc_queue(ehci, async);
}
q->qhaddr = entry;
q->seen++;
if (q->seen > 1) {
/* we are going in circles -- stop processing */
ehci_set_state(ehci, async, EST_ACTIVE);
q = NULL;
goto out;
}
get_dwords(NLPTR_GET(q->qhaddr), (uint32_t *) &q->qh, sizeof(EHCIqh) >> 2);
ehci_trace_qh(q, NLPTR_GET(q->qhaddr), &q->qh);
if (q->async == EHCI_ASYNC_INFLIGHT) {
/* I/O still in progress -- skip queue */
ehci_set_state(ehci, async, EST_HORIZONTALQH);
goto out;
}
if (q->async == EHCI_ASYNC_FINISHED) {
/* I/O finished -- continue processing queue */
trace_usb_ehci_queue_action(q, "resume");
ehci_set_state(ehci, async, EST_EXECUTING);
goto out;
}
if (async && (q->qh.epchar & QH_EPCHAR_H)) {
/* EHCI spec version 1.0 Section 4.8.3 & 4.10.1 */
if (ehci->usbsts & USBSTS_REC) {
ehci_clear_usbsts(ehci, USBSTS_REC);
} else {
DPRINTF("FETCHQH: QH 0x%08x. H-bit set, reclamation status reset"
" - done processing\n", q->qhaddr);
ehci_set_state(ehci, async, EST_ACTIVE);
q = NULL;
goto out;
}
}
#if EHCI_DEBUG
if (q->qhaddr != q->qh.next) {
DPRINTF("FETCHQH: QH 0x%08x (h %x halt %x active %x) next 0x%08x\n",
q->qhaddr,
q->qh.epchar & QH_EPCHAR_H,
q->qh.token & QTD_TOKEN_HALT,
q->qh.token & QTD_TOKEN_ACTIVE,
q->qh.next);
}
#endif
reload = get_field(q->qh.epchar, QH_EPCHAR_RL);
if (reload) {
set_field(&q->qh.altnext_qtd, reload, QH_ALTNEXT_NAKCNT);
}
if (q->qh.token & QTD_TOKEN_HALT) {
ehci_set_state(ehci, async, EST_HORIZONTALQH);
} else if ((q->qh.token & QTD_TOKEN_ACTIVE) && (q->qh.current_qtd > 0x1000)) {
q->qtdaddr = q->qh.current_qtd;
ehci_set_state(ehci, async, EST_FETCHQTD);
} else {
/* EHCI spec version 1.0 Section 4.10.2 */
ehci_set_state(ehci, async, EST_ADVANCEQUEUE);
}
out:
return q;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11167 | static void omap_rtc_reset(struct omap_rtc_s *s)
{
struct tm tm;
s->interrupts = 0;
s->comp_reg = 0;
s->running = 0;
s->pm_am = 0;
s->auto_comp = 0;
s->round = 0;
s->tick = qemu_get_clock(rt_clock);
memset(&s->alarm_tm, 0, sizeof(s->alarm_tm));
s->alarm_tm.tm_mday = 0x01;
s->status = 1 << 7;
qemu_get_timedate(&tm, 0);
s->ti = mktimegm(&tm);
omap_rtc_alarm_update(s);
omap_rtc_tick(s);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11193 | static void tosa_init(MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *rom = g_new(MemoryRegion, 1);
PXA2xxState *mpu;
TC6393xbState *tmio;
DeviceState *scp0, *scp1;
if (!cpu_model)
cpu_model = "pxa255";
mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
memory_region_init_ram(rom, NULL, "tosa.rom", TOSA_ROM, &error_abort);
vmstate_register_ram_global(rom);
memory_region_set_readonly(rom, true);
memory_region_add_subregion(address_space_mem, 0, rom);
tmio = tc6393xb_init(address_space_mem, 0x10000000,
qdev_get_gpio_in(mpu->gpio, TOSA_GPIO_TC6393XB_INT));
scp0 = sysbus_create_simple("scoop", 0x08800000, NULL);
scp1 = sysbus_create_simple("scoop", 0x14800040, NULL);
tosa_gpio_setup(mpu, scp0, scp1, tmio);
tosa_microdrive_attach(mpu);
tosa_tg_init(mpu);
tosa_binfo.kernel_filename = kernel_filename;
tosa_binfo.kernel_cmdline = kernel_cmdline;
tosa_binfo.initrd_filename = initrd_filename;
tosa_binfo.board_id = 0x208;
arm_load_kernel(mpu->cpu, &tosa_binfo);
sl_bootparam_write(SL_PXA_PARAM_BASE);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11202 | static void get_sensor_evt_enable(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMISensor *sens;
IPMI_CHECK_CMD_LEN(3);
if ((cmd[2] > MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
sens = ibs->sensors + cmd[2];
IPMI_ADD_RSP_DATA(IPMI_SENSOR_GET_RET_STATUS(sens));
IPMI_ADD_RSP_DATA(sens->assert_enable & 0xff);
IPMI_ADD_RSP_DATA((sens->assert_enable >> 8) & 0xff);
IPMI_ADD_RSP_DATA(sens->deassert_enable & 0xff);
IPMI_ADD_RSP_DATA((sens->deassert_enable >> 8) & 0xff);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11235 | struct omap_uart_s *omap_uart_init(hwaddr base,
qemu_irq irq, omap_clk fclk, omap_clk iclk,
qemu_irq txdma, qemu_irq rxdma,
const char *label, CharDriverState *chr)
{
struct omap_uart_s *s = (struct omap_uart_s *)
g_malloc0(sizeof(struct omap_uart_s));
s->base = base;
s->fclk = fclk;
s->irq = irq;
s->serial = serial_mm_init(get_system_memory(), base, 2, irq,
omap_clk_getrate(fclk)/16,
chr ?: qemu_chr_new(label, "null", NULL),
DEVICE_NATIVE_ENDIAN);
return s;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11268 | static int create_dynamic_disk(int fd, uint8_t *buf, int64_t total_sectors)
{
VHDDynDiskHeader *dyndisk_header =
(VHDDynDiskHeader *) buf;
size_t block_size, num_bat_entries;
int i;
int ret = -EIO;
// Write the footer (twice: at the beginning and at the end)
block_size = 0x200000;
num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) {
goto fail;
}
if (lseek(fd, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0) {
goto fail;
}
if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) {
goto fail;
}
// Write the initial BAT
if (lseek(fd, 3 * 512, SEEK_SET) < 0) {
goto fail;
}
memset(buf, 0xFF, 512);
for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) {
if (write(fd, buf, 512) != 512) {
goto fail;
}
}
// Prepare the Dynamic Disk Header
memset(buf, 0, 1024);
memcpy(dyndisk_header->magic, "cxsparse", 8);
/*
* Note: The spec is actually wrong here for data_offset, it says
* 0xFFFFFFFF, but MS tools expect all 64 bits to be set.
*/
dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL);
dyndisk_header->table_offset = be64_to_cpu(3 * 512);
dyndisk_header->version = be32_to_cpu(0x00010000);
dyndisk_header->block_size = be32_to_cpu(block_size);
dyndisk_header->max_table_entries = be32_to_cpu(num_bat_entries);
dyndisk_header->checksum = be32_to_cpu(vpc_checksum(buf, 1024));
// Write the header
if (lseek(fd, 512, SEEK_SET) < 0) {
goto fail;
}
if (write(fd, buf, 1024) != 1024) {
goto fail;
}
ret = 0;
fail:
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11303 | static int qemu_rbd_snap_list(BlockDriverState *bs,
QEMUSnapshotInfo **psn_tab)
{
BDRVRBDState *s = bs->opaque;
QEMUSnapshotInfo *sn_info, *sn_tab = NULL;
int i, snap_count;
rbd_snap_info_t *snaps;
int max_snaps = RBD_MAX_SNAPS;
do {
snaps = g_malloc(sizeof(*snaps) * max_snaps);
snap_count = rbd_snap_list(s->image, snaps, &max_snaps);
if (snap_count < 0) {
g_free(snaps);
}
} while (snap_count == -ERANGE);
if (snap_count <= 0) {
return snap_count;
}
sn_tab = g_malloc0(snap_count * sizeof(QEMUSnapshotInfo));
for (i = 0; i < snap_count; i++) {
const char *snap_name = snaps[i].name;
sn_info = sn_tab + i;
pstrcpy(sn_info->id_str, sizeof(sn_info->id_str), snap_name);
pstrcpy(sn_info->name, sizeof(sn_info->name), snap_name);
sn_info->vm_state_size = snaps[i].size;
sn_info->date_sec = 0;
sn_info->date_nsec = 0;
sn_info->vm_clock_nsec = 0;
}
rbd_snap_list_end(snaps);
*psn_tab = sn_tab;
return snap_count;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11316 | static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
MMUAccessType access_type, ARMMMUIdx mmu_idx,
hwaddr *phys_ptr, int *prot, uint32_t *fsr)
{
ARMCPU *cpu = arm_env_get_cpu(env);
bool is_user = regime_is_user(env, mmu_idx);
int n;
int matchregion = -1;
bool hit = false;
*phys_ptr = address;
*prot = 0;
/* Unlike the ARM ARM pseudocode, we don't need to check whether this
* was an exception vector read from the vector table (which is always
* done using the default system address map), because those accesses
* are done in arm_v7m_load_vector(), which always does a direct
* read using address_space_ldl(), rather than going via this function.
*/
if (regime_translation_disabled(env, mmu_idx)) { /* MPU disabled */
hit = true;
} else if (m_is_ppb_region(env, address)) {
hit = true;
} else if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
hit = true;
} else {
for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
/* region search */
/* Note that the base address is bits [31:5] from the register
* with bits [4:0] all zeroes, but the limit address is bits
* [31:5] from the register with bits [4:0] all ones.
*/
uint32_t base = env->pmsav8.rbar[n] & ~0x1f;
uint32_t limit = env->pmsav8.rlar[n] | 0x1f;
if (!(env->pmsav8.rlar[n] & 0x1)) {
/* Region disabled */
continue;
}
if (address < base || address > limit) {
continue;
}
if (hit) {
/* Multiple regions match -- always a failure (unlike
* PMSAv7 where highest-numbered-region wins)
*/
*fsr = 0x00d; /* permission fault */
return true;
}
matchregion = n;
hit = true;
if (base & ~TARGET_PAGE_MASK) {
qemu_log_mask(LOG_UNIMP,
"MPU_RBAR[%d]: No support for MPU region base"
"address of 0x%" PRIx32 ". Minimum alignment is "
"%d\n",
n, base, TARGET_PAGE_BITS);
continue;
}
if ((limit + 1) & ~TARGET_PAGE_MASK) {
qemu_log_mask(LOG_UNIMP,
"MPU_RBAR[%d]: No support for MPU region limit"
"address of 0x%" PRIx32 ". Minimum alignment is "
"%d\n",
n, limit, TARGET_PAGE_BITS);
continue;
}
}
}
if (!hit) {
/* background fault */
*fsr = 0;
return true;
}
if (matchregion == -1) {
/* hit using the background region */
get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
} else {
uint32_t ap = extract32(env->pmsav8.rbar[matchregion], 1, 2);
uint32_t xn = extract32(env->pmsav8.rbar[matchregion], 0, 1);
if (m_is_system_region(env, address)) {
/* System space is always execute never */
xn = 1;
}
*prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
if (*prot && !xn) {
*prot |= PAGE_EXEC;
}
/* We don't need to look the attribute up in the MAIR0/MAIR1
* registers because that only tells us about cacheability.
*/
}
*fsr = 0x00d; /* Permission fault */
return !(*prot & (1 << access_type));
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_11328 | static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
uint64_t off, uint32_t max_count)
{
ssize_t err;
size_t offset = 7;
int read_count;
int64_t xattr_len;
V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
VirtQueueElement *elem = v->elems[pdu->idx];
xattr_len = fidp->fs.xattr.len;
read_count = xattr_len - off;
if (read_count > max_count) {
read_count = max_count;
} else if (read_count < 0) {
/*
* read beyond XATTR value
*/
read_count = 0;
}
err = pdu_marshal(pdu, offset, "d", read_count);
if (err < 0) {
return err;
}
offset += err;
err = v9fs_pack(elem->in_sg, elem->in_num, offset,
((char *)fidp->fs.xattr.value) + off,
read_count);
if (err < 0) {
return err;
}
offset += err;
return offset;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11334 | static coroutine_fn int vmdk_co_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
int ret;
BDRVVmdkState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
ret = vmdk_write(bs, sector_num, buf, nb_sectors);
qemu_co_mutex_unlock(&s->lock);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11359 | int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
uint8_t *dst, int dlen)
{
uint32_t zrun_len = 0, nzrun_len = 0;
int d = 0, i = 0;
long res, xor;
uint8_t *nzrun_start = NULL;
g_assert(!(((uintptr_t)old_buf | (uintptr_t)new_buf | slen) %
sizeof(long)));
while (i < slen) {
/* overflow */
if (d + 2 > dlen) {
return -1;
}
/* not aligned to sizeof(long) */
res = (slen - i) % sizeof(long);
while (res && old_buf[i] == new_buf[i]) {
zrun_len++;
i++;
res--;
}
/* word at a time for speed */
if (!res) {
while (i < slen &&
(*(long *)(old_buf + i)) == (*(long *)(new_buf + i))) {
i += sizeof(long);
zrun_len += sizeof(long);
}
/* go over the rest */
while (i < slen && old_buf[i] == new_buf[i]) {
zrun_len++;
i++;
}
}
/* buffer unchanged */
if (zrun_len == slen) {
return 0;
}
/* skip last zero run */
if (i == slen) {
return d;
}
d += uleb128_encode_small(dst + d, zrun_len);
zrun_len = 0;
nzrun_start = new_buf + i;
/* overflow */
if (d + 2 > dlen) {
return -1;
}
/* not aligned to sizeof(long) */
res = (slen - i) % sizeof(long);
while (res && old_buf[i] != new_buf[i]) {
i++;
nzrun_len++;
res--;
}
/* word at a time for speed, use of 32-bit long okay */
if (!res) {
/* truncation to 32-bit long okay */
long mask = (long)0x0101010101010101ULL;
while (i < slen) {
xor = *(long *)(old_buf + i) ^ *(long *)(new_buf + i);
if ((xor - mask) & ~xor & (mask << 7)) {
/* found the end of an nzrun within the current long */
while (old_buf[i] != new_buf[i]) {
nzrun_len++;
i++;
}
break;
} else {
i += sizeof(long);
nzrun_len += sizeof(long);
}
}
}
d += uleb128_encode_small(dst + d, nzrun_len);
/* overflow */
if (d + nzrun_len > dlen) {
return -1;
}
memcpy(dst + d, nzrun_start, nzrun_len);
d += nzrun_len;
nzrun_len = 0;
}
return d;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11361 | static av_cold void init_atrac3_transforms(ATRAC3Context *q) {
float enc_window[256];
int i;
/* Generate the mdct window, for details see
* http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
for (i=0 ; i<256; i++)
enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5;
if (!mdct_window[0])
for (i=0 ; i<256; i++) {
mdct_window[i] = enc_window[i]/(enc_window[i]*enc_window[i] + enc_window[255-i]*enc_window[255-i]);
mdct_window[511-i] = mdct_window[i];
}
/* Initialize the MDCT transform. */
ff_mdct_init(&mdct_ctx, 9, 1, 1.0);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11368 | static void gd_resize(DisplayChangeListener *dcl,
DisplayState *ds)
{
GtkDisplayState *s = ds->opaque;
cairo_format_t kind;
int stride;
DPRINTF("resize(width=%d, height=%d)\n",
ds_get_width(ds), ds_get_height(ds));
if (s->surface) {
cairo_surface_destroy(s->surface);
}
switch (ds->surface->pf.bits_per_pixel) {
case 8:
kind = CAIRO_FORMAT_A8;
break;
case 16:
kind = CAIRO_FORMAT_RGB16_565;
break;
case 32:
kind = CAIRO_FORMAT_RGB24;
break;
default:
g_assert_not_reached();
break;
}
stride = cairo_format_stride_for_width(kind, ds_get_width(ds));
g_assert(ds_get_linesize(ds) == stride);
s->surface = cairo_image_surface_create_for_data(ds_get_data(ds),
kind,
ds_get_width(ds),
ds_get_height(ds),
ds_get_linesize(ds));
if (!s->full_screen) {
GtkRequisition req;
double sx, sy;
if (s->free_scale) {
sx = s->scale_x;
sy = s->scale_y;
s->scale_y = 1.0;
s->scale_x = 1.0;
} else {
sx = 1.0;
sy = 1.0;
}
gtk_widget_set_size_request(s->drawing_area,
ds_get_width(ds) * s->scale_x,
ds_get_height(ds) * s->scale_y);
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_get_preferred_size(s->vbox, NULL, &req);
#else
gtk_widget_size_request(s->vbox, &req);
#endif
gtk_window_resize(GTK_WINDOW(s->window),
req.width * sx, req.height * sy);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_11381 | void lm32_juart_set_jtx(DeviceState *d, uint32_t jtx)
{
LM32JuartState *s = LM32_JUART(d);
unsigned char ch = jtx & 0xff;
trace_lm32_juart_set_jtx(s->jtx);
s->jtx = jtx;
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &ch, 1);
}
}
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.