id stringlengths 22 26 | content stringlengths 72 142k |
|---|---|
devign_test_set_data_25081 | static inline void idct_col(int16_t *blk, const uint8_t *quant)
{
int t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, tA, tB, tC, tD, tE, tF;
int t10, t11, t12, t13;
int s0, s1, s2, s3, s4, s5, s6, s7;
s0 = (int) blk[0 * 8] * quant[0 * 8];
s1 = (int) blk[1 * 8] * quant[1 * 8];
s2 = (int) blk[2 * 8] * quant[2 * 8];
s3 = (int) blk[3 * 8] * quant[3 * 8];
s4 = (int) blk[4 * 8] * quant[4 * 8];
s5 = (int) blk[5 * 8] * quant[5 * 8];
s6 = (int) blk[6 * 8] * quant[6 * 8];
s7 = (int) blk[7 * 8] * quant[7 * 8];
t0 = (s3 * 19266 + s5 * 12873) >> 15;
t1 = (s5 * 19266 - s3 * 12873) >> 15;
t2 = ((s7 * 4520 + s1 * 22725) >> 15) - t0;
t3 = ((s1 * 4520 - s7 * 22725) >> 15) - t1;
t4 = t0 * 2 + t2;
t5 = t1 * 2 + t3;
t6 = t2 - t3;
t7 = t3 * 2 + t6;
t8 = (t6 * 11585) >> 14;
t9 = (t7 * 11585) >> 14;
tA = (s2 * 8867 - s6 * 21407) >> 14;
tB = (s6 * 8867 + s2 * 21407) >> 14;
tC = (s0 >> 1) - (s4 >> 1);
tD = (s4 >> 1) * 2 + tC;
tE = tC - (tA >> 1);
tF = tD - (tB >> 1);
t10 = tF - t5;
t11 = tE - t8;
t12 = tE + (tA >> 1) * 2 - t9;
t13 = tF + (tB >> 1) * 2 - t4;
blk[0 * 8] = t13 + t4 * 2;
blk[1 * 8] = t12 + t9 * 2;
blk[2 * 8] = t11 + t8 * 2;
blk[3 * 8] = t10 + t5 * 2;
blk[4 * 8] = t10;
blk[5 * 8] = t11;
blk[6 * 8] = t12;
blk[7 * 8] = t13;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25091 | static int fourxm_probe(AVProbeData *p)
{
if (p->buf_size < 12)
return 0;
if ((AV_RL32(&p->buf[0]) != RIFF_TAG) ||
(AV_RL32(&p->buf[8]) != _4XMV_TAG))
return 0;
return AVPROBE_SCORE_MAX;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25095 | static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
ScanTable *intra_scantable,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64],
int hsample[3])
{
int i, j, size;
uint8_t *ptr;
MpegEncContext *s = avctx->priv_data;
if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
int matrix_count = 1 + !!memcmp(luma_intra_matrix,
chroma_intra_matrix,
sizeof(luma_intra_matrix[0]) * 64);
if (s->force_duplicated_matrix)
matrix_count = 2;
/* quant matrixes */
put_marker(p, DQT);
put_bits(p, 16, 2 + matrix_count * (1 + 64));
put_bits(p, 4, 0); /* 8 bit precision */
put_bits(p, 4, 0); /* table 0 */
for(i=0;i<64;i++) {
j = intra_scantable->permutated[i];
put_bits(p, 8, luma_intra_matrix[j]);
}
if (matrix_count > 1) {
put_bits(p, 4, 0); /* 8 bit precision */
put_bits(p, 4, 1); /* table 1 */
for(i=0;i<64;i++) {
j = intra_scantable->permutated[i];
put_bits(p, 8, chroma_intra_matrix[j]);
}
}
}
if(avctx->active_thread_type & FF_THREAD_SLICE){
put_marker(p, DRI);
put_bits(p, 16, 4);
put_bits(p, 16, (avctx->width-1)/(8*hsample[0]) + 1);
}
/* huffman table */
put_marker(p, DHT);
flush_put_bits(p);
ptr = put_bits_ptr(p);
put_bits(p, 16, 0); /* patched later */
size = 2;
// Only MJPEG can have a variable Huffman variable. All other
// formats use the default Huffman table.
if (s->out_format == FMT_MJPEG && s->huffman == HUFFMAN_TABLE_OPTIMAL) {
size += put_huffman_table(p, 0, 0, s->mjpeg_ctx->bits_dc_luminance,
s->mjpeg_ctx->val_dc_luminance);
size += put_huffman_table(p, 0, 1, s->mjpeg_ctx->bits_dc_chrominance,
s->mjpeg_ctx->val_dc_chrominance);
size += put_huffman_table(p, 1, 0, s->mjpeg_ctx->bits_ac_luminance,
s->mjpeg_ctx->val_ac_luminance);
size += put_huffman_table(p, 1, 1, s->mjpeg_ctx->bits_ac_chrominance,
s->mjpeg_ctx->val_ac_chrominance);
} else {
size += put_huffman_table(p, 0, 0, avpriv_mjpeg_bits_dc_luminance,
avpriv_mjpeg_val_dc);
size += put_huffman_table(p, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
avpriv_mjpeg_val_dc);
size += put_huffman_table(p, 1, 0, avpriv_mjpeg_bits_ac_luminance,
avpriv_mjpeg_val_ac_luminance);
size += put_huffman_table(p, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
avpriv_mjpeg_val_ac_chrominance);
}
AV_WB16(ptr, size);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25103 | static void ppc_spapr_init(MachineState *machine)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
PowerPCCPU *cpu;
PCIHostState *phb;
int i;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *rma_region;
void *rma = NULL;
hwaddr rma_alloc_size;
hwaddr node0_size = spapr_node0_size();
uint32_t initrd_base = 0;
long kernel_size = 0, initrd_size = 0;
long load_limit, fw_size;
bool kernel_le = false;
char *filename;
msi_supported = true;
QLIST_INIT(&spapr->phbs);
cpu_ppc_hypercall = emulate_spapr_hypercall;
/* Allocate RMA if necessary */
rma_alloc_size = kvmppc_alloc_rma(&rma);
if (rma_alloc_size == -1) {
error_report("Unable to create RMA");
exit(1);
}
if (rma_alloc_size && (rma_alloc_size < node0_size)) {
spapr->rma_size = rma_alloc_size;
} else {
spapr->rma_size = node0_size;
/* With KVM, we don't actually know whether KVM supports an
* unbounded RMA (PR KVM) or is limited by the hash table size
* (HV KVM using VRMA), so we always assume the latter
*
* In that case, we also limit the initial allocations for RTAS
* etc... to 256M since we have no way to know what the VRMA size
* is going to be as it depends on the size of the hash table
* isn't determined yet.
*/
if (kvm_enabled()) {
spapr->vrma_adjust = 1;
spapr->rma_size = MIN(spapr->rma_size, 0x10000000);
}
}
if (spapr->rma_size > node0_size) {
error_report("Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")",
spapr->rma_size);
exit(1);
}
/* Setup a load limit for the ramdisk leaving room for SLOF and FDT */
load_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR) - FW_OVERHEAD;
/* We aim for a hash table of size 1/128 the size of RAM. The
* normal rule of thumb is 1/64 the size of RAM, but that's much
* more than needed for the Linux guests we support. */
spapr->htab_shift = 18; /* Minimum architected size */
while (spapr->htab_shift <= 46) {
if ((1ULL << (spapr->htab_shift + 7)) >= machine->maxram_size) {
break;
}
spapr->htab_shift++;
}
spapr_alloc_htab(spapr);
/* Set up Interrupt Controller before we create the VCPUs */
spapr->icp = xics_system_init(machine,
DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(),
smp_threads),
XICS_IRQS, &error_fatal);
if (smc->dr_lmb_enabled) {
spapr_validate_node_memory(machine, &error_fatal);
}
/* init CPUs */
if (machine->cpu_model == NULL) {
machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_ppc_init(machine->cpu_model);
if (cpu == NULL) {
error_report("Unable to find PowerPC CPU definition");
exit(1);
}
spapr_cpu_init(spapr, cpu, &error_fatal);
}
if (kvm_enabled()) {
/* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */
kvmppc_enable_logical_ci_hcalls();
kvmppc_enable_set_mode_hcall();
}
/* allocate RAM */
memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
machine->ram_size);
memory_region_add_subregion(sysmem, 0, ram);
if (rma_alloc_size && rma) {
rma_region = g_new(MemoryRegion, 1);
memory_region_init_ram_ptr(rma_region, NULL, "ppc_spapr.rma",
rma_alloc_size, rma);
vmstate_register_ram_global(rma_region);
memory_region_add_subregion(sysmem, 0, rma_region);
}
/* initialize hotplug memory address space */
if (machine->ram_size < machine->maxram_size) {
ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) {
error_report("Specified number of memory slots %"
PRIu64" exceeds max supported %d",
machine->ram_slots, SPAPR_MAX_RAM_SLOTS);
exit(1);
}
spapr->hotplug_memory.base = ROUND_UP(machine->ram_size,
SPAPR_HOTPLUG_MEM_ALIGN);
memory_region_init(&spapr->hotplug_memory.mr, OBJECT(spapr),
"hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(sysmem, spapr->hotplug_memory.base,
&spapr->hotplug_memory.mr);
}
if (smc->dr_lmb_enabled) {
spapr_create_lmb_dr_connectors(spapr);
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
if (!filename) {
error_report("Could not find LPAR rtas '%s'", "spapr-rtas.bin");
exit(1);
}
spapr->rtas_size = get_image_size(filename);
spapr->rtas_blob = g_malloc(spapr->rtas_size);
if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
error_report("Could not load LPAR rtas '%s'", filename);
exit(1);
}
if (spapr->rtas_size > RTAS_MAX_SIZE) {
error_report("RTAS too big ! 0x%zx bytes (max is 0x%x)",
(size_t)spapr->rtas_size, RTAS_MAX_SIZE);
exit(1);
}
g_free(filename);
/* Set up EPOW events infrastructure */
spapr_events_init(spapr);
/* Set up the RTC RTAS interfaces */
spapr_rtc_create(spapr);
/* Set up VIO bus */
spapr->vio_bus = spapr_vio_bus_init();
for (i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
spapr_vty_create(spapr->vio_bus, serial_hds[i]);
}
}
/* We always have at least the nvram device on VIO */
spapr_create_nvram(spapr);
/* Set up PCI */
spapr_pci_rtas_init();
phb = spapr_create_phb(spapr, 0);
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!nd->model) {
nd->model = g_strdup("ibmveth");
}
if (strcmp(nd->model, "ibmveth") == 0) {
spapr_vlan_create(spapr->vio_bus, nd);
} else {
pci_nic_init_nofail(&nd_table[i], phb->bus, nd->model, NULL);
}
}
for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) {
spapr_vscsi_create(spapr->vio_bus);
}
/* Graphics */
if (spapr_vga_init(phb->bus, &error_fatal)) {
spapr->has_graphics = true;
machine->usb |= defaults_enabled() && !machine->usb_disabled;
}
if (machine->usb) {
if (smc->use_ohci_by_default) {
pci_create_simple(phb->bus, -1, "pci-ohci");
} else {
pci_create_simple(phb->bus, -1, "nec-usb-xhci");
}
if (spapr->has_graphics) {
USBBus *usb_bus = usb_bus_find(-1);
usb_create_simple(usb_bus, "usb-kbd");
usb_create_simple(usb_bus, "usb-mouse");
}
}
if (spapr->rma_size < (MIN_RMA_SLOF << 20)) {
error_report(
"pSeries SLOF firmware requires >= %ldM guest RMA (Real Mode Area memory)",
MIN_RMA_SLOF);
exit(1);
}
if (kernel_filename) {
uint64_t lowaddr = 0;
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
if (kernel_size == ELF_LOAD_WRONG_ENDIAN) {
kernel_size = load_elf(kernel_filename,
translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 0, PPC_ELF_MACHINE, 0);
kernel_le = kernel_size > 0;
}
if (kernel_size < 0) {
error_report("error loading %s: %s",
kernel_filename, load_elf_strerror(kernel_size));
exit(1);
}
/* load initrd */
if (initrd_filename) {
/* Try to locate the initrd in the gap between the kernel
* and the firmware. Add a bit of space just in case
*/
initrd_base = (KERNEL_LOAD_ADDR + kernel_size + 0x1ffff) & ~0xffff;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
load_limit - initrd_base);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
}
if (bios_name == NULL) {
bios_name = FW_FILE_NAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (!filename) {
error_report("Could not find LPAR firmware '%s'", bios_name);
exit(1);
}
fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);
if (fw_size <= 0) {
error_report("Could not load LPAR firmware '%s'", filename);
exit(1);
}
g_free(filename);
/* FIXME: Should register things through the MachineState's qdev
* interface, this is a legacy from the sPAPREnvironment structure
* which predated MachineState but had a similar function */
vmstate_register(NULL, 0, &vmstate_spapr, spapr);
register_savevm_live(NULL, "spapr/htab", -1, 1,
&savevm_htab_handlers, spapr);
/* Prepare the device tree */
spapr->fdt_skel = spapr_create_fdt_skel(initrd_base, initrd_size,
kernel_size, kernel_le,
kernel_cmdline,
spapr->check_exception_irq);
assert(spapr->fdt_skel != NULL);
/* used by RTAS */
QTAILQ_INIT(&spapr->ccs_list);
qemu_register_reset(spapr_ccs_reset_hook, spapr);
qemu_register_boot_set(spapr_boot_set, spapr);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25113 | static void n8x0_nand_setup(struct n800_s *s)
{
char *otp_region;
DriveInfo *dinfo;
s->nand = qdev_create(NULL, "onenand");
qdev_prop_set_uint16(s->nand, "manufacturer_id", NAND_MFR_SAMSUNG);
/* Either 0x40 or 0x48 are OK for the device ID */
qdev_prop_set_uint16(s->nand, "device_id", 0x48);
qdev_prop_set_uint16(s->nand, "version_id", 0);
qdev_prop_set_int32(s->nand, "shift", 1);
dinfo = drive_get(IF_MTD, 0, 0);
if (dinfo) {
qdev_prop_set_drive_nofail(s->nand, "drive",
blk_bs(blk_by_legacy_dinfo(dinfo)));
}
qdev_init_nofail(s->nand);
sysbus_connect_irq(SYS_BUS_DEVICE(s->nand), 0,
qdev_get_gpio_in(s->mpu->gpio, N8X0_ONENAND_GPIO));
omap_gpmc_attach(s->mpu->gpmc, N8X0_ONENAND_CS,
sysbus_mmio_get_region(SYS_BUS_DEVICE(s->nand), 0));
otp_region = onenand_raw_otp(s->nand);
memcpy(otp_region + 0x000, n8x0_cal_wlan_mac, sizeof(n8x0_cal_wlan_mac));
memcpy(otp_region + 0x800, n8x0_cal_bt_id, sizeof(n8x0_cal_bt_id));
/* XXX: in theory should also update the OOB for both pages */
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25119 | void cpu_dump_state (CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)
{
uint32_t c0_status;
int i;
cpu_fprintf(f, "pc=0x" TARGET_FMT_lx " HI=0x" TARGET_FMT_lx " LO=0x" TARGET_FMT_lx " ds %04x " TARGET_FMT_lx " %d\n",
env->PC, env->HI, env->LO, env->hflags, env->btarget, env->bcond);
for (i = 0; i < 32; i++) {
if ((i & 3) == 0)
cpu_fprintf(f, "GPR%02d:", i);
cpu_fprintf(f, " %s " TARGET_FMT_lx, regnames[i], env->gpr[i]);
if ((i & 3) == 3)
cpu_fprintf(f, "\n");
}
c0_status = env->CP0_Status;
cpu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx "\n",
c0_status, env->CP0_Cause, env->CP0_EPC);
cpu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x" TARGET_FMT_lx "\n",
env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr);
if (c0_status & (1 << CP0St_CU1))
fpu_dump_state(env, f, cpu_fprintf, flags);
#if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
cpu_mips_check_sign_extensions(env, f, cpu_fprintf, flags);
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25130 | static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
GetBitContext bits;
AACADTSHeaderInfo hdr;
int size;
union {
uint64_t u64;
uint8_t u8[8];
} tmp;
tmp.u64 = av_be2ne64(state);
init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8);
if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0)
return 0;
*need_next_header = 0;
*new_frame_start = 1;
hdr_info->sample_rate = hdr.sample_rate;
hdr_info->channels = ff_mpeg4audio_channels[hdr.chan_config];
hdr_info->samples = hdr.samples;
hdr_info->bit_rate = hdr.bit_rate;
return size;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25134 | uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, int asi, int size,
int sign)
{
uint64_t ret = 0;
#if defined(DEBUG_ASI)
target_ulong last_addr = addr;
#endif
if (asi < 0x80) {
helper_raise_exception(env, TT_PRIV_ACT);
}
helper_check_align(env, addr, size - 1);
addr = asi_address_mask(env, asi, addr);
switch (asi) {
case 0x82: /* Primary no-fault */
case 0x8a: /* Primary no-fault LE */
if (page_check_range(addr, size, PAGE_READ) == -1) {
#ifdef DEBUG_ASI
dump_asi("read ", last_addr, asi, size, ret);
#endif
return 0;
}
/* Fall through */
case 0x80: /* Primary */
case 0x88: /* Primary LE */
{
switch (size) {
case 1:
ret = ldub_raw(addr);
break;
case 2:
ret = lduw_raw(addr);
break;
case 4:
ret = ldl_raw(addr);
break;
default:
case 8:
ret = ldq_raw(addr);
break;
}
}
break;
case 0x83: /* Secondary no-fault */
case 0x8b: /* Secondary no-fault LE */
if (page_check_range(addr, size, PAGE_READ) == -1) {
#ifdef DEBUG_ASI
dump_asi("read ", last_addr, asi, size, ret);
#endif
return 0;
}
/* Fall through */
case 0x81: /* Secondary */
case 0x89: /* Secondary LE */
/* XXX */
break;
default:
break;
}
/* Convert from little endian */
switch (asi) {
case 0x88: /* Primary LE */
case 0x89: /* Secondary LE */
case 0x8a: /* Primary no-fault LE */
case 0x8b: /* Secondary no-fault LE */
switch (size) {
case 2:
ret = bswap16(ret);
break;
case 4:
ret = bswap32(ret);
break;
case 8:
ret = bswap64(ret);
break;
default:
break;
}
default:
break;
}
/* Convert to signed number */
if (sign) {
switch (size) {
case 1:
ret = (int8_t) ret;
break;
case 2:
ret = (int16_t) ret;
break;
case 4:
ret = (int32_t) ret;
break;
default:
break;
}
}
#ifdef DEBUG_ASI
dump_asi("read ", last_addr, asi, size, ret);
#endif
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25135 | static av_cold int vc2_encode_init(AVCodecContext *avctx)
{
Plane *p;
SubBand *b;
int i, j, level, o, shift, ret;
const AVPixFmtDescriptor *fmt = av_pix_fmt_desc_get(avctx->pix_fmt);
const int depth = fmt->comp[0].depth;
VC2EncContext *s = avctx->priv_data;
s->picture_number = 0;
/* Total allowed quantization range */
s->q_ceil = DIRAC_MAX_QUANT_INDEX;
s->ver.major = 2;
s->ver.minor = 0;
s->profile = 3;
s->level = 3;
s->base_vf = -1;
s->strict_compliance = 1;
s->q_avg = 0;
s->slice_max_bytes = 0;
s->slice_min_bytes = 0;
/* Mark unknown as progressive */
s->interlaced = !((avctx->field_order == AV_FIELD_UNKNOWN) ||
(avctx->field_order == AV_FIELD_PROGRESSIVE));
for (i = 0; i < base_video_fmts_len; i++) {
const VC2BaseVideoFormat *fmt = &base_video_fmts[i];
if (avctx->pix_fmt != fmt->pix_fmt)
continue;
if (avctx->time_base.num != fmt->time_base.num)
continue;
if (avctx->time_base.den != fmt->time_base.den)
continue;
if (avctx->width != fmt->width)
continue;
if (avctx->height != fmt->height)
continue;
if (s->interlaced != fmt->interlaced)
continue;
s->base_vf = i;
s->level = base_video_fmts[i].level;
break;
}
if (s->interlaced)
av_log(avctx, AV_LOG_WARNING, "Interlacing enabled!\n");
if ((s->slice_width & (s->slice_width - 1)) ||
(s->slice_height & (s->slice_height - 1))) {
av_log(avctx, AV_LOG_ERROR, "Slice size is not a power of two!\n");
return AVERROR_UNKNOWN;
}
if ((s->slice_width > avctx->width) ||
(s->slice_height > avctx->height)) {
av_log(avctx, AV_LOG_ERROR, "Slice size is bigger than the image!\n");
return AVERROR_UNKNOWN;
}
if (s->base_vf <= 0) {
if (avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) {
s->strict_compliance = s->base_vf = 0;
av_log(avctx, AV_LOG_WARNING, "Format does not strictly comply with VC2 specs\n");
} else {
av_log(avctx, AV_LOG_WARNING, "Given format does not strictly comply with "
"the specifications, decrease strictness to use it.\n");
return AVERROR_UNKNOWN;
}
} else {
av_log(avctx, AV_LOG_INFO, "Selected base video format = %i (%s)\n",
s->base_vf, base_video_fmts[s->base_vf].name);
}
/* Chroma subsampling */
ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
if (ret)
return ret;
/* Bit depth and color range index */
if (depth == 8 && avctx->color_range == AVCOL_RANGE_JPEG) {
s->bpp = 1;
s->bpp_idx = 1;
s->diff_offset = 128;
} else if (depth == 8 && (avctx->color_range == AVCOL_RANGE_MPEG ||
avctx->color_range == AVCOL_RANGE_UNSPECIFIED)) {
s->bpp = 1;
s->bpp_idx = 2;
s->diff_offset = 128;
} else if (depth == 10) {
s->bpp = 2;
s->bpp_idx = 3;
s->diff_offset = 512;
} else {
s->bpp = 2;
s->bpp_idx = 4;
s->diff_offset = 2048;
}
/* Planes initialization */
for (i = 0; i < 3; i++) {
int w, h;
p = &s->plane[i];
p->width = avctx->width >> (i ? s->chroma_x_shift : 0);
p->height = avctx->height >> (i ? s->chroma_y_shift : 0);
if (s->interlaced)
p->height >>= 1;
p->dwt_width = w = FFALIGN(p->width, (1 << s->wavelet_depth));
p->dwt_height = h = FFALIGN(p->height, (1 << s->wavelet_depth));
p->coef_stride = FFALIGN(p->dwt_width, 32);
p->coef_buf = av_malloc(p->coef_stride*p->dwt_height*sizeof(dwtcoef));
if (!p->coef_buf)
goto alloc_fail;
for (level = s->wavelet_depth-1; level >= 0; level--) {
w = w >> 1;
h = h >> 1;
for (o = 0; o < 4; o++) {
b = &p->band[level][o];
b->width = w;
b->height = h;
b->stride = p->coef_stride;
shift = (o > 1)*b->height*b->stride + (o & 1)*b->width;
b->buf = p->coef_buf + shift;
}
}
/* DWT init */
if (ff_vc2enc_init_transforms(&s->transform_args[i].t,
s->plane[i].coef_stride,
s->plane[i].dwt_height))
goto alloc_fail;
}
/* Slices */
s->num_x = s->plane[0].dwt_width/s->slice_width;
s->num_y = s->plane[0].dwt_height/s->slice_height;
s->slice_args = av_calloc(s->num_x*s->num_y, sizeof(SliceArgs));
if (!s->slice_args)
goto alloc_fail;
/* Lookup tables */
s->coef_lut_len = av_malloc(COEF_LUT_TAB*(s->q_ceil+1)*sizeof(*s->coef_lut_len));
if (!s->coef_lut_len)
goto alloc_fail;
s->coef_lut_val = av_malloc(COEF_LUT_TAB*(s->q_ceil+1)*sizeof(*s->coef_lut_val));
if (!s->coef_lut_val)
goto alloc_fail;
for (i = 0; i < s->q_ceil; i++) {
uint8_t *len_lut = &s->coef_lut_len[i*COEF_LUT_TAB];
uint32_t *val_lut = &s->coef_lut_val[i*COEF_LUT_TAB];
for (j = 0; j < COEF_LUT_TAB; j++) {
get_vc2_ue_uint(QUANT(j, ff_dirac_qscale_tab[i]),
&len_lut[j], &val_lut[j]);
if (len_lut[j] != 1) {
len_lut[j] += 1;
val_lut[j] <<= 1;
} else {
val_lut[j] = 1;
}
}
}
return 0;
alloc_fail:
vc2_encode_end(avctx);
av_log(avctx, AV_LOG_ERROR, "Unable to allocate memory!\n");
return AVERROR(ENOMEM);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25149 | static av_cold int rv40_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
r->rv30 = 0;
ff_rv34_decode_init(avctx);
if(!aic_top_vlc.bits)
rv40_init_tables();
r->parse_slice_header = rv40_parse_slice_header;
r->decode_intra_types = rv40_decode_intra_types;
r->decode_mb_info = rv40_decode_mb_info;
r->loop_filter = rv40_loop_filter;
r->luma_dc_quant_i = rv40_luma_dc_quant[0];
r->luma_dc_quant_p = rv40_luma_dc_quant[1];
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25163 | static void spr_write_dbatu_h (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_dbatu((sprn - SPR_DBAT4U) / 2);
RET_STOP(ctx);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25167 | sprintf_len(char *string, const char *format, ...)
#else
sprintf_len(va_alist) va_dcl
#endif
{
va_list args;
#ifdef __STDC__
va_start(args, format);
#else
char *string;
char *format;
va_start(args);
string = va_arg(args, char *);
format = va_arg(args, char *);
#endif
vsprintf(string, format, args);
return strlen(string);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25179 | static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
uint8_t **data, int *size)
{
static const int extradata_nal_types_hevc[] = {
HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS,
};
static const int extradata_nal_types_h264[] = {
H264_NAL_SPS, H264_NAL_PPS,
};
ExtractExtradataContext *s = ctx->priv_data;
H2645Packet h2645_pkt = { 0 };
int extradata_size = 0;
const int *extradata_nal_types;
int nb_extradata_nal_types;
int i, has_sps = 0, has_vps = 0, ret = 0;
if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
extradata_nal_types = extradata_nal_types_hevc;
nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_hevc);
} else {
extradata_nal_types = extradata_nal_types_h264;
nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_h264);
}
ret = ff_h2645_packet_split(&h2645_pkt, pkt->data, pkt->size,
ctx, 0, 0, ctx->par_in->codec_id, 1);
if (ret < 0)
return ret;
for (i = 0; i < h2645_pkt.nb_nals; i++) {
H2645NAL *nal = &h2645_pkt.nals[i];
if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type)) {
extradata_size += nal->raw_size + 3;
if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
if (nal->type == HEVC_NAL_SPS) has_sps = 1;
if (nal->type == HEVC_NAL_VPS) has_vps = 1;
} else {
if (nal->type == H264_NAL_SPS) has_sps = 1;
}
}
}
if (extradata_size &&
((ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) ||
(ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) {
AVBufferRef *filtered_buf;
uint8_t *extradata, *filtered_data;
if (s->remove) {
filtered_buf = av_buffer_alloc(pkt->size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!filtered_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
filtered_data = filtered_buf->data;
}
extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!extradata) {
av_buffer_unref(&filtered_buf);
ret = AVERROR(ENOMEM);
goto fail;
}
*data = extradata;
*size = extradata_size;
for (i = 0; i < h2645_pkt.nb_nals; i++) {
H2645NAL *nal = &h2645_pkt.nals[i];
if (val_in_array(extradata_nal_types, nb_extradata_nal_types,
nal->type)) {
AV_WB24(extradata, 1); // startcode
memcpy(extradata + 3, nal->raw_data, nal->raw_size);
extradata += 3 + nal->raw_size;
} else if (s->remove) {
AV_WB24(filtered_data, 1); // startcode
memcpy(filtered_data + 3, nal->raw_data, nal->raw_size);
filtered_data += 3 + nal->raw_size;
}
}
if (s->remove) {
av_buffer_unref(&pkt->buf);
pkt->buf = filtered_buf;
pkt->data = filtered_buf->data;
pkt->size = filtered_data - filtered_buf->data;
}
}
fail:
ff_h2645_packet_uninit(&h2645_pkt);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25181 | static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
int16_t *src2,
int height, int denom, int wx0, int wx1,
int ox0, int ox1, intptr_t mx, intptr_t my, int width)
{
int x, y;
pixel *src = (pixel *)_src;
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
const int8_t *filter = ff_hevc_epel_filters[mx - 1];
int shift = 14 + 1 - BIT_DEPTH;
int log2Wd = denom + shift - 1;
ox0 = ox0 * (1 << (BIT_DEPTH - 8));
ox1 = ox1 * (1 << (BIT_DEPTH - 8));
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
src += srcstride;
dst += dststride;
src2 += MAX_PB_SIZE;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25182 | void sdl2_gl_scanout(DisplayChangeListener *dcl,
uint32_t backing_id, bool backing_y_0_top,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
assert(scon->opengl);
scon->x = x;
scon->y = y;
scon->w = w;
scon->h = h;
scon->tex_id = backing_id;
scon->y0_top = backing_y_0_top;
SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
if (scon->tex_id == 0 || scon->w == 0 || scon->h == 0) {
sdl2_set_scanout_mode(scon, false);
return;
}
sdl2_set_scanout_mode(scon, true);
if (!scon->fbo_id) {
glGenFramebuffers(1, &scon->fbo_id);
}
glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, scon->tex_id, 0);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25185 | static void mm_stop_timer(struct qemu_alarm_timer *t)
{
timeKillEvent(mm_timer);
timeEndPeriod(mm_period);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25189 | static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr,
TCGMemOpIdx oi)
{
TCGMemOp memop = get_memop(oi);
#ifdef CONFIG_SOFTMMU
unsigned memi = get_mmuidx(oi);
TCGReg addrz, param;
tcg_insn_unit *func;
tcg_insn_unit *label_ptr;
addrz = tcg_out_tlb_load(s, addr, memi, memop,
offsetof(CPUTLBEntry, addr_write));
/* The fast path is exactly one insn. Thus we can perform the entire
TLB Hit in the (annulled) delay slot of the branch over TLB Miss. */
/* beq,a,pt %[xi]cc, label0 */
label_ptr = s->code_ptr;
tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT
| (TARGET_LONG_BITS == 64 ? BPCC_XCC : BPCC_ICC), 0);
/* delay slot */
tcg_out_ldst_rr(s, data, addrz, TCG_REG_O1,
qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]);
/* TLB Miss. */
param = TCG_REG_O1;
if (!SPARC64 && TARGET_LONG_BITS == 64) {
/* Skip the high-part; we'll perform the extract in the trampoline. */
param++;
}
tcg_out_mov(s, TCG_TYPE_REG, param++, addr);
if (!SPARC64 && (memop & MO_SIZE) == MO_64) {
/* Skip the high-part; we'll perform the extract in the trampoline. */
param++;
}
tcg_out_mov(s, TCG_TYPE_REG, param++, data);
func = qemu_st_trampoline[memop & (MO_BSWAP | MO_SIZE)];
tcg_debug_assert(func != NULL);
tcg_out_call_nodelay(s, func);
/* delay slot */
tcg_out_movi(s, TCG_TYPE_I32, param, oi);
*label_ptr |= INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr));
#else
if (SPARC64 && TARGET_LONG_BITS == 32) {
tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL);
addr = TCG_REG_T1;
}
tcg_out_ldst_rr(s, data, addr,
(guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0),
qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]);
#endif /* CONFIG_SOFTMMU */
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25223 | QEMUFile *qemu_fopen_fd(int fd)
{
QEMUFileFD *s = qemu_mallocz(sizeof(QEMUFileFD));
if (s == NULL)
return NULL;
s->fd = fd;
s->file = qemu_fopen_ops(s, fd_put_buffer, fd_get_buffer, fd_close, NULL);
return s->file;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25245 | static void pred_spatial_direct_motion(const H264Context *const h, H264SliceContext *sl,
int *mb_type)
{
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = sl->mb_xy, mb_y = sl->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type = MB_TYPE_L0L1;
int i8, i4;
int ref[2];
int mv[2];
int list;
assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, sl->ref_list[1][0].parent,
sl->mb_y + !!IS_INTERLACED(*mb_type));
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
/* ref = min(neighbors) */
for (list = 0; list < 2; list++) {
int left_ref = sl->ref_cache[list][scan8[0] - 1];
int top_ref = sl->ref_cache[list][scan8[0] - 8];
int refc = sl->ref_cache[list][scan8[0] - 8 + 4];
const int16_t *C = sl->mv_cache[list][scan8[0] - 8 + 4];
if (refc == PART_NOT_AVAILABLE) {
refc = sl->ref_cache[list][scan8[0] - 8 - 1];
C = sl->mv_cache[list][scan8[0] - 8 - 1];
}
ref[list] = FFMIN3((unsigned)left_ref,
(unsigned)top_ref,
(unsigned)refc);
if (ref[list] >= 0) {
/* This is just pred_motion() but with the cases removed that
* cannot happen for direct blocks. */
const int16_t *const A = sl->mv_cache[list][scan8[0] - 1];
const int16_t *const B = sl->mv_cache[list][scan8[0] - 8];
int match_count = (left_ref == ref[list]) +
(top_ref == ref[list]) +
(refc == ref[list]);
if (match_count > 1) { // most common
mv[list] = pack16to32(mid_pred(A[0], B[0], C[0]),
mid_pred(A[1], B[1], C[1]));
} else {
assert(match_count == 1);
if (left_ref == ref[list])
mv[list] = AV_RN32A(A);
else if (top_ref == ref[list])
mv[list] = AV_RN32A(B);
else
mv[list] = AV_RN32A(C);
}
} else {
int mask = ~(MB_TYPE_L0 << (2 * list));
mv[list] = 0;
ref[list] = -1;
if (!is_b8x8)
*mb_type &= mask;
sub_mb_type &= mask;
}
}
if (ref[0] < 0 && ref[1] < 0) {
ref[0] = ref[1] = 0;
if (!is_b8x8)
*mb_type |= MB_TYPE_L0L1;
sub_mb_type |= MB_TYPE_L0L1;
}
if (!(is_b8x8 | mv[0] | mv[1])) {
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
*mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 |
MB_TYPE_P1L0 | MB_TYPE_P1L1)) |
MB_TYPE_16x16 | MB_TYPE_DIRECT2;
return;
}
if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = sl->mb_x +
((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0;
} else {
mb_y += sl->col_fieldoff;
mb_xy += h->mb_stride * sl->col_fieldoff; // non-zero for FL -> FL & differ parity
}
goto single_col;
} else { // AFL/AFR/FR/FL -> AFR/FR
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = sl->mb_y & ~1;
mb_xy = (sl->mb_y & ~1) * h->mb_stride + sl->mb_x;
mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) !=
IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED;
mb_type_col[1] &= ~MB_TYPE_INTERLACED;
}
sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) &&
(mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) &&
!is_b8x8) {
*mb_type |= MB_TYPE_16x8 | MB_TYPE_DIRECT2; /* B_16x8 */
} else {
*mb_type |= MB_TYPE_8x8;
}
} else { // AFR/FR -> AFR/FR
single_col:
mb_type_col[0] =
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy];
sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) {
*mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_16x16 */
} else if (!is_b8x8 &&
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {
*mb_type |= MB_TYPE_DIRECT2 |
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));
} else {
if (!h->ps.sps->direct_8x8_inference_flag) {
/* FIXME: Save sub mb types from previous frames (or derive
* from MVs) so we know exactly what block size to use. */
sub_mb_type += (MB_TYPE_8x8 - MB_TYPE_16x16); /* B_SUB_4x4 */
}
*mb_type |= MB_TYPE_8x8;
}
}
}
await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
l1mv0 = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy];
if (!b8_stride) {
if (sl->mb_y & 1) {
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2 * b4_stride;
l1mv1 += 2 * b4_stride;
}
}
if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
int n = 0;
for (i8 = 0; i8 < 4; i8++) {
int x8 = i8 & 1;
int y8 = i8 >> 1;
int xy8 = x8 + y8 * b8_stride;
int xy4 = x8 * 3 + y8 * b4_stride;
int a, b;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[1], 1);
if (!IS_INTRA(mb_type_col[y8]) && !sl->ref_list[1][0].parent->long_ref &&
((l1ref0[xy8] == 0 &&
FFABS(l1mv0[xy4][0]) <= 1 &&
FFABS(l1mv0[xy4][1]) <= 1) ||
(l1ref0[xy8] < 0 &&
l1ref1[xy8] == 0 &&
FFABS(l1mv1[xy4][0]) <= 1 &&
FFABS(l1mv1[xy4][1]) <= 1))) {
a =
b = 0;
if (ref[0] > 0)
a = mv[0];
if (ref[1] > 0)
b = mv[1];
n++;
} else {
a = mv[0];
b = mv[1];
}
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, a, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, b, 4);
}
if (!is_b8x8 && !(n & 3))
*mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 |
MB_TYPE_P1L0 | MB_TYPE_P1L1)) |
MB_TYPE_16x16 | MB_TYPE_DIRECT2;
} else if (IS_16X16(*mb_type)) {
int a, b;
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].parent->long_ref &&
((l1ref0[0] == 0 &&
FFABS(l1mv0[0][0]) <= 1 &&
FFABS(l1mv0[0][1]) <= 1) ||
(l1ref0[0] < 0 && !l1ref1[0] &&
FFABS(l1mv1[0][0]) <= 1 &&
FFABS(l1mv1[0][1]) <= 1 &&
h->sei.unregistered.x264_build > 33U))) {
a = b = 0;
if (ref[0] > 0)
a = mv[0];
if (ref[1] > 0)
b = mv[1];
} else {
a = mv[0];
b = mv[1];
}
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, a, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, b, 4);
} else {
int n = 0;
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, mv[0], 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, mv[1], 4);
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[1], 1);
assert(b8_stride == 2);
/* col_zero_flag */
if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].parent->long_ref &&
(l1ref0[i8] == 0 ||
(l1ref0[i8] < 0 &&
l1ref1[i8] == 0 &&
h->sei.unregistered.x264_build > 33U))) {
const int16_t (*l1mv)[2] = l1ref0[i8] == 0 ? l1mv0 : l1mv1;
if (IS_SUB_8X8(sub_mb_type)) {
const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
if (FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1) {
if (ref[0] == 0)
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2,
8, 0, 4);
if (ref[1] == 0)
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2,
8, 0, 4);
n += 4;
}
} else {
int m = 0;
for (i4 = 0; i4 < 4; i4++) {
const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
(y8 * 2 + (i4 >> 1)) * b4_stride];
if (FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1) {
if (ref[0] == 0)
AV_ZERO32(sl->mv_cache[0][scan8[i8 * 4 + i4]]);
if (ref[1] == 0)
AV_ZERO32(sl->mv_cache[1][scan8[i8 * 4 + i4]]);
m++;
}
}
if (!(m & 3))
sl->sub_mb_type[i8] += MB_TYPE_16x16 - MB_TYPE_8x8;
n += m;
}
}
}
if (!is_b8x8 && !(n & 15))
*mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 |
MB_TYPE_P1L0 | MB_TYPE_P1L1)) |
MB_TYPE_16x16 | MB_TYPE_DIRECT2;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25247 | static void boston_lcd_event(void *opaque, int event)
{
BostonState *s = opaque;
if (event == CHR_EVENT_OPENED && !s->lcd_inited) {
qemu_chr_fe_printf(&s->lcd_display, " ");
s->lcd_inited = true;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25252 | void add_command(const cmdinfo_t *ci)
{
cmdtab = realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
cmdtab[ncmds - 1] = *ci;
qsort(cmdtab, ncmds, sizeof(*cmdtab), compare);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25260 | static void openpic_update_irq(OpenPICState *opp, int n_IRQ)
{
IRQ_src_t *src;
int i;
src = &opp->src[n_IRQ];
if (!src->pending) {
/* no irq pending */
DPRINTF("%s: IRQ %d is not pending\n", __func__, n_IRQ);
return;
}
if (src->ipvp & IPVP_MASK_MASK) {
/* Interrupt source is disabled */
DPRINTF("%s: IRQ %d is disabled\n", __func__, n_IRQ);
return;
}
if (IPVP_PRIORITY(src->ipvp) == 0) {
/* Priority set to zero */
DPRINTF("%s: IRQ %d has 0 priority\n", __func__, n_IRQ);
return;
}
if (src->ipvp & IPVP_ACTIVITY_MASK) {
/* IRQ already active */
DPRINTF("%s: IRQ %d is already active\n", __func__, n_IRQ);
return;
}
if (src->ide == 0) {
/* No target */
DPRINTF("%s: IRQ %d has no target\n", __func__, n_IRQ);
return;
}
if (src->ide == (1 << src->last_cpu)) {
/* Only one CPU is allowed to receive this IRQ */
IRQ_local_pipe(opp, src->last_cpu, n_IRQ);
} else if (!(src->ipvp & IPVP_MODE_MASK)) {
/* Directed delivery mode */
for (i = 0; i < opp->nb_cpus; i++) {
if (src->ide & (1 << i)) {
IRQ_local_pipe(opp, i, n_IRQ);
}
}
} else {
/* Distributed delivery mode */
for (i = src->last_cpu + 1; i != src->last_cpu; i++) {
if (i == opp->nb_cpus)
i = 0;
if (src->ide & (1 << i)) {
IRQ_local_pipe(opp, i, n_IRQ);
src->last_cpu = i;
break;
}
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25263 | static inline void usb_bt_fifo_out_enqueue(struct USBBtState *s,
struct usb_hci_out_fifo_s *fifo,
void (*send)(struct HCIInfo *, const uint8_t *, int),
int (*complete)(const uint8_t *, int),
const uint8_t *data, int len)
{
if (fifo->len) {
memcpy(fifo->data + fifo->len, data, len);
fifo->len += len;
if (complete(fifo->data, fifo->len)) {
send(s->hci, fifo->data, fifo->len);
fifo->len = 0;
}
} else if (complete(data, len))
send(s->hci, data, len);
else {
memcpy(fifo->data, data, len);
fifo->len = len;
}
/* TODO: do we need to loop? */
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25265 | static void compute_status(HTTPContext *c)
{
HTTPContext *c1;
FFStream *stream;
char *p;
time_t ti;
int i, len;
AVIOContext *pb;
if (avio_open_dyn_buf(&pb) < 0) {
/* XXX: return an error ? */
c->buffer_ptr = c->buffer;
c->buffer_end = c->buffer;
return;
}
avio_printf(pb, "HTTP/1.0 200 OK\r\n");
avio_printf(pb, "Content-type: %s\r\n", "text/html");
avio_printf(pb, "Pragma: no-cache\r\n");
avio_printf(pb, "\r\n");
avio_printf(pb, "<html><head><title>%s Status</title>\n", program_name);
if (c->stream->feed_filename[0])
avio_printf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename);
avio_printf(pb, "</head>\n<body>");
avio_printf(pb, "<h1>%s Status</h1>\n", program_name);
/* format status */
avio_printf(pb, "<h2>Available Streams</h2>\n");
avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n");
avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n");
stream = first_stream;
while (stream != NULL) {
char sfilename[1024];
char *eosf;
if (stream->feed != stream) {
av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10);
eosf = sfilename + strlen(sfilename);
if (eosf - sfilename >= 4) {
if (strcmp(eosf - 4, ".asf") == 0)
strcpy(eosf - 4, ".asx");
else if (strcmp(eosf - 3, ".rm") == 0)
strcpy(eosf - 3, ".ram");
else if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
/* generate a sample RTSP director if
unicast. Generate an SDP redirector if
multicast */
eosf = strrchr(sfilename, '.');
if (!eosf)
eosf = sfilename + strlen(sfilename);
if (stream->is_multicast)
strcpy(eosf, ".sdp");
else
strcpy(eosf, ".rtsp");
}
}
avio_printf(pb, "<tr><td><a href=\"/%s\">%s</a> ",
sfilename, stream->filename);
avio_printf(pb, "<td align=right> %d <td align=right> ",
stream->conns_served);
fmt_bytecount(pb, stream->bytes_served);
switch(stream->stream_type) {
case STREAM_TYPE_LIVE: {
int audio_bit_rate = 0;
int video_bit_rate = 0;
const char *audio_codec_name = "";
const char *video_codec_name = "";
const char *audio_codec_name_extra = "";
const char *video_codec_name_extra = "";
for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
audio_bit_rate += st->codec->bit_rate;
if (codec) {
if (*audio_codec_name)
audio_codec_name_extra = "...";
audio_codec_name = codec->name;
}
break;
case AVMEDIA_TYPE_VIDEO:
video_bit_rate += st->codec->bit_rate;
if (codec) {
if (*video_codec_name)
video_codec_name_extra = "...";
video_codec_name = codec->name;
}
break;
case AVMEDIA_TYPE_DATA:
video_bit_rate += st->codec->bit_rate;
break;
default:
abort();
}
}
avio_printf(pb, "<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s",
stream->fmt->name,
stream->bandwidth,
video_bit_rate / 1000, video_codec_name, video_codec_name_extra,
audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra);
if (stream->feed)
avio_printf(pb, "<td>%s", stream->feed->filename);
else
avio_printf(pb, "<td>%s", stream->feed_filename);
avio_printf(pb, "\n");
}
break;
default:
avio_printf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n");
break;
}
}
stream = stream->next;
}
avio_printf(pb, "</table>\n");
stream = first_stream;
while (stream != NULL) {
if (stream->feed == stream) {
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
if (stream->pid) {
avio_printf(pb, "Running as pid %d.\n", stream->pid);
#if defined(linux) && !defined(CONFIG_NOCUTILS)
{
FILE *pid_stat;
char ps_cmd[64];
/* This is somewhat linux specific I guess */
snprintf(ps_cmd, sizeof(ps_cmd),
"ps -o \"%%cpu,cputime\" --no-headers %d",
stream->pid);
pid_stat = popen(ps_cmd, "r");
if (pid_stat) {
char cpuperc[10];
char cpuused[64];
if (fscanf(pid_stat, "%9s %63s", cpuperc,
cpuused) == 2) {
avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n",
cpuperc, cpuused);
}
fclose(pid_stat);
}
}
#endif
avio_printf(pb, "<p>");
}
avio_printf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n");
for (i = 0; i < stream->nb_streams; i++) {
AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
const char *type = "unknown";
char parameters[64];
parameters[0] = 0;
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
type = "audio";
snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", st->codec->channels, st->codec->sample_rate);
break;
case AVMEDIA_TYPE_VIDEO:
type = "video";
snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height,
st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);
break;
default:
abort();
}
avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
}
avio_printf(pb, "</table>\n");
}
stream = stream->next;
}
/* connection status */
avio_printf(pb, "<h2>Connection Status</h2>\n");
avio_printf(pb, "Number of connections: %d / %d<br>\n",
nb_connections, nb_max_connections);
avio_printf(pb, "Bandwidth in use: %"PRIu64"k / %"PRIu64"k<br>\n",
current_bandwidth, max_bandwidth);
avio_printf(pb, "<table>\n");
avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n");
c1 = first_http_ctx;
i = 0;
while (c1 != NULL) {
int bitrate;
int j;
bitrate = 0;
if (c1->stream) {
for (j = 0; j < c1->stream->nb_streams; j++) {
if (!c1->stream->feed)
bitrate += c1->stream->streams[j]->codec->bit_rate;
else if (c1->feed_streams[j] >= 0)
bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec->bit_rate;
}
}
i++;
p = inet_ntoa(c1->from_addr.sin_addr);
avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>",
i,
c1->stream ? c1->stream->filename : "",
c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "",
p,
c1->protocol,
http_state[c1->state]);
fmt_bytecount(pb, bitrate);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, c1->data_count);
avio_printf(pb, "\n");
c1 = c1->next;
}
avio_printf(pb, "</table>\n");
/* date */
ti = time(NULL);
p = ctime(&ti);
avio_printf(pb, "<hr size=1 noshade>Generated at %s", p);
avio_printf(pb, "</body>\n</html>\n");
len = avio_close_dyn_buf(pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25284 | static int ram_save_compressed_page(QEMUFile *f, PageSearchStatus *pss,
bool last_stage,
uint64_t *bytes_transferred)
{
int pages = -1;
uint64_t bytes_xmit;
uint8_t *p;
int ret;
RAMBlock *block = pss->block;
ram_addr_t offset = pss->offset;
p = block->host + offset;
bytes_xmit = 0;
ret = ram_control_save_page(f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_xmit);
if (bytes_xmit) {
*bytes_transferred += bytes_xmit;
pages = 1;
}
if (block == last_sent_block) {
offset |= RAM_SAVE_FLAG_CONTINUE;
}
if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret != RAM_SAVE_CONTROL_DELAYED) {
if (bytes_xmit > 0) {
acct_info.norm_pages++;
} else if (bytes_xmit == 0) {
acct_info.dup_pages++;
}
}
} else {
/* When starting the process of a new block, the first page of
* the block should be sent out before other pages in the same
* block, and all the pages in last block should have been sent
* out, keeping this order is important, because the 'cont' flag
* is used to avoid resending the block name.
*/
if (block != last_sent_block) {
flush_compressed_data(f);
pages = save_zero_page(f, block, offset, p, bytes_transferred);
if (pages == -1) {
set_compress_params(&comp_param[0], block, offset);
/* Use the qemu thread to compress the data to make sure the
* first page is sent out before other pages
*/
bytes_xmit = do_compress_ram_page(&comp_param[0]);
acct_info.norm_pages++;
qemu_put_qemu_file(f, comp_param[0].file);
*bytes_transferred += bytes_xmit;
pages = 1;
}
} else {
pages = save_zero_page(f, block, offset, p, bytes_transferred);
if (pages == -1) {
pages = compress_page_with_multi_thread(f, block, offset,
bytes_transferred);
}
}
}
return pages;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25310 | void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
bool has_base, const char *base,
bool has_backing_file, const char *backing_file,
bool has_speed, int64_t speed,
bool has_on_error, BlockdevOnError on_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *base_bs = NULL;
AioContext *aio_context;
Error *local_err = NULL;
const char *base_name = NULL;
if (!has_on_error) {
on_error = BLOCKDEV_ON_ERROR_REPORT;
}
bs = qmp_get_root_bs(device, errp);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) {
goto out;
}
if (has_base) {
base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) {
error_setg(errp, QERR_BASE_NOT_FOUND, base);
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
base_name = base;
}
/* if we are streaming the entire chain, the result will have no backing
* file, and specifying one is therefore an error */
if (base_bs == NULL && has_backing_file) {
error_setg(errp, "backing file specified, but streaming the "
"entire chain");
goto out;
}
/* backing_file string overrides base bs filename */
base_name = has_backing_file ? backing_file : base_name;
stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name,
has_speed ? speed : 0, on_error, block_job_cb, bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
trace_qmp_block_stream(bs, bs->job);
out:
aio_context_release(aio_context);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25344 | int ff_dxva2_commit_buffer(AVCodecContext *avctx,
AVDXVAContext *ctx,
DECODER_BUFFER_DESC *dsc,
unsigned type, const void *data, unsigned size,
unsigned mb_count)
{
void *dxva_data;
unsigned dxva_size;
int result;
HRESULT hr;
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
D3D11VA_CONTEXT(ctx)->decoder,
type,
&dxva_size, &dxva_data);
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
hr = IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder, type,
&dxva_data, &dxva_size);
#endif
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%x\n",
type, hr);
return -1;
}
if (size <= dxva_size) {
memcpy(dxva_data, data, size);
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc;
memset(dsc11, 0, sizeof(*dsc11));
dsc11->BufferType = type;
dsc11->DataSize = size;
dsc11->NumMBsInBuffer = mb_count;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
DXVA2_DecodeBufferDesc *dsc2 = dsc;
memset(dsc2, 0, sizeof(*dsc2));
dsc2->CompressedBufferType = type;
dsc2->DataSize = size;
dsc2->NumMBsInBuffer = mb_count;
}
#endif
result = 0;
} else {
av_log(avctx, AV_LOG_ERROR, "Buffer for type %u was too small\n", type);
result = -1;
}
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type);
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
hr = IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type);
#endif
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR,
"Failed to release buffer type %u: 0x%x\n",
type, hr);
result = -1;
}
return result;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25353 | static int inet_listen_saddr(InetSocketAddress *saddr,
int port_offset,
bool update_addr,
Error **errp)
{
struct addrinfo ai,*res,*e;
char port[33];
char uaddr[INET6_ADDRSTRLEN+1];
char uport[33];
int slisten, rc, port_min, port_max, p;
Error *err = NULL;
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_PASSIVE;
if (saddr->has_numeric && saddr->numeric) {
ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
}
ai.ai_family = inet_ai_family_from_address(saddr, &err);
ai.ai_socktype = SOCK_STREAM;
if (err) {
error_propagate(errp, err);
return -1;
}
if (saddr->host == NULL) {
error_setg(errp, "host not specified");
return -1;
}
if (saddr->port != NULL) {
pstrcpy(port, sizeof(port), saddr->port);
} else {
port[0] = '\0';
}
/* lookup */
if (port_offset) {
unsigned long long baseport;
if (strlen(port) == 0) {
error_setg(errp, "port not specified");
return -1;
}
if (parse_uint_full(port, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", port);
return -1;
}
if (baseport > 65535 ||
baseport + port_offset > 65535) {
error_setg(errp, "port %s out of range", port);
return -1;
}
snprintf(port, sizeof(port), "%d", (int)baseport + port_offset);
}
rc = getaddrinfo(strlen(saddr->host) ? saddr->host : NULL,
strlen(port) ? port : NULL, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s",
saddr->host, port, gai_strerror(rc));
return -1;
}
/* create socket + bind */
for (e = res; e != NULL; e = e->ai_next) {
getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
uaddr,INET6_ADDRSTRLEN,uport,32,
NI_NUMERICHOST | NI_NUMERICSERV);
slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
if (slisten < 0) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to create socket");
}
continue;
}
socket_set_fast_reuse(slisten);
port_min = inet_getport(e);
port_max = saddr->has_to ? saddr->to + port_offset : port_min;
for (p = port_min; p <= port_max; p++) {
inet_setport(e, p);
if (try_bind(slisten, saddr, e) >= 0) {
goto listen;
}
if (p == port_max) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to bind socket");
}
}
}
closesocket(slisten);
}
freeaddrinfo(res);
return -1;
listen:
if (listen(slisten,1) != 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
closesocket(slisten);
freeaddrinfo(res);
return -1;
}
if (update_addr) {
g_free(saddr->host);
saddr->host = g_strdup(uaddr);
g_free(saddr->port);
saddr->port = g_strdup_printf("%d",
inet_getport(e) - port_offset);
saddr->has_ipv6 = saddr->ipv6 = e->ai_family == PF_INET6;
saddr->has_ipv4 = saddr->ipv4 = e->ai_family != PF_INET6;
}
freeaddrinfo(res);
return slisten;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25357 | static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
if (codec->codec_tag == MKTAG('A', 'V', 'i', 'n') &&
codec->codec_id == AV_CODEC_ID_H264 &&
atom.size > 11) {
avio_skip(pb, 10);
/* For AVID AVCI50, force width of 1440 to be able to select the correct SPS and PPS */
if (avio_rb16(pb) == 0xd4d)
codec->width = 1440;
return 0;
}
return mov_read_avid(c, pb, atom);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25370 | void vmstate_unregister(const VMStateDescription *vmsd, void *opaque)
{
SaveStateEntry *se, *new_se;
TAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
if (se->vmsd == vmsd && se->opaque == opaque) {
TAILQ_REMOVE(&savevm_handlers, se, entry);
qemu_free(se);
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25382 | static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
struct iovec *iov, unsigned int iov_cnt)
{
struct virtio_net_ctrl_mac mac_data;
size_t s;
NetClientState *nc = qemu_get_queue(n->nic);
if (cmd == VIRTIO_NET_CTRL_MAC_ADDR_SET) {
if (iov_size(iov, iov_cnt) != sizeof(n->mac)) {
return VIRTIO_NET_ERR;
}
s = iov_to_buf(iov, iov_cnt, 0, &n->mac, sizeof(n->mac));
assert(s == sizeof(n->mac));
qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
rxfilter_notify(nc);
return VIRTIO_NET_OK;
}
if (cmd != VIRTIO_NET_CTRL_MAC_TABLE_SET) {
return VIRTIO_NET_ERR;
}
int in_use = 0;
int first_multi = 0;
uint8_t uni_overflow = 0;
uint8_t multi_overflow = 0;
uint8_t *macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
s = iov_to_buf(iov, iov_cnt, 0, &mac_data.entries,
sizeof(mac_data.entries));
mac_data.entries = ldl_p(&mac_data.entries);
if (s != sizeof(mac_data.entries)) {
goto error;
}
iov_discard_front(&iov, &iov_cnt, s);
if (mac_data.entries * ETH_ALEN > iov_size(iov, iov_cnt)) {
goto error;
}
if (mac_data.entries <= MAC_TABLE_ENTRIES) {
s = iov_to_buf(iov, iov_cnt, 0, macs,
mac_data.entries * ETH_ALEN);
if (s != mac_data.entries * ETH_ALEN) {
goto error;
}
in_use += mac_data.entries;
} else {
uni_overflow = 1;
}
iov_discard_front(&iov, &iov_cnt, mac_data.entries * ETH_ALEN);
first_multi = in_use;
s = iov_to_buf(iov, iov_cnt, 0, &mac_data.entries,
sizeof(mac_data.entries));
mac_data.entries = ldl_p(&mac_data.entries);
if (s != sizeof(mac_data.entries)) {
goto error;
}
iov_discard_front(&iov, &iov_cnt, s);
if (mac_data.entries * ETH_ALEN != iov_size(iov, iov_cnt)) {
goto error;
}
if (in_use + mac_data.entries <= MAC_TABLE_ENTRIES) {
s = iov_to_buf(iov, iov_cnt, 0, &macs[in_use * ETH_ALEN],
mac_data.entries * ETH_ALEN);
if (s != mac_data.entries * ETH_ALEN) {
goto error;
}
in_use += mac_data.entries;
} else {
multi_overflow = 1;
}
n->mac_table.in_use = in_use;
n->mac_table.first_multi = first_multi;
n->mac_table.uni_overflow = uni_overflow;
n->mac_table.multi_overflow = multi_overflow;
memcpy(n->mac_table.macs, macs, MAC_TABLE_ENTRIES * ETH_ALEN);
g_free(macs);
rxfilter_notify(nc);
return VIRTIO_NET_OK;
error:
g_free(macs);
return VIRTIO_NET_ERR;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25401 | static av_cold int ffmmal_init_decoder(AVCodecContext *avctx)
{
MMALDecodeContext *ctx = avctx->priv_data;
MMAL_STATUS_T status;
MMAL_ES_FORMAT_T *format_in;
MMAL_COMPONENT_T *decoder;
char tmp[32];
int ret = 0;
bcm_host_init();
if (mmal_vc_init()) {
av_log(avctx, AV_LOG_ERROR, "Cannot initialize MMAL VC driver!\n");
return AVERROR(ENOSYS);
if ((ret = ff_get_format(avctx, avctx->codec->pix_fmts)) < 0)
return ret;
avctx->pix_fmt = ret;
if ((status = mmal_component_create(MMAL_COMPONENT_DEFAULT_VIDEO_DECODER, &ctx->decoder)))
goto fail;
decoder = ctx->decoder;
format_in = decoder->input[0]->format;
format_in->type = MMAL_ES_TYPE_VIDEO;
switch (avctx->codec_id) {
case AV_CODEC_ID_MPEG2VIDEO:
format_in->encoding = MMAL_ENCODING_MP2V;
break;
case AV_CODEC_ID_MPEG4:
format_in->encoding = MMAL_ENCODING_MP4V;
break;
case AV_CODEC_ID_VC1:
format_in->encoding = MMAL_ENCODING_WVC1;
break;
case AV_CODEC_ID_H264:
default:
format_in->encoding = MMAL_ENCODING_H264;
break;
format_in->es->video.width = FFALIGN(avctx->width, 32);
format_in->es->video.height = FFALIGN(avctx->height, 16);
format_in->es->video.crop.width = avctx->width;
format_in->es->video.crop.height = avctx->height;
format_in->es->video.frame_rate.num = 24000;
format_in->es->video.frame_rate.den = 1001;
format_in->es->video.par.num = avctx->sample_aspect_ratio.num;
format_in->es->video.par.den = avctx->sample_aspect_ratio.den;
format_in->flags = MMAL_ES_FORMAT_FLAG_FRAMED;
av_get_codec_tag_string(tmp, sizeof(tmp), format_in->encoding);
av_log(avctx, AV_LOG_DEBUG, "Using MMAL %s encoding.\n", tmp);
if ((status = mmal_port_format_commit(decoder->input[0])))
goto fail;
decoder->input[0]->buffer_num =
FFMAX(decoder->input[0]->buffer_num_min, 20);
decoder->input[0]->buffer_size =
FFMAX(decoder->input[0]->buffer_size_min, 512 * 1024);
ctx->pool_in = mmal_pool_create(decoder->input[0]->buffer_num, 0);
if (!ctx->pool_in) {
ret = AVERROR(ENOMEM);
goto fail;
if ((ret = ffmal_update_format(avctx)) < 0)
goto fail;
ctx->queue_decoded_frames = mmal_queue_create();
if (!ctx->queue_decoded_frames)
goto fail;
decoder->input[0]->userdata = (void*)avctx;
decoder->output[0]->userdata = (void*)avctx;
decoder->control->userdata = (void*)avctx;
if ((status = mmal_port_enable(decoder->control, control_port_cb)))
goto fail;
if ((status = mmal_port_enable(decoder->input[0], input_callback)))
goto fail;
if ((status = mmal_port_enable(decoder->output[0], output_callback)))
goto fail;
if ((status = mmal_component_enable(decoder)))
goto fail;
return 0;
fail:
ffmmal_close_decoder(avctx);
return ret < 0 ? ret : AVERROR_UNKNOWN;
The vulnerability label is: Vulnerable |
devign_test_set_data_25404 | static int ogg_get_length(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
int i;
int64_t size, end;
int streams_left=0;
if(!s->pb->seekable)
return 0;
// already set
if (s->duration != AV_NOPTS_VALUE)
return 0;
size = avio_size(s->pb);
if(size < 0)
return 0;
end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: 0;
ogg_save (s);
avio_seek (s->pb, end, SEEK_SET);
while (!ogg_read_page (s, &i)){
if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
ogg->streams[i].codec) {
s->streams[i]->duration =
ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
if (s->streams[i]->start_time != AV_NOPTS_VALUE){
s->streams[i]->duration -= s->streams[i]->start_time;
streams_left-= (ogg->streams[i].got_start==-1);
ogg->streams[i].got_start= 1;
}else if(!ogg->streams[i].got_start){
ogg->streams[i].got_start= -1;
streams_left++;
}
}
}
ogg_restore (s, 0);
ogg_save (s);
avio_seek (s->pb, s->data_offset, SEEK_SET);
ogg_reset(s);
while (!ogg_packet(s, &i, NULL, NULL, NULL)) {
int64_t pts = ogg_calc_pts(s, i, NULL);
if (pts != AV_NOPTS_VALUE && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
s->streams[i]->duration -= pts;
ogg->streams[i].got_start= 1;
streams_left--;
}else if(s->streams[i]->start_time != AV_NOPTS_VALUE && !ogg->streams[i].got_start){
ogg->streams[i].got_start= 1;
streams_left--;
}
}
if(streams_left<=0)
break;
}
ogg_restore (s, 0);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25413 | static int mimic_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MimicContext *ctx = avctx->priv_data;
GetByteContext gb;
int is_pframe;
int width, height;
int quality, num_coeffs;
int swap_buf_size = buf_size - MIMIC_HEADER_SIZE;
if (buf_size <= MIMIC_HEADER_SIZE) {
av_log(avctx, AV_LOG_ERROR, "insufficient data\n");
return -1;
}
bytestream2_init(&gb, buf, MIMIC_HEADER_SIZE);
bytestream2_skip(&gb, 2); /* some constant (always 256) */
quality = bytestream2_get_le16u(&gb);
width = bytestream2_get_le16u(&gb);
height = bytestream2_get_le16u(&gb);
bytestream2_skip(&gb, 4); /* some constant */
is_pframe = bytestream2_get_le32u(&gb);
num_coeffs = bytestream2_get_byteu(&gb);
bytestream2_skip(&gb, 3); /* some constant */
if(!ctx->avctx) {
int i;
if(!(width == 160 && height == 120) &&
!(width == 320 && height == 240)) {
av_log(avctx, AV_LOG_ERROR, "invalid width/height!\n");
return -1;
}
ctx->avctx = avctx;
avctx->width = width;
avctx->height = height;
avctx->pix_fmt = PIX_FMT_YUV420P;
for(i = 0; i < 3; i++) {
ctx->num_vblocks[i] = -((-height) >> (3 + !!i));
ctx->num_hblocks[i] = width >> (3 + !!i) ;
}
} else if(width != ctx->avctx->width || height != ctx->avctx->height) {
av_log(avctx, AV_LOG_ERROR, "resolution changing is not supported\n");
return -1;
}
if(is_pframe && !ctx->buf_ptrs[ctx->prev_index].data[0]) {
av_log(avctx, AV_LOG_ERROR, "decoding must start with keyframe\n");
return -1;
}
ctx->buf_ptrs[ctx->cur_index].reference = 1;
ctx->buf_ptrs[ctx->cur_index].pict_type = is_pframe ? AV_PICTURE_TYPE_P:AV_PICTURE_TYPE_I;
if(ff_thread_get_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index])) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
ctx->next_prev_index = ctx->cur_index;
ctx->next_cur_index = (ctx->cur_index - 1) & 15;
prepare_avpic(ctx, &ctx->flipped_ptrs[ctx->cur_index],
(AVPicture*) &ctx->buf_ptrs[ctx->cur_index]);
ff_thread_finish_setup(avctx);
av_fast_malloc(&ctx->swap_buf, &ctx->swap_buf_size,
swap_buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if(!ctx->swap_buf)
return AVERROR(ENOMEM);
ctx->dsp.bswap_buf(ctx->swap_buf,
(const uint32_t*) (buf + MIMIC_HEADER_SIZE),
swap_buf_size>>2);
init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3);
if(!decode(ctx, quality, num_coeffs, !is_pframe)) {
if (avctx->active_thread_type&FF_THREAD_FRAME)
ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], INT_MAX, 0);
else {
ff_thread_release_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index]);
return -1;
}
}
*(AVFrame*)data = ctx->buf_ptrs[ctx->cur_index];
*data_size = sizeof(AVFrame);
ctx->prev_index = ctx->next_prev_index;
ctx->cur_index = ctx->next_cur_index;
/* Only release frames that aren't used for backreferences anymore */
if(ctx->buf_ptrs[ctx->cur_index].data[0])
ff_thread_release_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index]);
return buf_size;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25448 | static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s)
{
int x, y;
unsigned char P[2];
unsigned int flags = 0;
/* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
* either top and bottom or left and right halves */
CHECK_STREAM_PTR(2);
P[0] = *s->stream_ptr++;
P[1] = *s->stream_ptr++;
if (P[0] <= P[1]) {
CHECK_STREAM_PTR(14);
s->stream_ptr -= 2;
for (y = 0; y < 16; y++) {
// new values for each 4x4 block
if (!(y & 3)) {
P[0] = *s->stream_ptr++; P[1] = *s->stream_ptr++;
flags = bytestream_get_le16(&s->stream_ptr);
}
for (x = 0; x < 4; x++, flags >>= 1)
*s->pixel_ptr++ = P[flags & 1];
s->pixel_ptr += s->stride - 4;
// switch to right half
if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;
}
} else {
/* need 10 more bytes */
CHECK_STREAM_PTR(10);
if (s->stream_ptr[4] <= s->stream_ptr[5]) {
flags = bytestream_get_le32(&s->stream_ptr);
/* vertical split; left & right halves are 2-color encoded */
for (y = 0; y < 16; y++) {
for (x = 0; x < 4; x++, flags >>= 1)
*s->pixel_ptr++ = P[flags & 1];
s->pixel_ptr += s->stride - 4;
// switch to right half
if (y == 7) {
s->pixel_ptr -= 8 * s->stride - 4;
P[0] = *s->stream_ptr++; P[1] = *s->stream_ptr++;
flags = bytestream_get_le32(&s->stream_ptr);
}
}
} else {
/* horizontal split; top & bottom halves are 2-color encoded */
for (y = 0; y < 8; y++) {
if (y == 4) {
P[0] = *s->stream_ptr++;
P[1] = *s->stream_ptr++;
}
flags = *s->stream_ptr++ | 0x100;
for (; flags != 1; flags >>= 1)
*s->pixel_ptr++ = P[flags & 1];
s->pixel_ptr += s->line_inc;
}
}
}
/* report success */
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25459 | static int gdb_set_avr_reg(CPUState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
#ifdef WORDS_BIGENDIAN
env->avr[n].u64[0] = ldq_p(mem_buf);
env->avr[n].u64[1] = ldq_p(mem_buf+8);
#else
env->avr[n].u64[1] = ldq_p(mem_buf);
env->avr[n].u64[0] = ldq_p(mem_buf+8);
#endif
return 16;
}
if (n == 33) {
env->vscr = ldl_p(mem_buf);
return 4;
}
if (n == 34) {
env->spr[SPR_VRSAVE] = (target_ulong)ldl_p(mem_buf);
return 4;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25472 | static void vga_draw_text(VGACommonState *s, int full_update)
{
DisplaySurface *surface = qemu_console_surface(s->con);
int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;
int cx_min, cx_max, linesize, x_incr, line, line1;
uint32_t offset, fgcol, bgcol, v, cursor_offset;
uint8_t *d1, *d, *src, *dest, *cursor_ptr;
const uint8_t *font_ptr, *font_base[2];
int dup9, line_offset;
uint32_t *palette;
uint32_t *ch_attr_ptr;
int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);
/* compute font data address (in plane 2) */
v = s->sr[VGA_SEQ_CHARACTER_MAP];
offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2;
if (offset != s->font_offsets[0]) {
s->font_offsets[0] = offset;
full_update = 1;
}
font_base[0] = s->vram_ptr + offset;
offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2;
font_base[1] = s->vram_ptr + offset;
if (offset != s->font_offsets[1]) {
s->font_offsets[1] = offset;
full_update = 1;
}
if (s->plane_updated & (1 << 2) || s->has_chain4_alias) {
/* if the plane 2 was modified since the last display, it
indicates the font may have been modified */
s->plane_updated = 0;
full_update = 1;
}
full_update |= update_basic_params(s);
line_offset = s->line_offset;
vga_get_text_resolution(s, &width, &height, &cw, &cheight);
if ((height * width) <= 1) {
/* better than nothing: exit if transient size is too small */
return;
}
if ((height * width) > CH_ATTR_SIZE) {
/* better than nothing: exit if transient size is too big */
return;
}
if (width != s->last_width || height != s->last_height ||
cw != s->last_cw || cheight != s->last_ch || s->last_depth) {
s->last_scr_width = width * cw;
s->last_scr_height = height * cheight;
qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);
surface = qemu_console_surface(s->con);
dpy_text_resize(s->con, width, height);
s->last_depth = 0;
s->last_width = width;
s->last_height = height;
s->last_ch = cheight;
s->last_cw = cw;
full_update = 1;
}
full_update |= update_palette16(s);
palette = s->last_palette;
x_incr = cw * surface_bytes_per_pixel(surface);
if (full_update) {
s->full_update_text = 1;
}
if (s->full_update_gfx) {
s->full_update_gfx = 0;
full_update |= 1;
}
cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) |
s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr;
if (cursor_offset != s->cursor_offset ||
s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start ||
s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end) {
/* if the cursor position changed, we update the old and new
chars */
if (s->cursor_offset < CH_ATTR_SIZE)
s->last_ch_attr[s->cursor_offset] = -1;
if (cursor_offset < CH_ATTR_SIZE)
s->last_ch_attr[cursor_offset] = -1;
s->cursor_offset = cursor_offset;
s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];
s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];
}
cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4;
if (now >= s->cursor_blink_time) {
s->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2;
s->cursor_visible_phase = !s->cursor_visible_phase;
}
dest = surface_data(surface);
linesize = surface_stride(surface);
ch_attr_ptr = s->last_ch_attr;
line = 0;
offset = s->start_addr * 4;
for(cy = 0; cy < height; cy++) {
d1 = dest;
src = s->vram_ptr + offset;
cx_min = width;
cx_max = -1;
for(cx = 0; cx < width; cx++) {
ch_attr = *(uint16_t *)src;
if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {
if (cx < cx_min)
cx_min = cx;
if (cx > cx_max)
cx_max = cx;
*ch_attr_ptr = ch_attr;
#ifdef HOST_WORDS_BIGENDIAN
ch = ch_attr >> 8;
cattr = ch_attr & 0xff;
#else
ch = ch_attr & 0xff;
cattr = ch_attr >> 8;
#endif
font_ptr = font_base[(cattr >> 3) & 1];
font_ptr += 32 * 4 * ch;
bgcol = palette[cattr >> 4];
fgcol = palette[cattr & 0x0f];
if (cw == 16) {
vga_draw_glyph16(d1, linesize,
font_ptr, cheight, fgcol, bgcol);
} else if (cw != 9) {
vga_draw_glyph8(d1, linesize,
font_ptr, cheight, fgcol, bgcol);
} else {
dup9 = 0;
if (ch >= 0xb0 && ch <= 0xdf &&
(s->ar[VGA_ATC_MODE] & 0x04)) {
dup9 = 1;
}
vga_draw_glyph9(d1, linesize,
font_ptr, cheight, fgcol, bgcol, dup9);
}
if (src == cursor_ptr &&
!(s->cr[VGA_CRTC_CURSOR_START] & 0x20) &&
s->cursor_visible_phase) {
int line_start, line_last, h;
/* draw the cursor */
line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f;
line_last = s->cr[VGA_CRTC_CURSOR_END] & 0x1f;
/* XXX: check that */
if (line_last > cheight - 1)
line_last = cheight - 1;
if (line_last >= line_start && line_start < cheight) {
h = line_last - line_start + 1;
d = d1 + linesize * line_start;
if (cw == 16) {
vga_draw_glyph16(d, linesize,
cursor_glyph, h, fgcol, bgcol);
} else if (cw != 9) {
vga_draw_glyph8(d, linesize,
cursor_glyph, h, fgcol, bgcol);
} else {
vga_draw_glyph9(d, linesize,
cursor_glyph, h, fgcol, bgcol, 1);
}
}
}
}
d1 += x_incr;
src += 4;
ch_attr_ptr++;
}
if (cx_max != -1) {
dpy_gfx_update(s->con, cx_min * cw, cy * cheight,
(cx_max - cx_min + 1) * cw, cheight);
}
dest += linesize * cheight;
line1 = line + cheight;
offset += line_offset;
if (line < s->line_compare && line1 >= s->line_compare) {
offset = 0;
}
line = line1;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25492 | int64_t qemu_ftell(QEMUFile *f)
{
qemu_fflush(f);
return f->pos;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25501 | static int libquvi_read_packet(AVFormatContext *s, AVPacket *pkt)
{
LibQuviContext *qc = s->priv_data;
return av_read_frame(qc->fmtctx, pkt);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25505 | static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
const char *devaddr,
const char *opts)
{
PCIDevice *dev;
DriveInfo *dinfo = NULL;
int type = -1;
char buf[128];
PCIBus *bus;
int devfn;
if (get_param_value(buf, sizeof(buf), "if", opts)) {
if (!strcmp(buf, "scsi"))
type = IF_SCSI;
else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
} else {
monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
return NULL;
}
} else {
monitor_printf(mon, "no if= specified\n");
return NULL;
}
if (get_param_value(buf, sizeof(buf), "file", opts)) {
dinfo = add_init_drive(opts);
if (!dinfo)
return NULL;
if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
return NULL;
}
} else {
dinfo = NULL;
}
bus = pci_get_bus_devfn(&devfn, devaddr);
if (!bus) {
monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
return NULL;
}
switch (type) {
case IF_SCSI:
if (!dinfo) {
monitor_printf(mon, "scsi requires a backing file/device.\n");
return NULL;
}
dev = pci_create(bus, devfn, "lsi53c895a");
if (qdev_init(&dev->qdev) < 0)
dev = NULL;
if (dev) {
BusState *scsibus = QLIST_FIRST(&dev->qdev.child_bus);
scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),
dinfo, dinfo->unit);
}
break;
case IF_VIRTIO:
if (!dinfo) {
monitor_printf(mon, "virtio requires a backing file/device.\n");
return NULL;
}
dev = pci_create(bus, devfn, "virtio-blk-pci");
qdev_prop_set_drive(&dev->qdev, "drive", dinfo);
if (qdev_init(&dev->qdev) < 0)
dev = NULL;
break;
default:
dev = NULL;
}
return dev;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25510 | uint16_t eeprom93xx_read(eeprom_t *eeprom)
{
/* Return status of pin DO (0 or 1). */
logout("CS=%u DO=%u\n", eeprom->eecs, eeprom->eedo);
return (eeprom->eedo);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25515 | static void sysctl_write(void *opaque, target_phys_addr_t addr, uint32_t value)
{
MilkymistSysctlState *s = opaque;
trace_milkymist_sysctl_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_GPIO_OUT:
case R_GPIO_INTEN:
case R_TIMER0_COUNTER:
if (value > s->regs[R_TIMER0_COUNTER]) {
value = s->regs[R_TIMER0_COUNTER];
error_report("milkymist_sysctl: timer0: trying to write a "
"value greater than the limit. Clipping.");
}
/* milkymist timer counts up */
value = s->regs[R_TIMER0_COUNTER] - value;
ptimer_set_count(s->ptimer0, value);
break;
case R_TIMER1_COUNTER:
if (value > s->regs[R_TIMER1_COUNTER]) {
value = s->regs[R_TIMER1_COUNTER];
error_report("milkymist_sysctl: timer1: trying to write a "
"value greater than the limit. Clipping.");
}
/* milkymist timer counts up */
value = s->regs[R_TIMER1_COUNTER] - value;
ptimer_set_count(s->ptimer1, value);
break;
case R_TIMER0_COMPARE:
ptimer_set_limit(s->ptimer0, value, 0);
s->regs[addr] = value;
break;
case R_TIMER1_COMPARE:
ptimer_set_limit(s->ptimer1, value, 0);
s->regs[addr] = value;
break;
case R_TIMER0_CONTROL:
s->regs[addr] = value;
if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) {
trace_milkymist_sysctl_start_timer1();
ptimer_run(s->ptimer0, 0);
} else {
trace_milkymist_sysctl_stop_timer1();
ptimer_stop(s->ptimer0);
}
break;
case R_TIMER1_CONTROL:
s->regs[addr] = value;
if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) {
trace_milkymist_sysctl_start_timer1();
ptimer_run(s->ptimer1, 0);
} else {
trace_milkymist_sysctl_stop_timer1();
ptimer_stop(s->ptimer1);
}
break;
case R_ICAP:
sysctl_icap_write(s, value);
break;
case R_SYSTEM_ID:
qemu_system_reset_request();
break;
case R_GPIO_IN:
case R_CAPABILITIES:
error_report("milkymist_sysctl: write to read-only register 0x"
TARGET_FMT_plx, addr << 2);
break;
default:
error_report("milkymist_sysctl: write access to unkown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25526 | AVFrame *avcodec_alloc_frame(void)
{
AVFrame *frame = av_mallocz(sizeof(AVFrame));
if (frame == NULL)
return NULL;
FF_DISABLE_DEPRECATION_WARNINGS
avcodec_get_frame_defaults(frame);
FF_ENABLE_DEPRECATION_WARNINGS
return frame;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25530 | static int add_hfyu_left_prediction_int16_c(uint16_t *dst, const uint16_t *src, unsigned mask, int w, int acc){
int i;
for(i=0; i<w-1; i++){
acc+= src[i];
dst[i]= acc & mask;
i++;
acc+= src[i];
dst[i]= acc & mask;
}
for(; i<w; i++){
acc+= src[i];
dst[i]= acc & mask;
}
return acc;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25549 | qemu_irq *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)
{
PXA2xxPICState *s;
int iomemtype;
qemu_irq *qi;
s = (PXA2xxPICState *)
qemu_mallocz(sizeof(PXA2xxPICState));
if (!s)
return NULL;
s->cpu_env = env;
s->int_pending[0] = 0;
s->int_pending[1] = 0;
s->int_enabled[0] = 0;
s->int_enabled[1] = 0;
s->is_fiq[0] = 0;
s->is_fiq[1] = 0;
qi = qemu_allocate_irqs(pxa2xx_pic_set_irq, s, PXA2XX_PIC_SRCS);
/* Enable IC memory-mapped registers access. */
iomemtype = cpu_register_io_memory(pxa2xx_pic_readfn,
pxa2xx_pic_writefn, s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 0x00100000, iomemtype);
/* Enable IC coprocessor access. */
cpu_arm_set_cp_io(env, 6, pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s);
register_savevm(NULL, "pxa2xx_pic", 0, 0, pxa2xx_pic_save,
pxa2xx_pic_load, s);
return qi;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25550 | int net_init_vde(QemuOpts *opts, const NetClientOptions *new_opts,
const char *name, VLANState *vlan)
{
const char *sock;
const char *group;
int port, mode;
sock = qemu_opt_get(opts, "sock");
group = qemu_opt_get(opts, "group");
port = qemu_opt_get_number(opts, "port", 0);
mode = qemu_opt_get_number(opts, "mode", 0700);
if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
return -1;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25557 | static const ID3v2EMFunc *get_extra_meta_func(const char *tag, int isv34)
{
int i = 0;
while (ff_id3v2_extra_meta_funcs[i].tag3) {
if (!memcmp(tag,
(isv34 ?
ff_id3v2_extra_meta_funcs[i].tag4 :
ff_id3v2_extra_meta_funcs[i].tag3),
(isv34 ? 4 : 3)))
return &ff_id3v2_extra_meta_funcs[i];
i++;
}
return NULL;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25566 | int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
AVFilterBufferRef *picref, int flags)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterBufferRef *buf;
int ret;
if (!picref) {
c->eof = 1;
return 0;
} else if (c->eof)
return AVERROR(EINVAL);
if (!av_fifo_space(c->fifo) &&
(ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
sizeof(buf))) < 0)
return ret;
if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
ret = check_format_change(buffer_filter, picref);
if (ret < 0)
return ret;
}
if (flags & AV_BUFFERSRC_FLAG_NO_COPY)
buf = picref;
else
buf = copy_buffer_ref(buffer_filter, picref);
if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
if (buf != picref)
avfilter_unref_buffer(buf);
return ret;
}
c->nb_failed_requests = 0;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25571 | static void qstring_destroy_obj(QObject *obj)
{
QString *qs;
assert(obj != NULL);
qs = qobject_to_qstring(obj);
g_free(qs->string);
g_free(qs);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25574 | bool aio_pending(AioContext *ctx)
{
AioHandler *node;
bool result = false;
/*
* We have to walk very carefully in case aio_set_fd_handler is
* called while we're walking.
*/
qemu_lockcnt_inc(&ctx->list_lock);
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
if (node->pfd.revents && node->io_notify) {
result = true;
break;
}
if ((node->pfd.revents & G_IO_IN) && node->io_read) {
result = true;
break;
}
if ((node->pfd.revents & G_IO_OUT) && node->io_write) {
result = true;
break;
}
}
qemu_lockcnt_dec(&ctx->list_lock);
return result;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25578 | static size_t get_request_size(VirtQueue *vq)
{
unsigned int in, out;
virtqueue_get_avail_bytes(vq, &in, &out);
return in;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25580 | static void do_quit(int argc, const char **argv)
{
exit(0);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25583 | static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model,
int pci_enabled,
int kvmclock_enabled)
{
int i;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *cpu_irq;
qemu_irq *isa_irq;
qemu_irq *i8259;
qemu_irq *cmos_s3;
qemu_irq *smi_irq;
IsaIrqState *isa_irq_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
FDCtrl *floppy_controller;
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
pc_cpus_init(cpu_model);
if (kvmclock_enabled) {
kvmclock_create();
}
/* allocate ram and load rom/bios */
pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename,
&below_4g_mem_size, &above_4g_mem_size);
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(cpu_irq[0]);
isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
if (pci_enabled) {
ioapic_init(isa_irq_state);
}
isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size);
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus_new(NULL);
}
isa_bus_irqs(isa_irq);
pc_register_ferr_irq(isa_reserve_irq(13));
pc_vga_init(pci_enabled? pci_bus: NULL);
/* init basic PC hardware */
pc_basic_device_init(isa_irq, &floppy_controller, &rtc_state);
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd);
else
pci_nic_init_nofail(nd, "e1000", NULL);
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
if (pci_enabled) {
PCIDevice *dev;
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
dev = isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0");
}
}
audio_init(isa_irq, pci_enabled ? pci_bus : NULL);
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
idebus[0], idebus[1], floppy_controller, rtc_state);
if (pci_enabled && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
}
if (pci_enabled && acpi_enabled) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
i2c_bus *smbus;
cmos_s3 = qemu_allocate_irqs(pc_cmos_set_s3_resume, rtc_state, 1);
smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
/* TODO: Populate SPD eeprom data. */
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
isa_reserve_irq(9), *cmos_s3, *smi_irq,
kvm_enabled());
for (i = 0; i < 8; i++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init_nofail(eeprom);
}
}
if (i440fx_state) {
i440fx_init_memory_mappings(i440fx_state);
}
if (pci_enabled) {
pc_pci_device_init(pci_bus);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25593 | static av_cold int roq_decode_init(AVCodecContext *avctx)
{
RoqContext *s = avctx->priv_data;
s->avctx = avctx;
if (avctx->width % 16 || avctx->height % 16) {
av_log(avctx, AV_LOG_ERROR,
"Dimensions must be a multiple of 16\n");
return AVERROR_PATCHWELCOME;
}
s->width = avctx->width;
s->height = avctx->height;
s->last_frame = av_frame_alloc();
s->current_frame = av_frame_alloc();
if (!s->current_frame || !s->last_frame) {
av_frame_free(&s->current_frame);
av_frame_free(&s->last_frame);
return AVERROR(ENOMEM);
}
avctx->pix_fmt = AV_PIX_FMT_YUV444P;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25602 | static int usb_bt_handle_data(USBDevice *dev, USBPacket *p)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret = 0;
if (!s->config)
goto fail;
switch (p->pid) {
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case USB_EVT_EP:
ret = usb_bt_fifo_dequeue(&s->evt, p);
break;
case USB_ACL_EP:
ret = usb_bt_fifo_dequeue(&s->acl, p);
break;
case USB_SCO_EP:
ret = usb_bt_fifo_dequeue(&s->sco, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep & 0xf) {
case USB_ACL_EP:
usb_bt_fifo_out_enqueue(s, &s->outacl, s->hci->acl_send,
usb_bt_hci_acl_complete, p->data, p->len);
break;
case USB_SCO_EP:
usb_bt_fifo_out_enqueue(s, &s->outsco, s->hci->sco_send,
usb_bt_hci_sco_complete, p->data, p->len);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25619 | static void rtas_ibm_read_slot_reset_state2(PowerPCCPU *cpu,
sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args, uint32_t nret,
target_ulong rets)
{
sPAPRPHBState *sphb;
sPAPRPHBClass *spc;
uint64_t buid;
int state, ret;
if ((nargs != 3) || (nret != 4 && nret != 5)) {
goto param_error_exit;
}
buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
sphb = find_phb(spapr, buid);
if (!sphb) {
goto param_error_exit;
}
spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
if (!spc->eeh_get_state) {
goto param_error_exit;
}
ret = spc->eeh_get_state(sphb, &state);
rtas_st(rets, 0, ret);
if (ret != RTAS_OUT_SUCCESS) {
return;
}
rtas_st(rets, 1, state);
rtas_st(rets, 2, RTAS_EEH_SUPPORT);
rtas_st(rets, 3, RTAS_EEH_PE_UNAVAIL_INFO);
if (nret >= 5) {
rtas_st(rets, 4, RTAS_EEH_PE_RECOVER_INFO);
}
return;
param_error_exit:
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25636 | void qmp_migrate_set_cache_size(int64_t value, Error **errp)
{
MigrationState *s = migrate_get_current();
/* Check for truncation */
if (value != (size_t)value) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
"exceeding address space");
return;
}
s->xbzrle_cache_size = xbzrle_cache_resize(value);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25669 | int path_is_absolute(const char *path)
{
const char *p;
#ifdef _WIN32
/* specific case for names like: "\\.\d:" */
if (*path == '/' || *path == '\\')
return 1;
#endif
p = strchr(path, ':');
if (p)
p++;
else
p = path;
#ifdef _WIN32
return (*p == '/' || *p == '\\');
#else
return (*p == '/');
#endif
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25670 | opts_end_struct(Visitor *v, Error **errp)
{
OptsVisitor *ov = to_ov(v);
GHashTableIter iter;
GQueue *any;
if (--ov->depth > 0) {
return;
}
/* we should have processed all (distinct) QemuOpt instances */
g_hash_table_iter_init(&iter, ov->unprocessed_opts);
if (g_hash_table_iter_next(&iter, NULL, (void **)&any)) {
const QemuOpt *first;
first = g_queue_peek_head(any);
error_setg(errp, QERR_INVALID_PARAMETER, first->name);
}
g_hash_table_destroy(ov->unprocessed_opts);
ov->unprocessed_opts = NULL;
if (ov->fake_id_opt) {
g_free(ov->fake_id_opt->name);
g_free(ov->fake_id_opt->str);
g_free(ov->fake_id_opt);
}
ov->fake_id_opt = NULL;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25672 | static av_cold int shorten_decode_close(AVCodecContext *avctx)
{
ShortenContext *s = avctx->priv_data;
int i;
for (i = 0; i < s->channels; i++) {
s->decoded[i] -= s->nwrap;
av_freep(&s->decoded[i]);
av_freep(&s->offset[i]);
}
av_freep(&s->bitstream);
av_freep(&s->coeffs);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25693 | void ff_avg_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_and_aver_dst_4x4_msa(src + stride - 2,
src - (stride * 2),
stride, dst, stride);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25704 | static uint32_t apic_mem_readl(void *opaque, target_phys_addr_t addr)
{
DeviceState *d;
APICCommonState *s;
uint32_t val;
int index;
d = cpu_get_current_apic();
if (!d) {
return 0;
}
s = DO_UPCAST(APICCommonState, busdev.qdev, d);
index = (addr >> 4) & 0xff;
switch(index) {
case 0x02: /* id */
val = s->id << 24;
break;
case 0x03: /* version */
val = 0x11 | ((APIC_LVT_NB - 1) << 16); /* version 0x11 */
break;
case 0x08:
apic_sync_vapic(s, SYNC_FROM_VAPIC);
if (apic_report_tpr_access) {
cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_READ);
}
val = s->tpr;
break;
case 0x09:
val = apic_get_arb_pri(s);
break;
case 0x0a:
/* ppr */
val = apic_get_ppr(s);
break;
case 0x0b:
val = 0;
break;
case 0x0d:
val = s->log_dest << 24;
break;
case 0x0e:
val = s->dest_mode << 28;
break;
case 0x0f:
val = s->spurious_vec;
break;
case 0x10 ... 0x17:
val = s->isr[index & 7];
break;
case 0x18 ... 0x1f:
val = s->tmr[index & 7];
break;
case 0x20 ... 0x27:
val = s->irr[index & 7];
break;
case 0x28:
val = s->esr;
break;
case 0x30:
case 0x31:
val = s->icr[index & 1];
break;
case 0x32 ... 0x37:
val = s->lvt[index - 0x32];
break;
case 0x38:
val = s->initial_count;
break;
case 0x39:
val = apic_get_current_count(s);
break;
case 0x3e:
val = s->divide_conf;
break;
default:
s->esr |= ESR_ILLEGAL_ADDRESS;
val = 0;
break;
}
trace_apic_mem_readl(addr, val);
return val;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25711 | static SocketAddressLegacy *tcp_build_address(const char *host_port, Error **errp)
{
InetSocketAddress *iaddr = g_new(InetSocketAddress, 1);
SocketAddressLegacy *saddr;
if (inet_parse(iaddr, host_port, errp)) {
qapi_free_InetSocketAddress(iaddr);
return NULL;
}
saddr = g_new0(SocketAddressLegacy, 1);
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
saddr->u.inet.data = iaddr;
return saddr;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25729 | static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf)
{
int dy = y1 - y0;
int adx = x1 - x0;
int ady = FFABS(dy);
int sy = dy < 0 ? -1 : 1;
buf[x0] = ff_vorbis_floor1_inverse_db_table[y0];
if (ady*2 <= adx) { // optimized common case
render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);
} else {
int base = dy / adx;
int x = x0;
uint8_t y = y0;
int err = -adx;
ady -= FFABS(base) * adx;
while (++x < x1) {
y += base;
err += ady;
if (err >= 0) {
err -= adx;
y += sy;
}
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25734 | static const QObject *qmp_input_get_object(QmpInputVisitor *qiv,
const char *name)
{
const QObject *qobj;
if (qiv->nb_stack == 0) {
qobj = qiv->obj;
} else {
qobj = qiv->stack[qiv->nb_stack - 1].obj;
}
if (name && qobject_type(qobj) == QTYPE_QDICT) {
return qdict_get(qobject_to_qdict(qobj), name);
} else if (qiv->nb_stack > 0 && qobject_type(qobj) == QTYPE_QLIST) {
return qlist_entry_obj(qiv->stack[qiv->nb_stack - 1].entry);
}
return qobj;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25737 | static BufferPoolEntry *get_pool(AVBufferPool *pool)
{
BufferPoolEntry *cur = NULL, *last = NULL;
do {
FFSWAP(BufferPoolEntry*, cur, last);
cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, last, NULL);
if (!cur)
return NULL;
} while (cur != last);
return cur;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25738 | static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos,
int *end_pos2)
{
if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) {
s->gb = s->in_gb;
s->in_gb.buffer = NULL;
assert((get_bits_count(&s->gb) & 7) == 0);
skip_bits_long(&s->gb, *pos - *end_pos);
*end_pos2 =
*end_pos = *end_pos2 + get_bits_count(&s->gb) - *pos;
*pos = get_bits_count(&s->gb);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25741 | static int vpc_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
BDRVVPCState *s = bs->opaque;
int64_t offset;
int64_t sectors, sectors_per_block;
int ret;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
if (cpu_to_be32(footer->type) == VHD_FIXED) {
return bdrv_write(bs->file, sector_num, buf, nb_sectors);
}
while (nb_sectors > 0) {
offset = get_sector_offset(bs, sector_num, 1);
sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;
sectors = sectors_per_block - (sector_num % sectors_per_block);
if (sectors > nb_sectors) {
sectors = nb_sectors;
}
if (offset == -1) {
offset = alloc_block(bs, sector_num);
if (offset < 0)
return -1;
}
ret = bdrv_pwrite(bs->file, offset, buf, sectors * BDRV_SECTOR_SIZE);
if (ret != sectors * BDRV_SECTOR_SIZE) {
return -1;
}
nb_sectors -= sectors;
sector_num += sectors;
buf += sectors * BDRV_SECTOR_SIZE;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25748 | static int read_old_huffman_tables(HYuvContext *s){
#if 1
GetBitContext gb;
int i;
init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
if(read_len_table(s->len[0], &gb)<0)
return -1;
init_get_bits(&gb, classic_shift_chroma, sizeof(classic_shift_chroma)*8);
if(read_len_table(s->len[1], &gb)<0)
return -1;
for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];
for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];
if(s->bitstream_bpp >= 24){
memcpy(s->bits[1], s->bits[0], 256*sizeof(uint32_t));
memcpy(s->len[1] , s->len [0], 256*sizeof(uint8_t));
}
memcpy(s->bits[2], s->bits[1], 256*sizeof(uint32_t));
memcpy(s->len[2] , s->len [1], 256*sizeof(uint8_t));
for(i=0; i<3; i++){
ff_free_vlc(&s->vlc[i]);
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
}
generate_joint_tables(s);
return 0;
#else
av_log(s->avctx, AV_LOG_DEBUG, "v1 huffyuv is not supported \n");
return -1;
#endif
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25753 | exynos4_boards_init_common(MachineState *machine,
Exynos4BoardType board_type)
{
Exynos4BoardState *s = g_new(Exynos4BoardState, 1);
MachineClass *mc = MACHINE_GET_CLASS(machine);
if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) {
error_report("%s board supports only %d CPU cores, ignoring smp_cpus"
" value",
mc->name, EXYNOS4210_NCPUS);
}
exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type];
exynos4_board_binfo.board_id = exynos4_board_id[board_type];
exynos4_board_binfo.smp_bootreg_addr =
exynos4_board_smp_bootreg_addr[board_type];
exynos4_board_binfo.kernel_filename = machine->kernel_filename;
exynos4_board_binfo.initrd_filename = machine->initrd_filename;
exynos4_board_binfo.kernel_cmdline = machine->kernel_cmdline;
exynos4_board_binfo.gic_cpu_if_addr =
EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100;
PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n"
" kernel_filename: %s\n"
" kernel_cmdline: %s\n"
" initrd_filename: %s\n",
exynos4_board_ram_size[board_type] / 1048576,
exynos4_board_ram_size[board_type],
machine->kernel_filename,
machine->kernel_cmdline,
machine->initrd_filename);
exynos4_boards_init_ram(s, get_system_memory(),
exynos4_board_ram_size[board_type]);
s->soc = exynos4210_init(get_system_memory());
return s;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25787 | static void json_print_section_header(WriterContext *wctx)
{
JSONContext *json = wctx->priv;
AVBPrint buf;
const struct section *section = wctx->section[wctx->level];
const struct section *parent_section = wctx->level ?
wctx->section[wctx->level-1] : NULL;
if (wctx->level && wctx->nb_item[wctx->level-1])
printf(",\n");
if (section->flags & SECTION_FLAG_IS_WRAPPER) {
printf("{\n");
json->indent_level++;
} else {
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
json_escape_str(&buf, section->name, wctx);
JSON_INDENT();
json->indent_level++;
if (section->flags & SECTION_FLAG_IS_ARRAY) {
printf("\"%s\": [\n", buf.str);
} else if (!(parent_section->flags & SECTION_FLAG_IS_ARRAY)) {
printf("\"%s\": {%s", buf.str, json->item_start_end);
} else {
printf("{%s", json->item_start_end);
/* this is required so the parser can distinguish between packets and frames */
if (parent_section->id == SECTION_ID_PACKETS_AND_FRAMES) {
if (!json->compact)
JSON_INDENT();
printf("\"type\": \"%s\"%s", section->name, json->item_sep);
}
}
av_bprint_finalize(&buf, NULL);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25810 | build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
{
int madt_start = table_data->len;
const MemMapEntry *memmap = guest_info->memmap;
const int *irqmap = guest_info->irqmap;
AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd;
AcpiMadtGenericMsiFrame *gic_msi;
int i;
madt = acpi_data_push(table_data, sizeof *madt);
gicd = acpi_data_push(table_data, sizeof *gicd);
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
gicd->length = sizeof(*gicd);
gicd->base_address = memmap[VIRT_GIC_DIST].base;
gicd->version = guest_info->gic_version;
for (i = 0; i < guest_info->smp_cpus; i++) {
AcpiMadtGenericInterrupt *gicc = acpi_data_push(table_data,
sizeof *gicc);
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
gicc->length = sizeof(*gicc);
if (guest_info->gic_version == 2) {
gicc->base_address = memmap[VIRT_GIC_CPU].base;
}
gicc->cpu_interface_number = i;
gicc->arm_mpidr = armcpu->mp_affinity;
gicc->uid = i;
gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED);
if (armcpu->has_pmu) {
gicc->performance_interrupt = cpu_to_le32(PPI(VIRTUAL_PMU_IRQ));
}
}
if (guest_info->gic_version == 3) {
AcpiMadtGenericTranslator *gic_its;
AcpiMadtGenericRedistributor *gicr = acpi_data_push(table_data,
sizeof *gicr);
gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;
gicr->length = sizeof(*gicr);
gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
if (its_class_name()) {
gic_its = acpi_data_push(table_data, sizeof *gic_its);
gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
gic_its->length = sizeof(*gic_its);
gic_its->translation_id = 0;
gic_its->base_address = cpu_to_le64(memmap[VIRT_GIC_ITS].base);
}
} else {
gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
gic_msi->length = sizeof(*gic_msi);
gic_msi->gic_msi_frame_id = 0;
gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base);
gic_msi->flags = cpu_to_le32(1);
gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE);
}
build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC",
table_data->len - madt_start, 3, NULL, NULL);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25813 | int slirp_can_output(void)
{
return !slirp_vc || qemu_can_send_packet(slirp_vc);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25814 | static void usb_tablet_class_initfn(ObjectClass *klass, void *data)
{
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
uc->init = usb_tablet_initfn;
uc->product_desc = "QEMU USB Tablet";
uc->usb_desc = &desc_tablet;
uc->handle_packet = usb_generic_handle_packet;
uc->handle_reset = usb_hid_handle_reset;
uc->handle_control = usb_hid_handle_control;
uc->handle_data = usb_hid_handle_data;
uc->handle_destroy = usb_hid_handle_destroy;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25828 | static int pixlet_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
PixletContext *ctx = avctx->priv_data;
int i, w, h, width, height, ret, version;
AVFrame *p = data;
ThreadFrame frame = { .f = data };
uint32_t pktsize;
bytestream2_init(&ctx->gb, avpkt->data, avpkt->size);
pktsize = bytestream2_get_be32(&ctx->gb);
if (pktsize <= 44 || pktsize - 4 > bytestream2_get_bytes_left(&ctx->gb)) {
av_log(avctx, AV_LOG_ERROR, "Invalid packet size %"PRIu32"\n", pktsize);
}
version = bytestream2_get_le32(&ctx->gb);
if (version != 1)
avpriv_request_sample(avctx, "Version %d", version);
bytestream2_skip(&ctx->gb, 4);
if (bytestream2_get_be32(&ctx->gb) != 1)
bytestream2_skip(&ctx->gb, 4);
width = bytestream2_get_be32(&ctx->gb);
height = bytestream2_get_be32(&ctx->gb);
w = FFALIGN(width, 1 << (NB_LEVELS + 1));
h = FFALIGN(height, 1 << (NB_LEVELS + 1));
ctx->levels = bytestream2_get_be32(&ctx->gb);
if (ctx->levels != NB_LEVELS)
ctx->depth = bytestream2_get_be32(&ctx->gb);
if (ctx->depth < 8 || ctx->depth > 15) {
avpriv_request_sample(avctx, "Depth %d", ctx->depth);
}
ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
return ret;
avctx->width = width;
avctx->height = height;
if (ctx->w != w || ctx->h != h) {
free_buffers(avctx);
ctx->w = w;
ctx->h = h;
ret = init_decoder(avctx);
if (ret < 0) {
free_buffers(avctx);
ctx->w = 0;
ctx->h = 0;
return ret;
}
}
bytestream2_skip(&ctx->gb, 8);
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
p->color_range = AVCOL_RANGE_JPEG;
ret = ff_thread_get_buffer(avctx, &frame, 0);
if (ret < 0)
return ret;
for (i = 0; i < 3; i++) {
ret = decode_plane(avctx, i, avpkt, frame.f);
if (ret < 0)
return ret;
if (avctx->flags & AV_CODEC_FLAG_GRAY)
break;
}
postprocess_luma(frame.f, ctx->w, ctx->h, ctx->depth);
postprocess_chroma(frame.f, ctx->w >> 1, ctx->h >> 1, ctx->depth);
*got_frame = 1;
return pktsize;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25831 | static void ccw_machine_2_9_class_options(MachineClass *mc)
{
S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
s390mc->gs_allowed = false;
ccw_machine_2_10_class_options(mc);
SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9);
s390mc->css_migration_enabled = false;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25854 | static int matroska_read_header(AVFormatContext *s)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *attachements_list = &matroska->attachments;
MatroskaAttachement *attachements;
EbmlList *chapters_list = &matroska->chapters;
MatroskaChapter *chapters;
MatroskaTrack *tracks;
uint64_t max_start = 0;
int64_t pos;
Ebml ebml = { 0 };
AVStream *st;
int i, j, k, res;
matroska->ctx = s;
/* First read the EBML header. */
if (ebml_parse(matroska, ebml_syntax, &ebml)
|| ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t)
|| ebml.id_length > sizeof(uint32_t) || ebml.doctype_version > 3) {
av_log(matroska->ctx, AV_LOG_ERROR,
"EBML header using unsupported features\n"
"(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n",
ebml.version, ebml.doctype, ebml.doctype_version);
ebml_free(ebml_syntax, &ebml);
return AVERROR_PATCHWELCOME;
} else if (ebml.doctype_version == 3) {
av_log(matroska->ctx, AV_LOG_WARNING,
"EBML header using unsupported features\n"
"(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n",
ebml.version, ebml.doctype, ebml.doctype_version);
}
for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++)
if (!strcmp(ebml.doctype, matroska_doctypes[i]))
break;
if (i >= FF_ARRAY_ELEMS(matroska_doctypes)) {
av_log(s, AV_LOG_WARNING, "Unknown EBML doctype '%s'\n", ebml.doctype);
}
ebml_free(ebml_syntax, &ebml);
/* The next thing is a segment. */
pos = avio_tell(matroska->ctx->pb);
res = ebml_parse(matroska, matroska_segments, matroska);
// try resyncing until we find a EBML_STOP type element.
while (res != 1) {
res = matroska_resync(matroska, pos);
if (res < 0)
return res;
pos = avio_tell(matroska->ctx->pb);
res = ebml_parse(matroska, matroska_segment, matroska);
}
matroska_execute_seekhead(matroska);
if (!matroska->time_scale)
matroska->time_scale = 1000000;
if (matroska->duration)
matroska->ctx->duration = matroska->duration * matroska->time_scale
* 1000 / AV_TIME_BASE;
av_dict_set(&s->metadata, "title", matroska->title, 0);
if (matroska->date_utc.size == 8)
matroska_metadata_creation_time(&s->metadata, AV_RB64(matroska->date_utc.data));
tracks = matroska->tracks.elem;
for (i=0; i < matroska->tracks.nb_elem; i++) {
MatroskaTrack *track = &tracks[i];
enum CodecID codec_id = CODEC_ID_NONE;
EbmlList *encodings_list = &track->encodings;
MatroskaTrackEncoding *encodings = encodings_list->elem;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
uint32_t fourcc = 0;
AVIOContext b;
/* Apply some sanity checks. */
if (track->type != MATROSKA_TRACK_TYPE_VIDEO &&
track->type != MATROSKA_TRACK_TYPE_AUDIO &&
track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown or unsupported track type %"PRIu64"\n",
track->type);
continue;
}
if (track->codec_id == NULL)
continue;
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
if (!track->default_duration)
track->default_duration = 1000000000/track->video.frame_rate;
if (!track->video.display_width)
track->video.display_width = track->video.pixel_width;
if (!track->video.display_height)
track->video.display_height = track->video.pixel_height;
if (track->video.color_space.size == 4)
fourcc = AV_RL32(track->video.color_space.data);
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
if (!track->audio.out_samplerate)
track->audio.out_samplerate = track->audio.samplerate;
}
if (encodings_list->nb_elem > 1) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Multiple combined encodings not supported");
} else if (encodings_list->nb_elem == 1) {
if (encodings[0].type ||
(encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
#if CONFIG_ZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
#endif
#if CONFIG_BZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB &&
#endif
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) {
encodings[0].scope = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Unsupported encoding type");
} else if (track->codec_priv.size && encodings[0].scope&2) {
uint8_t *codec_priv = track->codec_priv.data;
int offset = matroska_decode_buffer(&track->codec_priv.data,
&track->codec_priv.size,
track);
if (offset < 0) {
track->codec_priv.data = NULL;
track->codec_priv.size = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Failed to decode codec private data\n");
} else if (offset > 0) {
track->codec_priv.data = av_malloc(track->codec_priv.size + offset);
memcpy(track->codec_priv.data,
encodings[0].compression.settings.data, offset);
memcpy(track->codec_priv.data+offset, codec_priv,
track->codec_priv.size);
track->codec_priv.size += offset;
}
if (codec_priv != track->codec_priv.data)
av_free(codec_priv);
}
}
for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){
if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
strlen(ff_mkv_codec_tags[j].str))){
codec_id= ff_mkv_codec_tags[j].id;
break;
}
}
st = track->stream = avformat_new_stream(s, NULL);
if (st == NULL)
return AVERROR(ENOMEM);
if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
&& track->codec_priv.size >= 40
&& track->codec_priv.data != NULL) {
track->ms_compat = 1;
fourcc = AV_RL32(track->codec_priv.data + 16);
codec_id = ff_codec_get_id(ff_codec_bmp_tags, fourcc);
extradata_offset = 40;
} else if (!strcmp(track->codec_id, "A_MS/ACM")
&& track->codec_priv.size >= 14
&& track->codec_priv.data != NULL) {
int ret;
ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size,
AVIO_FLAG_READ, NULL, NULL, NULL, NULL);
ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size);
if (ret < 0)
return ret;
codec_id = st->codec->codec_id;
extradata_offset = FFMIN(track->codec_priv.size, 18);
} else if (!strcmp(track->codec_id, "V_QUICKTIME")
&& (track->codec_priv.size >= 86)
&& (track->codec_priv.data != NULL)) {
fourcc = AV_RL32(track->codec_priv.data);
codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
} else if (codec_id == CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24BE; break;
case 32: codec_id = CODEC_ID_PCM_S32BE; break;
}
} else if (codec_id == CODEC_ID_PCM_S16LE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24LE; break;
case 32: codec_id = CODEC_ID_PCM_S32LE; break;
}
} else if (codec_id==CODEC_ID_PCM_F32LE && track->audio.bitdepth==64) {
codec_id = CODEC_ID_PCM_F64LE;
} else if (codec_id == CODEC_ID_AAC && !track->codec_priv.size) {
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(track->audio.samplerate);
extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (track->audio.channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(track->audio.out_samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else
extradata_size = 2;
} else if (codec_id == CODEC_ID_TTA) {
extradata_size = 30;
extradata = av_mallocz(extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (extradata == NULL)
return AVERROR(ENOMEM);
ffio_init_context(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
avio_write(&b, "TTA1", 4);
avio_wl16(&b, 1);
avio_wl16(&b, track->audio.channels);
avio_wl16(&b, track->audio.bitdepth);
avio_wl32(&b, track->audio.out_samplerate);
avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate);
} else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
} else if (codec_id == CODEC_ID_RA_144) {
track->audio.out_samplerate = 8000;
track->audio.channels = 1;
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) {
int flavor;
ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
avio_skip(&b, 22);
flavor = avio_rb16(&b);
track->audio.coded_framesize = avio_rb32(&b);
avio_skip(&b, 12);
track->audio.sub_packet_h = avio_rb16(&b);
track->audio.frame_size = avio_rb16(&b);
track->audio.sub_packet_size = avio_rb16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
if (codec_id == CODEC_ID_SIPR && flavor < 4) {
const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
st->codec->bit_rate = sipr_bit_rate[flavor];
}
st->codec->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
}
}
track->codec_priv.size -= extradata_offset;
if (codec_id == CODEC_ID_NONE)
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %s.\n", track->codec_id);
if (track->time_scale < 0.01)
track->time_scale = 1.0;
avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
av_dict_set(&st->metadata, "language", track->language, 0);
av_dict_set(&st->metadata, "title", track->name, 0);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->flag_forced)
st->disposition |= AV_DISPOSITION_FORCED;
if (!st->codec->extradata) {
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv.data && track->codec_priv.size > 0){
st->codec->extradata = av_mallocz(track->codec_priv.size +
FF_INPUT_BUFFER_PADDING_SIZE);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv.size;
memcpy(st->codec->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
MatroskaTrackPlane *planes = track->operation.combine_planes.elem;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_tag = fourcc;
st->codec->width = track->video.pixel_width;
st->codec->height = track->video.pixel_height;
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
st->codec->height * track->video.display_width,
st->codec-> width * track->video.display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->default_duration)
st->avg_frame_rate = av_d2q(1000000000.0/track->default_duration, INT_MAX);
/* export stereo mode flag as metadata tag */
if (track->video.stereo_mode && track->video.stereo_mode < MATROSKA_VIDEO_STEREO_MODE_COUNT)
av_dict_set(&st->metadata, "stereo_mode", matroska_video_stereo_mode[track->video.stereo_mode], 0);
/* if we have virtual track, mark the real tracks */
for (j=0; j < track->operation.combine_planes.nb_elem; j++) {
char buf[32];
if (planes[j].type >= MATROSKA_VIDEO_STEREO_PLANE_COUNT)
continue;
snprintf(buf, sizeof(buf), "%s_%d",
matroska_video_stereo_plane[planes[j].type], i);
for (k=0; k < matroska->tracks.nb_elem; k++)
if (planes[j].uid == tracks[k].uid) {
av_dict_set(&s->streams[k]->metadata,
"stereo_mode", buf, 0);
break;
}
}
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = track->audio.out_samplerate;
st->codec->channels = track->audio.channels;
if (st->codec->codec_id != CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
}
}
attachements = attachements_list->elem;
for (j=0; j<attachements_list->nb_elem; j++) {
if (!(attachements[j].filename && attachements[j].mime &&
attachements[j].bin.data && attachements[j].bin.size > 0)) {
av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n");
} else {
AVStream *st = avformat_new_stream(s, NULL);
if (st == NULL)
break;
av_dict_set(&st->metadata, "filename",attachements[j].filename, 0);
av_dict_set(&st->metadata, "mimetype", attachements[j].mime, 0);
st->codec->codec_id = CODEC_ID_NONE;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[j].bin.size + FF_INPUT_BUFFER_PADDING_SIZE);
if(st->codec->extradata == NULL)
break;
st->codec->extradata_size = attachements[j].bin.size;
memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
for (i=0; ff_mkv_mime_tags[i].id != CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_mime_tags[i].str, attachements[j].mime,
strlen(ff_mkv_mime_tags[i].str))) {
st->codec->codec_id = ff_mkv_mime_tags[i].id;
break;
}
}
attachements[j].stream = st;
}
}
chapters = chapters_list->elem;
for (i=0; i<chapters_list->nb_elem; i++)
if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid
&& (max_start==0 || chapters[i].start > max_start)) {
chapters[i].chapter =
avpriv_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
chapters[i].start, chapters[i].end,
chapters[i].title);
av_dict_set(&chapters[i].chapter->metadata,
"title", chapters[i].title, 0);
max_start = chapters[i].start;
}
matroska_add_index_entries(matroska);
matroska_convert_tags(s);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25859 | static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
{
AVFilterContext *ctx = inlink->dst;
SignatureContext *sic = ctx->priv;
StreamContext *sc = &(sic->streamcontexts[FF_INLINK_IDX(inlink)]);
FineSignature* fs;
static const uint8_t pot3[5] = { 3*3*3*3, 3*3*3, 3*3, 3, 1 };
/* indexes of words : 210,217,219,274,334 44,175,233,270,273 57,70,103,237,269 100,285,295,337,354 101,102,111,275,296
s2usw = sorted to unsorted wordvec: 44 is at index 5, 57 at index 10...
*/
static const unsigned int wordvec[25] = {44,57,70,100,101,102,103,111,175,210,217,219,233,237,269,270,273,274,275,285,295,296,334,337,354};
static const uint8_t s2usw[25] = { 5,10,11, 15, 20, 21, 12, 22, 6, 0, 1, 2, 7, 13, 14, 8, 9, 3, 23, 16, 17, 24, 4, 18, 19};
uint8_t wordt2b[5] = { 0, 0, 0, 0, 0 }; /* word ternary to binary */
uint64_t intpic[32][32];
uint64_t rowcount;
uint8_t *p = picref->data[0];
int inti, intj;
int *intjlut;
uint64_t conflist[DIFFELEM_SIZE];
int f = 0, g = 0, w = 0;
int32_t dh1 = 1, dh2 = 1, dw1 = 1, dw2 = 1, a, b;
int64_t denom;
int i, j, k, ternary;
uint64_t blocksum;
int blocksize;
int64_t th; /* threshold */
int64_t sum;
int64_t precfactor = (sc->divide) ? 65536 : BLOCK_LCM;
/* initialize fs */
if (sc->curfinesig) {
fs = av_mallocz(sizeof(FineSignature));
if (!fs)
return AVERROR(ENOMEM);
sc->curfinesig->next = fs;
fs->prev = sc->curfinesig;
sc->curfinesig = fs;
} else {
fs = sc->curfinesig = sc->finesiglist;
sc->curcoarsesig1->first = fs;
}
fs->pts = picref->pts;
fs->index = sc->lastindex++;
memset(intpic, 0, sizeof(uint64_t)*32*32);
intjlut = av_malloc_array(inlink->w, sizeof(int));
if (!intjlut)
return AVERROR(ENOMEM);
for (i = 0; i < inlink->w; i++) {
intjlut[i] = (i*32)/inlink->w;
}
for (i = 0; i < inlink->h; i++) {
inti = (i*32)/inlink->h;
for (j = 0; j < inlink->w; j++) {
intj = intjlut[j];
intpic[inti][intj] += p[j];
}
p += picref->linesize[0];
}
av_freep(&intjlut);
/* The following calculates a summed area table (intpic) and brings the numbers
* in intpic to the same denominator.
* So you only have to handle the numinator in the following sections.
*/
dh1 = inlink->h / 32;
if (inlink->h % 32)
dh2 = dh1 + 1;
dw1 = inlink->w / 32;
if (inlink->w % 32)
dw2 = dw1 + 1;
denom = (sc->divide) ? dh1 * dh2 * dw1 * dw2 : 1;
for (i = 0; i < 32; i++) {
rowcount = 0;
a = 1;
if (dh2 > 1) {
a = ((inlink->h*(i+1))%32 == 0) ? (inlink->h*(i+1))/32 - 1 : (inlink->h*(i+1))/32;
a -= ((inlink->h*i)%32 == 0) ? (inlink->h*i)/32 - 1 : (inlink->h*i)/32;
a = (a == dh1)? dh2 : dh1;
}
for (j = 0; j < 32; j++) {
b = 1;
if (dw2 > 1) {
b = ((inlink->w*(j+1))%32 == 0) ? (inlink->w*(j+1))/32 - 1 : (inlink->w*(j+1))/32;
b -= ((inlink->w*j)%32 == 0) ? (inlink->w*j)/32 - 1 : (inlink->w*j)/32;
b = (b == dw1)? dw2 : dw1;
}
rowcount += intpic[i][j] * a * b * precfactor / denom;
if (i > 0) {
intpic[i][j] = intpic[i-1][j] + rowcount;
} else {
intpic[i][j] = rowcount;
}
}
}
denom = (sc->divide) ? 1 : dh1 * dh2 * dw1 * dw2;
for (i = 0; i < ELEMENT_COUNT; i++) {
const ElemCat* elemcat = elements[i];
int64_t* elemsignature;
uint64_t* sortsignature;
elemsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
if (!elemsignature)
return AVERROR(ENOMEM);
sortsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
if (!sortsignature)
return AVERROR(ENOMEM);
for (j = 0; j < elemcat->elem_count; j++) {
blocksum = 0;
blocksize = 0;
for (k = 0; k < elemcat->left_count; k++) {
blocksum += get_block_sum(sc, intpic, &elemcat->blocks[j*elemcat->block_count+k]);
blocksize += get_block_size(&elemcat->blocks[j*elemcat->block_count+k]);
}
sum = blocksum / blocksize;
if (elemcat->av_elem) {
sum -= 128 * precfactor * denom;
} else {
blocksum = 0;
blocksize = 0;
for (; k < elemcat->block_count; k++) {
blocksum += get_block_sum(sc, intpic, &elemcat->blocks[j*elemcat->block_count+k]);
blocksize += get_block_size(&elemcat->blocks[j*elemcat->block_count+k]);
}
sum -= blocksum / blocksize;
conflist[g++] = FFABS(sum * 8 / (precfactor * denom));
}
elemsignature[j] = sum;
sortsignature[j] = FFABS(sum);
}
/* get threshold */
qsort(sortsignature, elemcat->elem_count, sizeof(uint64_t), (void*) cmp);
th = sortsignature[(int) (elemcat->elem_count*0.333)];
/* ternarize */
for (j = 0; j < elemcat->elem_count; j++) {
if (elemsignature[j] < -th) {
ternary = 0;
} else if (elemsignature[j] <= th) {
ternary = 1;
} else {
ternary = 2;
}
fs->framesig[f/5] += ternary * pot3[f%5];
if (f == wordvec[w]) {
fs->words[s2usw[w]/5] += ternary * pot3[wordt2b[s2usw[w]/5]++];
if (w < 24)
w++;
}
f++;
}
av_freep(&elemsignature);
av_freep(&sortsignature);
}
/* confidence */
qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), (void*) cmp);
fs->confidence = FFMIN(conflist[DIFFELEM_SIZE/2], 255);
/* coarsesignature */
if (sc->coarsecount == 0) {
if (sc->curcoarsesig2) {
sc->curcoarsesig1 = av_mallocz(sizeof(CoarseSignature));
if (!sc->curcoarsesig1)
return AVERROR(ENOMEM);
sc->curcoarsesig1->first = fs;
sc->curcoarsesig2->next = sc->curcoarsesig1;
sc->coarseend = sc->curcoarsesig1;
}
}
if (sc->coarsecount == 45) {
sc->midcoarse = 1;
sc->curcoarsesig2 = av_mallocz(sizeof(CoarseSignature));
if (!sc->curcoarsesig2)
return AVERROR(ENOMEM);
sc->curcoarsesig2->first = fs;
sc->curcoarsesig1->next = sc->curcoarsesig2;
sc->coarseend = sc->curcoarsesig2;
}
for (i = 0; i < 5; i++) {
set_bit(sc->curcoarsesig1->data[i], fs->words[i]);
}
/* assuming the actual frame is the last */
sc->curcoarsesig1->last = fs;
if (sc->midcoarse) {
for (i = 0; i < 5; i++) {
set_bit(sc->curcoarsesig2->data[i], fs->words[i]);
}
sc->curcoarsesig2->last = fs;
}
sc->coarsecount = (sc->coarsecount+1)%90;
/* debug printing finesignature */
if (av_log_get_level() == AV_LOG_DEBUG) {
av_log(ctx, AV_LOG_DEBUG, "input %d, confidence: %d\n", FF_INLINK_IDX(inlink), fs->confidence);
av_log(ctx, AV_LOG_DEBUG, "words:");
for (i = 0; i < 5; i++) {
av_log(ctx, AV_LOG_DEBUG, " %d:", fs->words[i] );
av_log(ctx, AV_LOG_DEBUG, " %d", fs->words[i] / pot3[0] );
for (j = 1; j < 5; j++)
av_log(ctx, AV_LOG_DEBUG, ",%d", fs->words[i] % pot3[j-1] / pot3[j] );
av_log(ctx, AV_LOG_DEBUG, ";");
}
av_log(ctx, AV_LOG_DEBUG, "\n");
av_log(ctx, AV_LOG_DEBUG, "framesignature:");
for (i = 0; i < SIGELEM_SIZE/5; i++) {
av_log(ctx, AV_LOG_DEBUG, " %d", fs->framesig[i] / pot3[0] );
for (j = 1; j < 5; j++)
av_log(ctx, AV_LOG_DEBUG, ",%d", fs->framesig[i] % pot3[j-1] / pot3[j] );
}
av_log(ctx, AV_LOG_DEBUG, "\n");
}
if (FF_INLINK_IDX(inlink) == 0)
return ff_filter_frame(inlink->dst->outputs[0], picref);
return 1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25862 | static void test_dma_fragmented(void)
{
AHCIQState *ahci;
AHCICommand *cmd;
uint8_t px;
size_t bufsize = 4096;
unsigned char *tx = g_malloc(bufsize);
unsigned char *rx = g_malloc0(bufsize);
uint64_t ptr;
ahci = ahci_boot_and_enable(NULL);
px = ahci_port_select(ahci);
ahci_port_clear(ahci, px);
/* create pattern */
generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE);
/* Create a DMA buffer in guest memory, and write our pattern to it. */
ptr = guest_alloc(ahci->parent->alloc, bufsize);
g_assert(ptr);
bufwrite(ptr, tx, bufsize);
cmd = ahci_command_create(CMD_WRITE_DMA);
ahci_command_adjust(cmd, 0, ptr, bufsize, 32);
ahci_command_commit(ahci, cmd, px);
ahci_command_issue(ahci, cmd);
ahci_command_verify(ahci, cmd);
g_free(cmd);
cmd = ahci_command_create(CMD_READ_DMA);
ahci_command_adjust(cmd, 0, ptr, bufsize, 32);
ahci_command_commit(ahci, cmd, px);
ahci_command_issue(ahci, cmd);
ahci_command_verify(ahci, cmd);
g_free(cmd);
/* Read back the guest's receive buffer into local memory */
bufread(ptr, rx, bufsize);
guest_free(ahci->parent->alloc, ptr);
g_assert_cmphex(memcmp(tx, rx, bufsize), ==, 0);
ahci_shutdown(ahci);
g_free(rx);
g_free(tx);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25865 | static uint32_t pcihotplug_read(void *opaque, uint32_t addr)
{
uint32_t val = 0;
struct pci_status *g = opaque;
switch (addr) {
case PCI_BASE:
val = g->up;
break;
case PCI_BASE + 4:
val = g->down;
break;
default:
break;
}
PIIX4_DPRINTF("pcihotplug read %x == %x\n", addr, val);
return val;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25868 | static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
int64_t size;
AVIOContext *pb = s->pb;
WAVContext *wav = s->priv_data;
AVStream *st;
uint8_t guid[16];
avio_read(pb, guid, 16);
if (memcmp(guid, guid_riff, 16))
return -1;
if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
return -1;
avio_read(pb, guid, 16);
if (memcmp(guid, guid_wave, 16)) {
av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
return -1;
}
size = find_guid(pb, guid_fmt);
if (size < 0) {
av_log(s, AV_LOG_ERROR, "could not find fmt guid\n");
return -1;
}
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
/* subtract chunk header size - normal wav file doesn't count it */
ff_get_wav_header(pb, st->codec, size - 24);
avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
st->need_parsing = AVSTREAM_PARSE_FULL;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
size = find_guid(pb, guid_data);
if (size < 0) {
av_log(s, AV_LOG_ERROR, "could not find data guid\n");
return -1;
}
wav->data_end = avio_tell(pb) + size - 24;
wav->w64 = 1;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25869 | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long 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_25872 | int vnc_job_add_rect(VncJob *job, int x, int y, int w, int h)
{
VncRectEntry *entry = g_malloc0(sizeof(VncRectEntry));
entry->rect.x = x;
entry->rect.y = y;
entry->rect.w = w;
entry->rect.h = h;
vnc_lock_queue(queue);
QLIST_INSERT_HEAD(&job->rectangles, entry, next);
vnc_unlock_queue(queue);
return 1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25925 | static void uhci_async_complete_packet(USBPacket * packet, void *opaque)
{
UHCIState *s = opaque;
UHCI_QH qh;
UHCI_TD td;
uint32_t link;
uint32_t old_td_ctrl;
uint32_t val;
uint32_t frame_addr;
int ret;
/* Handle async isochronous packet completion */
frame_addr = s->async_frame_addr;
if (frame_addr) {
cpu_physical_memory_read(frame_addr, (uint8_t *)&link, 4);
le32_to_cpus(&link);
cpu_physical_memory_read(link & ~0xf, (uint8_t *)&td, sizeof(td));
le32_to_cpus(&td.link);
le32_to_cpus(&td.ctrl);
le32_to_cpus(&td.token);
le32_to_cpus(&td.buffer);
old_td_ctrl = td.ctrl;
ret = uhci_handle_td(s, &td, &s->pending_int_mask, 1);
/* update the status bits of the TD */
if (old_td_ctrl != td.ctrl) {
val = cpu_to_le32(td.ctrl);
cpu_physical_memory_write((link & ~0xf) + 4,
(const uint8_t *)&val,
sizeof(val));
}
if (ret == 2) {
s->async_frame_addr = frame_addr;
} else if (ret == 0) {
/* update qh element link */
val = cpu_to_le32(td.link);
cpu_physical_memory_write(frame_addr,
(const uint8_t *)&val,
sizeof(val));
}
return;
}
link = s->async_qh;
if (!link) {
/* This should never happen. It means a TD somehow got removed
without cancelling the associated async IO request. */
return;
}
cpu_physical_memory_read(link & ~0xf, (uint8_t *)&qh, sizeof(qh));
le32_to_cpus(&qh.link);
le32_to_cpus(&qh.el_link);
/* Re-process the queue containing the async packet. */
while (1) {
cpu_physical_memory_read(qh.el_link & ~0xf,
(uint8_t *)&td, sizeof(td));
le32_to_cpus(&td.link);
le32_to_cpus(&td.ctrl);
le32_to_cpus(&td.token);
le32_to_cpus(&td.buffer);
old_td_ctrl = td.ctrl;
ret = uhci_handle_td(s, &td, &s->pending_int_mask, 1);
/* update the status bits of the TD */
if (old_td_ctrl != td.ctrl) {
val = cpu_to_le32(td.ctrl);
cpu_physical_memory_write((qh.el_link & ~0xf) + 4,
(const uint8_t *)&val,
sizeof(val));
}
if (ret < 0)
break; /* interrupted frame */
if (ret == 2) {
s->async_qh = link;
break;
} else if (ret == 0) {
/* update qh element link */
qh.el_link = td.link;
val = cpu_to_le32(qh.el_link);
cpu_physical_memory_write((link & ~0xf) + 4,
(const uint8_t *)&val,
sizeof(val));
if (!(qh.el_link & 4))
break;
}
break;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25932 | static void tracked_request_end(BdrvTrackedRequest *req)
{
if (req->serialising) {
req->bs->serialising_in_flight--;
}
QLIST_REMOVE(req, list);
qemu_co_queue_restart_all(&req->wait_queue);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25936 | static int adpcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ADPCMDecodeContext *c = avctx->priv_data;
ADPCMChannelStatus *cs;
int n, m, channel, i;
int block_predictor[2];
short *samples;
short *samples_end;
const uint8_t *src;
int st; /* stereo */
/* DK3 ADPCM accounting variables */
unsigned char last_byte = 0;
unsigned char nibble;
int decode_top_nibble_next = 0;
int diff_channel;
/* EA ADPCM state variables */
uint32_t samples_in_chunk;
int32_t previous_left_sample, previous_right_sample;
int32_t current_left_sample, current_right_sample;
int32_t next_left_sample, next_right_sample;
int32_t coeff1l, coeff2l, coeff1r, coeff2r;
uint8_t shift_left, shift_right;
int count1, count2;
int coeff[2][2], shift[2];//used in EA MAXIS ADPCM
if (!buf_size)
return 0;
//should protect all 4bit ADPCM variants
//8 is needed for CODEC_ID_ADPCM_IMA_WAV with 2 channels
//
if(*data_size/4 < buf_size + 8)
return -1;
samples = data;
samples_end= samples + *data_size/2;
*data_size= 0;
src = buf;
st = avctx->channels == 2 ? 1 : 0;
switch(avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_QT:
n = buf_size - 2*avctx->channels;
for (channel = 0; channel < avctx->channels; channel++) {
int16_t predictor;
int step_index;
cs = &(c->status[channel]);
/* (pppppp) (piiiiiii) */
/* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
predictor = AV_RB16(src);
step_index = predictor & 0x7F;
predictor &= 0xFF80;
src += 2;
if (cs->step_index == step_index) {
int diff = (int)predictor - cs->predictor;
if (diff < 0)
diff = - diff;
if (diff > 0x7f)
goto update;
} else {
update:
cs->step_index = step_index;
cs->predictor = predictor;
}
if (cs->step_index > 88){
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
cs->step_index = 88;
}
samples = (short*)data + channel;
for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */
*samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3);
samples += avctx->channels;
*samples = adpcm_ima_qt_expand_nibble(cs, src[0] >> 4 , 3);
samples += avctx->channels;
src ++;
}
}
if (st)
samples--;
break;
case CODEC_ID_ADPCM_IMA_WAV:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
// samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1;
for(i=0; i<avctx->channels; i++){
cs = &(c->status[i]);
cs->predictor = *samples++ = (int16_t)bytestream_get_le16(&src);
cs->step_index = *src++;
if (cs->step_index > 88){
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
cs->step_index = 88;
}
if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]); /* unused */
}
while(src < buf + buf_size){
for(m=0; m<4; m++){
for(i=0; i<=st; i++)
*samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] & 0x0F, 3);
for(i=0; i<=st; i++)
*samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] >> 4 , 3);
src++;
}
src += 4*st;
}
break;
case CODEC_ID_ADPCM_4XM:
cs = &(c->status[0]);
c->status[0].predictor= (int16_t)bytestream_get_le16(&src);
if(st){
c->status[1].predictor= (int16_t)bytestream_get_le16(&src);
}
c->status[0].step_index= (int16_t)bytestream_get_le16(&src);
if(st){
c->status[1].step_index= (int16_t)bytestream_get_le16(&src);
}
if (cs->step_index < 0) cs->step_index = 0;
if (cs->step_index > 88) cs->step_index = 88;
m= (buf_size - (src - buf))>>st;
for(i=0; i<m; i++) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4);
if (st)
*samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4);
*samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4);
if (st)
*samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4);
}
src += m<<st;
break;
case CODEC_ID_ADPCM_MS:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
n = buf_size - 7 * avctx->channels;
if (n < 0)
return -1;
block_predictor[0] = av_clip(*src++, 0, 6);
block_predictor[1] = 0;
if (st)
block_predictor[1] = av_clip(*src++, 0, 6);
c->status[0].idelta = (int16_t)bytestream_get_le16(&src);
if (st){
c->status[1].idelta = (int16_t)bytestream_get_le16(&src);
}
c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor[0]];
c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor[0]];
c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor[1]];
c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor[1]];
c->status[0].sample1 = bytestream_get_le16(&src);
if (st) c->status[1].sample1 = bytestream_get_le16(&src);
c->status[0].sample2 = bytestream_get_le16(&src);
if (st) c->status[1].sample2 = bytestream_get_le16(&src);
*samples++ = c->status[0].sample2;
if (st) *samples++ = c->status[1].sample2;
*samples++ = c->status[0].sample1;
if (st) *samples++ = c->status[1].sample1;
for(;n>0;n--) {
*samples++ = adpcm_ms_expand_nibble(&c->status[0 ], src[0] >> 4 );
*samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
src ++;
}
break;
case CODEC_ID_ADPCM_IMA_DK4:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
c->status[0].predictor = (int16_t)bytestream_get_le16(&src);
c->status[0].step_index = *src++;
src++;
*samples++ = c->status[0].predictor;
if (st) {
c->status[1].predictor = (int16_t)bytestream_get_le16(&src);
c->status[1].step_index = *src++;
src++;
*samples++ = c->status[1].predictor;
}
while (src < buf + buf_size) {
uint8_t v = *src++;
*samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
}
break;
case CODEC_ID_ADPCM_IMA_DK3:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
if(buf_size + 16 > (samples_end - samples)*3/8)
return -1;
c->status[0].predictor = (int16_t)AV_RL16(src + 10);
c->status[1].predictor = (int16_t)AV_RL16(src + 12);
c->status[0].step_index = src[14];
c->status[1].step_index = src[15];
/* sign extend the predictors */
src += 16;
diff_channel = c->status[1].predictor;
/* the DK3_GET_NEXT_NIBBLE macro issues the break statement when
* the buffer is consumed */
while (1) {
/* for this algorithm, c->status[0] is the sum channel and
* c->status[1] is the diff channel */
/* process the first predictor of the sum channel */
DK3_GET_NEXT_NIBBLE();
adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
/* process the diff channel predictor */
DK3_GET_NEXT_NIBBLE();
adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
/* process the first pair of stereo PCM samples */
diff_channel = (diff_channel + c->status[1].predictor) / 2;
*samples++ = c->status[0].predictor + c->status[1].predictor;
*samples++ = c->status[0].predictor - c->status[1].predictor;
/* process the second predictor of the sum channel */
DK3_GET_NEXT_NIBBLE();
adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
/* process the second pair of stereo PCM samples */
diff_channel = (diff_channel + c->status[1].predictor) / 2;
*samples++ = c->status[0].predictor + c->status[1].predictor;
*samples++ = c->status[0].predictor - c->status[1].predictor;
}
break;
case CODEC_ID_ADPCM_IMA_ISS:
c->status[0].predictor = (int16_t)AV_RL16(src + 0);
c->status[0].step_index = src[2];
src += 4;
if(st) {
c->status[1].predictor = (int16_t)AV_RL16(src + 0);
c->status[1].step_index = src[2];
src += 4;
}
while (src < buf + buf_size) {
uint8_t v1, v2;
uint8_t v = *src++;
/* nibbles are swapped for mono */
if (st) {
v1 = v >> 4;
v2 = v & 0x0F;
} else {
v2 = v >> 4;
v1 = v & 0x0F;
}
*samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
}
break;
case CODEC_ID_ADPCM_IMA_WS:
while (src < buf + buf_size) {
uint8_t v = *src++;
*samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
}
break;
case CODEC_ID_ADPCM_XA:
while (buf_size >= 128) {
xa_decode(samples, src, &c->status[0], &c->status[1],
avctx->channels);
src += 128;
samples += 28 * 8;
buf_size -= 128;
}
break;
case CODEC_ID_ADPCM_IMA_EA_EACS:
samples_in_chunk = bytestream_get_le32(&src) >> (1-st);
if (samples_in_chunk > buf_size-4-(8<<st)) {
src += buf_size - 4;
break;
}
for (i=0; i<=st; i++)
c->status[i].step_index = bytestream_get_le32(&src);
for (i=0; i<=st; i++)
c->status[i].predictor = bytestream_get_le32(&src);
for (; samples_in_chunk; samples_in_chunk--, src++) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0], *src>>4, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[st], *src&0x0F, 3);
}
break;
case CODEC_ID_ADPCM_IMA_EA_SEAD:
for (; src < buf+buf_size; src++) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] >> 4, 6);
*samples++ = adpcm_ima_expand_nibble(&c->status[st],src[0]&0x0F, 6);
}
break;
case CODEC_ID_ADPCM_EA:
/* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
each coding 28 stereo samples. */
if (buf_size < 12) {
av_log(avctx, AV_LOG_ERROR, "frame too small\n");
return AVERROR(EINVAL);
}
samples_in_chunk = AV_RL32(src);
if (samples_in_chunk / 28 > (buf_size - 12) / 30) {
av_log(avctx, AV_LOG_ERROR, "invalid frame\n");
return AVERROR(EINVAL);
}
src += 4;
current_left_sample = (int16_t)bytestream_get_le16(&src);
previous_left_sample = (int16_t)bytestream_get_le16(&src);
current_right_sample = (int16_t)bytestream_get_le16(&src);
previous_right_sample = (int16_t)bytestream_get_le16(&src);
for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
coeff1l = ea_adpcm_table[ *src >> 4 ];
coeff2l = ea_adpcm_table[(*src >> 4 ) + 4];
coeff1r = ea_adpcm_table[*src & 0x0F];
coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];
src++;
shift_left = (*src >> 4 ) + 8;
shift_right = (*src & 0x0F) + 8;
src++;
for (count2 = 0; count2 < 28; count2++) {
next_left_sample = (int32_t)((*src & 0xF0) << 24) >> shift_left;
next_right_sample = (int32_t)((*src & 0x0F) << 28) >> shift_right;
src++;
next_left_sample = (next_left_sample +
(current_left_sample * coeff1l) +
(previous_left_sample * coeff2l) + 0x80) >> 8;
next_right_sample = (next_right_sample +
(current_right_sample * coeff1r) +
(previous_right_sample * coeff2r) + 0x80) >> 8;
previous_left_sample = current_left_sample;
current_left_sample = av_clip_int16(next_left_sample);
previous_right_sample = current_right_sample;
current_right_sample = av_clip_int16(next_right_sample);
*samples++ = (unsigned short)current_left_sample;
*samples++ = (unsigned short)current_right_sample;
}
}
if (src - buf == buf_size - 2)
src += 2; // Skip terminating 0x0000
break;
case CODEC_ID_ADPCM_EA_MAXIS_XA:
for(channel = 0; channel < avctx->channels; channel++) {
for (i=0; i<2; i++)
coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i];
shift[channel] = (*src & 0x0F) + 8;
src++;
}
for (count1 = 0; count1 < (buf_size - avctx->channels) / avctx->channels; count1++) {
for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
for(channel = 0; channel < avctx->channels; channel++) {
int32_t sample = (int32_t)(((*(src+channel) >> i) & 0x0F) << 0x1C) >> shift[channel];
sample = (sample +
c->status[channel].sample1 * coeff[channel][0] +
c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
c->status[channel].sample2 = c->status[channel].sample1;
c->status[channel].sample1 = av_clip_int16(sample);
*samples++ = c->status[channel].sample1;
}
}
src+=avctx->channels;
}
break;
case CODEC_ID_ADPCM_EA_R1:
case CODEC_ID_ADPCM_EA_R2:
case CODEC_ID_ADPCM_EA_R3: {
/* channel numbering
2chan: 0=fl, 1=fr
4chan: 0=fl, 1=rl, 2=fr, 3=rr
6chan: 0=fl, 1=c, 2=fr, 3=rl, 4=rr, 5=sub */
const int big_endian = avctx->codec->id == CODEC_ID_ADPCM_EA_R3;
int32_t previous_sample, current_sample, next_sample;
int32_t coeff1, coeff2;
uint8_t shift;
unsigned int channel;
uint16_t *samplesC;
const uint8_t *srcC;
const uint8_t *src_end = buf + buf_size;
samples_in_chunk = (big_endian ? bytestream_get_be32(&src)
: bytestream_get_le32(&src)) / 28;
if (samples_in_chunk > UINT32_MAX/(28*avctx->channels) ||
28*samples_in_chunk*avctx->channels > samples_end-samples) {
src += buf_size - 4;
break;
}
for (channel=0; channel<avctx->channels; channel++) {
int32_t offset = (big_endian ? bytestream_get_be32(&src)
: bytestream_get_le32(&src))
+ (avctx->channels-channel-1) * 4;
if ((offset < 0) || (offset >= src_end - src - 4)) break;
srcC = src + offset;
samplesC = samples + channel;
if (avctx->codec->id == CODEC_ID_ADPCM_EA_R1) {
current_sample = (int16_t)bytestream_get_le16(&srcC);
previous_sample = (int16_t)bytestream_get_le16(&srcC);
} else {
current_sample = c->status[channel].predictor;
previous_sample = c->status[channel].prev_sample;
}
for (count1=0; count1<samples_in_chunk; count1++) {
if (*srcC == 0xEE) { /* only seen in R2 and R3 */
srcC++;
if (srcC > src_end - 30*2) break;
current_sample = (int16_t)bytestream_get_be16(&srcC);
previous_sample = (int16_t)bytestream_get_be16(&srcC);
for (count2=0; count2<28; count2++) {
*samplesC = (int16_t)bytestream_get_be16(&srcC);
samplesC += avctx->channels;
}
} else {
coeff1 = ea_adpcm_table[ *srcC>>4 ];
coeff2 = ea_adpcm_table[(*srcC>>4) + 4];
shift = (*srcC++ & 0x0F) + 8;
if (srcC > src_end - 14) break;
for (count2=0; count2<28; count2++) {
if (count2 & 1)
next_sample = (int32_t)((*srcC++ & 0x0F) << 28) >> shift;
else
next_sample = (int32_t)((*srcC & 0xF0) << 24) >> shift;
next_sample += (current_sample * coeff1) +
(previous_sample * coeff2);
next_sample = av_clip_int16(next_sample >> 8);
previous_sample = current_sample;
current_sample = next_sample;
*samplesC = current_sample;
samplesC += avctx->channels;
}
}
}
if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) {
c->status[channel].predictor = current_sample;
c->status[channel].prev_sample = previous_sample;
}
}
src = src + buf_size - (4 + 4*avctx->channels);
samples += 28 * samples_in_chunk * avctx->channels;
break;
}
case CODEC_ID_ADPCM_EA_XAS:
if (samples_end-samples < 32*4*avctx->channels
|| buf_size < (4+15)*4*avctx->channels) {
src += buf_size;
break;
}
for (channel=0; channel<avctx->channels; channel++) {
int coeff[2][4], shift[4];
short *s2, *s = &samples[channel];
for (n=0; n<4; n++, s+=32*avctx->channels) {
for (i=0; i<2; i++)
coeff[i][n] = ea_adpcm_table[(src[0]&0x0F)+4*i];
shift[n] = (src[2]&0x0F) + 8;
for (s2=s, i=0; i<2; i++, src+=2, s2+=avctx->channels)
s2[0] = (src[0]&0xF0) + (src[1]<<8);
}
for (m=2; m<32; m+=2) {
s = &samples[m*avctx->channels + channel];
for (n=0; n<4; n++, src++, s+=32*avctx->channels) {
for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) {
int level = (int32_t)((*src & (0xF0>>i)) << (24+i)) >> shift[n];
int pred = s2[-1*avctx->channels] * coeff[0][n]
+ s2[-2*avctx->channels] * coeff[1][n];
s2[0] = av_clip_int16((level + pred + 0x80) >> 8);
}
}
}
}
samples += 32*4*avctx->channels;
break;
case CODEC_ID_ADPCM_IMA_AMV:
case CODEC_ID_ADPCM_IMA_SMJPEG:
c->status[0].predictor = (int16_t)bytestream_get_le16(&src);
c->status[0].step_index = bytestream_get_le16(&src);
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
src+=4;
while (src < buf + buf_size) {
char hi, lo;
lo = *src & 0x0F;
hi = *src >> 4;
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
FFSWAP(char, hi, lo);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
lo, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
hi, 3);
src++;
}
break;
case CODEC_ID_ADPCM_CT:
while (src < buf + buf_size) {
uint8_t v = *src++;
*samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 );
*samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F);
}
break;
case CODEC_ID_ADPCM_SBPRO_4:
case CODEC_ID_ADPCM_SBPRO_3:
case CODEC_ID_ADPCM_SBPRO_2:
if (!c->status[0].step_index) {
/* the first byte is a raw sample */
*samples++ = 128 * (*src++ - 0x80);
if (st)
*samples++ = 128 * (*src++ - 0x80);
c->status[0].step_index = 1;
}
if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) {
while (src < buf + buf_size) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
src[0] >> 4, 4, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
src[0] & 0x0F, 4, 0);
src++;
}
} else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
while (src < buf + buf_size && samples + 2 < samples_end) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
src[0] >> 5 , 3, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 2) & 0x07, 3, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
src[0] & 0x03, 2, 0);
src++;
}
} else {
while (src < buf + buf_size && samples + 3 < samples_end) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
src[0] >> 6 , 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
(src[0] >> 4) & 0x03, 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 2) & 0x03, 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
src[0] & 0x03, 2, 2);
src++;
}
}
break;
case CODEC_ID_ADPCM_SWF:
{
GetBitContext gb;
const int *table;
int k0, signmask, nb_bits, count;
int size = buf_size*8;
init_get_bits(&gb, buf, size);
//read bits & initial values
nb_bits = get_bits(&gb, 2)+2;
//av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits);
table = swf_index_tables[nb_bits-2];
k0 = 1 << (nb_bits-2);
signmask = 1 << (nb_bits-1);
while (get_bits_count(&gb) <= size - 22*avctx->channels) {
for (i = 0; i < avctx->channels; i++) {
*samples++ = c->status[i].predictor = get_sbits(&gb, 16);
c->status[i].step_index = get_bits(&gb, 6);
}
for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
int i;
for (i = 0; i < avctx->channels; i++) {
// similar to IMA adpcm
int delta = get_bits(&gb, nb_bits);
int step = ff_adpcm_step_table[c->status[i].step_index];
long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
int k = k0;
do {
if (delta & k)
vpdiff += step;
step >>= 1;
k >>= 1;
} while(k);
vpdiff += step;
if (delta & signmask)
c->status[i].predictor -= vpdiff;
else
c->status[i].predictor += vpdiff;
c->status[i].step_index += table[delta & (~signmask)];
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
c->status[i].predictor = av_clip_int16(c->status[i].predictor);
*samples++ = c->status[i].predictor;
if (samples >= samples_end) {
av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n");
return -1;
}
}
}
}
src += buf_size;
break;
}
case CODEC_ID_ADPCM_YAMAHA:
while (src < buf + buf_size) {
uint8_t v = *src++;
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F);
*samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
}
break;
case CODEC_ID_ADPCM_THP:
{
int table[2][16];
unsigned int samplecnt;
int prev[2][2];
int ch;
if (buf_size < 80) {
av_log(avctx, AV_LOG_ERROR, "frame too small\n");
return -1;
}
src+=4;
samplecnt = bytestream_get_be32(&src);
for (i = 0; i < 32; i++)
table[0][i] = (int16_t)bytestream_get_be16(&src);
/* Initialize the previous sample. */
for (i = 0; i < 4; i++)
prev[0][i] = (int16_t)bytestream_get_be16(&src);
if (samplecnt >= (samples_end - samples) / (st + 1)) {
av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n");
return -1;
}
for (ch = 0; ch <= st; ch++) {
samples = (unsigned short *) data + ch;
/* Read in every sample for this channel. */
for (i = 0; i < samplecnt / 14; i++) {
int index = (*src >> 4) & 7;
unsigned int exp = 28 - (*src++ & 15);
int factor1 = table[ch][index * 2];
int factor2 = table[ch][index * 2 + 1];
/* Decode 14 samples. */
for (n = 0; n < 14; n++) {
int32_t sampledat;
if(n&1) sampledat= *src++ <<28;
else sampledat= (*src&0xF0)<<24;
sampledat = ((prev[ch][0]*factor1
+ prev[ch][1]*factor2) >> 11) + (sampledat>>exp);
*samples = av_clip_int16(sampledat);
prev[ch][1] = prev[ch][0];
prev[ch][0] = *samples++;
/* In case of stereo, skip one sample, this sample
is for the other channel. */
samples += st;
}
}
}
/* In the previous loop, in case stereo is used, samples is
increased exactly one time too often. */
samples -= st;
break;
}
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25937 | static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size)
{
int res;
HuffContext huff;
HuffContext tmp1, tmp2;
VLC vlc[2] = { { 0 } };
int escapes[3];
DBCtx ctx;
int err = 0;
if(size >= UINT_MAX>>4){ // (((size + 3) >> 2) + 3) << 2 must not overflow
av_log(smk->avctx, AV_LOG_ERROR, "size too large\n");
return AVERROR_INVALIDDATA;
}
tmp1.length = 256;
tmp1.maxlength = 0;
tmp1.current = 0;
tmp1.bits = av_mallocz(256 * 4);
tmp1.lengths = av_mallocz(256 * sizeof(int));
tmp1.values = av_mallocz(256 * sizeof(int));
tmp2.length = 256;
tmp2.maxlength = 0;
tmp2.current = 0;
tmp2.bits = av_mallocz(256 * 4);
tmp2.lengths = av_mallocz(256 * sizeof(int));
tmp2.values = av_mallocz(256 * sizeof(int));
if(get_bits1(gb)) {
smacker_decode_tree(gb, &tmp1, 0, 0);
skip_bits1(gb);
if(tmp1.current > 1) {
res = init_vlc(&vlc[0], SMKTREE_BITS, tmp1.length,
tmp1.lengths, sizeof(int), sizeof(int),
tmp1.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
if(res < 0) {
av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
return AVERROR_INVALIDDATA;
}
}
}
if (!vlc[0].table) {
av_log(smk->avctx, AV_LOG_ERROR, "Skipping low bytes tree\n");
}
if(get_bits1(gb)){
smacker_decode_tree(gb, &tmp2, 0, 0);
skip_bits1(gb);
if(tmp2.current > 1) {
res = init_vlc(&vlc[1], SMKTREE_BITS, tmp2.length,
tmp2.lengths, sizeof(int), sizeof(int),
tmp2.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
if(res < 0) {
av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
return AVERROR_INVALIDDATA;
}
}
}
if (!vlc[1].table) {
av_log(smk->avctx, AV_LOG_ERROR, "Skipping high bytes tree\n");
}
escapes[0] = get_bits(gb, 16);
escapes[1] = get_bits(gb, 16);
escapes[2] = get_bits(gb, 16);
last[0] = last[1] = last[2] = -1;
ctx.escapes[0] = escapes[0];
ctx.escapes[1] = escapes[1];
ctx.escapes[2] = escapes[2];
ctx.v1 = &vlc[0];
ctx.v2 = &vlc[1];
ctx.recode1 = tmp1.values;
ctx.recode2 = tmp2.values;
ctx.last = last;
huff.length = ((size + 3) >> 2) + 3;
huff.maxlength = 0;
huff.current = 0;
huff.values = av_mallocz(huff.length * sizeof(int));
if (smacker_decode_bigtree(gb, &huff, &ctx) < 0)
err = -1;
skip_bits1(gb);
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
if(huff.current > huff.length){
ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
return AVERROR_INVALIDDATA;
}
*recodes = huff.values;
if(vlc[0].table)
ff_free_vlc(&vlc[0]);
if(vlc[1].table)
ff_free_vlc(&vlc[1]);
av_free(tmp1.bits);
av_free(tmp1.lengths);
av_free(tmp1.values);
av_free(tmp2.bits);
av_free(tmp2.lengths);
av_free(tmp2.values);
return err;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25947 | static int standard_decode_picture_primary_header(VC9Context *v)
{
GetBitContext *gb = &v->s.gb;
int status = 0;
if (v->finterpflag) v->interpfrm = get_bits(gb, 1);
skip_bits(gb, 2); //framecnt unused
if (v->rangered) v->rangeredfrm = get_bits(gb, 1);
v->s.pict_type = get_bits(gb, 1);
if (v->s.avctx->max_b_frames)
{
if (!v->s.pict_type)
{
if (get_bits(gb, 1)) v->s.pict_type = I_TYPE;
else v->s.pict_type = B_TYPE;
}
else v->s.pict_type = P_TYPE;
}
else v->s.pict_type++;
switch (v->s.pict_type)
{
case I_TYPE: status = decode_i_picture_header(v); break;
case P_TYPE: status = decode_p_picture_primary_header(v); break;
case BI_TYPE:
case B_TYPE: status = decode_b_picture_primary_header(v); break;
}
if (status == FRAME_SKIPED)
{
av_log(v->s.avctx, AV_LOG_INFO, "Skipping frame...\n");
return status;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_25948 | static FFServerIPAddressACL* parse_dynamic_acl(FFServerStream *stream, HTTPContext *c)
{
FILE* f;
char line[1024];
char cmd[1024];
FFServerIPAddressACL *acl = NULL;
int line_num = 0;
const char *p;
f = fopen(stream->dynamic_acl, "r");
if (!f) {
perror(stream->dynamic_acl);
return NULL;
}
acl = av_mallocz(sizeof(FFServerIPAddressACL));
/* Build ACL */
for(;;) {
if (fgets(line, sizeof(line), f) == NULL)
break;
line_num++;
p = line;
while (av_isspace(*p))
p++;
if (*p == '\0' || *p == '#')
continue;
ffserver_get_arg(cmd, sizeof(cmd), &p);
if (!av_strcasecmp(cmd, "ACL"))
ffserver_parse_acl_row(NULL, NULL, acl, p, stream->dynamic_acl, line_num);
}
fclose(f);
return acl;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25958 | static int discard_f(BlockBackend *blk, int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, qflag = 0;
int c, ret;
int64_t offset, count;
while ((c = getopt(argc, argv, "Cq")) != -1) {
switch (c) {
case 'C':
Cflag = 1;
break;
case 'q':
qflag = 1;
break;
default:
return qemuio_command_usage(&discard_cmd);
}
}
if (optind != argc - 2) {
return qemuio_command_usage(&discard_cmd);
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
print_cvtnum_err(offset, argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
print_cvtnum_err(count, argv[optind]);
return 0;
} else if (count >> BDRV_SECTOR_BITS > INT_MAX) {
printf("length cannot exceed %"PRIu64", given %s\n",
(uint64_t)INT_MAX << BDRV_SECTOR_BITS,
argv[optind]);
return 0;
}
gettimeofday(&t1, NULL);
ret = blk_discard(blk, offset >> BDRV_SECTOR_BITS,
count >> BDRV_SECTOR_BITS);
gettimeofday(&t2, NULL);
if (ret < 0) {
printf("discard failed: %s\n", strerror(-ret));
goto out;
}
/* Finally, report back -- -C gives a parsable format */
if (!qflag) {
t2 = tsub(t2, t1);
print_report("discard", &t2, offset, count, count, 1, Cflag);
}
out:
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_25997 | void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr,
hwaddr size)
{
assert(mr->terminates);
cpu_physical_memory_set_dirty_range(mr->ram_addr + addr, size,
memory_region_get_dirty_log_mask(mr));
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_26003 | static void vnc_display_print_local_addr(VncDisplay *vd)
{
SocketAddressLegacy *addr;
Error *err = NULL;
if (!vd->nlsock) {
return;
}
addr = qio_channel_socket_get_local_address(vd->lsock[0], &err);
if (!addr) {
return;
}
if (addr->type != SOCKET_ADDRESS_LEGACY_KIND_INET) {
qapi_free_SocketAddressLegacy(addr);
return;
}
error_printf_unless_qmp("VNC server running on %s:%s\n",
addr->u.inet.data->host,
addr->u.inet.data->port);
qapi_free_SocketAddressLegacy(addr);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_26008 | static int v9fs_synth_lstat(FsContext *fs_ctx,
V9fsPath *fs_path, struct stat *stbuf)
{
V9fsSynthNode *node = *(V9fsSynthNode **)fs_path->data;
v9fs_synth_fill_statbuf(node, stbuf);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_26030 | static av_cold int qsv_decode_close(AVCodecContext *avctx)
{
QSVOtherContext *s = avctx->priv_data;
ff_qsv_decode_close(&s->qsv);
qsv_clear_buffers(s);
av_fifo_free(s->packet_fifo);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_26031 | int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,
const char *buf)
{
const char *text = NULL;
char new_line[2];
int text_len = 0;
while (*buf) {
if (text && callbacks->text &&
(sscanf(buf, "\\%1[nN]", new_line) == 1 ||
!strncmp(buf, "{\\", 2))) {
callbacks->text(priv, text, text_len);
text = NULL;
}
if (sscanf(buf, "\\%1[nN]", new_line) == 1) {
if (callbacks->new_line)
callbacks->new_line(priv, new_line[0] == 'N');
buf += 2;
} else if (!strncmp(buf, "{\\", 2)) {
buf++;
while (*buf == '\\') {
char style[2], c[2], sep[2], c_num[2] = "0", tmp[128] = {0};
unsigned int color = 0xFFFFFFFF;
int len, size = -1, an = -1, alpha = -1;
int x1, y1, x2, y2, t1 = -1, t2 = -1;
if (sscanf(buf, "\\%1[bisu]%1[01\\}]%n", style, c, &len) > 1) {
int close = c[0] == '0' ? 1 : c[0] == '1' ? 0 : -1;
len += close != -1;
if (callbacks->style)
callbacks->style(priv, style[0], close);
} else if (sscanf(buf, "\\c%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\c&H%X&%1[\\}]%n", &color, sep, &len) > 1 ||
sscanf(buf, "\\%1[1234]c%1[\\}]%n", c_num, sep, &len) > 1 ||
sscanf(buf, "\\%1[1234]c&H%X&%1[\\}]%n", c_num, &color, sep, &len) > 2) {
if (callbacks->color)
callbacks->color(priv, color, c_num[0] - '0');
} else if (sscanf(buf, "\\alpha%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\alpha&H%2X&%1[\\}]%n", &alpha, sep, &len) > 1 ||
sscanf(buf, "\\%1[1234]a%1[\\}]%n", c_num, sep, &len) > 1 ||
sscanf(buf, "\\%1[1234]a&H%2X&%1[\\}]%n", c_num, &alpha, sep, &len) > 2) {
if (callbacks->alpha)
callbacks->alpha(priv, alpha, c_num[0] - '0');
} else if (sscanf(buf, "\\fn%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\fn%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) {
if (callbacks->font_name)
callbacks->font_name(priv, tmp[0] ? tmp : NULL);
} else if (sscanf(buf, "\\fs%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\fs%u%1[\\}]%n", &size, sep, &len) > 1) {
if (callbacks->font_size)
callbacks->font_size(priv, size);
} else if (sscanf(buf, "\\a%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\a%2u%1[\\}]%n", &an, sep, &len) > 1 ||
sscanf(buf, "\\an%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\an%1u%1[\\}]%n", &an, sep, &len) > 1) {
if (an != -1 && buf[2] != 'n')
an = (an&3) + (an&4 ? 6 : an&8 ? 3 : 0);
if (callbacks->alignment)
callbacks->alignment(priv, an);
} else if (sscanf(buf, "\\r%1[\\}]%n", sep, &len) > 0 ||
sscanf(buf, "\\r%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) {
if (callbacks->cancel_overrides)
callbacks->cancel_overrides(priv, tmp);
} else if (sscanf(buf, "\\move(%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, sep, &len) > 4 ||
sscanf(buf, "\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, &t1, &t2, sep, &len) > 6) {
if (callbacks->move)
callbacks->move(priv, x1, y1, x2, y2, t1, t2);
} else if (sscanf(buf, "\\pos(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {
if (callbacks->move)
callbacks->move(priv, x1, y1, x1, y1, -1, -1);
} else if (sscanf(buf, "\\org(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {
if (callbacks->origin)
callbacks->origin(priv, x1, y1);
} else {
len = strcspn(buf+1, "\\}") + 2; /* skip unknown code */
}
buf += len - 1;
}
if (*buf++ != '}')
return AVERROR_INVALIDDATA;
} else {
if (!text) {
text = buf;
text_len = 1;
} else
text_len++;
buf++;
}
}
if (text && callbacks->text)
callbacks->text(priv, text, text_len);
if (callbacks->end)
callbacks->end(priv);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_26038 | static void compute_scale_factors(unsigned char scale_code[SBLIMIT],
unsigned char scale_factors[SBLIMIT][3],
int sb_samples[3][12][SBLIMIT],
int sblimit)
{
int *p, vmax, v, n, i, j, k, code;
int index, d1, d2;
unsigned char *sf = &scale_factors[0][0];
for(j=0;j<sblimit;j++) {
for(i=0;i<3;i++) {
/* find the max absolute value */
p = &sb_samples[i][0][j];
vmax = abs(*p);
for(k=1;k<12;k++) {
p += SBLIMIT;
v = abs(*p);
if (v > vmax)
vmax = v;
}
/* compute the scale factor index using log 2 computations */
if (vmax > 0) {
n = av_log2(vmax);
/* n is the position of the MSB of vmax. now
use at most 2 compares to find the index */
index = (21 - n) * 3 - 3;
if (index >= 0) {
while (vmax <= scale_factor_table[index+1])
index++;
} else {
index = 0; /* very unlikely case of overflow */
}
} else {
index = 62; /* value 63 is not allowed */
}
#if 0
printf("%2d:%d in=%x %x %d\n",
j, i, vmax, scale_factor_table[index], index);
#endif
/* store the scale factor */
assert(index >=0 && index <= 63);
sf[i] = index;
}
/* compute the transmission factor : look if the scale factors
are close enough to each other */
d1 = scale_diff_table[sf[0] - sf[1] + 64];
d2 = scale_diff_table[sf[1] - sf[2] + 64];
/* handle the 25 cases */
switch(d1 * 5 + d2) {
case 0*5+0:
case 0*5+4:
case 3*5+4:
case 4*5+0:
case 4*5+4:
code = 0;
break;
case 0*5+1:
case 0*5+2:
case 4*5+1:
case 4*5+2:
code = 3;
sf[2] = sf[1];
break;
case 0*5+3:
case 4*5+3:
code = 3;
sf[1] = sf[2];
break;
case 1*5+0:
case 1*5+4:
case 2*5+4:
code = 1;
sf[1] = sf[0];
break;
case 1*5+1:
case 1*5+2:
case 2*5+0:
case 2*5+1:
case 2*5+2:
code = 2;
sf[1] = sf[2] = sf[0];
break;
case 2*5+3:
case 3*5+3:
code = 2;
sf[0] = sf[1] = sf[2];
break;
case 3*5+0:
case 3*5+1:
case 3*5+2:
code = 2;
sf[0] = sf[2] = sf[1];
break;
case 1*5+3:
code = 2;
if (sf[0] > sf[2])
sf[0] = sf[2];
sf[1] = sf[2] = sf[0];
break;
default:
assert(0); //cannot happen
code = 0; /* kill warning */
}
#if 0
printf("%d: %2d %2d %2d %d %d -> %d\n", j,
sf[0], sf[1], sf[2], d1, d2, code);
#endif
scale_code[j] = code;
sf += 3;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_26059 | static void armv7m_nvic_clear_pending(void *opaque, int irq)
{
NVICState *s = (NVICState *)opaque;
VecInfo *vec;
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
vec = &s->vectors[irq];
trace_nvic_clear_pending(irq, vec->enabled, vec->prio);
if (vec->pending) {
vec->pending = 0;
nvic_irq_update(s);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_26061 | static void vararg_string(void)
{
int i;
struct {
const char *decoded;
} test_cases[] = {
{ "hello world" },
{ "the quick brown fox jumped over the fence" },
{}
};
for (i = 0; test_cases[i].decoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_jsonf("%s", test_cases[i].decoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_26069 | static int scsi_qdev_exit(DeviceState *qdev)
{
SCSIDevice *dev = SCSI_DEVICE(qdev);
if (dev->vmsentry) {
qemu_del_vm_change_state_handler(dev->vmsentry);
}
scsi_device_destroy(dev);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_26075 | static int gen_sub_bitmap(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
{
int resx = page->columns * BITMAP_CHAR_WIDTH;
int resy = (page->rows - chop_top) * BITMAP_CHAR_HEIGHT;
uint8_t ci, cmax = 0;
int ret;
vbi_char *vc = page->text + (chop_top * page->columns);
vbi_char *vcend = page->text + (page->rows * page->columns);
for (; vc < vcend; vc++) {
if (vc->opacity != VBI_TRANSPARENT_SPACE) {
cmax = VBI_NB_COLORS;
break;
}
}
if (cmax == 0) {
av_log(ctx, AV_LOG_DEBUG, "dropping empty page %3x\n", page->pgno);
sub_rect->type = SUBTITLE_NONE;
return 0;
}
if ((ret = avpicture_alloc(&sub_rect->pict, AV_PIX_FMT_PAL8, resx, resy)) < 0)
return ret;
// Yes, we want to allocate the palette on our own because AVSubtitle works this way
sub_rect->pict.data[1] = NULL;
vbi_draw_vt_page_region(page, VBI_PIXFMT_PAL8,
sub_rect->pict.data[0], sub_rect->pict.linesize[0],
0, chop_top, page->columns, page->rows - chop_top,
/*reveal*/ 1, /*flash*/ 1);
fix_transparency(ctx, sub_rect, page, chop_top, cmax, resx, resy);
sub_rect->x = ctx->x_offset;
sub_rect->y = ctx->y_offset + chop_top * BITMAP_CHAR_HEIGHT;
sub_rect->w = resx;
sub_rect->h = resy;
sub_rect->nb_colors = (int)cmax + 1;
sub_rect->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
if (!sub_rect->pict.data[1]) {
av_freep(&sub_rect->pict.data[0]);
return AVERROR(ENOMEM);
}
for (ci = 0; ci < cmax; ci++) {
int r, g, b, a;
r = VBI_R(page->color_map[ci]);
g = VBI_G(page->color_map[ci]);
b = VBI_B(page->color_map[ci]);
a = VBI_A(page->color_map[ci]);
((uint32_t *)sub_rect->pict.data[1])[ci] = RGBA(r, g, b, a);
av_dlog(ctx, "palette %0x\n", ((uint32_t *)sub_rect->pict.data[1])[ci]);
}
((uint32_t *)sub_rect->pict.data[1])[cmax] = RGBA(0, 0, 0, 0);
sub_rect->type = SUBTITLE_BITMAP;
return 0;
}
The vulnerability label is: Non-vulnerable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.