diff --git "a/devign/alpaca/devign_0-512_test.json" "b/devign/alpaca/devign_0-512_test.json" new file mode 100644--- /dev/null +++ "b/devign/alpaca/devign_0-512_test.json" @@ -0,0 +1,11540 @@ +[ + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void downmix_3f_to_mono(float *samples)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < 256; i++) {\n\n samples[i] += (samples[i + 256] + samples[i + 512]);\n\n samples[i + 256] = samples[i + 512] = 0;\n\n }\n\n}\n", + "output": "0", + "index": 3086 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void memory_region_init_alias(MemoryRegion *mr,\n\n Object *owner,\n\n const char *name,\n\n MemoryRegion *orig,\n\n hwaddr offset,\n\n uint64_t size)\n\n{\n\n memory_region_init(mr, owner, name, size);\n\n memory_region_ref(orig);\n\n mr->destructor = memory_region_destructor_alias;\n\n mr->alias = orig;\n\n mr->alias_offset = offset;\n\n}\n", + "output": "1", + "index": 8035 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t ga_get_fd_handle(GAState *s, Error **errp)\n\n{\n\n int64_t handle;\n\n\n\n g_assert(s->pstate_filepath);\n\n /* we blacklist commands and avoid operations that potentially require\n\n * writing to disk when we're in a frozen state. this includes opening\n\n * new files, so we should never get here in that situation\n\n */\n\n g_assert(!ga_is_frozen(s));\n\n\n\n handle = s->pstate.fd_counter++;\n\n if (s->pstate.fd_counter < 0) {\n\n s->pstate.fd_counter = 0;\n\n }\n\n if (!write_persistent_state(&s->pstate, s->pstate_filepath)) {\n\n error_setg(errp, \"failed to commit persistent state to disk\");\n\n }\n\n\n\n return handle;\n\n}\n", + "output": "1", + "index": 11384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "long do_sigreturn(CPUCRISState *env)\n\n{\n\n\tstruct target_signal_frame *frame;\n\n\tabi_ulong frame_addr;\n\n\ttarget_sigset_t target_set;\n\n\tsigset_t set;\n\n\tint i;\n\n\n\n\tframe_addr = env->regs[R_SP];\n\n\t/* Make sure the guest isn't playing games. */\n\n\tif (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))\n\n\t\tgoto badframe;\n\n\n\n\t/* Restore blocked signals */\n\n\tif (__get_user(target_set.sig[0], &frame->sc.oldmask))\n\n\t\tgoto badframe;\n\n\tfor(i = 1; i < TARGET_NSIG_WORDS; i++) {\n\n\t\tif (__get_user(target_set.sig[i], &frame->extramask[i - 1]))\n\n\t\t\tgoto badframe;\n\n\t}\n\n\ttarget_to_host_sigset_internal(&set, &target_set);\n\n do_sigprocmask(SIG_SETMASK, &set, NULL);\n\n\n\n\trestore_sigcontext(&frame->sc, env);\n\n\tunlock_user_struct(frame, frame_addr, 0);\n\n\treturn env->regs[10];\n\n badframe:\n\n\tunlock_user_struct(frame, frame_addr, 0);\n\n\tforce_sig(TARGET_SIGSEGV);\n\n}\n", + "output": "1", + "index": 9721 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_ringbuf(const char *id,\n\n ChardevBackend *backend,\n\n ChardevReturn *ret,\n\n Error **errp)\n\n{\n\n ChardevRingbuf *opts = backend->u.ringbuf;\n\n CharDriverState *chr;\n\n RingBufCharDriver *d;\n\n\n\n chr = qemu_chr_alloc();\n\n d = g_malloc(sizeof(*d));\n\n\n\n d->size = opts->has_size ? opts->size : 65536;\n\n\n\n /* The size must be power of 2 */\n\n if (d->size & (d->size - 1)) {\n\n error_setg(errp, \"size of ringbuf chardev must be power of two\");\n\n goto fail;\n\n }\n\n\n\n d->prod = 0;\n\n d->cons = 0;\n\n d->cbuf = g_malloc0(d->size);\n\n\n\n chr->opaque = d;\n\n chr->chr_write = ringbuf_chr_write;\n\n chr->chr_close = ringbuf_chr_close;\n\n\n\n return chr;\n\n\n\nfail:\n\n g_free(d);\n\n g_free(chr);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 21485 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)\n\n{\n\n assert(dev->nirqs < ARRAY_SIZE(dev->isairq));\n\n if (isabus->assigned & (1 << isairq)) {\n\n hw_error(\"isa irq %d already assigned\", isairq);\n\n }\n\n isabus->assigned |= (1 << isairq);\n\n dev->isairq[dev->nirqs] = isairq;\n\n *p = isabus->irqs[isairq];\n\n dev->nirqs++;\n\n}\n", + "output": "0", + "index": 19185 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blkverify_open(BlockDriverState *bs, const char *filename, int flags)\n\n{\n\n BDRVBlkverifyState *s = bs->opaque;\n\n int ret;\n\n char *raw, *c;\n\n\n\n /* Parse the blkverify: prefix */\n\n if (strncmp(filename, \"blkverify:\", strlen(\"blkverify:\"))) {\n\n return -EINVAL;\n\n }\n\n filename += strlen(\"blkverify:\");\n\n\n\n /* Parse the raw image filename */\n\n c = strchr(filename, ':');\n\n if (c == NULL) {\n\n return -EINVAL;\n\n }\n\n\n\n raw = strdup(filename);\n\n raw[c - filename] = '\\0';\n\n ret = bdrv_file_open(&bs->file, raw, flags);\n\n free(raw);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n filename = c + 1;\n\n\n\n /* Open the test file */\n\n s->test_file = bdrv_new(\"\");\n\n ret = bdrv_open(s->test_file, filename, flags, NULL);\n\n if (ret < 0) {\n\n bdrv_delete(s->test_file);\n\n s->test_file = NULL;\n\n return ret;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 23851 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CPUX86State *cpu_x86_init(void)\n\n{\n\n CPUX86State *env;\n\n int i;\n\n static int inited;\n\n\n\n cpu_x86_tblocks_init();\n\n\n\n env = malloc(sizeof(CPUX86State));\n\n if (!env)\n\n return NULL;\n\n memset(env, 0, sizeof(CPUX86State));\n\n /* basic FPU init */\n\n for(i = 0;i < 8; i++)\n\n env->fptags[i] = 1;\n\n env->fpuc = 0x37f;\n\n /* flags setup */\n\n env->eflags = 0;\n\n\n\n /* init various static tables */\n\n if (!inited) {\n\n inited = 1;\n\n optimize_flags_init();\n\n }\n\n return env;\n\n}\n", + "output": "0", + "index": 12645 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct omap_mpu_timer_s *omap_mpu_timer_init(MemoryRegion *system_memory,\n\n target_phys_addr_t base,\n\n qemu_irq irq, omap_clk clk)\n\n{\n\n struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)\n\n g_malloc0(sizeof(struct omap_mpu_timer_s));\n\n\n\n s->irq = irq;\n\n s->clk = clk;\n\n s->timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, s);\n\n s->tick = qemu_bh_new(omap_timer_fire, s);\n\n omap_mpu_timer_reset(s);\n\n omap_timer_clk_setup(s);\n\n\n\n memory_region_init_io(&s->iomem, &omap_mpu_timer_ops, s,\n\n \"omap-mpu-timer\", 0x100);\n\n\n\n memory_region_add_subregion(system_memory, base, &s->iomem);\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 22340 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap1_mpu_reset(void *opaque)\n\n{\n\n struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;\n\n\n\n omap_inth_reset(mpu->ih[0]);\n\n omap_inth_reset(mpu->ih[1]);\n\n omap_dma_reset(mpu->dma);\n\n omap_mpu_timer_reset(mpu->timer[0]);\n\n omap_mpu_timer_reset(mpu->timer[1]);\n\n omap_mpu_timer_reset(mpu->timer[2]);\n\n omap_wd_timer_reset(mpu->wdt);\n\n omap_os_timer_reset(mpu->os_timer);\n\n omap_lcdc_reset(mpu->lcd);\n\n omap_ulpd_pm_reset(mpu);\n\n omap_pin_cfg_reset(mpu);\n\n omap_mpui_reset(mpu);\n\n omap_tipb_bridge_reset(mpu->private_tipb);\n\n omap_tipb_bridge_reset(mpu->public_tipb);\n\n omap_dpll_reset(&mpu->dpll[0]);\n\n omap_dpll_reset(&mpu->dpll[1]);\n\n omap_dpll_reset(&mpu->dpll[2]);\n\n omap_uart_reset(mpu->uart[0]);\n\n omap_uart_reset(mpu->uart[1]);\n\n omap_uart_reset(mpu->uart[2]);\n\n omap_mmc_reset(mpu->mmc);\n\n omap_mpuio_reset(mpu->mpuio);\n\n omap_uwire_reset(mpu->microwire);\n\n omap_pwl_reset(mpu);\n\n omap_pwt_reset(mpu);\n\n omap_i2c_reset(mpu->i2c[0]);\n\n omap_rtc_reset(mpu->rtc);\n\n omap_mcbsp_reset(mpu->mcbsp1);\n\n omap_mcbsp_reset(mpu->mcbsp2);\n\n omap_mcbsp_reset(mpu->mcbsp3);\n\n omap_lpg_reset(mpu->led[0]);\n\n omap_lpg_reset(mpu->led[1]);\n\n omap_clkm_reset(mpu);\n\n cpu_reset(mpu->env);\n\n}\n", + "output": "0", + "index": 4441 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void colo_do_failover(MigrationState *s)\n\n{\n\n /* Make sure VM stopped while failover happened. */\n\n if (!colo_runstate_is_stopped()) {\n\n vm_stop_force_state(RUN_STATE_COLO);\n\n }\n\n\n\n if (get_colo_mode() == COLO_MODE_PRIMARY) {\n\n primary_vm_do_failover();\n\n\n\n }\n\n}", + "output": "1", + "index": 14033 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MigrationState *unix_start_outgoing_migration(Monitor *mon,\n\n const char *path,\n\n\t\t\t\t\t int64_t bandwidth_limit,\n\n\t\t\t\t\t int detach,\n\n\t\t\t\t\t int blk,\n\n\t\t\t\t\t int inc)\n\n{\n\n FdMigrationState *s;\n\n struct sockaddr_un addr;\n\n int ret;\n\n\n\n addr.sun_family = AF_UNIX;\n\n snprintf(addr.sun_path, sizeof(addr.sun_path), \"%s\", path);\n\n\n\n s = qemu_mallocz(sizeof(*s));\n\n\n\n s->get_error = unix_errno;\n\n s->write = unix_write;\n\n s->close = unix_close;\n\n s->mig_state.cancel = migrate_fd_cancel;\n\n s->mig_state.get_status = migrate_fd_get_status;\n\n s->mig_state.release = migrate_fd_release;\n\n\n\n s->mig_state.blk = blk;\n\n s->mig_state.shared = inc;\n\n\n\n s->state = MIG_STATE_ACTIVE;\n\n s->mon = NULL;\n\n s->bandwidth_limit = bandwidth_limit;\n\n s->fd = socket(PF_UNIX, SOCK_STREAM, 0);\n\n if (s->fd < 0) {\n\n dprintf(\"Unable to open socket\");\n\n goto err_after_alloc;\n\n }\n\n\n\n socket_set_nonblock(s->fd);\n\n\n\n if (!detach) {\n\n migrate_fd_monitor_suspend(s, mon);\n\n }\n\n\n\n do {\n\n ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));\n\n if (ret == -1)\n\n\t ret = -(s->get_error(s));\n\n\n\n if (ret == -EINPROGRESS || ret == -EWOULDBLOCK)\n\n\t qemu_set_fd_handler2(s->fd, NULL, NULL, unix_wait_for_connect, s);\n\n } while (ret == -EINTR);\n\n\n\n if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {\n\n dprintf(\"connect failed\\n\");\n\n goto err_after_open;\n\n } else if (ret >= 0)\n\n migrate_fd_connect(s);\n\n\n\n return &s->mig_state;\n\n\n\nerr_after_open:\n\n close(s->fd);\n\n\n\nerr_after_alloc:\n\n qemu_free(s);\n\n return NULL;\n\n}\n", + "output": "1", + "index": 6665 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs,\n\n int64_t offset, int count)\n\n{\n\n int ret;\n\n BDRVQcow2State *s = bs->opaque;\n\n\n\n if (!QEMU_IS_ALIGNED(offset | count, s->cluster_size)) {\n\n assert(count < s->cluster_size);\n\n /* Ignore partial clusters, except for the special case of the\n\n * complete partial cluster at the end of an unaligned file */\n\n if (!QEMU_IS_ALIGNED(offset, s->cluster_size) ||\n\n offset + count != bs->total_sectors * BDRV_SECTOR_SIZE) {\n\n return -ENOTSUP;\n\n }\n\n }\n\n\n\n qemu_co_mutex_lock(&s->lock);\n\n ret = qcow2_discard_clusters(bs, offset, count >> BDRV_SECTOR_BITS,\n\n QCOW2_DISCARD_REQUEST, false);\n\n qemu_co_mutex_unlock(&s->lock);\n\n return ret;\n\n}\n", + "output": "0", + "index": 3051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)\n\n\n\n/**\n\n * monitor_protocol_event(): Generate a Monitor event\n\n *\n\n * Event-specific data can be emitted through the (optional) 'data' parameter.\n\n */\n\nvoid monitor_protocol_event(MonitorEvent event, QObject *data)\n\n{\n\n QDict *qmp;\n\n const char *event_name;\n\n Monitor *mon;\n\n\n\n assert(event < QEVENT_MAX);\n\n\n\n event_name = monitor_event_names[event];\n\n assert(event_name != NULL);\n\n\n\n qmp = qdict_new();\n\n timestamp_put(qmp);\n\n qdict_put(qmp, \"event\", qstring_from_str(event_name));\n\n if (data) {\n\n qobject_incref(data);\n\n qdict_put_obj(qmp, \"data\", data);\n\n }\n\n\n\n QLIST_FOREACH(mon, &mon_list, entry) {\n\n if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {\n\n monitor_json_emitter(mon, QOBJECT(qmp));\n\n }\n\n }\n\n QDECREF(qmp);\n\n}\n", + "output": "1", + "index": 19019 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_chr_fe_read_all(CharDriverState *s, uint8_t *buf, int len)\n\n{\n\n int offset = 0, counter = 10;\n\n int res;\n\n\n\n if (!s->chr_sync_read) {\n\n return 0;\n\n }\n\n \n\n if (s->replay && replay_mode == REPLAY_MODE_PLAY) {\n\n return replay_char_read_all_load(buf);\n\n }\n\n\n\n while (offset < len) {\n\n do {\n\n res = s->chr_sync_read(s, buf + offset, len - offset);\n\n if (res == -1 && errno == EAGAIN) {\n\n g_usleep(100);\n\n }\n\n } while (res == -1 && errno == EAGAIN);\n\n\n\n if (res == 0) {\n\n break;\n\n }\n\n\n\n if (res < 0) {\n\n if (s->replay && replay_mode == REPLAY_MODE_RECORD) {\n\n replay_char_read_all_save_error(res);\n\n }\n\n return res;\n\n }\n\n\n\n offset += res;\n\n\n\n if (!counter--) {\n\n break;\n\n }\n\n }\n\n\n\n if (s->replay && replay_mode == REPLAY_MODE_RECORD) {\n\n replay_char_read_all_save_buf(buf, offset);\n\n }\n\n return offset;\n\n}\n", + "output": "1", + "index": 7125 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int hpel_motion(MpegEncContext *s,\n\n uint8_t *dest, uint8_t *src,\n\n int src_x, int src_y,\n\n op_pixels_func *pix_op,\n\n int motion_x, int motion_y)\n\n{\n\n int dxy = 0;\n\n int emu = 0;\n\n\n\n src_x += motion_x >> 1;\n\n src_y += motion_y >> 1;\n\n\n\n /* WARNING: do no forget half pels */\n\n src_x = av_clip(src_x, -16, s->width); // FIXME unneeded for emu?\n\n if (src_x != s->width)\n\n dxy |= motion_x & 1;\n\n src_y = av_clip(src_y, -16, s->height);\n\n if (src_y != s->height)\n\n dxy |= (motion_y & 1) << 1;\n\n src += src_y * s->linesize + src_x;\n\n\n\n if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) ||\n\n (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) {\n\n s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src,\n\n s->linesize, s->linesize,\n\n 9, 9,\n\n src_x, src_y,\n\n s->h_edge_pos, s->v_edge_pos);\n\n src = s->edge_emu_buffer;\n\n emu = 1;\n\n }\n\n pix_op[dxy](dest, src, s->linesize, 8);\n\n return emu;\n\n}\n", + "output": "0", + "index": 27138 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size, uint8_t **data)\n\n{\n\n AVIOContext *pb = s->pb;\n\n int len;\n\n\n\n for(;;) {\n\n len = ffio_read_indirect(pb, buf, TS_PACKET_SIZE, data);\n\n if (len != TS_PACKET_SIZE)\n\n return len < 0 ? len : AVERROR_EOF;\n\n /* check packet sync byte */\n\n if ((*data)[0] != 0x47) {\n\n /* find a new packet start */\n\n avio_seek(pb, -TS_PACKET_SIZE, SEEK_CUR);\n\n if (mpegts_resync(s) < 0)\n\n return AVERROR(EAGAIN);\n\n else\n\n continue;\n\n } else {\n\n break;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 13316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void acpi_get_hotplug_info(AcpiMiscInfo *misc)\n\n{\n\n int i;\n\n PCIBus *bus = find_i440fx();\n\n\n\n if (!bus) {\n\n /* Only PIIX supports ACPI hotplug */\n\n memset(misc->slot_hotplug_enable, 0, sizeof misc->slot_hotplug_enable);\n\n return;\n\n }\n\n\n\n memset(misc->slot_hotplug_enable, 0xff,\n\n DIV_ROUND_UP(PCI_SLOT_MAX, BITS_PER_BYTE));\n\n\n\n for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {\n\n PCIDeviceClass *pc;\n\n PCIDevice *pdev = bus->devices[i];\n\n\n\n if (!pdev) {\n\n continue;\n\n }\n\n\n\n pc = PCI_DEVICE_GET_CLASS(pdev);\n\n\n\n if (pc->no_hotplug) {\n\n int slot = PCI_SLOT(i);\n\n\n\n clear_bit(slot, misc->slot_hotplug_enable);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 1247 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_update_timer(RTCState *s)\n\n{\n\n uint64_t next_update_time;\n\n uint64_t guest_nsec;\n\n int next_alarm_sec;\n\n\n\n /* From the data sheet: \"Holding the dividers in reset prevents\n\n * interrupts from operating, while setting the SET bit allows\"\n\n * them to occur. However, it will prevent an alarm interrupt\n\n * from occurring, because the time of day is not updated.\n\n */\n\n if ((s->cmos_data[RTC_REG_A] & 0x60) == 0x60) {\n\n timer_del(s->update_timer);\n\n return;\n\n }\n\n if ((s->cmos_data[RTC_REG_C] & REG_C_UF) &&\n\n (s->cmos_data[RTC_REG_B] & REG_B_SET)) {\n\n timer_del(s->update_timer);\n\n return;\n\n }\n\n if ((s->cmos_data[RTC_REG_C] & REG_C_UF) &&\n\n (s->cmos_data[RTC_REG_C] & REG_C_AF)) {\n\n timer_del(s->update_timer);\n\n return;\n\n }\n\n\n\n guest_nsec = get_guest_rtc_ns(s) % NANOSECONDS_PER_SECOND;\n\n /* if UF is clear, reprogram to next second */\n\n next_update_time = qemu_clock_get_ns(rtc_clock)\n\n + NANOSECONDS_PER_SECOND - guest_nsec;\n\n\n\n /* Compute time of next alarm. One second is already accounted\n\n * for in next_update_time.\n\n */\n\n next_alarm_sec = get_next_alarm(s);\n\n s->next_alarm_time = next_update_time +\n\n (next_alarm_sec - 1) * NANOSECONDS_PER_SECOND;\n\n\n\n if (s->cmos_data[RTC_REG_C] & REG_C_UF) {\n\n /* UF is set, but AF is clear. Program the timer to target\n\n * the alarm time. */\n\n next_update_time = s->next_alarm_time;\n\n }\n\n if (next_update_time != timer_expire_time_ns(s->update_timer)) {\n\n timer_mod(s->update_timer, next_update_time);\n\n }\n\n}\n", + "output": "0", + "index": 1974 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ThreadPool *aio_get_thread_pool(AioContext *ctx)\n\n{\n\n if (!ctx->thread_pool) {\n\n ctx->thread_pool = thread_pool_new(ctx);\n\n }\n\n return ctx->thread_pool;\n\n}\n", + "output": "0", + "index": 27057 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)\n\n{\n\n int rc;\n\n\n\n cmd->lba = -1;\n\n cmd->len = scsi_cdb_length(buf);\n\n\n\n switch (dev->type) {\n\n case TYPE_TAPE:\n\n rc = scsi_req_stream_xfer(cmd, dev, buf);\n\n break;\n\n case TYPE_MEDIUM_CHANGER:\n\n rc = scsi_req_medium_changer_xfer(cmd, dev, buf);\n\n break;\n\n default:\n\n rc = scsi_req_xfer(cmd, dev, buf);\n\n break;\n\n }\n\n\n\n if (rc != 0)\n\n return rc;\n\n\n\n memcpy(cmd->buf, buf, cmd->len);\n\n scsi_cmd_xfer_mode(cmd);\n\n cmd->lba = scsi_cmd_lba(cmd);\n\n return 0;\n\n}\n", + "output": "1", + "index": 17181 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_run_all_timers(void)\n\n{\n\n alarm_timer->pending = 0;\n\n\n\n /* rearm timer, if not periodic */\n\n if (alarm_timer->expired) {\n\n alarm_timer->expired = 0;\n\n qemu_rearm_alarm_timer(alarm_timer);\n\n }\n\n\n\n /* vm time timers */\n\n qemu_run_timers(vm_clock);\n\n qemu_run_timers(rt_clock);\n\n qemu_run_timers(host_clock);\n\n}\n", + "output": "0", + "index": 15434 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aio_read_f(int argc, char **argv)\n\n{\n\n int nr_iov, c;\n\n struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));\n\n\n\n while ((c = getopt(argc, argv, \"CP:qv\")) != EOF) {\n\n switch (c) {\n\n case 'C':\n\n ctx->Cflag = 1;\n\n break;\n\n case 'P':\n\n ctx->Pflag = 1;\n\n ctx->pattern = parse_pattern(optarg);\n\n if (ctx->pattern < 0) {\n\n free(ctx);\n\n return 0;\n\n }\n\n break;\n\n case 'q':\n\n ctx->qflag = 1;\n\n break;\n\n case 'v':\n\n ctx->vflag = 1;\n\n break;\n\n default:\n\n free(ctx);\n\n return command_usage(&aio_read_cmd);\n\n }\n\n }\n\n\n\n if (optind > argc - 2) {\n\n free(ctx);\n\n return command_usage(&aio_read_cmd);\n\n }\n\n\n\n ctx->offset = cvtnum(argv[optind]);\n\n if (ctx->offset < 0) {\n\n printf(\"non-numeric length argument -- %s\\n\", argv[optind]);\n\n free(ctx);\n\n return 0;\n\n }\n\n optind++;\n\n\n\n if (ctx->offset & 0x1ff) {\n\n printf(\"offset %\" PRId64 \" is not sector aligned\\n\",\n\n ctx->offset);\n\n free(ctx);\n\n return 0;\n\n }\n\n\n\n nr_iov = argc - optind;\n\n ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab);\n\n if (ctx->buf == NULL) {\n\n free(ctx);\n\n return 0;\n\n }\n\n\n\n gettimeofday(&ctx->t1, NULL);\n\n bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov,\n\n ctx->qiov.size >> 9, aio_read_done, ctx);\n\n return 0;\n\n}\n", + "output": "0", + "index": 1173 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_doz(DisasContext *ctx)\n\n{\n\n int l1 = gen_new_label();\n\n int l2 = gen_new_label();\n\n tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], l1);\n\n tcg_gen_sub_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);\n\n tcg_gen_br(l2);\n\n gen_set_label(l1);\n\n tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);\n\n gen_set_label(l2);\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);\n\n}\n", + "output": "0", + "index": 3355 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int load_image_targphys(const char *filename,\n\n\t\t\ttarget_phys_addr_t addr, int max_sz)\n\n{\n\n FILE *f;\n\n size_t got;\n\n\n\n f = fopen(filename, \"rb\");\n\n if (!f) return -1;\n\n\n\n got = fread_targphys(addr, max_sz, f);\n\n if (ferror(f)) { fclose(f); return -1; }\n\n fclose(f);\n\n\n\n return got;\n\n}\n", + "output": "0", + "index": 22277 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int opt_opencl_bench(void *optctx, const char *opt, const char *arg)\n\n{\n\n int i, j, nb_devices = 0, count = 0;\n\n int64_t score = 0;\n\n AVOpenCLDeviceList *device_list;\n\n AVOpenCLDeviceNode *device_node = NULL;\n\n OpenCLDeviceBenchmark *devices = NULL;\n\n cl_platform_id platform;\n\n\n\n av_opencl_get_device_list(&device_list);\n\n for (i = 0; i < device_list->platform_num; i++)\n\n nb_devices += device_list->platform_node[i]->device_num;\n\n if (!nb_devices) {\n\n av_log(NULL, AV_LOG_ERROR, \"No OpenCL device detected!\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) {\n\n av_log(NULL, AV_LOG_ERROR, \"Could not allocate buffer\\n\");\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n for (i = 0; i < device_list->platform_num; i++) {\n\n for (j = 0; j < device_list->platform_node[i]->device_num; j++) {\n\n device_node = device_list->platform_node[i]->device_node[j];\n\n platform = device_list->platform_node[i]->platform_id;\n\n score = av_opencl_benchmark(device_node, platform, run_opencl_bench);\n\n if (score > 0) {\n\n devices[count].platform_idx = i;\n\n devices[count].device_idx = j;\n\n devices[count].runtime = score;\n\n av_strlcpy(devices[count].device_name, device_node->device_name,\n\n sizeof(devices[count].device_name));\n\n count++;\n\n }\n\n }\n\n }\n\n qsort(devices, count, sizeof(OpenCLDeviceBenchmark), compare_ocl_device_desc);\n\n fprintf(stderr, \"platform_idx\\tdevice_idx\\tdevice_name\\truntime\\n\");\n\n for (i = 0; i < count; i++)\n\n fprintf(stdout, \"%d\\t%d\\t%s\\t%\"PRId64\"\\n\",\n\n devices[i].platform_idx, devices[i].device_idx,\n\n devices[i].device_name, devices[i].runtime);\n\n\n\n av_opencl_free_device_list(&device_list);\n\n av_free(devices);\n\n return 0;\n\n}\n", + "output": "1", + "index": 1452 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t cpu_ppc_load_decr (CPUState *env)\n\n{\n\n ppc_tb_t *tb_env = env->tb_env;\n\n uint32_t decr;\n\n\n\n decr = muldiv64(tb_env->decr_next - qemu_get_clock(vm_clock),\n\n tb_env->tb_freq, ticks_per_sec);\n\n#if defined(DEBUG_TB)\n\n printf(\"%s: 0x%08x\\n\", __func__, decr);\n\n#endif\n\n\n\n return decr;\n\n}\n", + "output": "0", + "index": 8269 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_hpeldsp_vp3_init_x86(HpelDSPContext *c, int cpu_flags, int flags)\n\n{\n\n if (EXTERNAL_AMD3DNOW(cpu_flags)) {\n\n if (flags & AV_CODEC_FLAG_BITEXACT) {\n\n c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow;\n\n c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow;\n\n }\n\n }\n\n\n\n if (EXTERNAL_MMXEXT(cpu_flags)) {\n\n if (flags & AV_CODEC_FLAG_BITEXACT) {\n\n c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;\n\n c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 27005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_hid_initfn(USBDevice *dev, int kind)\n\n{\n\n USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);\n\n\n\n usb_desc_init(dev);\n\n hid_init(&us->hid, kind, usb_hid_changed);\n\n\n\n /* Force poll routine to be run and grab input the first time. */\n\n us->changed = 1;\n\n return 0;\n\n}\n", + "output": "0", + "index": 4182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void opt_top_field_first(const char *arg)\n\n{\n\n top_field_first= atoi(arg);\n\n}\n", + "output": "0", + "index": 6451 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int slice_end(AVCodecContext *avctx, AVFrame *pict)\n\n{\n\n Mpeg1Context *s1 = avctx->priv_data;\n\n MpegEncContext *s = &s1->mpeg_enc_ctx;\n\n\n\n if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)\n\n return 0;\n\n\n\n if (s->avctx->hwaccel) {\n\n if (s->avctx->hwaccel->end_frame(s->avctx) < 0)\n\n av_log(avctx, AV_LOG_ERROR,\n\n \"hardware accelerator failed to decode picture\\n\");\n\n }\n\n\n\n#if FF_API_XVMC\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)\n\n ff_xvmc_field_end(s);\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif /* FF_API_XVMC */\n\n\n\n /* end of slice reached */\n\n if (/* s->mb_y << field_pic == s->mb_height && */ !s->first_field) {\n\n /* end of image */\n\n\n\n ff_er_frame_end(&s->er);\n\n\n\n ff_mpv_frame_end(s);\n\n\n\n if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {\n\n int ret = av_frame_ref(pict, s->current_picture_ptr->f);\n\n if (ret < 0)\n\n return ret;\n\n ff_print_debug_info(s, s->current_picture_ptr);\n\n } else {\n\n if (avctx->active_thread_type & FF_THREAD_FRAME)\n\n s->picture_number++;\n\n /* latency of 1 frame for I- and P-frames */\n\n /* XXX: use another variable than picture_number */\n\n if (s->last_picture_ptr != NULL) {\n\n int ret = av_frame_ref(pict, s->last_picture_ptr->f);\n\n if (ret < 0)\n\n return ret;\n\n ff_print_debug_info(s, s->last_picture_ptr);\n\n }\n\n }\n\n\n\n return 1;\n\n } else {\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 4199 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)\n\n{\n\n SerialState *s = opaque;\n\n\n\n if (s->tsr_retry <= 0) {\n\n if (s->fcr & UART_FCR_FE) {\n\n s->tsr = fifo8_is_full(&s->xmit_fifo) ?\n\n 0 : fifo8_pop(&s->xmit_fifo);\n\n if (!s->xmit_fifo.num) {\n\n s->lsr |= UART_LSR_THRE;\n\n }\n\n } else if ((s->lsr & UART_LSR_THRE)) {\n\n return FALSE;\n\n } else {\n\n s->tsr = s->thr;\n\n s->lsr |= UART_LSR_THRE;\n\n s->lsr &= ~UART_LSR_TEMT;\n\n }\n\n }\n\n\n\n if (s->mcr & UART_MCR_LOOP) {\n\n /* in loopback mode, say that we just received a char */\n\n serial_receive1(s, &s->tsr, 1);\n\n } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {\n\n if (s->tsr_retry >= 0 && s->tsr_retry < MAX_XMIT_RETRY &&\n\n qemu_chr_fe_add_watch(s->chr, G_IO_OUT, serial_xmit, s) > 0) {\n\n s->tsr_retry++;\n\n return FALSE;\n\n }\n\n s->tsr_retry = 0;\n\n } else {\n\n s->tsr_retry = 0;\n\n }\n\n\n\n s->last_xmit_ts = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);\n\n\n\n if (s->lsr & UART_LSR_THRE) {\n\n s->lsr |= UART_LSR_TEMT;\n\n s->thr_ipending = 1;\n\n serial_update_irq(s);\n\n }\n\n\n\n return FALSE;\n\n}\n", + "output": "0", + "index": 3836 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,\n\n qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk)\n\n{\n\n int iomemtype;\n\n struct omap_eac_s *s = (struct omap_eac_s *)\n\n qemu_mallocz(sizeof(struct omap_eac_s));\n\n\n\n s->irq = irq;\n\n s->codec.rxdrq = *drq ++;\n\n s->codec.txdrq = *drq;\n\n omap_eac_reset(s);\n\n\n\n#ifdef HAS_AUDIO\n\n AUD_register_card(\"OMAP EAC\", &s->codec.card);\n\n\n\n iomemtype = cpu_register_io_memory(omap_eac_readfn,\n\n omap_eac_writefn, s);\n\n omap_l4_attach(ta, 0, iomemtype);\n\n#endif\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 11921 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)\n{\n const char *sec_model = qemu_opt_get(opts, \"security_model\");\n const char *path = qemu_opt_get(opts, \"path\");\n if (sec_model) {\n error_report(\"Invalid argument security_model specified with handle fsdriver\");\n return -1;\n }\n if (!path) {\n error_report(\"fsdev: No path specified\");\n return -1;\n }\n fse->path = g_strdup(path);\n return 0;\n}", + "output": "1", + "index": 19612 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void map_linear_vram(CirrusVGAState *s)\n\n{\n\n\n\n\n if (!s->map_addr && s->lfb_addr && s->lfb_end) {\n\n s->map_addr = s->lfb_addr;\n\n s->map_end = s->lfb_end;\n\n cpu_register_physical_memory(s->map_addr, s->map_end - s->map_addr, s->vram_offset);\n\n }\n\n\n\n if (!s->map_addr)\n\n return;\n\n\n\n s->lfb_vram_mapped = 0;\n\n\n\n\n\n\n\n if (!(s->cirrus_srcptr != s->cirrus_srcptr_end)\n\n && !((s->sr[0x07] & 0x01) == 0)\n\n && !((s->gr[0x0B] & 0x14) == 0x14)\n\n && !(s->gr[0x0B] & 0x02)) {\n\n\n\n\n\n (s->vram_offset + s->cirrus_bank_base[0]) | IO_MEM_RAM);\n\n\n (s->vram_offset + s->cirrus_bank_base[1]) | IO_MEM_RAM);\n\n\n\n s->lfb_vram_mapped = 1;\n\n }\n\n else {\n\n cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,\n\n s->vga_io_memory);\n\n }\n\n\n\n vga_dirty_log_start((VGAState *)s);\n\n}", + "output": "1", + "index": 19835 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void visit_nested_struct_list(Visitor *v, void **native, Error **errp)\n\n{\n\n visit_type_UserDefNestedList(v, (UserDefNestedList **)native, NULL, errp);\n\n}\n", + "output": "0", + "index": 25935 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "gdb_handlesig (CPUState *env, int sig)\n\n{\n\n GDBState *s;\n\n char buf[256];\n\n int n;\n\n\n\n s = &gdbserver_state;\n\n if (gdbserver_fd < 0 || s->fd < 0)\n\n return sig;\n\n\n\n /* disable single step if it was enabled */\n\n cpu_single_step(env, 0);\n\n tb_flush(env);\n\n\n\n if (sig != 0)\n\n {\n\n snprintf(buf, sizeof(buf), \"S%02x\", sig);\n\n put_packet(s, buf);\n\n }\n\n /* put_packet() might have detected that the peer terminated the \n\n connection. */\n\n if (s->fd < 0)\n\n return sig;\n\n\n\n sig = 0;\n\n s->state = RS_IDLE;\n\n s->running_state = 0;\n\n while (s->running_state == 0) {\n\n n = read (s->fd, buf, 256);\n\n if (n > 0)\n\n {\n\n int i;\n\n\n\n for (i = 0; i < n; i++)\n\n gdb_read_byte (s, buf[i]);\n\n }\n\n else if (n == 0 || errno != EAGAIN)\n\n {\n\n /* XXX: Connection closed. Should probably wait for annother\n\n connection before continuing. */\n\n return sig;\n\n }\n\n }\n\n sig = s->signal;\n\n s->signal = 0;\n\n return sig;\n\n}\n", + "output": "0", + "index": 4954 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,\n\n target_ulong *pages, bool is_write)\n\n{\n\n bool lowprot = is_write && lowprot_enabled(&cpu->env);\n\n uint64_t asc = cpu->env.psw.mask & PSW_MASK_ASC;\n\n CPUS390XState *env = &cpu->env;\n\n int ret, i, pflags;\n\n\n\n for (i = 0; i < nr_pages; i++) {\n\n /* Low-address protection? */\n\n if (lowprot && (addr < 512 || (addr >= 4096 && addr < 4096 + 512))) {\n\n trigger_access_exception(env, PGM_PROTECTION, ILEN_AUTO, 0);\n\n return -EACCES;\n\n }\n\n ret = mmu_translate(env, addr, is_write, asc, &pages[i], &pflags, true);\n\n if (ret) {\n\n return ret;\n\n }\n\n if (!address_space_access_valid(&address_space_memory, pages[i],\n\n TARGET_PAGE_SIZE, is_write)) {\n\n program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO);\n\n return -EFAULT;\n\n }\n\n addr += TARGET_PAGE_SIZE;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 10250 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pollfds_poll(GArray *pollfds, int nfds, fd_set *rfds,\n\n fd_set *wfds, fd_set *xfds)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < pollfds->len; i++) {\n\n GPollFD *pfd = &g_array_index(pollfds, GPollFD, i);\n\n int fd = pfd->fd;\n\n int revents = 0;\n\n\n\n if (FD_ISSET(fd, rfds)) {\n\n revents |= G_IO_IN | G_IO_HUP | G_IO_ERR;\n\n }\n\n if (FD_ISSET(fd, wfds)) {\n\n revents |= G_IO_OUT | G_IO_ERR;\n\n }\n\n if (FD_ISSET(fd, xfds)) {\n\n revents |= G_IO_PRI;\n\n }\n\n pfd->revents = revents & pfd->events;\n\n }\n\n}\n", + "output": "1", + "index": 17535 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_outb(CPUState *env, pio_addr_t addr, uint8_t val)\n\n{\n\n LOG_IOPORT(\"outb: %04\"FMT_pioaddr\" %02\"PRIx8\"\\n\", addr, val);\n\n ioport_write(0, addr, val);\n\n#ifdef CONFIG_KQEMU\n\n if (env)\n\n env->last_io_time = cpu_get_time_fast();\n\n#endif\n\n}\n", + "output": "0", + "index": 20513 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_fcmpo (uint64_t arg1, uint64_t arg2, uint32_t crfD)\n\n{\n\n CPU_DoubleU farg1, farg2;\n\n uint32_t ret = 0;\n\n farg1.ll = arg1;\n\n farg2.ll = arg2;\n\n\n\n if (unlikely(float64_is_nan(farg1.d) ||\n\n float64_is_nan(farg2.d))) {\n\n ret = 0x01UL;\n\n } else if (float64_lt(farg1.d, farg2.d, &env->fp_status)) {\n\n ret = 0x08UL;\n\n } else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) {\n\n ret = 0x04UL;\n\n } else {\n\n ret = 0x02UL;\n\n }\n\n\n\n env->fpscr &= ~(0x0F << FPSCR_FPRF);\n\n env->fpscr |= ret << FPSCR_FPRF;\n\n env->crf[crfD] = ret;\n\n if (unlikely (ret == 0x01UL)) {\n\n if (float64_is_signaling_nan(farg1.d) ||\n\n float64_is_signaling_nan(farg2.d)) {\n\n /* sNaN comparison */\n\n fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN |\n\n POWERPC_EXCP_FP_VXVC);\n\n } else {\n\n /* qNaN comparison */\n\n fload_invalid_op_excp(POWERPC_EXCP_FP_VXVC);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 12121 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ac3_probe(AVProbeData *p)\n\n{\n\n int max_frames, first_frames, frames;\n\n uint8_t *buf, *buf2, *end;\n\n AC3HeaderInfo hdr;\n\n\n\n if(p->buf_size < 7)\n\n return 0;\n\n\n\n max_frames = 0;\n\n buf = p->buf;\n\n end = buf + FFMIN(4096, p->buf_size - 7);\n\n\n\n for(; buf < end; buf++) {\n\n buf2 = buf;\n\n\n\n for(frames = 0; buf2 < end; frames++) {\n\n if(ff_ac3_parse_header(buf2, &hdr) < 0)\n\n break;\n\n buf2 += hdr.frame_size;\n\n }\n\n max_frames = FFMAX(max_frames, frames);\n\n if(buf == p->buf)\n\n first_frames = frames;\n\n }\n\n if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;\n\n else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;\n\n else if(max_frames>=1) return 1;\n\n else return 0;\n\n}\n", + "output": "1", + "index": 8544 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen)\n\n{\n\n int i = 0, d = 0;\n\n int ret;\n\n uint32_t count = 0;\n\n\n\n while (i < slen) {\n\n\n\n /* zrun */\n\n if ((slen - i) < 2) {\n\n return -1;\n\n }\n\n\n\n ret = uleb128_decode_small(src + i, &count);\n\n if (ret < 0 || (i && !count)) {\n\n return -1;\n\n }\n\n i += ret;\n\n d += count;\n\n\n\n /* overflow */\n\n if (d > dlen) {\n\n return -1;\n\n }\n\n\n\n /* nzrun */\n\n if ((slen - i) < 2) {\n\n return -1;\n\n }\n\n\n\n ret = uleb128_decode_small(src + i, &count);\n\n if (ret < 0 || !count) {\n\n return -1;\n\n }\n\n i += ret;\n\n\n\n /* overflow */\n\n if (d + count > dlen || i + count > slen) {\n\n return -1;\n\n }\n\n\n\n memcpy(dst + d, src + i, count);\n\n d += count;\n\n i += count;\n\n }\n\n\n\n return d;\n\n}\n", + "output": "1", + "index": 8429 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)\n\n{\n\n VideoData *s = s1->priv_data;\n\n char filename[1024];\n\n int ret;\n\n ByteIOContext f1, *f;\n\n\n\n if (get_frame_filename(filename, sizeof(filename),\n\n s->path, s->img_number) < 0)\n\n return -EIO;\n\n \n\n if (!s->is_pipe) {\n\n f = &f1;\n\n if (url_fopen(f, filename, URL_RDONLY) < 0)\n\n return -EIO;\n\n } else {\n\n f = &s1->pb;\n\n if (url_feof(f))\n\n return -EIO;\n\n }\n\n\n\n av_new_packet(pkt, s->img_size);\n\n pkt->stream_index = 0;\n\n\n\n switch(s->img_fmt) {\n\n case IMGFMT_PGMYUV:\n\n ret = pgm_read(s, f, pkt->data, pkt->size, 1);\n\n break;\n\n case IMGFMT_PGM:\n\n ret = pgm_read(s, f, pkt->data, pkt->size, 0);\n\n break;\n\n case IMGFMT_YUV:\n\n ret = yuv_read(s, filename, pkt->data, pkt->size);\n\n break;\n\n case IMGFMT_PPM:\n\n ret = ppm_read(s, f, pkt->data, pkt->size);\n\n break;\n\n default:\n\n return -EIO;\n\n }\n\n \n\n if (!s->is_pipe) {\n\n url_fclose(f);\n\n }\n\n\n\n if (ret < 0) {\n\n av_free_packet(pkt);\n\n return -EIO; /* signal EOF */\n\n } else {\n\n s->img_number++;\n\n return 0;\n\n }\n\n}\n", + "output": "1", + "index": 446 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)\n\n{\n\n Mpeg4DecContext *ctx = avctx->priv_data;\n\n MpegEncContext *s = &ctx->m;\n\n\n\n /* divx 5.01+ bitstream reorder stuff */\n\n /* Since this clobbers the input buffer and hwaccel codecs still need the\n\n * data during hwaccel->end_frame we should not do this any earlier */\n\n if (s->divx_packed) {\n\n int current_pos = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);\n\n int startcode_found = 0;\n\n\n\n if (buf_size - current_pos > 7) {\n\n\n\n int i;\n\n for (i = current_pos; i < buf_size - 4; i++)\n\n\n\n if (buf[i] == 0 &&\n\n buf[i + 1] == 0 &&\n\n buf[i + 2] == 1 &&\n\n buf[i + 3] == 0xB6) {\n\n startcode_found = !(buf[i + 4] & 0x40);\n\n break;\n\n }\n\n }\n\n\n\n if (startcode_found) {\n\n av_fast_malloc(&s->bitstream_buffer,\n\n &s->allocated_bitstream_buffer_size,\n\n buf_size - current_pos +\n\n FF_INPUT_BUFFER_PADDING_SIZE);\n\n if (!s->bitstream_buffer)\n\n return AVERROR(ENOMEM);\n\n memcpy(s->bitstream_buffer, buf + current_pos,\n\n buf_size - current_pos);\n\n s->bitstream_buffer_size = buf_size - current_pos;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 7592 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)\n\n{\n\n VirtIONet *n = VIRTIO_NET(vdev);\n\n int i;\n\n\n\n virtio_net_set_multiqueue(n, !!(features & (1 << VIRTIO_NET_F_MQ)),\n\n !!(features & (1 << VIRTIO_NET_F_CTRL_VQ)));\n\n\n\n virtio_net_set_mrg_rx_bufs(n, !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF)));\n\n\n\n if (n->has_vnet_hdr) {\n\n tap_set_offload(qemu_get_subqueue(n->nic, 0)->peer,\n\n (features >> VIRTIO_NET_F_GUEST_CSUM) & 1,\n\n (features >> VIRTIO_NET_F_GUEST_TSO4) & 1,\n\n (features >> VIRTIO_NET_F_GUEST_TSO6) & 1,\n\n (features >> VIRTIO_NET_F_GUEST_ECN) & 1,\n\n (features >> VIRTIO_NET_F_GUEST_UFO) & 1);\n\n }\n\n\n\n for (i = 0; i < n->max_queues; i++) {\n\n NetClientState *nc = qemu_get_subqueue(n->nic, i);\n\n\n\n if (!nc->peer || nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {\n\n continue;\n\n }\n\n if (!tap_get_vhost_net(nc->peer)) {\n\n continue;\n\n }\n\n vhost_net_ack_features(tap_get_vhost_net(nc->peer), features);\n\n }\n\n}\n", + "output": "0", + "index": 1220 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors,\n\n int sector_size)\n\n{\n\n s->lba = lba;\n\n s->packet_transfer_size = nb_sectors * sector_size;\n\n s->io_buffer_index = 0;\n\n s->io_buffer_size = 0;\n\n s->cd_sector_size = sector_size;\n\n\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->packet_transfer_size,\n\n BLOCK_ACCT_READ);\n\n\n\n /* XXX: check if BUSY_STAT should be set */\n\n s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;\n\n ide_start_dma(s, ide_atapi_cmd_read_dma_cb);\n\n}\n", + "output": "0", + "index": 23358 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int url_connect(struct variant *var, AVDictionary *opts)\n\n{\n\n AVDictionary *tmp = NULL;\n\n int ret;\n\n\n\n av_dict_copy(&tmp, opts, 0);\n\n\n\n av_opt_set_dict(var->input, &tmp);\n\n\n\n if ((ret = ffurl_connect(var->input, NULL)) < 0) {\n\n ffurl_close(var->input);\n\n var->input = NULL;\n\n }\n\n\n\n av_dict_free(&tmp);\n\n return ret;\n\n}\n", + "output": "0", + "index": 7746 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_packet_split_side_data(AVPacket *pkt){\n\n if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){\n\n int i;\n\n unsigned int size;\n\n uint8_t *p;\n\n\n\n p = pkt->data + pkt->size - 8 - 5;\n\n for (i=1; ; i++){\n\n size = AV_RB32(p);\n\n if (size>INT_MAX || p - pkt->data < size)\n\n return 0;\n\n if (p[4]&128)\n\n break;\n\n p-= size+5;\n\n }\n\n\n\n pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));\n\n if (!pkt->side_data)\n\n return AVERROR(ENOMEM);\n\n\n\n p= pkt->data + pkt->size - 8 - 5;\n\n for (i=0; ; i++){\n\n size= AV_RB32(p);\n\n av_assert0(size<=INT_MAX && p - pkt->data >= size);\n\n pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);\n\n pkt->side_data[i].size = size;\n\n pkt->side_data[i].type = p[4]&127;\n\n if (!pkt->side_data[i].data)\n\n return AVERROR(ENOMEM);\n\n memcpy(pkt->side_data[i].data, p-size, size);\n\n pkt->size -= size + 5;\n\n if(p[4]&128)\n\n break;\n\n p-= size+5;\n\n }\n\n pkt->size -= 8;\n\n pkt->side_data_elems = i+1;\n\n return 1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 4159 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_hevc_cu_qp_delta_abs(HEVCContext *s)\n\n{\n\n int prefix_val = 0;\n\n int suffix_val = 0;\n\n int inc = 0;\n\n\n\n while (prefix_val < 5 && GET_CABAC(elem_offset[CU_QP_DELTA] + inc)) {\n\n prefix_val++;\n\n inc = 1;\n\n }\n\n if (prefix_val >= 5) {\n\n int k = 0;\n\n while (k < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc)) {\n\n suffix_val += 1 << k;\n\n k++;\n\n }\n\n if (k == CABAC_MAX_BIN)\n\n av_log(s->avctx, AV_LOG_ERROR, \"CABAC_MAX_BIN : %d\\n\", k);\n\n\n\n while (k--)\n\n suffix_val += get_cabac_bypass(&s->HEVClc->cc) << k;\n\n }\n\n return prefix_val + suffix_val;\n\n}\n", + "output": "1", + "index": 6952 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov,\n\n int pattern)\n\n{\n\n size_t *sizes = g_new0(size_t, nr_iov);\n\n size_t count = 0;\n\n void *buf = NULL;\n\n void *p;\n\n int i;\n\n\n\n for (i = 0; i < nr_iov; i++) {\n\n char *arg = argv[i];\n\n int64_t len;\n\n\n\n len = cvtnum(arg);\n\n if (len < 0) {\n\n print_cvtnum_err(len, arg);\n\n goto fail;\n\n }\n\n\n\n if (len > SIZE_MAX) {\n\n printf(\"Argument '%s' exceeds maximum size %llu\\n\", arg,\n\n (unsigned long long)SIZE_MAX);\n\n goto fail;\n\n }\n\n\n\n sizes[i] = len;\n\n count += len;\n\n }\n\n\n\n qemu_iovec_init(qiov, nr_iov);\n\n\n\n buf = p = qemu_io_alloc(blk, count, pattern);\n\n\n\n for (i = 0; i < nr_iov; i++) {\n\n qemu_iovec_add(qiov, p, sizes[i]);\n\n p += sizes[i];\n\n }\n\n\n\nfail:\n\n g_free(sizes);\n\n return buf;\n\n}\n", + "output": "1", + "index": 4078 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ppc64_v3_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx,\n\n int mmu_idx)\n\n{\n\n if (ppc64_radix_guest(cpu)) { /* Guest uses radix */\n\n /* TODO - Unsupported */\n\n error_report(\"Guest Radix Support Unimplemented\");\n\n exit(1);\n\n } else { /* Guest uses hash */\n\n return ppc_hash64_handle_mmu_fault(cpu, eaddr, rwx, mmu_idx);\n\n }\n\n}\n", + "output": "0", + "index": 6753 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_dcbi(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n#else\n\n TCGv EA, val;\n\n if (unlikely(ctx->pr)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n return;\n\n }\n\n EA = tcg_temp_new();\n\n gen_set_access_type(ctx, ACCESS_CACHE);\n\n gen_addr_reg_index(ctx, EA);\n\n val = tcg_temp_new();\n\n /* XXX: specification says this should be treated as a store by the MMU */\n\n gen_qemu_ld8u(ctx, val, EA);\n\n gen_qemu_st8(ctx, val, EA);\n\n tcg_temp_free(val);\n\n tcg_temp_free(EA);\n\n#endif\n\n}\n", + "output": "1", + "index": 10725 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order)\n\n{\n\n const int blocksize = s->blocksize;\n\n int32_t *decoded = s->decoded[channel];\n\n int a, b, c, d, i;\n\n\n\n /* warm up samples */\n\n for (i = 0; i < pred_order; i++) {\n\n decoded[i] = get_sbits(&s->gb, s->curr_bps);\n\n }\n\n\n\n if (decode_residuals(s, channel, pred_order) < 0)\n\n return -1;\n\n\n\n if (pred_order > 0)\n\n a = decoded[pred_order-1];\n\n if (pred_order > 1)\n\n b = a - decoded[pred_order-2];\n\n if (pred_order > 2)\n\n c = b - decoded[pred_order-2] + decoded[pred_order-3];\n\n if (pred_order > 3)\n\n d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];\n\n\n\n switch (pred_order) {\n\n case 0:\n\n break;\n\n case 1:\n\n for (i = pred_order; i < blocksize; i++)\n\n decoded[i] = a += decoded[i];\n\n break;\n\n case 2:\n\n for (i = pred_order; i < blocksize; i++)\n\n decoded[i] = a += b += decoded[i];\n\n break;\n\n case 3:\n\n for (i = pred_order; i < blocksize; i++)\n\n decoded[i] = a += b += c += decoded[i];\n\n break;\n\n case 4:\n\n for (i = pred_order; i < blocksize; i++)\n\n decoded[i] = a += b += c += d += decoded[i];\n\n break;\n\n default:\n\n av_log(s->avctx, AV_LOG_ERROR, \"illegal pred order %d\\n\", pred_order);\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 9344 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_co_queue(void)\n\n{\n\n Coroutine *c1;\n\n Coroutine *c2;\n\n\n\n c1 = qemu_coroutine_create(c1_fn);\n\n c2 = qemu_coroutine_create(c2_fn);\n\n\n\n qemu_coroutine_enter(c1, c2);\n\n memset(c1, 0xff, sizeof(Coroutine));\n\n qemu_coroutine_enter(c2, NULL);\n\n}\n", + "output": "1", + "index": 22605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)\n\n{\n\n\tunsigned i;\n\n\tfor(i=0; i 0) {\n\n if (decrypt) {\n\n v0 = AV_RB32(src);\n\n v1 = AV_RB32(src + 4);\n\n\n\n av_blowfish_crypt_ecb(ctx, &v0, &v1, decrypt);\n\n\n\n AV_WB32(dst, v0);\n\n AV_WB32(dst + 4, v1);\n\n\n\n if (iv) {\n\n for (i = 0; i < 8; i++)\n\n dst[i] = dst[i] ^ iv[i];\n\n memcpy(iv, src, 8);\n\n }\n\n } else {\n\n if (iv) {\n\n for (i = 0; i < 8; i++)\n\n dst[i] = src[i] ^ iv[i];\n\n v0 = AV_RB32(dst);\n\n v1 = AV_RB32(dst + 4);\n\n } else {\n\n v0 = AV_RB32(src);\n\n v1 = AV_RB32(src + 4);\n\n }\n\n\n\n av_blowfish_crypt_ecb(ctx, &v0, &v1, decrypt);\n\n\n\n AV_WB32(dst, v0);\n\n AV_WB32(dst + 4, v1);\n\n\n\n if (iv)\n\n memcpy(iv, dst, 8);\n\n }\n\n\n\n src += 8;\n\n dst += 8;\n\n count -= 8;\n\n }\n\n}\n", + "output": "0", + "index": 4259 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nppscale_query_formats(AVFilterContext *ctx)\n\n{\n\n static const enum AVPixelFormat pixel_formats[] = {\n\n AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,\n\n };\n\n AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);\n\n\n\n ff_set_common_formats(ctx, pix_fmts);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22697 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int webm_dash_manifest_write_header(AVFormatContext *s)\n\n{\n\n int i;\n\n double start = 0.0;\n\n WebMDashMuxContext *w = s->priv_data;\n\n parse_adaptation_sets(s);\n\n write_header(s);\n\n avio_printf(s->pb, \"pb, \" start=\\\"PT%gS\\\"\", start);\n\n if (!w->is_live) {\n\n avio_printf(s->pb, \" duration=\\\"PT%gS\\\"\", get_duration(s));\n\n }\n\n avio_printf(s->pb, \" >\\n\");\n\n\n\n for (i = 0; i < w->nb_as; i++) {\n\n if (write_adaptation_set(s, i) < 0) return -1;\n\n }\n\n\n\n avio_printf(s->pb, \"\\n\");\n\n write_footer(s);\n\n return 0;\n\n}\n", + "output": "1", + "index": 22124 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_outs(DisasContext *s, TCGMemOp ot)\n\n{\n\n if (s->base.tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_string_movl_A0_ESI(s);\n\n gen_op_ld_v(s, ot, cpu_T0, cpu_A0);\n\n\n\n tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_EDX]);\n\n tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);\n\n tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T0);\n\n gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);\n\n gen_op_movl_T0_Dshift(ot);\n\n gen_op_add_reg_T0(s->aflag, R_ESI);\n\n gen_bpt_io(s, cpu_tmp2_i32, ot);\n\n if (s->base.tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n }\n\n}\n", + "output": "1", + "index": 21682 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hmp_info_snapshots(Monitor *mon, const QDict *qdict)\n\n{\n\n BlockDriverState *bs, *bs1;\n\n QEMUSnapshotInfo *sn_tab, *sn, s, *sn_info = &s;\n\n int nb_sns, i, ret, available;\n\n int total;\n\n int *available_snapshots;\n\n\n\n bs = find_vmstate_bs();\n\n if (!bs) {\n\n monitor_printf(mon, \"No available block device supports snapshots\\n\");\n\n return;\n\n }\n\n\n\n nb_sns = bdrv_snapshot_list(bs, &sn_tab);\n\n if (nb_sns < 0) {\n\n monitor_printf(mon, \"bdrv_snapshot_list: error %d\\n\", nb_sns);\n\n return;\n\n }\n\n\n\n if (nb_sns == 0) {\n\n monitor_printf(mon, \"There is no snapshot available.\\n\");\n\n return;\n\n }\n\n\n\n available_snapshots = g_malloc0(sizeof(int) * nb_sns);\n\n total = 0;\n\n for (i = 0; i < nb_sns; i++) {\n\n sn = &sn_tab[i];\n\n available = 1;\n\n bs1 = NULL;\n\n\n\n while ((bs1 = bdrv_next(bs1))) {\n\n if (bdrv_can_snapshot(bs1) && bs1 != bs) {\n\n ret = bdrv_snapshot_find(bs1, sn_info, sn->id_str);\n\n if (ret < 0) {\n\n available = 0;\n\n break;\n\n }\n\n }\n\n }\n\n\n\n if (available) {\n\n available_snapshots[total] = i;\n\n total++;\n\n }\n\n }\n\n\n\n if (total > 0) {\n\n bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL);\n\n monitor_printf(mon, \"\\n\");\n\n for (i = 0; i < total; i++) {\n\n sn = &sn_tab[available_snapshots[i]];\n\n bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, sn);\n\n monitor_printf(mon, \"\\n\");\n\n }\n\n } else {\n\n monitor_printf(mon, \"There is no suitable snapshot available\\n\");\n\n }\n\n\n\n g_free(sn_tab);\n\n g_free(available_snapshots);\n\n\n\n}\n", + "output": "1", + "index": 12558 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ram_addr_t find_ram_offset(ram_addr_t size)\n\n{\n\n RAMBlock *block, *next_block;\n\n ram_addr_t offset, mingap = ULONG_MAX;\n\n\n\n if (QLIST_EMPTY(&ram_list.blocks))\n\n return 0;\n\n\n\n QLIST_FOREACH(block, &ram_list.blocks, next) {\n\n ram_addr_t end, next = ULONG_MAX;\n\n\n\n end = block->offset + block->length;\n\n\n\n QLIST_FOREACH(next_block, &ram_list.blocks, next) {\n\n if (next_block->offset >= end) {\n\n next = MIN(next, next_block->offset);\n\n }\n\n }\n\n if (next - end >= size && next - end < mingap) {\n\n offset = end;\n\n mingap = next - end;\n\n }\n\n }\n\n return offset;\n\n}\n", + "output": "1", + "index": 17409 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d)\n\n{\n\n qemu_irq *irq;\n\n\n\n if (bus->dma == &bm->dma) {\n\n return;\n\n }\n\n\n\n bm->dma.ops = &bmdma_ops;\n\n bus->dma = &bm->dma;\n\n bm->irq = bus->irq;\n\n irq = qemu_allocate_irqs(bmdma_irq, bm, 1);\n\n bus->irq = *irq;\n\n bm->pci_dev = d;\n\n}\n", + "output": "1", + "index": 13984 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(simple_varargs)\n\n{\n\n QObject *embedded_obj;\n\n QObject *obj;\n\n LiteralQObject decoded = QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QINT(1),\n\n QLIT_QINT(2),\n\n QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QINT(32),\n\n QLIT_QINT(42),\n\n {}})),\n\n {}}));\n\n\n\n embedded_obj = qobject_from_json(\"[32, 42]\");\n\n fail_unless(embedded_obj != NULL);\n\n\n\n obj = qobject_from_jsonf(\"[%d, 2, %p]\", 1, embedded_obj);\n\n fail_unless(obj != NULL);\n\n\n\n fail_unless(compare_litqobj_to_qobj(&decoded, obj) == 1);\n\n\n\n qobject_decref(obj);\n\n}\n", + "output": "0", + "index": 7827 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vu_queue_flush(VuDev *dev, VuVirtq *vq, unsigned int count)\n\n{\n\n uint16_t old, new;\n\n\n\n if (unlikely(dev->broken)) {\n\n return;\n\n }\n\n\n\n /* Make sure buffer is written before we update index. */\n\n smp_wmb();\n\n\n\n old = vq->used_idx;\n\n new = old + count;\n\n vring_used_idx_set(dev, vq, new);\n\n vq->inuse -= count;\n\n if (unlikely((int16_t)(new - vq->signalled_used) < (uint16_t)(new - old))) {\n\n vq->signalled_used_valid = false;\n\n }\n\n}\n", + "output": "1", + "index": 21980 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong h_vio_signal(CPUState *env, sPAPREnvironment *spapr,\n\n target_ulong opcode,\n\n target_ulong *args)\n\n{\n\n target_ulong reg = args[0];\n\n target_ulong mode = args[1];\n\n VIOsPAPRDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);\n\n VIOsPAPRDeviceInfo *info;\n\n\n\n if (!dev) {\n\n return H_PARAMETER;\n\n }\n\n\n\n info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);\n\n\n\n if (mode & ~info->signal_mask) {\n\n return H_PARAMETER;\n\n }\n\n\n\n dev->signal_state = mode;\n\n\n\n return H_SUCCESS;\n\n}\n", + "output": "0", + "index": 25352 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int config(struct vf_instance *vf,\n\n int width, int height, int d_width, int d_height,\n\n unsigned int flags, unsigned int outfmt)\n\n{\n\n switch (vf->priv->mode) {\n\n case 0:\n\n case 3:\n\n return ff_vf_next_config(vf,width,height*2,d_width,d_height*2,flags,outfmt);\n\n case 1: /* odd frames */\n\n case 2: /* even frames */\n\n case 4: /* alternate frame (height-preserving) interlacing */\n\n return ff_vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 12463 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void raw_reopen_abort(BDRVReopenState *state)\n\n{\n\n g_free(state->opaque);\n\n state->opaque = NULL;\n\n}\n", + "output": "0", + "index": 12528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t prefix, int length)\n\n{\n\n if(length > 32) {\n\n av_log(NULL, AV_LOG_ERROR, \"length too long\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n if(!get_bits1(gb)){ //Leaf\n\n if(hc->current >= 256){\n\n av_log(NULL, AV_LOG_ERROR, \"Tree size exceeded!\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n if(length){\n\n hc->bits[hc->current] = prefix;\n\n hc->lengths[hc->current] = length;\n\n } else {\n\n hc->bits[hc->current] = 0;\n\n hc->lengths[hc->current] = 0;\n\n }\n\n hc->values[hc->current] = get_bits(gb, 8);\n\n hc->current++;\n\n if(hc->maxlength < length)\n\n hc->maxlength = length;\n\n return 0;\n\n } else { //Node\n\n int r;\n\n length++;\n\n r = smacker_decode_tree(gb, hc, prefix, length);\n\n if(r)\n\n return r;\n\n return smacker_decode_tree(gb, hc, prefix | (1 << (length - 1)), length);\n\n }\n\n}\n", + "output": "0", + "index": 4436 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)\n\n{\n\n ff_draw_horiz_band(s->avctx, &s->current_picture.f,\n\n &s->last_picture.f, y, h, s->picture_structure,\n\n s->first_field, s->low_delay);\n\n}\n", + "output": "1", + "index": 6985 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void downmix_stereo_to_mono(float *samples)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < 256; i++) {\n\n samples[i] += samples[i + 256];\n\n samples[i + 256] = 0;\n\n }\n\n}\n", + "output": "0", + "index": 9690 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int mmubooke_get_physical_address (CPUState *env, mmu_ctx_t *ctx,\n\n target_ulong address, int rw,\n\n int access_type)\n\n{\n\n ppcemb_tlb_t *tlb;\n\n target_phys_addr_t raddr;\n\n int i, prot, ret;\n\n\n\n ret = -1;\n\n raddr = -1;\n\n for (i = 0; i < env->nb_tlb; i++) {\n\n tlb = &env->tlb[i].tlbe;\n\n if (ppcemb_tlb_check(env, tlb, &raddr, address,\n\n env->spr[SPR_BOOKE_PID], 1, i) < 0)\n\n continue;\n\n if (msr_pr != 0)\n\n prot = tlb->prot & 0xF;\n\n else\n\n prot = (tlb->prot >> 4) & 0xF;\n\n /* Check the address space */\n\n if (access_type == ACCESS_CODE) {\n\n if (msr_ir != (tlb->attr & 1))\n\n continue;\n\n ctx->prot = prot;\n\n if (prot & PAGE_EXEC) {\n\n ret = 0;\n\n break;\n\n }\n\n ret = -3;\n\n } else {\n\n if (msr_dr != (tlb->attr & 1))\n\n continue;\n\n ctx->prot = prot;\n\n if ((!rw && prot & PAGE_READ) || (rw && (prot & PAGE_WRITE))) {\n\n ret = 0;\n\n break;\n\n }\n\n ret = -2;\n\n }\n\n }\n\n if (ret >= 0)\n\n ctx->raddr = raddr;\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 6694 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void fork_end(int child)\n\n{\n\n mmap_fork_end(child);\n\n if (child) {\n\n CPUState *cpu, *next_cpu;\n\n /* Child processes created by fork() only have a single thread.\n\n Discard information about the parent threads. */\n\n CPU_FOREACH_SAFE(cpu, next_cpu) {\n\n if (cpu != thread_cpu) {\n\n QTAILQ_REMOVE(&cpus, cpu, node);\n\n }\n\n }\n\n qemu_mutex_init(&tb_ctx.tb_lock);\n\n qemu_init_cpu_list();\n\n gdbserver_fork(thread_cpu);\n\n\n\n\n } else {\n\n qemu_mutex_unlock(&tb_ctx.tb_lock);\n\n cpu_list_unlock();\n\n\n }\n\n}", + "output": "1", + "index": 24822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void print_report(const char *op, struct timeval *t, int64_t offset,\n\n int64_t count, int64_t total, int cnt, int Cflag)\n\n{\n\n char s1[64], s2[64], ts[64];\n\n\n\n timestr(t, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0);\n\n if (!Cflag) {\n\n cvtstr((double)total, s1, sizeof(s1));\n\n cvtstr(tdiv((double)total, *t), s2, sizeof(s2));\n\n printf(\"%s %\"PRId64\"/%\"PRId64\" bytes at offset %\" PRId64 \"\\n\",\n\n op, total, count, offset);\n\n printf(\"%s, %d ops; %s (%s/sec and %.4f ops/sec)\\n\",\n\n s1, cnt, ts, s2, tdiv((double)cnt, *t));\n\n } else {/* bytes,ops,time,bytes/sec,ops/sec */\n\n printf(\"%\"PRId64\",%d,%s,%.3f,%.3f\\n\",\n\n total, cnt, ts,\n\n tdiv((double)total, *t),\n\n tdiv((double)cnt, *t));\n\n }\n\n}\n", + "output": "0", + "index": 17027 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)\n\n{\n\n struct kvm_irq_routing_entry kroute;\n\n\n\n if (!kvm_irqchip_in_kernel()) {\n\n return -ENOSYS;\n\n }\n\n\n\n kroute.gsi = virq;\n\n kroute.type = KVM_IRQ_ROUTING_MSI;\n\n kroute.flags = 0;\n\n kroute.u.msi.address_lo = (uint32_t)msg.address;\n\n kroute.u.msi.address_hi = msg.address >> 32;\n\n kroute.u.msi.data = le32_to_cpu(msg.data);\n\n\n\n return kvm_update_routing_entry(s, &kroute);\n\n}\n", + "output": "1", + "index": 6179 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PPC_OP(subfeo)\n\n{\n\n do_subfeo();\n\n RETURN();\n\n}\n", + "output": "1", + "index": 24532 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_image_copy_plane(uint8_t *dst, int dst_linesize,\n\n const uint8_t *src, int src_linesize,\n\n int bytewidth, int height)\n\n{\n\n if (!dst || !src)\n\n return;\n\n\n\n for (;height > 0; height--) {\n\n memcpy(dst, src, bytewidth);\n\n dst += dst_linesize;\n\n src += src_linesize;\n\n }\n\n}", + "output": "1", + "index": 12902 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void emulate_spapr_hypercall(CPUPPCState *env)\n\n{\n\n env->gpr[3] = spapr_hypercall(env, env->gpr[3], &env->gpr[4]);\n\n}\n", + "output": "1", + "index": 13727 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void icp_realize(DeviceState *dev, Error **errp)\n\n{\n\n ICPState *icp = ICP(dev);\n\n ICPStateClass *icpc = ICP_GET_CLASS(dev);\n\n PowerPCCPU *cpu;\n\n CPUPPCState *env;\n\n Object *obj;\n\n Error *err = NULL;\n\n\n\n obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err);\n\n if (!obj) {\n\n error_setg(errp, \"%s: required link '\" ICP_PROP_XICS \"' not found: %s\",\n\n __func__, error_get_pretty(err));\n\n return;\n\n }\n\n\n\n icp->xics = XICS_FABRIC(obj);\n\n\n\n obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err);\n\n if (!obj) {\n\n error_setg(errp, \"%s: required link '\" ICP_PROP_CPU \"' not found: %s\",\n\n __func__, error_get_pretty(err));\n\n return;\n\n }\n\n\n\n cpu = POWERPC_CPU(obj);\n\n cpu->intc = OBJECT(icp);\n\n icp->cs = CPU(obj);\n\n\n\n env = &cpu->env;\n\n switch (PPC_INPUT(env)) {\n\n case PPC_FLAGS_INPUT_POWER7:\n\n icp->output = env->irq_inputs[POWER7_INPUT_INT];\n\n break;\n\n\n\n case PPC_FLAGS_INPUT_970:\n\n icp->output = env->irq_inputs[PPC970_INPUT_INT];\n\n break;\n\n\n\n default:\n\n error_setg(errp, \"XICS interrupt controller does not support this CPU bus model\");\n\n return;\n\n }\n\n\n\n if (icpc->realize) {\n\n icpc->realize(icp, errp);\n\n }\n\n\n\n qemu_register_reset(icp_reset, dev);\n\n vmstate_register(NULL, icp->cs->cpu_index, &vmstate_icp_server, icp);\n\n}\n", + "output": "1", + "index": 5538 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,\n\n const AVDXVAContext *ctx,\n\n const AVFrame *frame)\n\n{\n\n void *surface = ff_dxva2_get_surface(frame);\n\n unsigned i;\n\n\n\n for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++)\n\n if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface)\n\n return i;\n\n\n\n assert(0);\n\n return 0;\n\n}\n", + "output": "1", + "index": 24029 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_gain_table(COOKContext *q) {\n\n int i;\n\n q->gain_size_factor = q->samples_per_channel/8;\n\n for (i=0 ; i<23 ; i++) {\n\n q->gain_table[i] = pow((double)q->pow2tab[i+52] ,\n\n (1.0/(double)q->gain_size_factor));\n\n }\n\n memset(&q->gain_copy, 0, sizeof(COOKgain));\n\n memset(&q->gain_current, 0, sizeof(COOKgain));\n\n memset(&q->gain_now, 0, sizeof(COOKgain));\n\n memset(&q->gain_previous, 0, sizeof(COOKgain));\n\n}\n", + "output": "1", + "index": 6999 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,\n\n SocketAddress *localAddr,\n\n SocketAddress *remoteAddr,\n\n QIOTaskFunc callback,\n\n gpointer opaque,\n\n GDestroyNotify destroy)\n\n{\n\n QIOTask *task = qio_task_new(\n\n OBJECT(ioc), callback, opaque, destroy);\n\n struct QIOChannelSocketDGramWorkerData *data = g_new0(\n\n struct QIOChannelSocketDGramWorkerData, 1);\n\n\n\n data->localAddr = QAPI_CLONE(SocketAddress, localAddr);\n\n data->remoteAddr = QAPI_CLONE(SocketAddress, remoteAddr);\n\n\n\n trace_qio_channel_socket_dgram_async(ioc, localAddr, remoteAddr);\n\n qio_task_run_in_thread(task,\n\n qio_channel_socket_dgram_worker,\n\n data,\n\n qio_channel_socket_dgram_worker_free);\n\n}\n", + "output": "0", + "index": 6232 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void memory_region_del_eventfd(MemoryRegion *mr,\n\n hwaddr addr,\n\n unsigned size,\n\n bool match_data,\n\n uint64_t data,\n\n EventNotifier *e)\n\n{\n\n MemoryRegionIoeventfd mrfd = {\n\n .addr.start = int128_make64(addr),\n\n .addr.size = int128_make64(size),\n\n .match_data = match_data,\n\n .data = data,\n\n .e = e,\n\n };\n\n unsigned i;\n\n\n\n adjust_endianness(mr, &mrfd.data, size);\n\n memory_region_transaction_begin();\n\n for (i = 0; i < mr->ioeventfd_nb; ++i) {\n\n if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) {\n\n break;\n\n }\n\n }\n\n assert(i != mr->ioeventfd_nb);\n\n memmove(&mr->ioeventfds[i], &mr->ioeventfds[i+1],\n\n sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1)));\n\n --mr->ioeventfd_nb;\n\n mr->ioeventfds = g_realloc(mr->ioeventfds,\n\n sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 1);\n\n ioeventfd_update_pending |= mr->enabled;\n\n memory_region_transaction_commit();\n\n}\n", + "output": "1", + "index": 7196 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int select_reference_stream(AVFormatContext *s)\n\n{\n\n SegmentContext *seg = s->priv_data;\n\n int ret, i;\n\n\n\n seg->reference_stream_index = -1;\n\n if (!strcmp(seg->reference_stream_specifier, \"auto\")) {\n\n /* select first index of type with highest priority */\n\n int type_index_map[AVMEDIA_TYPE_NB];\n\n static const enum AVMediaType type_priority_list[] = {\n\n AVMEDIA_TYPE_VIDEO,\n\n AVMEDIA_TYPE_AUDIO,\n\n AVMEDIA_TYPE_SUBTITLE,\n\n AVMEDIA_TYPE_DATA,\n\n AVMEDIA_TYPE_ATTACHMENT\n\n };\n\n enum AVMediaType type;\n\n\n\n for (i = 0; i < AVMEDIA_TYPE_NB; i++)\n\n type_index_map[i] = -1;\n\n\n\n /* select first index for each type */\n\n for (i = 0; i < s->nb_streams; i++) {\n\n type = s->streams[i]->codec->codec_type;\n\n if ((unsigned)type < AVMEDIA_TYPE_NB && type_index_map[type] == -1\n\n /* ignore attached pictures/cover art streams */\n\n && !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))\n\n type_index_map[type] = i;\n\n }\n\n\n\n for (i = 0; i < FF_ARRAY_ELEMS(type_priority_list); i++) {\n\n type = type_priority_list[i];\n\n if ((seg->reference_stream_index = type_index_map[type]) >= 0)\n\n break;\n\n }\n\n } else {\n\n for (i = 0; i < s->nb_streams; i++) {\n\n ret = avformat_match_stream_specifier(s, s->streams[i],\n\n seg->reference_stream_specifier);\n\n if (ret < 0)\n\n break;\n\n if (ret > 0) {\n\n seg->reference_stream_index = i;\n\n break;\n\n }\n\n }\n\n }\n\n\n\n if (seg->reference_stream_index < 0) {\n\n av_log(s, AV_LOG_ERROR, \"Could not select stream matching identifier '%s'\\n\",\n\n seg->reference_stream_specifier);\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 3617 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int interp(RA144Context *ractx, int16_t *out, int block_num,\n\n int copyold, int energy)\n\n{\n\n int work[10];\n\n int a = block_num + 1;\n\n int b = NBLOCKS - a;\n\n int x;\n\n\n\n // Interpolate block coefficients from the this frame forth block and\n\n // last frame forth block\n\n for (x=0; x<30; x++)\n\n out[x] = (a * ractx->lpc_coef[0][x] + b * ractx->lpc_coef[1][x])>> 2;\n\n\n\n if (eval_refl(work, out, ractx)) {\n\n // The interpolated coefficients are unstable, copy either new or old\n\n // coefficients\n\n int_to_int16(out, ractx->lpc_coef[copyold]);\n\n return rescale_rms(ractx->lpc_refl_rms[copyold], energy);\n\n } else {\n\n return rescale_rms(rms(work), energy);\n\n }\n\n}\n", + "output": "0", + "index": 25513 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip)\n\n{\n\n const ARMCPRegInfo *ri = rip;\n\n\n\n return ri->readfn(env, ri);\n\n}\n", + "output": "1", + "index": 10728 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t epic_decode_pixel_pred(ePICContext *dc, int x, int y,\n const uint32_t *curr_row,\n const uint32_t *above_row)\n{\n uint32_t N, W, NW, pred;\n unsigned delta;\n int GN, GW, GNW, R, G, B;\n if (x && y) {\n W = curr_row[x - 1];\n N = above_row[x];\n NW = above_row[x - 1];\n GN = (N >> G_shift) & 0xFF;\n GW = (W >> G_shift) & 0xFF;\n GNW = (NW >> G_shift) & 0xFF;\n G = epic_decode_component_pred(dc, GN, GW, GNW);\n R = G + epic_decode_component_pred(dc,\n ((N >> R_shift) & 0xFF) - GN,\n ((W >> R_shift) & 0xFF) - GW,\n ((NW >> R_shift) & 0xFF) - GNW);\n B = G + epic_decode_component_pred(dc,\n ((N >> B_shift) & 0xFF) - GN,\n ((W >> B_shift) & 0xFF) - GW,\n ((NW >> B_shift) & 0xFF) - GNW);\n } else {\n if (x)\n pred = curr_row[x - 1];\n else\n pred = above_row[x];\n delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);\n R = ((pred >> R_shift) & 0xFF) - TOSIGNED(delta);\n delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);\n G = ((pred >> G_shift) & 0xFF) - TOSIGNED(delta);\n delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);\n B = ((pred >> B_shift) & 0xFF) - TOSIGNED(delta);\n return (R << R_shift) | (G << G_shift) | (B << B_shift);", + "output": "1", + "index": 19898 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_cpu_kick(void *_env)\n\n{\n\n CPUState *env = _env;\n\n\n\n qemu_cond_broadcast(env->halt_cond);\n\n if (!env->thread_kicked) {\n\n qemu_cpu_kick_thread(env);\n\n env->thread_kicked = true;\n\n }\n\n}\n", + "output": "0", + "index": 226 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\n\n long width, long height,\n\n long lumStride, long chromStride, long dstStride)\n\n{\n\n //FIXME interpolate chroma\n\n RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);\n\n}\n", + "output": "0", + "index": 26169 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,\n\n hwaddr ctl_addr, hwaddr data_addr)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *d;\n\n FWCfgState *s;\n\n\n\n dev = qdev_create(NULL, TYPE_FW_CFG);\n\n qdev_prop_set_uint32(dev, \"ctl_iobase\", ctl_port);\n\n qdev_prop_set_uint32(dev, \"data_iobase\", data_port);\n\n d = SYS_BUS_DEVICE(dev);\n\n\n\n s = FW_CFG(dev);\n\n\n\n assert(!object_resolve_path(FW_CFG_PATH, NULL));\n\n\n\n object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s), NULL);\n\n\n\n qdev_init_nofail(dev);\n\n\n\n if (ctl_addr) {\n\n sysbus_mmio_map(d, 0, ctl_addr);\n\n }\n\n if (data_addr) {\n\n sysbus_mmio_map(d, 1, data_addr);\n\n }\n\n fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)\"QEMU\", 4);\n\n fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16);\n\n fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));\n\n fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);\n\n fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);\n\n fw_cfg_bootsplash(s);\n\n fw_cfg_reboot(s);\n\n\n\n s->machine_ready.notify = fw_cfg_machine_ready;\n\n qemu_add_machine_init_done_notifier(&s->machine_ready);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 17459 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t cas_check_pvr(PowerPCCPU *cpu, target_ulong *addr,\n\n Error **errp)\n\n{\n\n bool explicit_match = false; /* Matched the CPU's real PVR */\n\n uint32_t max_compat = cpu->max_compat;\n\n uint32_t best_compat = 0;\n\n int i;\n\n\n\n /*\n\n * We scan the supplied table of PVRs looking for two things\n\n * 1. Is our real CPU PVR in the list?\n\n * 2. What's the \"best\" listed logical PVR\n\n */\n\n for (i = 0; i < 512; ++i) {\n\n uint32_t pvr, pvr_mask;\n\n\n\n pvr_mask = ldl_be_phys(&address_space_memory, *addr);\n\n pvr = ldl_be_phys(&address_space_memory, *addr + 4);\n\n *addr += 8;\n\n\n\n if (~pvr_mask & pvr) {\n\n break; /* Terminator record */\n\n }\n\n\n\n if ((cpu->env.spr[SPR_PVR] & pvr_mask) == (pvr & pvr_mask)) {\n\n explicit_match = true;\n\n } else {\n\n if (ppc_check_compat(cpu, pvr, best_compat, max_compat)) {\n\n best_compat = pvr;\n\n }\n\n }\n\n }\n\n\n\n if ((best_compat == 0) && (!explicit_match || max_compat)) {\n\n /* We couldn't find a suitable compatibility mode, and either\n\n * the guest doesn't support \"raw\" mode for this CPU, or raw\n\n * mode is disabled because a maximum compat mode is set */\n\n error_setg(errp, \"Couldn't negotiate a suitable PVR during CAS\");\n\n return 0;\n\n }\n\n\n\n /* Parsing finished */\n\n trace_spapr_cas_pvr(cpu->compat_pvr, explicit_match, best_compat);\n\n\n\n return best_compat;\n\n}\n", + "output": "1", + "index": 4733 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int slirp_is_inited(void)\n\n{\n\n return slirp_inited;\n\n}\n", + "output": "0", + "index": 1100 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nic_reset(void *opaque)\n\n{\n\n EEPRO100State *s = opaque;\n\n TRACE(OTHER, logout(\"%p\\n\", s));\n\n /* TODO: Clearing of multicast table for selective reset, too? */\n\n memset(&s->mult[0], 0, sizeof(s->mult));\n\n nic_selective_reset(s);\n\n}\n", + "output": "1", + "index": 24970 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int http_open(URLContext *h, const char *uri, int flags)\n\n{\n\n HTTPContext *s = h->priv_data;\n\n\n\n h->is_streamed = 1;\n\n\n\n s->filesize = -1;\n\n av_strlcpy(s->location, uri, sizeof(s->location));\n\n\n\n if (s->headers) {\n\n int len = strlen(s->headers);\n\n if (len < 2 || strcmp(\"\\r\\n\", s->headers + len - 2))\n\n av_log(h, AV_LOG_WARNING, \"No trailing CRLF found in HTTP header.\\n\");\n\n }\n\n\n\n return http_open_cnx(h);\n\n}\n", + "output": "0", + "index": 25945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int cpu_sparc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,\n\n int mmu_idx, int is_softmmu)\n\n{\n\n target_ulong virt_addr, vaddr;\n\n target_phys_addr_t paddr;\n\n int error_code = 0, prot, ret = 0, access_index;\n\n\n\n error_code = get_physical_address(env, &paddr, &prot, &access_index,\n\n address, rw, mmu_idx);\n\n if (error_code == 0) {\n\n virt_addr = address & TARGET_PAGE_MASK;\n\n vaddr = virt_addr + ((address & TARGET_PAGE_MASK) &\n\n (TARGET_PAGE_SIZE - 1));\n\n#ifdef DEBUG_MMU\n\n printf(\"Translate at 0x%\" PRIx64 \" -> 0x%\" PRIx64 \", vaddr 0x%\" PRIx64\n\n \"\\n\", address, paddr, vaddr);\n\n#endif\n\n ret = tlb_set_page_exec(env, vaddr, paddr, prot, mmu_idx, is_softmmu);\n\n return ret;\n\n }\n\n // XXX\n\n return 1;\n\n}\n", + "output": "0", + "index": 20241 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_log_stop(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n /* FIXME: implement */\n\n}\n", + "output": "0", + "index": 5283 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_log_start(CPUPhysMemoryClient *client,\n\n target_phys_addr_t phys_addr, ram_addr_t size)\n\n{\n\n return kvm_dirty_pages_log_change(phys_addr, size, true);\n\n}\n", + "output": "1", + "index": 26289 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "virtio_crypto_check_cryptodev_is_used(const Object *obj, const char *name,\n\n Object *val, Error **errp)\n\n{\n\n if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(val))) {\n\n char *path = object_get_canonical_path_component(val);\n\n error_setg(errp,\n\n \"can't use already used cryptodev backend: %s\", path);\n\n g_free(path);\n\n } else {\n\n qdev_prop_allow_set_link_before_realize(obj, name, val, errp);\n\n }\n\n}\n", + "output": "0", + "index": 14276 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_sem_post(QemuSemaphore *sem)\n\n{\n\n int rc;\n\n\n\n#if defined(__APPLE__) || defined(__NetBSD__)\n\n pthread_mutex_lock(&sem->lock);\n\n if (sem->count == INT_MAX) {\n\n rc = EINVAL;\n\n } else if (sem->count++ < 0) {\n\n rc = pthread_cond_signal(&sem->cond);\n\n } else {\n\n rc = 0;\n\n }\n\n pthread_mutex_unlock(&sem->lock);\n\n if (rc != 0) {\n\n error_exit(rc, __func__);\n\n }\n\n#else\n\n rc = sem_post(&sem->sem);\n\n if (rc < 0) {\n\n error_exit(errno, __func__);\n\n }\n\n#endif\n\n}\n", + "output": "1", + "index": 7605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qio_channel_socket_connect_async(QIOChannelSocket *ioc,\n\n SocketAddress *addr,\n\n QIOTaskFunc callback,\n\n gpointer opaque,\n\n GDestroyNotify destroy)\n\n{\n\n QIOTask *task = qio_task_new(\n\n OBJECT(ioc), callback, opaque, destroy);\n\n SocketAddress *addrCopy;\n\n\n\n addrCopy = QAPI_CLONE(SocketAddress, addr);\n\n\n\n /* socket_connect() does a non-blocking connect(), but it\n\n * still blocks in DNS lookups, so we must use a thread */\n\n trace_qio_channel_socket_connect_async(ioc, addr);\n\n qio_task_run_in_thread(task,\n\n qio_channel_socket_connect_worker,\n\n addrCopy,\n\n (GDestroyNotify)qapi_free_SocketAddress);\n\n}\n", + "output": "0", + "index": 12882 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)\n\n{\n\n IscsiLun *iscsilun = bs->opaque;\n\n struct IscsiTask iTask;\n\n\n\n if (bs->sg) {\n\n return 0;\n\n }\n\n\n\n if (!iscsilun->force_next_flush) {\n\n return 0;\n\n }\n\n iscsilun->force_next_flush = false;\n\n\n\n iscsi_co_init_iscsitask(iscsilun, &iTask);\n\nretry:\n\n if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,\n\n 0, iscsi_co_generic_cb, &iTask) == NULL) {\n\n return -ENOMEM;\n\n }\n\n\n\n while (!iTask.complete) {\n\n iscsi_set_events(iscsilun);\n\n qemu_coroutine_yield();\n\n }\n\n\n\n if (iTask.task != NULL) {\n\n scsi_free_scsi_task(iTask.task);\n\n iTask.task = NULL;\n\n }\n\n\n\n if (iTask.do_retry) {\n\n iTask.complete = 0;\n\n goto retry;\n\n }\n\n\n\n if (iTask.status != SCSI_STATUS_GOOD) {\n\n return -EIO;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 1893 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pcnet_h_reset(void *opaque)\n\n{\n\n PCNetState *s = opaque;\n\n int i;\n\n uint16_t checksum;\n\n\n\n /* Initialize the PROM */\n\n\n\n\n\n\n\n memcpy(s->prom, s->conf.macaddr.a, 6);\n\n\n\n\n\n\n\n\n\n\n\n s->prom[12] = s->prom[13] = 0x00;\n\n\n\n s->prom[14] = s->prom[15] = 0x57;\n\n\n\n for (i = 0,checksum = 0; i < 16; i++)\n\n checksum += s->prom[i];\n\n *(uint16_t *)&s->prom[12] = cpu_to_le16(checksum);\n\n\n\n\n\n s->bcr[BCR_MSRDA] = 0x0005;\n\n s->bcr[BCR_MSWRA] = 0x0005;\n\n s->bcr[BCR_MC ] = 0x0002;\n\n s->bcr[BCR_LNKST] = 0x00c0;\n\n s->bcr[BCR_LED1 ] = 0x0084;\n\n s->bcr[BCR_LED2 ] = 0x0088;\n\n s->bcr[BCR_LED3 ] = 0x0090;\n\n s->bcr[BCR_FDC ] = 0x0000;\n\n s->bcr[BCR_BSBC ] = 0x9001;\n\n s->bcr[BCR_EECAS] = 0x0002;\n\n s->bcr[BCR_SWS ] = 0x0200;\n\n s->bcr[BCR_PLAT ] = 0xff06;\n\n\n\n pcnet_s_reset(s);\n\n pcnet_update_irq(s);\n\n pcnet_poll_timer(s);\n\n}", + "output": "1", + "index": 3144 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_para_features(CPUState *env)\n\n{\n\n int i, features = 0;\n\n\n\n for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {\n\n if (kvm_check_extension(env->kvm_state, para_features[i].cap))\n\n features |= (1 << para_features[i].feature);\n\n }\n\n\n\n return features;\n\n}\n", + "output": "0", + "index": 7084 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)\n\n{\n\n int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi;\n\n int num_blocks = s->coded_fragment_list_index;\n\n\n\n for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) {\n\n i = blocks_decoded = num_blocks_at_qpi = 0;\n\n\n\n bit = get_bits1(gb);\n\n\n\n do {\n\n run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1;\n\n if (run_length == 34)\n\n run_length += get_bits(gb, 12);\n\n blocks_decoded += run_length;\n\n\n\n if (!bit)\n\n num_blocks_at_qpi += run_length;\n\n\n\n for (j = 0; j < run_length; i++) {\n\n if (i > s->coded_fragment_list_index)\n\n return -1;\n\n\n\n if (s->all_fragments[s->coded_fragment_list[i]].qpi == qpi) {\n\n s->all_fragments[s->coded_fragment_list[i]].qpi += bit;\n\n j++;\n\n }\n\n }\n\n\n\n if (run_length == 4129)\n\n bit = get_bits1(gb);\n\n else\n\n bit ^= 1;\n\n } while (blocks_decoded < num_blocks);\n\n\n\n num_blocks -= num_blocks_at_qpi;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 7249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void monitor_disas(Monitor *mon, CPUState *cpu,\n\n target_ulong pc, int nb_insn, int is_physical)\n\n{\n\n CPUClass *cc = CPU_GET_CLASS(cpu);\n\n int count, i;\n\n CPUDebug s;\n\n\n\n INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);\n\n\n\n s.cpu = cpu;\n\n monitor_disas_is_physical = is_physical;\n\n s.info.read_memory_func = monitor_read_memory;\n\n s.info.print_address_func = generic_print_address;\n\n s.info.buffer_vma = pc;\n\n s.info.cap_arch = -1;\n\n s.info.cap_mode = 0;\n\n\n\n#ifdef TARGET_WORDS_BIGENDIAN\n\n s.info.endian = BFD_ENDIAN_BIG;\n\n#else\n\n s.info.endian = BFD_ENDIAN_LITTLE;\n\n#endif\n\n\n\n if (cc->disas_set_info) {\n\n cc->disas_set_info(cpu, &s.info);\n\n }\n\n\n\n if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) {\n\n return;\n\n }\n\n\n\n if (!s.info.print_insn) {\n\n monitor_printf(mon, \"0x\" TARGET_FMT_lx\n\n \": Asm output not supported on this arch\\n\", pc);\n\n return;\n\n }\n\n\n\n for(i = 0; i < nb_insn; i++) {\n\n\tmonitor_printf(mon, \"0x\" TARGET_FMT_lx \": \", pc);\n\n count = s.info.print_insn(pc, &s.info);\n\n\tmonitor_printf(mon, \"\\n\");\n\n\tif (count < 0)\n\n\t break;\n\n pc += count;\n\n }\n\n}\n", + "output": "1", + "index": 17869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "offset_t url_filesize(URLContext *h)\n\n{\n\n offset_t pos, size;\n\n\n\n size= url_seek(h, 0, AVSEEK_SIZE);\n\n if(size<0){\n\n pos = url_seek(h, 0, SEEK_CUR);\n\n size = url_seek(h, -1, SEEK_END)+1;\n\n url_seek(h, pos, SEEK_SET);\n\n }\n\n return size;\n\n}\n", + "output": "0", + "index": 7275 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_proc_460 (CPUPPCState *env)\n\n{\n\n /* Time base */\n\n gen_tbl(env);\n\n gen_spr_BookE(env);\n\n gen_spr_440(env);\n\n spr_register(env, SPR_BOOKE_MCSR, \"MCSR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n spr_register(env, SPR_BOOKE_MCSRR0, \"MCSRR0\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n spr_register(env, SPR_BOOKE_MCSRR1, \"MCSRR1\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n spr_register(env, SPR_440_CCR1, \"CCR1\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n spr_register(env, SPR_DCRIPR, \"SPR_DCRIPR\",\n\n &spr_read_generic, &spr_write_generic,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n /* Memory management */\n\n env->nb_tlb = 64;\n\n env->nb_ways = 1;\n\n env->id_tlbs = 0;\n\n /* XXX: TODO: allocate internal IRQ controller */\n\n}\n", + "output": "0", + "index": 20219 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t bonito_readl(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n PCIBonitoState *s = opaque;\n\n uint32_t saddr;\n\n\n\n saddr = (addr - BONITO_REGBASE) >> 2;\n\n\n\n DPRINTF(\"bonito_readl \"TARGET_FMT_plx\"\\n\", addr);\n\n switch (saddr) {\n\n case BONITO_INTISR:\n\n return s->regs[saddr];\n\n default:\n\n return s->regs[saddr];\n\n }\n\n}\n", + "output": "0", + "index": 26074 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_logicq_cc(TCGv_i64 val)\n\n{\n\n TCGv tmp = new_tmp();\n\n gen_helper_logicq_cc(tmp, val);\n\n gen_logic_CC(tmp);\n\n dead_tmp(tmp);\n\n}\n", + "output": "1", + "index": 7190 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_create_nvram(sPAPREnvironment *spapr)\n\n{\n\n DeviceState *dev = qdev_create(&spapr->vio_bus->bus, \"spapr-nvram\");\n\n DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);\n\n\n\n if (dinfo) {\n\n qdev_prop_set_drive_nofail(dev, \"drive\",\n\n blk_bs(blk_by_legacy_dinfo(dinfo)));\n\n }\n\n\n\n qdev_init_nofail(dev);\n\n\n\n spapr->nvram = (struct sPAPRNVRAM *)dev;\n\n}\n", + "output": "0", + "index": 9967 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usbredir_get_bufpq(QEMUFile *f, void *priv, size_t unused)\n\n{\n\n struct endp_data *endp = priv;\n\n USBRedirDevice *dev = endp->dev;\n\n struct buf_packet *bufp;\n\n int i;\n\n\n\n endp->bufpq_size = qemu_get_be32(f);\n\n for (i = 0; i < endp->bufpq_size; i++) {\n\n bufp = g_malloc(sizeof(struct buf_packet));\n\n bufp->len = qemu_get_be32(f);\n\n bufp->status = qemu_get_be32(f);\n\n bufp->offset = 0;\n\n bufp->data = qemu_oom_check(malloc(bufp->len)); /* regular malloc! */\n\n bufp->free_on_destroy = bufp->data;\n\n qemu_get_buffer(f, bufp->data, bufp->len);\n\n QTAILQ_INSERT_TAIL(&endp->bufpq, bufp, next);\n\n DPRINTF(\"get_bufpq %d/%d len %d status %d\\n\", i + 1, endp->bufpq_size,\n\n bufp->len, bufp->status);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 3246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pte_check_hash32(struct mmu_ctx_hash32 *ctx, target_ulong pte0,\n\n target_ulong pte1, int h, int rw, int type)\n\n{\n\n target_ulong mmask;\n\n int access, ret, pp;\n\n\n\n ret = -1;\n\n /* Check validity and table match */\n\n if ((pte0 & HPTE32_V_VALID) && (h == !!(pte0 & HPTE32_V_SECONDARY))) {\n\n /* Check vsid & api */\n\n mmask = PTE_CHECK_MASK;\n\n pp = pte1 & HPTE32_R_PP;\n\n if (HPTE32_V_COMPARE(pte0, ctx->ptem)) {\n\n if (ctx->raddr != (hwaddr)-1ULL) {\n\n /* all matches should have equal RPN, WIMG & PP */\n\n if ((ctx->raddr & mmask) != (pte1 & mmask)) {\n\n qemu_log(\"Bad RPN/WIMG/PP\\n\");\n\n return -3;\n\n }\n\n }\n\n /* Compute access rights */\n\n access = ppc_hash32_pp_check(ctx->key, pp, ctx->nx);\n\n /* Keep the matching PTE informations */\n\n ctx->raddr = pte1;\n\n ctx->prot = access;\n\n ret = ppc_hash32_check_prot(ctx->prot, rw, type);\n\n if (ret == 0) {\n\n /* Access granted */\n\n LOG_MMU(\"PTE access granted !\\n\");\n\n } else {\n\n /* Access right violation */\n\n LOG_MMU(\"PTE access rejected\\n\");\n\n }\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 1172 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_quantization(Jpeg2000EncoderContext *s)\n\n{\n\n int compno, reslevelno, bandno;\n\n Jpeg2000QuantStyle *qntsty = &s->qntsty;\n\n Jpeg2000CodingStyle *codsty = &s->codsty;\n\n\n\n for (compno = 0; compno < s->ncomponents; compno++){\n\n int gbandno = 0;\n\n for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){\n\n int nbands, lev = codsty->nreslevels - reslevelno - 1;\n\n nbands = reslevelno ? 3 : 1;\n\n for (bandno = 0; bandno < nbands; bandno++, gbandno++){\n\n int expn, mant;\n\n\n\n if (codsty->transform == FF_DWT97){\n\n int bandpos = bandno + (reslevelno>0),\n\n ss = 81920000 / dwt_norms[0][bandpos][lev],\n\n log = av_log2(ss);\n\n mant = (11 - log < 0 ? ss >> log - 11 : ss << 11 - log) & 0x7ff;\n\n expn = s->cbps[compno] - log + 13;\n\n } else\n\n expn = ((bandno&2)>>1) + (reslevelno>0) + s->cbps[compno];\n\n\n\n qntsty->expn[gbandno] = expn;\n\n qntsty->mant[gbandno] = mant;\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 1757 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int GetCode(GifState * s)\n\n{\n\n int c, sizbuf;\n\n uint8_t *ptr;\n\n\n\n while (s->bbits < s->cursize) {\n\n ptr = s->pbuf;\n\n if (ptr >= s->ebuf) {\n\n if (!s->eob_reached) {\n\n sizbuf = get_byte(s->f);\n\n s->ebuf = s->buf + sizbuf;\n\n s->pbuf = s->buf;\n\n if (sizbuf > 0) {\n\n get_buffer(s->f, s->buf, sizbuf);\n\n } else {\n\n s->eob_reached = 1;\n\n }\n\n }\n\n ptr = s->pbuf;\n\n }\n\n s->bbuf |= ptr[0] << s->bbits;\n\n ptr++;\n\n s->pbuf = ptr;\n\n s->bbits += 8;\n\n }\n\n c = s->bbuf & s->curmask;\n\n s->bbuf >>= s->cursize;\n\n s->bbits -= s->cursize;\n\n return c;\n\n}\n", + "output": "1", + "index": 13318 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unterminated_dict(void)\n\n{\n\n QObject *obj = qobject_from_json(\"{'abc':32\", NULL);\n\n g_assert(obj == NULL);\n\n}\n", + "output": "1", + "index": 21973 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int add_crc_to_array(uint32_t crc, int64_t pts)\n\n{\n\n if (size_of_array <= number_of_elements) {\n\n if (size_of_array == 0)\n\n size_of_array = 10;\n\n size_of_array *= 2;\n\n crc_array = av_realloc(crc_array, size_of_array * sizeof(uint32_t));\n\n pts_array = av_realloc(pts_array, size_of_array * sizeof(int64_t));\n\n if ((crc_array == NULL) || (pts_array == NULL)) {\n\n av_log(NULL, AV_LOG_ERROR, \"Can't allocate array to store crcs\\n\");\n\n return AVERROR(ENOMEM);\n\n }\n\n }\n\n crc_array[number_of_elements] = crc;\n\n pts_array[number_of_elements] = pts;\n\n number_of_elements++;\n\n return 0;\n\n}\n", + "output": "1", + "index": 26212 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int prepare_packet(AVPacket *pkt,const FailingMuxerPacketData *pkt_data, int64_t pts)\n\n{\n\n int ret;\n\n FailingMuxerPacketData *data = av_malloc(sizeof(*data));\n\n\n\n\n memcpy(data, pkt_data, sizeof(FailingMuxerPacketData));\n\n ret = av_packet_from_data(pkt, (uint8_t*) data, sizeof(*data));\n\n\n\n pkt->pts = pkt->dts = pts;\n\n pkt->duration = 1;\n\n\n\n return ret;\n", + "output": "1", + "index": 10520 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_check_reservation_64 (void)\n\n{\n\n if ((uint64_t)env->reserve == (uint64_t)(T0 & ~0x00000003))\n\n env->reserve = -1;\n\n RETURN();\n\n}\n", + "output": "1", + "index": 25867 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "setup_sigcontext(struct target_sigcontext *sc, struct target_fpstate *fpstate,\n\n\t\t CPUX86State *env, abi_ulong mask, abi_ulong fpstate_addr)\n\n{\n\n CPUState *cs = CPU(x86_env_get_cpu(env));\n\n int err = 0;\n\n uint16_t magic;\n\n\n\n\t/* already locked in setup_frame() */\n\n __put_user(env->segs[R_GS].selector, (unsigned int *)&sc->gs);\n\n __put_user(env->segs[R_FS].selector, (unsigned int *)&sc->fs);\n\n __put_user(env->segs[R_ES].selector, (unsigned int *)&sc->es);\n\n __put_user(env->segs[R_DS].selector, (unsigned int *)&sc->ds);\n\n __put_user(env->regs[R_EDI], &sc->edi);\n\n __put_user(env->regs[R_ESI], &sc->esi);\n\n __put_user(env->regs[R_EBP], &sc->ebp);\n\n __put_user(env->regs[R_ESP], &sc->esp);\n\n __put_user(env->regs[R_EBX], &sc->ebx);\n\n __put_user(env->regs[R_EDX], &sc->edx);\n\n __put_user(env->regs[R_ECX], &sc->ecx);\n\n __put_user(env->regs[R_EAX], &sc->eax);\n\n __put_user(cs->exception_index, &sc->trapno);\n\n __put_user(env->error_code, &sc->err);\n\n __put_user(env->eip, &sc->eip);\n\n __put_user(env->segs[R_CS].selector, (unsigned int *)&sc->cs);\n\n __put_user(env->eflags, &sc->eflags);\n\n __put_user(env->regs[R_ESP], &sc->esp_at_signal);\n\n __put_user(env->segs[R_SS].selector, (unsigned int *)&sc->ss);\n\n\n\n cpu_x86_fsave(env, fpstate_addr, 1);\n\n fpstate->status = fpstate->sw;\n\n magic = 0xffff;\n\n __put_user(magic, &fpstate->magic);\n\n __put_user(fpstate_addr, &sc->fpstate);\n\n\n\n\t/* non-iBCS2 extensions.. */\n\n __put_user(mask, &sc->oldmask);\n\n __put_user(env->cr[2], &sc->cr2);\n\n\treturn err;\n\n}\n", + "output": "0", + "index": 8931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void serial_receive_byte(SerialState *s, int ch)\n\n{\n\n s->rbr = ch;\n\n s->lsr |= UART_LSR_DR;\n\n serial_update_irq(s);\n\n}\n", + "output": "1", + "index": 17174 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)\n\n{\n\n OggVorbisContext *s = avctx->priv_data;\n\n\n\n /* notify vorbisenc this is EOF */\n\n vorbis_analysis_wrote(&s->vd, 0);\n\n\n\n vorbis_block_clear(&s->vb);\n\n vorbis_dsp_clear(&s->vd);\n\n vorbis_info_clear(&s->vi);\n\n\n\n av_freep(&avctx->coded_frame);\n\n av_freep(&avctx->extradata);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 7551 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri,\n\n uint64_t value)\n\n{\n\n ARMCPU *cpu = arm_env_get_cpu(env);\n\n\n\n /* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */\n\n tlb_flush(CPU(cpu), 1);\n\n env->cp15.c2_control = value;\n\n}\n", + "output": "0", + "index": 9304 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int compand_drain(AVFilterLink *outlink)\n\n{\n\n AVFilterContext *ctx = outlink->src;\n\n CompandContext *s = ctx->priv;\n\n const int channels = outlink->channels;\n\n AVFrame *frame = NULL;\n\n int chan, i, dindex;\n\n\n\n /* 2048 is to limit output frame size during drain */\n\n frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->delay_count));\n\n if (!frame)\n\n return AVERROR(ENOMEM);\n\n frame->pts = s->pts;\n\n s->pts += av_rescale_q(frame->nb_samples,\n\n (AVRational){ 1, outlink->sample_rate }, outlink->time_base);\n\n\n\n\n for (chan = 0; chan < channels; chan++) {\n\n AVFrame *delay_frame = s->delay_frame;\n\n double *dbuf = (double *)delay_frame->extended_data[chan];\n\n double *dst = (double *)frame->extended_data[chan];\n\n ChanParam *cp = &s->channels[chan];\n\n\n\n dindex = s->delay_index;\n\n for (i = 0; i < frame->nb_samples; i++) {\n\n dst[i] = av_clipd(dbuf[dindex] * get_volume(s, cp->volume),\n\n -1, 1);\n\n dindex = MOD(dindex + 1, s->delay_samples);\n\n }\n\n }\n\n s->delay_count -= frame->nb_samples;\n\n s->delay_index = dindex;\n\n\n\n return ff_filter_frame(outlink, frame);\n\n}", + "output": "1", + "index": 25489 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_int16(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n DeviceState *dev = DEVICE(obj);\n\n Property *prop = opaque;\n\n int16_t *ptr = qdev_get_prop_ptr(dev, prop);\n\n Error *local_err = NULL;\n\n int64_t value;\n\n\n\n if (dev->state != DEV_STATE_CREATED) {\n\n error_set(errp, QERR_PERMISSION_DENIED);\n\n return;\n\n }\n\n\n\n visit_type_int(v, &value, name, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n if (value > prop->info->min && value <= prop->info->max) {\n\n *ptr = value;\n\n } else {\n\n error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,\n\n dev->id?:\"\", name, value, prop->info->min,\n\n prop->info->max);\n\n }\n\n}\n", + "output": "1", + "index": 20168 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void clr_msg_flags(IPMIBmcSim *ibs,\n\n uint8_t *cmd, unsigned int cmd_len,\n\n uint8_t *rsp, unsigned int *rsp_len,\n\n unsigned int max_rsp_len)\n\n{\n\n IPMIInterface *s = ibs->parent.intf;\n\n IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);\n\n\n\n IPMI_CHECK_CMD_LEN(3);\n\n ibs->msg_flags &= ~cmd[2];\n\n k->set_atn(s, attn_set(ibs), attn_irq_enabled(ibs));\n\n}\n", + "output": "1", + "index": 24613 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_rle_sgi(uint8_t *out_buf, SgiState *s)\n\n{\n\n uint8_t *dest_row;\n\n unsigned int len = s->height * s->depth * 4;\n\n GetByteContext g_table = s->g;\n\n unsigned int y, z;\n\n unsigned int start_offset;\n\n\n\n /* size of RLE offset and length tables */\n\n if (len * 2 > bytestream2_get_bytes_left(&s->g)) {\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n for (z = 0; z < s->depth; z++) {\n\n dest_row = out_buf;\n\n for (y = 0; y < s->height; y++) {\n\n dest_row -= s->linesize;\n\n start_offset = bytestream2_get_be32(&g_table);\n\n bytestream2_seek(&s->g, start_offset, SEEK_SET);\n\n if (expand_rle_row(s, dest_row + z, dest_row + FFABS(s->linesize),\n\n s->depth) != s->width) {\n\n return AVERROR_INVALIDDATA;\n\n }\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 5329 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int huff_build12(VLC *vlc, uint8_t *len)\n\n{\n\n HuffEntry he[4096];\n\n uint32_t codes[4096];\n\n uint8_t bits[4096];\n\n uint16_t syms[4096];\n\n uint32_t code;\n\n int i;\n\n\n\n for (i = 0; i < 4096; i++) {\n\n he[i].sym = 4095 - i;\n\n he[i].len = len[i];\n\n if (len[i] == 0)\n\n return AVERROR_INVALIDDATA;\n\n }\n\n AV_QSORT(he, 4096, HuffEntry, huff_cmp_len12);\n\n\n\n code = 1;\n\n for (i = 4095; i >= 0; i--) {\n\n codes[i] = code >> (32 - he[i].len);\n\n bits[i] = he[i].len;\n\n syms[i] = he[i].sym;\n\n code += 0x80000000u >> (he[i].len - 1);\n\n }\n\n\n\n ff_free_vlc(vlc);\n\n return ff_init_vlc_sparse(vlc, FFMIN(he[4095].len, 14), 4096,\n\n bits, sizeof(*bits), sizeof(*bits),\n\n codes, sizeof(*codes), sizeof(*codes),\n\n syms, sizeof(*syms), sizeof(*syms), 0);\n\n}\n", + "output": "1", + "index": 23664 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static DisplaySurface* sdl_create_displaysurface(int width, int height)\n\n{\n\n DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));\n\n if (surface == NULL) {\n\n fprintf(stderr, \"sdl_create_displaysurface: malloc failed\\n\");\n\n exit(1);\n\n }\n\n\n\n surface->width = width;\n\n surface->height = height;\n\n\n\n if (scaling_active) {\n\n int linesize;\n\n PixelFormat pf;\n\n if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) {\n\n linesize = width * 4;\n\n pf = qemu_default_pixelformat(32);\n\n } else {\n\n linesize = width * host_format.BytesPerPixel;\n\n pf = sdl_to_qemu_pixelformat(&host_format);\n\n }\n\n qemu_alloc_display(surface, width, height, linesize, pf, 0);\n\n return surface;\n\n }\n\n\n\n if (host_format.BitsPerPixel == 16)\n\n do_sdl_resize(width, height, 16);\n\n else\n\n do_sdl_resize(width, height, 32);\n\n\n\n surface->pf = sdl_to_qemu_pixelformat(real_screen->format);\n\n surface->linesize = real_screen->pitch;\n\n surface->data = real_screen->pixels;\n\n\n\n#ifdef HOST_WORDS_BIGENDIAN\n\n surface->flags = QEMU_REALPIXELS_FLAG | QEMU_BIG_ENDIAN_FLAG;\n\n#else\n\n surface->flags = QEMU_REALPIXELS_FLAG;\n\n#endif\n\n allocator = 1;\n\n\n\n return surface;\n\n}\n", + "output": "1", + "index": 25880 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void compute_rematrixing_strategy(AC3EncodeContext *s)\n\n{\n\n int nb_coefs;\n\n int blk, bnd, i;\n\n AC3Block *block, *block0;\n\n\n\n s->num_rematrixing_bands = 4;\n\n\n\n if (s->rematrixing & AC3_REMATRIXING_IS_STATIC)\n\n return;\n\n\n\n nb_coefs = FFMIN(s->nb_coefs[0], s->nb_coefs[1]);\n\n\n\n for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {\n\n block = &s->blocks[blk];\n\n block->new_rematrixing_strategy = !blk;\n\n for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) {\n\n /* calculate calculate sum of squared coeffs for one band in one block */\n\n int start = ff_ac3_rematrix_band_tab[bnd];\n\n int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);\n\n CoefSumType sum[4] = {0,};\n\n for (i = start; i < end; i++) {\n\n CoefType lt = block->mdct_coef[0][i];\n\n CoefType rt = block->mdct_coef[1][i];\n\n CoefType md = lt + rt;\n\n CoefType sd = lt - rt;\n\n sum[0] += lt * lt;\n\n sum[1] += rt * rt;\n\n sum[2] += md * md;\n\n sum[3] += sd * sd;\n\n }\n\n\n\n /* compare sums to determine if rematrixing will be used for this band */\n\n if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))\n\n block->rematrixing_flags[bnd] = 1;\n\n else\n\n block->rematrixing_flags[bnd] = 0;\n\n\n\n /* determine if new rematrixing flags will be sent */\n\n if (blk &&\n\n block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) {\n\n block->new_rematrixing_strategy = 1;\n\n }\n\n }\n\n block0 = block;\n\n }\n\n}\n", + "output": "1", + "index": 149 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool run_poll_handlers(AioContext *ctx, int64_t max_ns)\n\n{\n\n bool progress;\n\n int64_t end_time;\n\n\n\n assert(ctx->notify_me);\n\n assert(qemu_lockcnt_count(&ctx->list_lock) > 0);\n\n assert(ctx->poll_disable_cnt == 0);\n\n\n\n trace_run_poll_handlers_begin(ctx, max_ns);\n\n\n\n end_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + max_ns;\n\n\n\n do {\n\n progress = run_poll_handlers_once(ctx);\n\n } while (!progress && qemu_clock_get_ns(QEMU_CLOCK_REALTIME) < end_time);\n\n\n\n trace_run_poll_handlers_end(ctx, progress);\n\n\n\n return progress;\n\n}\n", + "output": "0", + "index": 1986 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_component(DiracContext *s, int comp)\n\n{\n\n AVCodecContext *avctx = s->avctx;\n\n SubBand *bands[3*MAX_DWT_LEVELS+1];\n\n enum dirac_subband orientation;\n\n int level, num_bands = 0;\n\n\n\n /* Unpack all subbands at all levels. */\n\n for (level = 0; level < s->wavelet_depth; level++) {\n\n for (orientation = !!level; orientation < 4; orientation++) {\n\n SubBand *b = &s->plane[comp].band[level][orientation];\n\n bands[num_bands++] = b;\n\n\n\n align_get_bits(&s->gb);\n\n /* [DIRAC_STD] 13.4.2 subband() */\n\n b->length = svq3_get_ue_golomb(&s->gb);\n\n if (b->length) {\n\n b->quant = svq3_get_ue_golomb(&s->gb);\n\n align_get_bits(&s->gb);\n\n b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;\n\n b->length = FFMIN(b->length, get_bits_left(&s->gb)/8);\n\n skip_bits_long(&s->gb, b->length*8);\n\n }\n\n }\n\n /* arithmetic coding has inter-level dependencies, so we can only execute one level at a time */\n\n if (s->is_arith)\n\n avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level],\n\n NULL, 4-!!level, sizeof(SubBand));\n\n }\n\n /* golomb coding has no inter-level dependencies, so we can execute all subbands in parallel */\n\n if (!s->is_arith)\n\n avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*));\n\n}\n", + "output": "1", + "index": 697 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_listener_region_del(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n VFIOContainer *container = container_of(listener, VFIOContainer,\n\n iommu_data.listener);\n\n hwaddr iova, end;\n\n int ret;\n\n\n\n if (vfio_listener_skipped_section(section)) {\n\n DPRINTF(\"SKIPPING region_del %\"HWADDR_PRIx\" - %\"PRIx64\"\\n\",\n\n section->offset_within_address_space,\n\n section->offset_within_address_space + section->size - 1);\n\n return;\n\n }\n\n\n\n if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) !=\n\n (section->offset_within_region & ~TARGET_PAGE_MASK))) {\n\n error_report(\"%s received unaligned region\", __func__);\n\n return;\n\n }\n\n\n\n iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);\n\n end = (section->offset_within_address_space + int128_get64(section->size)) &\n\n TARGET_PAGE_MASK;\n\n\n\n if (iova >= end) {\n\n return;\n\n }\n\n\n\n DPRINTF(\"region_del %\"HWADDR_PRIx\" - %\"HWADDR_PRIx\"\\n\",\n\n iova, end - 1);\n\n\n\n ret = vfio_dma_unmap(container, iova, end - iova);\n\n memory_region_unref(section->mr);\n\n if (ret) {\n\n error_report(\"vfio_dma_unmap(%p, 0x%\"HWADDR_PRIx\", \"\n\n \"0x%\"HWADDR_PRIx\") = %d (%m)\",\n\n container, iova, end - iova, ret);\n\n }\n\n}\n", + "output": "1", + "index": 26213 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_compat_1_4(QEMUMachineInitArgs *args)\n\n{\n\n pc_compat_1_5(args);\n\n has_pvpanic = false;\n\n x86_cpu_compat_set_features(\"n270\", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);\n\n x86_cpu_compat_set_features(\"Westmere\", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);\n\n}\n", + "output": "1", + "index": 21967 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mips_cpu_initfn(Object *obj)\n\n{\n\n CPUState *cs = CPU(obj);\n\n MIPSCPU *cpu = MIPS_CPU(obj);\n\n CPUMIPSState *env = &cpu->env;\n\n\n\n cs->env_ptr = env;\n\n cpu_exec_init(cs, &error_abort);\n\n\n\n if (tcg_enabled()) {\n\n mips_tcg_init();\n\n }\n\n}\n", + "output": "1", + "index": 1456 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,\n int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)\n{\n BlockDriver *drv = bs->drv;\n BdrvTrackedRequest req;\n int ret;\n if (!drv) {\n return -ENOMEDIUM;\n if (bdrv_check_request(bs, sector_num, nb_sectors)) {\n return -EIO;\n /* throttling disk read I/O */\n if (bs->io_limits_enabled) {\n bdrv_io_limits_intercept(bs, false, nb_sectors);\n tracked_request_begin(&req, bs, sector_num, nb_sectors, false);\n ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);\n tracked_request_end(&req);\n return ret;", + "output": "1", + "index": 20700 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_fcmpo(CPUPPCState *env, uint64_t arg1, uint64_t arg2,\n\n uint32_t crfD)\n\n{\n\n CPU_DoubleU farg1, farg2;\n\n uint32_t ret = 0;\n\n\n\n farg1.ll = arg1;\n\n farg2.ll = arg2;\n\n\n\n if (unlikely(float64_is_any_nan(farg1.d) ||\n\n float64_is_any_nan(farg2.d))) {\n\n ret = 0x01UL;\n\n } else if (float64_lt(farg1.d, farg2.d, &env->fp_status)) {\n\n ret = 0x08UL;\n\n } else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) {\n\n ret = 0x04UL;\n\n } else {\n\n ret = 0x02UL;\n\n }\n\n\n\n env->fpscr &= ~(0x0F << FPSCR_FPRF);\n\n env->fpscr |= ret << FPSCR_FPRF;\n\n env->crf[crfD] = ret;\n\n if (unlikely(ret == 0x01UL)) {\n\n if (float64_is_signaling_nan(farg1.d) ||\n\n float64_is_signaling_nan(farg2.d)) {\n\n /* sNaN comparison */\n\n fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN |\n\n POWERPC_EXCP_FP_VXVC);\n\n } else {\n\n /* qNaN comparison */\n\n fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXVC);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 14270 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static size_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb)\n\n{\n\n size_t offset = 0;\n\n ssize_t len;\n\n\n\n do {\n\n if (aiocb->aio_type == QEMU_PAIO_WRITE)\n\n len = qemu_pwritev(aiocb->aio_fildes,\n\n aiocb->aio_iov,\n\n aiocb->aio_niov,\n\n aiocb->aio_offset + offset);\n\n else\n\n len = qemu_preadv(aiocb->aio_fildes,\n\n aiocb->aio_iov,\n\n aiocb->aio_niov,\n\n aiocb->aio_offset + offset);\n\n } while (len == -1 && errno == EINTR);\n\n\n\n if (len == -1)\n\n return -errno;\n\n return len;\n\n}\n", + "output": "0", + "index": 24095 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rdma_get_fd(void *opaque)\n\n{\n\n QEMUFileRDMA *rfile = opaque;\n\n RDMAContext *rdma = rfile->rdma;\n\n\n\n return rdma->comp_channel->fd;\n\n}\n", + "output": "1", + "index": 7881 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_readline_printf(void *opaque, const char *fmt, ...)\n\n{\n\n va_list ap;\n\n va_start(ap, fmt);\n\n monitor_vprintf(opaque, fmt, ap);\n\n va_end(ap);\n\n}\n", + "output": "0", + "index": 7495 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void assert_file_overwrite(const char *filename)\n\n{\n\n if (file_overwrite && no_file_overwrite) {\n\n fprintf(stderr, \"Error, both -y and -n supplied. Exiting.\\n\");\n\n exit_program(1);\n\n }\n\n\n\n if (!file_overwrite &&\n\n (strchr(filename, ':') == NULL || filename[1] == ':' ||\n\n av_strstart(filename, \"file:\", NULL))) {\n\n if (avio_check(filename, 0) == 0) {\n\n if (stdin_interaction && !no_file_overwrite) {\n\n fprintf(stderr,\"File '%s' already exists. Overwrite ? [y/N] \", filename);\n\n fflush(stderr);\n\n term_exit();\n\n signal(SIGINT, SIG_DFL);\n\n if (!read_yesno()) {\n\n av_log(NULL, AV_LOG_FATAL, \"Not overwriting - exiting\\n\");\n\n exit_program(1);\n\n }\n\n term_init();\n\n }\n\n else {\n\n av_log(NULL, AV_LOG_FATAL, \"File '%s' already exists. Exiting.\\n\", filename);\n\n exit_program(1);\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 20184 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void console_refresh(QemuConsole *s)\n\n{\n\n DisplaySurface *surface = qemu_console_surface(s);\n\n TextCell *c;\n\n int x, y, y1;\n\n\n\n if (s->ds->have_text) {\n\n s->text_x[0] = 0;\n\n s->text_y[0] = 0;\n\n s->text_x[1] = s->width - 1;\n\n s->text_y[1] = s->height - 1;\n\n s->cursor_invalidate = 1;\n\n }\n\n\n\n vga_fill_rect(s, 0, 0, surface_width(surface), surface_height(surface),\n\n color_table_rgb[0][COLOR_BLACK]);\n\n y1 = s->y_displayed;\n\n for (y = 0; y < s->height; y++) {\n\n c = s->cells + y1 * s->width;\n\n for (x = 0; x < s->width; x++) {\n\n vga_putcharxy(s, x, y, c->ch,\n\n &(c->t_attrib));\n\n c++;\n\n }\n\n if (++y1 == s->total_height) {\n\n y1 = 0;\n\n }\n\n }\n\n console_show_cursor(s, 1);\n\n dpy_gfx_update(s, 0, 0,\n\n surface_width(surface), surface_height(surface));\n\n}\n", + "output": "0", + "index": 26807 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void compute_frame_duration(int *pnum, int *pden, AVStream *st,\n\n AVCodecParserContext *pc, AVPacket *pkt)\n\n{\n\n int frame_size;\n\n\n\n *pnum = 0;\n\n *pden = 0;\n\n switch(st->codec->codec_type) {\n\n case AVMEDIA_TYPE_VIDEO:\n\n if (st->r_frame_rate.num) {\n\n *pnum = st->r_frame_rate.den;\n\n *pden = st->r_frame_rate.num;\n\n } else if(st->time_base.num*1000LL > st->time_base.den) {\n\n *pnum = st->time_base.num;\n\n *pden = st->time_base.den;\n\n }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){\n\n *pnum = st->codec->time_base.num;\n\n *pden = st->codec->time_base.den;\n\n if (pc && pc->repeat_pict) {\n\n *pnum = (*pnum) * (1 + pc->repeat_pict);\n\n }\n\n //If this codec can be interlaced or progressive then we need a parser to compute duration of a packet\n\n //Thus if we have no parser in such case leave duration undefined.\n\n if(st->codec->ticks_per_frame>1 && !pc){\n\n *pnum = *pden = 0;\n\n }\n\n }\n\n break;\n\n case AVMEDIA_TYPE_AUDIO:\n\n frame_size = get_audio_frame_size(st->codec, pkt->size, 0);\n\n if (frame_size <= 0 || st->codec->sample_rate <= 0)\n\n break;\n\n *pnum = frame_size;\n\n *pden = st->codec->sample_rate;\n\n break;\n\n default:\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 18965 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void update_msix_table_msg_data(S390PCIBusDevice *pbdev, uint64_t offset,\n\n uint64_t *data, uint8_t len)\n\n{\n\n uint32_t val;\n\n uint8_t *msg_data;\n\n\n\n if (offset % PCI_MSIX_ENTRY_SIZE != 8) {\n\n return;\n\n }\n\n\n\n if (len != 4) {\n\n DPRINTF(\"access msix table msg data but len is %d\\n\", len);\n\n return;\n\n }\n\n\n\n msg_data = (uint8_t *)data - offset % PCI_MSIX_ENTRY_SIZE +\n\n PCI_MSIX_ENTRY_VECTOR_CTRL;\n\n val = pci_get_long(msg_data) | (pbdev->fid << ZPCI_MSI_VEC_BITS);\n\n pci_set_long(msg_data, val);\n\n DPRINTF(\"update msix msg_data to 0x%\" PRIx64 \"\\n\", *data);\n\n}\n", + "output": "1", + "index": 24948 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(stby_e)(CPUHPPAState *env, target_ulong addr, target_ulong val)\n\n{\n\n uintptr_t ra = GETPC();\n\n\n\n switch (addr & 3) {\n\n case 3:\n\n /* The 3 byte store must appear atomic. */\n\n if (parallel_cpus) {\n\n atomic_store_3(env, addr - 3, val, 0xffffff00u, ra);\n\n } else {\n\n cpu_stw_data_ra(env, addr - 3, val >> 16, ra);\n\n cpu_stb_data_ra(env, addr - 1, val >> 8, ra);\n\n }\n\n break;\n\n case 2:\n\n cpu_stw_data_ra(env, addr - 2, val >> 16, ra);\n\n break;\n\n case 1:\n\n cpu_stb_data_ra(env, addr - 1, val >> 24, ra);\n\n break;\n\n default:\n\n /* Nothing is stored, but protection is checked and the\n\n cacheline is marked dirty. */\n\n#ifndef CONFIG_USER_ONLY\n\n probe_write(env, addr, cpu_mmu_index(env, 0), ra);\n\n#endif\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 23743 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_channel_idx(char **map, int *ch, char delim, int max_ch)\n\n{\n\n char *next = split(*map, delim);\n\n int len;\n\n int n = 0;\n\n if (!next && delim == '-')\n\n return AVERROR(EINVAL);\n\n if (!*map)\n\n return AVERROR(EINVAL);\n\n len = strlen(*map);\n\n sscanf(*map, \"%d%n\", ch, &n);\n\n if (n != len)\n\n return AVERROR(EINVAL);\n\n if (*ch < 0 || *ch > max_ch)\n\n return AVERROR(EINVAL);\n\n *map = next;\n\n return 0;\n\n}\n", + "output": "0", + "index": 21114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)\n\n{\n\n sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);\n\n uint64_t tce;\n\n\n\n#ifdef DEBUG_TCE\n\n fprintf(stderr, \"spapr_tce_translate liobn=0x%\" PRIx32 \" addr=0x\"\n\n DMA_ADDR_FMT \"\\n\", tcet->liobn, addr);\n\n#endif\n\n\n\n if (tcet->bypass) {\n\n return (IOMMUTLBEntry) {\n\n .target_as = &address_space_memory,\n\n .iova = 0,\n\n .translated_addr = 0,\n\n .addr_mask = ~(hwaddr)0,\n\n .perm = IOMMU_RW,\n\n };\n\n }\n\n\n\n /* Check if we are in bound */\n\n if (addr >= tcet->window_size) {\n\n#ifdef DEBUG_TCE\n\n fprintf(stderr, \"spapr_tce_translate out of bounds\\n\");\n\n#endif\n\n return (IOMMUTLBEntry) { .perm = IOMMU_NONE };\n\n }\n\n\n\n tce = tcet->table[addr >> SPAPR_TCE_PAGE_SHIFT].tce;\n\n\n\n#ifdef DEBUG_TCE\n\n fprintf(stderr, \" -> *paddr=0x%llx, *len=0x%llx\\n\",\n\n (tce & ~SPAPR_TCE_PAGE_MASK), SPAPR_TCE_PAGE_MASK + 1);\n\n#endif\n\n\n\n return (IOMMUTLBEntry) {\n\n .target_as = &address_space_memory,\n\n .iova = addr & ~SPAPR_TCE_PAGE_MASK,\n\n .translated_addr = tce & ~SPAPR_TCE_PAGE_MASK,\n\n .addr_mask = SPAPR_TCE_PAGE_MASK,\n\n .perm = tce,\n\n };\n\n}\n", + "output": "0", + "index": 5293 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists)\n\n{\n\n QemuOpts *opts = NULL;\n\n\n\n if (id) {\n\n if (!id_wellformed(id)) {\n\n qerror_report(QERR_INVALID_PARAMETER_VALUE, \"id\", \"an identifier\");\n\n error_printf_unless_qmp(\"Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\\n\");\n\n return NULL;\n\n }\n\n opts = qemu_opts_find(list, id);\n\n if (opts != NULL) {\n\n if (fail_if_exists && !list->merge_lists) {\n\n qerror_report(QERR_DUPLICATE_ID, id, list->name);\n\n return NULL;\n\n } else {\n\n return opts;\n\n }\n\n }\n\n } else if (list->merge_lists) {\n\n opts = qemu_opts_find(list, NULL);\n\n if (opts) {\n\n return opts;\n\n }\n\n }\n\n opts = g_malloc0(sizeof(*opts));\n\n if (id) {\n\n opts->id = g_strdup(id);\n\n }\n\n opts->list = list;\n\n loc_save(&opts->loc);\n\n QTAILQ_INIT(&opts->head);\n\n QTAILQ_INSERT_TAIL(&list->head, opts, next);\n\n return opts;\n\n}\n", + "output": "1", + "index": 14243 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "float64 uint64_to_float64( uint64 a STATUS_PARAM )\n\n{\n\n if ( a == 0 ) return 0;\n\n return normalizeRoundAndPackFloat64( 0, 0x43C, a STATUS_VAR );\n\n\n\n}\n", + "output": "0", + "index": 19189 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qcrypto_tls_creds_x509_unload(QCryptoTLSCredsX509 *creds)\n\n{\n\n if (creds->data) {\n\n gnutls_certificate_free_credentials(creds->data);\n\n creds->data = NULL;\n\n\n\n\n\n", + "output": "1", + "index": 8609 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)\n\n{\n\n StreamBlockJob *s = container_of(job, StreamBlockJob, common);\n\n\n\n if (speed < 0) {\n\n error_setg(errp, QERR_INVALID_PARAMETER, \"speed\");\n\n return;\n\n }\n\n ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);\n\n}\n", + "output": "1", + "index": 22709 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int eth_can_rx(NetClientState *nc)\n\n{\n\n struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque;\n\n int r;\n\n r = !(s->regs[R_RX_CTRL0] & CTRL_S);\n\n return r;\n\n}\n", + "output": "0", + "index": 7763 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_wd_timer_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque;\n\n\n\n if (size != 2) {\n\n return omap_badwidth_write16(opaque, addr, value);\n\n }\n\n\n\n switch (addr) {\n\n case 0x00:\t/* CNTL_TIMER */\n\n omap_timer_sync(&s->timer);\n\n s->timer.ptv = (value >> 9) & 7;\n\n s->timer.ar = (value >> 8) & 1;\n\n s->timer.st = (value >> 7) & 1;\n\n s->free = (value >> 1) & 1;\n\n omap_timer_update(&s->timer);\n\n break;\n\n\n\n case 0x04:\t/* LOAD_TIMER */\n\n s->timer.reset_val = value & 0xffff;\n\n break;\n\n\n\n case 0x08:\t/* TIMER_MODE */\n\n if (!s->mode && ((value >> 15) & 1))\n\n omap_clk_get(s->timer.clk);\n\n s->mode |= (value >> 15) & 1;\n\n if (s->last_wr == 0xf5) {\n\n if ((value & 0xff) == 0xa0) {\n\n if (s->mode) {\n\n s->mode = 0;\n\n omap_clk_put(s->timer.clk);\n\n }\n\n } else {\n\n /* XXX: on T|E hardware somehow this has no effect,\n\n * on Zire 71 it works as specified. */\n\n s->reset = 1;\n\n qemu_system_reset_request();\n\n }\n\n }\n\n s->last_wr = value & 0xff;\n\n break;\n\n\n\n default:\n\n OMAP_BAD_REG(addr);\n\n }\n\n}\n", + "output": "0", + "index": 14979 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)\n\n{\n\n int err;\n\n\n\n err = mov_read_default(c, pb, atom);\n\n /* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */\n\n /* so we don't parse the whole file if over a network */\n\n c->found_moov=1;\n\n if(c->found_mdat)\n\n return 1; /* found both, just go */\n\n return 0; /* now go for mdat */\n\n}\n", + "output": "0", + "index": 4274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t vtd_context_cache_invalidate(IntelIOMMUState *s, uint64_t val)\n\n{\n\n uint64_t caig;\n\n uint64_t type = val & VTD_CCMD_CIRG_MASK;\n\n\n\n switch (type) {\n\n case VTD_CCMD_GLOBAL_INVL:\n\n VTD_DPRINTF(INV, \"Global invalidation request\");\n\n caig = VTD_CCMD_GLOBAL_INVL_A;\n\n break;\n\n\n\n case VTD_CCMD_DOMAIN_INVL:\n\n VTD_DPRINTF(INV, \"Domain-selective invalidation request\");\n\n caig = VTD_CCMD_DOMAIN_INVL_A;\n\n break;\n\n\n\n case VTD_CCMD_DEVICE_INVL:\n\n VTD_DPRINTF(INV, \"Domain-selective invalidation request\");\n\n caig = VTD_CCMD_DEVICE_INVL_A;\n\n break;\n\n\n\n default:\n\n VTD_DPRINTF(GENERAL,\n\n \"error: wrong context-cache invalidation granularity\");\n\n caig = 0;\n\n }\n\n return caig;\n\n}\n", + "output": "0", + "index": 7793 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void draw_rectangle(unsigned val, uint8_t *dst, int dst_linesize, unsigned segment_width,\n\n unsigned x, unsigned y, unsigned w, unsigned h)\n\n{\n\n int i;\n\n int step = 3;\n\n\n\n dst += segment_width * (step * x + y * dst_linesize);\n\n w *= segment_width * step;\n\n h *= segment_width;\n\n for (i = 0; i < h; i++) {\n\n memset(dst, val, w);\n\n dst += dst_linesize;\n\n }\n\n}\n", + "output": "1", + "index": 17278 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const char *read_ts(const char *buf, int *ts_start, int *ts_end,\n\n int *x1, int *y1, int *x2, int *y2)\n\n{\n\n int i, hs, ms, ss, he, me, se;\n\n\n\n for (i=0; i<2; i++) {\n\n /* try to read timestamps in either the first or second line */\n\n int c = sscanf(buf, \"%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d\"\n\n \"%*[ ]X1:%u X2:%u Y1:%u Y2:%u\",\n\n &hs, &ms, &ss, ts_start, &he, &me, &se, ts_end,\n\n x1, x2, y1, y2);\n\n buf += strcspn(buf, \"\\n\") + 1;\n\n if (c >= 8) {\n\n *ts_start = 100*(ss + 60*(ms + 60*hs)) + *ts_start/10;\n\n *ts_end = 100*(se + 60*(me + 60*he)) + *ts_end /10;\n\n return buf;\n\n }\n\n }\n\n return NULL;\n\n}\n", + "output": "1", + "index": 15133 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_dev_sync_region(struct vhost_dev *dev,\n\n MemoryRegionSection *section,\n\n uint64_t mfirst, uint64_t mlast,\n\n uint64_t rfirst, uint64_t rlast)\n\n{\n\n uint64_t start = MAX(mfirst, rfirst);\n\n uint64_t end = MIN(mlast, rlast);\n\n vhost_log_chunk_t *from = dev->log + start / VHOST_LOG_CHUNK;\n\n vhost_log_chunk_t *to = dev->log + end / VHOST_LOG_CHUNK + 1;\n\n uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;\n\n\n\n if (end < start) {\n\n return;\n\n }\n\n assert(end / VHOST_LOG_CHUNK < dev->log_size);\n\n assert(start / VHOST_LOG_CHUNK < dev->log_size);\n\n\n\n for (;from < to; ++from) {\n\n vhost_log_chunk_t log;\n\n int bit;\n\n /* We first check with non-atomic: much cheaper,\n\n * and we expect non-dirty to be the common case. */\n\n if (!*from) {\n\n addr += VHOST_LOG_CHUNK;\n\n continue;\n\n }\n\n /* Data must be read atomically. We don't really\n\n * need the barrier semantics of __sync\n\n * builtins, but it's easier to use them than\n\n * roll our own. */\n\n log = __sync_fetch_and_and(from, 0);\n\n while ((bit = sizeof(log) > sizeof(int) ?\n\n ffsll(log) : ffs(log))) {\n\n ram_addr_t ram_addr;\n\n bit -= 1;\n\n ram_addr = section->offset_within_region + bit * VHOST_LOG_PAGE;\n\n memory_region_set_dirty(section->mr, ram_addr, VHOST_LOG_PAGE);\n\n log &= ~(0x1ull << bit);\n\n }\n\n addr += VHOST_LOG_CHUNK;\n\n }\n\n}\n", + "output": "1", + "index": 10610 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1,\n\n TCGv arg2, int sign, int compute_ov)\n\n{\n\n TCGLabel *l1 = gen_new_label();\n\n TCGLabel *l2 = gen_new_label();\n\n TCGv_i32 t0 = tcg_temp_local_new_i32();\n\n TCGv_i32 t1 = tcg_temp_local_new_i32();\n\n\n\n tcg_gen_trunc_tl_i32(t0, arg1);\n\n tcg_gen_trunc_tl_i32(t1, arg2);\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, t1, 0, l1);\n\n if (sign) {\n\n TCGLabel *l3 = gen_new_label();\n\n tcg_gen_brcondi_i32(TCG_COND_NE, t1, -1, l3);\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, t0, INT32_MIN, l1);\n\n gen_set_label(l3);\n\n tcg_gen_div_i32(t0, t0, t1);\n\n } else {\n\n tcg_gen_divu_i32(t0, t0, t1);\n\n }\n\n if (compute_ov) {\n\n tcg_gen_movi_tl(cpu_ov, 0);\n\n }\n\n tcg_gen_br(l2);\n\n gen_set_label(l1);\n\n if (sign) {\n\n tcg_gen_sari_i32(t0, t0, 31);\n\n } else {\n\n tcg_gen_movi_i32(t0, 0);\n\n }\n\n if (compute_ov) {\n\n tcg_gen_movi_tl(cpu_ov, 1);\n\n tcg_gen_movi_tl(cpu_so, 1);\n\n }\n\n gen_set_label(l2);\n\n tcg_gen_extu_i32_tl(ret, t0);\n\n tcg_temp_free_i32(t0);\n\n tcg_temp_free_i32(t1);\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, ret);\n\n}\n", + "output": "0", + "index": 23827 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void _t_gen_mov_TN_env(TCGv tn, int offset)\n\n{\n\n if (offset > sizeof(CPUCRISState)) {\n\n fprintf(stderr, \"wrong load from env from off=%d\\n\", offset);\n\n }\n\n tcg_gen_ld_tl(tn, cpu_env, offset);\n\n}\n", + "output": "0", + "index": 27246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtp_write_header(AVFormatContext *s1)\n\n{\n\n RTPDemuxContext *s = s1->priv_data;\n\n int payload_type, max_packet_size, n;\n\n AVStream *st;\n\n\n\n if (s1->nb_streams != 1)\n\n return -1;\n\n st = s1->streams[0];\n\n\n\n payload_type = rtp_get_payload_type(st->codec);\n\n if (payload_type < 0)\n\n payload_type = RTP_PT_PRIVATE; /* private payload type */\n\n s->payload_type = payload_type;\n\n\n\n s->base_timestamp = random();\n\n s->timestamp = s->base_timestamp;\n\n s->ssrc = random();\n\n s->first_packet = 1;\n\n\n\n max_packet_size = url_fget_max_packet_size(&s1->pb);\n\n if (max_packet_size <= 12)\n\n return AVERROR_IO;\n\n s->max_payload_size = max_packet_size - 12;\n\n\n\n switch(st->codec->codec_id) {\n\n case CODEC_ID_MP2:\n\n case CODEC_ID_MP3:\n\n s->buf_ptr = s->buf + 4;\n\n s->cur_timestamp = 0;\n\n break;\n\n case CODEC_ID_MPEG1VIDEO:\n\n s->cur_timestamp = 0;\n\n break;\n\n case CODEC_ID_MPEG2TS:\n\n n = s->max_payload_size / TS_PACKET_SIZE;\n\n if (n < 1)\n\n n = 1;\n\n s->max_payload_size = n * TS_PACKET_SIZE;\n\n s->buf_ptr = s->buf;\n\n break;\n\n default:\n\n s->buf_ptr = s->buf;\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 10073 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BusState *qbus_find_recursive(BusState *bus, const char *name,\n\n const char *bus_typename)\n\n{\n\n BusChild *kid;\n\n BusState *child, *ret;\n\n int match = 1;\n\n\n\n if (name && (strcmp(bus->name, name) != 0)) {\n\n match = 0;\n\n }\n\n if (bus_typename &&\n\n (strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) {\n\n match = 0;\n\n }\n\n if (match) {\n\n return bus;\n\n }\n\n\n\n QTAILQ_FOREACH(kid, &bus->children, sibling) {\n\n DeviceState *dev = kid->child;\n\n QLIST_FOREACH(child, &dev->child_bus, sibling) {\n\n ret = qbus_find_recursive(child, name, bus_typename);\n\n if (ret) {\n\n return ret;\n\n }\n\n }\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 23523 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_excp_4xx_softmmu (CPUPPCState *env)\n\n{\n\n#if !defined(CONFIG_USER_ONLY)\n\n env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100;\n\n env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200;\n\n env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300;\n\n env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400;\n\n env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;\n\n env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600;\n\n env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700;\n\n env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00;\n\n env->excp_vectors[POWERPC_EXCP_PIT] = 0x00001000;\n\n env->excp_vectors[POWERPC_EXCP_FIT] = 0x00001010;\n\n env->excp_vectors[POWERPC_EXCP_WDT] = 0x00001020;\n\n env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00001100;\n\n env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00001200;\n\n env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00002000;\n\n env->excp_prefix = 0x00000000;\n\n env->ivor_mask = 0x0000FFF0;\n\n env->ivpr_mask = 0xFFFF0000;\n\n /* Hardware reset vector */\n\n env->hreset_vector = 0xFFFFFFFCUL;\n\n#endif\n\n}\n", + "output": "1", + "index": 13449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t flush_buf(VirtIOSerialPort *port,\n const uint8_t *buf, ssize_t len)\n{\n VirtConsole *vcon = VIRTIO_CONSOLE(port);\n ssize_t ret;\n if (!vcon->chr) {\n /* If there's no backend, we can just say we consumed all data. */\n return len;\n }\n ret = qemu_chr_fe_write(vcon->chr, buf, len);\n trace_virtio_console_flush_buf(port->id, len, ret);\n if (ret < len) {\n VirtIOSerialPortClass *k = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n /*\n * Ideally we'd get a better error code than just -1, but\n * that's what the chardev interface gives us right now. If\n * we had a finer-grained message, like -EPIPE, we could close\n * this connection.\n if (ret < 0)\n ret = 0;\n if (!k->is_console) {\n virtio_serial_throttle_port(port, true);\n if (!vcon->watch) {\n vcon->watch = qemu_chr_fe_add_watch(vcon->chr,\n G_IO_OUT|G_IO_HUP,\n chr_write_unblocked, vcon);\n }\n }\n }\n return ret;\n}", + "output": "1", + "index": 5157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_block_job_resume(const char *device, Error **errp)\n\n{\n\n BlockJob *job = find_block_job(device);\n\n\n\n if (!job) {\n\n error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);\n\n return;\n\n }\n\n\n\n trace_qmp_block_job_resume(job);\n\n block_job_resume(job);\n\n}\n", + "output": "0", + "index": 19957 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,\n\n uint32_t length,\n\n Error **errp)\n\n{\n\n QIOChannel *ioc;\n\n QIOChannelTLS *tioc;\n\n struct NBDTLSHandshakeData data = { 0 };\n\n\n\n trace_nbd_negotiate_handle_starttls();\n\n ioc = client->ioc;\n\n if (length) {\n\n if (nbd_drop(ioc, length, errp) < 0) {\n\n return NULL;\n\n }\n\n nbd_negotiate_send_rep_err(ioc, NBD_REP_ERR_INVALID, NBD_OPT_STARTTLS,\n\n errp,\n\n \"OPT_STARTTLS should not have length\");\n\n return NULL;\n\n }\n\n\n\n if (nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK,\n\n NBD_OPT_STARTTLS, errp) < 0) {\n\n return NULL;\n\n }\n\n\n\n tioc = qio_channel_tls_new_server(ioc,\n\n client->tlscreds,\n\n client->tlsaclname,\n\n errp);\n\n if (!tioc) {\n\n return NULL;\n\n }\n\n\n\n qio_channel_set_name(QIO_CHANNEL(tioc), \"nbd-server-tls\");\n\n trace_nbd_negotiate_handle_starttls_handshake();\n\n data.loop = g_main_loop_new(g_main_context_default(), FALSE);\n\n qio_channel_tls_handshake(tioc,\n\n nbd_tls_handshake,\n\n &data,\n\n NULL);\n\n\n\n if (!data.complete) {\n\n g_main_loop_run(data.loop);\n\n }\n\n g_main_loop_unref(data.loop);\n\n if (data.error) {\n\n object_unref(OBJECT(tioc));\n\n error_propagate(errp, data.error);\n\n return NULL;\n\n }\n\n\n\n return QIO_CHANNEL(tioc);\n\n}\n", + "output": "0", + "index": 4703 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_flush_nodev(void)\n\n{\n\n QPCIDevice *dev;\n\n QPCIBar bmdma_bar, ide_bar;\n\n\n\n ide_test_start(\"\");\n\n\n\n dev = get_pci_device(&bmdma_bar, &ide_bar);\n\n\n\n /* FLUSH CACHE command on device 0*/\n\n qpci_io_writeb(dev, ide_bar, reg_device, 0);\n\n qpci_io_writeb(dev, ide_bar, reg_command, CMD_FLUSH_CACHE);\n\n\n\n /* Just testing that qemu doesn't crash... */\n\n\n\n\n ide_test_quit();\n\n}", + "output": "1", + "index": 11046 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_metadata_size(const uint8_t *buf, int buf_size)\n\n{\n\n int metadata_last, metadata_size;\n\n const uint8_t *buf_end = buf + buf_size;\n\n\n\n buf += 4;\n\n do {\n\n ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);\n\n buf += 4;\n\n if (buf + metadata_size > buf_end) {\n\n /* need more data in order to read the complete header */\n\n return 0;\n\n }\n\n buf += metadata_size;\n\n } while (!metadata_last);\n\n\n\n return buf_size - (buf_end - buf);\n\n}\n", + "output": "1", + "index": 6557 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_write_udta_tag(ByteIOContext *pb, MOVContext* mov,\n\n AVFormatContext *s)\n\n{\n\n offset_t pos = url_ftell(pb);\n\n int i;\n\n\n\n put_be32(pb, 0); /* size */\n\n put_tag(pb, \"udta\");\n\n\n\n /* iTunes meta data */\n\n mov_write_meta_tag(pb, mov, s);\n\n\n\n if(mov->mode == MODE_MOV){ // the title field breaks gtkpod with mp4 and my suspicion is that stuff isnt valid in mp4\n\n /* Requirements */\n\n for (i=0; itracks[i].entry <= 0) continue;\n\n if (mov->tracks[i].enc->codec_id == CODEC_ID_AAC ||\n\n mov->tracks[i].enc->codec_id == CODEC_ID_MPEG4) {\n\n mov_write_string_tag(pb, \"\\251req\", \"QuickTime 6.0 or greater\", 0);\n\n break;\n\n }\n\n }\n\n\n\n mov_write_string_tag(pb, \"\\251nam\", s->title , 0);\n\n mov_write_string_tag(pb, \"\\251aut\", s->author , 0);\n\n mov_write_string_tag(pb, \"\\251alb\", s->album , 0);\n\n mov_write_day_tag(pb, s->year, 0);\n\n if(mov->tracks[0].enc && !(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT))\n\n mov_write_string_tag(pb, \"\\251enc\", LIBAVFORMAT_IDENT, 0);\n\n mov_write_string_tag(pb, \"\\251des\", s->comment , 0);\n\n mov_write_string_tag(pb, \"\\251gen\", s->genre , 0);\n\n }\n\n\n\n return updateSize(pb, pos);\n\n}\n", + "output": "0", + "index": 23464 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ogg_new_buf(struct ogg *ogg, int idx)\n\n{\n\n struct ogg_stream *os = ogg->streams + idx;\n\n uint8_t *nb = av_malloc(os->bufsize);\n\n int size = os->bufpos - os->pstart;\n\n if(os->buf){\n\n memcpy(nb, os->buf + os->pstart, size);\n\n av_free(os->buf);\n\n }\n\n os->buf = nb;\n\n os->bufpos = size;\n\n os->pstart = 0;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 13069 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_cpu_kick_thread(CPUState *env)\n\n{\n\n#ifndef _WIN32\n\n int err;\n\n\n\n err = pthread_kill(env->thread->thread, SIG_IPI);\n\n if (err) {\n\n fprintf(stderr, \"qemu:%s: %s\", __func__, strerror(err));\n\n exit(1);\n\n }\n\n#else /* _WIN32 */\n\n if (!qemu_cpu_is_self(env)) {\n\n SuspendThread(env->thread->thread);\n\n cpu_signal(0);\n\n ResumeThread(env->thread->thread);\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 10326 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blend_frames(AVFilterContext *ctx, int interpolate)\n\n{\n\n FrameRateContext *s = ctx->priv;\n\n AVFilterLink *outlink = ctx->outputs[0];\n\n double interpolate_scene_score = 0;\n\n\n\n if ((s->flags & FRAMERATE_FLAG_SCD)) {\n\n if (s->score >= 0.0)\n\n interpolate_scene_score = s->score;\n\n else\n\n interpolate_scene_score = s->score = get_scene_score(ctx, s->f0, s->f1);\n\n ff_dlog(ctx, \"blend_frames() interpolate scene score:%f\\n\", interpolate_scene_score);\n\n }\n\n // decide if the shot-change detection allows us to blend two frames\n\n if (interpolate_scene_score < s->scene_score) {\n\n ThreadData td;\n\n td.copy_src1 = s->f0;\n\n td.copy_src2 = s->f1;\n\n td.src2_factor = interpolate;\n\n td.src1_factor = s->max - td.src2_factor;\n\n\n\n // get work-space for output frame\n\n s->work = ff_get_video_buffer(outlink, outlink->w, outlink->h);\n\n if (!s->work)\n\n return AVERROR(ENOMEM);\n\n\n\n av_frame_copy_props(s->work, s->f0);\n\n\n\n ff_dlog(ctx, \"blend_frames() INTERPOLATE to create work frame\\n\");\n\n ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));\n\n return 1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 24653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,\n\n const uint8_t *buf, int nb_sectors)\n\n{\n\n int async_ret;\n\n BlockDriverAIOCB *acb;\n\n\n\n async_ret = NOT_DONE;\n\n qemu_aio_wait_start();\n\n acb = bdrv_aio_write(bs, sector_num, buf, nb_sectors,\n\n bdrv_rw_em_cb, &async_ret);\n\n if (acb == NULL) {\n\n qemu_aio_wait_end();\n\n return -1;\n\n }\n\n while (async_ret == NOT_DONE) {\n\n qemu_aio_wait();\n\n }\n\n qemu_aio_wait_end();\n\n return async_ret;\n\n}\n", + "output": "1", + "index": 20268 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_io_limits_enable(BlockDriverState *bs, const char *group)\n\n{\n\n assert(!bs->throttle_state);\n\n throttle_group_register_bs(bs, group);\n\n}\n", + "output": "0", + "index": 26896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)\n\n{\n\n int ret, i;\n\n AVFormatContext *dev = NULL;\n\n AVDeviceInfoList *device_list = NULL;\n\n AVDictionary *tmp_opts = NULL;\n\n\n\n if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))\n\n return AVERROR(EINVAL);\n\n\n\n printf(\"Audo-detected sources for %s:\\n\", fmt->name);\n\n if (!fmt->get_device_list) {\n\n ret = AVERROR(ENOSYS);\n\n printf(\"Cannot list sources. Not implemented.\\n\");\n\n goto fail;\n\n }\n\n\n\n /* TODO: avformat_open_input calls read_header callback which is not necessary.\n\n Function like avformat_alloc_output_context2 for input could be helpful here. */\n\n av_dict_copy(&tmp_opts, opts, 0);\n\n if ((ret = avformat_open_input(&dev, NULL, fmt, &tmp_opts)) < 0) {\n\n printf(\"Cannot open device: %s.\\n\", fmt->name);\n\n goto fail;\n\n }\n\n\n\n if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {\n\n printf(\"Cannot list sources.\\n\");\n\n goto fail;\n\n }\n\n\n\n for (i = 0; i < device_list->nb_devices; i++) {\n\n printf(\"%s %s [%s]\\n\", device_list->default_device == i ? \"*\" : \" \",\n\n device_list->devices[i]->device_name, device_list->devices[i]->device_description);\n\n }\n\n\n\n fail:\n\n av_dict_free(&tmp_opts);\n\n avdevice_free_list_devices(&device_list);\n\n avformat_close_input(&dev);\n\n return ret;\n\n}\n", + "output": "1", + "index": 17905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void build_fs_mount_list_from_mtab(FsMountList *mounts, Error **errp)\n\n{\n\n struct mntent *ment;\n\n FsMount *mount;\n\n char const *mtab = \"/proc/self/mounts\";\n\n FILE *fp;\n\n unsigned int devmajor, devminor;\n\n\n\n fp = setmntent(mtab, \"r\");\n\n if (!fp) {\n\n error_setg(errp, \"failed to open mtab file: '%s'\", mtab);\n\n return;\n\n }\n\n\n\n while ((ment = getmntent(fp))) {\n\n /*\n\n * An entry which device name doesn't start with a '/' is\n\n * either a dummy file system or a network file system.\n\n * Add special handling for smbfs and cifs as is done by\n\n * coreutils as well.\n\n */\n\n if ((ment->mnt_fsname[0] != '/') ||\n\n (strcmp(ment->mnt_type, \"smbfs\") == 0) ||\n\n (strcmp(ment->mnt_type, \"cifs\") == 0)) {\n\n continue;\n\n }\n\n if (dev_major_minor(ment->mnt_fsname, &devmajor, &devminor) == -2) {\n\n /* Skip bind mounts */\n\n continue;\n\n }\n\n\n\n mount = g_malloc0(sizeof(FsMount));\n\n mount->dirname = g_strdup(ment->mnt_dir);\n\n mount->devtype = g_strdup(ment->mnt_type);\n\n mount->devmajor = devmajor;\n\n mount->devminor = devminor;\n\n\n\n QTAILQ_INSERT_TAIL(mounts, mount, next);\n\n }\n\n\n\n endmntent(fp);\n\n}\n", + "output": "1", + "index": 8356 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan)\n\n{\n\n const char *ifname;\n\n\n\n ifname = qemu_opt_get(opts, \"ifname\");\n\n\n\n if (!ifname) {\n\n error_report(\"tap: no interface name\");\n\n return -1;\n\n }\n\n\n\n if (tap_win32_init(vlan, \"tap\", name, ifname) == -1) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 14 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int net_handle_fd_param(Monitor *mon, const char *param)\n\n{\n\n if (!qemu_isdigit(param[0])) {\n\n int fd;\n\n\n\n fd = monitor_get_fd(mon, param);\n\n if (fd == -1) {\n\n error_report(\"No file descriptor named %s found\", param);\n\n return -1;\n\n }\n\n\n\n return fd;\n\n } else {\n\n return strtol(param, NULL, 0);\n\n }\n\n}\n", + "output": "1", + "index": 5494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void avformat_free_context(AVFormatContext *s)\n\n{\n\n int i;\n\n\n\n if (!s)\n\n return;\n\n\n\n av_opt_free(s);\n\n if (s->iformat && s->iformat->priv_class && s->priv_data)\n\n av_opt_free(s->priv_data);\n\n if (s->oformat && s->oformat->priv_class && s->priv_data)\n\n av_opt_free(s->priv_data);\n\n\n\n for (i = s->nb_streams - 1; i >= 0; i--) {\n\n ff_free_stream(s, s->streams[i]);\n\n }\n\n for (i = s->nb_programs - 1; i >= 0; i--) {\n\n av_dict_free(&s->programs[i]->metadata);\n\n av_freep(&s->programs[i]->stream_index);\n\n av_freep(&s->programs[i]);\n\n }\n\n av_freep(&s->programs);\n\n av_freep(&s->priv_data);\n\n while (s->nb_chapters--) {\n\n av_dict_free(&s->chapters[s->nb_chapters]->metadata);\n\n av_freep(&s->chapters[s->nb_chapters]);\n\n }\n\n av_freep(&s->chapters);\n\n av_dict_free(&s->metadata);\n\n av_freep(&s->streams);\n\n av_freep(&s->internal);\n\n\n av_free(s);\n\n}", + "output": "1", + "index": 20637 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_synth_rename(FsContext *ctx, const char *oldpath,\n\n const char *newpath)\n\n{\n\n errno = EPERM;\n\n return -1;\n\n}\n", + "output": "0", + "index": 2906 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_stats_iter(QObject *data, void *opaque)\n\n{\n\n QDict *qdict;\n\n Monitor *mon = opaque;\n\n\n\n qdict = qobject_to_qdict(data);\n\n monitor_printf(mon, \"%s:\", qdict_get_str(qdict, \"device\"));\n\n\n\n qdict = qobject_to_qdict(qdict_get(qdict, \"stats\"));\n\n monitor_printf(mon, \" rd_bytes=%\" PRId64\n\n \" wr_bytes=%\" PRId64\n\n \" rd_operations=%\" PRId64\n\n \" wr_operations=%\" PRId64\n\n \" flush_operations=%\" PRId64\n\n \"\\n\",\n\n qdict_get_int(qdict, \"rd_bytes\"),\n\n qdict_get_int(qdict, \"wr_bytes\"),\n\n qdict_get_int(qdict, \"rd_operations\"),\n\n qdict_get_int(qdict, \"wr_operations\"),\n\n qdict_get_int(qdict, \"flush_operations\"));\n\n}\n", + "output": "0", + "index": 1068 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_vlan(DeviceState *dev, Property *prop, const char *str)\n\n{\n\n VLANState **ptr = qdev_get_prop_ptr(dev, prop);\n\n int id;\n\n\n\n if (sscanf(str, \"%d\", &id) != 1)\n\n return -EINVAL;\n\n *ptr = qemu_find_vlan(id, 1);\n\n if (*ptr == NULL)\n\n return -ENOENT;\n\n return 0;\n\n}\n", + "output": "1", + "index": 11057 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len)\n\n{\n\n QEMUSizedBuffer *qsb;\n\n size_t alloc_len, num_chunks, i, to_copy;\n\n size_t chunk_size = (len > QSB_MAX_CHUNK_SIZE)\n\n ? QSB_MAX_CHUNK_SIZE\n\n : QSB_CHUNK_SIZE;\n\n\n\n num_chunks = DIV_ROUND_UP(len ? len : QSB_CHUNK_SIZE, chunk_size);\n\n alloc_len = num_chunks * chunk_size;\n\n\n\n qsb = g_try_new0(QEMUSizedBuffer, 1);\n\n if (!qsb) {\n\n return NULL;\n\n }\n\n\n\n qsb->iov = g_try_new0(struct iovec, num_chunks);\n\n if (!qsb->iov) {\n\n g_free(qsb);\n\n return NULL;\n\n }\n\n\n\n qsb->n_iov = num_chunks;\n\n\n\n for (i = 0; i < num_chunks; i++) {\n\n qsb->iov[i].iov_base = g_try_malloc0(chunk_size);\n\n if (!qsb->iov[i].iov_base) {\n\n /* qsb_free is safe since g_free can cope with NULL */\n\n qsb_free(qsb);\n\n return NULL;\n\n }\n\n\n\n qsb->iov[i].iov_len = chunk_size;\n\n if (buffer) {\n\n to_copy = (len - qsb->used) > chunk_size\n\n ? chunk_size : (len - qsb->used);\n\n memcpy(qsb->iov[i].iov_base, &buffer[qsb->used], to_copy);\n\n qsb->used += to_copy;\n\n }\n\n }\n\n\n\n qsb->size = alloc_len;\n\n\n\n return qsb;\n\n}\n", + "output": "1", + "index": 22306 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int hevc_decode_init(AVCodecContext *avctx)\n\n{\n\n HEVCContext *s = avctx->priv_data;\n\n int ret;\n\n\n\n avctx->internal->allocate_progress = 1;\n\n\n\n ret = hevc_init_context(avctx);\n\n if (ret < 0)\n\n return ret;\n\n\n\n s->enable_parallel_tiles = 0;\n\n s->sei.picture_timing.picture_struct = 0;\n\n s->eos = 1;\n\n\n\n atomic_init(&s->wpp_err, 0);\n\n\n\n if(avctx->active_thread_type & FF_THREAD_SLICE)\n\n s->threads_number = avctx->thread_count;\n\n else\n\n s->threads_number = 1;\n\n\n\n if (avctx->extradata_size > 0 && avctx->extradata) {\n\n ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size);\n\n if (ret < 0) {\n\n hevc_decode_free(avctx);\n\n return ret;\n\n }\n\n }\n\n\n\n if((avctx->active_thread_type & FF_THREAD_FRAME) && avctx->thread_count > 1)\n\n s->threads_type = FF_THREAD_FRAME;\n\n else\n\n s->threads_type = FF_THREAD_SLICE;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 12696 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void s390x_tod_timer(void *opaque)\n\n{\n\n S390CPU *cpu = opaque;\n\n CPUS390XState *env = &cpu->env;\n\n\n\n env->pending_int |= INTERRUPT_TOD;\n\n cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);\n\n}\n", + "output": "0", + "index": 14897 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void filter0(int32_t *dst, const int32_t *src, int32_t coeff, ptrdiff_t len)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < len; i++)\n\n dst[i] -= mul22(src[i], coeff);\n\n}\n", + "output": "1", + "index": 2843 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vga_invalidate_display(void *opaque)\n\n{\n\n VGAState *s = (VGAState *)opaque;\n\n\n\n s->last_width = -1;\n\n s->last_height = -1;\n\n}\n", + "output": "1", + "index": 24349 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void raw_close(BlockDriverState *bs)\n\n{\n\n}\n", + "output": "0", + "index": 20214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(pka)(CPUS390XState *env, uint64_t dest, uint64_t src,\n\n uint32_t srclen)\n\n{\n\n uintptr_t ra = GETPC();\n\n int i;\n\n /* The destination operand is always 16 bytes long. */\n\n const int destlen = 16;\n\n\n\n /* The operands are processed from right to left. */\n\n src += srclen - 1;\n\n dest += destlen - 1;\n\n\n\n for (i = 0; i < destlen; i++) {\n\n uint8_t b = 0;\n\n\n\n /* Start with a positive sign */\n\n if (i == 0) {\n\n b = 0xc;\n\n } else if (srclen > 1) {\n\n b = cpu_ldub_data_ra(env, src, ra) & 0x0f;\n\n src--;\n\n srclen--;\n\n }\n\n\n\n if (srclen > 1) {\n\n b |= cpu_ldub_data_ra(env, src, ra) << 4;\n\n src--;\n\n srclen--;\n\n }\n\n\n\n cpu_stb_data_ra(env, dest, b, ra);\n\n dest--;\n\n }\n\n}\n", + "output": "0", + "index": 4433 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvmclock_realize(DeviceState *dev, Error **errp)\n{\n KVMClockState *s = KVM_CLOCK(dev);\n kvm_update_clock(s);\n qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s);", + "output": "1", + "index": 11523 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mdct512(AC3MDCTContext *mdct, float *out, float *in)\n\n{\n\n mdct->fft.mdct_calc(&mdct->fft, out, in);\n\n}\n", + "output": "0", + "index": 2730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void t_gen_swapb(TCGv d, TCGv s)\n\n{\n\n\tTCGv t, org_s;\n\n\n\n\tt = tcg_temp_new(TCG_TYPE_TL);\n\n\torg_s = tcg_temp_new(TCG_TYPE_TL);\n\n\n\n\t/* d and s may refer to the same object. */\n\n\ttcg_gen_mov_tl(org_s, s);\n\n\ttcg_gen_shli_tl(t, org_s, 8);\n\n\ttcg_gen_andi_tl(d, t, 0xff00ff00);\n\n\ttcg_gen_shri_tl(t, org_s, 8);\n\n\ttcg_gen_andi_tl(t, t, 0x00ff00ff);\n\n\ttcg_gen_or_tl(d, d, t);\n\n\ttcg_temp_free(t);\n\n\ttcg_temp_free(org_s);\n\n}\n", + "output": "0", + "index": 16751 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int multiwrite_req_compare(const void *a, const void *b)\n\n{\n\n return (((BlockRequest*) a)->sector - ((BlockRequest*) b)->sector);\n\n}\n", + "output": "1", + "index": 24359 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_thread_get_self(QemuThread *thread)\n\n{\n\n if (!thread->thread) {\n\n /* In the main thread of the process. Initialize the QemuThread\n\n pointer in TLS, and use the dummy GetCurrentThread handle as\n\n the identifier for qemu_thread_is_self. */\n\n qemu_thread_init();\n\n TlsSetValue(qemu_thread_tls_index, thread);\n\n thread->thread = GetCurrentThread();\n\n }\n\n}\n", + "output": "1", + "index": 26238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void pxa2xx_rtc_int_update(PXA2xxState *s)\n\n{\n\n qemu_set_irq(s->pic[PXA2XX_PIC_RTCALARM], !!(s->rtsr & 0x2553));\n\n}\n", + "output": "0", + "index": 20936 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void handle_arg_log_filename(const char *arg)\n\n{\n\n qemu_set_log_filename(arg);\n\n}\n", + "output": "1", + "index": 2314 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtosz_float(void)\n\n{\n\n const char *str = \"12.345M\";\n\n char *endptr = NULL;\n\n int64_t res;\n\n\n\n res = qemu_strtosz(str, &endptr);\n\n g_assert_cmpint(res, ==, 12.345 * M_BYTE);\n\n g_assert(endptr == str + 7);\n\n}\n", + "output": "0", + "index": 9854 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t empty_slot_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n DPRINTF(\"read from \" TARGET_FMT_plx \"\\n\", addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 4497 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qdev_print_devinfo(ObjectClass *klass, void *opaque)\n\n{\n\n DeviceClass *dc;\n\n bool *show_no_user = opaque;\n\n\n\n dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE);\n\n\n\n if (!dc || (show_no_user && !*show_no_user && dc->no_user)) {\n\n return;\n\n }\n\n\n\n error_printf(\"name \\\"%s\\\"\", object_class_get_name(klass));\n\n if (dc->bus_info) {\n\n error_printf(\", bus %s\", dc->bus_info->name);\n\n }\n\n if (dc->alias) {\n\n error_printf(\", alias \\\"%s\\\"\", dc->alias);\n\n }\n\n if (dc->desc) {\n\n error_printf(\", desc \\\"%s\\\"\", dc->desc);\n\n }\n\n if (dc->no_user) {\n\n error_printf(\", no-user\");\n\n }\n\n error_printf(\"\\n\");\n\n}\n", + "output": "0", + "index": 18055 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_cold ff_ivi_free_buffers(IVIPlaneDesc *planes)\n\n{\n\n int p, b, t;\n\n\n\n for (p = 0; p < 3; p++) {\n\n for (b = 0; b < planes[p].num_bands; b++) {\n\n av_freep(&planes[p].bands[b].bufs[0]);\n\n av_freep(&planes[p].bands[b].bufs[1]);\n\n av_freep(&planes[p].bands[b].bufs[2]);\n\n\n\n\n\n for (t = 0; t < planes[p].bands[b].num_tiles; t++)\n\n av_freep(&planes[p].bands[b].tiles[t].mbs);\n\n av_freep(&planes[p].bands[b].tiles);\n\n }\n\n av_freep(&planes[p].bands);\n\n }\n\n}", + "output": "1", + "index": 1132 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline void gen_bcond (DisasContext *ctx,\n\n TCGCond cond,\n\n int ra, int32_t disp16, int mask)\n\n{\n\n int l1, l2;\n\n\n\n l1 = gen_new_label();\n\n l2 = gen_new_label();\n\n if (likely(ra != 31)) {\n\n if (mask) {\n\n TCGv tmp = tcg_temp_new(TCG_TYPE_I64);\n\n tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);\n\n tcg_gen_brcondi_i64(cond, tmp, 0, l1);\n\n tcg_temp_free(tmp);\n\n } else\n\n tcg_gen_brcondi_i64(cond, cpu_ir[ra], 0, l1);\n\n } else {\n\n /* Very uncommon case - Do not bother to optimize. */\n\n TCGv tmp = tcg_const_i64(0);\n\n tcg_gen_brcondi_i64(cond, tmp, 0, l1);\n\n tcg_temp_free(tmp);\n\n }\n\n tcg_gen_movi_i64(cpu_pc, ctx->pc);\n\n tcg_gen_br(l2);\n\n gen_set_label(l1);\n\n tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));\n\n gen_set_label(l2);\n\n}\n", + "output": "0", + "index": 25362 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_sasl_client_cleanup(VncState *vs)\n\n{\n\n if (vs->sasl.conn) {\n\n vs->sasl.runSSF = vs->sasl.waitWriteSSF = vs->sasl.wantSSF = 0;\n\n vs->sasl.encodedLength = vs->sasl.encodedOffset = 0;\n\n vs->sasl.encoded = NULL;\n\n g_free(vs->sasl.username);\n\n free(vs->sasl.mechlist);\n\n vs->sasl.username = vs->sasl.mechlist = NULL;\n\n sasl_dispose(&vs->sasl.conn);\n\n vs->sasl.conn = NULL;\n\n }\n\n}\n", + "output": "1", + "index": 19633 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qxl_init_ramsize(PCIQXLDevice *qxl, uint32_t ram_min_mb)\n\n{\n\n /* vga ram (bar 0) */\n\n if (qxl->ram_size_mb != -1) {\n\n qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024;\n\n }\n\n if (qxl->vga.vram_size < ram_min_mb * 1024 * 1024) {\n\n qxl->vga.vram_size = ram_min_mb * 1024 * 1024;\n\n }\n\n\n\n /* vram32 (surfaces, 32bit, bar 1) */\n\n if (qxl->vram32_size_mb != -1) {\n\n qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;\n\n }\n\n if (qxl->vram32_size < 4096) {\n\n qxl->vram32_size = 4096;\n\n }\n\n\n\n /* vram (surfaces, 64bit, bar 4+5) */\n\n if (qxl->vram_size_mb != -1) {\n\n qxl->vram_size = qxl->vram_size_mb * 1024 * 1024;\n\n }\n\n if (qxl->vram_size < qxl->vram32_size) {\n\n qxl->vram_size = qxl->vram32_size;\n\n }\n\n\n\n if (qxl->revision == 1) {\n\n qxl->vram32_size = 4096;\n\n qxl->vram_size = 4096;\n\n }\n\n qxl->vga.vram_size = msb_mask(qxl->vga.vram_size * 2 - 1);\n\n qxl->vram32_size = msb_mask(qxl->vram32_size * 2 - 1);\n\n qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);\n\n}\n", + "output": "1", + "index": 21230 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int announce_self_create(uint8_t *buf, \n\n\t\t\t\tuint8_t *mac_addr)\n\n{\n\n uint32_t magic = EXPERIMENTAL_MAGIC;\n\n uint16_t proto = htons(ETH_P_EXPERIMENTAL);\n\n\n\n /* FIXME: should we send a different packet (arp/rarp/ping)? */\n\n\n\n memset(buf, 0, 64);\n\n memset(buf, 0xff, 6); /* h_dst */\n\n memcpy(buf + 6, mac_addr, 6); /* h_src */\n\n memcpy(buf + 12, &proto, 2); /* h_proto */\n\n memcpy(buf + 14, &magic, 4); /* magic */\n\n\n\n return 64; /* len */\n\n}\n", + "output": "1", + "index": 18951 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_check_irqs(CPUState *env)\n\n{\n\n uint32_t pil = env->pil_in | (env->softint & ~SOFTINT_TIMER) |\n\n ((env->softint & SOFTINT_TIMER) << 14);\n\n\n\n if (pil && (env->interrupt_index == 0 ||\n\n (env->interrupt_index & ~15) == TT_EXTINT)) {\n\n unsigned int i;\n\n\n\n for (i = 15; i > 0; i--) {\n\n if (pil & (1 << i)) {\n\n int old_interrupt = env->interrupt_index;\n\n\n\n env->interrupt_index = TT_EXTINT | i;\n\n if (old_interrupt != env->interrupt_index) {\n\n CPUIRQ_DPRINTF(\"Set CPU IRQ %d\\n\", i);\n\n cpu_interrupt(env, CPU_INTERRUPT_HARD);\n\n }\n\n break;\n\n }\n\n }\n\n } else if (!pil && (env->interrupt_index & ~15) == TT_EXTINT) {\n\n CPUIRQ_DPRINTF(\"Reset CPU IRQ %d\\n\", env->interrupt_index & 15);\n\n env->interrupt_index = 0;\n\n cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);\n\n }\n\n}\n", + "output": "0", + "index": 5690 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool all_cpu_threads_idle(void)\n\n{\n\n CPUState *env;\n\n\n\n for (env = first_cpu; env != NULL; env = env->next_cpu) {\n\n if (!cpu_thread_is_idle(env)) {\n\n return false;\n\n }\n\n }\n\n return true;\n\n}\n", + "output": "1", + "index": 16612 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void conv411(uint8_t *dst, int dst_wrap, \n uint8_t *src, int src_wrap,\n int width, int height)\n{\n int w, c;\n uint8_t *s1, *s2, *d;\n for(;height > 0; height--) {\n s1 = src;\n s2 = src + src_wrap;\n d = dst;\n for(w = width;w > 0; w--) {\n c = (s1[0] + s2[0]) >> 1;\n d[0] = c;\n d[1] = c;\n s1++;\n s2++;\n d += 2;\n }\n src += src_wrap * 2;\n dst += dst_wrap;\n }\n}", + "output": "1", + "index": 2526 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_control_event(void *opaque, int event)\n\n{\n\n if (event == CHR_EVENT_OPENED) {\n\n QObject *data;\n\n Monitor *mon = opaque;\n\n\n\n mon->mc->command_mode = 0;\n\n json_message_parser_init(&mon->mc->parser, handle_qmp_command);\n\n\n\n data = get_qmp_greeting();\n\n monitor_json_emitter(mon, data);\n\n qobject_decref(data);\n\n }\n\n}\n", + "output": "1", + "index": 14643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "cryptodev_builtin_get_aes_algo(uint32_t key_len, Error **errp)\n\n{\n\n int algo;\n\n\n\n if (key_len == 128 / 8) {\n\n algo = QCRYPTO_CIPHER_ALG_AES_128;\n\n } else if (key_len == 192 / 8) {\n\n algo = QCRYPTO_CIPHER_ALG_AES_192;\n\n } else if (key_len == 256 / 8) {\n\n algo = QCRYPTO_CIPHER_ALG_AES_256;\n\n } else {\n\n error_setg(errp, \"Unsupported key length :%u\", key_len);\n\n return -1;\n\n }\n\n\n\n return algo;\n\n}\n", + "output": "0", + "index": 17592 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)\n\n{\n\n S390CPU *cpu = S390_CPU(cs);\n\n int ret = 0;\n\n\n\n switch (run->exit_reason) {\n\n case KVM_EXIT_S390_SIEIC:\n\n ret = handle_intercept(cpu);\n\n break;\n\n case KVM_EXIT_S390_RESET:\n\n qemu_system_reset_request();\n\n break;\n\n case KVM_EXIT_S390_TSCH:\n\n ret = handle_tsch(cpu);\n\n break;\n\n case KVM_EXIT_DEBUG:\n\n ret = kvm_arch_handle_debug_exit(cpu);\n\n break;\n\n default:\n\n fprintf(stderr, \"Unknown KVM exit: %d\\n\", run->exit_reason);\n\n break;\n\n }\n\n\n\n if (ret == 0) {\n\n ret = EXCP_INTERRUPT;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 27254 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_acpi_piix4_tcg_cphp(void)\n\n{\n\n test_data data;\n\n\n\n memset(&data, 0, sizeof(data));\n\n data.machine = MACHINE_PC;\n\n data.variant = \".cphp\";\n\n test_acpi_one(\"-smp 2,cores=3,sockets=2,maxcpus=6\"\n\n \" -numa node -numa node\",\n\n &data);\n\n free_test_data(&data);\n\n}\n", + "output": "0", + "index": 20829 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)\n\n{\n\n struct sockaddr_in sin = {\n\n .sin_family = AF_INET,\n\n .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },\n\n };\n\n struct sockaddr_in6 sin6 = {\n\n .sin6_family = AF_INET6,\n\n .sin6_addr = IN6ADDR_LOOPBACK_INIT,\n\n };\n\n\n\n if (check_bind((struct sockaddr *)&sin, sizeof(sin), has_ipv4) < 0) {\n\n return -1;\n\n }\n\n if (check_bind((struct sockaddr *)&sin6, sizeof(sin6), has_ipv6) < 0) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 1818 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int i, ret;\n\n\n\n ret = find_snapshot_by_id(bs, name);\n\n if (ret >= 0)\n\n return ret;\n\n for(i = 0; i < s->nb_snapshots; i++) {\n\n if (!strcmp(s->snapshots[i].name, name))\n\n return i;\n\n }\n\n return -1;\n\n}\n", + "output": "1", + "index": 5771 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pnv_chip_realize(DeviceState *dev, Error **errp)\n{\n PnvChip *chip = PNV_CHIP(dev);\n Error *error = NULL;\n PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);\n char *typename = pnv_core_typename(pcc->cpu_model);\n size_t typesize = object_type_get_instance_size(typename);\n int i, core_hwid;\n if (!object_class_by_name(typename)) {\n error_setg(errp, \"Unable to find PowerNV CPU Core '%s'\", typename);\n /* Cores */\n pnv_chip_core_sanitize(chip, &error);\n chip->cores = g_malloc0(typesize * chip->nr_cores);\n for (i = 0, core_hwid = 0; (core_hwid < sizeof(chip->cores_mask) * 8)\n && (i < chip->nr_cores); core_hwid++) {\n char core_name[32];\n void *pnv_core = chip->cores + i * typesize;\n if (!(chip->cores_mask & (1ull << core_hwid))) {\n continue;\n object_initialize(pnv_core, typesize, typename);\n snprintf(core_name, sizeof(core_name), \"core[%d]\", core_hwid);\n object_property_add_child(OBJECT(chip), core_name, OBJECT(pnv_core),\n &error_fatal);\n object_property_set_int(OBJECT(pnv_core), smp_threads, \"nr-threads\",\n &error_fatal);\n object_property_set_int(OBJECT(pnv_core), core_hwid,\n CPU_CORE_PROP_CORE_ID, &error_fatal);\n object_property_set_int(OBJECT(pnv_core),\n pcc->core_pir(chip, core_hwid),\n \"pir\", &error_fatal);\n object_property_set_bool(OBJECT(pnv_core), true, \"realized\",\n &error_fatal);\n object_unref(OBJECT(pnv_core));\n i++;\n g_free(typename);", + "output": "1", + "index": 12174 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int es1370_initfn (PCIDevice *dev)\n\n{\n\n ES1370State *s = DO_UPCAST (ES1370State, dev, dev);\n\n uint8_t *c = s->dev.config;\n\n\n\n pci_config_set_vendor_id (c, PCI_VENDOR_ID_ENSONIQ);\n\n pci_config_set_device_id (c, PCI_DEVICE_ID_ENSONIQ_ES1370);\n\n c[PCI_STATUS + 1] = PCI_STATUS_DEVSEL_SLOW >> 8;\n\n pci_config_set_class (c, PCI_CLASS_MULTIMEDIA_AUDIO);\n\n\n\n#if 1\n\n c[PCI_SUBSYSTEM_VENDOR_ID] = 0x42;\n\n c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x49;\n\n c[PCI_SUBSYSTEM_ID] = 0x4c;\n\n c[PCI_SUBSYSTEM_ID + 1] = 0x4c;\n\n#else\n\n c[PCI_SUBSYSTEM_VENDOR_ID] = 0x74;\n\n c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x12;\n\n c[PCI_SUBSYSTEM_ID] = 0x71;\n\n c[PCI_SUBSYSTEM_ID + 1] = 0x13;\n\n c[PCI_CAPABILITY_LIST] = 0xdc;\n\n c[PCI_INTERRUPT_LINE] = 10;\n\n c[0xdc] = 0x00;\n\n#endif\n\n\n\n /* TODO: RST# value should be 0. */\n\n c[PCI_INTERRUPT_PIN] = 1;\n\n c[PCI_MIN_GNT] = 0x0c;\n\n c[PCI_MAX_LAT] = 0x80;\n\n\n\n pci_register_bar (&s->dev, 0, 256, PCI_BASE_ADDRESS_SPACE_IO, es1370_map);\n\n qemu_register_reset (es1370_on_reset, s);\n\n\n\n AUD_register_card (\"es1370\", &s->card);\n\n es1370_reset (s);\n\n return 0;\n\n}\n", + "output": "0", + "index": 20894 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pcmcia_socket_unregister(PCMCIASocket *socket)\n\n{\n\n struct pcmcia_socket_entry_s *entry, **ptr;\n\n\n\n ptr = &pcmcia_sockets;\n\n for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)\n\n if (entry->socket == socket) {\n\n *ptr = entry->next;\n\n g_free(entry);\n\n }\n\n}\n", + "output": "1", + "index": 14467 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int slirp_smb(SlirpState* s, const char *exported_dir,\n\n struct in_addr vserver_addr)\n\n{\n\n static int instance;\n\n char smb_conf[128];\n\n char smb_cmdline[128];\n\n FILE *f;\n\n\n\n snprintf(s->smb_dir, sizeof(s->smb_dir), \"/tmp/qemu-smb.%ld-%d\",\n\n (long)getpid(), instance++);\n\n if (mkdir(s->smb_dir, 0700) < 0) {\n\n error_report(\"could not create samba server dir '%s'\", s->smb_dir);\n\n return -1;\n\n }\n\n snprintf(smb_conf, sizeof(smb_conf), \"%s/%s\", s->smb_dir, \"smb.conf\");\n\n\n\n f = fopen(smb_conf, \"w\");\n\n if (!f) {\n\n slirp_smb_cleanup(s);\n\n error_report(\"could not create samba server configuration file '%s'\",\n\n smb_conf);\n\n return -1;\n\n }\n\n fprintf(f,\n\n \"[global]\\n\"\n\n \"private dir=%s\\n\"\n\n \"socket address=127.0.0.1\\n\"\n\n \"pid directory=%s\\n\"\n\n \"lock directory=%s\\n\"\n\n \"state directory=%s\\n\"\n\n \"log file=%s/log.smbd\\n\"\n\n \"smb passwd file=%s/smbpasswd\\n\"\n\n \"security = share\\n\"\n\n \"[qemu]\\n\"\n\n \"path=%s\\n\"\n\n \"read only=no\\n\"\n\n \"guest ok=yes\\n\",\n\n\n\n\n\n\n\n exported_dir\n\n );\n\n fclose(f);\n\n\n\n snprintf(smb_cmdline, sizeof(smb_cmdline), \"%s -s %s\",\n\n CONFIG_SMBD_COMMAND, smb_conf);\n\n\n\n if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) {\n\n slirp_smb_cleanup(s);\n\n error_report(\"conflicting/invalid smbserver address\");\n\n return -1;\n\n }\n\n return 0;\n\n}", + "output": "1", + "index": 7691 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static FFServerIPAddressACL* parse_dynamic_acl(FFServerStream *stream, HTTPContext *c)\n\n{\n\n FILE* f;\n\n char line[1024];\n\n char cmd[1024];\n\n FFServerIPAddressACL *acl = NULL;\n\n int line_num = 0;\n\n const char *p;\n\n\n\n f = fopen(stream->dynamic_acl, \"r\");\n\n if (!f) {\n\n perror(stream->dynamic_acl);\n\n return NULL;\n\n }\n\n\n\n acl = av_mallocz(sizeof(FFServerIPAddressACL));\n\n\n\n /* Build ACL */\n\n for(;;) {\n\n if (fgets(line, sizeof(line), f) == NULL)\n\n break;\n\n line_num++;\n\n p = line;\n\n while (av_isspace(*p))\n\n p++;\n\n if (*p == '\\0' || *p == '#')\n\n continue;\n\n ffserver_get_arg(cmd, sizeof(cmd), &p);\n\n\n\n if (!av_strcasecmp(cmd, \"ACL\"))\n\n ffserver_parse_acl_row(NULL, NULL, acl, p, stream->dynamic_acl, line_num);\n\n }\n\n fclose(f);\n\n return acl;\n\n}\n", + "output": "0", + "index": 25948 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QList *qobject_to_qlist(const QObject *obj)\n\n{\n\n if (qobject_type(obj) != QTYPE_QLIST) {\n\n return NULL;\n\n }\n\n\n\n return container_of(obj, QList, base);\n\n}\n", + "output": "1", + "index": 14203 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spin_kick(void *data)\n\n{\n\n SpinKick *kick = data;\n\n CPUState *cpu = CPU(kick->cpu);\n\n CPUPPCState *env = &kick->cpu->env;\n\n SpinInfo *curspin = kick->spin;\n\n hwaddr map_size = 64 * 1024 * 1024;\n\n hwaddr map_start;\n\n\n\n cpu_synchronize_state(cpu);\n\n stl_p(&curspin->pir, env->spr[SPR_PIR]);\n\n env->nip = ldq_p(&curspin->addr) & (map_size - 1);\n\n env->gpr[3] = ldq_p(&curspin->r3);\n\n env->gpr[4] = 0;\n\n env->gpr[5] = 0;\n\n env->gpr[6] = 0;\n\n env->gpr[7] = map_size;\n\n env->gpr[8] = 0;\n\n env->gpr[9] = 0;\n\n\n\n map_start = ldq_p(&curspin->addr) & ~(map_size - 1);\n\n mmubooke_create_initial_mapping(env, 0, map_start, map_size);\n\n\n\n cpu->halted = 0;\n\n cpu->exception_index = -1;\n\n cpu->stopped = false;\n\n qemu_cpu_kick(cpu);\n\n}\n", + "output": "0", + "index": 25022 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *qemu_get_virtqueue_element(VirtIODevice *vdev, QEMUFile *f, size_t sz)\n\n{\n\n VirtQueueElement *elem;\n\n VirtQueueElementOld data;\n\n int i;\n\n\n\n qemu_get_buffer(f, (uint8_t *)&data, sizeof(VirtQueueElementOld));\n\n\n\n /* TODO: teach all callers that this can fail, and return failure instead\n\n * of asserting here.\n\n * When we do, we might be able to re-enable NDEBUG below.\n\n */\n\n#ifdef NDEBUG\n\n#error building with NDEBUG is not supported\n\n#endif\n\n assert(ARRAY_SIZE(data.in_addr) >= data.in_num);\n\n assert(ARRAY_SIZE(data.out_addr) >= data.out_num);\n\n\n\n elem = virtqueue_alloc_element(sz, data.out_num, data.in_num);\n\n elem->index = data.index;\n\n\n\n for (i = 0; i < elem->in_num; i++) {\n\n elem->in_addr[i] = data.in_addr[i];\n\n }\n\n\n\n for (i = 0; i < elem->out_num; i++) {\n\n elem->out_addr[i] = data.out_addr[i];\n\n }\n\n\n\n for (i = 0; i < elem->in_num; i++) {\n\n /* Base is overwritten by virtqueue_map. */\n\n elem->in_sg[i].iov_base = 0;\n\n elem->in_sg[i].iov_len = data.in_sg[i].iov_len;\n\n }\n\n\n\n for (i = 0; i < elem->out_num; i++) {\n\n /* Base is overwritten by virtqueue_map. */\n\n elem->out_sg[i].iov_base = 0;\n\n elem->out_sg[i].iov_len = data.out_sg[i].iov_len;\n\n }\n\n\n\n virtqueue_map(vdev, elem);\n\n return elem;\n\n}\n", + "output": "1", + "index": 10965 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void fimd_swap_data(unsigned int swap_ctl, uint64_t *data)\n\n{\n\n int i;\n\n uint64_t res;\n\n uint64_t x = *data;\n\n\n\n if (swap_ctl & FIMD_WINCON_SWAP_BITS) {\n\n res = 0;\n\n for (i = 0; i < 64; i++) {\n\n if (x & (1ULL << (64 - i))) {\n\n res |= (1ULL << i);\n\n }\n\n }\n\n x = res;\n\n }\n\n\n\n if (swap_ctl & FIMD_WINCON_SWAP_BYTE) {\n\n x = bswap64(x);\n\n }\n\n\n\n if (swap_ctl & FIMD_WINCON_SWAP_HWORD) {\n\n x = ((x & 0x000000000000FFFFULL) << 48) |\n\n ((x & 0x00000000FFFF0000ULL) << 16) |\n\n ((x & 0x0000FFFF00000000ULL) >> 16) |\n\n ((x & 0xFFFF000000000000ULL) >> 48);\n\n }\n\n\n\n if (swap_ctl & FIMD_WINCON_SWAP_WORD) {\n\n x = ((x & 0x00000000FFFFFFFFULL) << 32) |\n\n ((x & 0xFFFFFFFF00000000ULL) >> 32);\n\n }\n\n\n\n *data = x;\n\n}\n", + "output": "1", + "index": 19454 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr,\n\n qemu_irq **irqs)\n\n{\n\n qemu_irq *mpic;\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n int i, j, k;\n\n\n\n mpic = g_new(qemu_irq, 256);\n\n dev = qdev_create(NULL, \"openpic\");\n\n qdev_prop_set_uint32(dev, \"nb_cpus\", smp_cpus);\n\n qdev_prop_set_uint32(dev, \"model\", params->mpic_version);\n\n qdev_init_nofail(dev);\n\n s = SYS_BUS_DEVICE(dev);\n\n\n\n k = 0;\n\n for (i = 0; i < smp_cpus; i++) {\n\n for (j = 0; j < OPENPIC_OUTPUT_NB; j++) {\n\n sysbus_connect_irq(s, k++, irqs[i][j]);\n\n }\n\n }\n\n\n\n for (i = 0; i < 256; i++) {\n\n mpic[i] = qdev_get_gpio_in(dev, i);\n\n }\n\n\n\n memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET,\n\n s->mmio[0].memory);\n\n\n\n return mpic;\n\n}\n", + "output": "0", + "index": 7480 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CharDriverState *chr_testdev_init(void)\n\n{\n\n TestdevCharState *testdev;\n\n CharDriverState *chr;\n\n\n\n testdev = g_malloc0(sizeof(TestdevCharState));\n\n testdev->chr = chr = g_malloc0(sizeof(CharDriverState));\n\n\n\n chr->opaque = testdev;\n\n chr->chr_write = testdev_write;\n\n chr->chr_close = testdev_close;\n\n\n\n return chr;\n\n}\n", + "output": "1", + "index": 21802 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int normalize_bits(int num, int width)\n\n{\n\n int i = 0;\n\n int bits = (width) ? 31 : 15;\n\n int limit = 1 << (bits - 1);\n\n\n\n if (num) {\n\n if (num == -1)\n\n return bits;\n\n if (num < 0)\n\n num = ~num;\n\n for (i = 0; num < limit; i++)\n\n num <<= 1;\n\n }\n\n return i;\n\n}\n", + "output": "0", + "index": 4239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "iscsi_allocmap_update(IscsiLun *iscsilun, int64_t sector_num,\n\n int nb_sectors, bool allocated, bool valid)\n\n{\n\n int64_t cl_num_expanded, nb_cls_expanded, cl_num_shrunk, nb_cls_shrunk;\n\n\n\n if (iscsilun->allocmap == NULL) {\n\n return;\n\n }\n\n /* expand to entirely contain all affected clusters */\n\n cl_num_expanded = sector_num / iscsilun->cluster_sectors;\n\n nb_cls_expanded = DIV_ROUND_UP(sector_num + nb_sectors,\n\n iscsilun->cluster_sectors) - cl_num_expanded;\n\n /* shrink to touch only completely contained clusters */\n\n cl_num_shrunk = DIV_ROUND_UP(sector_num, iscsilun->cluster_sectors);\n\n nb_cls_shrunk = (sector_num + nb_sectors) / iscsilun->cluster_sectors\n\n - cl_num_shrunk;\n\n if (allocated) {\n\n bitmap_set(iscsilun->allocmap, cl_num_expanded, nb_cls_expanded);\n\n } else {\n\n bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);\n\n }\n\n\n\n if (iscsilun->allocmap_valid == NULL) {\n\n return;\n\n }\n\n if (valid) {\n\n bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);\n\n } else {\n\n bitmap_clear(iscsilun->allocmap_valid, cl_num_expanded,\n\n nb_cls_expanded);\n\n }\n\n}\n", + "output": "1", + "index": 24003 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ehci_mem_writew(void *ptr, target_phys_addr_t addr, uint32_t val)\n\n{\n\n fprintf(stderr, \"EHCI doesn't handle 16-bit writes to MMIO\\n\");\n\n exit(1);\n\n}\n", + "output": "1", + "index": 155 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv b)\n\n{\n\n TCGv_i64 tmp64 = tcg_temp_new_i64();\n\n\n\n tcg_gen_extu_i32_i64(tmp64, b);\n\n dead_tmp(b);\n\n tcg_gen_shli_i64(tmp64, tmp64, 32);\n\n tcg_gen_add_i64(a, tmp64, a);\n\n\n\n tcg_temp_free_i64(tmp64);\n\n return a;\n\n}\n", + "output": "1", + "index": 26531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int copy_stream_props(AVStream *st, AVStream *source_st)\n\n{\n\n int ret;\n\n\n\n if (st->codecpar->codec_id || !source_st->codecpar->codec_id) {\n\n if (st->codecpar->extradata_size < source_st->codecpar->extradata_size) {\n\n if (st->codecpar->extradata) {\n\n av_freep(&st->codecpar->extradata);\n\n st->codecpar->extradata_size = 0;\n\n }\n\n ret = ff_alloc_extradata(st->codecpar,\n\n source_st->codecpar->extradata_size);\n\n if (ret < 0)\n\n return ret;\n\n }\n\n memcpy(st->codecpar->extradata, source_st->codecpar->extradata,\n\n source_st->codecpar->extradata_size);\n\n return 0;\n\n }\n\n if ((ret = avcodec_parameters_copy(st->codecpar, source_st->codecpar)) < 0)\n\n return ret;\n\n st->r_frame_rate = source_st->r_frame_rate;\n\n st->avg_frame_rate = source_st->avg_frame_rate;\n\n st->time_base = source_st->time_base;\n\n st->sample_aspect_ratio = source_st->sample_aspect_ratio;\n\n\n\n av_dict_copy(&st->metadata, source_st->metadata, 0);\n\n return 0;\n\n}\n", + "output": "0", + "index": 3677 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t qemu_devtree_get_phandle(void *fdt, const char *path)\n\n{\n\n uint32_t r;\n\n\n\n r = fdt_get_phandle(fdt, findnode_nofail(fdt, path));\n\n if (r <= 0) {\n\n fprintf(stderr, \"%s: Couldn't get phandle for %s: %s\\n\", __func__,\n\n path, fdt_strerror(r));\n\n exit(1);\n\n }\n\n\n\n return r;\n\n}\n", + "output": "0", + "index": 21542 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_devtree_setprop(void *fdt, const char *node_path,\n\n const char *property, void *val_array, int size)\n\n{\n\n int offset;\n\n\n\n offset = fdt_path_offset(fdt, node_path);\n\n if (offset < 0)\n\n return offset;\n\n\n\n return fdt_setprop(fdt, offset, property, val_array, size);\n\n}\n", + "output": "1", + "index": 536 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void colo_compare_finalize(Object *obj)\n\n{\n\n CompareState *s = COLO_COMPARE(obj);\n\n\n\n qemu_chr_fe_deinit(&s->chr_pri_in, false);\n\n qemu_chr_fe_deinit(&s->chr_sec_in, false);\n\n qemu_chr_fe_deinit(&s->chr_out, false);\n\n\n\n g_main_loop_quit(s->compare_loop);\n\n qemu_thread_join(&s->thread);\n\n\n\n /* Release all unhandled packets after compare thead exited */\n\n g_queue_foreach(&s->conn_list, colo_flush_packets, s);\n\n\n\n g_queue_clear(&s->conn_list);\n\n\n\n g_hash_table_destroy(s->connection_track_table);\n\n g_free(s->pri_indev);\n\n g_free(s->sec_indev);\n\n g_free(s->outdev);\n\n}\n", + "output": "0", + "index": 19207 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ccid_card_init(DeviceState *qdev)\n\n{\n\n CCIDCardState *card = CCID_CARD(qdev);\n\n USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);\n\n USBCCIDState *s = USB_CCID_DEV(dev);\n\n int ret = 0;\n\n\n\n if (card->slot != 0) {\n\n error_report(\"Warning: usb-ccid supports one slot, can't add %d\",\n\n card->slot);\n\n return -1;\n\n }\n\n if (s->card != NULL) {\n\n error_report(\"Warning: usb-ccid card already full, not adding\");\n\n return -1;\n\n }\n\n ret = ccid_card_initfn(card);\n\n if (ret == 0) {\n\n s->card = card;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 16531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t nvdimm_get_max_xfer_label_size(void)\n\n{\n\n uint32_t max_get_size, max_set_size, dsm_memory_size = 4096;\n\n\n\n /*\n\n * the max data ACPI can read one time which is transferred by\n\n * the response of 'Get Namespace Label Data' function.\n\n */\n\n max_get_size = dsm_memory_size - sizeof(NvdimmFuncGetLabelDataOut);\n\n\n\n /*\n\n * the max data ACPI can write one time which is transferred by\n\n * 'Set Namespace Label Data' function.\n\n */\n\n max_set_size = dsm_memory_size - offsetof(NvdimmDsmIn, arg3) -\n\n sizeof(NvdimmFuncSetLabelDataIn);\n\n\n\n return MIN(max_get_size, max_set_size);\n\n}\n", + "output": "0", + "index": 8292 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static OSStatus audioDeviceIOProc(\n\n AudioDeviceID inDevice,\n\n const AudioTimeStamp* inNow,\n\n const AudioBufferList* inInputData,\n\n const AudioTimeStamp* inInputTime,\n\n AudioBufferList* outOutputData,\n\n const AudioTimeStamp* inOutputTime,\n\n void* hwptr)\n\n{\n\n UInt32 frame, frameCount;\n\n float *out = outOutputData->mBuffers[0].mData;\n\n HWVoiceOut *hw = hwptr;\n\n coreaudioVoiceOut *core = (coreaudioVoiceOut *) hwptr;\n\n int rpos, live;\n\n st_sample_t *src;\n\n#ifndef FLOAT_MIXENG\n\n#ifdef RECIPROCAL\n\n const float scale = 1.f / UINT_MAX;\n\n#else\n\n const float scale = UINT_MAX;\n\n#endif\n\n#endif\n\n\n\n if (coreaudio_lock (core, \"audioDeviceIOProc\")) {\n\n inInputTime = 0;\n\n return 0;\n\n }\n\n\n\n frameCount = core->audioDevicePropertyBufferFrameSize;\n\n live = core->live;\n\n\n\n /* if there are not enough samples, set signal and return */\n\n if (live < frameCount) {\n\n inInputTime = 0;\n\n coreaudio_unlock (core, \"audioDeviceIOProc(empty)\");\n\n return 0;\n\n }\n\n\n\n rpos = core->rpos;\n\n src = hw->mix_buf + rpos;\n\n\n\n /* fill buffer */\n\n for (frame = 0; frame < frameCount; frame++) {\n\n#ifdef FLOAT_MIXENG\n\n *out++ = src[frame].l; /* left channel */\n\n *out++ = src[frame].r; /* right channel */\n\n#else\n\n#ifdef RECIPROCAL\n\n *out++ = src[frame].l * scale; /* left channel */\n\n *out++ = src[frame].r * scale; /* right channel */\n\n#else\n\n *out++ = src[frame].l / scale; /* left channel */\n\n *out++ = src[frame].r / scale; /* right channel */\n\n#endif\n\n#endif\n\n }\n\n\n\n rpos = (rpos + frameCount) % hw->samples;\n\n core->decr += frameCount;\n\n core->rpos = rpos;\n\n\n\n coreaudio_unlock (core, \"audioDeviceIOProc\");\n\n return 0;\n\n}\n", + "output": "0", + "index": 17600 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],\n\n const uint8_t *map, unsigned size, VLC *vlc)\n\n{\n\n Node nodes[2*size], *tmp = &nodes[size];\n\n int a, b, i;\n\n\n\n /* first compute probabilities from model */\n\n tmp[0].count = 256;\n\n for (i=0; i> 8;\n\n b = tmp[i].count * (255 - coeff_model[i]) >> 8;\n\n nodes[map[2*i ]].count = a + !a;\n\n nodes[map[2*i+1]].count = b + !b;\n\n }\n\n\n\n\n /* then build the huffman tree accodring to probabilities */\n\n ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,\n\n FF_HUFFMAN_FLAG_HNODE_FIRST);\n\n}", + "output": "1", + "index": 2441 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)\n\n{\n\n ObjectClass *oc;\n\n DeviceClass *dc;\n\n\n\n oc = object_class_by_name(*driver);\n\n if (!oc) {\n\n const char *typename = find_typename_by_alias(*driver);\n\n\n\n if (typename) {\n\n *driver = typename;\n\n oc = object_class_by_name(*driver);\n\n }\n\n }\n\n\n\n if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {\n\n error_setg(errp, \"'%s' is not a valid device model name\", *driver);\n\n return NULL;\n\n }\n\n\n\n if (object_class_is_abstract(oc)) {\n\n error_setg(errp, QERR_INVALID_PARAMETER_VALUE, \"driver\",\n\n \"non-abstract device type\");\n\n return NULL;\n\n }\n\n\n\n dc = DEVICE_CLASS(oc);\n\n if (dc->cannot_instantiate_with_device_add_yet ||\n\n (qdev_hotplug && !dc->hotpluggable)) {\n\n error_setg(errp, QERR_INVALID_PARAMETER_VALUE, \"driver\",\n\n \"pluggable device type\");\n\n return NULL;\n\n }\n\n\n\n return dc;\n\n}\n", + "output": "0", + "index": 4618 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,\n\n char *line, int line_size, int *print_prefix)\n\n{\n\n AVBPrint part[4];\n\n format_line(ptr, level, fmt, vl, part, print_prefix, NULL);\n\n snprintf(line, line_size, \"%s%s%s%s\", part[0].str, part[1].str, part[2].str, part[3].str);\n\n av_bprint_finalize(part+3, NULL);\n\n}\n", + "output": "0", + "index": 23372 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_9p_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);\n\n\n\n dc->props = virtio_9p_properties;\n\n set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);\n\n vdc->realize = virtio_9p_device_realize;\n\n\n vdc->get_features = virtio_9p_get_features;\n\n vdc->get_config = virtio_9p_get_config;\n\n}", + "output": "1", + "index": 23885 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_savevm_send_postcopy_advise(QEMUFile *f)\n\n{\n\n uint64_t tmp[2];\n\n tmp[0] = cpu_to_be64(getpagesize());\n\n tmp[1] = cpu_to_be64(1ul << qemu_target_page_bits());\n\n\n\n trace_qemu_savevm_send_postcopy_advise();\n\n qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_ADVISE, 16, (uint8_t *)tmp);\n\n}\n", + "output": "1", + "index": 1675 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void glib_pollfds_fill(int64_t *cur_timeout)\n\n{\n\n GMainContext *context = g_main_context_default();\n\n int timeout = 0;\n\n int64_t timeout_ns;\n\n int n;\n\n\n\n g_main_context_prepare(context, &max_priority);\n\n\n\n glib_pollfds_idx = gpollfds->len;\n\n n = glib_n_poll_fds;\n\n do {\n\n GPollFD *pfds;\n\n glib_n_poll_fds = n;\n\n g_array_set_size(gpollfds, glib_pollfds_idx + glib_n_poll_fds);\n\n pfds = &g_array_index(gpollfds, GPollFD, glib_pollfds_idx);\n\n n = g_main_context_query(context, max_priority, &timeout, pfds,\n\n glib_n_poll_fds);\n\n } while (n != glib_n_poll_fds);\n\n\n\n if (timeout < 0) {\n\n timeout_ns = -1;\n\n } else {\n\n timeout_ns = (int64_t)timeout * (int64_t)SCALE_MS;\n\n }\n\n\n\n *cur_timeout = qemu_soonest_timeout(timeout_ns, *cur_timeout);\n\n}\n", + "output": "0", + "index": 15522 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Object *object_dynamic_cast(Object *obj, const char *typename)\n\n{\n\n GSList *i;\n\n\n\n /* Check if typename is a direct ancestor */\n\n if (object_is_type(obj, typename)) {\n\n return obj;\n\n }\n\n\n\n /* Check if obj has an interface of typename */\n\n for (i = obj->interfaces; i; i = i->next) {\n\n Interface *iface = i->data;\n\n\n\n if (object_is_type(OBJECT(iface), typename)) {\n\n return OBJECT(iface);\n\n }\n\n }\n\n\n\n /* Check if obj is an interface and its containing object is a direct\n\n * ancestor of typename */\n\n if (object_is_type(obj, TYPE_INTERFACE)) {\n\n Interface *iface = INTERFACE(obj);\n\n\n\n if (object_is_type(iface->obj, typename)) {\n\n return iface->obj;\n\n }\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 10039 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void numa_add(const char *optarg)\n\n{\n\n char option[128];\n\n char *endptr;\n\n unsigned long long value, endvalue;\n\n int nodenr;\n\n\n\n optarg = get_opt_name(option, 128, optarg, ',') + 1;\n\n if (!strcmp(option, \"node\")) {\n\n if (get_param_value(option, 128, \"nodeid\", optarg) == 0) {\n\n nodenr = nb_numa_nodes;\n\n } else {\n\n nodenr = strtoull(option, NULL, 10);\n\n }\n\n\n\n if (get_param_value(option, 128, \"mem\", optarg) == 0) {\n\n node_mem[nodenr] = 0;\n\n } else {\n\n int64_t sval;\n\n sval = strtosz(option, &endptr);\n\n if (sval < 0 || *endptr) {\n\n fprintf(stderr, \"qemu: invalid numa mem size: %s\\n\", optarg);\n\n exit(1);\n\n }\n\n node_mem[nodenr] = sval;\n\n }\n\n if (get_param_value(option, 128, \"cpus\", optarg) == 0) {\n\n node_cpumask[nodenr] = 0;\n\n } else {\n\n value = strtoull(option, &endptr, 10);\n\n if (value >= 64) {\n\n value = 63;\n\n fprintf(stderr, \"only 64 CPUs in NUMA mode supported.\\n\");\n\n } else {\n\n if (*endptr == '-') {\n\n endvalue = strtoull(endptr+1, &endptr, 10);\n\n if (endvalue >= 63) {\n\n endvalue = 62;\n\n fprintf(stderr,\n\n \"only 63 CPUs in NUMA mode supported.\\n\");\n\n }\n\n value = (2ULL << endvalue) - (1ULL << value);\n\n } else {\n\n value = 1ULL << value;\n\n }\n\n }\n\n node_cpumask[nodenr] = value;\n\n }\n\n nb_numa_nodes++;\n\n }\n\n return;\n\n}\n", + "output": "0", + "index": 5885 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)\n\n{\n\n int status;\n\n AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context;\n\n VTContext *vtctx = avctx->internal->hwaccel_priv_data;\n\n\n\n av_buffer_unref(&frame->buf[0]);\n\n\n\n if (!videotoolbox->session || !vtctx->bitstream)\n\n return AVERROR_INVALIDDATA;\n\n\n\n status = videotoolbox_session_decode_frame(avctx);\n\n\n\n if (status) {\n\n av_log(avctx, AV_LOG_ERROR, \"Failed to decode frame (%d)\\n\", status);\n\n return AVERROR_UNKNOWN;\n\n }\n\n\n\n if (!vtctx->frame)\n\n return AVERROR_UNKNOWN;\n\n\n\n return ff_videotoolbox_buffer_create(vtctx, frame);\n\n}\n", + "output": "1", + "index": 14323 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_populate_pci_devices_dt(PCIBus *bus, PCIDevice *pdev,\n\n void *opaque)\n\n{\n\n PCIBus *sec_bus;\n\n sPAPRFDT *p = opaque;\n\n int offset;\n\n sPAPRFDT s_fdt;\n\n uint32_t drc_index = spapr_phb_get_pci_drc_index(p->sphb, pdev);\n\n\n\n offset = spapr_create_pci_child_dt(p->sphb, pdev,\n\n drc_index, NULL,\n\n p->fdt, p->node_off);\n\n if (!offset) {\n\n error_report(\"Failed to create pci child device tree node\");\n\n return;\n\n }\n\n\n\n if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=\n\n PCI_HEADER_TYPE_BRIDGE)) {\n\n return;\n\n }\n\n\n\n sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));\n\n if (!sec_bus) {\n\n return;\n\n }\n\n\n\n s_fdt.fdt = p->fdt;\n\n s_fdt.node_off = offset;\n\n s_fdt.sphb = p->sphb;\n\n pci_for_each_device(sec_bus, pci_bus_num(sec_bus),\n\n spapr_populate_pci_devices_dt,\n\n &s_fdt);\n\n}\n", + "output": "0", + "index": 23813 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int get_video_format_idx(AVCodecContext *avctx)\n\n{\n\n unsigned int ret_idx = 0;\n\n unsigned int idx;\n\n unsigned int num_formats = sizeof(ff_schro_video_format_info) /\n\n sizeof(ff_schro_video_format_info[0]);\n\n\n\n for (idx = 1; idx < num_formats; ++idx) {\n\n const SchroVideoFormatInfo *vf = &ff_schro_video_format_info[idx];\n\n if (avctx->width == vf->width &&\n\n avctx->height == vf->height) {\n\n ret_idx = idx;\n\n if (avctx->time_base.den == vf->frame_rate_num &&\n\n avctx->time_base.num == vf->frame_rate_denom)\n\n return idx;\n\n }\n\n }\n\n return ret_idx;\n\n}\n", + "output": "1", + "index": 2228 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_snapshot_by_id(BlockDriverState *bs, const char *id_str)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int i;\n\n\n\n for(i = 0; i < s->nb_snapshots; i++) {\n\n if (!strcmp(s->snapshots[i].id_str, id_str))\n\n return i;\n\n }\n\n return -1;\n\n}\n", + "output": "1", + "index": 19869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ac3_encode_frame(AVCodecContext *avctx,\n\n unsigned char *frame, int buf_size, void *data)\n\n{\n\n AC3EncodeContext *s = avctx->priv_data;\n\n const int16_t *samples = data;\n\n int16_t planar_samples[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE+AC3_FRAME_SIZE];\n\n int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];\n\n uint8_t exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];\n\n uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];\n\n uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];\n\n uint8_t num_exp_groups[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];\n\n uint8_t grouped_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_EXP_GROUPS];\n\n uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];\n\n int8_t exp_shift[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];\n\n uint16_t qmant[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];\n\n int frame_bits;\n\n\n\n if (s->bit_alloc.sr_code == 1)\n\n adjust_frame_size(s);\n\n\n\n deinterleave_input_samples(s, samples, planar_samples);\n\n\n\n apply_mdct(s, planar_samples, exp_shift, mdct_coef);\n\n\n\n frame_bits = process_exponents(s, mdct_coef, exp_shift, exp, exp_strategy,\n\n encoded_exp, num_exp_groups, grouped_exp);\n\n\n\n compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);\n\n\n\n quantize_mantissas(s, mdct_coef, exp_shift, encoded_exp, bap, qmant);\n\n\n\n output_frame(s, frame, exp_strategy, num_exp_groups, grouped_exp, bap, qmant);\n\n\n\n return s->frame_size;\n\n}\n", + "output": "0", + "index": 299 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_fill_buffer(QEMUFile *f)\n\n{\n\n int len;\n\n int pending;\n\n\n\n assert(!qemu_file_is_writable(f));\n\n\n\n pending = f->buf_size - f->buf_index;\n\n if (pending > 0) {\n\n memmove(f->buf, f->buf + f->buf_index, pending);\n\n }\n\n f->buf_index = 0;\n\n f->buf_size = pending;\n\n\n\n len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,\n\n IO_BUF_SIZE - pending);\n\n if (len > 0) {\n\n f->buf_size += len;\n\n f->pos += len;\n\n } else if (len == 0) {\n\n qemu_file_set_error(f, -EIO);\n\n } else if (len != -EAGAIN) {\n\n qemu_file_set_error(f, len);\n\n }\n\n}\n", + "output": "1", + "index": 11702 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "float64 helper_fqtod(CPUSPARCState *env)\n\n{\n\n float64 ret;\n\n clear_float_exceptions(env);\n\n ret = float128_to_float64(QT1, &env->fp_status);\n\n check_ieee_exceptions(env);\n\n return ret;\n\n}\n", + "output": "0", + "index": 9713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)\n\n{\n\n\tint offset;\n\n\tint channels,freq,size;\n\n\n\n\toffset = is_adx(buf,bufsize);\n\n\tif (offset==0) return 0;\n\n\n\n\tchannels = buf[7];\n\n\tfreq = read_long(buf+8);\n\n\tsize = read_long(buf+12);\n\n\n\n//\tprintf(\"freq=%d ch=%d\\n\",freq,channels);\n\n\n\n\tavctx->sample_rate = freq;\n\n\tavctx->channels = channels;\n\n\tavctx->bit_rate = freq*channels*18*8/32;\n\n//\tavctx->frame_size = 18*channels;\n\n\n\n\treturn offset;\n\n}\n", + "output": "1", + "index": 19881 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "target_ulong helper_udiv(target_ulong a, target_ulong b)\n\n{\n\n uint64_t x0;\n\n uint32_t x1;\n\n\n\n x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32);\n\n x1 = (b & 0xffffffff);\n\n\n\n if (x1 == 0) {\n\n raise_exception(TT_DIV_ZERO);\n\n }\n\n\n\n x0 = x0 / x1;\n\n if (x0 > 0xffffffff) {\n\n env->cc_src2 = 1;\n\n return 0xffffffff;\n\n } else {\n\n env->cc_src2 = 0;\n\n return x0;\n\n }\n\n}\n", + "output": "1", + "index": 135 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool gen_rsr_ccount(DisasContext *dc, TCGv_i32 d, uint32_t sr)\n\n{\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_helper_update_ccount(cpu_env);\n\n tcg_gen_mov_i32(d, cpu_SR[sr]);\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n return true;\n\n }\n\n return false;\n\n}\n", + "output": "1", + "index": 18840 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)\n\n{\n\n BaumDriverState *baum;\n\n CharDriverState *chr;\n\n brlapi_handle_t *handle;\n\n#ifdef CONFIG_SDL\n\n SDL_SysWMinfo info;\n\n#endif\n\n int tty;\n\n\n\n baum = g_malloc0(sizeof(BaumDriverState));\n\n baum->chr = chr = g_malloc0(sizeof(CharDriverState));\n\n\n\n chr->opaque = baum;\n\n chr->chr_write = baum_write;\n\n chr->chr_accept_input = baum_accept_input;\n\n chr->chr_close = baum_close;\n\n\n\n handle = g_malloc0(brlapi_getHandleSize());\n\n baum->brlapi = handle;\n\n\n\n baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);\n\n if (baum->brlapi_fd == -1) {\n\n brlapi_perror(\"baum_init: brlapi_openConnection\");\n\n goto fail_handle;\n\n }\n\n\n\n baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum);\n\n\n\n if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {\n\n brlapi_perror(\"baum_init: brlapi_getDisplaySize\");\n\n goto fail;\n\n }\n\n\n\n#ifdef CONFIG_SDL\n\n memset(&info, 0, sizeof(info));\n\n SDL_VERSION(&info.version);\n\n if (SDL_GetWMInfo(&info))\n\n tty = info.info.x11.wmwindow;\n\n else\n\n#endif\n\n tty = BRLAPI_TTY_DEFAULT;\n\n\n\n if (brlapi__enterTtyMode(handle, tty, NULL) == -1) {\n\n brlapi_perror(\"baum_init: brlapi_enterTtyMode\");\n\n goto fail;\n\n }\n\n\n\n qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);\n\n\n\n qemu_chr_generic_open(chr);\n\n\n\n *_chr = chr;\n\n return 0;\n\n\n\nfail:\n\n qemu_free_timer(baum->cellCount_timer);\n\n brlapi__closeConnection(handle);\n\nfail_handle:\n\n g_free(handle);\n\n g_free(chr);\n\n g_free(baum);\n\n return -EIO;\n\n}\n", + "output": "1", + "index": 13882 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean vtd_hash_remove_by_page(gpointer key, gpointer value,\n\n gpointer user_data)\n\n{\n\n VTDIOTLBEntry *entry = (VTDIOTLBEntry *)value;\n\n VTDIOTLBPageInvInfo *info = (VTDIOTLBPageInvInfo *)user_data;\n\n uint64_t gfn = info->gfn & info->mask;\n\n return (entry->domain_id == info->domain_id) &&\n\n ((entry->gfn & info->mask) == gfn);\n\n}\n", + "output": "0", + "index": 10943 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ogg_restore(AVFormatContext *s)\n\n{\n\n struct ogg *ogg = s->priv_data;\n\n AVIOContext *bc = s->pb;\n\n struct ogg_state *ost = ogg->state;\n\n int i, err;\n\n\n\n if (!ost)\n\n return 0;\n\n\n\n ogg->state = ost->next;\n\n\n\n for (i = 0; i < ogg->nstreams; i++)\n\n av_freep(&ogg->streams[i].buf);\n\n\n\n avio_seek(bc, ost->pos, SEEK_SET);\n\n ogg->page_pos = -1;\n\n ogg->curidx = ost->curidx;\n\n ogg->nstreams = ost->nstreams;\n\n if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams,\n\n sizeof(*ogg->streams))) < 0) {\n\n ogg->nstreams = 0;\n\n return err;\n\n } else\n\n memcpy(ogg->streams, ost->streams,\n\n ost->nstreams * sizeof(*ogg->streams));\n\n\n\n av_free(ost);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18318 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_srli_T0 (void)\n\n{\n\n T0 = T0 >> PARAM1;\n\n RETURN();\n\n}\n", + "output": "1", + "index": 13928 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void process_incoming_migration(QEMUFile *f)\n{\n if (qemu_loadvm_state(f) < 0) {\n fprintf(stderr, \"load of migration failed\\n\");\n exit(0);\n }\n qemu_announce_self();\n DPRINTF(\"successfully loaded vm state\\n\");\n if (autostart)\n vm_start();\n}", + "output": "1", + "index": 3544 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)\n\n{\n\n BDRVParallelsState *s = bs->opaque;\n\n uint32_t index, offset, position;\n\n\n\n index = sector_num / s->tracks;\n\n offset = sector_num % s->tracks;\n\n\n\n // not allocated\n\n if ((index > s->catalog_size) || (s->catalog_bitmap[index] == 0))\n\n\treturn -1;\n\n\n\n position = (s->catalog_bitmap[index] + offset) * 512;\n\n\n\n// fprintf(stderr, \"sector: %llx index=%x offset=%x pointer=%x position=%x\\n\",\n\n//\tsector_num, index, offset, s->catalog_bitmap[index], position);\n\n\n\n if (lseek(s->fd, position, SEEK_SET) != position)\n\n\treturn -1;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 1091 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_pm1_cnt_init(ACPIREGS *ar, qemu_irq cmos_s3)\n\n{\n\n ar->pm1.cnt.cmos_s3 = cmos_s3;\n\n}\n", + "output": "0", + "index": 26791 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],\n const int16_t *ubuf[2], const int16_t *vbuf[2],\n const int16_t *abuf[2], uint8_t *dest, int dstW,\n int yalpha, int uvalpha, int y,\n enum PixelFormat target)\n{\n const int16_t *buf0 = buf[0], *buf1 = buf[1],\n *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],\n *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];\n int yalpha1 = 4095 - yalpha;\n int uvalpha1 = 4095 - uvalpha;\n int i;\n for (i = 0; i < (dstW >> 1); i++) {\n int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;\n int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;\n int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;\n int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;\n output_pixels(i * 4, Y1, U, Y2, V);\n }\n}", + "output": "1", + "index": 20334 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_queue_host_notifier_read(EventNotifier *n)\n\n{\n\n VirtQueue *vq = container_of(n, VirtQueue, host_notifier);\n\n if (event_notifier_test_and_clear(n)) {\n\n virtio_queue_notify_vq(vq);\n\n }\n\n}\n", + "output": "1", + "index": 9906 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void i440fx_realize(PCIDevice *dev, Error **errp)\n\n{\n\n dev->config[I440FX_SMRAM] = 0x02;\n\n\n\n if (object_property_get_bool(qdev_get_machine(), \"iommu\", NULL)) {\n\n error_report(\"warning: i440fx doesn't support emulated iommu\");\n\n }\n\n}\n", + "output": "0", + "index": 4884 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,\n\n SocketAddress *addr,\n\n QIOTaskFunc func,\n\n gpointer opaque,\n\n GDestroyNotify notify)\n\n{\n\n QIOTask *task;\n\n struct QIODNSResolverLookupData *data =\n\n g_new0(struct QIODNSResolverLookupData, 1);\n\n\n\n data->addr = QAPI_CLONE(SocketAddress, addr);\n\n\n\n task = qio_task_new(OBJECT(resolver), func, opaque, notify);\n\n\n\n qio_task_run_in_thread(task,\n\n qio_dns_resolver_lookup_worker,\n\n data,\n\n qio_dns_resolver_lookup_data_free);\n\n}\n", + "output": "0", + "index": 13004 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_write(BlockDriverState *bs, int64_t sector_num, \n\n const uint8_t *buf, int nb_sectors)\n\n{\n\n BDRVVmdkState *s = bs->opaque;\n\n int index_in_cluster, n;\n\n uint64_t cluster_offset;\n\n static int cid_update = 0;\n\n\n\n while (nb_sectors > 0) {\n\n index_in_cluster = sector_num & (s->cluster_sectors - 1);\n\n n = s->cluster_sectors - index_in_cluster;\n\n if (n > nb_sectors)\n\n n = nb_sectors;\n\n cluster_offset = get_cluster_offset(bs, sector_num << 9, 1);\n\n if (!cluster_offset)\n\n return -1;\n\n if (bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512) != n * 512)\n\n return -1;\n\n nb_sectors -= n;\n\n sector_num += n;\n\n buf += n * 512;\n\n\n\n // update CID on the first write every time the virtual disk is opened\n\n if (!cid_update) {\n\n vmdk_write_cid(bs, time(NULL));\n\n cid_update++;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 5117 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,\n\n BlockBackend *blk, qemu_irq irq, qemu_irq dma[],\n\n omap_clk fclk, omap_clk iclk)\n\n{\n\n struct omap_mmc_s *s = (struct omap_mmc_s *)\n\n g_malloc0(sizeof(struct omap_mmc_s));\n\n\n\n s->irq = irq;\n\n s->dma = dma;\n\n s->clk = fclk;\n\n s->lines = 4;\n\n s->rev = 2;\n\n\n\n omap_mmc_reset(s);\n\n\n\n memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, \"omap.mmc\",\n\n omap_l4_region_size(ta, 0));\n\n omap_l4_attach(ta, 0, &s->iomem);\n\n\n\n /* Instantiate the storage */\n\n s->card = sd_init(blk, false);\n\n if (s->card == NULL) {\n\n exit(1);\n\n }\n\n\n\n s->cdet = qemu_allocate_irq(omap_mmc_cover_cb, s, 0);\n\n sd_set_cb(s->card, NULL, s->cdet);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 9831 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_complete_req(VirtIOSCSIReq *req)\n\n{\n\n VirtIOSCSI *s = req->dev;\n\n VirtQueue *vq = req->vq;\n\n VirtIODevice *vdev = VIRTIO_DEVICE(s);\n\n\n\n qemu_iovec_from_buf(&req->resp_iov, 0, &req->resp, req->resp_size);\n\n virtqueue_push(vq, &req->elem, req->qsgl.size + req->resp_iov.size);\n\n if (s->dataplane_started && !s->dataplane_fenced) {\n\n virtio_scsi_dataplane_notify(vdev, req);\n\n } else {\n\n virtio_notify(vdev, vq);\n\n }\n\n\n\n if (req->sreq) {\n\n req->sreq->hba_private = NULL;\n\n scsi_req_unref(req->sreq);\n\n }\n\n virtio_scsi_free_req(req);\n\n}\n", + "output": "1", + "index": 696 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int query_format(struct vf_instance *vf, unsigned int fmt)\n\n{\n\n /* FIXME - figure out which other formats work */\n\n switch (fmt) {\n\n case IMGFMT_YV12:\n\n case IMGFMT_IYUV:\n\n case IMGFMT_I420:\n\n return ff_vf_next_query_format(vf, fmt);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 16871 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_blockdev_backup(const char *job_id, const char *device,\n\n const char *target, enum MirrorSyncMode sync,\n\n bool has_speed, int64_t speed,\n\n bool has_on_source_error,\n\n BlockdevOnError on_source_error,\n\n bool has_on_target_error,\n\n BlockdevOnError on_target_error,\n\n BlockJobTxn *txn, Error **errp)\n\n{\n\n BlockBackend *blk;\n\n BlockDriverState *bs;\n\n BlockDriverState *target_bs;\n\n Error *local_err = NULL;\n\n AioContext *aio_context;\n\n\n\n if (!has_speed) {\n\n speed = 0;\n\n }\n\n if (!has_on_source_error) {\n\n on_source_error = BLOCKDEV_ON_ERROR_REPORT;\n\n }\n\n if (!has_on_target_error) {\n\n on_target_error = BLOCKDEV_ON_ERROR_REPORT;\n\n }\n\n\n\n blk = blk_by_name(device);\n\n if (!blk) {\n\n error_setg(errp, \"Device '%s' not found\", device);\n\n return;\n\n }\n\n\n\n aio_context = blk_get_aio_context(blk);\n\n aio_context_acquire(aio_context);\n\n\n\n if (!blk_is_available(blk)) {\n\n error_setg(errp, \"Device '%s' has no medium\", device);\n\n goto out;\n\n }\n\n bs = blk_bs(blk);\n\n\n\n target_bs = bdrv_lookup_bs(target, target, errp);\n\n if (!target_bs) {\n\n goto out;\n\n }\n\n\n\n if (bdrv_get_aio_context(target_bs) != aio_context) {\n\n if (!bdrv_has_blk(target_bs)) {\n\n /* The target BDS is not attached, we can safely move it to another\n\n * AioContext. */\n\n bdrv_set_aio_context(target_bs, aio_context);\n\n } else {\n\n error_setg(errp, \"Target is attached to a different thread from \"\n\n \"source.\");\n\n goto out;\n\n }\n\n }\n\n backup_start(job_id, bs, target_bs, speed, sync, NULL, on_source_error,\n\n on_target_error, block_job_cb, bs, txn, &local_err);\n\n if (local_err != NULL) {\n\n error_propagate(errp, local_err);\n\n }\n\nout:\n\n aio_context_release(aio_context);\n\n}\n", + "output": "0", + "index": 26887 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)\n\n{\n\n int index = le32_to_cpu(e820_reserve.count);\n\n struct e820_entry *entry;\n\n\n\n if (type != E820_RAM) {\n\n /* old FW_CFG_E820_TABLE entry -- reservations only */\n\n if (index >= E820_NR_ENTRIES) {\n\n return -EBUSY;\n\n }\n\n entry = &e820_reserve.entry[index++];\n\n\n\n entry->address = cpu_to_le64(address);\n\n entry->length = cpu_to_le64(length);\n\n entry->type = cpu_to_le32(type);\n\n\n\n e820_reserve.count = cpu_to_le32(index);\n\n }\n\n\n\n /* new \"etc/e820\" file -- include ram too */\n\n e820_table = g_realloc(e820_table,\n\n sizeof(struct e820_entry) * (e820_entries+1));\n\n e820_table[e820_entries].address = cpu_to_le64(address);\n\n e820_table[e820_entries].length = cpu_to_le64(length);\n\n e820_table[e820_entries].type = cpu_to_le32(type);\n\n e820_entries++;\n\n\n\n return e820_entries;\n\n}\n", + "output": "1", + "index": 9287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int alac_encode_close(AVCodecContext *avctx)\n\n{\n\n AlacEncodeContext *s = avctx->priv_data;\n\n ff_lpc_end(&s->lpc_ctx);\n\n av_freep(&avctx->extradata);\n\n avctx->extradata_size = 0;\n\n av_freep(&avctx->coded_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 16062 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void do_imdct(AC3DecodeContext *s, int channels)\n\n{\n\n int ch;\n\n\n\n for (ch=1; ch<=channels; ch++) {\n\n if (s->block_switch[ch]) {\n\n int i;\n\n float *x = s->tmp_output+128;\n\n for(i=0; i<128; i++)\n\n x[i] = s->transform_coeffs[ch][2*i];\n\n ff_imdct_half(&s->imdct_256, s->tmp_output, x);\n\n s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128);\n\n for(i=0; i<128; i++)\n\n x[i] = s->transform_coeffs[ch][2*i+1];\n\n ff_imdct_half(&s->imdct_256, s->delay[ch-1], x);\n\n } else {\n\n ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]);\n\n s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128);\n\n memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float));\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 680 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kqemu_set_phys_mem(uint64_t start_addr, ram_addr_t size, \n\n ram_addr_t phys_offset)\n\n{\n\n struct kqemu_phys_mem kphys_mem1, *kphys_mem = &kphys_mem1;\n\n uint64_t end;\n\n int ret, io_index;\n\n\n\n end = (start_addr + size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;\n\n start_addr &= TARGET_PAGE_MASK;\n\n kphys_mem->phys_addr = start_addr;\n\n kphys_mem->size = end - start_addr;\n\n kphys_mem->ram_addr = phys_offset & TARGET_PAGE_MASK;\n\n io_index = phys_offset & ~TARGET_PAGE_MASK;\n\n switch(io_index) {\n\n case IO_MEM_RAM:\n\n kphys_mem->io_index = KQEMU_IO_MEM_RAM;\n\n break;\n\n case IO_MEM_ROM:\n\n kphys_mem->io_index = KQEMU_IO_MEM_ROM;\n\n break;\n\n default:\n\n if (qpi_io_memory == io_index) {\n\n kphys_mem->io_index = KQEMU_IO_MEM_COMM;\n\n } else {\n\n kphys_mem->io_index = KQEMU_IO_MEM_UNASSIGNED;\n\n }\n\n break;\n\n }\n\n#ifdef _WIN32\n\n {\n\n DWORD temp;\n\n ret = DeviceIoControl(kqemu_fd, KQEMU_SET_PHYS_MEM, \n\n kphys_mem, sizeof(*kphys_mem),\n\n NULL, 0, &temp, NULL) == TRUE ? 0 : -1;\n\n }\n\n#else\n\n ret = ioctl(kqemu_fd, KQEMU_SET_PHYS_MEM, kphys_mem);\n\n#endif\n\n if (ret < 0) {\n\n fprintf(stderr, \"kqemu: KQEMU_SET_PHYS_PAGE error=%d: start_addr=0x%016\" PRIx64 \" size=0x%08lx phys_offset=0x%08lx\\n\",\n\n ret, start_addr, \n\n (unsigned long)size, (unsigned long)phys_offset);\n\n }\n\n}\n", + "output": "0", + "index": 5634 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_pci_load_config(void * opaque, QEMUFile *f)\n\n{\n\n VirtIOPCIProxy *proxy = opaque;\n\n int ret;\n\n ret = pci_device_load(&proxy->pci_dev, f);\n\n if (ret) {\n\n return ret;\n\n }\n\n msix_load(&proxy->pci_dev, f);\n\n if (msix_present(&proxy->pci_dev)) {\n\n qemu_get_be16s(f, &proxy->vdev->config_vector);\n\n } else {\n\n proxy->vdev->config_vector = VIRTIO_NO_VECTOR;\n\n }\n\n if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {\n\n return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);\n\n }\n\n\n\n /* Try to find out if the guest has bus master disabled, but is\n\n in ready state. Then we have a buggy guest OS. */\n\n if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) &&\n\n !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {\n\n proxy->bugs |= VIRTIO_PCI_BUG_BUS_MASTER;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 9350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type)\n\n{\n\n ByteIOContext *pb = mxf->fc->pb;\n\n MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;\n\n uint64_t klv_end = url_ftell(pb) + klv->length;\n\n\n\n if (!ctx)\n\n return -1;\n\n while (url_ftell(pb) + 4 < klv_end) {\n\n int tag = get_be16(pb);\n\n int size = get_be16(pb); /* KLV specified by 0x53 */\n\n uint64_t next = url_ftell(pb) + size;\n\n UID uid = {0};\n\n\n\n dprintf(mxf->fc, \"local tag %#04x size %d\\n\", tag, size);\n\n if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */\n\n av_log(mxf->fc, AV_LOG_ERROR, \"local tag %#04x with 0 size\\n\", tag);\n\n continue;\n\n }\n\n if (tag > 0x7FFF) { /* dynamic tag */\n\n int i;\n\n for (i = 0; i < mxf->local_tags_count; i++) {\n\n int local_tag = AV_RB16(mxf->local_tags+i*18);\n\n if (local_tag == tag) {\n\n memcpy(uid, mxf->local_tags+i*18+2, 16);\n\n dprintf(mxf->fc, \"local tag %#04x\\n\", local_tag);\n\n PRINT_KEY(mxf->fc, \"uid\", uid);\n\n }\n\n }\n\n }\n\n if (ctx_size && tag == 0x3C0A)\n\n get_buffer(pb, ctx->uid, 16);\n\n else if (read_child(ctx, pb, tag, size, uid) < 0)\n\n return -1;\n\n\n\n url_fseek(pb, next, SEEK_SET);\n\n }\n\n if (ctx_size) ctx->type = type;\n\n return ctx_size ? mxf_add_metadata_set(mxf, ctx) : 0;\n\n}\n", + "output": "1", + "index": 2674 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "pp_context *pp_get_context(int width, int height, int cpuCaps){\n PPContext *c= av_mallocz(sizeof(PPContext));\n int stride= FFALIGN(width, 16); //assumed / will realloc if needed\n int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed\n c->av_class = &av_codec_context_class;\n if(cpuCaps&PP_FORMAT){\n c->hChromaSubSample= cpuCaps&0x3;\n c->vChromaSubSample= (cpuCaps>>4)&0x3;\n }else{\n c->hChromaSubSample= 1;\n c->vChromaSubSample= 1;\n }\n if (cpuCaps & PP_CPU_CAPS_AUTO) {\n c->cpuCaps = av_get_cpu_flags();\n } else {\n c->cpuCaps = 0;\n if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;\n if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;\n if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;\n if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;\n }\n reallocBuffers(c, width, height, stride, qpStride);\n c->frameNum=-1;\n return c;\n}", + "output": "1", + "index": 19066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,\n\n const AVFrame *pic_arg, int *got_packet)\n\n\n\n{\n\n MpegEncContext *s = avctx->priv_data;\n\n AVFrame *pic;\n\n int i, ret;\n\n int chroma_h_shift, chroma_v_shift;\n\n\n\n av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);\n\n\n\n //CODEC_FLAG_EMU_EDGE have to be cleared\n\n if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)\n\n return AVERROR(EINVAL);\n\n\n\n pic = av_frame_alloc();\n\n if (!pic)\n\n return AVERROR(ENOMEM);\n\n av_frame_ref(pic, pic_arg);\n\n //picture should be flipped upside-down\n\n for(i=0; i < 3; i++) {\n\n int vsample = i ? 2 >> chroma_v_shift : 2;\n\n pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));\n\n pic->linesize[i] *= -1;\n\n }\n\n ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);\n\n av_frame_free(&pic);\n\n return ret;\n\n}\n", + "output": "0", + "index": 4011 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int net_init_netmap(const NetClientOptions *opts,\n\n const char *name, NetClientState *peer, Error **errp)\n\n{\n\n const NetdevNetmapOptions *netmap_opts = opts->u.netmap;\n\n struct nm_desc *nmd;\n\n NetClientState *nc;\n\n Error *err = NULL;\n\n NetmapState *s;\n\n\n\n nmd = netmap_open(netmap_opts, &err);\n\n if (err) {\n\n error_propagate(errp, err);\n\n return -1;\n\n }\n\n /* Create the object. */\n\n nc = qemu_new_net_client(&net_netmap_info, peer, \"netmap\", name);\n\n s = DO_UPCAST(NetmapState, nc, nc);\n\n s->nmd = nmd;\n\n s->tx = NETMAP_TXRING(nmd->nifp, 0);\n\n s->rx = NETMAP_RXRING(nmd->nifp, 0);\n\n s->vnet_hdr_len = 0;\n\n pstrcpy(s->ifname, sizeof(s->ifname), netmap_opts->ifname);\n\n netmap_read_poll(s, true); /* Initially only poll for reads. */\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f)\n\n{\n\n int64_t completed_sector_sum = 0;\n\n BlkMigDevState *bmds;\n\n int progress;\n\n int ret = 0;\n\n\n\n QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {\n\n if (bmds->bulk_completed == 0) {\n\n if (mig_save_device_bulk(mon, f, bmds) == 1) {\n\n /* completed bulk section for this device */\n\n bmds->bulk_completed = 1;\n\n }\n\n completed_sector_sum += bmds->completed_sectors;\n\n ret = 1;\n\n break;\n\n } else {\n\n completed_sector_sum += bmds->completed_sectors;\n\n }\n\n }\n\n\n\n if (block_mig_state.total_sector_sum != 0) {\n\n progress = completed_sector_sum * 100 /\n\n block_mig_state.total_sector_sum;\n\n } else {\n\n progress = 100;\n\n }\n\n if (progress != block_mig_state.prev_progress) {\n\n block_mig_state.prev_progress = progress;\n\n qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)\n\n | BLK_MIG_FLAG_PROGRESS);\n\n monitor_printf(mon, \"Completed %d %%\\r\", progress);\n\n monitor_flush(mon);\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 23233 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,\n\n int64_t offset_in_cluster, const uint8_t *buf,\n\n int nb_sectors, int64_t sector_num)\n\n{\n\n int ret;\n\n VmdkGrainMarker *data = NULL;\n\n uLongf buf_len;\n\n const uint8_t *write_buf = buf;\n\n int write_len = nb_sectors * 512;\n\n\n\n if (extent->compressed) {\n\n if (!extent->has_marker) {\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n buf_len = (extent->cluster_sectors << 9) * 2;\n\n data = g_malloc(buf_len + sizeof(VmdkGrainMarker));\n\n if (compress(data->data, &buf_len, buf, nb_sectors << 9) != Z_OK ||\n\n buf_len == 0) {\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n data->lba = sector_num;\n\n data->size = buf_len;\n\n write_buf = (uint8_t *)data;\n\n write_len = buf_len + sizeof(VmdkGrainMarker);\n\n }\n\n ret = bdrv_pwrite(extent->file,\n\n cluster_offset + offset_in_cluster,\n\n write_buf,\n\n write_len);\n\n if (ret != write_len) {\n\n ret = ret < 0 ? ret : -EIO;\n\n goto out;\n\n }\n\n ret = 0;\n\n out:\n\n g_free(data);\n\n return ret;\n\n}\n", + "output": "1", + "index": 7697 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_422_bitstream(HYuvContext *s, int count)\n\n{\n\n int i;\n\n\n\n count /= 2;\n\n\n\n if (count >= (get_bits_left(&s->gb)) / (31 * 4)) {\n\n for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {\n\n READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);\n\n READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2);\n\n }\n\n\n\n\n } else {\n\n for (i = 0; i < count; i++) {\n\n READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);\n\n READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2);\n\n }\n\n }\n\n}", + "output": "1", + "index": 8907 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SocketAddressLegacy *socket_parse(const char *str, Error **errp)\n\n{\n\n SocketAddressLegacy *addr;\n\n\n\n addr = g_new0(SocketAddressLegacy, 1);\n\n if (strstart(str, \"unix:\", NULL)) {\n\n if (str[5] == '\\0') {\n\n error_setg(errp, \"invalid Unix socket address\");\n\n goto fail;\n\n } else {\n\n addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;\n\n addr->u.q_unix.data = g_new(UnixSocketAddress, 1);\n\n addr->u.q_unix.data->path = g_strdup(str + 5);\n\n }\n\n } else if (strstart(str, \"fd:\", NULL)) {\n\n if (str[3] == '\\0') {\n\n error_setg(errp, \"invalid file descriptor address\");\n\n goto fail;\n\n } else {\n\n addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD;\n\n addr->u.fd.data = g_new(String, 1);\n\n addr->u.fd.data->str = g_strdup(str + 3);\n\n }\n\n } else if (strstart(str, \"vsock:\", NULL)) {\n\n addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;\n\n addr->u.vsock.data = g_new(VsockSocketAddress, 1);\n\n if (vsock_parse(addr->u.vsock.data, str + strlen(\"vsock:\"), errp)) {\n\n goto fail;\n\n }\n\n } else {\n\n addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;\n\n addr->u.inet.data = g_new(InetSocketAddress, 1);\n\n if (inet_parse(addr->u.inet.data, str, errp)) {\n\n goto fail;\n\n }\n\n }\n\n return addr;\n\n\n\nfail:\n\n qapi_free_SocketAddressLegacy(addr);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 3515 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_ivi_inverse_haar_4x4(const int32_t *in, int16_t *out, ptrdiff_t pitch,\n\n const uint8_t *flags)\n\n{\n\n int i, shift, sp1, sp2;\n\n const int32_t *src;\n\n int32_t *dst;\n\n int tmp[16];\n\n int t0, t1, t2, t3, t4;\n\n\n\n /* apply the InvHaar4 to all columns */\n\n#define COMPENSATE(x) (x)\n\n src = in;\n\n dst = tmp;\n\n for (i = 0; i < 4; i++) {\n\n if (flags[i]) {\n\n /* pre-scaling */\n\n shift = !(i & 2);\n\n sp1 = src[0] << shift;\n\n sp2 = src[4] << shift;\n\n INV_HAAR4( sp1, sp2, src[8], src[12],\n\n dst[0], dst[4], dst[8], dst[12],\n\n t0, t1, t2, t3, t4);\n\n } else\n\n dst[0] = dst[4] = dst[8] = dst[12] = 0;\n\n\n\n src++;\n\n dst++;\n\n }\n\n#undef COMPENSATE\n\n\n\n /* apply the InvHaar8 to all rows */\n\n#define COMPENSATE(x) (x)\n\n src = tmp;\n\n for (i = 0; i < 4; i++) {\n\n if (!src[0] && !src[1] && !src[2] && !src[3]) {\n\n memset(out, 0, 4 * sizeof(out[0]));\n\n } else {\n\n INV_HAAR4(src[0], src[1], src[2], src[3],\n\n out[0], out[1], out[2], out[3],\n\n t0, t1, t2, t3, t4);\n\n }\n\n src += 4;\n\n out += pitch;\n\n }\n\n#undef COMPENSATE\n\n}\n", + "output": "1", + "index": 12181 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_native_list_int32(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n test_native_list_integer_helper(data, unused,\n\n USER_DEF_NATIVE_LIST_UNION_KIND_S32);\n\n}\n", + "output": "0", + "index": 13494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_enabled(void)\n\n{\n\n int i;\n\n\n\n throttle_config_init(&cfg);\n\n g_assert(!throttle_enabled(&cfg));\n\n\n\n for (i = 0; i < BUCKETS_COUNT; i++) {\n\n throttle_config_init(&cfg);\n\n set_cfg_value(false, i, 150);\n\n g_assert(throttle_enabled(&cfg));\n\n }\n\n\n\n for (i = 0; i < BUCKETS_COUNT; i++) {\n\n throttle_config_init(&cfg);\n\n set_cfg_value(false, i, -150);\n\n g_assert(!throttle_enabled(&cfg));\n\n }\n\n}\n", + "output": "1", + "index": 10423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int start_auth_vencrypt(VncState *vs)\n\n{\n\n /* Send VeNCrypt version 0.2 */\n\n vnc_write_u8(vs, 0);\n\n vnc_write_u8(vs, 2);\n\n\n\n vnc_read_when(vs, protocol_client_vencrypt_init, 2);\n\n return 0;\n\n}\n", + "output": "0", + "index": 7863 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,\n\n size_t max_len, hwaddr addr, const char *fw_file_name,\n\n FWCfgReadCallback fw_callback, void *callback_opaque)\n\n{\n\n MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());\n\n Rom *rom;\n\n MemoryRegion *mr = NULL;\n\n\n\n rom = g_malloc0(sizeof(*rom));\n\n rom->name = g_strdup(name);\n\n rom->addr = addr;\n\n rom->romsize = max_len ? max_len : len;\n\n rom->datasize = len;\n\n rom->data = g_malloc0(rom->datasize);\n\n memcpy(rom->data, blob, len);\n\n rom_insert(rom);\n\n if (fw_file_name && fw_cfg) {\n\n char devpath[100];\n\n void *data;\n\n\n\n snprintf(devpath, sizeof(devpath), \"/rom@%s\", fw_file_name);\n\n\n\n if (mc->rom_file_has_mr) {\n\n data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);\n\n mr = rom->mr;\n\n } else {\n\n data = rom->data;\n\n }\n\n\n\n fw_cfg_add_file_callback(fw_cfg, fw_file_name,\n\n fw_callback, callback_opaque,\n\n data, rom->datasize);\n\n }\n\n return mr;\n\n}\n", + "output": "0", + "index": 23115 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_display_close(VncDisplay *vs)\n\n{\n\n if (!vs)\n\n return;\n\n vs->enabled = false;\n\n vs->is_unix = false;\n\n if (vs->lsock != NULL) {\n\n if (vs->lsock_tag) {\n\n g_source_remove(vs->lsock_tag);\n\n }\n\n object_unref(OBJECT(vs->lsock));\n\n vs->lsock = NULL;\n\n }\n\n vs->ws_enabled = false;\n\n if (vs->lwebsock != NULL) {\n\n if (vs->lwebsock_tag) {\n\n g_source_remove(vs->lwebsock_tag);\n\n }\n\n object_unref(OBJECT(vs->lwebsock));\n\n vs->lwebsock = NULL;\n\n }\n\n vs->auth = VNC_AUTH_INVALID;\n\n vs->subauth = VNC_AUTH_INVALID;\n\n if (vs->tlscreds) {\n\n object_unparent(OBJECT(vs->tlscreds));\n\n\n }\n\n g_free(vs->tlsaclname);\n\n vs->tlsaclname = NULL;\n\n}", + "output": "1", + "index": 4382 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int esp_pci_scsi_init(PCIDevice *dev)\n\n{\n\n PCIESPState *pci = PCI_ESP(dev);\n\n DeviceState *d = DEVICE(dev);\n\n ESPState *s = &pci->esp;\n\n uint8_t *pci_conf;\n\n Error *err = NULL;\n\n\n\n pci_conf = dev->config;\n\n\n\n /* Interrupt pin A */\n\n pci_conf[PCI_INTERRUPT_PIN] = 0x01;\n\n\n\n s->dma_memory_read = esp_pci_dma_memory_read;\n\n s->dma_memory_write = esp_pci_dma_memory_write;\n\n s->dma_opaque = pci;\n\n s->chip_id = TCHI_AM53C974;\n\n memory_region_init_io(&pci->io, OBJECT(pci), &esp_pci_io_ops, pci,\n\n \"esp-io\", 0x80);\n\n\n\n pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->io);\n\n s->irq = pci_allocate_irq(dev);\n\n\n\n scsi_bus_new(&s->bus, sizeof(s->bus), d, &esp_pci_scsi_info, NULL);\n\n if (!d->hotplugged) {\n\n scsi_bus_legacy_handle_cmdline(&s->bus, &err);\n\n if (err != NULL) {\n\n\n error_free(err);\n\n return -1;\n\n }\n\n }\n\n return 0;\n\n}", + "output": "1", + "index": 11748 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void in_asm_used_var_warning_killer()\n\n{\n\n volatile int i= yCoeff+vrCoeff+ubCoeff+vgCoeff+ugCoeff+bF8+bFC+w400+w80+w10+\n\n bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+asm_yalpha1+ asm_uvalpha1+\n\n M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0];\n\n if(i) i=0;\n\n}\n", + "output": "0", + "index": 15748 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t ehci_mem_readl(void *ptr, target_phys_addr_t addr)\n\n{\n\n EHCIState *s = ptr;\n\n uint32_t val;\n\n\n\n val = s->mmio[addr] | (s->mmio[addr+1] << 8) |\n\n (s->mmio[addr+2] << 16) | (s->mmio[addr+3] << 24);\n\n\n\n trace_usb_ehci_mmio_readl(addr, addr2str(addr), val);\n\n return val;\n\n}\n", + "output": "1", + "index": 11228 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)\n\n{\n\n Error *err = NULL;\n\n MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);\n\n MemoryDeviceInfoList *info;\n\n MemoryDeviceInfo *value;\n\n PCDIMMDeviceInfo *di;\n\n\n\n for (info = info_list; info; info = info->next) {\n\n value = info->value;\n\n\n\n if (value) {\n\n switch (value->kind) {\n\n case MEMORY_DEVICE_INFO_KIND_DIMM:\n\n di = value->dimm;\n\n\n\n monitor_printf(mon, \"Memory device [%s]: \\\"%s\\\"\\n\",\n\n MemoryDeviceInfoKind_lookup[value->kind],\n\n di->id ? di->id : \"\");\n\n monitor_printf(mon, \" addr: 0x%\" PRIx64 \"\\n\", di->addr);\n\n monitor_printf(mon, \" slot: %\" PRId64 \"\\n\", di->slot);\n\n monitor_printf(mon, \" node: %\" PRId64 \"\\n\", di->node);\n\n monitor_printf(mon, \" size: %\" PRIu64 \"\\n\", di->size);\n\n monitor_printf(mon, \" memdev: %s\\n\", di->memdev);\n\n monitor_printf(mon, \" hotplugged: %s\\n\",\n\n di->hotplugged ? \"true\" : \"false\");\n\n monitor_printf(mon, \" hotpluggable: %s\\n\",\n\n di->hotpluggable ? \"true\" : \"false\");\n\n break;\n\n default:\n\n break;\n\n }\n\n }\n\n }\n\n\n\n qapi_free_MemoryDeviceInfoList(info_list);\n\n}\n", + "output": "0", + "index": 2057 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t lance_mem_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n SysBusPCNetState *d = opaque;\n\n uint32_t val;\n\n\n\n val = pcnet_ioport_readw(&d->state, addr);\n\n trace_lance_mem_readw(addr, val & 0xffff);\n\n return val & 0xffff;\n\n}\n", + "output": "0", + "index": 4560 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qio_channel_websock_write_close(QIOChannelWebsock *ioc,\n\n uint16_t code, const char *reason)\n\n{\n\n struct iovec iov;\n\n buffer_reserve(&ioc->rawoutput, 2 + (reason ? strlen(reason) : 0));\n\n *(uint16_t *)(ioc->rawoutput.buffer + ioc->rawoutput.offset) =\n\n cpu_to_be16(code);\n\n ioc->rawoutput.offset += 2;\n\n if (reason) {\n\n buffer_append(&ioc->rawoutput, reason, strlen(reason));\n\n }\n\n iov.iov_base = ioc->rawoutput.buffer;\n\n iov.iov_len = ioc->rawoutput.offset;\n\n qio_channel_websock_encode(ioc, QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE,\n\n &iov, 1, iov.iov_len);\n\n buffer_reset(&ioc->rawoutput);\n\n qio_channel_websock_write_wire(ioc, NULL);\n\n qio_channel_shutdown(ioc->master, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);\n\n}\n", + "output": "0", + "index": 12023 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void curl_close(BlockDriverState *bs)\n\n{\n\n BDRVCURLState *s = bs->opaque;\n\n int i;\n\n\n\n DPRINTF(\"CURL: Close\\n\");\n\n for (i=0; istates[i].in_use)\n\n curl_clean_state(&s->states[i]);\n\n if (s->states[i].curl) {\n\n curl_easy_cleanup(s->states[i].curl);\n\n s->states[i].curl = NULL;\n\n }\n\n if (s->states[i].orig_buf) {\n\n g_free(s->states[i].orig_buf);\n\n s->states[i].orig_buf = NULL;\n\n }\n\n }\n\n if (s->multi)\n\n curl_multi_cleanup(s->multi);\n\n\n\n timer_del(&s->timer);\n\n\n\n g_free(s->url);\n\n}\n", + "output": "0", + "index": 15488 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_egolomb(GetBitContext *gb)\n\n{\n\n int v = 4;\n\n\n\n while (get_bits1(gb)) v++;\n\n\n\n return (1 << v) + get_bits(gb, v);\n\n}\n", + "output": "0", + "index": 17126 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_bh_delete(QEMUBH *bh)\n\n{\n\n qemu_bh_cancel(bh);\n\n qemu_free(bh);\n\n}\n", + "output": "1", + "index": 10182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void empty_input(void)\n\n{\n\n const char *empty = \"\";\n\n\n\n QObject *obj = qobject_from_json(empty, NULL);\n\n g_assert(obj == NULL);\n\n}\n", + "output": "1", + "index": 13692 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_vga_quirk_teardown(VFIODevice *vdev)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < ARRAY_SIZE(vdev->vga.region); i++) {\n\n while (!QLIST_EMPTY(&vdev->vga.region[i].quirks)) {\n\n VFIOQuirk *quirk = QLIST_FIRST(&vdev->vga.region[i].quirks);\n\n memory_region_del_subregion(&vdev->vga.region[i].mem, &quirk->mem);\n\n\n QLIST_REMOVE(quirk, next);\n\n g_free(quirk);\n\n }\n\n }\n\n}", + "output": "1", + "index": 21982 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_create_post_mksock(V9fsState *s, V9fsCreateState *vs,\n\n int err)\n\n{\n\n if (err) {\n\n err = -errno;\n\n goto out;\n\n }\n\n\n\n err = v9fs_do_chmod(s, &vs->fullname, vs->perm & 0777);\n\n v9fs_create_post_perms(s, vs, err);\n\n return;\n\n\n\nout:\n\n v9fs_post_create(s, vs, err);\n\n}\n", + "output": "0", + "index": 22866 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel8_mc20_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hz_8w_msa(src - 2, stride, dst, stride, 8);\n\n}\n", + "output": "0", + "index": 1538 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_opts_print(QemuOpts *opts)\n\n{\n\n QemuOpt *opt;\n\n QemuOptDesc *desc = opts->list->desc;\n\n\n\n if (desc[0].name == NULL) {\n\n QTAILQ_FOREACH(opt, &opts->head, next) {\n\n printf(\"%s=\\\"%s\\\" \", opt->name, opt->str);\n\n }\n\n return;\n\n }\n\n for (; desc && desc->name; desc++) {\n\n const char *value;\n\n QemuOpt *opt = qemu_opt_find(opts, desc->name);\n\n\n\n value = opt ? opt->str : desc->def_value_str;\n\n if (!value) {\n\n continue;\n\n }\n\n if (desc->type == QEMU_OPT_STRING) {\n\n printf(\"%s='%s' \", desc->name, value);\n\n } else if ((desc->type == QEMU_OPT_SIZE ||\n\n desc->type == QEMU_OPT_NUMBER) && opt) {\n\n printf(\"%s=%\" PRId64 \" \", desc->name, opt->value.uint);\n\n } else {\n\n printf(\"%s=%s \", desc->name, value);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 22994 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_addco (void)\n\n{\n\n T2 = T0;\n\n T0 += T1;\n\n if (likely(T0 >= T2)) {\n\n xer_ca = 0;\n\n } else {\n\n xer_ca = 1;\n\n }\n\n if (likely(!((T2 ^ T1 ^ (-1)) & (T2 ^ T0) & (1 << 31)))) {\n\n xer_ov = 0;\n\n } else {\n\n xer_so = 1;\n\n xer_ov = 1;\n\n }\n\n}\n", + "output": "1", + "index": 19781 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int register_savevm_live(const char *idstr,\n\n int instance_id,\n\n int version_id,\n\n SaveLiveStateHandler *save_live_state,\n\n SaveStateHandler *save_state,\n\n LoadStateHandler *load_state,\n\n void *opaque)\n\n{\n\n SaveStateEntry *se;\n\n\n\n se = qemu_malloc(sizeof(SaveStateEntry));\n\n pstrcpy(se->idstr, sizeof(se->idstr), idstr);\n\n se->version_id = version_id;\n\n se->section_id = global_section_id++;\n\n se->save_live_state = save_live_state;\n\n se->save_state = save_state;\n\n se->load_state = load_state;\n\n se->opaque = opaque;\n\n se->vmsd = NULL;\n\n\n\n if (instance_id == -1) {\n\n se->instance_id = calculate_new_instance_id(idstr);\n\n } else {\n\n se->instance_id = instance_id;\n\n }\n\n /* add at the end of list */\n\n TAILQ_INSERT_TAIL(&savevm_handlers, se, entry);\n\n return 0;\n\n}\n", + "output": "0", + "index": 23013 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_subfzeo_64 (void)\n\n{\n\n T1 = T0;\n\n T0 = ~T0 + xer_ca;\n\n if (likely(!(((uint64_t)~T1 ^ UINT64_MAX) &\n\n ((uint64_t)(~T1) ^ (uint64_t)T0) & (1ULL << 63)))) {\n\n xer_ov = 0;\n\n } else {\n\n xer_ov = 1;\n\n xer_so = 1;\n\n }\n\n if (likely((uint64_t)T0 >= (uint64_t)~T1)) {\n\n xer_ca = 0;\n\n } else {\n\n xer_ca = 1;\n\n }\n\n}\n", + "output": "1", + "index": 24737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void termsig_handler(int signum)\n\n{\n\n static int sigterm_reported;\n\n if (!sigterm_reported) {\n\n sigterm_reported = (write(sigterm_wfd, \"\", 1) == 1);\n\n }\n\n}\n", + "output": "0", + "index": 17659 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_config(BDRVNBDState *s, QDict *options, char **export)\n\n{\n\n Error *local_err = NULL;\n\n\n\n if (qdict_haskey(options, \"path\") == qdict_haskey(options, \"host\")) {\n\n if (qdict_haskey(options, \"path\")) {\n\n qerror_report(ERROR_CLASS_GENERIC_ERROR, \"path and host may not \"\n\n \"be used at the same time.\");\n\n } else {\n\n qerror_report(ERROR_CLASS_GENERIC_ERROR, \"one of path and host \"\n\n \"must be specified.\");\n\n }\n\n return -EINVAL;\n\n }\n\n\n\n s->client.is_unix = qdict_haskey(options, \"path\");\n\n s->socket_opts = qemu_opts_create(&socket_optslist, NULL, 0,\n\n &error_abort);\n\n\n\n qemu_opts_absorb_qdict(s->socket_opts, options, &local_err);\n\n if (local_err) {\n\n qerror_report_err(local_err);\n\n error_free(local_err);\n\n return -EINVAL;\n\n }\n\n\n\n if (!qemu_opt_get(s->socket_opts, \"port\")) {\n\n qemu_opt_set_number(s->socket_opts, \"port\", NBD_DEFAULT_PORT);\n\n }\n\n\n\n *export = g_strdup(qdict_get_try_str(options, \"export\"));\n\n if (*export) {\n\n qdict_del(options, \"export\");\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 5029 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "e1000_can_receive(NetClientState *nc)\n\n{\n\n E1000State *s = qemu_get_nic_opaque(nc);\n\n\n\n return (s->mac_reg[RCTL] & E1000_RCTL_EN) && e1000_has_rxbufs(s, 1);\n\n}\n", + "output": "1", + "index": 16753 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_core_release(DeviceState *dev, void *opaque)\n\n{\n\n HotplugHandler *hotplug_ctrl;\n\n\n\n hotplug_ctrl = qdev_get_hotplug_handler(dev);\n\n hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);\n\n}\n", + "output": "0", + "index": 11153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int test_vector_fmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,\n\n const float *v1, const float *src0, float scale)\n\n{\n\n LOCAL_ALIGNED(32, float, cdst, [LEN]);\n\n LOCAL_ALIGNED(32, float, odst, [LEN]);\n\n int ret;\n\n\n\n memcpy(cdst, v1, LEN * sizeof(*v1));\n\n memcpy(odst, v1, LEN * sizeof(*v1));\n\n\n\n cdsp->vector_fmac_scalar(cdst, src0, scale, LEN);\n\n fdsp->vector_fmac_scalar(odst, src0, scale, LEN);\n\n\n\n if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST))\n\n av_log(NULL, AV_LOG_ERROR, \"vector_fmac_scalar failed\\n\");\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 6512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref)\n\n{\n\n AVFilterLink *out = NULL;\n\n\n\n if(link->dst->output_count)\n\n out = link->dst->outputs[0];\n\n\n\n if(out) {\n\n out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, link->w, link->h);\n\n out->outpic->pts = picref->pts;\n\n avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));\n\n }\n\n}\n", + "output": "1", + "index": 9930 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dump_map_entry(OutputFormat output_format, MapEntry *e,\n\n MapEntry *next)\n\n{\n\n switch (output_format) {\n\n case OFORMAT_HUMAN:\n\n if ((e->flags & BDRV_BLOCK_DATA) &&\n\n !(e->flags & BDRV_BLOCK_OFFSET_VALID)) {\n\n error_report(\"File contains external, encrypted or compressed clusters.\");\n\n exit(1);\n\n }\n\n if ((e->flags & (BDRV_BLOCK_DATA|BDRV_BLOCK_ZERO)) == BDRV_BLOCK_DATA) {\n\n printf(\"%#-16\"PRIx64\"%#-16\"PRIx64\"%#-16\"PRIx64\"%s\\n\",\n\n e->start, e->length, e->offset, e->bs->filename);\n\n }\n\n /* This format ignores the distinction between 0, ZERO and ZERO|DATA.\n\n * Modify the flags here to allow more coalescing.\n\n */\n\n if (next &&\n\n (next->flags & (BDRV_BLOCK_DATA|BDRV_BLOCK_ZERO)) != BDRV_BLOCK_DATA) {\n\n next->flags &= ~BDRV_BLOCK_DATA;\n\n next->flags |= BDRV_BLOCK_ZERO;\n\n }\n\n break;\n\n case OFORMAT_JSON:\n\n printf(\"%s{ \\\"start\\\": %\"PRId64\", \\\"length\\\": %\"PRId64\", \\\"depth\\\": %d,\"\n\n \" \\\"zero\\\": %s, \\\"data\\\": %s\",\n\n (e->start == 0 ? \"[\" : \",\\n\"),\n\n e->start, e->length, e->depth,\n\n (e->flags & BDRV_BLOCK_ZERO) ? \"true\" : \"false\",\n\n (e->flags & BDRV_BLOCK_DATA) ? \"true\" : \"false\");\n\n if (e->flags & BDRV_BLOCK_OFFSET_VALID) {\n\n printf(\", 'offset': %\"PRId64\"\", e->offset);\n\n }\n\n putchar('}');\n\n\n\n if (!next) {\n\n printf(\"]\\n\");\n\n }\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 25826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void omap_badwidth_write16(void *opaque, target_phys_addr_t addr,\n\n uint32_t value)\n\n{\n\n uint16_t val16 = value;\n\n\n\n OMAP_16B_REG(addr);\n\n cpu_physical_memory_write(addr, (void *) &val16, 2);\n\n}\n", + "output": "0", + "index": 14727 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int gen_neon_unzip(int rd, int rm, int size, int q)\n\n{\n\n TCGv tmp, tmp2;\n\n if (size == 3 || (!q && size == 2)) {\n\n return 1;\n\n }\n\n tmp = tcg_const_i32(rd);\n\n tmp2 = tcg_const_i32(rm);\n\n if (q) {\n\n switch (size) {\n\n case 0:\n\n gen_helper_neon_qunzip8(tmp, tmp2);\n\n break;\n\n case 1:\n\n gen_helper_neon_qunzip16(tmp, tmp2);\n\n break;\n\n case 2:\n\n gen_helper_neon_qunzip32(tmp, tmp2);\n\n break;\n\n default:\n\n abort();\n\n }\n\n } else {\n\n switch (size) {\n\n case 0:\n\n gen_helper_neon_unzip8(tmp, tmp2);\n\n break;\n\n case 1:\n\n gen_helper_neon_unzip16(tmp, tmp2);\n\n break;\n\n default:\n\n abort();\n\n }\n\n }\n\n tcg_temp_free_i32(tmp);\n\n tcg_temp_free_i32(tmp2);\n\n return 0;\n\n}\n", + "output": "1", + "index": 13966 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)\n\n{\n\n PCIDevice *s = container_of(pv, PCIDevice, config);\n\n uint32_t irq_state[PCI_NUM_PINS];\n\n int i;\n\n for (i = 0; i < PCI_NUM_PINS; ++i) {\n\n irq_state[i] = qemu_get_be32(f);\n\n if (irq_state[i] != 0x1 && irq_state[i] != 0) {\n\n fprintf(stderr, \"irq state %d: must be 0 or 1.\\n\",\n\n irq_state[i]);\n\n return -EINVAL;\n\n }\n\n }\n\n\n\n for (i = 0; i < PCI_NUM_PINS; ++i) {\n\n pci_set_irq_state(s, i, irq_state[i]);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 7821 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,\n\n DriveInfo **fds, qemu_irq *fdc_tc)\n\n{\n\n DeviceState *dev;\n\n fdctrl_sysbus_t *sys;\n\n fdctrl_t *fdctrl;\n\n\n\n dev = qdev_create(NULL, \"SUNW,fdtwo\");\n\n qdev_prop_set_drive(dev, \"drive\", fds[0]);\n\n if (qdev_init(dev) != 0)\n\n return NULL;\n\n sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);\n\n fdctrl = &sys->state;\n\n sysbus_connect_irq(&sys->busdev, 0, irq);\n\n sysbus_mmio_map(&sys->busdev, 0, io_base);\n\n *fdc_tc = qdev_get_gpio_in(dev, 0);\n\n\n\n return fdctrl;\n\n}\n", + "output": "1", + "index": 17834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void laio_cleanup(void *s_)\n{\n struct qemu_laio_state *s = s_;\n event_notifier_cleanup(&s->e);\n g_free(s);", + "output": "1", + "index": 26049 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dp8393x_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)\n\n{\n\n uint16_t old_val = dp8393x_readw(opaque, addr & ~0x1);\n\n\n\n switch (addr & 3) {\n\n case 0:\n\n val = val | (old_val & 0xff00);\n\n break;\n\n case 1:\n\n val = (val << 8) | (old_val & 0x00ff);\n\n break;\n\n }\n\n dp8393x_writew(opaque, addr & ~0x1, val);\n\n}\n", + "output": "0", + "index": 17688 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t mcf_intc_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n int offset;\n\n mcf_intc_state *s = (mcf_intc_state *)opaque;\n\n offset = addr & 0xff;\n\n if (offset >= 0x40 && offset < 0x80) {\n\n return s->icr[offset - 0x40];\n\n }\n\n switch (offset) {\n\n case 0x00:\n\n return (uint32_t)(s->ipr >> 32);\n\n case 0x04:\n\n return (uint32_t)s->ipr;\n\n case 0x08:\n\n return (uint32_t)(s->imr >> 32);\n\n case 0x0c:\n\n return (uint32_t)s->imr;\n\n case 0x10:\n\n return (uint32_t)(s->ifr >> 32);\n\n case 0x14:\n\n return (uint32_t)s->ifr;\n\n case 0xe0: /* SWIACK. */\n\n return s->active_vector;\n\n case 0xe1: case 0xe2: case 0xe3: case 0xe4:\n\n case 0xe5: case 0xe6: case 0xe7:\n\n /* LnIACK */\n\n hw_error(\"mcf_intc_read: LnIACK not implemented\\n\");\n\n default:\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 16041 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_init_pci_1_5(QEMUMachineInitArgs *args)\n\n{\n\n has_pci_info = false;\n\n pc_init_pci(args);\n\n}\n", + "output": "1", + "index": 24006 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)\n\n{\n\n TC6393xbState *s;\n\n DriveInfo *nand;\n\n static const MemoryRegionOps tc6393xb_ops = {\n\n .read = tc6393xb_readb,\n\n .write = tc6393xb_writeb,\n\n .endianness = DEVICE_NATIVE_ENDIAN,\n\n .impl = {\n\n .min_access_size = 1,\n\n .max_access_size = 1,\n\n },\n\n };\n\n\n\n s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));\n\n s->irq = irq;\n\n s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);\n\n\n\n s->l3v = qemu_allocate_irq(tc6393xb_l3v, s, 0);\n\n s->blanked = 1;\n\n\n\n s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);\n\n\n\n nand = drive_get(IF_MTD, 0, 0);\n\n s->flash = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,\n\n NAND_MFR_TOSHIBA, 0x76);\n\n\n\n memory_region_init_io(&s->iomem, NULL, &tc6393xb_ops, s, \"tc6393xb\", 0x10000);\n\n memory_region_add_subregion(sysmem, base, &s->iomem);\n\n\n\n memory_region_init_ram(&s->vram, NULL, \"tc6393xb.vram\", 0x100000,\n\n &error_abort);\n\n vmstate_register_ram_global(&s->vram);\n\n s->vram_ptr = memory_region_get_ram_ptr(&s->vram);\n\n memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);\n\n s->scr_width = 480;\n\n s->scr_height = 640;\n\n s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 24624 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void text_console_do_init(CharDriverState *chr, DisplayState *ds)\n\n{\n\n TextConsole *s;\n\n static int color_inited;\n\n\n\n s = chr->opaque;\n\n\n\n chr->chr_write = console_puts;\n\n chr->chr_send_event = console_send_event;\n\n\n\n s->out_fifo.buf = s->out_fifo_buf;\n\n s->out_fifo.buf_size = sizeof(s->out_fifo_buf);\n\n s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);\n\n s->ds = ds;\n\n\n\n if (!color_inited) {\n\n color_inited = 1;\n\n console_color_init(s->ds);\n\n }\n\n s->y_displayed = 0;\n\n s->y_base = 0;\n\n s->total_height = DEFAULT_BACKSCROLL;\n\n s->x = 0;\n\n s->y = 0;\n\n if (s->console_type == TEXT_CONSOLE) {\n\n s->g_width = ds_get_width(s->ds);\n\n s->g_height = ds_get_height(s->ds);\n\n }\n\n\n\n s->hw_invalidate = text_console_invalidate;\n\n s->hw_text_update = text_console_update;\n\n s->hw = s;\n\n\n\n /* Set text attribute defaults */\n\n s->t_attrib_default.bold = 0;\n\n s->t_attrib_default.uline = 0;\n\n s->t_attrib_default.blink = 0;\n\n s->t_attrib_default.invers = 0;\n\n s->t_attrib_default.unvisible = 0;\n\n s->t_attrib_default.fgcol = COLOR_WHITE;\n\n s->t_attrib_default.bgcol = COLOR_BLACK;\n\n /* set current text attributes to default */\n\n s->t_attrib = s->t_attrib_default;\n\n text_console_resize(s);\n\n\n\n if (chr->label) {\n\n char msg[128];\n\n int len;\n\n\n\n s->t_attrib.bgcol = COLOR_BLUE;\n\n len = snprintf(msg, sizeof(msg), \"%s console\\r\\n\", chr->label);\n\n console_puts(chr, (uint8_t*)msg, len);\n\n s->t_attrib = s->t_attrib_default;\n\n }\n\n\n\n qemu_chr_generic_open(chr);\n\n if (chr->init)\n\n chr->init(chr);\n\n}\n", + "output": "0", + "index": 10703 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_client_co_flush(BlockDriverState *bs)\n\n{\n\n NBDClientSession *client = nbd_get_client_session(bs);\n\n NBDRequest request = { .type = NBD_CMD_FLUSH };\n\n NBDReply reply;\n\n ssize_t ret;\n\n\n\n if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) {\n\n return 0;\n\n }\n\n\n\n request.from = 0;\n\n request.len = 0;\n\n\n\n nbd_coroutine_start(client, &request);\n\n ret = nbd_co_send_request(bs, &request, NULL);\n\n if (ret < 0) {\n\n reply.error = -ret;\n\n } else {\n\n nbd_co_receive_reply(client, &request, &reply, NULL);\n\n }\n\n nbd_coroutine_end(bs, &request);\n\n return -reply.error;\n\n}\n", + "output": "1", + "index": 25845 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_parser_close(AVCodecParserContext *s)\n\n{\n\n if(s){\n\n if (s->parser->parser_close) {\n\n ff_lock_avcodec(NULL);\n\n s->parser->parser_close(s);\n\n ff_unlock_avcodec();\n\n }\n\n av_free(s->priv_data);\n\n av_free(s);\n\n }\n\n}\n", + "output": "1", + "index": 3120 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dump_receive(void *opaque, const uint8_t *buf, size_t size)\n\n{\n\n DumpState *s = opaque;\n\n struct pcap_sf_pkthdr hdr;\n\n int64_t ts;\n\n int caplen;\n\n\n\n /* Early return in case of previous error. */\n\n if (s->fd < 0) {\n\n return;\n\n }\n\n\n\n ts = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);\n\n caplen = size > s->pcap_caplen ? s->pcap_caplen : size;\n\n\n\n hdr.ts.tv_sec = ts / 1000000;\n\n hdr.ts.tv_usec = ts % 1000000;\n\n hdr.caplen = caplen;\n\n hdr.len = size;\n\n if (write(s->fd, &hdr, sizeof(hdr)) != sizeof(hdr) ||\n\n write(s->fd, buf, caplen) != caplen) {\n\n qemu_log(\"-net dump write error - stop dump\\n\");\n\n close(s->fd);\n\n s->fd = -1;\n\n }\n\n}\n", + "output": "0", + "index": 1978 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "set_rdt(E1000State *s, int index, uint32_t val)\n\n{\n\n s->check_rxov = 0;\n\n s->mac_reg[index] = val & 0xffff;\n\n if (e1000_has_rxbufs(s, 1)) {\n\n qemu_flush_queued_packets(&s->nic->nc);\n\n }\n\n}\n", + "output": "0", + "index": 2483 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void stq_phys(target_phys_addr_t addr, uint64_t val)\n\n{\n\n val = tswap64(val);\n\n cpu_physical_memory_write(addr, &val, 8);\n\n}\n", + "output": "0", + "index": 16551 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pl061_load(QEMUFile *f, void *opaque, int version_id)\n\n{\n\n pl061_state *s = (pl061_state *)opaque;\n\n if (version_id != 1)\n\n return -EINVAL;\n\n\n\n s->locked = qemu_get_be32(f);\n\n s->data = qemu_get_be32(f);\n\n s->old_data = qemu_get_be32(f);\n\n s->dir = qemu_get_be32(f);\n\n s->isense = qemu_get_be32(f);\n\n s->ibe = qemu_get_be32(f);\n\n s->iev = qemu_get_be32(f);\n\n s->im = qemu_get_be32(f);\n\n s->istate = qemu_get_be32(f);\n\n s->afsel = qemu_get_be32(f);\n\n s->dr2r = qemu_get_be32(f);\n\n s->dr4r = qemu_get_be32(f);\n\n s->dr8r = qemu_get_be32(f);\n\n s->odr = qemu_get_be32(f);\n\n s->pur = qemu_get_be32(f);\n\n s->pdr = qemu_get_be32(f);\n\n s->slr = qemu_get_be32(f);\n\n s->den = qemu_get_be32(f);\n\n s->cr = qemu_get_be32(f);\n\n s->float_high = qemu_get_be32(f);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 16148 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nic_can_receive(void *opaque)\n\n{\n\n dp8393xState *s = opaque;\n\n\n\n if (!(s->regs[SONIC_CR] & SONIC_CR_RXEN))\n\n return 0;\n\n if (s->regs[SONIC_ISR] & SONIC_ISR_RBE)\n\n return 0;\n\n return 1;\n\n}\n", + "output": "0", + "index": 5039 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blkdebug_debug_remove_breakpoint(BlockDriverState *bs,\n\n const char *tag)\n\n{\n\n BDRVBlkdebugState *s = bs->opaque;\n\n BlkdebugSuspendedReq *r, *r_next;\n\n BlkdebugRule *rule, *next;\n\n int i, ret = -ENOENT;\n\n\n\n for (i = 0; i < BLKDBG__MAX; i++) {\n\n QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) {\n\n if (rule->action == ACTION_SUSPEND &&\n\n !strcmp(rule->options.suspend.tag, tag)) {\n\n remove_rule(rule);\n\n ret = 0;\n\n }\n\n }\n\n }\n\n QLIST_FOREACH_SAFE(r, &s->suspended_reqs, next, r_next) {\n\n if (!strcmp(r->tag, tag)) {\n\n qemu_coroutine_enter(r->co, NULL);\n\n ret = 0;\n\n }\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 13094 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_puts(Monitor *mon, const char *str)\n\n{\n\n char c;\n\n\n\n for(;;) {\n\n c = *str++;\n\n if (c == '\\0')\n\n break;\n\n if (c == '\\n') {\n\n qstring_append_chr(mon->outbuf, '\\r');\n\n }\n\n qstring_append_chr(mon->outbuf, c);\n\n if (c == '\\n') {\n\n monitor_flush(mon);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 21256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aiff_read_packet(AVFormatContext *s,\n AVPacket *pkt)\n{\n AVStream *st = s->streams[0];\n AIFFInputContext *aiff = s->priv_data;\n int64_t max_size;\n int res, size;\n /* calculate size of remaining data */\n max_size = aiff->data_end - avio_tell(s->pb);\n if (max_size <= 0)\n return AVERROR_EOF;\n /* Now for that packet */\n switch (st->codecpar->codec_id) {\n case AV_CODEC_ID_ADPCM_IMA_QT:\n case AV_CODEC_ID_GSM:\n case AV_CODEC_ID_QDM2:\n case AV_CODEC_ID_QCELP:\n size = st->codecpar->block_align;\n break;\n default:\n size = st->codecpar->block_align ? (MAX_SIZE / st->codecpar->block_align) * st->codecpar->block_align : MAX_SIZE;\n size = FFMIN(max_size, size);\n res = av_get_packet(s->pb, pkt, size);\n if (res < 0)\n return res;\n if (size >= st->codecpar->block_align)\n pkt->flags &= ~AV_PKT_FLAG_CORRUPT;\n /* Only one stream in an AIFF file */\n pkt->stream_index = 0;\n pkt->duration = (res / st->codecpar->block_align) * aiff->block_duration;\n return 0;", + "output": "1", + "index": 24732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,\n\n QemuConsole *con, int idx,\n\n GSList *group, GtkWidget *view_menu)\n\n{\n\n Error *local_err = NULL;\n\n Object *obj;\n\n\n\n obj = object_property_get_link(OBJECT(con), \"device\", &local_err);\n\n if (obj) {\n\n vc->label = g_strdup_printf(\"%s\", object_get_typename(obj));\n\n } else {\n\n vc->label = g_strdup_printf(\"VGA\");\n\n }\n\n\n\n vc->s = s;\n\n vc->gfx.scale_x = 1.0;\n\n vc->gfx.scale_y = 1.0;\n\n\n\n vc->gfx.drawing_area = gtk_drawing_area_new();\n\n gtk_widget_add_events(vc->gfx.drawing_area,\n\n GDK_POINTER_MOTION_MASK |\n\n GDK_BUTTON_PRESS_MASK |\n\n GDK_BUTTON_RELEASE_MASK |\n\n GDK_BUTTON_MOTION_MASK |\n\n GDK_ENTER_NOTIFY_MASK |\n\n GDK_LEAVE_NOTIFY_MASK |\n\n GDK_SCROLL_MASK |\n\n GDK_KEY_PRESS_MASK);\n\n gtk_widget_set_can_focus(vc->gfx.drawing_area, TRUE);\n\n\n\n vc->type = GD_VC_GFX;\n\n vc->tab_item = vc->gfx.drawing_area;\n\n gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),\n\n vc->tab_item, gtk_label_new(vc->label));\n\n gd_connect_vc_gfx_signals(vc);\n\n\n\n group = gd_vc_menu_init(s, vc, idx, group, view_menu);\n\n\n\n vc->gfx.dcl.ops = &dcl_ops;\n\n vc->gfx.dcl.con = con;\n\n register_displaychangelistener(&vc->gfx.dcl);\n\n\n\n return group;\n\n}\n", + "output": "1", + "index": 24836 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type)\n\n{\n\n int is_read = (type == SCSI_REQ_STATUS_RETRY_READ);\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n\n BlockErrorAction action = bdrv_get_on_error(s->bs, is_read);\n\n\n\n if (action == BLOCK_ERR_IGNORE) {\n\n bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, is_read);\n\n return 0;\n\n }\n\n\n\n if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)\n\n || action == BLOCK_ERR_STOP_ANY) {\n\n\n\n type &= SCSI_REQ_STATUS_RETRY_TYPE_MASK;\n\n r->status |= SCSI_REQ_STATUS_RETRY | type;\n\n\n\n bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);\n\n vm_stop(VMSTOP_DISKFULL);\n\n } else {\n\n if (type == SCSI_REQ_STATUS_RETRY_READ) {\n\n scsi_req_data(&r->req, 0);\n\n }\n\n if (error == ENOMEM) {\n\n scsi_command_complete(r, CHECK_CONDITION,\n\n SENSE_CODE(TARGET_FAILURE));\n\n } else {\n\n scsi_command_complete(r, CHECK_CONDITION,\n\n SENSE_CODE(IO_ERROR));\n\n }\n\n bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, is_read);\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "0", + "index": 26608 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_dma_restart_bh(void *opaque)\n\n{\n\n SCSIDiskState *s = opaque;\n\n SCSIRequest *req;\n\n SCSIDiskReq *r;\n\n\n\n qemu_bh_delete(s->bh);\n\n s->bh = NULL;\n\n\n\n QTAILQ_FOREACH(req, &s->qdev.requests, next) {\n\n r = DO_UPCAST(SCSIDiskReq, req, req);\n\n if (r->status & SCSI_REQ_STATUS_RETRY) {\n\n int status = r->status;\n\n int ret;\n\n\n\n r->status &=\n\n ~(SCSI_REQ_STATUS_RETRY | SCSI_REQ_STATUS_RETRY_TYPE_MASK);\n\n\n\n switch (status & SCSI_REQ_STATUS_RETRY_TYPE_MASK) {\n\n case SCSI_REQ_STATUS_RETRY_READ:\n\n scsi_read_data(&r->req);\n\n break;\n\n case SCSI_REQ_STATUS_RETRY_WRITE:\n\n scsi_write_data(&r->req);\n\n break;\n\n case SCSI_REQ_STATUS_RETRY_FLUSH:\n\n ret = scsi_disk_emulate_command(r, r->iov.iov_base);\n\n if (ret == 0) {\n\n scsi_command_complete(r, GOOD, NO_SENSE);\n\n }\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 9986 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void type_initialize(TypeImpl *ti)\n\n{\n\n TypeImpl *parent;\n\n\n\n if (ti->class) {\n\n return;\n\n }\n\n\n\n ti->class_size = type_class_get_size(ti);\n\n ti->instance_size = type_object_get_size(ti);\n\n\n\n ti->class = g_malloc0(ti->class_size);\n\n\n\n parent = type_get_parent(ti);\n\n if (parent) {\n\n type_initialize(parent);\n\n GSList *e;\n\n int i;\n\n\n\n g_assert(parent->class_size <= ti->class_size);\n\n memcpy(ti->class, parent->class, parent->class_size);\n\n ti->class->interfaces = NULL;\n\n\n\n for (e = parent->class->interfaces; e; e = e->next) {\n\n ObjectClass *iface = e->data;\n\n type_initialize_interface(ti, object_class_get_name(iface));\n\n }\n\n\n\n for (i = 0; i < ti->num_interfaces; i++) {\n\n TypeImpl *t = type_get_by_name(ti->interfaces[i].typename);\n\n for (e = ti->class->interfaces; e; e = e->next) {\n\n TypeImpl *target_type = OBJECT_CLASS(e->data)->type;\n\n\n\n if (type_is_ancestor(target_type, t)) {\n\n break;\n\n }\n\n }\n\n\n\n if (e) {\n\n continue;\n\n }\n\n\n\n type_initialize_interface(ti, ti->interfaces[i].typename);\n\n }\n\n }\n\n\n\n ti->class->type = ti;\n\n\n\n while (parent) {\n\n if (parent->class_base_init) {\n\n parent->class_base_init(ti->class, ti->class_data);\n\n }\n\n parent = type_get_parent(parent);\n\n }\n\n\n\n if (ti->class_init) {\n\n ti->class_init(ti->class, ti->class_data);\n\n }\n\n\n\n\n\n}\n", + "output": "1", + "index": 1474 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_compare_and_swap32(void *cpu_env, int num)\n\n{\n\n#ifdef TARGET_I386\n\n uint32_t old = ((CPUX86State*)cpu_env)->regs[R_EAX];\n\n uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX];\n\n DPRINTF(\"commpage: compare_and_swap32(%x,new,%p)\\n\", old, value);\n\n\n\n if(value && old == tswap32(*value))\n\n {\n\n uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX];\n\n *value = tswap32(new);\n\n /* set zf flag */\n\n ((CPUX86State*)cpu_env)->eflags |= 0x40;\n\n }\n\n else\n\n {\n\n ((CPUX86State*)cpu_env)->regs[R_EAX] = tswap32(*value);\n\n /* unset zf flag */\n\n ((CPUX86State*)cpu_env)->eflags &= ~0x40;\n\n }\n\n#else\n\n qerror(\"do_compare_and_swap32 unimplemented\");\n\n#endif\n\n}\n", + "output": "1", + "index": 25666 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cavs_find_frame_end(ParseContext *pc, const uint8_t *buf,\n\n int buf_size) {\n\n int pic_found, i;\n\n uint32_t state;\n\n\n\n pic_found= pc->frame_start_found;\n\n state= pc->state;\n\n\n\n i=0;\n\n if(!pic_found){\n\n for(i=0; i SLICE_MAX_START_CODE){\n\n pc->frame_start_found=0;\n\n pc->state=-1;\n\n return i-3;\n\n }\n\n }\n\n }\n\n }\n\n pc->frame_start_found= pic_found;\n\n pc->state= state;\n\n return END_NOT_FOUND;\n\n}\n", + "output": "0", + "index": 17505 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_acpi_tables(test_data *data)\n\n{\n\n int tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */\n\n int i;\n\n\n\n for (i = 0; i < tables_nr; i++) {\n\n AcpiSdtTable ssdt_table;\n\n uint32_t addr;\n\n\n\n addr = le32_to_cpu(data->rsdt_tables_addr[i + 1]); /* fadt is first */\n\n test_dst_table(&ssdt_table, addr);\n\n g_array_append_val(data->tables, ssdt_table);\n\n }\n\n}\n", + "output": "0", + "index": 15822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,\n\n bool is_read)\n\n{\n\n BlockErrorAction action = blk_get_error_action(req->dev->blk,\n\n is_read, error);\n\n VirtIOBlock *s = req->dev;\n\n\n\n if (action == BLOCK_ERROR_ACTION_STOP) {\n\n req->next = s->rq;\n\n s->rq = req;\n\n } else if (action == BLOCK_ERROR_ACTION_REPORT) {\n\n virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);\n\n block_acct_done(blk_get_stats(s->blk), &req->acct);\n\n virtio_blk_free_request(req);\n\n }\n\n\n\n blk_error_action(s->blk, action, is_read, error);\n\n return action != BLOCK_ERROR_ACTION_IGNORE;\n\n}\n", + "output": "1", + "index": 6701 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pfpu_write(void *opaque, target_phys_addr_t addr, uint64_t value,\n\n unsigned size)\n\n{\n\n MilkymistPFPUState *s = opaque;\n\n\n\n trace_milkymist_pfpu_memory_write(addr, value);\n\n\n\n addr >>= 2;\n\n switch (addr) {\n\n case R_CTL:\n\n if (value & CTL_START_BUSY) {\n\n pfpu_start(s);\n\n }\n\n break;\n\n case R_MESHBASE:\n\n case R_HMESHLAST:\n\n case R_VMESHLAST:\n\n case R_CODEPAGE:\n\n case R_VERTICES:\n\n case R_COLLISIONS:\n\n case R_STRAYWRITES:\n\n case R_LASTDMA:\n\n case R_PC:\n\n case R_DREGBASE:\n\n case R_CODEBASE:\n\n s->regs[addr] = value;\n\n break;\n\n case GPR_BEGIN ... GPR_END:\n\n s->gp_regs[addr - GPR_BEGIN] = value;\n\n break;\n\n case MICROCODE_BEGIN ... MICROCODE_END:\n\n s->microcode[get_microcode_address(s, addr)] = value;\n\n break;\n\n\n\n default:\n\n error_report(\"milkymist_pfpu: write access to unknown register 0x\"\n\n TARGET_FMT_plx, addr << 2);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 21476 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ppc_store_msr_32 (CPUPPCState *env, uint32_t value)\n\n{\n\n do_store_msr(env,\n\n (do_load_msr(env) & ~0xFFFFFFFFULL) | (value & 0xFFFFFFFF));\n\n}\n", + "output": "1", + "index": 17822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int ff_h264_decode_init(AVCodecContext *avctx)\n\n{\n\n H264Context *h = avctx->priv_data;\n\n int ret;\n\n\n\n ret = h264_init_context(avctx, h);\n\n if (ret < 0)\n\n return ret;\n\n\n\n memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));\n\n memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t));\n\n\n\n /* set defaults */\n\n // s->decode_mb = ff_h263_decode_mb;\n\n if (!avctx->has_b_frames)\n\n h->low_delay = 1;\n\n\n\n ff_h264_decode_init_vlc();\n\n\n\n ff_init_cabac_states();\n\n\n\n if (avctx->codec_id == AV_CODEC_ID_H264) {\n\n if (avctx->ticks_per_frame == 1)\n\n h->avctx->framerate.num *= 2;\n\n avctx->ticks_per_frame = 2;\n\n }\n\n\n\n if (avctx->extradata_size > 0 && avctx->extradata) {\n\n ret = ff_h264_decode_extradata(h);\n\n if (ret < 0) {\n\n ff_h264_free_context(h);\n\n return ret;\n\n }\n\n }\n\n\n\n if (h->sps.bitstream_restriction_flag &&\n\n h->avctx->has_b_frames < h->sps.num_reorder_frames) {\n\n h->avctx->has_b_frames = h->sps.num_reorder_frames;\n\n h->low_delay = 0;\n\n }\n\n\n\n avctx->internal->allocate_progress = 1;\n\n\n\n if (h->enable_er) {\n\n av_log(avctx, AV_LOG_WARNING,\n\n \"Error resilience is enabled. It is unsafe and unsupported and may crash. \"\n\n \"Use it at your own risk\\n\");\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void swr_compensate(struct SwrContext *s, int sample_delta, int compensation_distance){\n\n ResampleContext *c= s->resample;\n\n// sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr;\n\n c->compensation_distance= compensation_distance;\n\n c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance;\n\n}\n", + "output": "0", + "index": 25450 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int udp_set_remote_url(URLContext *h, const char *uri)\n\n{\n\n UDPContext *s = h->priv_data;\n\n char hostname[256];\n\n int port;\n\n \n\n url_split(NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);\n\n\n\n /* set the destination address */\n\n if (resolve_host(&s->dest_addr.sin_addr, hostname) < 0)\n\n return AVERROR_IO;\n\n s->dest_addr.sin_family = AF_INET;\n\n s->dest_addr.sin_port = htons(port);\n\n return 0;\n\n}\n", + "output": "0", + "index": 25322 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_pipe(int pipefd[2])\n\n{\n\n int ret;\n\n\n\n#ifdef CONFIG_PIPE2\n\n ret = pipe2(pipefd, O_CLOEXEC);\n\n#else\n\n ret = pipe(pipefd);\n\n if (ret == 0) {\n\n qemu_set_cloexec(pipefd[0]);\n\n qemu_set_cloexec(pipefd[1]);\n\n }\n\n#endif\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 26508 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)\n\n{\n\n GetBitContext *gb = &ctx->gb;\n\n ALSChannelData *current = cd;\n\n unsigned int channels = ctx->avctx->channels;\n\n int entries = 0;\n\n\n\n while (entries < channels && !(current->stop_flag = get_bits1(gb))) {\n\n current->master_channel = get_bits_long(gb, av_ceil_log2(channels));\n\n\n\n if (current->master_channel >= channels) {\n\n av_log(ctx->avctx, AV_LOG_ERROR, \"Invalid master channel!\\n\");\n\n return -1;\n\n }\n\n\n\n if (current->master_channel != c) {\n\n current->time_diff_flag = get_bits1(gb);\n\n current->weighting[0] = als_weighting(gb, 1, 16);\n\n current->weighting[1] = als_weighting(gb, 2, 14);\n\n current->weighting[2] = als_weighting(gb, 1, 16);\n\n\n\n if (current->time_diff_flag) {\n\n current->weighting[3] = als_weighting(gb, 1, 16);\n\n current->weighting[4] = als_weighting(gb, 1, 16);\n\n current->weighting[5] = als_weighting(gb, 1, 16);\n\n\n\n current->time_diff_sign = get_bits1(gb);\n\n current->time_diff_index = get_bits(gb, ctx->ltp_lag_length - 3) + 3;\n\n }\n\n }\n\n\n\n current++;\n\n entries++;\n\n }\n\n\n\n if (entries == channels) {\n\n av_log(ctx->avctx, AV_LOG_ERROR, \"Damaged channel data!\\n\");\n\n return -1;\n\n }\n\n\n\n align_get_bits(gb);\n\n return 0;\n\n}\n", + "output": "1", + "index": 25796 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n ASFContext *asf = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n ASFStream *stream;\n\n AVCodecContext *codec;\n\n uint32_t packet_number;\n\n int64_t pts;\n\n int start_sec;\n\n int flags = pkt->flags;\n\n int ret;\n\n uint64_t offset = avio_tell(pb);\n\n\n\n codec = s->streams[pkt->stream_index]->codec;\n\n stream = &asf->streams[pkt->stream_index];\n\n\n\n if (codec->codec_type == AVMEDIA_TYPE_AUDIO)\n\n flags &= ~AV_PKT_FLAG_KEY;\n\n\n\n pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;\n\n av_assert0(pts != AV_NOPTS_VALUE);\n\n\n\n\n\n\n pts *= 10000;\n\n asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);\n\n\n\n packet_number = asf->nb_packets;\n\n put_frame(s, stream, s->streams[pkt->stream_index],\n\n pkt->dts, pkt->data, pkt->size, flags);\n\n\n\n start_sec = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)\n\n / ASF_INDEXED_INTERVAL);\n\n\n\n /* check index */\n\n if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {\n\n uint16_t packet_count = asf->nb_packets - packet_number;\n\n ret = update_index(s, start_sec, packet_number, packet_count, offset);\n\n if (ret < 0)\n\n return ret;\n\n\n asf->end_sec = start_sec;\n\n\n\n return 0;\n", + "output": "1", + "index": 13981 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_text_update(void *opaque, console_ch_t *chardata)\n\n{\n\n struct vmsvga_state_s *s = opaque;\n\n\n\n if (s->vga.text_update)\n\n s->vga.text_update(&s->vga, chardata);\n\n}\n", + "output": "0", + "index": 15473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int stdio_pclose(void *opaque)\n\n{\n\n QEMUFileStdio *s = opaque;\n\n int ret;\n\n ret = pclose(s->stdio_file);\n\n if (ret == -1) {\n\n ret = -errno;\n\n } else if (!WIFEXITED(ret) || WEXITSTATUS(ret) != 0) {\n\n /* close succeeded, but non-zero exit code: */\n\n ret = -EIO; /* fake errno value */\n\n }\n\n g_free(s);\n\n return ret;\n\n}\n", + "output": "1", + "index": 14027 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_open_desc_file(BlockDriverState *bs, int flags,\n\n int64_t desc_offset)\n\n{\n\n int ret;\n\n char buf[2048];\n\n char ct[128];\n\n BDRVVmdkState *s = bs->opaque;\n\n\n\n ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n buf[2047] = '\\0';\n\n if (vmdk_parse_description(buf, \"createType\", ct, sizeof(ct))) {\n\n return -EINVAL;\n\n }\n\n if (strcmp(ct, \"monolithicFlat\") &&\n\n strcmp(ct, \"twoGbMaxExtentSparse\") &&\n\n strcmp(ct, \"twoGbMaxExtentFlat\")) {\n\n fprintf(stderr,\n\n \"VMDK: Not supported image type \\\"%s\\\"\"\".\\n\", ct);\n\n return -ENOTSUP;\n\n }\n\n s->desc_offset = 0;\n\n ret = vmdk_parse_extents(buf, bs, bs->file->filename);\n\n if (ret) {\n\n return ret;\n\n }\n\n\n\n /* try to open parent images, if exist */\n\n if (vmdk_parent_open(bs)) {\n\n g_free(s->extents);\n\n return -EINVAL;\n\n }\n\n s->parent_cid = vmdk_read_cid(bs, 1);\n\n return 0;\n\n}\n", + "output": "1", + "index": 3669 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_key(DBEContext *s)\n\n{\n\n int key = 0;\n\n\n\n if (s->key_present && s->input_size > 0)\n\n key = AV_RB24(s->input) >> 24 - s->word_bits;\n\n\n\n skip_input(s, s->key_present);\n\n return key;\n\n}\n", + "output": "1", + "index": 1814 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blk_mig_save_dirty_block(Monitor *mon, QEMUFile *f, int is_async)\n\n{\n\n BlkMigDevState *bmds;\n\n int ret = 0;\n\n\n\n QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {\n\n if (mig_save_device_dirty(mon, f, bmds, is_async) == 0) {\n\n ret = 1;\n\n break;\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 19947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type)\n\n{\n\n int ret;\n\n struct flock fl = {\n\n .l_whence = SEEK_SET,\n\n .l_start = start,\n\n .l_len = len,\n\n .l_type = fl_type,\n\n };\n\n ret = fcntl(fd, QEMU_SETLK, &fl);\n\n return ret == -1 ? -errno : 0;\n\n}\n", + "output": "0", + "index": 20235 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,\n\n unsigned size)\n\n{\n\n PXA2xxI2CState *s = (PXA2xxI2CState *) opaque;\n\n I2CSlave *slave;\n\n\n\n addr -= s->offset;\n\n switch (addr) {\n\n case ICR:\n\n return s->control;\n\n case ISR:\n\n return s->status | (i2c_bus_busy(s->bus) << 2);\n\n case ISAR:\n\n slave = I2C_SLAVE(s->slave);\n\n return slave->address;\n\n case IDBR:\n\n return s->data;\n\n case IBMR:\n\n if (s->status & (1 << 2))\n\n s->ibmr ^= 3;\t/* Fake SCL and SDA pin changes */\n\n else\n\n s->ibmr = 0;\n\n return s->ibmr;\n\n default:\n\n printf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, addr);\n\n break;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 8051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n\n{\n\n AVStream *st;\n\n\n\n if (c->fc->nb_streams < 1)\n\n return 0;\n\n st = c->fc->streams[c->fc->nb_streams-1];\n\n\n\n if ((uint64_t)atom.size > (1<<30))\n\n return AVERROR_INVALIDDATA;\n\n\n\n if (st->codec->codec_id == AV_CODEC_ID_QDM2 || st->codec->codec_id == AV_CODEC_ID_QDMC) {\n\n // pass all frma atom to codec, needed at least for QDMC and QDM2\n\n av_free(st->codec->extradata);\n\n st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);\n\n if (!st->codec->extradata)\n\n return AVERROR(ENOMEM);\n\n st->codec->extradata_size = atom.size;\n\n avio_read(pb, st->codec->extradata, atom.size);\n\n } else if (atom.size > 8) { /* to read frma, esds atoms */\n\n int ret;\n\n if ((ret = mov_read_default(c, pb, atom)) < 0)\n\n return ret;\n\n } else\n\n avio_skip(pb, atom.size);\n\n return 0;\n\n}\n", + "output": "1", + "index": 15381 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void run_dependent_requests(BDRVQcowState *s, QCowL2Meta *m)\n\n{\n\n /* Take the request off the list of running requests */\n\n if (m->nb_clusters != 0) {\n\n QLIST_REMOVE(m, next_in_flight);\n\n }\n\n\n\n /* Restart all dependent requests */\n\n if (!qemu_co_queue_empty(&m->dependent_requests)) {\n\n qemu_co_mutex_unlock(&s->lock);\n\n while(qemu_co_queue_next(&m->dependent_requests));\n\n qemu_co_mutex_lock(&s->lock);\n\n }\n\n}\n", + "output": "0", + "index": 1769 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)\n\n{\n\n USBDevice *dev;\n\n struct USBBtState *s;\n\n HCIInfo *hci;\n\n const char *name = \"usb-bt-dongle\";\n\n\n\n if (*cmdline) {\n\n hci = hci_init(cmdline);\n\n } else {\n\n hci = bt_new_hci(qemu_find_bt_vlan(0));\n\n }\n\n if (!hci)\n\n return NULL;\n\n\n\n dev = usb_create(bus, name);\n\n s = DO_UPCAST(struct USBBtState, dev, dev);\n\n s->hci = hci;\n\n if (qdev_init(&dev->qdev) < 0) {\n\n error_report(\"Failed to initialize USB device '%s'\", name);\n\n return NULL;\n\n }\n\n\n\n return dev;\n\n}\n", + "output": "1", + "index": 2363 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ppc_hw_interrupt (CPUState *env)\n\n{\n\n env->exception_index = -1;\n\n}\n", + "output": "0", + "index": 24510 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_acl_append(qemu_acl *acl,\n\n int deny,\n\n const char *match)\n\n{\n\n qemu_acl_entry *entry;\n\n\n\n entry = qemu_malloc(sizeof(*entry));\n\n entry->match = qemu_strdup(match);\n\n entry->deny = deny;\n\n\n\n TAILQ_INSERT_TAIL(&acl->entries, entry, next);\n\n acl->nentries++;\n\n\n\n return acl->nentries;\n\n}\n", + "output": "0", + "index": 24684 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_write_403_pbr (void *opaque, int sprn)\n\n{\n\n DisasContext *ctx = opaque;\n\n\n\n gen_op_store_403_pb(sprn - SPR_403_PBL1);\n\n RET_STOP(ctx);\n\n}\n", + "output": "0", + "index": 18134 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void intra_predict_horiz_16x16_msa(uint8_t *src, int32_t src_stride,\n\n uint8_t *dst, int32_t dst_stride)\n\n{\n\n uint32_t row;\n\n uint8_t inp0, inp1, inp2, inp3;\n\n v16u8 src0, src1, src2, src3;\n\n\n\n for (row = 4; row--;) {\n\n inp0 = src[0];\n\n src += src_stride;\n\n inp1 = src[0];\n\n src += src_stride;\n\n inp2 = src[0];\n\n src += src_stride;\n\n inp3 = src[0];\n\n src += src_stride;\n\n\n\n src0 = (v16u8) __msa_fill_b(inp0);\n\n src1 = (v16u8) __msa_fill_b(inp1);\n\n src2 = (v16u8) __msa_fill_b(inp2);\n\n src3 = (v16u8) __msa_fill_b(inp3);\n\n\n\n ST_UB4(src0, src1, src2, src3, dst, dst_stride);\n\n dst += (4 * dst_stride);\n\n }\n\n}\n", + "output": "0", + "index": 23760 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "socket_sockaddr_to_address_vsock(struct sockaddr_storage *sa,\n\n socklen_t salen,\n\n Error **errp)\n\n{\n\n SocketAddressLegacy *addr;\n\n VsockSocketAddress *vaddr;\n\n struct sockaddr_vm *svm = (struct sockaddr_vm *)sa;\n\n\n\n addr = g_new0(SocketAddressLegacy, 1);\n\n addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;\n\n addr->u.vsock.data = vaddr = g_new0(VsockSocketAddress, 1);\n\n vaddr->cid = g_strdup_printf(\"%u\", svm->svm_cid);\n\n vaddr->port = g_strdup_printf(\"%u\", svm->svm_port);\n\n\n\n return addr;\n\n}\n", + "output": "0", + "index": 3938 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool is_iso_bc_entry_compatible(IsoBcSection *s)\n\n{\n\n return true;\n\n}\n", + "output": "0", + "index": 13044 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void count_cpreg(gpointer key, gpointer opaque)\n\n{\n\n ARMCPU *cpu = opaque;\n\n uint64_t regidx;\n\n const ARMCPRegInfo *ri;\n\n\n\n regidx = *(uint32_t *)key;\n\n ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);\n\n\n\n if (!(ri->type & ARM_CP_NO_MIGRATE)) {\n\n cpu->cpreg_array_len++;\n\n }\n\n}\n", + "output": "0", + "index": 1097 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_balloon(int64_t value, Error **errp)\n\n{\n\n if (kvm_enabled() && !kvm_has_sync_mmu()) {\n\n error_set(errp, QERR_KVM_MISSING_CAP, \"synchronous MMU\", \"balloon\");\n\n return;\n\n }\n\n\n\n if (value <= 0) {\n\n error_set(errp, QERR_INVALID_PARAMETER_VALUE, \"target\", \"a size\");\n\n return;\n\n }\n\n \n\n if (qemu_balloon(value) == 0) {\n\n error_set(errp, QERR_DEVICE_NOT_ACTIVE, \"balloon\");\n\n }\n\n}\n", + "output": "0", + "index": 6223 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean ga_channel_listen_accept(GIOChannel *channel,\n\n GIOCondition condition, gpointer data)\n\n{\n\n GAChannel *c = data;\n\n int ret, client_fd;\n\n bool accepted = false;\n\n struct sockaddr_un addr;\n\n socklen_t addrlen = sizeof(addr);\n\n\n\n g_assert(channel != NULL);\n\n\n\n client_fd = qemu_accept(g_io_channel_unix_get_fd(channel),\n\n (struct sockaddr *)&addr, &addrlen);\n\n if (client_fd == -1) {\n\n g_warning(\"error converting fd to gsocket: %s\", strerror(errno));\n\n goto out;\n\n }\n\n fcntl(client_fd, F_SETFL, O_NONBLOCK);\n\n ret = ga_channel_client_add(c, client_fd);\n\n if (ret) {\n\n g_warning(\"error setting up connection\");\n\n\n goto out;\n\n }\n\n accepted = true;\n\n\n\nout:\n\n /* only accept 1 connection at a time */\n\n return !accepted;\n\n}", + "output": "1", + "index": 7890 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,\n\n int fdt_start_offset, Error **errp)\n\n{\n\n trace_spapr_drc_attach(spapr_drc_index(drc));\n\n\n\n if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {\n\n error_setg(errp, \"an attached device is still awaiting release\");\n\n return;\n\n }\n\n if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_PCI) {\n\n g_assert(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE);\n\n }\n\n g_assert(fdt);\n\n\n\n drc->dev = d;\n\n drc->fdt = fdt;\n\n drc->fdt_start_offset = fdt_start_offset;\n\n\n\n if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {\n\n drc->awaiting_allocation = true;\n\n }\n\n\n\n object_property_add_link(OBJECT(drc), \"device\",\n\n object_get_typename(OBJECT(drc->dev)),\n\n (Object **)(&drc->dev),\n\n NULL, 0, NULL);\n\n}\n", + "output": "1", + "index": 12694 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unterminated_literal(void)\n\n{\n\n QObject *obj = qobject_from_json(\"nul\", NULL);\n\n g_assert(obj == NULL);\n\n}\n", + "output": "1", + "index": 7349 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpegts_raw_read_packet(AVFormatContext *s,\n\n AVPacket *pkt)\n\n{\n\n MpegTSContext *ts = s->priv_data;\n\n int ret, i;\n\n int64_t pcr_h, next_pcr_h, pos;\n\n int pcr_l, next_pcr_l;\n\n uint8_t pcr_buf[12];\n\n\n\n if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)\n\n return AVERROR(ENOMEM);\n\n pkt->pos= url_ftell(s->pb);\n\n ret = read_packet(s->pb, pkt->data, ts->raw_packet_size);\n\n if (ret < 0) {\n\n av_free_packet(pkt);\n\n return ret;\n\n }\n\n if (ts->mpeg2ts_compute_pcr) {\n\n /* compute exact PCR for each packet */\n\n if (parse_pcr(&pcr_h, &pcr_l, pkt->data) == 0) {\n\n /* we read the next PCR (XXX: optimize it by using a bigger buffer */\n\n pos = url_ftell(s->pb);\n\n for(i = 0; i < MAX_PACKET_READAHEAD; i++) {\n\n url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);\n\n get_buffer(s->pb, pcr_buf, 12);\n\n if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {\n\n /* XXX: not precise enough */\n\n ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) /\n\n (i + 1);\n\n break;\n\n }\n\n }\n\n url_fseek(s->pb, pos, SEEK_SET);\n\n /* no next PCR found: we use previous increment */\n\n ts->cur_pcr = pcr_h * 300 + pcr_l;\n\n }\n\n pkt->pts = ts->cur_pcr;\n\n pkt->duration = ts->pcr_incr;\n\n ts->cur_pcr += ts->pcr_incr;\n\n }\n\n pkt->stream_index = 0;\n\n return 0;\n\n}\n", + "output": "0", + "index": 23499 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t guest_file_handle_add(FILE *fh, Error **errp)\n\n{\n\n GuestFileHandle *gfh;\n\n int64_t handle;\n\n\n\n handle = ga_get_fd_handle(ga_state, errp);\n\n if (handle < 0) {\n\n return -1;\n\n }\n\n\n\n gfh = g_malloc0(sizeof(GuestFileHandle));\n\n gfh->id = handle;\n\n gfh->fh = fh;\n\n QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next);\n\n\n\n return handle;\n\n}\n", + "output": "1", + "index": 9523 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){\n\n int i;\n\n\n\n s->dts= s->pts= AV_NOPTS_VALUE;\n\n s->offset= 0;\n\n for(i = 0; i < AV_PARSER_PTS_NB; i++) {\n\n if ( s->next_frame_offset + off >= s->cur_frame_offset[i]\n\n &&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset)\n\n //check is disabled becausue mpeg-ts doesnt send complete PES packets\n\n && /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){\n\n s->dts= s->cur_frame_dts[i];\n\n s->pts= s->cur_frame_pts[i];\n\n s->offset = s->next_frame_offset - s->cur_frame_offset[i];\n\n if(remove)\n\n s->cur_frame_offset[i]= INT64_MAX;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 2436 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ahci_shutdown(AHCIQState *ahci)\n{\n QOSState *qs = ahci->parent;\n free_ahci_device(ahci->dev);\n g_free(ahci);\n qtest_shutdown(qs);\n}", + "output": "1", + "index": 14765 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t bw_io_read(void *opaque, target_phys_addr_t addr, unsigned size)\n\n{\n\n switch (size) {\n\n case 1:\n\n return cpu_inb(addr);\n\n case 2:\n\n return cpu_inw(addr);\n\n case 4:\n\n return cpu_inl(addr);\n\n }\n\n abort();\n\n}\n", + "output": "0", + "index": 16905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int socket_listen(SocketAddressLegacy *addr, Error **errp)\n\n{\n\n int fd;\n\n\n\n switch (addr->type) {\n\n case SOCKET_ADDRESS_LEGACY_KIND_INET:\n\n fd = inet_listen_saddr(addr->u.inet.data, 0, false, errp);\n\n break;\n\n\n\n case SOCKET_ADDRESS_LEGACY_KIND_UNIX:\n\n fd = unix_listen_saddr(addr->u.q_unix.data, false, errp);\n\n break;\n\n\n\n case SOCKET_ADDRESS_LEGACY_KIND_FD:\n\n fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp);\n\n break;\n\n\n\n case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:\n\n fd = vsock_listen_saddr(addr->u.vsock.data, errp);\n\n break;\n\n\n\n default:\n\n abort();\n\n }\n\n return fd;\n\n}\n", + "output": "0", + "index": 16021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)\n\n{\n\n VirtConsole *vcon = VIRTIO_CONSOLE(port);\n\n DeviceState *dev = DEVICE(port);\n\n\n\n if (vcon->chr) {\n\n qemu_chr_fe_set_open(vcon->chr, guest_connected);\n\n }\n\n\n\n if (dev->id) {\n\n qapi_event_send_vserport_change(dev->id, guest_connected,\n\n &error_abort);\n\n }\n\n}\n", + "output": "1", + "index": 822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void tcg_out_ld_ptr(TCGContext *s, int ret,\n\n tcg_target_long arg)\n\n{\n\n#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)\n\n if (arg != (arg & 0xffffffff))\n\n fprintf(stderr, \"unimplemented %s with offset %ld\\n\", __func__, arg);\n\n if (arg != (arg & 0xfff))\n\n tcg_out32(s, SETHI | INSN_RD(ret) | (((uint32_t)arg & 0xfffffc00) >> 10));\n\n tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(ret) |\n\n INSN_IMM13(arg & 0x3ff));\n\n#else\n\n tcg_out_ld_raw(s, ret, arg);\n\n#endif\n\n}\n", + "output": "0", + "index": 2628 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path,\n\n mode_t st_mode, uint64_t *st_gen)\n\n{\n\n int err;\n\n\n\n /* Do not try to open special files like device nodes, fifos etc\n\n * we can get fd for regular files and directories only\n\n */\n\n if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) {\n\n errno = ENOTTY;\n\n return -1;\n\n }\n\n err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, \"s\", path);\n\n if (err < 0) {\n\n errno = -err;\n\n err = -1;\n\n }\n\n return err;\n\n}\n", + "output": "0", + "index": 4106 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, int decode)\n\n{\n\n int ret = 0;\n\n int got_frame = 0;\n\n AVFrame *frame = NULL;\n\n int skip_frame = codec_ctx->skip_frame;\n\n\n\n if (!avcodec_is_open(codec_ctx)) {\n\n const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);\n\n\n\n ret = avcodec_open2(codec_ctx, codec, NULL);\n\n if (ret < 0) {\n\n av_log(codec_ctx, AV_LOG_ERROR, \"Failed to open codec\\n\");\n\n goto end;\n\n }\n\n }\n\n\n\n frame = av_frame_alloc();\n\n if (!frame) {\n\n av_log(NULL, AV_LOG_ERROR, \"Failed to allocate frame\\n\");\n\n goto end;\n\n }\n\n\n\n if (!decode && codec_ctx->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {\n\n codec_ctx->skip_frame = AVDISCARD_ALL;\n\n }\n\n\n\n do {\n\n ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);\n\n av_assert0(decode || (!decode && !got_frame));\n\n if (ret < 0)\n\n break;\n\n pkt->data += ret;\n\n pkt->size -= ret;\n\n\n\n if (got_frame) {\n\n break;\n\n }\n\n } while (pkt->size > 0);\n\n\n\nend:\n\n codec_ctx->skip_frame = skip_frame;\n\n\n\n av_frame_free(&frame);\n\n return ret;\n\n}\n", + "output": "1", + "index": 26138 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int omap_validate_tipb_mpui_addr(struct omap_mpu_state_s *s,\n\n target_phys_addr_t addr)\n\n{\n\n return addr >= 0xe1010000 && addr < 0xe1020004;\n\n}\n", + "output": "0", + "index": 7815 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_strtoull(const char *nptr, const char **endptr, int base,\n\n uint64_t *result)\n\n{\n\n char *p;\n\n int err = 0;\n\n if (!nptr) {\n\n if (endptr) {\n\n *endptr = nptr;\n\n }\n\n err = -EINVAL;\n\n } else {\n\n errno = 0;\n\n *result = strtoull(nptr, &p, base);\n\n err = check_strtox_error(endptr, p, errno);\n\n }\n\n return err;\n\n}\n", + "output": "1", + "index": 6549 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qpci_memwrite(QPCIDevice *dev, void *data, const void *buf, size_t len)\n\n{\n\n uintptr_t addr = (uintptr_t)data;\n\n\n\n g_assert(addr >= QPCI_PIO_LIMIT);\n\n dev->bus->memwrite(dev->bus, addr, buf, len);\n\n}\n", + "output": "1", + "index": 26915 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv,\n\n TCGv_i32 newv, TCGArg idx, TCGMemOp memop)\n\n{\n\n memop = tcg_canonicalize_memop(memop, 0, 0);\n\n\n\n if (!parallel_cpus) {\n\n TCGv_i32 t1 = tcg_temp_new_i32();\n\n TCGv_i32 t2 = tcg_temp_new_i32();\n\n\n\n tcg_gen_ext_i32(t2, cmpv, memop & MO_SIZE);\n\n\n\n tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN);\n\n tcg_gen_movcond_i32(TCG_COND_EQ, t2, t1, t2, newv, t1);\n\n tcg_gen_qemu_st_i32(t2, addr, idx, memop);\n\n tcg_temp_free_i32(t2);\n\n\n\n if (memop & MO_SIGN) {\n\n tcg_gen_ext_i32(retv, t1, memop);\n\n } else {\n\n tcg_gen_mov_i32(retv, t1);\n\n }\n\n tcg_temp_free_i32(t1);\n\n } else {\n\n gen_atomic_cx_i32 gen;\n\n\n\n gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)];\n\n tcg_debug_assert(gen != NULL);\n\n\n\n#ifdef CONFIG_SOFTMMU\n\n {\n\n TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop & ~MO_SIGN, idx));\n\n gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv, oi);\n\n tcg_temp_free_i32(oi);\n\n }\n\n#else\n\n gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv);\n\n#endif\n\n\n\n if (memop & MO_SIGN) {\n\n tcg_gen_ext_i32(retv, retv, memop);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 1624 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int ohci_put_ed(OHCIState *ohci,\n\n uint32_t addr, struct ohci_ed *ed)\n\n{\n\n return put_dwords(ohci, addr, (uint32_t *)ed, sizeof(*ed) >> 2);\n\n}\n", + "output": "1", + "index": 23648 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_put_byte(QEMUFile *f, int v)\n\n{\n\n if (f->last_error) {\n\n return;\n\n }\n\n\n\n f->buf[f->buf_index] = v;\n\n f->bytes_xfer++;\n\n if (f->ops->writev_buffer) {\n\n add_to_iovec(f, f->buf + f->buf_index, 1);\n\n }\n\n f->buf_index++;\n\n if (f->buf_index == IO_BUF_SIZE) {\n\n qemu_fflush(f);\n\n }\n\n}\n", + "output": "1", + "index": 3623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){\n\n#if CONFIG_SMALL\n\n#define ROT(x,s) ((x<>(32-s)))\n\n return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24);\n\n#else\n\n return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d];\n\n#endif\n\n}\n", + "output": "1", + "index": 24819 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_pred4x4(H264PredContext *h, uint8_t *buf0, uint8_t *buf1,\n\n int codec, int chroma_format, int bit_depth)\n\n{\n\n if (chroma_format == 1) {\n\n uint8_t *topright = buf0 + 2*16;\n\n int pred_mode;\n\n for (pred_mode = 0; pred_mode < 15; pred_mode++) {\n\n if (check_pred_func(h->pred4x4[pred_mode], \"4x4\", pred4x4_modes[codec][pred_mode])) {\n\n randomize_buffers();\n\n call_ref(src0, topright, (ptrdiff_t)12*SIZEOF_PIXEL);\n\n call_new(src1, topright, (ptrdiff_t)12*SIZEOF_PIXEL);\n\n if (memcmp(buf0, buf1, BUF_SIZE))\n\n fail();\n\n bench_new(src1, topright, (ptrdiff_t)12*SIZEOF_PIXEL);\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 2858 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)\n\n{\n\n OpenRISCCPU *cpu = OPENRISC_CPU(dev);\n\n OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(dev);\n\n\n\n cpu_reset(CPU(cpu));\n\n\n\n occ->parent_realize(dev, errp);\n\n}\n", + "output": "1", + "index": 13702 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_errno_to_system_errno(int err)\n\n{\n\n switch (err) {\n\n case NBD_SUCCESS:\n\n return 0;\n\n case NBD_EPERM:\n\n return EPERM;\n\n case NBD_EIO:\n\n return EIO;\n\n case NBD_ENOMEM:\n\n return ENOMEM;\n\n case NBD_ENOSPC:\n\n return ENOSPC;\n\n case NBD_EINVAL:\n\n default:\n\n return EINVAL;\n\n }\n\n}\n", + "output": "1", + "index": 5074 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_abs(DisasContext *ctx)\n\n{\n\n int l1 = gen_new_label();\n\n int l2 = gen_new_label();\n\n tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rA(ctx->opcode)], 0, l1);\n\n tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);\n\n tcg_gen_br(l2);\n\n gen_set_label(l1);\n\n tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);\n\n gen_set_label(l2);\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);\n\n}\n", + "output": "0", + "index": 17950 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_input_start_list(Visitor *v, const char *name,\n\n GenericList **list, size_t size, Error **errp)\n\n{\n\n QmpInputVisitor *qiv = to_qiv(v);\n\n QObject *qobj = qmp_input_get_object(qiv, name, true, errp);\n\n const QListEntry *entry;\n\n\n\n if (!qobj) {\n\n return;\n\n }\n\n if (qobject_type(qobj) != QTYPE_QLIST) {\n\n if (list) {\n\n *list = NULL;\n\n }\n\n error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",\n\n \"list\");\n\n return;\n\n }\n\n\n\n entry = qmp_input_push(qiv, qobj, list, errp);\n\n if (list) {\n\n if (entry) {\n\n *list = g_malloc0(size);\n\n } else {\n\n *list = NULL;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 14856 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_commit_all(void)\n\n{\n\n BlockDriverState *bs;\n\n\n\n QTAILQ_FOREACH(bs, &bdrv_states, list) {\n\n bdrv_commit(bs);\n\n }\n\n}\n", + "output": "1", + "index": 5520 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_dealloc_types(void)\n\n{\n\n UserDefOne *ud1test, *ud1a, *ud1b;\n\n UserDefOneList *ud1list;\n\n\n\n ud1test = g_malloc0(sizeof(UserDefOne));\n\n ud1test->base = g_new0(UserDefZero, 1);\n\n ud1test->base->integer = 42;\n\n ud1test->string = g_strdup(\"hi there 42\");\n\n\n\n qapi_free_UserDefOne(ud1test);\n\n\n\n ud1a = g_malloc0(sizeof(UserDefOne));\n\n ud1a->base = g_new0(UserDefZero, 1);\n\n ud1a->base->integer = 43;\n\n ud1a->string = g_strdup(\"hi there 43\");\n\n\n\n ud1b = g_malloc0(sizeof(UserDefOne));\n\n ud1b->base = g_new0(UserDefZero, 1);\n\n ud1b->base->integer = 44;\n\n ud1b->string = g_strdup(\"hi there 44\");\n\n\n\n ud1list = g_malloc0(sizeof(UserDefOneList));\n\n ud1list->value = ud1a;\n\n ud1list->next = g_malloc0(sizeof(UserDefOneList));\n\n ud1list->next->value = ud1b;\n\n\n\n qapi_free_UserDefOneList(ud1list);\n\n}\n", + "output": "0", + "index": 6919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base,\n\n intptr_t offset, const char *name)\n\n{\n\n TCGContext *s = &tcg_ctx;\n\n TCGTemp *ts, *base_ts = &s->temps[GET_TCGV_PTR(base)];\n\n int idx, reg = base_ts->reg;\n\n\n\n idx = s->nb_globals;\n\n#if TCG_TARGET_REG_BITS == 32\n\n if (type == TCG_TYPE_I64) {\n\n char buf[64];\n\n tcg_temp_alloc(s, s->nb_globals + 2);\n\n ts = &s->temps[s->nb_globals];\n\n ts->base_type = type;\n\n ts->type = TCG_TYPE_I32;\n\n ts->fixed_reg = 0;\n\n ts->mem_allocated = 1;\n\n ts->mem_reg = reg;\n\n#ifdef HOST_WORDS_BIGENDIAN\n\n ts->mem_offset = offset + 4;\n\n#else\n\n ts->mem_offset = offset;\n\n#endif\n\n pstrcpy(buf, sizeof(buf), name);\n\n pstrcat(buf, sizeof(buf), \"_0\");\n\n ts->name = strdup(buf);\n\n ts++;\n\n\n\n ts->base_type = type;\n\n ts->type = TCG_TYPE_I32;\n\n ts->fixed_reg = 0;\n\n ts->mem_allocated = 1;\n\n ts->mem_reg = reg;\n\n#ifdef HOST_WORDS_BIGENDIAN\n\n ts->mem_offset = offset;\n\n#else\n\n ts->mem_offset = offset + 4;\n\n#endif\n\n pstrcpy(buf, sizeof(buf), name);\n\n pstrcat(buf, sizeof(buf), \"_1\");\n\n ts->name = strdup(buf);\n\n\n\n s->nb_globals += 2;\n\n } else\n\n#endif\n\n {\n\n tcg_temp_alloc(s, s->nb_globals + 1);\n\n ts = &s->temps[s->nb_globals];\n\n ts->base_type = type;\n\n ts->type = type;\n\n ts->fixed_reg = 0;\n\n ts->mem_allocated = 1;\n\n ts->mem_reg = reg;\n\n ts->mem_offset = offset;\n\n ts->name = name;\n\n s->nb_globals++;\n\n }\n\n return idx;\n\n}\n", + "output": "0", + "index": 4334 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adx_decode(ADXContext *c, int16_t *out, int offset,\n\n const uint8_t *in, int ch)\n\n{\n\n ADXChannelState *prev = &c->prev[ch];\n\n GetBitContext gb;\n\n int scale = AV_RB16(in);\n\n int i;\n\n int s0, s1, s2, d;\n\n\n\n /* check if this is an EOF packet */\n\n if (scale & 0x8000)\n\n return -1;\n\n\n\n init_get_bits(&gb, in + 2, (BLOCK_SIZE - 2) * 8);\n\n out += offset;\n\n s1 = prev->s1;\n\n s2 = prev->s2;\n\n for (i = 0; i < BLOCK_SAMPLES; i++) {\n\n d = get_sbits(&gb, 4);\n\n s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;\n\n s2 = s1;\n\n s1 = av_clip_int16(s0);\n\n *out++ = s1;\n\n }\n\n prev->s1 = s1;\n\n prev->s2 = s2;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 19158 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int t27(InterplayACMContext *s, unsigned ind, unsigned col)\n\n{\n\n GetBitContext *gb = &s->gb;\n\n unsigned i, b;\n\n int n1, n2, n3;\n\n\n\n for (i = 0; i < s->rows; i++) {\n\n /* b = (x1) + (x2 * 5) + (x3 * 25) */\n\n b = get_bits(gb, 7);\n\n\n\n\n\n\n\n n1 = (mul_3x5[b] & 0x0F) - 2;\n\n n2 = ((mul_3x5[b] >> 4) & 0x0F) - 2;\n\n n3 = ((mul_3x5[b] >> 8) & 0x0F) - 2;\n\n\n\n set_pos(s, i++, col, n1);\n\n if (i >= s->rows)\n\n break;\n\n set_pos(s, i++, col, n2);\n\n if (i >= s->rows)\n\n break;\n\n set_pos(s, i, col, n3);\n\n\n return 0;\n", + "output": "1", + "index": 26585 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void icp_pit_write(void *opaque, target_phys_addr_t offset,\n\n uint64_t value, unsigned size)\n\n{\n\n icp_pit_state *s = (icp_pit_state *)opaque;\n\n int n;\n\n\n\n n = offset >> 8;\n\n if (n > 3) {\n\n hw_error(\"sp804_write: Bad timer %d\\n\", n);\n\n }\n\n\n\n arm_timer_write(s->timer[n], offset & 0xff, value);\n\n}\n", + "output": "1", + "index": 624 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow_make_empty(BlockDriverState *bs)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n uint32_t l1_length = s->l1_size * sizeof(uint64_t);\n\n int ret;\n\n\n\n memset(s->l1_table, 0, l1_length);\n\n if (bdrv_pwrite(bs->file, s->l1_table_offset, s->l1_table, l1_length) < 0)\n\n\treturn -1;\n\n ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length);\n\n if (ret < 0)\n\n return ret;\n\n\n\n memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));\n\n memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t));\n\n memset(s->l2_cache_counts, 0, L2_CACHE_SIZE * sizeof(uint32_t));\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 25842 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_subfmeo (void)\n\n{\n\n T1 = T0;\n\n T0 = ~T0 + xer_ca - 1;\n\n if (likely(!((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0) &\n\n (1UL << 31)))) {\n\n xer_ov = 0;\n\n } else {\n\n xer_so = 1;\n\n xer_ov = 1;\n\n }\n\n if (likely((uint32_t)T1 != UINT32_MAX))\n\n xer_ca = 1;\n\n}\n", + "output": "1", + "index": 9200 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qmp_check_client_args(const mon_cmd_t *cmd, QDict *client_args)\n\n{\n\n int flags, err;\n\n QDict *cmd_args;\n\n\n\n cmd_args = qdict_from_args_type(cmd->args_type);\n\n\n\n flags = 0;\n\n err = check_mandatory_args(cmd_args, client_args, &flags);\n\n if (err) {\n\n goto out;\n\n }\n\n\n\n /* TODO: Check client args type */\n\n\n\nout:\n\n QDECREF(cmd_args);\n\n return err;\n\n}\n", + "output": "0", + "index": 17309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void sdhci_reset_write(SDHCIState *s, uint8_t value)\n\n{\n\n switch (value) {\n\n case SDHC_RESET_ALL:\n\n DEVICE_GET_CLASS(s)->reset(DEVICE(s));\n\n break;\n\n case SDHC_RESET_CMD:\n\n s->prnsts &= ~SDHC_CMD_INHIBIT;\n\n s->norintsts &= ~SDHC_NIS_CMDCMP;\n\n break;\n\n case SDHC_RESET_DATA:\n\n s->data_count = 0;\n\n s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |\n\n SDHC_DOING_READ | SDHC_DOING_WRITE |\n\n SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);\n\n s->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);\n\n s->stopped_state = sdhc_not_stopped;\n\n s->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |\n\n SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 18881 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ecc_diag_mem_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t val, unsigned size)\n\n{\n\n ECCState *s = opaque;\n\n\n\n trace_ecc_diag_mem_writeb(addr, val);\n\n s->diag[addr & ECC_DIAG_MASK] = val;\n\n}\n", + "output": "0", + "index": 15939 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void network_to_register(RDMARegister *reg)\n\n{\n\n reg->key.current_addr = ntohll(reg->key.current_addr);\n\n reg->current_index = ntohl(reg->current_index);\n\n reg->chunks = ntohll(reg->chunks);\n\n}\n", + "output": "1", + "index": 13189 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_enum(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n DeviceState *dev = DEVICE(obj);\n\n Property *prop = opaque;\n\n int *ptr = qdev_get_prop_ptr(dev, prop);\n\n\n\n if (dev->state != DEV_STATE_CREATED) {\n\n error_set(errp, QERR_PERMISSION_DENIED);\n\n return;\n\n }\n\n\n\n visit_type_enum(v, ptr, prop->info->enum_table,\n\n prop->info->name, prop->name, errp);\n\n}\n", + "output": "0", + "index": 13822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_gluster_create(const char *filename,\n\n QemuOpts *opts, Error **errp)\n\n{\n\n struct glfs *glfs;\n\n struct glfs_fd *fd;\n\n int ret = 0;\n\n int prealloc = 0;\n\n int64_t total_size = 0;\n\n char *tmp = NULL;\n\n GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));\n\n\n\n glfs = qemu_gluster_init(gconf, filename, errp);\n\n if (!glfs) {\n\n ret = -errno;\n\n goto out;\n\n }\n\n\n\n total_size =\n\n qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;\n\n\n\n tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);\n\n if (!tmp || !strcmp(tmp, \"off\")) {\n\n prealloc = 0;\n\n } else if (!strcmp(tmp, \"full\") &&\n\n gluster_supports_zerofill()) {\n\n prealloc = 1;\n\n } else {\n\n error_setg(errp, \"Invalid preallocation mode: '%s'\"\n\n \" or GlusterFS doesn't support zerofill API\",\n\n tmp);\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n\n\n fd = glfs_creat(glfs, gconf->image,\n\n O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);\n\n if (!fd) {\n\n ret = -errno;\n\n } else {\n\n if (!glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE)) {\n\n if (prealloc && qemu_gluster_zerofill(fd, 0,\n\n total_size * BDRV_SECTOR_SIZE)) {\n\n ret = -errno;\n\n }\n\n } else {\n\n ret = -errno;\n\n }\n\n\n\n if (glfs_close(fd) != 0) {\n\n ret = -errno;\n\n }\n\n }\n\nout:\n\n g_free(tmp);\n\n qemu_gluster_gconf_free(gconf);\n\n if (glfs) {\n\n glfs_fini(glfs);\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 4996 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DISAS_INSN(divw)\n\n{\n\n TCGv reg;\n\n TCGv tmp;\n\n TCGv src;\n\n int sign;\n\n\n\n sign = (insn & 0x100) != 0;\n\n reg = DREG(insn, 9);\n\n if (sign) {\n\n tcg_gen_ext16s_i32(QREG_DIV1, reg);\n\n } else {\n\n tcg_gen_ext16u_i32(QREG_DIV1, reg);\n\n }\n\n SRC_EA(env, src, OS_WORD, sign, NULL);\n\n tcg_gen_mov_i32(QREG_DIV2, src);\n\n if (sign) {\n\n gen_helper_divs(cpu_env, tcg_const_i32(1));\n\n } else {\n\n gen_helper_divu(cpu_env, tcg_const_i32(1));\n\n }\n\n\n\n tmp = tcg_temp_new();\n\n src = tcg_temp_new();\n\n tcg_gen_ext16u_i32(tmp, QREG_DIV1);\n\n tcg_gen_shli_i32(src, QREG_DIV2, 16);\n\n tcg_gen_or_i32(reg, tmp, src);\n\n\n\n set_cc_op(s, CC_OP_FLAGS);\n\n}\n", + "output": "1", + "index": 354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_read_complete(void * opaque, int ret)\n\n{\n\n SCSIGenericReq *r = (SCSIGenericReq *)opaque;\n\n int len;\n\n\n\n if (ret) {\n\n DPRINTF(\"IO error ret %d\\n\", ret);\n\n scsi_command_complete(r, ret);\n\n return;\n\n }\n\n len = r->io_header.dxfer_len - r->io_header.resid;\n\n DPRINTF(\"Data ready tag=0x%x len=%d\\n\", r->req.tag, len);\n\n\n\n r->len = -1;\n\n r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);\n\n if (len == 0)\n\n scsi_command_complete(r, 0);\n\n}\n", + "output": "1", + "index": 25442 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,\n QEMUIOVector *iov, int nb_sectors,\n BlockDriverCompletionFunc *cb, void *opaque)\n{\n return bdrv_aio_rw_vector(bs, sector_num, iov, nb_sectors,\n cb, opaque, 1);\n}", + "output": "1", + "index": 27072 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "size_t slirp_socket_can_recv(struct in_addr guest_addr, int guest_port)\n\n{\n\n\tstruct iovec iov[2];\n\n\tstruct socket *so;\n\n\n\n if (!link_up)\n\n return 0;\n\n\n\n\tso = slirp_find_ctl_socket(guest_addr, guest_port);\n\n\n\n\tif (!so || so->so_state & SS_NOFDREF)\n\n\t\treturn 0;\n\n\n\n\tif (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2))\n\n\t\treturn 0;\n\n\n\n\treturn sopreprbuf(so, iov, NULL);\n\n}\n", + "output": "0", + "index": 4444 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_update_display(void *opaque)\n\n{\n\n struct vmsvga_state_s *s = opaque;\n\n DisplaySurface *surface;\n\n bool dirty = false;\n\n\n\n if (!s->enable) {\n\n s->vga.hw_ops->gfx_update(&s->vga);\n\n return;\n\n }\n\n\n\n vmsvga_check_size(s);\n\n surface = qemu_console_surface(s->vga.con);\n\n\n\n vmsvga_fifo_run(s);\n\n vmsvga_update_rect_flush(s);\n\n\n\n /*\n\n * Is it more efficient to look at vram VGA-dirty bits or wait\n\n * for the driver to issue SVGA_CMD_UPDATE?\n\n */\n\n if (memory_region_is_logging(&s->vga.vram)) {\n\n vga_sync_dirty_bitmap(&s->vga);\n\n dirty = memory_region_get_dirty(&s->vga.vram, 0,\n\n surface_stride(surface) * surface_height(surface),\n\n DIRTY_MEMORY_VGA);\n\n }\n\n if (s->invalidated || dirty) {\n\n s->invalidated = 0;\n\n dpy_gfx_update(s->vga.con, 0, 0,\n\n surface_width(surface), surface_height(surface));\n\n }\n\n if (dirty) {\n\n memory_region_reset_dirty(&s->vga.vram, 0,\n\n surface_stride(surface) * surface_height(surface),\n\n DIRTY_MEMORY_VGA);\n\n }\n\n}\n", + "output": "0", + "index": 13574 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void timer_del(QEMUTimer *ts)\n\n{\n\n QEMUTimerList *timer_list = ts->timer_list;\n\n\n\n qemu_mutex_lock(&timer_list->active_timers_lock);\n\n timer_del_locked(timer_list, ts);\n\n qemu_mutex_unlock(&timer_list->active_timers_lock);\n\n}\n", + "output": "1", + "index": 3826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bochs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,\n\n QEMUIOVector *qiov, int flags)\n\n{\n\n BDRVBochsState *s = bs->opaque;\n\n uint64_t sector_num = offset >> BDRV_SECTOR_BITS;\n\n int nb_sectors = bytes >> BDRV_SECTOR_BITS;\n\n uint64_t bytes_done = 0;\n\n QEMUIOVector local_qiov;\n\n int ret;\n\n\n\n assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);\n\n assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);\n\n\n\n qemu_iovec_init(&local_qiov, qiov->niov);\n\n qemu_co_mutex_lock(&s->lock);\n\n\n\n while (nb_sectors > 0) {\n\n int64_t block_offset = seek_to_sector(bs, sector_num);\n\n if (block_offset < 0) {\n\n ret = block_offset;\n\n goto fail;\n\n }\n\n\n\n qemu_iovec_reset(&local_qiov);\n\n qemu_iovec_concat(&local_qiov, qiov, bytes_done, 512);\n\n\n\n if (block_offset > 0) {\n\n ret = bdrv_co_preadv(bs->file->bs, block_offset, 512,\n\n &local_qiov, 0);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n } else {\n\n qemu_iovec_memset(&local_qiov, 0, 0, 512);\n\n }\n\n nb_sectors--;\n\n sector_num++;\n\n bytes_done += 512;\n\n }\n\n\n\n ret = 0;\n\nfail:\n\n qemu_co_mutex_unlock(&s->lock);\n\n qemu_iovec_destroy(&local_qiov);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 13802 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *colo_process_incoming_thread(void *opaque)\n\n{\n\n MigrationIncomingState *mis = opaque;\n\n\n\n migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,\n\n MIGRATION_STATUS_COLO);\n\n\n\n mis->to_src_file = qemu_file_get_return_path(mis->from_src_file);\n\n if (!mis->to_src_file) {\n\n error_report(\"COLO incoming thread: Open QEMUFile to_src_file failed\");\n\n goto out;\n\n }\n\n /*\n\n * Note: the communication between Primary side and Secondary side\n\n * should be sequential, we set the fd to unblocked in migration incoming\n\n * coroutine, and here we are in the COLO incoming thread, so it is ok to\n\n * set the fd back to blocked.\n\n */\n\n qemu_file_set_blocking(mis->from_src_file, true);\n\n\n\n /* TODO: COLO checkpoint restore loop */\n\n\n\nout:\n\n if (mis->to_src_file) {\n\n qemu_fclose(mis->to_src_file);\n\n }\n\n migration_incoming_exit_colo();\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 19339 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_vp8dsp_init_arm(VP8DSPContext *dsp)\n\n{\n\n int cpu_flags = av_get_cpu_flags();\n\n\n\n if (have_armv6(cpu_flags))\n\n ff_vp8dsp_init_armv6(dsp);\n\n if (have_neon(cpu_flags))\n\n ff_vp8dsp_init_neon(dsp);\n\n}\n", + "output": "0", + "index": 5941 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,\n\n TCGReg arg1, intptr_t arg2)\n\n{\n\n int opi, opx;\n\n\n\n assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32);\n\n if (type == TCG_TYPE_I32) {\n\n opi = STW, opx = STWX;\n\n } else {\n\n opi = STD, opx = STDX;\n\n }\n\n tcg_out_mem_long(s, opi, opx, arg, arg1, arg2);\n\n}\n", + "output": "0", + "index": 16304 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_partition(BlockDriverState *bs, int partition,\n\n off_t *offset, off_t *size)\n\n{\n\n struct partition_record mbr[4];\n\n uint8_t data[512];\n\n int i;\n\n int ext_partnum = 4;\n\n int ret;\n\n\n\n if ((ret = bdrv_read(bs, 0, data, 1)) < 0) {\n\n errno = -ret;\n\n err(EXIT_FAILURE, \"error while reading\");\n\n }\n\n\n\n if (data[510] != 0x55 || data[511] != 0xaa) {\n\n errno = -EINVAL;\n\n return -1;\n\n }\n\n\n\n for (i = 0; i < 4; i++) {\n\n read_partition(&data[446 + 16 * i], &mbr[i]);\n\n\n\n if (!mbr[i].nb_sectors_abs)\n\n continue;\n\n\n\n if (mbr[i].system == 0xF || mbr[i].system == 0x5) {\n\n struct partition_record ext[4];\n\n uint8_t data1[512];\n\n int j;\n\n\n\n if ((ret = bdrv_read(bs, mbr[i].start_sector_abs, data1, 1)) < 0) {\n\n errno = -ret;\n\n err(EXIT_FAILURE, \"error while reading\");\n\n }\n\n\n\n for (j = 0; j < 4; j++) {\n\n read_partition(&data1[446 + 16 * j], &ext[j]);\n\n if (!ext[j].nb_sectors_abs)\n\n continue;\n\n\n\n if ((ext_partnum + j + 1) == partition) {\n\n *offset = (uint64_t)ext[j].start_sector_abs << 9;\n\n *size = (uint64_t)ext[j].nb_sectors_abs << 9;\n\n return 0;\n\n }\n\n }\n\n ext_partnum += 4;\n\n } else if ((i + 1) == partition) {\n\n *offset = (uint64_t)mbr[i].start_sector_abs << 9;\n\n *size = (uint64_t)mbr[i].nb_sectors_abs << 9;\n\n return 0;\n\n }\n\n }\n\n\n\n errno = -ENOENT;\n\n return -1;\n\n}\n", + "output": "0", + "index": 6537 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq)\n\n{\n\n VirtQueueElement elem;\n\n\n\n if (!(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK))\n\n return;\n\n\n\n if (n->async_tx.elem.out_num) {\n\n virtio_queue_set_notification(n->tx_vq, 0);\n\n return;\n\n }\n\n\n\n while (virtqueue_pop(vq, &elem)) {\n\n ssize_t ret, len = 0;\n\n unsigned int out_num = elem.out_num;\n\n struct iovec *out_sg = &elem.out_sg[0];\n\n unsigned hdr_len;\n\n\n\n /* hdr_len refers to the header received from the guest */\n\n hdr_len = n->mergeable_rx_bufs ?\n\n sizeof(struct virtio_net_hdr_mrg_rxbuf) :\n\n sizeof(struct virtio_net_hdr);\n\n\n\n if (out_num < 1 || out_sg->iov_len != hdr_len) {\n\n fprintf(stderr, \"virtio-net header not in first element\\n\");\n\n exit(1);\n\n }\n\n\n\n /* ignore the header if GSO is not supported */\n\n if (!n->has_vnet_hdr) {\n\n out_num--;\n\n out_sg++;\n\n len += hdr_len;\n\n } else if (n->mergeable_rx_bufs) {\n\n /* tapfd expects a struct virtio_net_hdr */\n\n hdr_len -= sizeof(struct virtio_net_hdr);\n\n out_sg->iov_len -= hdr_len;\n\n len += hdr_len;\n\n }\n\n\n\n ret = qemu_sendv_packet_async(&n->nic->nc, out_sg, out_num,\n\n virtio_net_tx_complete);\n\n if (ret == 0) {\n\n virtio_queue_set_notification(n->tx_vq, 0);\n\n n->async_tx.elem = elem;\n\n n->async_tx.len = len;\n\n return;\n\n }\n\n\n\n len += ret;\n\n\n\n virtqueue_push(vq, &elem, len);\n\n virtio_notify(&n->vdev, vq);\n\n }\n\n}\n", + "output": "1", + "index": 19223 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nvdec_vp9_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)\n\n{\n\n NVDECContext *ctx = avctx->internal->hwaccel_priv_data;\n\n void *tmp;\n\n\n\n tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated,\n\n (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));\n\n if (!tmp)\n\n return AVERROR(ENOMEM);\n\n ctx->slice_offsets = tmp;\n\n\n\n if (!ctx->bitstream)\n\n ctx->bitstream = (uint8_t*)buffer;\n\n\n\n ctx->slice_offsets[ctx->nb_slices] = buffer - ctx->bitstream;\n\n ctx->bitstream_len += size;\n\n ctx->nb_slices++;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 26423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity,\n\n Error **errp)\n\n{\n\n int64_t bitmap_size;\n\n BdrvDirtyBitmap *bitmap;\n\n\n\n assert((granularity & (granularity - 1)) == 0);\n\n\n\n granularity >>= BDRV_SECTOR_BITS;\n\n assert(granularity);\n\n bitmap_size = bdrv_nb_sectors(bs);\n\n if (bitmap_size < 0) {\n\n error_setg_errno(errp, -bitmap_size, \"could not get length of device\");\n\n errno = -bitmap_size;\n\n return NULL;\n\n }\n\n bitmap = g_new0(BdrvDirtyBitmap, 1);\n\n bitmap->bitmap = hbitmap_alloc(bitmap_size, ffs(granularity) - 1);\n\n QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list);\n\n return bitmap;\n\n}\n", + "output": "0", + "index": 8070 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void apic_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)\n\n{\n\n}\n", + "output": "0", + "index": 21305 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void __attribute__((__constructor__)) rcu_init(void)\n\n{\n\n QemuThread thread;\n\n\n\n qemu_mutex_init(&rcu_gp_lock);\n\n qemu_event_init(&rcu_gp_event, true);\n\n\n\n qemu_event_init(&rcu_call_ready_event, false);\n\n qemu_thread_create(&thread, \"call_rcu\", call_rcu_thread,\n\n NULL, QEMU_THREAD_DETACHED);\n\n\n\n rcu_register_thread();\n\n}\n", + "output": "1", + "index": 21952 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_setup(PcGuestInfo *guest_info)\n\n{\n\n AcpiBuildTables tables;\n\n AcpiBuildState *build_state;\n\n\n\n if (!guest_info->fw_cfg) {\n\n ACPI_BUILD_DPRINTF(\"No fw cfg. Bailing out.\\n\");\n\n return;\n\n }\n\n\n\n if (!guest_info->has_acpi_build) {\n\n ACPI_BUILD_DPRINTF(\"ACPI build disabled. Bailing out.\\n\");\n\n return;\n\n }\n\n\n\n if (!acpi_enabled) {\n\n ACPI_BUILD_DPRINTF(\"ACPI disabled. Bailing out.\\n\");\n\n return;\n\n }\n\n\n\n build_state = g_malloc0(sizeof *build_state);\n\n\n\n build_state->guest_info = guest_info;\n\n\n\n acpi_set_pci_info();\n\n\n\n acpi_build_tables_init(&tables);\n\n acpi_build(build_state->guest_info, &tables);\n\n\n\n /* Now expose it all to Guest */\n\n build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,\n\n ACPI_BUILD_TABLE_FILE,\n\n ACPI_BUILD_TABLE_MAX_SIZE);\n\n assert(build_state->table_ram != RAM_ADDR_MAX);\n\n build_state->table_size = acpi_data_len(tables.table_data);\n\n\n\n acpi_add_rom_blob(NULL, tables.linker, \"etc/table-loader\", 0);\n\n\n\n fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,\n\n tables.tcpalog->data, acpi_data_len(tables.tcpalog));\n\n\n\n /*\n\n * RSDP is small so it's easy to keep it immutable, no need to\n\n * bother with ROM blobs.\n\n */\n\n fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,\n\n tables.rsdp->data, acpi_data_len(tables.rsdp));\n\n\n\n qemu_register_reset(acpi_build_reset, build_state);\n\n acpi_build_reset(build_state);\n\n vmstate_register(NULL, 0, &vmstate_acpi_build, build_state);\n\n\n\n /* Cleanup tables but don't free the memory: we track it\n\n * in build_state.\n\n */\n\n acpi_build_tables_cleanup(&tables, false);\n\n}\n", + "output": "1", + "index": 6681 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend,\n\n Error **errp)\n\n{\n\n const char *name = qemu_opt_get(opts, \"name\");\n\n ChardevSpicePort *spiceport;\n\n\n\n if (name == NULL) {\n\n error_setg(errp, \"chardev: spice port: no name given\");\n\n return;\n\n }\n\n spiceport = backend->u.spiceport = g_new0(ChardevSpicePort, 1);\n\n qemu_chr_parse_common(opts, qapi_ChardevSpicePort_base(spiceport));\n\n spiceport->fqdn = g_strdup(name);\n\n}\n", + "output": "0", + "index": 25962 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_parse_context(OptionParseContext *octx,\n\n const OptionGroupDef *groups, int nb_groups)\n\n{\n\n static const OptionGroupDef global_group = { \"global\" };\n\n int i;\n\n\n\n memset(octx, 0, sizeof(*octx));\n\n\n\n octx->nb_groups = nb_groups;\n\n octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups);\n\n if (!octx->groups)\n\n exit(1);\n\n\n\n for (i = 0; i < octx->nb_groups; i++)\n\n octx->groups[i].group_def = &groups[i];\n\n\n\n octx->global_opts.group_def = &global_group;\n\n octx->global_opts.arg = \"\";\n\n\n\n init_opts();\n\n}\n", + "output": "1", + "index": 13263 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BalloonInfo *qmp_query_balloon(Error **errp)\n\n{\n\n BalloonInfo *info;\n\n\n\n if (kvm_enabled() && !kvm_has_sync_mmu()) {\n\n error_set(errp, QERR_KVM_MISSING_CAP, \"synchronous MMU\", \"balloon\");\n\n return NULL;\n\n }\n\n\n\n info = g_malloc0(sizeof(*info));\n\n\n\n if (qemu_balloon_status(info) == 0) {\n\n error_set(errp, QERR_DEVICE_NOT_ACTIVE, \"balloon\");\n\n qapi_free_BalloonInfo(info);\n\n return NULL;\n\n }\n\n\n\n return info;\n\n}\n", + "output": "0", + "index": 12308 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "print_execve(const struct syscallname *name,\n\n abi_long arg1, abi_long arg2, abi_long arg3,\n\n abi_long arg4, abi_long arg5, abi_long arg6)\n\n{\n\n abi_ulong arg_ptr_addr;\n\n char *s;\n\n\n\n if (!(s = lock_user_string(arg1)))\n\n return;\n\n gemu_log(\"%s(\\\"%s\\\",{\", name->name, s);\n\n unlock_user(s, arg1, 0);\n\n\n\n for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {\n\n abi_ulong *arg_ptr, arg_addr, s_addr;\n\n\n\n arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);\n\n if (!arg_ptr)\n\n return;\n\n arg_addr = tswapl(*arg_ptr);\n\n unlock_user(arg_ptr, arg_ptr_addr, 0);\n\n if (!arg_addr)\n\n break;\n\n if ((s = lock_user_string(arg_addr))) {\n\n gemu_log(\"\\\"%s\\\",\", s);\n\n unlock_user(s, s_addr, 0);\n\n }\n\n }\n\n\n\n gemu_log(\"NULL})\");\n\n}\n", + "output": "1", + "index": 19358 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mkv_check_tag(AVDictionary *m)\n\n{\n\n AVDictionaryEntry *t = NULL;\n\n\n\n while ((t = av_dict_get(m, \"\", t, AV_DICT_IGNORE_SUFFIX)))\n\n if (av_strcasecmp(t->key, \"title\") && av_strcasecmp(t->key, \"stereo_mode\"))\n\n return 1;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 386 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cp15_tls_load_store(CPUState *env, DisasContext *s, uint32_t insn, uint32_t rd)\n\n{\n\n TCGv tmp;\n\n int cpn = (insn >> 16) & 0xf;\n\n int cpm = insn & 0xf;\n\n int op = ((insn >> 5) & 7) | ((insn >> 18) & 0x38);\n\n\n\n if (!arm_feature(env, ARM_FEATURE_V6K))\n\n return 0;\n\n\n\n if (!(cpn == 13 && cpm == 0))\n\n return 0;\n\n\n\n if (insn & ARM_CP_RW_BIT) {\n\n switch (op) {\n\n case 2:\n\n tmp = load_cpu_field(cp15.c13_tls1);\n\n break;\n\n case 3:\n\n tmp = load_cpu_field(cp15.c13_tls2);\n\n break;\n\n case 4:\n\n tmp = load_cpu_field(cp15.c13_tls3);\n\n break;\n\n default:\n\n return 0;\n\n }\n\n store_reg(s, rd, tmp);\n\n\n\n } else {\n\n tmp = load_reg(s, rd);\n\n switch (op) {\n\n case 2:\n\n store_cpu_field(tmp, cp15.c13_tls1);\n\n break;\n\n case 3:\n\n store_cpu_field(tmp, cp15.c13_tls2);\n\n break;\n\n case 4:\n\n store_cpu_field(tmp, cp15.c13_tls3);\n\n break;\n\n default:\n\n dead_tmp(tmp);\n\n return 0;\n\n }\n\n }\n\n return 1;\n\n}\n", + "output": "1", + "index": 21749 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,\n\n int64_t offset, unsigned int bytes)\n\n{\n\n BdrvTrackedRequest *req;\n\n int64_t cluster_offset;\n\n unsigned int cluster_bytes;\n\n bool retry;\n\n\n\n /* If we touch the same cluster it counts as an overlap. This guarantees\n\n * that allocating writes will be serialized and not race with each other\n\n * for the same cluster. For example, in copy-on-read it ensures that the\n\n * CoR read and write operations are atomic and guest writes cannot\n\n * interleave between them.\n\n */\n\n round_bytes_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes);\n\n\n\n do {\n\n retry = false;\n\n QLIST_FOREACH(req, &bs->tracked_requests, list) {\n\n if (tracked_request_overlaps(req, cluster_offset, cluster_bytes)) {\n\n /* Hitting this means there was a reentrant request, for\n\n * example, a block driver issuing nested requests. This must\n\n * never happen since it means deadlock.\n\n */\n\n assert(qemu_coroutine_self() != req->co);\n\n\n\n qemu_co_queue_wait(&req->wait_queue);\n\n retry = true;\n\n break;\n\n }\n\n }\n\n } while (retry);\n\n}\n", + "output": "0", + "index": 13512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PPC_OP(subfze)\n\n{\n\n T1 = ~T0;\n\n T0 = T1 + xer_ca;\n\n if (T0 < T1) {\n\n xer_ca = 1;\n\n } else {\n\n xer_ca = 0;\n\n }\n\n RETURN();\n\n}\n", + "output": "1", + "index": 10761 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nvme_instance_init(Object *obj)\n\n{\n\n object_property_add(obj, \"bootindex\", \"int32\",\n\n nvme_get_bootindex,\n\n nvme_set_bootindex, NULL, NULL, NULL);\n\n object_property_set_int(obj, -1, \"bootindex\", NULL);\n\n}\n", + "output": "1", + "index": 3278 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)\n\n{\n\n bool print16 = !!trace_event_get_state(TRACE_USB_OHCI_TD_PKT_SHORT);\n\n bool printall = !!trace_event_get_state(TRACE_USB_OHCI_TD_PKT_FULL);\n\n const int width = 16;\n\n int i;\n\n char tmp[3 * width + 1];\n\n char *p = tmp;\n\n\n\n if (!printall && !print16) {\n\n return;\n\n }\n\n\n\n for (i = 0; ; i++) {\n\n if (i && (!(i % width) || (i == len))) {\n\n if (!printall) {\n\n trace_usb_ohci_td_pkt_short(msg, tmp);\n\n break;\n\n }\n\n trace_usb_ohci_td_pkt_full(msg, tmp);\n\n p = tmp;\n\n *p = 0;\n\n }\n\n if (i == len) {\n\n break;\n\n }\n\n\n\n p += sprintf(p, \" %.2x\", buf[i]);\n\n }\n\n}\n", + "output": "1", + "index": 23663 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void timer_del(QEMUTimer *ts)\n\n{\n\n QEMUTimer **pt, *t;\n\n\n\n pt = &ts->timer_list->active_timers;\n\n for(;;) {\n\n t = *pt;\n\n if (!t)\n\n break;\n\n if (t == ts) {\n\n *pt = t->next;\n\n break;\n\n }\n\n pt = &t->next;\n\n }\n\n}\n", + "output": "0", + "index": 20066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_whole_cluster(BlockDriverState *bs, uint64_t cluster_offset,\n\n uint64_t offset, int allocate)\n\n{\n\n uint64_t parent_cluster_offset;\n\n BDRVVmdkState *s = bs->opaque;\n\n uint8_t whole_grain[s->cluster_sectors*512]; // 128 sectors * 512 bytes each = grain size 64KB\n\n\n\n // we will be here if it's first write on non-exist grain(cluster).\n\n // try to read from parent image, if exist\n\n if (s->hd->backing_hd) {\n\n BDRVVmdkState *ps = s->hd->backing_hd->opaque;\n\n\n\n if (!vmdk_is_cid_valid(bs))\n\n return -1;\n\n parent_cluster_offset = get_cluster_offset(s->hd->backing_hd, offset, allocate);\n\n if (bdrv_pread(ps->hd, parent_cluster_offset, whole_grain, ps->cluster_sectors*512) != \n\n ps->cluster_sectors*512)\n\n return -1;\n\n\n\n if (bdrv_pwrite(s->hd, cluster_offset << 9, whole_grain, sizeof(whole_grain)) != \n\n sizeof(whole_grain))\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 22681 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "VLANClientState *qemu_new_vlan_client(VLANState *vlan,\n\n IOReadHandler *fd_read, void *opaque)\n\n{\n\n VLANClientState *vc, **pvc;\n\n vc = qemu_mallocz(sizeof(VLANClientState));\n\n if (!vc)\n\n return NULL;\n\n vc->fd_read = fd_read;\n\n vc->opaque = opaque;\n\n vc->vlan = vlan;\n\n\n\n vc->next = NULL;\n\n pvc = &vlan->first_client;\n\n while (*pvc != NULL)\n\n pvc = &(*pvc)->next;\n\n *pvc = vc;\n\n return vc;\n\n}\n", + "output": "1", + "index": 24405 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usbredir_alt_setting_status(void *priv, uint32_t id,\n\n struct usb_redir_alt_setting_status_header *alt_setting_status)\n\n{\n\n USBRedirDevice *dev = priv;\n\n AsyncURB *aurb;\n\n int len = 0;\n\n\n\n DPRINTF(\"alt status %d intf %d alt %d id: %u\\n\",\n\n alt_setting_status->status,\n\n alt_setting_status->interface,\n\n alt_setting_status->alt, id);\n\n\n\n aurb = async_find(dev, id);\n\n if (!aurb) {\n\n return;\n\n }\n\n if (aurb->packet) {\n\n if (aurb->get) {\n\n dev->dev.data_buf[0] = alt_setting_status->alt;\n\n len = 1;\n\n }\n\n aurb->packet->len =\n\n usbredir_handle_status(dev, alt_setting_status->status, len);\n\n usb_generic_async_ctrl_complete(&dev->dev, aurb->packet);\n\n }\n\n async_free(dev, aurb);\n\n}\n", + "output": "1", + "index": 7535 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_cont(int argc, const char **argv)\n\n{\n\n vm_start();\n\n}\n", + "output": "0", + "index": 27245 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec)\n\n{\n\n AVStream *fst;\n\n\n\n fst = av_mallocz(sizeof(AVStream));\n\n if (!fst)\n\n return NULL;\n\n fst->priv_data = av_mallocz(sizeof(FeedData));\n\n memcpy(&fst->codec, codec, sizeof(AVCodecContext));\n\n\n stream->streams[stream->nb_streams++] = fst;\n\n return fst;\n\n}", + "output": "1", + "index": 6904 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_sgl_init_external(VirtIOSCSIReq *req, struct iovec *sg,\n\n hwaddr *addr, int num)\n\n{\n\n QEMUSGList *qsgl = &req->qsgl;\n\n\n\n qemu_sglist_init(qsgl, DEVICE(req->dev), num, &address_space_memory);\n\n while (num--) {\n\n qemu_sglist_add(qsgl, *(addr++), (sg++)->iov_len);\n\n }\n\n}\n", + "output": "0", + "index": 23452 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_len_table(uint8_t *dst, GetBitContext *gb){\n\n int i, val, repeat;\n\n\n\n for(i=0; i<256;){\n\n repeat= get_bits(gb, 3);\n\n val = get_bits(gb, 5);\n\n if(repeat==0)\n\n repeat= get_bits(gb, 8);\n\n//printf(\"%d %d\\n\", val, repeat);\n\n if(i+repeat > 256) {\n\n av_log(NULL, AV_LOG_ERROR, \"Error reading huffman table\\n\");\n\n return -1;\n\n }\n\n while (repeat--)\n\n dst[i++] = val;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 12179 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){\n\n int temp[16];\n\n uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n int i;\n\n\n\n rv34_row_transform(temp, block);\n\n memset(block, 0, 16*sizeof(DCTELEM));\n\n\n\n for(i = 0; i < 4; i++){\n\n const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;\n\n const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;\n\n const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];\n\n const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];\n\n\n\n dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];\n\n dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];\n\n dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];\n\n dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];\n\n\n\n dst += stride;\n\n }\n\n}\n", + "output": "0", + "index": 20778 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n NUTContext *nut = s->priv_data;\n\n ByteIOContext *bc = &s->pb;\n\n int i, frame_code=0, ret, skip;\n\n int64_t ts, back_ptr;\n\n\n\n for(;;){\n\n int64_t pos= url_ftell(bc);\n\n uint64_t tmp= nut->next_startcode;\n\n nut->next_startcode=0;\n\n\n\n if (url_feof(bc))\n\n return -1;\n\n\n\n if(tmp){\n\n pos-=8;\n\n }else{\n\n frame_code = get_byte(bc);\n\n if(frame_code == 'N'){\n\n tmp= frame_code;\n\n for(i=1; i<8; i++)\n\n tmp = (tmp<<8) + get_byte(bc);\n\n }\n\n }\n\n switch(tmp){\n\n case MAIN_STARTCODE:\n\n case STREAM_STARTCODE:\n\n case INDEX_STARTCODE:\n\n skip= get_packetheader(nut, bc, 0);\n\n url_fseek(bc, skip, SEEK_CUR);\n\n break;\n\n case INFO_STARTCODE:\n\n if(decode_info_header(nut)<0)\n\n goto resync;\n\n break;\n\n case SYNCPOINT_STARTCODE:\n\n if(decode_syncpoint(nut, &ts, &back_ptr)<0)\n\n goto resync;\n\n frame_code = get_byte(bc);\n\n case 0:\n\n ret= decode_frame(nut, pkt, frame_code);\n\n if(ret==0)\n\n return 0;\n\n else if(ret==1) //ok but discard packet\n\n break;\n\n default:\n\nresync:\n\nav_log(s, AV_LOG_DEBUG, \"syncing from %\"PRId64\"\\n\", pos);\n\n tmp= find_any_startcode(bc, nut->last_syncpoint_pos+1);\n\n if(tmp==0)\n\n return -1;\n\nav_log(s, AV_LOG_DEBUG, \"sync\\n\");\n\n nut->next_startcode= tmp;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 5741 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp)\n\n{\n\n MOVContext *mov = s->priv_data;\n\n int i, j;\n\n\n\n if (!mov->fragment_index_complete)\n\n return 0;\n\n\n\n for (i = 0; i < mov->fragment_index_count; i++) {\n\n if (mov->fragment_index_data[i]->track_id == st->id) {\n\n MOVFragmentIndex *index = index = mov->fragment_index_data[i];\n\n for (j = index->item_count - 1; j >= 0; j--) {\n\n if (index->items[j].time <= timestamp) {\n\n if (index->items[j].headers_read)\n\n return 0;\n\n\n\n return mov_switch_root(s, index->items[j].moof_offset);\n\n }\n\n }\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 5429 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_icbi (void)\n\n{\n\n uint32_t tmp;\n\n /* Invalidate one cache line :\n\n * PowerPC specification says this is to be treated like a load\n\n * (not a fetch) by the MMU. To be sure it will be so,\n\n * do the load \"by hand\".\n\n */\n\n#if defined(TARGET_PPC64)\n\n if (!msr_sf)\n\n T0 &= 0xFFFFFFFFULL;\n\n#endif\n\n tmp = ldl_kernel(T0);\n\n T0 &= ~(ICACHE_LINE_SIZE - 1);\n\n tb_invalidate_page_range(T0, T0 + ICACHE_LINE_SIZE);\n\n}\n", + "output": "1", + "index": 9783 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,\n\n const char *replaces,\n\n int64_t speed, uint32_t granularity,\n\n int64_t buf_size,\n\n BlockMirrorBackingMode backing_mode,\n\n BlockdevOnError on_source_error,\n\n BlockdevOnError on_target_error,\n\n bool unmap,\n\n BlockCompletionFunc *cb,\n\n void *opaque, Error **errp,\n\n const BlockJobDriver *driver,\n\n bool is_none_mode, BlockDriverState *base)\n\n{\n\n MirrorBlockJob *s;\n\n\n\n if (granularity == 0) {\n\n granularity = bdrv_get_default_bitmap_granularity(target);\n\n }\n\n\n\n assert ((granularity & (granularity - 1)) == 0);\n\n\n\n if (buf_size < 0) {\n\n error_setg(errp, \"Invalid parameter 'buf-size'\");\n\n return;\n\n }\n\n\n\n if (buf_size == 0) {\n\n buf_size = DEFAULT_MIRROR_BUF_SIZE;\n\n }\n\n\n\n s = block_job_create(driver, bs, speed, cb, opaque, errp);\n\n if (!s) {\n\n return;\n\n }\n\n\n\n s->target = blk_new();\n\n blk_insert_bs(s->target, target);\n\n\n\n s->replaces = g_strdup(replaces);\n\n s->on_source_error = on_source_error;\n\n s->on_target_error = on_target_error;\n\n s->is_none_mode = is_none_mode;\n\n s->backing_mode = backing_mode;\n\n s->base = base;\n\n s->granularity = granularity;\n\n s->buf_size = ROUND_UP(buf_size, granularity);\n\n s->unmap = unmap;\n\n\n\n s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);\n\n if (!s->dirty_bitmap) {\n\n g_free(s->replaces);\n\n blk_unref(s->target);\n\n block_job_unref(&s->common);\n\n return;\n\n }\n\n\n\n bdrv_op_block_all(target, s->common.blocker);\n\n\n\n s->common.co = qemu_coroutine_create(mirror_run);\n\n trace_mirror_start(bs, s, s->common.co, opaque);\n\n qemu_coroutine_enter(s->common.co, s);\n\n}\n", + "output": "1", + "index": 25555 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int hw_device_setup_for_decode(InputStream *ist)\n\n{\n\n enum AVHWDeviceType type;\n\n HWDevice *dev;\n\n int err;\n\n\n\n if (ist->hwaccel_device) {\n\n dev = hw_device_get_by_name(ist->hwaccel_device);\n\n if (!dev) {\n\n char *tmp;\n\n type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);\n\n if (type == AV_HWDEVICE_TYPE_NONE) {\n\n // No match - this isn't necessarily invalid, though,\n\n // because an explicit device might not be needed or\n\n // the hwaccel setup could be handled elsewhere.\n\n return 0;\n\n }\n\n tmp = av_asprintf(\"%s:%s\", av_hwdevice_get_type_name(type),\n\n ist->hwaccel_device);\n\n if (!tmp)\n\n return AVERROR(ENOMEM);\n\n err = hw_device_init_from_string(tmp, &dev);\n\n av_free(tmp);\n\n if (err < 0)\n\n return err;\n\n }\n\n } else {\n\n if (ist->hwaccel_id != HWACCEL_NONE)\n\n type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);\n\n else\n\n type = hw_device_match_type_in_name(ist->dec->name);\n\n if (type != AV_HWDEVICE_TYPE_NONE) {\n\n dev = hw_device_get_by_type(type);\n\n if (!dev) {\n\n hw_device_init_from_string(av_hwdevice_get_type_name(type),\n\n &dev);\n\n }\n\n } else {\n\n // No device required.\n\n return 0;\n\n }\n\n }\n\n\n\n if (!dev) {\n\n av_log(ist->dec_ctx, AV_LOG_WARNING, \"No device available \"\n\n \"for decoder (device type %s for codec %s).\\n\",\n\n av_hwdevice_get_type_name(type), ist->dec->name);\n\n return 0;\n\n }\n\n\n\n ist->dec_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref);\n\n if (!ist->dec_ctx->hw_device_ctx)\n\n return AVERROR(ENOMEM);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 16577 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void adx_decode_stereo(short *out,const unsigned char *in,PREV *prev)\n\n{\n\n\tshort tmp[32*2];\n\n\tint i;\n\n\n\n\tadx_decode(tmp ,in ,prev);\n\n\tadx_decode(tmp+32,in+18,prev+1);\n\n\tfor(i=0;i<32;i++) {\n\n\t\tout[i*2] = tmp[i];\n\n\t\tout[i*2+1] = tmp[i+32];\n\n\t}\n\n}\n", + "output": "1", + "index": 5613 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)\n\n{\n\n int i;\n\n HEVCLocalContext *lc = s->HEVClc;\n\n GetBitContext *gb = &lc->gb;\n\n decode_profile_tier_level(s, &ptl->general_PTL);\n\n ptl->general_PTL.level_idc = get_bits(gb, 8);\n\n\n\n for (i = 0; i < max_num_sub_layers - 1; i++) {\n\n ptl->sub_layer_profile_present_flag[i] = get_bits1(gb);\n\n ptl->sub_layer_level_present_flag[i] = get_bits1(gb);\n\n }\n\n if (max_num_sub_layers - 1> 0)\n\n for (i = max_num_sub_layers - 1; i < 8; i++)\n\n skip_bits(gb, 2); // reserved_zero_2bits[i]\n\n for (i = 0; i < max_num_sub_layers - 1; i++) {\n\n if (ptl->sub_layer_profile_present_flag[i])\n\n decode_profile_tier_level(s, &ptl->sub_layer_PTL[i]);\n\n if (ptl->sub_layer_level_present_flag[i])\n\n ptl->sub_layer_PTL[i].level_idc = get_bits(gb, 8);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 2200 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_msi_ctrl_write(void *opaque, hwaddr addr, uint64_t data,\n\n unsigned int size)\n\n{\n\n S390PCIBusDevice *pbdev;\n\n uint32_t io_int_word;\n\n uint32_t fid = data >> ZPCI_MSI_VEC_BITS;\n\n uint32_t vec = data & ZPCI_MSI_VEC_MASK;\n\n uint64_t ind_bit;\n\n uint32_t sum_bit;\n\n uint32_t e = 0;\n\n\n\n DPRINTF(\"write_msix data 0x%\" PRIx64 \" fid %d vec 0x%x\\n\", data, fid, vec);\n\n\n\n pbdev = s390_pci_find_dev_by_fid(fid);\n\n if (!pbdev) {\n\n e |= (vec << ERR_EVENT_MVN_OFFSET);\n\n s390_pci_generate_error_event(ERR_EVENT_NOMSI, 0, fid, addr, e);\n\n return;\n\n }\n\n\n\n if (pbdev->state != ZPCI_FS_ENABLED) {\n\n return;\n\n }\n\n\n\n ind_bit = pbdev->routes.adapter.ind_offset;\n\n sum_bit = pbdev->routes.adapter.summary_offset;\n\n\n\n set_ind_atomic(pbdev->routes.adapter.ind_addr + (ind_bit + vec) / 8,\n\n 0x80 >> ((ind_bit + vec) % 8));\n\n if (!set_ind_atomic(pbdev->routes.adapter.summary_addr + sum_bit / 8,\n\n 0x80 >> (sum_bit % 8))) {\n\n io_int_word = (pbdev->isc << 27) | IO_INT_WORD_AI;\n\n s390_io_interrupt(0, 0, 0, io_int_word);\n\n }\n\n}\n", + "output": "1", + "index": 2226 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int dec_movem_mr(DisasContext *dc)\n\n{\n\n\tTCGv tmp[16];\n\n\tTCGv addr;\n\n\tint i;\n\n\tint nr = dc->op2 + 1;\n\n\n\n\tDIS(fprintf (logfile, \"movem [$r%u%s, $r%u\\n\", dc->op1,\n\n\t\t dc->postinc ? \"+]\" : \"]\", dc->op2));\n\n\n\n\taddr = tcg_temp_new(TCG_TYPE_TL);\n\n\t/* There are probably better ways of doing this. */\n\n\tcris_flush_cc_state(dc);\n\n\tfor (i = 0; i < (nr >> 1); i++) {\n\n\t\ttmp[i] = tcg_temp_new(TCG_TYPE_I64);\n\n\t\ttcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8);\n\n\t\tgen_load(dc, tmp[i], addr, 8, 0);\n\n\t}\n\n\tif (nr & 1) {\n\n\t\ttmp[i] = tcg_temp_new(TCG_TYPE_I32);\n\n\t\ttcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8);\n\n\t\tgen_load(dc, tmp[i], addr, 4, 0);\n\n\t}\n\n\ttcg_temp_free(addr);\n\n\n\n\tfor (i = 0; i < (nr >> 1); i++) {\n\n\t\ttcg_gen_trunc_i64_i32(cpu_R[i * 2], tmp[i]);\n\n\t\ttcg_gen_shri_i64(tmp[i], tmp[i], 32);\n\n\t\ttcg_gen_trunc_i64_i32(cpu_R[i * 2 + 1], tmp[i]);\n\n\t\ttcg_temp_free(tmp[i]);\n\n\t}\n\n\tif (nr & 1) {\n\n\t\ttcg_gen_mov_tl(cpu_R[dc->op2], tmp[i]);\n\n\t\ttcg_temp_free(tmp[i]);\n\n\t}\n\n\n\n\t/* writeback the updated pointer value. */\n\n\tif (dc->postinc)\n\n\t\ttcg_gen_addi_tl(cpu_R[dc->op1], cpu_R[dc->op1], nr * 4);\n\n\n\n\t/* gen_load might want to evaluate the previous insns flags. */\n\n\tcris_cc_mask(dc, 0);\n\n\treturn 2;\n\n}\n", + "output": "0", + "index": 5702 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)\n\n{\n\n int port;\n\n const char *p;\n\n char buf[200], opts[50] = \"\";\n\n struct addrinfo hints = { 0 }, *ai = NULL;\n\n const char *proxy_path;\n\n int use_proxy;\n\n\n\n set_options(c, uri);\n\n\n\n if (c->listen)\n\n snprintf(opts, sizeof(opts), \"?listen=1\");\n\n\n\n av_url_split(NULL, 0, NULL, 0, c->host, sizeof(c->host), &port, NULL, 0, uri);\n\n\n\n p = strchr(uri, '?');\n\n\n\n if (!p) {\n\n p = opts;\n\n } else {\n\n if (av_find_info_tag(opts, sizeof(opts), \"listen\", p))\n\n c->listen = 1;\n\n }\n\n\n\n ff_url_join(buf, sizeof(buf), \"tcp\", NULL, c->host, port, \"%s\", p);\n\n\n\n hints.ai_flags = AI_NUMERICHOST;\n\n if (!getaddrinfo(c->host, NULL, &hints, &ai)) {\n\n c->numerichost = 1;\n\n freeaddrinfo(ai);\n\n }\n\n\n\n proxy_path = getenv(\"http_proxy\");\n\n use_proxy = !ff_http_match_no_proxy(getenv(\"no_proxy\"), c->host) &&\n\n proxy_path && av_strstart(proxy_path, \"http://\", NULL);\n\n\n\n if (use_proxy) {\n\n char proxy_host[200], proxy_auth[200], dest[200];\n\n int proxy_port;\n\n av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),\n\n proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,\n\n proxy_path);\n\n ff_url_join(dest, sizeof(dest), NULL, NULL, c->host, port, NULL);\n\n ff_url_join(buf, sizeof(buf), \"httpproxy\", proxy_auth, proxy_host,\n\n proxy_port, \"/%s\", dest);\n\n }\n\n\n\n return ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE,\n\n &parent->interrupt_callback, options);\n\n}\n", + "output": "1", + "index": 24837 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CharDriverState *qemu_chr_find(const char *name)\n\n{\n\n CharDriverState *chr;\n\n\n\n TAILQ_FOREACH(chr, &chardevs, next) {\n\n if (strcmp(chr->label, name) != 0)\n\n continue;\n\n return chr;\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 1701 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],\n\n const uint8_t *src,\n\n enum AVPixelFormat pix_fmt, int width, int height, int align)\n\n{\n\n int ret, i;\n\n\n\n if ((ret = av_image_check_size(width, height, 0, NULL)) < 0)\n\n return ret;\n\n\n\n if ((ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width)) < 0)\n\n return ret;\n\n\n\n for (i = 0; i < 4; i++)\n\n dst_linesize[i] = FFALIGN(dst_linesize[i], align);\n\n\n\n if ((ret = av_image_fill_pointers(dst_data, pix_fmt, width, NULL, dst_linesize)) < 0)\n\n return ret;\n\n\n\n return av_image_fill_pointers(dst_data, pix_fmt, height, (uint8_t *)src, dst_linesize);\n\n}\n", + "output": "0", + "index": 20017 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_co_send_request(BDRVNBDState *s, struct nbd_request *request,\n\n struct iovec *iov, int offset)\n\n{\n\n int rc, ret;\n\n\n\n qemu_co_mutex_lock(&s->send_mutex);\n\n s->send_coroutine = qemu_coroutine_self();\n\n qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, nbd_restart_write,\n\n nbd_have_request, NULL, s);\n\n rc = nbd_send_request(s->sock, request);\n\n if (rc >= 0 && iov) {\n\n ret = qemu_co_sendv(s->sock, iov, request->len, offset);\n\n if (ret != request->len) {\n\n errno = -EIO;\n\n rc = -1;\n\n }\n\n }\n\n qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL,\n\n nbd_have_request, NULL, s);\n\n s->send_coroutine = NULL;\n\n qemu_co_mutex_unlock(&s->send_mutex);\n\n return rc;\n\n}\n", + "output": "0", + "index": 3757 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b,\n\n int start_bits, int has_sign)\n\n{\n\n int i, j, len, len2, bsize, sign, v, v2;\n\n int16_t *dst = (int16_t*)b->cur_dec;\n\n\n\n CHECK_READ_VAL(gb, b, len);\n\n v = get_bits(gb, start_bits - has_sign);\n\n if (v && has_sign) {\n\n sign = -get_bits1(gb);\n\n v = (v ^ sign) - sign;\n\n }\n\n *dst++ = v;\n\n len--;\n\n for (i = 0; i < len; i += 8) {\n\n len2 = FFMIN(len - i, 8);\n\n bsize = get_bits(gb, 4);\n\n if (bsize) {\n\n for (j = 0; j < len2; j++) {\n\n v2 = get_bits(gb, bsize);\n\n if (v2) {\n\n sign = -get_bits1(gb);\n\n v2 = (v2 ^ sign) - sign;\n\n }\n\n v += v2;\n\n *dst++ = v;\n\n if (v < -32768 || v > 32767) {\n\n av_log(avctx, AV_LOG_ERROR, \"DC value went out of bounds: %d\\n\", v);\n\n return -1;\n\n }\n\n }\n\n } else {\n\n for (j = 0; j < len2; j++)\n\n *dst++ = v;\n\n }\n\n }\n\n\n\n b->cur_dec = (uint8_t*)dst;\n\n return 0;\n\n}\n", + "output": "1", + "index": 5788 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_set_geometry_hint(BlockDriverState *bs,\n\n int cyls, int heads, int secs)\n\n{\n\n bs->cyls = cyls;\n\n bs->heads = heads;\n\n bs->secs = secs;\n\n}\n", + "output": "0", + "index": 1901 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virgl_cmd_get_capset_info(VirtIOGPU *g,\n\n struct virtio_gpu_ctrl_command *cmd)\n\n{\n\n struct virtio_gpu_get_capset_info info;\n\n struct virtio_gpu_resp_capset_info resp;\n\n\n\n VIRTIO_GPU_FILL_CMD(info);\n\n\n\n\n if (info.capset_index == 0) {\n\n resp.capset_id = VIRTIO_GPU_CAPSET_VIRGL;\n\n virgl_renderer_get_cap_set(resp.capset_id,\n\n &resp.capset_max_version,\n\n &resp.capset_max_size);\n\n } else {\n\n resp.capset_max_version = 0;\n\n resp.capset_max_size = 0;\n\n }\n\n resp.hdr.type = VIRTIO_GPU_RESP_OK_CAPSET_INFO;\n\n virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp));\n\n}", + "output": "1", + "index": 6901 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "opts_next_list(Visitor *v, GenericList **list, Error **errp)\n\n{\n\n OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);\n\n GenericList **link;\n\n\n\n if (ov->repeated_opts_first) {\n\n ov->repeated_opts_first = false;\n\n link = list;\n\n } else {\n\n const QemuOpt *opt;\n\n\n\n opt = g_queue_pop_head(ov->repeated_opts);\n\n if (g_queue_is_empty(ov->repeated_opts)) {\n\n g_hash_table_remove(ov->unprocessed_opts, opt->name);\n\n return NULL;\n\n }\n\n link = &(*list)->next;\n\n }\n\n\n\n *link = g_malloc0(sizeof **link);\n\n return *link;\n\n}\n", + "output": "0", + "index": 5805 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bt_hid_interrupt_sdu(void *opaque, const uint8_t *data, int len)\n\n{\n\n struct bt_hid_device_s *hid = opaque;\n\n\n\n if (len > BT_HID_MTU || len < 1)\n\n goto bad;\n\n if ((data[0] & 3) != BT_DATA_OUTPUT)\n\n goto bad;\n\n if ((data[0] >> 4) == BT_DATA) {\n\n if (hid->intr_state)\n\n goto bad;\n\n\n\n hid->data_type = BT_DATA_OUTPUT;\n\n hid->intrdataout.len = 0;\n\n } else if ((data[0] >> 4) == BT_DATC) {\n\n if (!hid->intr_state)\n\n goto bad;\n\n } else\n\n goto bad;\n\n\n\n memcpy(hid->intrdataout.buffer + hid->intrdataout.len, data + 1, len - 1);\n\n hid->intrdataout.len += len - 1;\n\n hid->intr_state = (len == BT_HID_MTU);\n\n if (!hid->intr_state) {\n\n memcpy(hid->dataout.buffer, hid->intrdataout.buffer,\n\n hid->dataout.len = hid->intrdataout.len);\n\n bt_hid_out(hid);\n\n }\n\n\n\n return;\n\nbad:\n\n fprintf(stderr, \"%s: bad transaction on Interrupt channel.\\n\",\n\n __func__);\n\n}\n", + "output": "0", + "index": 10302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tta_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n TTAContext *c = s->priv_data;\n\n AVStream *st = s->streams[0];\n\n int size, ret;\n\n\n\n // FIXME!\n\n if (c->currentframe > c->totalframes)\n\n return -1;\n\n\n\n size = st->index_entries[c->currentframe].size;\n\n\n\n ret = av_get_packet(s->pb, pkt, size);\n\n pkt->dts = st->index_entries[c->currentframe++].timestamp;\n\n return ret;\n\n}\n", + "output": "1", + "index": 20655 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){\n\n int i;\n\n for(i=16; i<16+8; i++){\n\n if(nnzc[ scan8[i] ])\n\n ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);\n\n else if(block[i*16])\n\n ff_h264_idct_dc_add_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);\n\n }\n\n}\n", + "output": "0", + "index": 1270 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int flac_probe(AVProbeData *p)\n\n{\n\n uint8_t *bufptr = p->buf;\n\n uint8_t *end = p->buf + p->buf_size;\n\n\n\n if(bufptr > end-4 || memcmp(bufptr, \"fLaC\", 4)) return 0;\n\n else return AVPROBE_SCORE_MAX/2;\n\n}\n", + "output": "1", + "index": 931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void thread_pool_submit(ThreadPoolFunc *func, void *arg)\n\n{\n\n thread_pool_submit_aio(func, arg, NULL, NULL);\n\n}\n", + "output": "0", + "index": 501 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)\n\n{\n\n NvmeNamespace *ns;\n\n uint32_t nsid = le32_to_cpu(cmd->nsid);\n\n\n\n if (nsid == 0 || nsid > n->num_namespaces) {\n\n return NVME_INVALID_NSID | NVME_DNR;\n\n }\n\n\n\n ns = &n->namespaces[nsid - 1];\n\n switch (cmd->opcode) {\n\n case NVME_CMD_FLUSH:\n\n return nvme_flush(n, ns, cmd, req);\n\n case NVME_CMD_WRITE_ZEROS:\n\n return nvme_write_zeros(n, ns, cmd, req);\n\n case NVME_CMD_WRITE:\n\n case NVME_CMD_READ:\n\n return nvme_rw(n, ns, cmd, req);\n\n default:\n\n return NVME_INVALID_OPCODE | NVME_DNR;\n\n }\n\n}\n", + "output": "1", + "index": 21296 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(unterminated_string)\n\n{\n\n QObject *obj = qobject_from_json(\"\\\"abc\");\n\n fail_unless(obj == NULL);\n\n}\n", + "output": "0", + "index": 7872 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int decode_end(AVCodecContext *avctx)\n\n{\n\n ALSDecContext *ctx = avctx->priv_data;\n\n\n\n av_freep(&ctx->sconf.chan_pos);\n\n\n\n ff_bgmc_end(&ctx->bgmc_lut, &ctx->bgmc_lut_status);\n\n\n\n av_freep(&ctx->const_block);\n\n av_freep(&ctx->shift_lsbs);\n\n av_freep(&ctx->opt_order);\n\n av_freep(&ctx->store_prev_samples);\n\n av_freep(&ctx->use_ltp);\n\n av_freep(&ctx->ltp_lag);\n\n av_freep(&ctx->ltp_gain);\n\n av_freep(&ctx->ltp_gain_buffer);\n\n av_freep(&ctx->quant_cof);\n\n av_freep(&ctx->lpc_cof);\n\n av_freep(&ctx->quant_cof_buffer);\n\n av_freep(&ctx->lpc_cof_buffer);\n\n av_freep(&ctx->lpc_cof_reversed_buffer);\n\n av_freep(&ctx->prev_raw_samples);\n\n av_freep(&ctx->raw_samples);\n\n av_freep(&ctx->raw_buffer);\n\n av_freep(&ctx->chan_data);\n\n av_freep(&ctx->chan_data_buffer);\n\n av_freep(&ctx->reverted_channels);\n\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 19832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rearm_sensor_evts(IPMIBmcSim *ibs,\n\n uint8_t *cmd, unsigned int cmd_len,\n\n uint8_t *rsp, unsigned int *rsp_len,\n\n unsigned int max_rsp_len)\n\n{\n\n IPMISensor *sens;\n\n\n\n IPMI_CHECK_CMD_LEN(4);\n\n if ((cmd[2] >= MAX_SENSORS) ||\n\n !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {\n\n rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;\n\n return;\n\n }\n\n sens = ibs->sensors + cmd[2];\n\n\n\n if ((cmd[3] & 0x80) == 0) {\n\n /* Just clear everything */\n\n sens->states = 0;\n\n return;\n\n }\n\n}\n", + "output": "1", + "index": 9910 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ioapic_common_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->realize = ioapic_common_realize;\n\n dc->vmsd = &vmstate_ioapic_common;\n\n dc->no_user = 1;\n\n}\n", + "output": "1", + "index": 2340 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline int isnormal (float64 d)\n\n{\n\n CPU_DoubleU u;\n\n\n\n u.d = d;\n\n\n\n uint32_t exp = (u.ll >> 52) & 0x7FF;\n\n return ((0 < exp) && (exp < 0x7FF));\n\n}\n", + "output": "0", + "index": 14278 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avcodec_open(AVCodecContext *avctx, AVCodec *codec)\n\n{\n\n int ret;\n\n\n\n if(avctx->codec)\n\n return -1;\n\n\n\n avctx->codec = codec;\n\n avctx->codec_id = codec->id;\n\n avctx->frame_number = 0;\n\n if (codec->priv_data_size > 0) {\n\n avctx->priv_data = av_mallocz(codec->priv_data_size);\n\n if (!avctx->priv_data) \n\n return -ENOMEM;\n\n } else {\n\n avctx->priv_data = NULL;\n\n }\n\n\n\n if(avctx->coded_width && avctx->coded_height)\n\n avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);\n\n else if(avctx->width && avctx->height)\n\n avcodec_set_dimensions(avctx, avctx->width, avctx->height);\n\n\n\n if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height)){\n\n av_freep(&avctx->priv_data);\n\n return -1;\n\n }\n\n\n\n ret = avctx->codec->init(avctx);\n\n if (ret < 0) {\n\n av_freep(&avctx->priv_data);\n\n return ret;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 26168 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtsp_read_header(AVFormatContext *s,\n\n AVFormatParameters *ap)\n\n{\n\n RTSPState *rt = s->priv_data;\n\n int ret;\n\n\n\n ret = ff_rtsp_connect(s);\n\n if (ret)\n\n return ret;\n\n\n\n rt->real_setup_cache = av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));\n\n if (!rt->real_setup_cache)\n\n return AVERROR(ENOMEM);\n\n rt->real_setup = rt->real_setup_cache + s->nb_streams * sizeof(*rt->real_setup);\n\n\n\n if (ap->initial_pause) {\n\n /* do not start immediately */\n\n } else {\n\n if (rtsp_read_play(s) < 0) {\n\n ff_rtsp_close_streams(s);\n\n ff_rtsp_close_connections(s);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18550 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tpm_tis_initfn(Object *obj)\n\n{\n\n ISADevice *dev = ISA_DEVICE(obj);\n\n TPMState *s = TPM(obj);\n\n\n\n memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops,\n\n s, \"tpm-tis-mmio\",\n\n TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);\n\n memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE,\n\n &s->mmio);\n\n}\n", + "output": "1", + "index": 434 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,\n\n const uint8_t *src, int src_size)\n\n{\n\n int h, w;\n\n uint8_t *Y1, *Y2, *U, *V;\n\n int ret;\n\n\n\n if (src_size < avctx->width * avctx->height * 3LL / 2) {\n\n av_log(avctx, AV_LOG_ERROR, \"packet too small\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n avctx->pix_fmt = AV_PIX_FMT_YUV420P;\n\n if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)\n\n return ret;\n\n\n\n Y1 = pic->data[0];\n\n Y2 = pic->data[0] + pic->linesize[0];\n\n U = pic->data[1];\n\n V = pic->data[2];\n\n for (h = 0; h < avctx->height; h += 2) {\n\n for (w = 0; w < avctx->width; w += 2) {\n\n AV_COPY16(Y1 + w, src);\n\n AV_COPY16(Y2 + w, src + 2);\n\n U[w >> 1] = src[4] + 0x80;\n\n V[w >> 1] = src[5] + 0x80;\n\n src += 6;\n\n }\n\n Y1 += pic->linesize[0] << 1;\n\n Y2 += pic->linesize[0] << 1;\n\n U += pic->linesize[1];\n\n V += pic->linesize[2];\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4590 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool write_header(FILE *fp)\n\n{\n\n static const TraceRecord header = {\n\n .event = HEADER_EVENT_ID,\n\n .timestamp_ns = HEADER_MAGIC,\n\n .x1 = HEADER_VERSION,\n\n };\n\n\n\n return fwrite(&header, sizeof header, 1, fp) == 1;\n\n}\n", + "output": "1", + "index": 9473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong h_bulk_remove(PowerPCCPU *cpu, sPAPRMachineState *spapr,\n\n target_ulong opcode, target_ulong *args)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n int i;\n\n target_ulong rc = H_SUCCESS;\n\n\n\n for (i = 0; i < H_BULK_REMOVE_MAX_BATCH; i++) {\n\n target_ulong *tsh = &args[i*2];\n\n target_ulong tsl = args[i*2 + 1];\n\n target_ulong v, r, ret;\n\n\n\n if ((*tsh & H_BULK_REMOVE_TYPE) == H_BULK_REMOVE_END) {\n\n break;\n\n } else if ((*tsh & H_BULK_REMOVE_TYPE) != H_BULK_REMOVE_REQUEST) {\n\n return H_PARAMETER;\n\n }\n\n\n\n *tsh &= H_BULK_REMOVE_PTEX | H_BULK_REMOVE_FLAGS;\n\n *tsh |= H_BULK_REMOVE_RESPONSE;\n\n\n\n if ((*tsh & H_BULK_REMOVE_ANDCOND) && (*tsh & H_BULK_REMOVE_AVPN)) {\n\n *tsh |= H_BULK_REMOVE_PARM;\n\n return H_PARAMETER;\n\n }\n\n\n\n ret = remove_hpte(cpu, *tsh & H_BULK_REMOVE_PTEX, tsl,\n\n (*tsh & H_BULK_REMOVE_FLAGS) >> 26,\n\n &v, &r);\n\n\n\n *tsh |= ret << 60;\n\n\n\n switch (ret) {\n\n case REMOVE_SUCCESS:\n\n *tsh |= (r & (HPTE64_R_C | HPTE64_R_R)) << 43;\n\n break;\n\n\n\n case REMOVE_PARM:\n\n rc = H_PARAMETER;\n\n goto exit;\n\n\n\n case REMOVE_HW:\n\n rc = H_HARDWARE;\n\n goto exit;\n\n }\n\n }\n\n exit:\n\n check_tlb_flush(env);\n\n\n\n return rc;\n\n}\n", + "output": "1", + "index": 16939 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_lock(void *opaque)\n\n{\n\n int8_t status;\n\n V9fsFlock *flock;\n\n size_t offset = 7;\n\n struct stat stbuf;\n\n V9fsFidState *fidp;\n\n int32_t fid, err = 0;\n\n V9fsPDU *pdu = opaque;\n\n V9fsState *s = pdu->s;\n\n\n\n flock = g_malloc(sizeof(*flock));\n\n pdu_unmarshal(pdu, offset, \"dbdqqds\", &fid, &flock->type,\n\n &flock->flags, &flock->start, &flock->length,\n\n &flock->proc_id, &flock->client_id);\n\n\n\n trace_v9fs_lock(pdu->tag, pdu->id, fid,\n\n flock->type, flock->start, flock->length);\n\n\n\n status = P9_LOCK_ERROR;\n\n\n\n /* We support only block flag now (that too ignored currently) */\n\n if (flock->flags & ~P9_LOCK_FLAGS_BLOCK) {\n\n err = -EINVAL;\n\n goto out_nofid;\n\n }\n\n fidp = get_fid(pdu, fid);\n\n if (fidp == NULL) {\n\n err = -ENOENT;\n\n goto out_nofid;\n\n }\n\n err = v9fs_co_fstat(pdu, fidp, &stbuf);\n\n if (err < 0) {\n\n goto out;\n\n }\n\n status = P9_LOCK_SUCCESS;\n\nout:\n\n put_fid(pdu, fidp);\n\nout_nofid:\n\n err = offset;\n\n err += pdu_marshal(pdu, offset, \"b\", status);\n\n trace_v9fs_lock_return(pdu->tag, pdu->id, status);\n\n complete_pdu(s, pdu, err);\n\n v9fs_string_free(&flock->client_id);\n\n g_free(flock);\n\n}\n", + "output": "0", + "index": 16321 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qxl_reset_surfaces(PCIQXLDevice *d)\n\n{\n\n dprint(d, 1, \"%s:\\n\", __FUNCTION__);\n\n d->mode = QXL_MODE_UNDEFINED;\n\n qemu_mutex_unlock_iothread();\n\n d->ssd.worker->destroy_surfaces(d->ssd.worker);\n\n qemu_mutex_lock_iothread();\n\n memset(&d->guest_surfaces.cmds, 0, sizeof(d->guest_surfaces.cmds));\n\n}\n", + "output": "1", + "index": 27290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,\n\n uint8_t *p)\n\n{\n\n int pages = -1;\n\n\n\n if (is_zero_range(p, TARGET_PAGE_SIZE)) {\n\n rs->zero_pages++;\n\n rs->bytes_transferred +=\n\n save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS);\n\n qemu_put_byte(rs->f, 0);\n\n rs->bytes_transferred += 1;\n\n pages = 1;\n\n }\n\n\n\n return pages;\n\n}\n", + "output": "1", + "index": 4817 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)\n\n{\n\n int ret;\n\n int64_t wait_start = 0;\n\n\n\n while (1) {\n\n ret = ff_network_wait_fd(fd, write);\n\n if (ret != AVERROR(EAGAIN))\n\n return ret;\n\n if (ff_check_interrupt(int_cb))\n\n return AVERROR_EXIT;\n\n if (timeout > 0) {\n\n if (!wait_start)\n\n wait_start = av_gettime();\n\n else if (av_gettime() - wait_start > timeout)\n\n return AVERROR(ETIMEDOUT);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 8533 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_addl_ESP_im(int32_t val)\n\n{\n\n tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[R_ESP]));\n\n tcg_gen_addi_tl(cpu_tmp0, cpu_tmp0, val);\n\n#ifdef TARGET_X86_64\n\n tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xffffffff);\n\n#endif\n\n tcg_gen_st_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[R_ESP]));\n\n}\n", + "output": "0", + "index": 22545 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_uncompressed_sgi(unsigned char* out_buf, SgiState *s)\n\n{\n\n int x, y, z;\n\n unsigned int offset = s->height * s->width * s->bytes_per_channel;\n\n GetByteContext gp[4];\n\n uint8_t *out_end;\n\n\n\n /* Test buffer size. */\n\n if (offset * s->depth > bytestream2_get_bytes_left(&s->g))\n\n return AVERROR_INVALIDDATA;\n\n\n\n /* Create a reader for each plane */\n\n for (z = 0; z < s->depth; z++) {\n\n gp[z] = s->g;\n\n bytestream2_skip(&gp[z], z * offset);\n\n }\n\n\n\n for (y = s->height - 1; y >= 0; y--) {\n\n out_end = out_buf + (y * s->linesize);\n\n if (s->bytes_per_channel == 1) {\n\n for (x = s->width; x > 0; x--) {\n\n bytestream2_get_bufferu(&gp[z], out_end, s->depth);\n\n out_end += s->depth;\n\n }\n\n } else {\n\n uint16_t *out16 = (uint16_t *)out_end;\n\n for (x = s->width; x > 0; x--)\n\n for (z = 0; z < s->depth; z++)\n\n *out16++ = bytestream2_get_ne16u(&gp[z]);\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 8152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n\n\n if (drv && drv->bdrv_ioctl)\n\n return drv->bdrv_ioctl(bs, req, buf);\n\n return -ENOTSUP;\n\n}\n", + "output": "0", + "index": 27303 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void channel_load_g(struct fs_dma_ctrl *ctrl, int c)\n\n{\n\n\ttarget_phys_addr_t addr = channel_reg(ctrl, c, RW_GROUP);\n\n\n\n\t/* Load and decode. FIXME: handle endianness. */\n\n\tcpu_physical_memory_read (addr, \n\n\t\t\t\t (void *) &ctrl->channels[c].current_g, \n\n\t\t\t\t sizeof ctrl->channels[c].current_g);\n\n}\n", + "output": "0", + "index": 22753 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_fsqrtq(CPUSPARCState *env)\n\n{\n\n clear_float_exceptions(env);\n\n QT0 = float128_sqrt(QT1, &env->fp_status);\n\n check_ieee_exceptions(env);\n\n}\n", + "output": "0", + "index": 26460 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_null(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n Visitor *v;\n\n Error *err = NULL;\n\n char *tmp;\n\n\n\n /*\n\n * FIXME: Since QAPI doesn't know the 'null' type yet, we can't\n\n * test visit_type_null() by reading into a QAPI struct then\n\n * checking that it was populated correctly. The best we can do\n\n * for now is ensure that we consumed null from the input, proven\n\n * by the fact that we can't re-read the key; and that we detect\n\n * when input is not null.\n\n */\n\n\n\n v = visitor_input_test_init(data, \"{ 'a': null, 'b': '' }\");\n\n visit_start_struct(v, NULL, NULL, 0, &error_abort);\n\n visit_type_null(v, \"a\", &error_abort);\n\n visit_type_str(v, \"a\", &tmp, &err);\n\n g_assert(!tmp);\n\n error_free_or_abort(&err);\n\n visit_type_null(v, \"b\", &err);\n\n error_free_or_abort(&err);\n\n visit_check_struct(v, &error_abort);\n\n visit_end_struct(v, NULL);\n\n}\n", + "output": "0", + "index": 5246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tftp_session_allocate(Slirp *slirp, struct sockaddr_storage *srcsas,\n\n struct tftp_t *tp)\n\n{\n\n struct tftp_session *spt;\n\n int k;\n\n\n\n for (k = 0; k < TFTP_SESSIONS_MAX; k++) {\n\n spt = &slirp->tftp_sessions[k];\n\n\n\n if (!tftp_session_in_use(spt))\n\n goto found;\n\n\n\n /* sessions time out after 5 inactive seconds */\n\n if ((int)(curtime - spt->timestamp) > 5000) {\n\n tftp_session_terminate(spt);\n\n goto found;\n\n }\n\n }\n\n\n\n return -1;\n\n\n\n found:\n\n memset(spt, 0, sizeof(*spt));\n\n spt->client_addr = *srcsas;\n\n spt->fd = -1;\n\n spt->block_size = 512;\n\n spt->client_port = tp->udp.uh_sport;\n\n spt->slirp = slirp;\n\n\n\n tftp_session_update(spt);\n\n\n\n return k;\n\n}\n", + "output": "1", + "index": 25785 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_event_facility(Object *obj)\n\n{\n\n SCLPEventFacility *event_facility = EVENT_FACILITY(obj);\n\n DeviceState *sdev = DEVICE(obj);\n\n\n\n /* Spawn a new bus for SCLP events */\n\n qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus),\n\n TYPE_SCLP_EVENTS_BUS, sdev, NULL);\n\n\n\n object_initialize(&event_facility->quiesce_event, sizeof(SCLPEvent),\n\n TYPE_SCLP_QUIESCE);\n\n qdev_set_parent_bus(DEVICE(&event_facility->quiesce_event),\n\n &event_facility->sbus.qbus);\n\n object_initialize(&event_facility->cpu_hotplug_event, sizeof(SCLPEvent),\n\n TYPE_SCLP_CPU_HOTPLUG);\n\n qdev_set_parent_bus(DEVICE(&event_facility->cpu_hotplug_event),\n\n &event_facility->sbus.qbus);\n\n /* the facility will automatically realize the devices via the bus */\n\n}\n", + "output": "0", + "index": 26955 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CPUState *ppc4xx_init (const char *cpu_model,\n\n clk_setup_t *cpu_clk, clk_setup_t *tb_clk,\n\n uint32_t sysclk)\n\n{\n\n CPUState *env;\n\n\n\n /* init CPUs */\n\n env = cpu_init(cpu_model);\n\n if (!env) {\n\n fprintf(stderr, \"Unable to find PowerPC %s CPU definition\\n\",\n\n cpu_model);\n\n exit(1);\n\n }\n\n cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */\n\n cpu_clk->opaque = env;\n\n /* Set time-base frequency to sysclk */\n\n tb_clk->cb = ppc_emb_timers_init(env, sysclk);\n\n tb_clk->opaque = env;\n\n ppc_dcr_init(env, NULL, NULL);\n\n /* Register qemu callbacks */\n\n qemu_register_reset((QEMUResetHandler*)&cpu_reset, env);\n\n\n\n return env;\n\n}\n", + "output": "0", + "index": 7836 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_chmod(FsContext *ctx, const char *path, mode_t mode)\n\n{\n\n return chmod(rpath(ctx, path), mode);\n\n}\n", + "output": "0", + "index": 20564 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame,\n\n int perms)\n\n{\n\n AVFilterBufferRef *picref =\n\n avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize, perms,\n\n frame->width, frame->height,\n\n frame->format);\n\n if (!picref)\n\n return NULL;\n\n avfilter_copy_frame_props(picref, frame);\n\n return picref;\n\n}\n", + "output": "0", + "index": 7659 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cmd646_cmd_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t data, unsigned size)\n\n{\n\n CMD646BAR *cmd646bar = opaque;\n\n\n\n if (addr != 2 || size != 1) {\n\n return;\n\n }\n\n ide_cmd_write(cmd646bar->bus, addr + 2, data);\n\n}\n", + "output": "0", + "index": 19563 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_put_device(VFIOPCIDevice *vdev)\n\n{\n\n QLIST_REMOVE(vdev, next);\n\n vdev->vbasedev.group = NULL;\n\n trace_vfio_put_device(vdev->vbasedev.fd);\n\n close(vdev->vbasedev.fd);\n\n g_free(vdev->vbasedev.name);\n\n if (vdev->msix) {\n\n g_free(vdev->msix);\n\n vdev->msix = NULL;\n\n }\n\n}\n", + "output": "0", + "index": 10574 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static float *put_vector(vorbis_enc_codebook *book, PutBitContext *pb,\n\n float *num)\n\n{\n\n int i, entry = -1;\n\n float distance = FLT_MAX;\n\n assert(book->dimentions);\n\n for (i = 0; i < book->nentries; i++) {\n\n float * vec = book->dimentions + i * book->ndimentions, d = book->pow2[i];\n\n int j;\n\n if (!book->lens[i])\n\n continue;\n\n for (j = 0; j < book->ndimentions; j++)\n\n d -= vec[j] * num[j];\n\n if (distance > d) {\n\n entry = i;\n\n distance = d;\n\n }\n\n }\n\n put_codeword(pb, book, entry);\n\n return &book->dimentions[entry * book->ndimentions];\n\n}\n", + "output": "1", + "index": 19399 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_block_dirty_bitmap_add(const char *node, const char *name,\n\n bool has_granularity, uint32_t granularity,\n\n Error **errp)\n\n{\n\n AioContext *aio_context;\n\n BlockDriverState *bs;\n\n\n\n if (!name || name[0] == '\\0') {\n\n error_setg(errp, \"Bitmap name cannot be empty\");\n\n return;\n\n }\n\n\n\n bs = bdrv_lookup_bs(node, node, errp);\n\n if (!bs) {\n\n return;\n\n }\n\n\n\n aio_context = bdrv_get_aio_context(bs);\n\n aio_context_acquire(aio_context);\n\n\n\n if (has_granularity) {\n\n if (granularity < 512 || !is_power_of_2(granularity)) {\n\n error_setg(errp, \"Granularity must be power of 2 \"\n\n \"and at least 512\");\n\n goto out;\n\n }\n\n } else {\n\n /* Default to cluster size, if available: */\n\n granularity = bdrv_get_default_bitmap_granularity(bs);\n\n }\n\n\n\n bdrv_create_dirty_bitmap(bs, granularity, name, errp);\n\n\n\n out:\n\n aio_context_release(aio_context);\n\n}\n", + "output": "0", + "index": 13052 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void scsi_req_cancel(SCSIRequest *req)\n\n{\n\n trace_scsi_req_cancel(req->dev->id, req->lun, req->tag);\n\n if (!req->enqueued) {\n\n return;\n\n }\n\n\n\n scsi_req_ref(req);\n\n scsi_req_dequeue(req);\n\n req->io_canceled = true;\n\n if (req->aiocb) {\n\n blk_aio_cancel(req->aiocb);\n\n } else {\n\n scsi_req_cancel_complete(req);\n\n }\n\n}", + "output": "1", + "index": 11988 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void io_region_del(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n isa_unassign_ioport(section->offset_within_address_space,\n\n int128_get64(section->size));\n\n}\n", + "output": "0", + "index": 20107 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg G_GNUC_UNUSED)\n\n{\n\n return false;\n\n}\n", + "output": "0", + "index": 7486 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,\n\n GIOFunc func, void *user_data)\n\n{\n\n GSource *src;\n\n guint tag;\n\n\n\n if (s->chr_add_watch == NULL) {\n\n return -ENOSYS;\n\n }\n\n\n\n src = s->chr_add_watch(s, cond);\n\n if (!src) {\n\n return -EINVAL;\n\n }\n\n\n\n g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);\n\n tag = g_source_attach(src, NULL);\n\n g_source_unref(src);\n\n\n\n return tag;\n\n}\n", + "output": "0", + "index": 24600 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int enable_write_target(BDRVVVFATState *s, Error **errp)\n\n{\n\n BlockDriver *bdrv_qcow = NULL;\n\n QemuOpts *opts = NULL;\n\n int ret;\n\n int size = sector2cluster(s, s->sector_count);\n\n s->used_clusters = calloc(size, 1);\n\n\n\n array_init(&(s->commits), sizeof(commit_t));\n\n\n\n s->qcow_filename = g_malloc(1024);\n\n ret = get_tmp_filename(s->qcow_filename, 1024);\n\n if (ret < 0) {\n\n error_setg_errno(errp, -ret, \"can't create temporary file\");\n\n goto err;\n\n }\n\n\n\n bdrv_qcow = bdrv_find_format(\"qcow\");\n\n if (!bdrv_qcow) {\n\n error_setg(errp, \"Failed to locate qcow driver\");\n\n ret = -ENOENT;\n\n goto err;\n\n }\n\n\n\n opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort);\n\n qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512);\n\n qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, \"fat:\");\n\n\n\n ret = bdrv_create(bdrv_qcow, s->qcow_filename, opts, errp);\n\n qemu_opts_del(opts);\n\n if (ret < 0) {\n\n goto err;\n\n }\n\n\n\n s->qcow = NULL;\n\n ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL,\n\n BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,\n\n bdrv_qcow, errp);\n\n if (ret < 0) {\n\n goto err;\n\n }\n\n\n\n#ifndef _WIN32\n\n unlink(s->qcow_filename);\n\n#endif\n\n\n\n bdrv_set_backing_hd(s->bs, bdrv_new());\n\n s->bs->backing_hd->drv = &vvfat_write_target;\n\n s->bs->backing_hd->opaque = g_new(void *, 1);\n\n *(void**)s->bs->backing_hd->opaque = s;\n\n\n\n return 0;\n\n\n\nerr:\n\n g_free(s->qcow_filename);\n\n s->qcow_filename = NULL;\n\n return ret;\n\n}\n", + "output": "0", + "index": 6616 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,\n size_t size)\n{\n int64_t len;\n if (!bdrv_is_inserted(bs))\n return -ENOMEDIUM;\n if (bs->growable)\n return 0;\n len = bdrv_getlength(bs);\n if (offset < 0)\n if ((offset > len) || (len - offset < size))\n return 0;", + "output": "1", + "index": 21907 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){\n\n RMDemuxContext *rm = s->priv_data;\n\n ByteIOContext *pb = s->pb;\n\n int len, num, res, i;\n\n AVStream *st;\n\n uint32_t state=0xFFFFFFFF;\n\n\n\n while(!url_feof(pb)){\n\n *pos= url_ftell(pb) - 3;\n\n if(rm->remaining_len > 0){\n\n num= rm->current_stream;\n\n len= rm->remaining_len;\n\n *timestamp = AV_NOPTS_VALUE;\n\n *flags= 0;\n\n }else{\n\n state= (state<<8) + get_byte(pb);\n\n\n\n if(state == MKBETAG('I', 'N', 'D', 'X')){\n\n len = get_be16(pb) - 6;\n\n if(len<0)\n\n continue;\n\n goto skip;\n\n }\n\n\n\n if(state > (unsigned)0xFFFF || state < 12)\n\n continue;\n\n len=state;\n\n state= 0xFFFFFFFF;\n\n\n\n num = get_be16(pb);\n\n *timestamp = get_be32(pb);\n\n res= get_byte(pb); /* reserved */\n\n *flags = get_byte(pb); /* flags */\n\n\n\n\n\n len -= 12;\n\n }\n\n for(i=0;inb_streams;i++) {\n\n st = s->streams[i];\n\n if (num == st->id)\n\n break;\n\n }\n\n if (i == s->nb_streams) {\n\nskip:\n\n /* skip packet if unknown number */\n\n url_fskip(pb, len);\n\n rm->remaining_len -= len;\n\n continue;\n\n }\n\n *stream_index= i;\n\n\n\n return len;\n\n }\n\n return -1;\n\n}\n", + "output": "1", + "index": 6965 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dnxhd_decode_dct_block_8(const DNXHDContext *ctx,\n\n RowContext *row, int n)\n\n{\n\n dnxhd_decode_dct_block(ctx, row, n, 4, 32, 6);\n\n}\n", + "output": "1", + "index": 26302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo,\n\n USBPacket *p)\n\n{\n\n int len;\n\n\n\n if (likely(!fifo->len))\n\n return USB_RET_STALL;\n\n\n\n len = MIN(p->len, fifo->fifo[fifo->start].len);\n\n memcpy(p->data, fifo->fifo[fifo->start].data, len);\n\n if (len == p->len) {\n\n fifo->fifo[fifo->start].len -= len;\n\n fifo->fifo[fifo->start].data += len;\n\n } else {\n\n fifo->start ++;\n\n fifo->start &= CFIFO_LEN_MASK;\n\n fifo->len --;\n\n }\n\n\n\n fifo->dstart += len;\n\n fifo->dlen -= len;\n\n if (fifo->dstart >= fifo->dsize) {\n\n fifo->dstart = 0;\n\n fifo->dsize = DFIFO_LEN_MASK + 1;\n\n }\n\n\n\n return len;\n\n}\n", + "output": "1", + "index": 144 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_watchpoint(int offset, int len_mask, int flags)\n\n{\n\n CPUArchState *env = cpu_single_env;\n\n target_ulong pc, cs_base;\n\n TranslationBlock *tb;\n\n target_ulong vaddr;\n\n CPUWatchpoint *wp;\n\n int cpu_flags;\n\n\n\n if (env->watchpoint_hit) {\n\n /* We re-entered the check after replacing the TB. Now raise\n\n * the debug interrupt so that is will trigger after the\n\n * current instruction. */\n\n cpu_interrupt(env, CPU_INTERRUPT_DEBUG);\n\n return;\n\n }\n\n vaddr = (env->mem_io_vaddr & TARGET_PAGE_MASK) + offset;\n\n QTAILQ_FOREACH(wp, &env->watchpoints, entry) {\n\n if ((vaddr == (wp->vaddr & len_mask) ||\n\n (vaddr & wp->len_mask) == wp->vaddr) && (wp->flags & flags)) {\n\n wp->flags |= BP_WATCHPOINT_HIT;\n\n if (!env->watchpoint_hit) {\n\n env->watchpoint_hit = wp;\n\n tb = tb_find_pc(env->mem_io_pc);\n\n if (!tb) {\n\n cpu_abort(env, \"check_watchpoint: could not find TB for \"\n\n \"pc=%p\", (void *)env->mem_io_pc);\n\n }\n\n cpu_restore_state(tb, env, env->mem_io_pc);\n\n tb_phys_invalidate(tb, -1);\n\n if (wp->flags & BP_STOP_BEFORE_ACCESS) {\n\n env->exception_index = EXCP_DEBUG;\n\n cpu_loop_exit(env);\n\n } else {\n\n cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);\n\n tb_gen_code(env, pc, cs_base, cpu_flags, 1);\n\n cpu_resume_from_signal(env, NULL);\n\n }\n\n }\n\n } else {\n\n wp->flags &= ~BP_WATCHPOINT_HIT;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 12298 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_clkdsp_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;\n\n uint16_t diff;\n\n\n\n if (size != 2) {\n\n return omap_badwidth_write16(opaque, addr, value);\n\n }\n\n\n\n switch (addr) {\n\n case 0x04:\t/* DSP_IDLECT1 */\n\n diff = s->clkm.dsp_idlect1 ^ value;\n\n s->clkm.dsp_idlect1 = value & 0x01f7;\n\n omap_clkdsp_idlect1_update(s, diff, value);\n\n break;\n\n\n\n case 0x08:\t/* DSP_IDLECT2 */\n\n s->clkm.dsp_idlect2 = value & 0x0037;\n\n diff = s->clkm.dsp_idlect1 ^ value;\n\n omap_clkdsp_idlect2_update(s, diff, value);\n\n break;\n\n\n\n case 0x14:\t/* DSP_RSTCT2 */\n\n s->clkm.dsp_rstct2 = value & 0x0001;\n\n break;\n\n\n\n case 0x18:\t/* DSP_SYSST */\n\n s->clkm.cold_start &= value & 0x3f;\n\n break;\n\n\n\n default:\n\n OMAP_BAD_REG(addr);\n\n }\n\n}\n", + "output": "0", + "index": 18249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int print_block_option_help(const char *filename, const char *fmt)\n\n{\n\n BlockDriver *drv, *proto_drv;\n\n QEMUOptionParameter *create_options = NULL;\n\n\n\n /* Find driver and parse its options */\n\n drv = bdrv_find_format(fmt);\n\n if (!drv) {\n\n error_report(\"Unknown file format '%s'\", fmt);\n\n return 1;\n\n }\n\n\n\n create_options = append_option_parameters(create_options,\n\n drv->create_options);\n\n\n\n if (filename) {\n\n proto_drv = bdrv_find_protocol(filename, true);\n\n if (!proto_drv) {\n\n error_report(\"Unknown protocol '%s'\", filename);\n\n\n return 1;\n\n }\n\n create_options = append_option_parameters(create_options,\n\n proto_drv->create_options);\n\n }\n\n\n\n print_option_help(create_options);\n\n\n return 0;\n\n}", + "output": "1", + "index": 1649 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_gluster_create(const char *filename,\n\n QEMUOptionParameter *options, Error **errp)\n\n{\n\n struct glfs *glfs;\n\n struct glfs_fd *fd;\n\n int ret = 0;\n\n int prealloc = 0;\n\n int64_t total_size = 0;\n\n GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));\n\n\n\n glfs = qemu_gluster_init(gconf, filename, errp);\n\n if (!glfs) {\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n\n\n while (options && options->name) {\n\n if (!strcmp(options->name, BLOCK_OPT_SIZE)) {\n\n total_size = options->value.n / BDRV_SECTOR_SIZE;\n\n } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) {\n\n if (!options->value.s || !strcmp(options->value.s, \"off\")) {\n\n prealloc = 0;\n\n } else if (!strcmp(options->value.s, \"full\") &&\n\n gluster_supports_zerofill()) {\n\n prealloc = 1;\n\n } else {\n\n error_setg(errp, \"Invalid preallocation mode: '%s'\"\n\n \" or GlusterFS doesn't support zerofill API\",\n\n options->value.s);\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n }\n\n options++;\n\n }\n\n\n\n fd = glfs_creat(glfs, gconf->image,\n\n O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);\n\n if (!fd) {\n\n ret = -errno;\n\n } else {\n\n if (!glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE)) {\n\n if (prealloc && qemu_gluster_zerofill(fd, 0,\n\n total_size * BDRV_SECTOR_SIZE)) {\n\n ret = -errno;\n\n }\n\n } else {\n\n ret = -errno;\n\n }\n\n\n\n if (glfs_close(fd) != 0) {\n\n ret = -errno;\n\n }\n\n }\n\nout:\n\n qemu_gluster_gconf_free(gconf);\n\n if (glfs) {\n\n glfs_fini(glfs);\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 15126 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void softusb_read_pmem(MilkymistSoftUsbState *s,\n\n uint32_t offset, uint8_t *buf, uint32_t len)\n\n{\n\n if (offset + len >= s->pmem_size) {\n\n error_report(\"milkymist_softusb: read pmem out of bounds \"\n\n \"at offset 0x%x, len %d\", offset, len);\n\n\n return;\n\n }\n\n\n\n memcpy(buf, s->pmem_ptr + offset, len);\n\n}", + "output": "1", + "index": 25946 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline int sbr_hf_apply_noise(int (*Y)[2],\n\n const SoftFloat *s_m,\n\n const SoftFloat *q_filt,\n\n int noise,\n\n int phi_sign0,\n\n int phi_sign1,\n\n int m_max)\n\n{\n\n int m;\n\n\n\n for (m = 0; m < m_max; m++) {\n\n int y0 = Y[m][0];\n\n int y1 = Y[m][1];\n\n noise = (noise + 1) & 0x1ff;\n\n if (s_m[m].mant) {\n\n int shift, round;\n\n\n\n shift = 22 - s_m[m].exp;\n\n if (shift < 1) {\n\n av_log(NULL, AV_LOG_ERROR, \"Overflow in sbr_hf_apply_noise, shift=%d\\n\", shift);\n\n return AVERROR(ERANGE);\n\n } else if (shift < 30) {\n\n round = 1 << (shift-1);\n\n y0 += (s_m[m].mant * phi_sign0 + round) >> shift;\n\n y1 += (s_m[m].mant * phi_sign1 + round) >> shift;\n\n }\n\n } else {\n\n int shift, round, tmp;\n\n int64_t accu;\n\n\n\n shift = 22 - q_filt[m].exp;\n\n if (shift < 1) {\n\n av_log(NULL, AV_LOG_ERROR, \"Overflow in sbr_hf_apply_noise, shift=%d\\n\", shift);\n\n return AVERROR(ERANGE);\n\n } else if (shift < 30) {\n\n round = 1 << (shift-1);\n\n\n\n accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][0];\n\n tmp = (int)((accu + 0x40000000) >> 31);\n\n y0 += (tmp + round) >> shift;\n\n\n\n accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][1];\n\n tmp = (int)((accu + 0x40000000) >> 31);\n\n y1 += (tmp + round) >> shift;\n\n }\n\n }\n\n Y[m][0] = y0;\n\n Y[m][1] = y1;\n\n phi_sign1 = -phi_sign1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 8779 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_nested_struct_list(gconstpointer opaque)\n\n{\n\n TestArgs *args = (TestArgs *) opaque;\n\n const SerializeOps *ops = args->ops;\n\n UserDefNestedList *listp = NULL, *tmp, *tmp_copy, *listp_copy = NULL;\n\n Error *err = NULL;\n\n void *serialize_data;\n\n int i = 0;\n\n\n\n for (i = 0; i < 8; i++) {\n\n tmp = g_malloc0(sizeof(UserDefNestedList));\n\n tmp->value = nested_struct_create();\n\n tmp->next = listp;\n\n listp = tmp;\n\n }\n\n \n\n ops->serialize(listp, &serialize_data, visit_nested_struct_list, &err);\n\n ops->deserialize((void **)&listp_copy, serialize_data,\n\n visit_nested_struct_list, &err); \n\n\n\n g_assert(err == NULL);\n\n\n\n tmp = listp;\n\n tmp_copy = listp_copy;\n\n while (listp_copy) {\n\n g_assert(listp);\n\n nested_struct_compare(listp->value, listp_copy->value);\n\n listp = listp->next;\n\n listp_copy = listp_copy->next;\n\n }\n\n\n\n qapi_free_UserDefNestedList(tmp);\n\n qapi_free_UserDefNestedList(tmp_copy);\n\n\n\n ops->cleanup(serialize_data);\n\n g_free(args);\n\n}\n", + "output": "0", + "index": 27060 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vde_from_qemu(void *opaque, const uint8_t *buf, int size)\n\n{\n\n VDEState *s = opaque;\n\n int ret;\n\n for(;;) {\n\n ret = vde_send(s->vde, (const char *)buf, size, 0);\n\n if (ret < 0 && errno == EINTR) {\n\n } else {\n\n break;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 20826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert)\n\n{\n\n sd->readonly_cb = readonly;\n\n sd->inserted_cb = insert;\n\n qemu_set_irq(readonly, bdrv_is_read_only(sd->bdrv));\n\n qemu_set_irq(insert, bdrv_is_inserted(sd->bdrv));\n\n}\n", + "output": "1", + "index": 25886 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Aml *aml_arg(int pos)\n\n{\n\n Aml *var;\n\n uint8_t op = 0x68 /* ARG0 op */ + pos;\n\n\n\n assert(pos <= 6);\n\n var = aml_opcode(op);\n\n return var;\n\n}\n", + "output": "0", + "index": 12727 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void iothread_complete(UserCreatable *obj, Error **errp)\n\n{\n\n Error *local_error = NULL;\n\n IOThread *iothread = IOTHREAD(obj);\n\n\n\n iothread->stopping = false;\n\n iothread->thread_id = -1;\n\n iothread->ctx = aio_context_new(&local_error);\n\n if (!iothread->ctx) {\n\n error_propagate(errp, local_error);\n\n return;\n\n }\n\n\n\n qemu_mutex_init(&iothread->init_done_lock);\n\n qemu_cond_init(&iothread->init_done_cond);\n\n\n\n /* This assumes we are called from a thread with useful CPU affinity for us\n\n * to inherit.\n\n */\n\n qemu_thread_create(&iothread->thread, \"iothread\", iothread_run,\n\n iothread, QEMU_THREAD_JOINABLE);\n\n\n\n /* Wait for initialization to complete */\n\n qemu_mutex_lock(&iothread->init_done_lock);\n\n while (iothread->thread_id == -1) {\n\n qemu_cond_wait(&iothread->init_done_cond,\n\n &iothread->init_done_lock);\n\n }\n\n qemu_mutex_unlock(&iothread->init_done_lock);\n\n}\n", + "output": "0", + "index": 24718 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const uint8_t *parse_opus_ts_header(const uint8_t *start, int *payload_len, int buf_len)\n\n{\n\n const uint8_t *buf = start + 1;\n\n int start_trim_flag, end_trim_flag, control_extension_flag, control_extension_length;\n\n uint8_t flags;\n\n\n\n GetByteContext gb;\n\n bytestream2_init(&gb, buf, buf_len);\n\n\n\n flags = bytestream2_get_byte(&gb);\n\n start_trim_flag = (flags >> 4) & 1;\n\n end_trim_flag = (flags >> 3) & 1;\n\n control_extension_flag = (flags >> 2) & 1;\n\n\n\n *payload_len = 0;\n\n while (bytestream2_peek_byte(&gb) == 0xff)\n\n *payload_len += bytestream2_get_byte(&gb);\n\n\n\n *payload_len += bytestream2_get_byte(&gb);\n\n\n\n if (start_trim_flag)\n\n bytestream2_skip(&gb, 2);\n\n if (end_trim_flag)\n\n bytestream2_skip(&gb, 2);\n\n if (control_extension_flag) {\n\n control_extension_length = bytestream2_get_byte(&gb);\n\n bytestream2_skip(&gb, control_extension_length);\n\n }\n\n\n\n return buf + bytestream2_tell(&gb);\n\n}\n", + "output": "1", + "index": 6414 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr,\n\n qemu_irq **irqs)\n\n{\n\n QemuOptsList *list;\n\n qemu_irq *mpic;\n\n DeviceState *dev = NULL;\n\n SysBusDevice *s;\n\n int i;\n\n\n\n mpic = g_new(qemu_irq, 256);\n\n\n\n if (kvm_enabled()) {\n\n bool irqchip_allowed = true, irqchip_required = false;\n\n\n\n list = qemu_find_opts(\"machine\");\n\n if (!QTAILQ_EMPTY(&list->head)) {\n\n irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head),\n\n \"kernel_irqchip\", true);\n\n irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head),\n\n \"kernel_irqchip\", false);\n\n }\n\n\n\n if (irqchip_allowed) {\n\n dev = ppce500_init_mpic_kvm(params, irqs);\n\n }\n\n\n\n if (irqchip_required && !dev) {\n\n fprintf(stderr, \"%s: irqchip requested but unavailable\\n\",\n\n __func__);\n\n abort();\n\n }\n\n }\n\n\n\n if (!dev) {\n\n dev = ppce500_init_mpic_qemu(params, irqs);\n\n }\n\n\n\n for (i = 0; i < 256; i++) {\n\n mpic[i] = qdev_get_gpio_in(dev, i);\n\n }\n\n\n\n s = SYS_BUS_DEVICE(dev);\n\n memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET,\n\n s->mmio[0].memory);\n\n\n\n return mpic;\n\n}\n", + "output": "1", + "index": 22234 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_write_40x_dbcr0 (void *opaque, int sprn)\n\n{\n\n DisasContext *ctx = opaque;\n\n\n\n gen_op_store_40x_dbcr0();\n\n /* We must stop translation as we may have rebooted */\n\n RET_STOP(ctx);\n\n}\n", + "output": "0", + "index": 6079 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence)\n\n{\n\n if (whence == SEEK_SET) {\n\n /* nothing to do */\n\n } else if (whence == SEEK_CUR) {\n\n pos += qemu_ftell(f);\n\n } else {\n\n /* SEEK_END not supported */\n\n return -1;\n\n }\n\n if (f->is_writable) {\n\n qemu_fflush(f);\n\n f->buf_offset = pos;\n\n } else {\n\n f->buf_offset = pos;\n\n f->buf_index = 0;\n\n f->buf_size = 0;\n\n }\n\n return pos;\n\n}\n", + "output": "0", + "index": 3654 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void isabus_bridge_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);\n\n dc->fw_name = \"isa\";\n\n\n\n\n\n\n}", + "output": "1", + "index": 1646 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int add_candidate_ref(HEVCContext *s, RefPicList *list,\n\n int poc, int ref_flag)\n\n{\n\n HEVCFrame *ref = find_ref_idx(s, poc);\n\n\n\n if (ref == s->ref)\n\n return AVERROR_INVALIDDATA;\n\n\n\n if (!ref) {\n\n ref = generate_missing_ref(s, poc);\n\n if (!ref)\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n list->list[list->nb_refs] = ref->poc;\n\n list->ref[list->nb_refs] = ref;\n\n list->nb_refs++;\n\n\n\n mark_ref(ref, ref_flag);\n\n return 0;\n\n}\n", + "output": "1", + "index": 2400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vga_common_init(VGACommonState *s, int vga_ram_size)\n\n{\n\n int i, j, v, b;\n\n\n\n for(i = 0;i < 256; i++) {\n\n v = 0;\n\n for(j = 0; j < 8; j++) {\n\n v |= ((i >> j) & 1) << (j * 4);\n\n }\n\n expand4[i] = v;\n\n\n\n v = 0;\n\n for(j = 0; j < 4; j++) {\n\n v |= ((i >> (2 * j)) & 3) << (j * 4);\n\n }\n\n expand2[i] = v;\n\n }\n\n for(i = 0; i < 16; i++) {\n\n v = 0;\n\n for(j = 0; j < 4; j++) {\n\n b = ((i >> j) & 1);\n\n v |= b << (2 * j);\n\n v |= b << (2 * j + 1);\n\n }\n\n expand4to8[i] = v;\n\n }\n\n\n\n#ifdef CONFIG_BOCHS_VBE\n\n s->is_vbe_vmstate = 1;\n\n#else\n\n s->is_vbe_vmstate = 0;\n\n#endif\n\n s->vram_offset = qemu_ram_alloc(vga_ram_size);\n\n s->vram_ptr = qemu_get_ram_ptr(s->vram_offset);\n\n s->vram_size = vga_ram_size;\n\n s->get_bpp = vga_get_bpp;\n\n s->get_offsets = vga_get_offsets;\n\n s->get_resolution = vga_get_resolution;\n\n s->update = vga_update_display;\n\n s->invalidate = vga_invalidate_display;\n\n s->screen_dump = vga_screen_dump;\n\n s->text_update = vga_update_text;\n\n switch (vga_retrace_method) {\n\n case VGA_RETRACE_DUMB:\n\n s->retrace = vga_dumb_retrace;\n\n s->update_retrace_info = vga_dumb_update_retrace_info;\n\n break;\n\n\n\n case VGA_RETRACE_PRECISE:\n\n s->retrace = vga_precise_retrace;\n\n s->update_retrace_info = vga_precise_update_retrace_info;\n\n break;\n\n }\n\n vga_reset(s);\n\n}\n", + "output": "0", + "index": 15937 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void sclp_print(const char *str)\n\n{\n\n int len = _strlen(str);\n\n WriteEventData *sccb = (void*)_sccb;\n\n\n\n sccb->h.length = sizeof(WriteEventData) + len;\n\n sccb->h.function_code = SCLP_FC_NORMAL_WRITE;\n\n sccb->ebh.length = sizeof(EventBufferHeader) + len;\n\n sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;\n\n sccb->ebh.flags = 0;\n\n _memcpy(sccb->data, str, len);\n\n\n\n sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);\n\n}\n", + "output": "0", + "index": 24991 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp, int64_t *dts)\n\n{\n\n struct ogg *ogg = ctx->priv_data;\n\n struct ogg_stream *os = ogg->streams + idx;\n\n struct theora_params *thp = os->private;\n\n uint64_t iframe = gp >> thp->gpshift;\n\n uint64_t pframe = gp & thp->gpmask;\n\n\n\n if (thp->version < 0x030201)\n\n iframe++;\n\n\n\n if(!pframe)\n\n os->pflags |= AV_PKT_FLAG_KEY;\n\n\n\n if (dts)\n\n *dts = iframe + pframe;\n\n\n\n return iframe + pframe;\n\n}\n", + "output": "1", + "index": 9606 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw,\n\n target_ulong *addr, int *flags)\n\n{\n\n /* TODO: low address protection once we flush the tlb on cr changes */\n\n *flags = PAGE_READ | PAGE_WRITE;\n\n *addr = mmu_real2abs(env, raddr);\n\n\n\n /* TODO: storage key handling */\n\n return 0;\n\n}\n", + "output": "0", + "index": 21487 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,\n\n BlockDriverState **fds)\n\n{\n\n fdctrl_t *fdctrl;\n\n\n\n fdctrl = fdctrl_init(irq, 0, 1, io_base, fds);\n\n fdctrl->sun4m = 1;\n\n\n\n return fdctrl;\n\n}\n", + "output": "0", + "index": 3318 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int put_dwords(uint32_t addr, uint32_t *buf, int num)\n\n{\n\n int i;\n\n\n\n for(i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {\n\n uint32_t tmp = cpu_to_le32(*buf);\n\n cpu_physical_memory_rw(addr,(uint8_t *)&tmp, sizeof(tmp), 1);\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "0", + "index": 8377 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_read_frame_flush(AVFormatContext *s)\n\n{\n\n AVStream *st;\n\n int i, j;\n\n\n\n flush_packet_queue(s);\n\n\n\n s->cur_st = NULL;\n\n\n\n /* for each stream, reset read state */\n\n for(i = 0; i < s->nb_streams; i++) {\n\n st = s->streams[i];\n\n\n\n if (st->parser) {\n\n av_parser_close(st->parser);\n\n st->parser = NULL;\n\n av_free_packet(&st->cur_pkt);\n\n }\n\n st->last_IP_pts = AV_NOPTS_VALUE;\n\n st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */\n\n st->reference_dts = AV_NOPTS_VALUE;\n\n /* fail safe */\n\n st->cur_ptr = NULL;\n\n st->cur_len = 0;\n\n\n\n st->probe_packets = MAX_PROBE_PACKETS;\n\n\n\n for(j=0; jpts_buffer[j]= AV_NOPTS_VALUE;\n\n }\n\n}\n", + "output": "0", + "index": 16573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_fail_cmd_req(VirtIOSCSIReq *req)\n\n{\n\n req->resp.cmd->response = VIRTIO_SCSI_S_FAILURE;\n\n virtio_scsi_complete_cmd_req(req);\n\n}\n", + "output": "0", + "index": 4613 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void spapr_events_init(sPAPRMachineState *spapr)\n\n{\n\n QTAILQ_INIT(&spapr->pending_events);\n\n spapr->check_exception_irq = xics_alloc(spapr->icp, 0, 0, false);\n\n spapr->epow_notifier.notify = spapr_powerdown_req;\n\n qemu_register_powerdown_notifier(&spapr->epow_notifier);\n\n spapr_rtas_register(RTAS_CHECK_EXCEPTION, \"check-exception\",\n\n check_exception);\n\n spapr_rtas_register(RTAS_EVENT_SCAN, \"event-scan\", event_scan);\n\n}\n", + "output": "1", + "index": 14101 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_virtqueue_stop(struct vhost_dev *dev,\n\n struct VirtIODevice *vdev,\n\n struct vhost_virtqueue *vq,\n\n unsigned idx)\n\n{\n\n int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);\n\n struct vhost_vring_state state = {\n\n .index = vhost_vq_index,\n\n };\n\n int r;\n\n\n\n r = dev->vhost_ops->vhost_get_vring_base(dev, &state);\n\n if (r < 0) {\n\n VHOST_OPS_DEBUG(\"vhost VQ %d ring restore failed: %d\", idx, r);\n\n\n\n\n\n } else {\n\n virtio_queue_set_last_avail_idx(vdev, idx, state.num);\n\n }\n\n virtio_queue_invalidate_signalled_used(vdev, idx);\n\n virtio_queue_update_used_idx(vdev, idx);\n\n\n\n /* In the cross-endian case, we need to reset the vring endianness to\n\n * native as legacy devices expect so by default.\n\n\n if (vhost_needs_vring_endian(vdev)) {\n\n vhost_virtqueue_set_vring_endian_legacy(dev,\n\n !virtio_is_big_endian(vdev),\n\n vhost_vq_index);\n\n }\n\n\n\n vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx),\n\n 1, virtio_queue_get_used_size(vdev, idx));\n\n vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx),\n\n 0, virtio_queue_get_avail_size(vdev, idx));\n\n vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx),\n\n 0, virtio_queue_get_desc_size(vdev, idx));\n\n}", + "output": "1", + "index": 7723 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_uint64_equal(QEMUFile *f, void *pv, size_t size,\n\n VMStateField *field)\n\n{\n\n uint64_t *v = pv;\n\n uint64_t v2;\n\n qemu_get_be64s(f, &v2);\n\n\n\n if (*v == v2) {\n\n return 0;\n\n\n error_report(\"%\" PRIx64 \" != %\" PRIx64, *v, v2);\n\n\n\n\n return -EINVAL;\n", + "output": "1", + "index": 12576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct pxa2xx_fir_s *pxa2xx_fir_init(target_phys_addr_t base,\n\n qemu_irq irq, struct pxa2xx_dma_state_s *dma,\n\n CharDriverState *chr)\n\n{\n\n int iomemtype;\n\n struct pxa2xx_fir_s *s = (struct pxa2xx_fir_s *)\n\n qemu_mallocz(sizeof(struct pxa2xx_fir_s));\n\n\n\n s->base = base;\n\n s->irq = irq;\n\n s->dma = dma;\n\n s->chr = chr;\n\n\n\n pxa2xx_fir_reset(s);\n\n\n\n iomemtype = cpu_register_io_memory(0, pxa2xx_fir_readfn,\n\n pxa2xx_fir_writefn, s);\n\n cpu_register_physical_memory(s->base, 0xfff, iomemtype);\n\n\n\n if (chr)\n\n qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,\n\n pxa2xx_fir_rx, pxa2xx_fir_event, s);\n\n\n\n register_savevm(\"pxa2xx_fir\", 0, 0, pxa2xx_fir_save, pxa2xx_fir_load, s);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 23353 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static V9fsFidState *lookup_fid(V9fsState *s, int32_t fid)\n\n{\n\n V9fsFidState *f;\n\n\n\n for (f = s->fid_list; f; f = f->next) {\n\n if (f->fid == fid) {\n\n v9fs_do_setuid(s, f->uid);\n\n return f;\n\n }\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 3523 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block,\n\n int component, int dc_index,\n\n int16_t *quant_matrix, int Al)\n\n{\n\n int val;\n\n s->bdsp.clear_block(block);\n\n val = mjpeg_decode_dc(s, dc_index);\n\n if (val == 0xfffff) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"error dc\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n val = (val * (quant_matrix[0] << Al)) + s->last_dc[component];\n\n s->last_dc[component] = val;\n\n block[0] = val;\n\n return 0;\n\n}\n", + "output": "1", + "index": 8194 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,\n\n uint8_t *current, uint8_t *previous,\n\n int pitch, svq1_pmv *motion, int x, int y)\n\n{\n\n uint8_t *src;\n\n uint8_t *dst;\n\n svq1_pmv mv;\n\n svq1_pmv *pmv[3];\n\n int result;\n\n\n\n /* predict and decode motion vector */\n\n pmv[0] = &motion[0];\n\n if (y == 0) {\n\n pmv[1] =\n\n pmv[2] = pmv[0];\n\n } else {\n\n pmv[1] = &motion[x / 8 + 2];\n\n pmv[2] = &motion[x / 8 + 4];\n\n }\n\n\n\n result = svq1_decode_motion_vector(bitbuf, &mv, pmv);\n\n\n\n if (result != 0)\n\n return result;\n\n\n\n motion[0].x =\n\n motion[x / 8 + 2].x =\n\n motion[x / 8 + 3].x = mv.x;\n\n motion[0].y =\n\n motion[x / 8 + 2].y =\n\n motion[x / 8 + 3].y = mv.y;\n\n\n\n if (y + (mv.y >> 1) < 0)\n\n mv.y = 0;\n\n if (x + (mv.x >> 1) < 0)\n\n mv.x = 0;\n\n\n\n src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch];\n\n dst = current;\n\n\n\n s->dsp.put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 3905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_hotplug(SCSIBus *bus, SCSIDevice *dev)\n\n{\n\n VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);\n\n\n\n if (((s->vdev.guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) &&\n\n (s->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) {\n\n virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_TRANSPORT_RESET,\n\n VIRTIO_SCSI_EVT_RESET_RESCAN);\n\n }\n\n}\n", + "output": "0", + "index": 24203 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline int normal_limit(uint8_t *p, ptrdiff_t stride, int E, int I)\n\n{\n\n LOAD_PIXELS\n\n return simple_limit(p, stride, E)\n\n && FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I\n\n && FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;\n\n}\n", + "output": "0", + "index": 17031 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void start_input(DBDMA_channel *ch, int key, uint32_t addr,\n\n uint16_t req_count, int is_last)\n\n{\n\n DBDMA_DPRINTF(\"start_input\\n\");\n\n\n\n /* KEY_REGS, KEY_DEVICE and KEY_STREAM\n\n * are not implemented in the mac-io chip\n\n */\n\n\n\n if (!addr || key > KEY_STREAM3) {\n\n kill_channel(ch);\n\n return;\n\n }\n\n\n\n ch->io.addr = addr;\n\n ch->io.len = req_count;\n\n ch->io.is_last = is_last;\n\n ch->io.dma_end = dbdma_end;\n\n ch->io.is_dma_out = 0;\n\n ch->processing = 1;\n\n ch->rw(&ch->io);\n\n}\n", + "output": "0", + "index": 11152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void send_ext_audio_ack(VncState *vs)\n\n{\n\n vnc_lock_output(vs);\n\n vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);\n\n vnc_write_u8(vs, 0);\n\n vnc_write_u16(vs, 1);\n\n vnc_framebuffer_update(vs, 0, 0,\n\n surface_width(vs->vd->ds),\n\n surface_height(vs->vd->ds),\n\n VNC_ENCODING_AUDIO);\n\n vnc_unlock_output(vs);\n\n vnc_flush(vs);\n\n}\n", + "output": "1", + "index": 11804 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rdma_register_and_get_keys(RDMAContext *rdma,\n\n RDMALocalBlock *block, uintptr_t host_addr,\n\n uint32_t *lkey, uint32_t *rkey, int chunk,\n\n uint8_t *chunk_start, uint8_t *chunk_end)\n\n{\n\n if (block->mr) {\n\n if (lkey) {\n\n *lkey = block->mr->lkey;\n\n }\n\n if (rkey) {\n\n *rkey = block->mr->rkey;\n\n }\n\n return 0;\n\n }\n\n\n\n /* allocate memory to store chunk MRs */\n\n if (!block->pmr) {\n\n block->pmr = g_malloc0(block->nb_chunks * sizeof(struct ibv_mr *));\n\n }\n\n\n\n /*\n\n * If 'rkey', then we're the destination, so grant access to the source.\n\n *\n\n * If 'lkey', then we're the source VM, so grant access only to ourselves.\n\n */\n\n if (!block->pmr[chunk]) {\n\n uint64_t len = chunk_end - chunk_start;\n\n\n\n trace_qemu_rdma_register_and_get_keys(len, chunk_start);\n\n\n\n block->pmr[chunk] = ibv_reg_mr(rdma->pd,\n\n chunk_start, len,\n\n (rkey ? (IBV_ACCESS_LOCAL_WRITE |\n\n IBV_ACCESS_REMOTE_WRITE) : 0));\n\n\n\n if (!block->pmr[chunk]) {\n\n perror(\"Failed to register chunk!\");\n\n fprintf(stderr, \"Chunk details: block: %d chunk index %d\"\n\n \" start %\" PRIuPTR \" end %\" PRIuPTR\n\n \" host %\" PRIuPTR\n\n \" local %\" PRIuPTR \" registrations: %d\\n\",\n\n block->index, chunk, (uintptr_t)chunk_start,\n\n (uintptr_t)chunk_end, host_addr,\n\n (uintptr_t)block->local_host_addr,\n\n rdma->total_registrations);\n\n return -1;\n\n }\n\n rdma->total_registrations++;\n\n }\n\n\n\n if (lkey) {\n\n *lkey = block->pmr[chunk]->lkey;\n\n }\n\n if (rkey) {\n\n *rkey = block->pmr[chunk]->rkey;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 9508 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int flashsv2_prime(FlashSVContext *s, uint8_t *src,\n\n int size, int unp_size)\n\n{\n\n z_stream zs;\n\n int zret; // Zlib return code\n\n\n\n zs.zalloc = NULL;\n\n zs.zfree = NULL;\n\n zs.opaque = NULL;\n\n\n\n s->zstream.next_in = src;\n\n s->zstream.avail_in = size;\n\n s->zstream.next_out = s->tmpblock;\n\n s->zstream.avail_out = s->block_size * 3;\n\n inflate(&s->zstream, Z_SYNC_FLUSH);\n\n\n\n deflateInit(&zs, 0);\n\n zs.next_in = s->tmpblock;\n\n zs.avail_in = s->block_size * 3 - s->zstream.avail_out;\n\n zs.next_out = s->deflate_block;\n\n zs.avail_out = s->deflate_block_size;\n\n deflate(&zs, Z_SYNC_FLUSH);\n\n deflateEnd(&zs);\n\n\n\n if ((zret = inflateReset(&s->zstream)) != Z_OK) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"Inflate reset error: %d\\n\", zret);\n\n return AVERROR_UNKNOWN;\n\n }\n\n\n\n s->zstream.next_in = s->deflate_block;\n\n s->zstream.avail_in = s->deflate_block_size - zs.avail_out;\n\n s->zstream.next_out = s->tmpblock;\n\n s->zstream.avail_out = s->block_size * 3;\n\n inflate(&s->zstream, Z_SYNC_FLUSH);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PPC_OP(tlbie)\n\n{\n\n do_tlbie();\n\n RETURN();\n\n}\n", + "output": "1", + "index": 15566 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void op_cp1_enabled(void)\n\n{\n\n if (!(env->CP0_Status & (1 << CP0St_CU1))) {\n\n CALL_FROM_TB2(do_raise_exception_err, EXCP_CpU, 1);\n\n }\n\n RETURN();\n\n}\n", + "output": "0", + "index": 26164 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my)\n\n{\n\n const int xy= s->mb_x + 1 + (s->mb_y + 1)*(s->mb_width + 2);\n\n \n\n s->p_mv_table[xy][0] = mx;\n\n s->p_mv_table[xy][1] = my;\n\n\n\n /* has allready been set to the 4 MV if 4MV is done */\n\n if(!(s->flags&CODEC_FLAG_4MV)){\n\n int mot_xy= s->block_index[0];\n\n\n\n s->motion_val[mot_xy ][0]= mx;\n\n s->motion_val[mot_xy ][1]= my;\n\n s->motion_val[mot_xy+1][0]= mx;\n\n s->motion_val[mot_xy+1][1]= my;\n\n\n\n mot_xy += s->block_wrap[0];\n\n s->motion_val[mot_xy ][0]= mx;\n\n s->motion_val[mot_xy ][1]= my;\n\n s->motion_val[mot_xy+1][0]= mx;\n\n s->motion_val[mot_xy+1][1]= my;\n\n }\n\n}\n", + "output": "0", + "index": 24252 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride,\n\n const uint8_t *block,\n\n const int *color_tab)\n\n{\n\n uint8_t indices[16];\n\n int x, y;\n\n\n\n decompress_indices(indices, block + 2);\n\n\n\n /* Only one or two channels are stored at most, since it only used to\n\n * compress specular (black and white) or normal (red and green) maps.\n\n * Although the standard says to zero out unused components, many\n\n * implementations fill all of them with the same value. */\n\n for (y = 0; y < 4; y++) {\n\n for (x = 0; x < 4; x++) {\n\n int i = indices[x + y * 4];\n\n /* Interval expansion from [-1 1] or [0 1] to [0 255]. */\n\n int c = color_tab[i];\n\n uint32_t pixel = RGBA(c, c, c, 255);\n\n AV_WL32(dst + x * 4 + y * stride, pixel);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 13911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_image_alloc(uint8_t *pointers[4], int linesizes[4],\n\n int w, int h, enum PixelFormat pix_fmt, int align)\n\n{\n\n int i, ret;\n\n uint8_t *buf;\n\n\n\n if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)\n\n return ret;\n\n if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, w)) < 0)\n\n return ret;\n\n\n\n for (i = 0; i < 4; i++)\n\n linesizes[i] = FFALIGN(linesizes[i], align);\n\n\n\n if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)\n\n return ret;\n\n buf = av_malloc(ret + align);\n\n if (!buf)\n\n return AVERROR(ENOMEM);\n\n if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {\n\n av_free(buf);\n\n return ret;\n\n }\n\n if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL)\n\n ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 18438 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,\n\n int is_write, hwaddr access_len)\n\n{\n\n if (buffer != bounce.buffer) {\n\n MemoryRegion *mr;\n\n ram_addr_t addr1;\n\n\n\n mr = qemu_ram_addr_from_host(buffer, &addr1);\n\n assert(mr != NULL);\n\n if (is_write) {\n\n while (access_len) {\n\n unsigned l;\n\n l = TARGET_PAGE_SIZE;\n\n if (l > access_len)\n\n l = access_len;\n\n invalidate_and_set_dirty(addr1, l);\n\n addr1 += l;\n\n access_len -= l;\n\n }\n\n }\n\n if (xen_enabled()) {\n\n xen_invalidate_map_cache_entry(buffer);\n\n }\n\n memory_region_unref(mr);\n\n return;\n\n }\n\n if (is_write) {\n\n address_space_write(as, bounce.addr, bounce.buffer, access_len);\n\n }\n\n qemu_vfree(bounce.buffer);\n\n bounce.buffer = NULL;\n\n memory_region_unref(bounce.mr);\n\n cpu_notify_map_clients();\n\n}\n", + "output": "0", + "index": 8045 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline bool vtd_queued_inv_enable_check(IntelIOMMUState *s)\n\n{\n\n return s->iq_tail == 0;\n\n}\n", + "output": "1", + "index": 3394 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *avfilter_configuration(void)\n\n{\n\n return FFMPEG_CONFIGURATION;\n\n}\n", + "output": "0", + "index": 4305 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_timetables( FM_OPL *OPL , int ARRATE , int DRRATE )\n\n{\n\n\tint i;\n\n\tdouble rate;\n\n\n\n\t/* make attack rate & decay rate tables */\n\n\tfor (i = 0;i < 4;i++) OPL->AR_TABLE[i] = OPL->DR_TABLE[i] = 0;\n\n\tfor (i = 4;i <= 60;i++){\n\n\t\trate = OPL->freqbase;\t\t\t\t\t\t/* frequency rate */\n\n\t\tif( i < 60 ) rate *= 1.0+(i&3)*0.25;\t\t/* b0-1 : x1 , x1.25 , x1.5 , x1.75 */\n\n\t\trate *= 1<<((i>>2)-1);\t\t\t\t\t\t/* b2-5 : shift bit */\n\n\t\trate *= (double)(EG_ENT<AR_TABLE[i] = rate / ARRATE;\n\n\t\tOPL->DR_TABLE[i] = rate / DRRATE;\n\n\t}\n\n\tfor (i = 60; i < ARRAY_SIZE(OPL->AR_TABLE); i++)\n\n\t{\n\n\t\tOPL->AR_TABLE[i] = EG_AED-1;\n\n\t\tOPL->DR_TABLE[i] = OPL->DR_TABLE[60];\n\n\t}\n\n#if 0\n\n\tfor (i = 0;i < 64 ;i++){\t/* make for overflow area */\n\n\t\tLOG(LOG_WAR,(\"rate %2d , ar %f ms , dr %f ms \\n\",i,\n\n\t\t\t((double)(EG_ENT<AR_TABLE[i]) * (1000.0 / OPL->rate),\n\n\t\t\t((double)(EG_ENT<DR_TABLE[i]) * (1000.0 / OPL->rate) ));\n\n\t}\n\n#endif\n\n}\n", + "output": "0", + "index": 18124 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t ahci_idp_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n AHCIState *s = opaque;\n\n\n\n if (addr == s->idp_offset) {\n\n /* index register */\n\n return s->idp_index;\n\n } else if (addr == s->idp_offset + 4) {\n\n /* data register - do memory read at location selected by index */\n\n return ahci_mem_read(opaque, s->idp_index, size);\n\n } else {\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 23703 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *g_try_malloc0(size_t n_bytes)\n\n{\n\n __coverity_negative_sink__(n_bytes);\n\n return calloc(1, n_bytes == 0 ? 1 : n_bytes);\n\n}\n", + "output": "1", + "index": 6892 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold void sws_init_swscale(SwsContext *c)\n\n{\n\n enum AVPixelFormat srcFormat = c->srcFormat;\n\n\n\n ff_sws_init_output_funcs(c, &c->yuv2plane1, &c->yuv2planeX,\n\n &c->yuv2nv12cX, &c->yuv2packed1,\n\n &c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);\n\n\n\n ff_sws_init_input_funcs(c);\n\n\n\n if (c->srcBpc == 8) {\n\n if (c->dstBpc <= 10) {\n\n c->hyScale = c->hcScale = hScale8To15_c;\n\n if (c->flags & SWS_FAST_BILINEAR) {\n\n c->hyscale_fast = hyscale_fast_c;\n\n c->hcscale_fast = hcscale_fast_c;\n\n }\n\n } else {\n\n c->hyScale = c->hcScale = hScale8To19_c;\n\n }\n\n } else {\n\n c->hyScale = c->hcScale = c->dstBpc > 10 ? hScale16To19_c\n\n : hScale16To15_c;\n\n }\n\n\n\n if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {\n\n if (c->dstBpc <= 10) {\n\n if (c->srcRange) {\n\n c->lumConvertRange = lumRangeFromJpeg_c;\n\n c->chrConvertRange = chrRangeFromJpeg_c;\n\n } else {\n\n c->lumConvertRange = lumRangeToJpeg_c;\n\n c->chrConvertRange = chrRangeToJpeg_c;\n\n }\n\n } else {\n\n if (c->srcRange) {\n\n c->lumConvertRange = lumRangeFromJpeg16_c;\n\n c->chrConvertRange = chrRangeFromJpeg16_c;\n\n } else {\n\n c->lumConvertRange = lumRangeToJpeg16_c;\n\n c->chrConvertRange = chrRangeToJpeg16_c;\n\n }\n\n }\n\n }\n\n\n\n if (!(isGray(srcFormat) || isGray(c->dstFormat) ||\n\n srcFormat == AV_PIX_FMT_MONOBLACK || srcFormat == AV_PIX_FMT_MONOWHITE))\n\n c->needs_hcscale = 1;\n\n}\n", + "output": "0", + "index": 17493 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_check_interrupts(DisasContext *dc)\n\n{\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_helper_check_interrupts(cpu_env);\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n }\n\n}\n", + "output": "1", + "index": 18208 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)\n\n{\n\n QEMUResetEntry *re;\n\n\n\n TAILQ_FOREACH(re, &reset_handlers, entry) {\n\n if (re->func == func && re->opaque == opaque) {\n\n TAILQ_REMOVE(&reset_handlers, re, entry);\n\n qemu_free(re);\n\n return;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 7229 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nabm_writew (void *opaque, uint32_t addr, uint32_t val)\n\n{\n\n PCIAC97LinkState *d = opaque;\n\n AC97LinkState *s = &d->ac97;\n\n AC97BusMasterRegs *r = NULL;\n\n uint32_t index = addr - s->base[1];\n\n switch (index) {\n\n case PI_SR:\n\n case PO_SR:\n\n case MC_SR:\n\n r = &s->bm_regs[GET_BM (index)];\n\n r->sr |= val & ~(SR_RO_MASK | SR_WCLEAR_MASK);\n\n update_sr (s, r, r->sr & ~(val & SR_WCLEAR_MASK));\n\n dolog (\"SR[%d] <- %#x (sr %#x)\\n\", GET_BM (index), val, r->sr);\n\n break;\n\n default:\n\n dolog (\"U nabm writew %#x <- %#x\\n\", addr, val);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 21867 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_aio_unref(void *p)\n\n{\n\n BlockAIOCB *acb = p;\n\n assert(acb->refcnt > 0);\n\n if (--acb->refcnt == 0) {\n\n g_free(acb);\n\n }\n\n}\n", + "output": "0", + "index": 20245 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)\n\n{\n\n struct XenNetDev *netdev = opaque;\n\n netif_rx_request_t rxreq;\n\n RING_IDX rc, rp;\n\n void *page;\n\n\n\n if (netdev->xendev.be_state != XenbusStateConnected)\n\n\treturn;\n\n\n\n rc = netdev->rx_ring.req_cons;\n\n rp = netdev->rx_ring.sring->req_prod;\n\n xen_rmb(); /* Ensure we see queued requests up to 'rp'. */\n\n\n\n if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {\n\n\txen_be_printf(&netdev->xendev, 2, \"no buffer, drop packet\\n\");\n\n\treturn;\n\n }\n\n if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {\n\n\txen_be_printf(&netdev->xendev, 0, \"packet too big (%lu > %ld)\",\n\n\t\t (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);\n\n\treturn;\n\n }\n\n\n\n memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq));\n\n netdev->rx_ring.req_cons = ++rc;\n\n\n\n page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,\n\n\t\t\t\t netdev->xendev.dom,\n\n\t\t\t\t rxreq.gref, PROT_WRITE);\n\n if (page == NULL) {\n\n\txen_be_printf(&netdev->xendev, 0, \"error: rx gref dereference failed (%d)\\n\",\n\n rxreq.gref);\n\n\tnet_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);\n\n\treturn;\n\n }\n\n memcpy(page + NET_IP_ALIGN, buf, size);\n\n xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1);\n\n net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);\n\n}\n", + "output": "0", + "index": 18875 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char* mpjpeg_get_boundary(AVIOContext* pb)\n\n{\n\n uint8_t *mime_type = NULL;\n\n const char *start;\n\n const char *end;\n\n uint8_t *res = NULL;\n\n int len;\n\n\n\n /* get MIME type, and skip to the first parameter */\n\n av_opt_get(pb, \"mime_type\", AV_OPT_SEARCH_CHILDREN, &mime_type);\n\n start = mime_type;\n\n while (start != NULL && *start != '\\0') {\n\n start = strchr(start, ';');\n\n if (start)\n\n start = start+1;\n\n\n\n while (av_isspace(*start))\n\n start++;\n\n\n\n if (!av_stristart(start, \"boundary=\", &start)) {\n\n end = strchr(start, ';');\n\n if (end)\n\n len = end - start - 1;\n\n else\n\n len = strlen(start);\n\n res = av_strndup(start, len);\n\n break;\n\n }\n\n }\n\n\n\n av_freep(&mime_type);\n\n return res;\n\n}\n", + "output": "0", + "index": 1016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb, const HEVCParamSets *ps,\n\n void *logctx)\n\n{\n\n HEVCSEIPictureTiming *h = &s->picture_timing;\n\n HEVCSPS *sps;\n\n\n\n if (!ps->sps_list[s->active_seq_parameter_set_id])\n\n return(AVERROR(ENOMEM));\n\n sps = (HEVCSPS*)ps->sps_list[s->active_seq_parameter_set_id]->data;\n\n\n\n if (sps->vui.frame_field_info_present_flag) {\n\n int pic_struct = get_bits(gb, 4);\n\n h->picture_struct = AV_PICTURE_STRUCTURE_UNKNOWN;\n\n if (pic_struct == 2) {\n\n av_log(logctx, AV_LOG_DEBUG, \"BOTTOM Field\\n\");\n\n h->picture_struct = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;\n\n } else if (pic_struct == 1) {\n\n av_log(logctx, AV_LOG_DEBUG, \"TOP Field\\n\");\n\n h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD;\n\n }\n\n get_bits(gb, 2); // source_scan_type\n\n get_bits(gb, 1); // duplicate_flag\n\n }\n\n return 1;\n\n}\n", + "output": "1", + "index": 23713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void coroutine_fn qemu_coroutine_yield(void)\n\n{\n\n Coroutine *self = qemu_coroutine_self();\n\n Coroutine *to = self->caller;\n\n\n\n trace_qemu_coroutine_yield(self, to);\n\n\n\n if (!to) {\n\n fprintf(stderr, \"Co-routine is yielding to no one\\n\");\n\n abort();\n\n }\n\n\n\n self->caller = NULL;\n\n coroutine_swap(self, to);\n\n}\n", + "output": "1", + "index": 13481 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,\n\n FsCred *credp)\n\n{\n\n char buffer[PATH_MAX];\n\n\n\n if (chmod(rpath(fs_ctx, path, buffer), credp->fc_mode & 07777) < 0) {\n\n return -1;\n\n }\n\n if (lchown(rpath(fs_ctx, path, buffer), credp->fc_uid,\n\n credp->fc_gid) < 0) {\n\n /*\n\n * If we fail to change ownership and if we are\n\n * using security model none. Ignore the error\n\n */\n\n if (fs_ctx->fs_sm != SM_NONE) {\n\n return -1;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 7108 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn qed_need_check_timer_entry(void *opaque)\n\n{\n\n BDRVQEDState *s = opaque;\n\n int ret;\n\n\n\n /* The timer should only fire when allocating writes have drained */\n\n assert(!s->allocating_acb);\n\n\n\n trace_qed_need_check_timer_cb(s);\n\n\n\n qed_acquire(s);\n\n qed_plug_allocating_write_reqs(s);\n\n\n\n /* Ensure writes are on disk before clearing flag */\n\n ret = bdrv_co_flush(s->bs->file->bs);\n\n qed_release(s);\n\n if (ret < 0) {\n\n qed_unplug_allocating_write_reqs(s);\n\n return;\n\n }\n\n\n\n s->header.features &= ~QED_F_NEED_CHECK;\n\n ret = qed_write_header(s);\n\n (void) ret;\n\n\n\n qed_unplug_allocating_write_reqs(s);\n\n\n\n ret = bdrv_co_flush(s->bs);\n\n (void) ret;\n\n}\n", + "output": "0", + "index": 5103 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)\n\n{\n\n PerThreadContext *p = avctx->thread_opaque;\n\n int *progress, err;\n\n\n\n f->owner = avctx;\n\n\n\n ff_init_buffer_info(avctx, f);\n\n\n\n if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {\n\n f->thread_opaque = NULL;\n\n return avctx->get_buffer(avctx, f);\n\n }\n\n\n\n if (p->state != STATE_SETTING_UP &&\n\n (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&\n\n avctx->get_buffer != avcodec_default_get_buffer))) {\n\n av_log(avctx, AV_LOG_ERROR, \"get_buffer() cannot be called after ff_thread_finish_setup()\\n\");\n\n return -1;\n\n }\n\n\n\n pthread_mutex_lock(&p->parent->buffer_mutex);\n\n f->thread_opaque = progress = allocate_progress(p);\n\n\n\n if (!progress) {\n\n pthread_mutex_unlock(&p->parent->buffer_mutex);\n\n return -1;\n\n }\n\n\n\n progress[0] =\n\n progress[1] = -1;\n\n\n\n if (avctx->thread_safe_callbacks ||\n\n avctx->get_buffer == avcodec_default_get_buffer) {\n\n err = avctx->get_buffer(avctx, f);\n\n } else {\n\n p->requested_frame = f;\n\n p->state = STATE_GET_BUFFER;\n\n pthread_mutex_lock(&p->progress_mutex);\n\n pthread_cond_signal(&p->progress_cond);\n\n\n\n while (p->state != STATE_SETTING_UP)\n\n pthread_cond_wait(&p->progress_cond, &p->progress_mutex);\n\n\n\n err = p->result;\n\n\n\n pthread_mutex_unlock(&p->progress_mutex);\n\n\n\n if (!avctx->codec->update_thread_context)\n\n ff_thread_finish_setup(avctx);\n\n }\n\n\n\n pthread_mutex_unlock(&p->parent->buffer_mutex);\n\n\n\n return err;\n\n}\n", + "output": "1", + "index": 8105 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_cpu_kick(void *env)\n\n{\n\n}\n", + "output": "1", + "index": 6415 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qtest_quit(QTestState *s)\n\n{\n\n int status;\n\n\n\n pid_t pid = qtest_qemu_pid(s);\n\n if (pid != -1) {\n\n kill(pid, SIGTERM);\n\n waitpid(pid, &status, 0);\n\n }\n\n\n\n\n\n\n unlink(s->pid_file);\n\n unlink(s->socket_path);\n\n unlink(s->qmp_socket_path);\n\n g_free(s->pid_file);\n\n g_free(s->socket_path);\n\n g_free(s->qmp_socket_path);\n\n\n}", + "output": "1", + "index": 10179 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n)\n\n{\n\n BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));\n\n VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n\n int rc;\n\n\n\n /* Set up virtqueue notify */\n\n rc = k->set_host_notifier(qbus->parent, n, true);\n\n if (rc != 0) {\n\n fprintf(stderr, \"virtio-scsi: Failed to set host notifier (%d)\\n\",\n\n rc);\n\n s->dataplane_fenced = true;\n\n return rc;\n\n }\n\n\n\n virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, true, true);\n\n return 0;\n\n}\n", + "output": "1", + "index": 2127 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t helper_efdctsf (uint64_t val)\n\n{\n\n CPU_DoubleU u;\n\n float64 tmp;\n\n\n\n u.ll = val;\n\n /* NaN are not treated the same way IEEE 754 does */\n\n if (unlikely(float64_is_nan(u.d)))\n\n return 0;\n\n tmp = uint64_to_float64(1ULL << 32, &env->vec_status);\n\n u.d = float64_mul(u.d, tmp, &env->vec_status);\n\n\n\n return float64_to_int32(u.d, &env->vec_status);\n\n}\n", + "output": "0", + "index": 23413 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void picmemset(PicContext *s, AVFrame *frame, int value, int run,\n\n int *x, int *y, int *plane, int bits_per_plane)\n\n{\n\n uint8_t *d;\n\n int shift = *plane * bits_per_plane;\n\n int mask = ((1 << bits_per_plane) - 1) << shift;\n\n value <<= shift;\n\n\n\n while (run > 0) {\n\n int j;\n\n for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {\n\n d = frame->data[0] + *y * frame->linesize[0];\n\n d[*x] |= (value >> j) & mask;\n\n *x += 1;\n\n if (*x == s->width) {\n\n *y -= 1;\n\n *x = 0;\n\n if (*y < 0) {\n\n *y = s->height - 1;\n\n *plane += 1;\n\n if (*plane >= s->nb_planes)\n\n return;\n\n value <<= bits_per_plane;\n\n mask <<= bits_per_plane;\n\n }\n\n }\n\n }\n\n run--;\n\n }\n\n}\n", + "output": "1", + "index": 14665 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)\n\n{\n\n VirtIOSCSI *s = opaque;\n\n virtio_load(&s->vdev, f);\n\n return 0;\n\n}\n", + "output": "1", + "index": 18687 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_read_devaddr(Monitor *mon, const char *addr,\n\n int *busp, unsigned *slotp)\n\n{\n\n int dom;\n\n\n\n /* strip legacy tag */\n\n if (!strncmp(addr, \"pci_addr=\", 9)) {\n\n addr += 9;\n\n }\n\n if (pci_parse_devaddr(addr, &dom, busp, slotp, NULL)) {\n\n monitor_printf(mon, \"Invalid pci address\\n\");\n\n return -1;\n\n }\n\n if (dom != 0) {\n\n monitor_printf(mon, \"Multiple PCI domains not supported, use device_add\\n\");\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 10646 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmxnet3_update_mcast_filters(VMXNET3State *s)\n\n{\n\n uint16_t list_bytes =\n\n VMXNET3_READ_DRV_SHARED16(s->drv_shmem,\n\n devRead.rxFilterConf.mfTableLen);\n\n\n\n s->mcast_list_len = list_bytes / sizeof(s->mcast_list[0]);\n\n\n\n s->mcast_list = g_realloc(s->mcast_list, list_bytes);\n\n if (!s->mcast_list) {\n\n if (s->mcast_list_len == 0) {\n\n VMW_CFPRN(\"Current multicast list is empty\");\n\n } else {\n\n VMW_ERPRN(\"Failed to allocate multicast list of %d elements\",\n\n s->mcast_list_len);\n\n }\n\n s->mcast_list_len = 0;\n\n } else {\n\n int i;\n\n hwaddr mcast_list_pa =\n\n VMXNET3_READ_DRV_SHARED64(s->drv_shmem,\n\n devRead.rxFilterConf.mfTablePA);\n\n\n\n pci_dma_read(PCI_DEVICE(s), mcast_list_pa, s->mcast_list, list_bytes);\n\n\n\n VMW_CFPRN(\"Current multicast list len is %d:\", s->mcast_list_len);\n\n for (i = 0; i < s->mcast_list_len; i++) {\n\n VMW_CFPRN(\"\\t\" MAC_FMT, MAC_ARG(s->mcast_list[i].a));\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 12548 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoll_full_max(void)\n\n{\n\n\n\n const char *str = g_strdup_printf(\"%lld\", LLONG_MAX);\n\n int64_t res;\n\n int err;\n\n\n\n err = qemu_strtoll(str, NULL, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, LLONG_MAX);\n\n}\n", + "output": "1", + "index": 22227 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_net_init_pci(PCIDevice *pci_dev)\n\n{\n\n VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);\n\n VirtIODevice *vdev;\n\n\n\n vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic, &proxy->net);\n\n\n\n vdev->nvectors = proxy->nvectors;\n\n virtio_init_pci(proxy, vdev,\n\n PCI_VENDOR_ID_REDHAT_QUMRANET,\n\n PCI_DEVICE_ID_VIRTIO_NET,\n\n PCI_CLASS_NETWORK_ETHERNET,\n\n 0x00);\n\n\n\n /* make the actual value visible */\n\n proxy->nvectors = vdev->nvectors;\n\n return 0;\n\n}\n", + "output": "0", + "index": 20528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors,\n\n int flags)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n uint64_t end_offset;\n\n uint64_t nb_clusters;\n\n int ret;\n\n\n\n end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS);\n\n\n\n /* Caller must pass aligned values, except at image end */\n\n assert(QEMU_IS_ALIGNED(offset, s->cluster_size));\n\n assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) ||\n\n end_offset == bs->total_sectors << BDRV_SECTOR_BITS);\n\n\n\n /* The zero flag is only supported by version 3 and newer */\n\n if (s->qcow_version < 3) {\n\n return -ENOTSUP;\n\n }\n\n\n\n /* Each L2 table is handled by its own loop iteration */\n\n nb_clusters = size_to_clusters(s, nb_sectors << BDRV_SECTOR_BITS);\n\n\n\n s->cache_discards = true;\n\n\n\n while (nb_clusters > 0) {\n\n ret = zero_single_l2(bs, offset, nb_clusters, flags);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n nb_clusters -= ret;\n\n offset += (ret * s->cluster_size);\n\n }\n\n\n\n ret = 0;\n\nfail:\n\n s->cache_discards = false;\n\n qcow2_process_discards(bs, ret);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 11181 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)\n\n{\n\n struct xlx_ethlite *s = qemu_get_nic_opaque(nc);\n\n unsigned int rxbase = s->rxbuf * (0x800 / 4);\n\n\n\n /* DA filter. */\n\n if (!(buf[0] & 0x80) && memcmp(&s->conf.macaddr.a[0], buf, 6))\n\n return size;\n\n\n\n if (s->regs[rxbase + R_RX_CTRL0] & CTRL_S) {\n\n D(qemu_log(\"ethlite lost packet %x\\n\", s->regs[R_RX_CTRL0]));\n\n\n\n\n\n D(qemu_log(\"%s %zd rxbase=%x\\n\", __func__, size, rxbase));\n\n\n\n\n\n memcpy(&s->regs[rxbase + R_RX_BUF0], buf, size);\n\n\n\n s->regs[rxbase + R_RX_CTRL0] |= CTRL_S;\n\n if (s->regs[R_RX_CTRL0] & CTRL_I) {\n\n eth_pulse_irq(s);\n\n\n\n\n /* If c_rx_pingpong was set flip buffers. */\n\n s->rxbuf ^= s->c_rx_pingpong;\n\n return size;\n", + "output": "1", + "index": 3487 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QObject *parse_object(JSONParserContext *ctxt, va_list *ap)\n\n{\n\n QDict *dict = NULL;\n\n QObject *token, *peek;\n\n JSONParserContext saved_ctxt = parser_context_save(ctxt);\n\n\n\n token = parser_context_pop_token(ctxt);\n\n if (token == NULL) {\n\n goto out;\n\n }\n\n\n\n if (!token_is_operator(token, '{')) {\n\n goto out;\n\n }\n\n\n\n dict = qdict_new();\n\n\n\n peek = parser_context_peek_token(ctxt);\n\n if (peek == NULL) {\n\n parse_error(ctxt, NULL, \"premature EOI\");\n\n goto out;\n\n }\n\n\n\n if (!token_is_operator(peek, '}')) {\n\n if (parse_pair(ctxt, dict, ap) == -1) {\n\n goto out;\n\n }\n\n\n\n token = parser_context_pop_token(ctxt);\n\n if (token == NULL) {\n\n parse_error(ctxt, NULL, \"premature EOI\");\n\n goto out;\n\n }\n\n\n\n while (!token_is_operator(token, '}')) {\n\n if (!token_is_operator(token, ',')) {\n\n parse_error(ctxt, token, \"expected separator in dict\");\n\n goto out;\n\n }\n\n\n\n if (parse_pair(ctxt, dict, ap) == -1) {\n\n goto out;\n\n }\n\n\n\n token = parser_context_pop_token(ctxt);\n\n if (token == NULL) {\n\n parse_error(ctxt, NULL, \"premature EOI\");\n\n goto out;\n\n }\n\n }\n\n } else {\n\n (void)parser_context_pop_token(ctxt);\n\n }\n\n\n\n return QOBJECT(dict);\n\n\n\nout:\n\n parser_context_restore(ctxt, saved_ctxt);\n\n QDECREF(dict);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 12534 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ppc_hash64_pte_update_flags(struct mmu_ctx_hash64 *ctx,\n\n target_ulong *pte1p,\n\n int ret, int rw)\n\n{\n\n int store = 0;\n\n\n\n /* Update page flags */\n\n if (!(*pte1p & HPTE64_R_R)) {\n\n /* Update accessed flag */\n\n *pte1p |= HPTE64_R_R;\n\n store = 1;\n\n }\n\n if (!(*pte1p & HPTE64_R_C)) {\n\n if (rw == 1 && ret == 0) {\n\n /* Update changed flag */\n\n *pte1p |= HPTE64_R_C;\n\n store = 1;\n\n } else {\n\n /* Force page fault for first write access */\n\n ctx->prot &= ~PAGE_WRITE;\n\n }\n\n }\n\n\n\n return store;\n\n}\n", + "output": "0", + "index": 15521 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void blkverify_aio_cb(void *opaque, int ret)\n\n{\n\n BlkverifyAIOCB *acb = opaque;\n\n\n\n switch (++acb->done) {\n\n case 1:\n\n acb->ret = ret;\n\n break;\n\n\n\n case 2:\n\n if (acb->ret != ret) {\n\n blkverify_err(acb, \"return value mismatch %d != %d\", acb->ret, ret);\n\n }\n\n\n\n if (acb->verify) {\n\n acb->verify(acb);\n\n }\n\n\n\n aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),\n\n blkverify_aio_bh, acb);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 6779 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_disk_purge_requests(SCSIDiskState *s)\n\n{\n\n SCSIDiskReq *r;\n\n\n\n while (!QTAILQ_EMPTY(&s->qdev.requests)) {\n\n r = DO_UPCAST(SCSIDiskReq, req, QTAILQ_FIRST(&s->qdev.requests));\n\n if (r->req.aiocb) {\n\n bdrv_aio_cancel(r->req.aiocb);\n\n }\n\n scsi_remove_request(r);\n\n }\n\n}\n", + "output": "1", + "index": 14025 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void avfilter_free(AVFilterContext *filter)\n\n{\n\n int i;\n\n AVFilterLink *link;\n\n\n\n if (filter->filter->uninit)\n\n filter->filter->uninit(filter);\n\n\n\n for (i = 0; i < filter->input_count; i++) {\n\n if ((link = filter->inputs[i])) {\n\n if (link->src)\n\n link->src->outputs[link->srcpad - link->src->output_pads] = NULL;\n\n avfilter_formats_unref(&link->in_formats);\n\n avfilter_formats_unref(&link->out_formats);\n\n }\n\n av_freep(&link);\n\n }\n\n for (i = 0; i < filter->output_count; i++) {\n\n if ((link = filter->outputs[i])) {\n\n if (link->dst)\n\n link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;\n\n avfilter_formats_unref(&link->in_formats);\n\n avfilter_formats_unref(&link->out_formats);\n\n }\n\n av_freep(&link);\n\n }\n\n\n\n av_freep(&filter->name);\n\n av_freep(&filter->input_pads);\n\n av_freep(&filter->output_pads);\n\n av_freep(&filter->inputs);\n\n av_freep(&filter->outputs);\n\n av_freep(&filter->priv);\n\n av_free(filter);\n\n}\n", + "output": "1", + "index": 23302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qsort_strcmp(const void *a, const void *b)\n\n{\n\n return strcmp(a, b);\n\n}\n", + "output": "0", + "index": 21325 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static DeviceState *apic_init(void *env, uint8_t apic_id)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *d;\n\n static int apic_mapped;\n\n\n\n dev = qdev_create(NULL, \"apic\");\n\n qdev_prop_set_uint8(dev, \"id\", apic_id);\n\n qdev_prop_set_ptr(dev, \"cpu_env\", env);\n\n qdev_init_nofail(dev);\n\n d = sysbus_from_qdev(dev);\n\n\n\n /* XXX: mapping more APICs at the same memory location */\n\n if (apic_mapped == 0) {\n\n /* NOTE: the APIC is directly connected to the CPU - it is not\n\n on the global memory bus. */\n\n /* XXX: what if the base changes? */\n\n sysbus_mmio_map(d, 0, MSI_ADDR_BASE);\n\n apic_mapped = 1;\n\n }\n\n\n\n msi_supported = true;\n\n\n\n return dev;\n\n}\n", + "output": "0", + "index": 22173 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void AUD_vlog (const char *cap, const char *fmt, va_list ap)\n\n{\n\n if (conf.log_to_monitor) {\n\n if (cap) {\n\n monitor_printf(default_mon, \"%s: \", cap);\n\n }\n\n\n\n monitor_vprintf(default_mon, fmt, ap);\n\n }\n\n else {\n\n if (cap) {\n\n fprintf (stderr, \"%s: \", cap);\n\n }\n\n\n\n vfprintf (stderr, fmt, ap);\n\n }\n\n}\n", + "output": "1", + "index": 12347 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_aio_complete(void *opaque, int ret)\n\n{\n\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n\n\n\n assert(r->req.aiocb != NULL);\n\n r->req.aiocb = NULL;\n\n block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);\n\n if (r->req.io_canceled) {\n\n scsi_req_cancel_complete(&r->req);\n\n goto done;\n\n }\n\n\n\n if (ret < 0) {\n\n if (scsi_handle_rw_error(r, -ret)) {\n\n goto done;\n\n }\n\n }\n\n\n\n scsi_req_complete(&r->req, GOOD);\n\n\n\ndone:\n\n scsi_req_unref(&r->req);\n\n}\n", + "output": "0", + "index": 18616 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_init_pci_1_2(QEMUMachineInitArgs *args)\n\n{\n\n disable_kvm_pv_eoi();\n\n enable_compat_apic_id_mode();\n\n pc_sysfw_flash_vs_rom_bug_compatible = true;\n\n has_pvpanic = false;\n\n pc_init_pci(args);\n\n}\n", + "output": "1", + "index": 14757 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iovec *iov,\n unsigned int max_num_sg, bool is_write,\n hwaddr pa, size_t sz)\n{\n unsigned num_sg = *p_num_sg;\n assert(num_sg <= max_num_sg);\n if (!sz) {\n error_report(\"virtio: zero sized buffers are not allowed\");\n while (sz) {\n hwaddr len = sz;\n if (num_sg == max_num_sg) {\n error_report(\"virtio: too many write descriptors in indirect table\");\n iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);\n iov[num_sg].iov_len = len;\n addr[num_sg] = pa;\n sz -= len;\n pa += len;\n num_sg++;\n *p_num_sg = num_sg;", + "output": "1", + "index": 22162 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\n\n long width, long height,\n\n long lumStride, long chromStride, long dstStride)\n\n{\n\n RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 1);\n\n}\n", + "output": "0", + "index": 2246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pmac_ide_flush(DBDMA_io *io)\n\n{\n\n MACIOIDEState *m = io->opaque;\n\n\n\n if (m->aiocb) {\n\n bdrv_drain_all();\n\n }\n\n}\n", + "output": "0", + "index": 12370 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_co_flush(BlockDriverState *bs)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int ret;\n\n\n\n qemu_co_mutex_lock(&s->lock);\n\n ret = qcow2_cache_flush(bs, s->l2_table_cache);\n\n if (ret < 0) {\n\n\n return ret;\n\n }\n\n\n\n ret = qcow2_cache_flush(bs, s->refcount_block_cache);\n\n if (ret < 0) {\n\n\n return ret;\n\n }\n\n\n\n\n return bdrv_co_flush(bs->file);\n\n}", + "output": "1", + "index": 5129 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void gic_complete_irq(GICState *s, int cpu, int irq)\n\n{\n\n int update = 0;\n\n int cm = 1 << cpu;\n\n DPRINTF(\"EOI %d\\n\", irq);\n\n if (irq >= s->num_irq) {\n\n /* This handles two cases:\n\n * 1. If software writes the ID of a spurious interrupt [ie 1023]\n\n * to the GICC_EOIR, the GIC ignores that write.\n\n * 2. If software writes the number of a non-existent interrupt\n\n * this must be a subcase of \"value written does not match the last\n\n * valid interrupt value read from the Interrupt Acknowledge\n\n * register\" and so this is UNPREDICTABLE. We choose to ignore it.\n\n */\n\n return;\n\n }\n\n if (s->running_irq[cpu] == 1023)\n\n return; /* No active IRQ. */\n\n\n\n if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {\n\n /* Mark level triggered interrupts as pending if they are still\n\n raised. */\n\n if (!GIC_TEST_EDGE_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)\n\n && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {\n\n DPRINTF(\"Set %d pending mask %x\\n\", irq, cm);\n\n GIC_SET_PENDING(irq, cm);\n\n update = 1;\n\n }\n\n }\n\n\n\n if (irq != s->running_irq[cpu]) {\n\n /* Complete an IRQ that is not currently running. */\n\n int tmp = s->running_irq[cpu];\n\n while (s->last_active[tmp][cpu] != 1023) {\n\n if (s->last_active[tmp][cpu] == irq) {\n\n s->last_active[tmp][cpu] = s->last_active[irq][cpu];\n\n break;\n\n }\n\n tmp = s->last_active[tmp][cpu];\n\n }\n\n if (update) {\n\n gic_update(s);\n\n }\n\n } else {\n\n /* Complete the current running IRQ. */\n\n gic_set_running_irq(s, cpu, s->last_active[s->running_irq[cpu]][cpu]);\n\n }\n\n}\n", + "output": "0", + "index": 1156 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,\n\n unsigned int out_bytes)\n\n{\n\n unsigned int in_total, out_total;\n\n\n\n virtqueue_get_avail_bytes(vq, &in_total, &out_total);\n\n if ((in_bytes && in_bytes < in_total)\n\n || (out_bytes && out_bytes < out_total)) {\n\n return 1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 22756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void store_slice_mmx(uint8_t *dst, const uint16_t *src,\n\n int dst_stride, int src_stride,\n\n int width, int height, int log2_scale,\n\n const uint8_t dither[8][8])\n\n{\n\n int y;\n\n\n\n for (y = 0; y < height; y++) {\n\n uint8_t *dst1 = dst;\n\n const int16_t *src1 = src;\n\n __asm__ volatile(\n\n \"movq (%3), %%mm3 \\n\"\n\n \"movq (%3), %%mm4 \\n\"\n\n \"movd %4, %%mm2 \\n\"\n\n \"pxor %%mm0, %%mm0 \\n\"\n\n \"punpcklbw %%mm0, %%mm3 \\n\"\n\n \"punpckhbw %%mm0, %%mm4 \\n\"\n\n \"psraw %%mm2, %%mm3 \\n\"\n\n \"psraw %%mm2, %%mm4 \\n\"\n\n \"movd %5, %%mm2 \\n\"\n\n \"1: \\n\"\n\n \"movq (%0), %%mm0 \\n\"\n\n \"movq 8(%0), %%mm1 \\n\"\n\n \"paddw %%mm3, %%mm0 \\n\"\n\n \"paddw %%mm4, %%mm1 \\n\"\n\n \"psraw %%mm2, %%mm0 \\n\"\n\n \"psraw %%mm2, %%mm1 \\n\"\n\n \"packuswb %%mm1, %%mm0 \\n\"\n\n \"movq %%mm0, (%1) \\n\"\n\n \"add $16, %0 \\n\"\n\n \"add $8, %1 \\n\"\n\n \"cmp %2, %1 \\n\"\n\n \" jb 1b \\n\"\n\n : \"+r\" (src1), \"+r\"(dst1)\n\n : \"r\"(dst + width), \"r\"(dither[y]), \"g\"(log2_scale), \"g\"(MAX_LEVEL - log2_scale)\n\n );\n\n src += src_stride;\n\n dst += dst_stride;\n\n }\n\n}\n", + "output": "1", + "index": 19718 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint32_t lduw_phys_internal(target_phys_addr_t addr,\n\n enum device_endian endian)\n\n{\n\n uint8_t *ptr;\n\n uint64_t val;\n\n MemoryRegionSection *section;\n\n\n\n section = phys_page_find(addr >> TARGET_PAGE_BITS);\n\n\n\n if (!(memory_region_is_ram(section->mr) ||\n\n memory_region_is_romd(section->mr))) {\n\n /* I/O case */\n\n addr = memory_region_section_addr(section, addr);\n\n val = io_mem_read(section->mr, addr, 2);\n\n#if defined(TARGET_WORDS_BIGENDIAN)\n\n if (endian == DEVICE_LITTLE_ENDIAN) {\n\n val = bswap16(val);\n\n }\n\n#else\n\n if (endian == DEVICE_BIG_ENDIAN) {\n\n val = bswap16(val);\n\n }\n\n#endif\n\n } else {\n\n /* RAM case */\n\n ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)\n\n & TARGET_PAGE_MASK)\n\n + memory_region_section_addr(section, addr));\n\n switch (endian) {\n\n case DEVICE_LITTLE_ENDIAN:\n\n val = lduw_le_p(ptr);\n\n break;\n\n case DEVICE_BIG_ENDIAN:\n\n val = lduw_be_p(ptr);\n\n break;\n\n default:\n\n val = lduw_p(ptr);\n\n break;\n\n }\n\n }\n\n return val;\n\n}\n", + "output": "0", + "index": 18736 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void page_flush_tb(void)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < V_L1_SIZE; i++) {\n\n page_flush_tb_1(V_L1_SHIFT / L2_BITS - 1, l1_map + i);\n\n }\n\n}\n", + "output": "0", + "index": 2800 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static long do_rt_sigreturn_v2(CPUARMState *env)\n\n{\n\n abi_ulong frame_addr;\n\n struct rt_sigframe_v2 *frame = NULL;\n\n\n\n /*\n\n * Since we stacked the signal on a 64-bit boundary,\n\n * then 'sp' should be word aligned here. If it's\n\n * not, then the user is trying to mess with us.\n\n */\n\n frame_addr = env->regs[13];\n\n trace_user_do_rt_sigreturn(env, frame_addr);\n\n if (frame_addr & 7) {\n\n goto badframe;\n\n }\n\n\n\n if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {\n\n goto badframe;\n\n }\n\n\n\n if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {\n\n goto badframe;\n\n }\n\n\n\n unlock_user_struct(frame, frame_addr, 0);\n\n return -TARGET_QEMU_ESIGRETURN;\n\n\n\nbadframe:\n\n unlock_user_struct(frame, frame_addr, 0);\n\n force_sig(TARGET_SIGSEGV /* , current */);\n\n return 0;\n\n}\n", + "output": "1", + "index": 9519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf,\n\n int64_t bytes, CoroutineEntry co_entry,\n\n BdrvRequestFlags flags)\n\n{\n\n AioContext *aio_context;\n\n QEMUIOVector qiov;\n\n struct iovec iov;\n\n Coroutine *co;\n\n BlkRwCo rwco;\n\n\n\n iov = (struct iovec) {\n\n .iov_base = buf,\n\n .iov_len = bytes,\n\n };\n\n qemu_iovec_init_external(&qiov, &iov, 1);\n\n\n\n rwco = (BlkRwCo) {\n\n .blk = blk,\n\n .offset = offset,\n\n .qiov = &qiov,\n\n .flags = flags,\n\n .ret = NOT_DONE,\n\n };\n\n\n\n co = qemu_coroutine_create(co_entry, &rwco);\n\n qemu_coroutine_enter(co);\n\n\n\n aio_context = blk_get_aio_context(blk);\n\n while (rwco.ret == NOT_DONE) {\n\n aio_poll(aio_context, true);\n\n }\n\n\n\n return rwco.ret;\n\n}\n", + "output": "0", + "index": 12321 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int libopenjpeg_copy_packed16(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)\n\n{\n\n int compno;\n\n int x;\n\n int y;\n\n int *image_line;\n\n int frame_index;\n\n const int numcomps = image->numcomps;\n\n uint16_t *frame_ptr = (uint16_t*)frame->data[0];\n\n\n\n for (compno = 0; compno < numcomps; ++compno) {\n\n if (image->comps[compno].w > frame->linesize[0] / numcomps) {\n\n av_log(avctx, AV_LOG_ERROR, \"Error: frame's linesize is too small for the image\\n\");\n\n return 0;\n\n }\n\n }\n\n\n\n for (compno = 0; compno < numcomps; ++compno) {\n\n for (y = 0; y < avctx->height; ++y) {\n\n image_line = image->comps[compno].data + y * image->comps[compno].w;\n\n frame_index = y * (frame->linesize[0] / 2) + compno;\n\n for (x = 0; x < avctx->width; ++x) {\n\n image_line[x] = frame_ptr[frame_index];\n\n frame_index += numcomps;\n\n }\n\n for (; x < image->comps[compno].w; ++x) {\n\n image_line[x] = image_line[x - 1];\n\n }\n\n }\n\n for (; y < image->comps[compno].h; ++y) {\n\n image_line = image->comps[compno].data + y * image->comps[compno].w;\n\n for (x = 0; x < image->comps[compno].w; ++x) {\n\n image_line[x] = image_line[x - image->comps[compno].w];\n\n }\n\n }\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 19826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_change_backing_file(BlockDriverState *bs,\n\n const char *backing_file, const char *backing_fmt)\n\n{\n\n /* Backing file format doesn't make sense without a backing file */\n\n if (backing_fmt && !backing_file) {\n\n return -EINVAL;\n\n }\n\n\n\n pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: \"\");\n\n pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: \"\");\n\n\n\n return qcow2_update_header(bs);\n\n}\n", + "output": "0", + "index": 6613 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *isabus_get_fw_dev_path(DeviceState *dev)\n\n{\n\n ISADevice *d = (ISADevice*)dev;\n\n char path[40];\n\n int off;\n\n\n\n off = snprintf(path, sizeof(path), \"%s\", qdev_fw_name(dev));\n\n if (d->ioport_id) {\n\n snprintf(path + off, sizeof(path) - off, \"@%04x\", d->ioport_id);\n\n }\n\n\n\n return strdup(path);\n\n}\n", + "output": "0", + "index": 18097 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt)\n\n{\n\n int fd = -1;\n\n char *dev;\n\n char path[PATH_MAX];\n\n\n\n if (tpm_pt->options->cancel_path) {\n\n fd = qemu_open(tpm_pt->options->cancel_path, O_WRONLY);\n\n if (fd < 0) {\n\n error_report(\"Could not open TPM cancel path : %s\",\n\n strerror(errno));\n\n }\n\n return fd;\n\n }\n\n\n\n dev = strrchr(tpm_pt->tpm_dev, '/');\n\n if (dev) {\n\n dev++;\n\n if (snprintf(path, sizeof(path), \"/sys/class/misc/%s/device/cancel\",\n\n dev) < sizeof(path)) {\n\n fd = qemu_open(path, O_WRONLY);\n\n if (fd >= 0) {\n\n tpm_pt->options->cancel_path = g_strdup(path);\n\n } else {\n\n error_report(\"tpm_passthrough: Could not open TPM cancel \"\n\n \"path %s : %s\", path, strerror(errno));\n\n }\n\n }\n\n } else {\n\n error_report(\"tpm_passthrough: Bad TPM device path %s\",\n\n tpm_pt->tpm_dev);\n\n }\n\n\n\n return fd;\n\n}\n", + "output": "1", + "index": 22059 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static size_t v9fs_packunpack(void *addr, struct iovec *sg, int sg_count,\n\n size_t offset, size_t size, int pack)\n\n{\n\n int i = 0;\n\n size_t copied = 0;\n\n\n\n for (i = 0; size && i < sg_count; i++) {\n\n size_t len;\n\n if (offset >= sg[i].iov_len) {\n\n /* skip this sg */\n\n offset -= sg[i].iov_len;\n\n continue;\n\n } else {\n\n len = MIN(sg[i].iov_len - offset, size);\n\n if (pack) {\n\n memcpy(sg[i].iov_base + offset, addr, len);\n\n } else {\n\n memcpy(addr, sg[i].iov_base + offset, len);\n\n }\n\n size -= len;\n\n copied += len;\n\n addr += len;\n\n if (size) {\n\n offset = 0;\n\n continue;\n\n }\n\n }\n\n }\n\n\n\n return copied;\n\n}\n", + "output": "0", + "index": 16495 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)\n\n{\n\n MpegTSWrite *ts = s->priv_data;\n\n MpegTSWriteStream *ts_st = st->priv_data;\n\n uint8_t *q;\n\n uint8_t buf[TS_PACKET_SIZE];\n\n\n\n q = buf;\n\n *q++ = 0x47;\n\n *q++ = ts_st->pid >> 8;\n\n *q++ = ts_st->pid;\n\n *q++ = 0x20 | ts_st->cc; /* Adaptation only */\n\n /* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) */\n\n *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */\n\n *q++ = 0x10; /* Adaptation flags: PCR present */\n\n\n\n\n\n\n\n /* PCR coded into 6 bytes */\n\n q += write_pcr_bits(q, get_pcr(ts, s->pb));\n\n\n\n /* stuffing bytes */\n\n memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));\n\n mpegts_prefix_m2ts_header(s);\n\n avio_write(s->pb, buf, TS_PACKET_SIZE);\n", + "output": "1", + "index": 13627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time)\n\n{\n\n QEMUTimer **pt, *t;\n\n\n\n qemu_del_timer(ts);\n\n\n\n /* add the timer in the sorted list */\n\n /* NOTE: this code must be signal safe because\n\n qemu_timer_expired() can be called from a signal. */\n\n pt = &active_timers[ts->clock->type];\n\n for(;;) {\n\n t = *pt;\n\n if (!t)\n\n break;\n\n if (t->expire_time > expire_time)\n\n break;\n\n pt = &t->next;\n\n }\n\n ts->expire_time = expire_time;\n\n ts->next = *pt;\n\n *pt = ts;\n\n\n\n /* Rearm if necessary */\n\n if (pt == &active_timers[ts->clock->type]) {\n\n if (!alarm_timer->pending) {\n\n qemu_rearm_alarm_timer(alarm_timer);\n\n }\n\n /* Interrupt execution to force deadline recalculation. */\n\n if (use_icount)\n\n qemu_notify_event();\n\n }\n\n}\n", + "output": "1", + "index": 3562 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)\n\n{\n\n struct in_addr host_addr = { .s_addr = INADDR_ANY };\n\n int host_port;\n\n char buf[256] = \"\";\n\n const char *src_str, *p;\n\n SlirpState *s;\n\n int is_udp = 0;\n\n int err;\n\n const char *arg1 = qdict_get_str(qdict, \"arg1\");\n\n const char *arg2 = qdict_get_try_str(qdict, \"arg2\");\n\n const char *arg3 = qdict_get_try_str(qdict, \"arg3\");\n\n\n\n if (arg2) {\n\n s = slirp_lookup(mon, arg1, arg2);\n\n src_str = arg3;\n\n } else {\n\n s = slirp_lookup(mon, NULL, NULL);\n\n src_str = arg1;\n\n }\n\n if (!s) {\n\n return;\n\n }\n\n\n\n if (!src_str || !src_str[0])\n\n goto fail_syntax;\n\n\n\n p = src_str;\n\n get_str_sep(buf, sizeof(buf), &p, ':');\n\n\n\n if (!strcmp(buf, \"tcp\") || buf[0] == '\\0') {\n\n is_udp = 0;\n\n } else if (!strcmp(buf, \"udp\")) {\n\n is_udp = 1;\n\n } else {\n\n goto fail_syntax;\n\n }\n\n\n\n if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {\n\n goto fail_syntax;\n\n }\n\n if (buf[0] != '\\0' && !inet_aton(buf, &host_addr)) {\n\n goto fail_syntax;\n\n }\n\n\n\n host_port = atoi(p);\n\n\n\n err = slirp_remove_hostfwd(TAILQ_FIRST(&slirp_stacks)->slirp, is_udp,\n\n host_addr, host_port);\n\n\n\n monitor_printf(mon, \"host forwarding rule for %s %s\\n\", src_str,\n\n err ? \"removed\" : \"not found\");\n\n return;\n\n\n\n fail_syntax:\n\n monitor_printf(mon, \"invalid format\\n\");\n\n}\n", + "output": "0", + "index": 12533 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_arch_set_tsc_khz(CPUState *cs)\n\n{\n\n X86CPU *cpu = X86_CPU(cs);\n\n CPUX86State *env = &cpu->env;\n\n int r;\n\n\n\n if (!env->tsc_khz) {\n\n return 0;\n\n }\n\n\n\n r = kvm_check_extension(cs->kvm_state, KVM_CAP_TSC_CONTROL) ?\n\n kvm_vcpu_ioctl(cs, KVM_SET_TSC_KHZ, env->tsc_khz) :\n\n -ENOTSUP;\n\n if (r < 0) {\n\n /* When KVM_SET_TSC_KHZ fails, it's an error only if the current\n\n * TSC frequency doesn't match the one we want.\n\n */\n\n int cur_freq = kvm_check_extension(cs->kvm_state, KVM_CAP_GET_TSC_KHZ) ?\n\n kvm_vcpu_ioctl(cs, KVM_GET_TSC_KHZ) :\n\n -ENOTSUP;\n\n if (cur_freq <= 0 || cur_freq != env->tsc_khz) {\n\n error_report(\"warning: TSC frequency mismatch between \"\n\n \"VM (%\" PRId64 \" kHz) and host (%d kHz), \"\n\n \"and TSC scaling unavailable\",\n\n env->tsc_khz, cur_freq);\n\n return r;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 20744 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ExitStatus trans_log(DisasContext *ctx, uint32_t insn,\n\n const DisasInsn *di)\n\n{\n\n unsigned r2 = extract32(insn, 21, 5);\n\n unsigned r1 = extract32(insn, 16, 5);\n\n unsigned cf = extract32(insn, 12, 4);\n\n unsigned rt = extract32(insn, 0, 5);\n\n TCGv tcg_r1, tcg_r2;\n\n ExitStatus ret;\n\n\n\n if (cf) {\n\n nullify_over(ctx);\n\n }\n\n tcg_r1 = load_gpr(ctx, r1);\n\n tcg_r2 = load_gpr(ctx, r2);\n\n ret = do_log(ctx, rt, tcg_r1, tcg_r2, cf, di->f_ttt);\n\n return nullify_end(ctx, ret);\n\n}\n", + "output": "1", + "index": 9091 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr,\n\n uint32_t token, uint32_t nargs,\n\n target_ulong args, uint32_t nret,\n\n target_ulong rets)\n\n{\n\n uint32_t sensor_type;\n\n uint32_t sensor_index;\n\n uint32_t sensor_state;\n\n uint32_t ret = RTAS_OUT_SUCCESS;\n\n sPAPRDRConnector *drc;\n\n sPAPRDRConnectorClass *drck;\n\n\n\n if (nargs != 3 || nret != 1) {\n\n ret = RTAS_OUT_PARAM_ERROR;\n\n goto out;\n\n }\n\n\n\n sensor_type = rtas_ld(args, 0);\n\n sensor_index = rtas_ld(args, 1);\n\n sensor_state = rtas_ld(args, 2);\n\n\n\n if (!sensor_type_is_dr(sensor_type)) {\n\n goto out_unimplemented;\n\n }\n\n\n\n /* if this is a DR sensor we can assume sensor_index == drc_index */\n\n drc = spapr_drc_by_index(sensor_index);\n\n if (!drc) {\n\n trace_spapr_rtas_set_indicator_invalid(sensor_index);\n\n ret = RTAS_OUT_PARAM_ERROR;\n\n goto out;\n\n }\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n\n\n switch (sensor_type) {\n\n case RTAS_SENSOR_TYPE_ISOLATION_STATE:\n\n ret = drck->set_isolation_state(drc, sensor_state);\n\n break;\n\n case RTAS_SENSOR_TYPE_DR:\n\n ret = drck->set_indicator_state(drc, sensor_state);\n\n break;\n\n case RTAS_SENSOR_TYPE_ALLOCATION_STATE:\n\n ret = drck->set_allocation_state(drc, sensor_state);\n\n break;\n\n default:\n\n goto out_unimplemented;\n\n }\n\n\n\nout:\n\n rtas_st(rets, 0, ret);\n\n return;\n\n\n\nout_unimplemented:\n\n /* currently only DR-related sensors are implemented */\n\n trace_spapr_rtas_set_indicator_not_supported(sensor_index, sensor_type);\n\n rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED);\n\n}\n", + "output": "0", + "index": 16918 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static enum AVPixelFormat webp_get_format(AVCodecContext *avctx,\n\n const enum AVPixelFormat *formats)\n\n{\n\n WebPContext *s = avctx->priv_data;\n\n if (s->has_alpha)\n\n return AV_PIX_FMT_YUVA420P;\n\n else\n\n return AV_PIX_FMT_YUV420P;\n\n}\n", + "output": "0", + "index": 15803 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size)\n{\n int i, x, y;\n i=0; x=0; y=0;\n while(iframe.data[0] + y*s->frame.linesize[0] + x, color, run_length);\n if (half_vert)\n memset(s->frame.data[0] + (y+1)*s->frame.linesize[0] + x, color, run_length);\n }\n x+= run_length;\n if (x >= s->avctx->width) {\n x=0;\n y += 1 + half_vert;\n }\n }\n}", + "output": "1", + "index": 20046 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int crc_write_header(struct AVFormatContext *s)\n\n{\n\n CRCState *crc = s->priv_data;\n\n\n\n /* init CRC */\n\n crc->crcval = adler32(0, NULL, 0);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4580 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dirac_probe(AVProbeData *p)\n\n{\n\n if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))\n\n return AVPROBE_SCORE_MAX;\n\n else\n\n return 0;\n\n}\n", + "output": "1", + "index": 15398 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtosz_trailing(void)\n\n{\n\n const char *str;\n\n char *endptr = NULL;\n\n int64_t res;\n\n\n\n str = \"123xxx\";\n\n res = qemu_strtosz_MiB(str, &endptr);\n\n g_assert_cmpint(res, ==, 123 * M_BYTE);\n\n g_assert(endptr == str + 3);\n\n\n\n res = qemu_strtosz(str, NULL);\n\n g_assert_cmpint(res, ==, -EINVAL);\n\n\n\n str = \"1kiB\";\n\n res = qemu_strtosz(str, &endptr);\n\n g_assert_cmpint(res, ==, 1024);\n\n g_assert(endptr == str + 2);\n\n\n\n res = qemu_strtosz(str, NULL);\n\n g_assert_cmpint(res, ==, -EINVAL);\n\n}\n", + "output": "0", + "index": 18108 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_chmod(FsContext *fs_ctx, const char *path, FsCred *credp)\n\n{\n\n if (fs_ctx->fs_sm == SM_MAPPED) {\n\n return local_set_xattr(rpath(fs_ctx, path), credp);\n\n } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {\n\n return chmod(rpath(fs_ctx, path), credp->fc_mode);\n\n }\n\n return -1;\n\n}\n", + "output": "1", + "index": 23673 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pl061_init(SysBusDevice *dev, const unsigned char *id)\n\n{\n\n int iomemtype;\n\n pl061_state *s = FROM_SYSBUS(pl061_state, dev);\n\n s->id = id;\n\n iomemtype = cpu_register_io_memory(pl061_readfn,\n\n pl061_writefn, s,\n\n DEVICE_NATIVE_ENDIAN);\n\n sysbus_init_mmio(dev, 0x1000, iomemtype);\n\n sysbus_init_irq(dev, &s->irq);\n\n qdev_init_gpio_in(&dev->qdev, pl061_set_irq, 8);\n\n qdev_init_gpio_out(&dev->qdev, s->out, 8);\n\n pl061_reset(s);\n\n register_savevm(&dev->qdev, \"pl061_gpio\", -1, 1, pl061_save, pl061_load, s);\n\n return 0;\n\n}\n", + "output": "0", + "index": 14933 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int spapr_nvram_init(VIOsPAPRDevice *dev)\n\n{\n\n sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev);\n\n\n\n if (nvram->drive) {\n\n nvram->size = bdrv_getlength(nvram->drive);\n\n } else {\n\n nvram->size = DEFAULT_NVRAM_SIZE;\n\n nvram->buf = g_malloc0(nvram->size);\n\n }\n\n\n\n if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) {\n\n fprintf(stderr, \"spapr-nvram must be between %d and %d bytes in size\\n\",\n\n MIN_NVRAM_SIZE, MAX_NVRAM_SIZE);\n\n return -1;\n\n }\n\n\n\n spapr_rtas_register(RTAS_NVRAM_FETCH, \"nvram-fetch\", rtas_nvram_fetch);\n\n spapr_rtas_register(RTAS_NVRAM_STORE, \"nvram-store\", rtas_nvram_store);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pci_qdev_register(PCIDeviceInfo *info)\n\n{\n\n info->qdev.init = pci_qdev_init;\n\n info->qdev.bus_type = BUS_TYPE_PCI;\n\n qdev_register(&info->qdev);\n\n}\n", + "output": "0", + "index": 20213 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)\n\n{\n\n int x, fmt = sono->format, w = sono->width;\n\n uint8_t *lpy = sono->data[0] + idx * sono->linesize[0];\n\n uint8_t *lpu = sono->data[1] + idx * sono->linesize[1];\n\n uint8_t *lpv = sono->data[2] + idx * sono->linesize[2];\n\n\n\n for (x = 0; x < w; x += 2) {\n\n *lpy++ = c[x].yuv.y + 0.5f;\n\n *lpu++ = c[x].yuv.u + 0.5f;\n\n *lpv++ = c[x].yuv.v + 0.5f;\n\n *lpy++ = c[x+1].yuv.y + 0.5f;\n\n if (fmt == AV_PIX_FMT_YUV444P) {\n\n *lpu++ = c[x+1].yuv.u + 0.5f;\n\n *lpv++ = c[x+1].yuv.v + 0.5f;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 1919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void aio_co_schedule(AioContext *ctx, Coroutine *co)\n{\n trace_aio_co_schedule(ctx, co);\n QSLIST_INSERT_HEAD_ATOMIC(&ctx->scheduled_coroutines,\n co, co_scheduled_next);\n qemu_bh_schedule(ctx->co_schedule_bh);", + "output": "1", + "index": 17194 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int default_qemu_set_fd_handler2(int fd,\n\n IOCanReadHandler *fd_read_poll,\n\n IOHandler *fd_read,\n\n IOHandler *fd_write,\n\n void *opaque)\n\n\n\n{\n\n abort();\n\n}\n", + "output": "0", + "index": 11920 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem,\n\n int i)\n\n{\n\n VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);\n\n hwaddr pa = offsetof(VRingUsed, ring[i]);\n\n virtio_tswap32s(vq->vdev, &uelem->id);\n\n virtio_tswap32s(vq->vdev, &uelem->len);\n\n address_space_write_cached(&caches->used, pa, uelem, sizeof(VRingUsedElem));\n\n address_space_cache_invalidate(&caches->used, pa, sizeof(VRingUsedElem));\n\n}\n", + "output": "1", + "index": 18478 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int con_init(struct XenDevice *xendev)\n\n{\n\n struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);\n\n char *type, *dom;\n\n int ret = 0;\n\n\n\n /* setup */\n\n dom = xs_get_domain_path(xenstore, con->xendev.dom);\n\n snprintf(con->console, sizeof(con->console), \"%s/console\", dom);\n\n free(dom);\n\n\n\n type = xenstore_read_str(con->console, \"type\");\n\n if (!type || strcmp(type, \"ioemu\") != 0) {\n\n\txen_be_printf(xendev, 1, \"not for me (type=%s)\\n\", type);\n\n ret = -1;\n\n goto out;\n\n }\n\n\n\n if (!serial_hds[con->xendev.dev])\n\n\txen_be_printf(xendev, 1, \"WARNING: serial line %d not configured\\n\",\n\n con->xendev.dev);\n\n else\n\n con->chr = serial_hds[con->xendev.dev];\n\n\n\nout:\n\n qemu_free(type);\n\n return ret;\n\n}\n", + "output": "0", + "index": 24596 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Object *object_dynamic_cast(Object *obj, const char *typename)\n\n{\n\n if (object_class_dynamic_cast(object_get_class(obj), typename)) {\n\n return obj;\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "1", + "index": 5922 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int socket_dgram(SocketAddressLegacy *remote, SocketAddressLegacy *local, Error **errp)\n\n{\n\n int fd;\n\n\n\n /*\n\n * TODO SOCKET_ADDRESS_LEGACY_KIND_FD when fd is AF_INET or AF_INET6\n\n * (although other address families can do SOCK_DGRAM, too)\n\n */\n\n switch (remote->type) {\n\n case SOCKET_ADDRESS_LEGACY_KIND_INET:\n\n fd = inet_dgram_saddr(remote->u.inet.data,\n\n local ? local->u.inet.data : NULL, errp);\n\n break;\n\n\n\n default:\n\n error_setg(errp, \"socket type unsupported for datagram\");\n\n fd = -1;\n\n }\n\n return fd;\n\n}\n", + "output": "0", + "index": 18748 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_gluster_reopen_prepare(BDRVReopenState *state,\n\n BlockReopenQueue *queue, Error **errp)\n\n{\n\n int ret = 0;\n\n BDRVGlusterReopenState *reop_s;\n\n GlusterConf *gconf = NULL;\n\n int open_flags = 0;\n\n\n\n assert(state != NULL);\n\n assert(state->bs != NULL);\n\n\n\n state->opaque = g_malloc0(sizeof(BDRVGlusterReopenState));\n\n reop_s = state->opaque;\n\n\n\n qemu_gluster_parse_flags(state->flags, &open_flags);\n\n\n\n gconf = g_malloc0(sizeof(GlusterConf));\n\n\n\n reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, errp);\n\n if (reop_s->glfs == NULL) {\n\n ret = -errno;\n\n goto exit;\n\n }\n\n\n\n reop_s->fd = glfs_open(reop_s->glfs, gconf->image, open_flags);\n\n if (reop_s->fd == NULL) {\n\n /* reops->glfs will be cleaned up in _abort */\n\n ret = -errno;\n\n goto exit;\n\n }\n\n\n\nexit:\n\n /* state->opaque will be freed in either the _abort or _commit */\n\n qemu_gluster_gconf_free(gconf);\n\n return ret;\n\n}\n", + "output": "1", + "index": 13435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qpci_msix_enable(QPCIDevice *dev)\n\n{\n\n uint8_t addr;\n\n uint16_t val;\n\n uint32_t table;\n\n uint8_t bir_table;\n\n uint8_t bir_pba;\n\n void *offset;\n\n\n\n addr = qpci_find_capability(dev, PCI_CAP_ID_MSIX);\n\n g_assert_cmphex(addr, !=, 0);\n\n\n\n val = qpci_config_readw(dev, addr + PCI_MSIX_FLAGS);\n\n qpci_config_writew(dev, addr + PCI_MSIX_FLAGS, val | PCI_MSIX_FLAGS_ENABLE);\n\n\n\n table = qpci_config_readl(dev, addr + PCI_MSIX_TABLE);\n\n bir_table = table & PCI_MSIX_FLAGS_BIRMASK;\n\n offset = qpci_iomap(dev, bir_table, NULL);\n\n dev->msix_table = offset + (table & ~PCI_MSIX_FLAGS_BIRMASK);\n\n\n\n table = qpci_config_readl(dev, addr + PCI_MSIX_PBA);\n\n bir_pba = table & PCI_MSIX_FLAGS_BIRMASK;\n\n if (bir_pba != bir_table) {\n\n offset = qpci_iomap(dev, bir_pba, NULL);\n\n }\n\n dev->msix_pba = offset + (table & ~PCI_MSIX_FLAGS_BIRMASK);\n\n\n\n g_assert(dev->msix_table != NULL);\n\n g_assert(dev->msix_pba != NULL);\n\n dev->msix_enabled = true;\n\n}\n", + "output": "1", + "index": 11494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_dpy_setdata(DisplayState *ds)\n\n{\n\n /* We don't have to do anything */\n\n}\n", + "output": "0", + "index": 14402 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_i440fx_2_4_machine_options(MachineClass *m)\n\n{\n\n PCMachineClass *pcmc = PC_MACHINE_CLASS(m);\n\n pc_i440fx_2_5_machine_options(m);\n\n m->alias = NULL;\n\n m->is_default = 0;\n\n pcmc->broken_reserved_end = true;\n\n pcmc->inter_dimm_gap = false;\n\n SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);\n\n}\n", + "output": "1", + "index": 14511 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vc1_h_overlap_c(uint8_t* src, int stride)\n\n{\n\n int i;\n\n int a, b, c, d;\n\n int d1, d2;\n\n int rnd = 1;\n\n for(i = 0; i < 8; i++) {\n\n a = src[-2];\n\n b = src[-1];\n\n c = src[0];\n\n d = src[1];\n\n d1 = (a - d + 3 + rnd) >> 3;\n\n d2 = (a - d + b - c + 4 - rnd) >> 3;\n\n\n\n src[-2] = a - d1;\n\n src[-1] = b - d2;\n\n src[0] = c + d2;\n\n src[1] = d + d1;\n\n src += stride;\n\n rnd = !rnd;\n\n }\n\n}\n", + "output": "1", + "index": 14826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)\n\n{\n\n AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));\n\n AVFilterBufferRef *ref = av_mallocz(sizeof(AVFilterBufferRef));\n\n int i, tempsize;\n\n char *buf;\n\n\n\n ref->buf = pic;\n\n ref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps));\n\n ref->video->w = w;\n\n ref->video->h = h;\n\n\n\n /* make sure the buffer gets read permission or it's useless for output */\n\n ref->perms = perms | AV_PERM_READ;\n\n\n\n pic->refcount = 1;\n\n ref->format = link->format;\n\n pic->free = avfilter_default_free_buffer;\n\n av_fill_image_linesizes(pic->linesize, ref->format, ref->video->w);\n\n\n\n for (i=0; i<4;i++)\n\n pic->linesize[i] = FFALIGN(pic->linesize[i], 16);\n\n\n\n tempsize = av_fill_image_pointers(pic->data, ref->format, ref->video->h, NULL, pic->linesize);\n\n buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be\n\n // SIMD-friendly\n\n av_fill_image_pointers(pic->data, ref->format, ref->video->h, buf, pic->linesize);\n\n\n\n memcpy(ref->data, pic->data, sizeof(ref->data));\n\n memcpy(ref->linesize, pic->linesize, sizeof(ref->linesize));\n\n\n\n return ref;\n\n}\n", + "output": "0", + "index": 7570 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void csrhci_reset(struct csrhci_s *s)\n\n{\n\n s->out_len = 0;\n\n s->out_size = FIFO_LEN;\n\n s->in_len = 0;\n\n s->baud_delay = NANOSECONDS_PER_SECOND;\n\n s->enable = 0;\n\n s->in_hdr = INT_MAX;\n\n s->in_data = INT_MAX;\n\n\n\n s->modem_state = 0;\n\n /* After a while... (but sooner than 10ms) */\n\n s->modem_state |= CHR_TIOCM_CTS;\n\n\n\n memset(&s->bd_addr, 0, sizeof(bdaddr_t));\n\n}\n", + "output": "1", + "index": 10847 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcp_chr_connect(void *opaque)\n\n{\n\n CharDriverState *chr = opaque;\n\n TCPCharDriver *s = chr->opaque;\n\n struct sockaddr_storage ss, ps;\n\n socklen_t ss_len = sizeof(ss), ps_len = sizeof(ps);\n\n\n\n memset(&ss, 0, ss_len);\n\n if (getsockname(s->fd, (struct sockaddr *) &ss, &ss_len) != 0) {\n\n snprintf(chr->filename, CHR_MAX_FILENAME_SIZE,\n\n \"Error in getsockname: %s\\n\", strerror(errno));\n\n } else if (getpeername(s->fd, (struct sockaddr *) &ps, &ps_len) != 0) {\n\n snprintf(chr->filename, CHR_MAX_FILENAME_SIZE,\n\n \"Error in getpeername: %s\\n\", strerror(errno));\n\n } else {\n\n sockaddr_to_str(chr->filename, CHR_MAX_FILENAME_SIZE,\n\n &ss, ss_len, &ps, ps_len,\n\n s->is_listen, s->is_telnet);\n\n }\n\n\n\n s->connected = 1;\n\n if (s->chan) {\n\n chr->fd_in_tag = io_add_watch_poll(s->chan, tcp_chr_read_poll,\n\n tcp_chr_read, chr);\n\n }\n\n qemu_chr_be_generic_open(chr);\n\n}\n", + "output": "0", + "index": 3854 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t pt_getxattr(FsContext *ctx, const char *path, const char *name,\n\n void *value, size_t size)\n\n{\n\n char *buffer;\n\n ssize_t ret;\n\n\n\n buffer = rpath(ctx, path);\n\n ret = lgetxattr(buffer, name, value, size);\n\n g_free(buffer);\n\n return ret;\n\n}\n", + "output": "1", + "index": 9899 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)\n\n{\n\n int compno;\n\n int x;\n\n int y;\n\n int *image_line;\n\n int frame_index;\n\n const int numcomps = image->numcomps;\n\n\n\n for (compno = 0; compno < numcomps; ++compno) {\n\n if (image->comps[compno].w > frame->linesize[0] / numcomps) {\n\n av_log(avctx, AV_LOG_ERROR, \"Error: frame's linesize is too small for the image\\n\");\n\n return 0;\n\n }\n\n }\n\n\n\n for (compno = 0; compno < numcomps; ++compno) {\n\n for (y = 0; y < avctx->height; ++y) {\n\n image_line = image->comps[compno].data + y * image->comps[compno].w;\n\n frame_index = y * frame->linesize[0] + compno;\n\n for (x = 0; x < avctx->width; ++x) {\n\n image_line[x] = frame->data[0][frame_index];\n\n frame_index += numcomps;\n\n }\n\n for (; x < image->comps[compno].w; ++x) {\n\n image_line[x] = image_line[x - 1];\n\n }\n\n }\n\n for (; y < image->comps[compno].h; ++y) {\n\n image_line = image->comps[compno].data + y * image->comps[compno].w;\n\n for (x = 0; x < image->comps[compno].w; ++x) {\n\n image_line[x] = image_line[x - image->comps[compno].w];\n\n }\n\n }\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 21594 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void boston_platreg_write(void *opaque, hwaddr addr,\n\n uint64_t val, unsigned size)\n\n{\n\n if (size != 4) {\n\n qemu_log_mask(LOG_UNIMP, \"%uB platform register write\", size);\n\n return;\n\n }\n\n\n\n switch (addr & 0xffff) {\n\n case PLAT_FPGA_BUILD:\n\n case PLAT_CORE_CL:\n\n case PLAT_WRAPPER_CL:\n\n case PLAT_DDR3_STATUS:\n\n case PLAT_PCIE_STATUS:\n\n case PLAT_MMCM_DIV:\n\n case PLAT_BUILD_CFG:\n\n case PLAT_DDR_CFG:\n\n /* read only */\n\n break;\n\n case PLAT_SOFTRST_CTL:\n\n if (val & PLAT_SOFTRST_CTL_SYSRESET) {\n\n qemu_system_reset_request();\n\n }\n\n break;\n\n default:\n\n qemu_log_mask(LOG_UNIMP, \"Write platform register 0x%\" HWADDR_PRIx\n\n \" = 0x%\" PRIx64, addr & 0xffff, val);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 9719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_config(BDRVBlkdebugState *s, const char *filename, Error **errp)\n\n{\n\n FILE *f;\n\n int ret;\n\n struct add_rule_data d;\n\n\n\n f = fopen(filename, \"r\");\n\n if (f == NULL) {\n\n error_setg_errno(errp, errno, \"Could not read blkdebug config file\");\n\n return -errno;\n\n }\n\n\n\n ret = qemu_config_parse(f, config_groups, filename);\n\n if (ret < 0) {\n\n error_setg(errp, \"Could not parse blkdebug config file\");\n\n ret = -EINVAL;\n\n goto fail;\n\n }\n\n\n\n d.s = s;\n\n d.action = ACTION_INJECT_ERROR;\n\n qemu_opts_foreach(&inject_error_opts, add_rule, &d, 0);\n\n\n\n d.action = ACTION_SET_STATE;\n\n qemu_opts_foreach(&set_state_opts, add_rule, &d, 0);\n\n\n\n ret = 0;\n\nfail:\n\n qemu_opts_reset(&inject_error_opts);\n\n qemu_opts_reset(&set_state_opts);\n\n fclose(f);\n\n return ret;\n\n}\n", + "output": "0", + "index": 18010 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void avc_luma_mid_16w_msa(const uint8_t *src, int32_t src_stride,\n\n uint8_t *dst, int32_t dst_stride,\n\n int32_t height)\n\n{\n\n uint32_t multiple8_cnt;\n\n\n\n for (multiple8_cnt = 2; multiple8_cnt--;) {\n\n avc_luma_mid_8w_msa(src, src_stride, dst, dst_stride, height);\n\n src += 8;\n\n dst += 8;\n\n }\n\n}\n", + "output": "0", + "index": 7922 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_drain_poll(BlockDriverState *bs)\n\n{\n\n bool waited = false;\n\n\n\n while (atomic_read(&bs->in_flight) > 0) {\n\n aio_poll(bdrv_get_aio_context(bs), true);\n\n waited = true;\n\n }\n\n return waited;\n\n}\n", + "output": "0", + "index": 9029 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)\n{\n AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(dev);\n acc->parent_realize(dev, errp);\n}", + "output": "1", + "index": 14698 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qht_entry_move(struct qht_bucket *to, int i, struct qht_bucket *from, int j)\n\n{\n\n qht_debug_assert(!(to == from && i == j));\n\n qht_debug_assert(to->pointers[i]);\n\n qht_debug_assert(from->pointers[j]);\n\n\n\n to->hashes[i] = from->hashes[j];\n\n atomic_set(&to->pointers[i], from->pointers[j]);\n\n\n\n from->hashes[j] = 0;\n\n atomic_set(&from->pointers[j], NULL);\n\n}\n", + "output": "1", + "index": 22030 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,\n\n Error **errp)\n\n{\n\n DeviceState *dev = DEVICE(obj);\n\n Error *local_err = NULL;\n\n Property *prop = opaque;\n\n CharBackend *be = qdev_get_prop_ptr(dev, prop);\n\n CharDriverState *s;\n\n char *str;\n\n\n\n if (dev->realized) {\n\n qdev_prop_set_after_realize(dev, name, errp);\n\n return;\n\n }\n\n\n\n visit_type_str(v, name, &str, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n if (!*str) {\n\n g_free(str);\n\n be->chr = NULL;\n\n return;\n\n }\n\n\n\n s = qemu_chr_find(str);\n\n g_free(str);\n\n if (s == NULL) {\n\n error_setg(errp, \"Property '%s.%s' can't find value '%s'\",\n\n object_get_typename(obj), prop->name, str);\n\n return;\n\n }\n\n\n\n if (!qemu_chr_fe_init(be, s, errp)) {\n\n error_prepend(errp, \"Property '%s.%s' can't take value '%s': \",\n\n object_get_typename(obj), prop->name, str);\n\n return;\n\n }\n\n}\n", + "output": "1", + "index": 13335 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void poll_set_started(AioContext *ctx, bool started)\n\n{\n\n AioHandler *node;\n\n\n\n if (started == ctx->poll_started) {\n\n return;\n\n }\n\n\n\n ctx->poll_started = started;\n\n\n\n qemu_lockcnt_inc(&ctx->list_lock);\n\n QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {\n\n IOHandler *fn;\n\n\n\n if (node->deleted) {\n\n continue;\n\n }\n\n\n\n if (started) {\n\n fn = node->io_poll_begin;\n\n } else {\n\n fn = node->io_poll_end;\n\n }\n\n\n\n if (fn) {\n\n fn(node->opaque);\n\n }\n\n }\n\n qemu_lockcnt_dec(&ctx->list_lock);\n\n}\n", + "output": "0", + "index": 8844 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num,\n\n int nb_sectors, QEMUIOVector *iov,\n\n bool is_write)\n\n{\n\n CoroutineIOCompletion co = {\n\n .coroutine = qemu_coroutine_self(),\n\n };\n\n BlockDriverAIOCB *acb;\n\n\n\n if (is_write) {\n\n acb = bdrv_aio_writev(bs, sector_num, iov, nb_sectors,\n\n bdrv_co_io_em_complete, &co);\n\n } else {\n\n acb = bdrv_aio_readv(bs, sector_num, iov, nb_sectors,\n\n bdrv_co_io_em_complete, &co);\n\n }\n\n\n\n trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);\n\n if (!acb) {\n\n return -EIO;\n\n }\n\n qemu_coroutine_yield();\n\n\n\n return co.ret;\n\n}\n", + "output": "0", + "index": 19496 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usbredir_post_load(void *priv, int version_id)\n{\n USBRedirDevice *dev = priv;\n switch (dev->device_info.speed) {\n case usb_redir_speed_low:\n dev->dev.speed = USB_SPEED_LOW;\n break;\n case usb_redir_speed_full:\n dev->dev.speed = USB_SPEED_FULL;\n break;\n case usb_redir_speed_high:\n dev->dev.speed = USB_SPEED_HIGH;\n break;\n case usb_redir_speed_super:\n dev->dev.speed = USB_SPEED_SUPER;\n break;\n default:\n dev->dev.speed = USB_SPEED_FULL;\n dev->dev.speedmask = (1 << dev->dev.speed);\n usbredir_setup_usb_eps(dev);\n usbredir_check_bulk_receiving(dev);", + "output": "1", + "index": 25079 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp)\n\n{\n\n unix_nonblocking_connect(path, unix_wait_for_connect, s, errp);\n\n}\n", + "output": "1", + "index": 24402 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pte64_check(struct mmu_ctx_hash64 *ctx, target_ulong pte0,\n\n target_ulong pte1, int h, int rw, int type)\n\n{\n\n target_ulong mmask;\n\n int access, ret, pp;\n\n\n\n ret = -1;\n\n /* Check validity and table match */\n\n if ((pte0 & HPTE64_V_VALID) && (h == !!(pte0 & HPTE64_V_SECONDARY))) {\n\n /* Check vsid & api */\n\n mmask = PTE64_CHECK_MASK;\n\n pp = (pte1 & HPTE64_R_PP) | ((pte1 & HPTE64_R_PP0) >> 61);\n\n /* No execute if either noexec or guarded bits set */\n\n ctx->nx = (pte1 & HPTE64_R_N) || (pte1 & HPTE64_R_G);\n\n if (HPTE64_V_COMPARE(pte0, ctx->ptem)) {\n\n if (ctx->raddr != (hwaddr)-1ULL) {\n\n /* all matches should have equal RPN, WIMG & PP */\n\n if ((ctx->raddr & mmask) != (pte1 & mmask)) {\n\n qemu_log(\"Bad RPN/WIMG/PP\\n\");\n\n return -3;\n\n }\n\n }\n\n /* Compute access rights */\n\n access = ppc_hash64_pp_check(ctx->key, pp, ctx->nx);\n\n /* Keep the matching PTE informations */\n\n ctx->raddr = pte1;\n\n ctx->prot = access;\n\n ret = ppc_hash64_check_prot(ctx->prot, rw, type);\n\n if (ret == 0) {\n\n /* Access granted */\n\n LOG_MMU(\"PTE access granted !\\n\");\n\n } else {\n\n /* Access right violation */\n\n LOG_MMU(\"PTE access rejected\\n\");\n\n }\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 11926 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void opt_mb_qmax(const char *arg)\n\n{\n\n video_mb_qmax = atoi(arg);\n\n if (video_mb_qmax < 0 ||\n\n video_mb_qmax > 31) {\n\n fprintf(stderr, \"qmax must be >= 1 and <= 31\\n\");\n\n exit(1);\n\n }\n\n}\n", + "output": "0", + "index": 14873 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int create_ppc_opcodes (CPUPPCState *env, ppc_def_t *def)\n\n{\n\n opcode_t *opc, *start, *end;\n\n\n\n fill_new_table(env->opcodes, 0x40);\n\n#if defined(PPC_DUMP_CPU)\n\n printf(\"* PowerPC instructions for PVR %08x: %s flags %016\" PRIx64\n\n \" %08x\\n\",\n\n def->pvr, def->name, def->insns_flags, def->flags);\n\n#endif\n\n if (&opc_start < &opc_end) {\n\n start = &opc_start;\n\n end = &opc_end;\n\n } else {\n\n start = &opc_end;\n\n end = &opc_start;\n\n }\n\n for (opc = start + 1; opc != end; opc++) {\n\n if ((opc->handler.type & def->insns_flags) != 0) {\n\n if (register_insn(env->opcodes, opc) < 0) {\n\n printf(\"*** ERROR initializing PowerPC instruction \"\n\n \"0x%02x 0x%02x 0x%02x\\n\", opc->opc1, opc->opc2,\n\n opc->opc3);\n\n return -1;\n\n }\n\n#if defined(PPC_DUMP_CPU)\n\n if (opc1 != 0x00) {\n\n if (opc->opc3 == 0xFF) {\n\n if (opc->opc2 == 0xFF) {\n\n printf(\" %02x -- -- (%2d ----) : %s\\n\",\n\n opc->opc1, opc->opc1, opc->oname);\n\n } else {\n\n printf(\" %02x %02x -- (%2d %4d) : %s\\n\",\n\n opc->opc1, opc->opc2, opc->opc1, opc->opc2,\n\n opc->oname);\n\n }\n\n } else {\n\n printf(\" %02x %02x %02x (%2d %4d) : %s\\n\",\n\n opc->opc1, opc->opc2, opc->opc3,\n\n opc->opc1, (opc->opc3 << 5) | opc->opc2,\n\n opc->oname);\n\n }\n\n }\n\n#endif\n\n }\n\n }\n\n fix_opcode_tables(env->opcodes);\n\n fflush(stdout);\n\n fflush(stderr);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 166 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_set_fd_handler2(int fd,\n\n IOCanReadHandler *fd_read_poll,\n\n IOHandler *fd_read,\n\n IOHandler *fd_write,\n\n void *opaque)\n\n{\n\n IOHandlerRecord *ioh;\n\n\n\n assert(fd >= 0);\n\n\n\n if (!fd_read && !fd_write) {\n\n QLIST_FOREACH(ioh, &io_handlers, next) {\n\n if (ioh->fd == fd) {\n\n ioh->deleted = 1;\n\n break;\n\n }\n\n }\n\n } else {\n\n QLIST_FOREACH(ioh, &io_handlers, next) {\n\n if (ioh->fd == fd)\n\n goto found;\n\n }\n\n ioh = g_malloc0(sizeof(IOHandlerRecord));\n\n QLIST_INSERT_HEAD(&io_handlers, ioh, next);\n\n found:\n\n ioh->fd = fd;\n\n ioh->fd_read_poll = fd_read_poll;\n\n ioh->fd_read = fd_read;\n\n ioh->fd_write = fd_write;\n\n ioh->opaque = opaque;\n\n ioh->pollfds_idx = -1;\n\n ioh->deleted = 0;\n\n qemu_notify_event();\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 23611 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void interface_set_client_capabilities(QXLInstance *sin,\n uint8_t client_present,\n uint8_t caps[58])\n{\n PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);\n qxl->shadow_rom.client_present = client_present;\n memcpy(qxl->shadow_rom.client_capabilities, caps, sizeof(caps));\n qxl->rom->client_present = client_present;\n memcpy(qxl->rom->client_capabilities, caps, sizeof(caps));\n qxl_rom_set_dirty(qxl);\n qxl_send_events(qxl, QXL_INTERRUPT_CLIENT);", + "output": "1", + "index": 5751 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool guest_validate_base(unsigned long guest_base)\n\n{\n\n return 1;\n\n}\n", + "output": "1", + "index": 6546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pic_common_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->vmsd = &vmstate_pic_common;\n\n dc->no_user = 1;\n\n dc->props = pic_properties_common;\n\n dc->realize = pic_common_realize;\n\n}\n", + "output": "1", + "index": 19730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "mst_fpga_readb(void *opaque, target_phys_addr_t addr)\n\n{\n\n\tmst_irq_state *s = (mst_irq_state *) opaque;\n\n\n\n\tswitch (addr) {\n\n\tcase MST_LEDDAT1:\n\n\t\treturn s->leddat1;\n\n\tcase MST_LEDDAT2:\n\n\t\treturn s->leddat2;\n\n\tcase MST_LEDCTRL:\n\n\t\treturn s->ledctrl;\n\n\tcase MST_GPSWR:\n\n\t\treturn s->gpswr;\n\n\tcase MST_MSCWR1:\n\n\t\treturn s->mscwr1;\n\n\tcase MST_MSCWR2:\n\n\t\treturn s->mscwr2;\n\n\tcase MST_MSCWR3:\n\n\t\treturn s->mscwr3;\n\n\tcase MST_MSCRD:\n\n\t\treturn s->mscrd;\n\n\tcase MST_INTMSKENA:\n\n\t\treturn s->intmskena;\n\n\tcase MST_INTSETCLR:\n\n\t\treturn s->intsetclr;\n\n\tcase MST_PCMCIA0:\n\n\t\treturn s->pcmcia0;\n\n\tcase MST_PCMCIA1:\n\n\t\treturn s->pcmcia1;\n\n\tdefault:\n\n\t\tprintf(\"Mainstone - mst_fpga_readb: Bad register offset \"\n\n\t\t\t\"0x\" TARGET_FMT_plx \" \\n\", addr);\n\n\t}\n\n\treturn 0;\n\n}\n", + "output": "0", + "index": 11631 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xscom_write(void *opaque, hwaddr addr, uint64_t val,\n\n unsigned width)\n\n{\n\n PnvChip *chip = opaque;\n\n uint32_t pcba = pnv_xscom_pcba(chip, addr);\n\n MemTxResult result;\n\n\n\n /* Handle some SCOMs here before dispatch */\n\n if (xscom_write_default(chip, pcba, val)) {\n\n goto complete;\n\n }\n\n\n\n address_space_stq(&chip->xscom_as, pcba << 3, val, MEMTXATTRS_UNSPECIFIED,\n\n &result);\n\n if (result != MEMTX_OK) {\n\n qemu_log_mask(LOG_GUEST_ERROR, \"XSCOM write failed at @0x%\"\n\n HWADDR_PRIx \" pcba=0x%08x data=0x%\" PRIx64 \"\\n\",\n\n addr, pcba, val);\n\n xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);\n\n return;\n\n }\n\n\n\ncomplete:\n\n xscom_complete(current_cpu, HMER_XSCOM_DONE);\n\n}\n", + "output": "1", + "index": 11744 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_frame_ilbm(AVCodecContext *avctx,\n\n void *data, int *data_size,\n\n AVPacket *avpkt)\n\n{\n\n IffContext *s = avctx->priv_data;\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n const uint8_t *buf_end = buf+buf_size;\n\n int y, plane;\n\n\n\n if (avctx->reget_buffer(avctx, &s->frame) < 0){\n\n av_log(avctx, AV_LOG_ERROR, \"get_buffer() failed\\n\");\n\n return -1;\n\n }\n\n\n\n for(y = 0; y < avctx->height; y++ ) {\n\n uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];\n\n memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4));\n\n for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) {\n\n if (avctx->pix_fmt == PIX_FMT_PAL8) {\n\n decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane);\n\n } else { // PIX_FMT_BGR32\n\n decodeplane32(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane);\n\n }\n\n buf += s->planesize;\n\n }\n\n }\n\n\n\n *data_size = sizeof(AVFrame);\n\n *(AVFrame*)data = s->frame;\n\n return buf_size;\n\n}\n", + "output": "0", + "index": 22014 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ppc_get_compat_smt_threads(PowerPCCPU *cpu)\n\n{\n\n int ret = smp_threads;\n\n PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);\n\n\n\n switch (cpu->cpu_version) {\n\n case CPU_POWERPC_LOGICAL_2_05:\n\n ret = 2;\n\n break;\n\n case CPU_POWERPC_LOGICAL_2_06:\n\n ret = 4;\n\n break;\n\n case CPU_POWERPC_LOGICAL_2_07:\n\n ret = 8;\n\n break;\n\n default:\n\n if (pcc->pcr_mask & PCR_COMPAT_2_06) {\n\n ret = 4;\n\n } else if (pcc->pcr_mask & PCR_COMPAT_2_05) {\n\n ret = 2;\n\n }\n\n break;\n\n }\n\n\n\n return MIN(ret, smp_threads);\n\n}\n", + "output": "0", + "index": 9380 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void vring_used_idx_set(VirtQueue *vq, uint16_t val)\n\n{\n\n VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);\n\n hwaddr pa = offsetof(VRingUsed, idx);\n\n virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val);\n\n address_space_cache_invalidate(&caches->used, pa, sizeof(val));\n\n vq->used_idx = val;\n\n}\n", + "output": "1", + "index": 9284 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ftp_store(FTPContext *s)\n\n{\n\n char command[CONTROL_BUFFER_SIZE];\n\n const int stor_codes[] = {150, 0};\n\n\n\n snprintf(command, sizeof(command), \"STOR %s\\r\\n\", s->path);\n\n if (!ftp_send_command(s, command, stor_codes, NULL))\n\n return AVERROR(EIO);\n\n\n\n s->state = UPLOADING;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22656 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,\n\n void *s, void *sp)\n\n{\n\n DPRINTF(\"CURL (AIO): Sock action %d on fd %d\\n\", action, fd);\n\n switch (action) {\n\n case CURL_POLL_IN:\n\n qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, s);\n\n break;\n\n case CURL_POLL_OUT:\n\n qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, s);\n\n break;\n\n case CURL_POLL_INOUT:\n\n qemu_aio_set_fd_handler(fd, curl_multi_do, curl_multi_do, s);\n\n break;\n\n case CURL_POLL_REMOVE:\n\n qemu_aio_set_fd_handler(fd, NULL, NULL, NULL);\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 5306 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_nested_struct(gconstpointer opaque)\n\n{\n\n TestArgs *args = (TestArgs *) opaque;\n\n const SerializeOps *ops = args->ops;\n\n UserDefNested *udnp = nested_struct_create();\n\n UserDefNested *udnp_copy = NULL;\n\n Error *err = NULL;\n\n void *serialize_data;\n\n \n\n ops->serialize(udnp, &serialize_data, visit_nested_struct, &err);\n\n ops->deserialize((void **)&udnp_copy, serialize_data, visit_nested_struct, &err); \n\n\n\n g_assert(err == NULL);\n\n nested_struct_compare(udnp, udnp_copy);\n\n\n\n nested_struct_cleanup(udnp);\n\n nested_struct_cleanup(udnp_copy);\n\n\n\n ops->cleanup(serialize_data);\n\n g_free(args);\n\n}\n", + "output": "0", + "index": 1846 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_ue_code(GetBitContext *gb, int order)\n\n{\n\n if (order) {\n\n int ret = get_ue_golomb(gb) << order;\n\n return ret + get_bits(gb, order);\n\n }\n\n return get_ue_golomb(gb);\n\n}\n", + "output": "1", + "index": 1393 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_set_boot_mask(int net_boot_mask)\n\n{\n\n int i;\n\n\n\n /* Only the first four NICs may be bootable */\n\n net_boot_mask = net_boot_mask & 0xF;\n\n\n\n for (i = 0; i < nb_nics; i++) {\n\n if (net_boot_mask & (1 << i)) {\n\n net_boot_mask &= ~(1 << i);\n\n }\n\n }\n\n\n\n if (net_boot_mask) {\n\n fprintf(stderr, \"Cannot boot from non-existent NIC\\n\");\n\n exit(1);\n\n }\n\n}\n", + "output": "0", + "index": 7314 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_system_killed(int signal, pid_t pid)\n\n{\n\n shutdown_signal = signal;\n\n shutdown_pid = pid;\n\n no_shutdown = 0;\n\n qemu_system_shutdown_request();\n\n}\n", + "output": "0", + "index": 14222 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*init)(struct CharDriverState *s))\n\n{\n\n const char *p;\n\n CharDriverState *chr;\n\n QemuOpts *opts;\n\n Error *err = NULL;\n\n\n\n if (strstart(filename, \"chardev:\", &p)) {\n\n return qemu_chr_find(p);\n\n }\n\n\n\n opts = qemu_chr_parse_compat(label, filename);\n\n if (!opts)\n\n return NULL;\n\n\n\n chr = qemu_chr_new_from_opts(opts, init, &err);\n\n if (err) {\n\n error_report_err(err);\n\n }\n\n if (chr && qemu_opt_get_bool(opts, \"mux\", 0)) {\n\n qemu_chr_fe_claim_no_fail(chr);\n\n monitor_init(chr, MONITOR_USE_READLINE);\n\n }\n\n return chr;\n\n}\n", + "output": "0", + "index": 7481 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int posix_aio_process_queue(void *opaque)\n\n{\n\n PosixAioState *s = opaque;\n\n struct qemu_paiocb *acb, **pacb;\n\n int ret;\n\n int result = 0;\n\n int async_context_id = get_async_context_id();\n\n\n\n for(;;) {\n\n pacb = &s->first_aio;\n\n for(;;) {\n\n acb = *pacb;\n\n if (!acb)\n\n return result;\n\n\n\n /* we're only interested in requests in the right context */\n\n if (acb->async_context_id != async_context_id) {\n\n pacb = &acb->next;\n\n continue;\n\n }\n\n\n\n ret = qemu_paio_error(acb);\n\n if (ret == ECANCELED) {\n\n /* remove the request */\n\n *pacb = acb->next;\n\n qemu_aio_release(acb);\n\n result = 1;\n\n } else if (ret != EINPROGRESS) {\n\n /* end of aio */\n\n if (ret == 0) {\n\n ret = qemu_paio_return(acb);\n\n if (ret == acb->aio_nbytes)\n\n ret = 0;\n\n else\n\n ret = -EINVAL;\n\n } else {\n\n ret = -ret;\n\n }\n\n\n\n trace_paio_complete(acb, acb->common.opaque, ret);\n\n\n\n /* remove the request */\n\n *pacb = acb->next;\n\n /* call the callback */\n\n acb->common.cb(acb->common.opaque, ret);\n\n qemu_aio_release(acb);\n\n result = 1;\n\n break;\n\n } else {\n\n pacb = &acb->next;\n\n }\n\n }\n\n }\n\n\n\n return result;\n\n}\n", + "output": "0", + "index": 16732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void report_unavailable_features(FeatureWord w, uint32_t mask)\n\n{\n\n FeatureWordInfo *f = &feature_word_info[w];\n\n int i;\n\n\n\n for (i = 0; i < 32; ++i) {\n\n if ((1UL << i) & mask) {\n\n const char *reg = get_register_name_32(f->cpuid_reg);\n\n assert(reg);\n\n fprintf(stderr, \"warning: %s doesn't support requested feature: \"\n\n \"CPUID.%02XH:%s%s%s [bit %d]\\n\",\n\n kvm_enabled() ? \"host\" : \"TCG\",\n\n f->cpuid_eax, reg,\n\n f->feat_names[i] ? \".\" : \"\",\n\n f->feat_names[i] ? f->feat_names[i] : \"\", i);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 12443 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n RamDevice *d;\n\n\n\n /* allocate RAM */\n\n dev = qdev_create(NULL, \"memory\");\n\n s = sysbus_from_qdev(dev);\n\n\n\n d = FROM_SYSBUS(RamDevice, s);\n\n d->size = RAM_size;\n\n qdev_init(dev);\n\n\n\n sysbus_mmio_map(s, 0, addr);\n\n}\n", + "output": "1", + "index": 9443 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Object *qio_task_get_source(QIOTask *task)\n\n{\n\n object_ref(task->source);\n\n return task->source;\n\n}\n", + "output": "1", + "index": 25939 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int main(void)\n\n{\n\n int nf;\n\n Suite *s;\n\n SRunner *sr;\n\n\n\n s = qfloat_suite();\n\n sr = srunner_create(s);\n\n\n\n srunner_run_all(sr, CK_NORMAL);\n\n nf = srunner_ntests_failed(sr);\n\n srunner_free(sr);\n\n\n\n return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;\n\n}\n", + "output": "0", + "index": 1487 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_disable_command(const char *name)\n\n{\n\n QmpCommand *cmd;\n\n\n\n QTAILQ_FOREACH(cmd, &qmp_commands, node) {\n\n if (strcmp(cmd->name, name) == 0) {\n\n cmd->enabled = false;\n\n return;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 25546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)\n\n{\n\n uint8_t val;\n\n if (addr <= sizeof(s->mem) - sizeof(val)) {\n\n memcpy(&val, &s->mem[addr], sizeof(val));\n\n }\n\n\n\n switch (addr) {\n\n case SCBStatus:\n\n case SCBAck:\n\n TRACE(OTHER, logout(\"addr=%s val=0x%02x\\n\", regname(addr), val));\n\n break;\n\n case SCBCmd:\n\n TRACE(OTHER, logout(\"addr=%s val=0x%02x\\n\", regname(addr), val));\n\n#if 0\n\n val = eepro100_read_command(s);\n\n#endif\n\n break;\n\n case SCBIntmask:\n\n TRACE(OTHER, logout(\"addr=%s val=0x%02x\\n\", regname(addr), val));\n\n break;\n\n case SCBPort + 3:\n\n TRACE(OTHER, logout(\"addr=%s val=0x%02x\\n\", regname(addr), val));\n\n break;\n\n case SCBeeprom:\n\n val = eepro100_read_eeprom(s);\n\n break;\n\n case SCBpmdr: /* Power Management Driver Register */\n\n val = 0;\n\n TRACE(OTHER, logout(\"addr=%s val=0x%02x\\n\", regname(addr), val));\n\n break;\n\n case SCBgstat: /* General Status Register */\n\n /* 100 Mbps full duplex, valid link */\n\n val = 0x07;\n\n TRACE(OTHER, logout(\"addr=General Status val=%02x\\n\", val));\n\n break;\n\n default:\n\n logout(\"addr=%s val=0x%02x\\n\", regname(addr), val);\n\n missing(\"unknown byte read\");\n\n }\n\n return val;\n\n}\n", + "output": "1", + "index": 14461 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int AUD_write (SWVoiceOut *sw, void *buf, int size)\n\n{\n\n int bytes;\n\n\n\n if (!sw) {\n\n /* XXX: Consider options */\n\n return size;\n\n }\n\n\n\n if (!sw->hw->enabled) {\n\n dolog (\"Writing to disabled voice %s\\n\", SW_NAME (sw));\n\n return 0;\n\n }\n\n\n\n bytes = sw->hw->pcm_ops->write (sw, buf, size);\n\n return bytes;\n\n}\n", + "output": "0", + "index": 19958 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void terrier_init(int ram_size, int vga_ram_size, int boot_device,\n\n DisplayState *ds, const char **fd_filename, int snapshot,\n\n const char *kernel_filename, const char *kernel_cmdline,\n\n const char *initrd_filename, const char *cpu_model)\n\n{\n\n spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename,\n\n kernel_cmdline, initrd_filename, terrier, 0x33f);\n\n}\n", + "output": "0", + "index": 20973 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rdma_source_init(RDMAContext *rdma, Error **errp, bool pin_all)\n\n{\n\n int ret, idx;\n\n Error *local_err = NULL, **temp = &local_err;\n\n\n\n /*\n\n * Will be validated against destination's actual capabilities\n\n * after the connect() completes.\n\n */\n\n rdma->pin_all = pin_all;\n\n\n\n ret = qemu_rdma_resolve_host(rdma, temp);\n\n if (ret) {\n\n goto err_rdma_source_init;\n\n }\n\n\n\n ret = qemu_rdma_alloc_pd_cq(rdma);\n\n if (ret) {\n\n ERROR(temp, \"rdma migration: error allocating pd and cq! Your mlock()\"\n\n \" limits may be too low. Please check $ ulimit -a # and \"\n\n \"search for 'ulimit -l' in the output\");\n\n goto err_rdma_source_init;\n\n }\n\n\n\n ret = qemu_rdma_alloc_qp(rdma);\n\n if (ret) {\n\n ERROR(temp, \"rdma migration: error allocating qp!\");\n\n goto err_rdma_source_init;\n\n }\n\n\n\n ret = qemu_rdma_init_ram_blocks(rdma);\n\n if (ret) {\n\n ERROR(temp, \"rdma migration: error initializing ram blocks!\");\n\n goto err_rdma_source_init;\n\n }\n\n\n\n for (idx = 0; idx < RDMA_WRID_MAX; idx++) {\n\n ret = qemu_rdma_reg_control(rdma, idx);\n\n if (ret) {\n\n ERROR(temp, \"rdma migration: error registering %d control!\",\n\n idx);\n\n goto err_rdma_source_init;\n\n }\n\n }\n\n\n\n return 0;\n\n\n\nerr_rdma_source_init:\n\n error_propagate(errp, local_err);\n\n qemu_rdma_cleanup(rdma);\n\n return -1;\n\n}\n", + "output": "1", + "index": 21378 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t getutime(void)\n\n{\n\n#ifdef HAVE_GETRUSAGE\n\n struct rusage rusage;\n\n\n\n getrusage(RUSAGE_SELF, &rusage);\n\n return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;\n\n#elif defined(__MINGW32__)\n\n return av_gettime();\n\n#endif\n\n}\n", + "output": "0", + "index": 24020 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void migration_fd_process_incoming(QEMUFile *f)\n\n{\n\n Coroutine *co = qemu_coroutine_create(process_incoming_migration_co);\n\n\n\n migrate_decompress_threads_create();\n\n qemu_file_set_blocking(f, false);\n\n qemu_coroutine_enter(co, f);\n\n}\n", + "output": "1", + "index": 10467 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int shorten_decode_close(AVCodecContext *avctx)\n\n{\n\n ShortenContext *s = avctx->priv_data;\n\n int i;\n\n\n\n for (i = 0; i < s->channels; i++) {\n\n s->decoded[i] -= s->nwrap;\n\n av_freep(&s->decoded[i]);\n\n av_freep(&s->offset[i]);\n\n }\n\n av_freep(&s->bitstream);\n\n av_freep(&s->coeffs);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 25672 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_bit(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n DeviceState *dev = DEVICE(obj);\n\n Property *prop = opaque;\n\n Error *local_err = NULL;\n\n bool value;\n\n\n\n if (dev->realized) {\n\n qdev_prop_set_after_realize(dev, name, errp);\n\n return;\n\n }\n\n\n\n visit_type_bool(v, &value, name, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n bit_prop_set(dev, prop, value);\n\n}\n", + "output": "0", + "index": 22066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr,\n\n unsigned int *num_sg, unsigned int max_size,\n\n int is_write)\n\n{\n\n unsigned int i;\n\n hwaddr len;\n\n\n\n /* Note: this function MUST validate input, some callers\n\n * are passing in num_sg values received over the network.\n\n */\n\n /* TODO: teach all callers that this can fail, and return failure instead\n\n * of asserting here.\n\n * When we do, we might be able to re-enable NDEBUG below.\n\n */\n\n#ifdef NDEBUG\n\n#error building with NDEBUG is not supported\n\n#endif\n\n assert(*num_sg <= max_size);\n\n\n\n for (i = 0; i < *num_sg; i++) {\n\n len = sg[i].iov_len;\n\n sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write);\n\n if (!sg[i].iov_base) {\n\n error_report(\"virtio: error trying to map MMIO memory\");\n\n exit(1);\n\n }\n\n if (len != sg[i].iov_len) {\n\n error_report(\"virtio: unexpected memory split\");\n\n exit(1);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 16302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)\n\n{\n\n VReaderList *reader_list = vreader_get_reader_list();\n\n VReaderListEntry *current_entry = NULL;\n\n\n\n if (reader_list == NULL) {\n\n return NULL;\n\n }\n\n for (current_entry = vreader_list_get_first(reader_list); current_entry;\n\n current_entry = vreader_list_get_next(current_entry)) {\n\n VReader *reader = vreader_list_get_reader(current_entry);\n\n VReaderEmul *reader_emul = vreader_get_private(reader);\n\n if (reader_emul->slot == slot) {\n\n vreader_list_delete(reader_list);\n\n return reader;\n\n }\n\n vreader_free(reader);\n\n }\n\n\n\n vreader_list_delete(reader_list);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 14544 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *error_get_pretty(Error *err)\n\n{\n\n return err->msg;\n\n}\n", + "output": "1", + "index": 25192 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,\n\n uint32_t slb_pshift, bool secondary,\n\n target_ulong ptem, ppc_hash_pte64_t *pte)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n int i;\n\n uint64_t token;\n\n target_ulong pte0, pte1;\n\n target_ulong pte_index;\n\n\n\n pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;\n\n token = ppc_hash64_start_access(cpu, pte_index);\n\n if (!token) {\n\n return -1;\n\n }\n\n for (i = 0; i < HPTES_PER_GROUP; i++) {\n\n pte0 = ppc_hash64_load_hpte0(cpu, token, i);\n\n pte1 = ppc_hash64_load_hpte1(cpu, token, i);\n\n\n\n if ((pte0 & HPTE64_V_VALID)\n\n && (secondary == !!(pte0 & HPTE64_V_SECONDARY))\n\n && HPTE64_V_COMPARE(pte0, ptem)) {\n\n uint32_t pshift = ppc_hash64_pte_size_decode(pte1, slb_pshift);\n\n if (pshift == 0) {\n\n continue;\n\n }\n\n /* We don't do anything with pshift yet as qemu TLB only deals\n\n * with 4K pages anyway\n\n */\n\n pte->pte0 = pte0;\n\n pte->pte1 = pte1;\n\n ppc_hash64_stop_access(cpu, token);\n\n return (pte_index + i) * HASH_PTE_SIZE_64;\n\n }\n\n }\n\n ppc_hash64_stop_access(cpu, token);\n\n /*\n\n * We didn't find a valid entry.\n\n */\n\n return -1;\n\n}\n", + "output": "1", + "index": 22989 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,\n\n int64_t sector)\n\n{\n\n if (bitmap) {\n\n return hbitmap_get(bitmap->bitmap, sector);\n\n } else {\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 9373 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_frame_distances(MpegEncContext * s){\n\n assert(s->current_picture_ptr->f.pts != AV_NOPTS_VALUE);\n\n s->time = s->current_picture_ptr->f.pts * s->avctx->time_base.num;\n\n\n\n if(s->pict_type==AV_PICTURE_TYPE_B){\n\n s->pb_time= s->pp_time - (s->last_non_b_time - s->time);\n\n assert(s->pb_time > 0 && s->pb_time < s->pp_time);\n\n }else{\n\n s->pp_time= s->time - s->last_non_b_time;\n\n s->last_non_b_time= s->time;\n\n assert(s->picture_number==0 || s->pp_time > 0);\n\n }\n\n}\n", + "output": "1", + "index": 7147 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,\n\n uint32_t node, bool dedicated_hp_event_source,\n\n Error **errp)\n\n{\n\n sPAPRDRConnector *drc;\n\n sPAPRDRConnectorClass *drck;\n\n uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;\n\n int i, fdt_offset, fdt_size;\n\n void *fdt;\n\n uint64_t addr = addr_start;\n\n\n\n for (i = 0; i < nr_lmbs; i++) {\n\n drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n addr/SPAPR_MEMORY_BLOCK_SIZE);\n\n g_assert(drc);\n\n\n\n fdt = create_device_tree(&fdt_size);\n\n fdt_offset = spapr_populate_memory_node(fdt, node, addr,\n\n SPAPR_MEMORY_BLOCK_SIZE);\n\n\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);\n\n addr += SPAPR_MEMORY_BLOCK_SIZE;\n\n\n\n\n\n\n\n /* send hotplug notification to the\n\n * guest only in case of hotplugged memory\n\n */\n\n if (dev->hotplugged) {\n\n if (dedicated_hp_event_source) {\n\n drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n addr_start / SPAPR_MEMORY_BLOCK_SIZE);\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n nr_lmbs,\n\n drck->get_index(drc));\n\n } else {\n\n spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n nr_lmbs);\n\n\n", + "output": "1", + "index": 14617 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int ff_nvenc_encode_init(AVCodecContext *avctx)\n\n{\n\n int ret;\n\n\n\n if ((ret = nvenc_load_libraries(avctx)) < 0)\n\n return ret;\n\n\n\n if ((ret = nvenc_setup_device(avctx)) < 0)\n\n return ret;\n\n\n\n if ((ret = nvenc_setup_encoder(avctx)) < 0)\n\n return ret;\n\n\n\n if ((ret = nvenc_setup_surfaces(avctx)) < 0)\n\n return ret;\n\n\n\n if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {\n\n if ((ret = nvenc_setup_extradata(avctx)) < 0)\n\n return ret;\n\n }\n\n\n\n avctx->coded_frame = av_frame_alloc();\n\n if (!avctx->coded_frame)\n\n return AVERROR(ENOMEM);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13146 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void scsi_req_cancel(SCSIRequest *req)\n\n{\n\n trace_scsi_req_cancel(req->dev->id, req->lun, req->tag);\n\n if (!req->enqueued) {\n\n return;\n\n }\n\n scsi_req_ref(req);\n\n scsi_req_dequeue(req);\n\n req->io_canceled = true;\n\n if (req->aiocb) {\n\n bdrv_aio_cancel(req->aiocb);\n\n }\n\n}\n", + "output": "0", + "index": 8964 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void connex_init(ram_addr_t ram_size, int vga_ram_size,\n\n const char *boot_device,\n\n const char *kernel_filename, const char *kernel_cmdline,\n\n const char *initrd_filename, const char *cpu_model)\n\n{\n\n struct pxa2xx_state_s *cpu;\n\n int index;\n\n\n\n uint32_t connex_rom = 0x01000000;\n\n uint32_t connex_ram = 0x04000000;\n\n\n\n if (ram_size < (connex_ram + connex_rom + PXA2XX_INTERNAL_SIZE)) {\n\n fprintf(stderr, \"This platform requires %i bytes of memory\\n\",\n\n connex_ram + connex_rom + PXA2XX_INTERNAL_SIZE);\n\n exit(1);\n\n }\n\n\n\n cpu = pxa255_init(connex_ram);\n\n\n\n index = drive_get_index(IF_PFLASH, 0, 0);\n\n if (index == -1) {\n\n fprintf(stderr, \"A flash image must be given with the \"\n\n \"'pflash' parameter\\n\");\n\n exit(1);\n\n }\n\n\n\n if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(connex_rom),\n\n drives_table[index].bdrv, sector_len, connex_rom / sector_len,\n\n 2, 0, 0, 0, 0)) {\n\n fprintf(stderr, \"qemu: Error registering flash memory.\\n\");\n\n exit(1);\n\n }\n\n\n\n cpu->env->regs[15] = 0x00000000;\n\n\n\n /* Interrupt line of NIC is connected to GPIO line 36 */\n\n smc91c111_init(&nd_table[0], 0x04000300,\n\n pxa2xx_gpio_in_get(cpu->gpio)[36]);\n\n}\n", + "output": "0", + "index": 10021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len)\n\n{\n\n unsigned int i;\n\n uint32_t start = 0, end;\n\n struct OpenBIOS_nvpart_v1 *part_header;\n\n\n\n // OpenBIOS nvram variables\n\n // Variable partition\n\n part_header = (struct OpenBIOS_nvpart_v1 *)nvr->data;\n\n part_header->signature = OPENBIOS_PART_SYSTEM;\n\n pstrcpy(part_header->name, sizeof(part_header->name), \"system\");\n\n\n\n end = start + sizeof(struct OpenBIOS_nvpart_v1);\n\n for (i = 0; i < nb_prom_envs; i++)\n\n end = OpenBIOS_set_var(nvr->data, end, prom_envs[i]);\n\n\n\n // End marker\n\n nvr->data[end++] = '\\0';\n\n\n\n end = start + ((end - start + 15) & ~15);\n\n /* XXX: OpenBIOS is not able to grow up a partition. Leave some space for\n\n new variables. */\n\n if (end < DEF_SYSTEM_SIZE)\n\n end = DEF_SYSTEM_SIZE;\n\n OpenBIOS_finish_partition(part_header, end - start);\n\n\n\n // free partition\n\n start = end;\n\n part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];\n\n part_header->signature = OPENBIOS_PART_FREE;\n\n pstrcpy(part_header->name, sizeof(part_header->name), \"free\");\n\n\n\n end = len;\n\n OpenBIOS_finish_partition(part_header, end - start);\n\n}\n", + "output": "0", + "index": 6005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_phys_addr(CPUARMState *env, uint32_t address,\n\n int access_type, int is_user,\n\n hwaddr *phys_ptr, int *prot,\n\n target_ulong *page_size)\n\n{\n\n /* Fast Context Switch Extension. */\n\n if (address < 0x02000000)\n\n address += env->cp15.c13_fcse;\n\n\n\n if ((env->cp15.c1_sys & 1) == 0) {\n\n /* MMU/MPU disabled. */\n\n *phys_ptr = address;\n\n *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;\n\n *page_size = TARGET_PAGE_SIZE;\n\n return 0;\n\n } else if (arm_feature(env, ARM_FEATURE_MPU)) {\n\n *page_size = TARGET_PAGE_SIZE;\n\n\treturn get_phys_addr_mpu(env, address, access_type, is_user, phys_ptr,\n\n\t\t\t\t prot);\n\n } else if (extended_addresses_enabled(env)) {\n\n return get_phys_addr_lpae(env, address, access_type, is_user, phys_ptr,\n\n prot, page_size);\n\n } else if (env->cp15.c1_sys & (1 << 23)) {\n\n return get_phys_addr_v6(env, address, access_type, is_user, phys_ptr,\n\n prot, page_size);\n\n } else {\n\n return get_phys_addr_v5(env, address, access_type, is_user, phys_ptr,\n\n prot, page_size);\n\n }\n\n}\n", + "output": "0", + "index": 17667 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int pam_encode_init(AVCodecContext *avctx)\n\n{\n\n avctx->coded_frame = av_frame_alloc();\n\n if (!avctx->coded_frame)\n\n return AVERROR(ENOMEM);\n\n\n\n avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;\n\n avctx->coded_frame->key_frame = 1;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17421 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t dp8393x_readb(void *opaque, target_phys_addr_t addr)\n\n{\n\n uint16_t v = dp8393x_readw(opaque, addr & ~0x1);\n\n return (v >> (8 * (addr & 0x1))) & 0xff;\n\n}\n", + "output": "0", + "index": 4333 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void probe_group_enter(const char *name, int type)\n\n{\n\n int64_t count = -1;\n\n\n\n octx.prefix =\n\n av_realloc(octx.prefix, sizeof(PrintElement) * (octx.level + 1));\n\n\n\n if (!octx.prefix || !name) {\n\n fprintf(stderr, \"Out of memory\\n\");\n\n exit(1);\n\n }\n\n\n\n if (octx.level) {\n\n PrintElement *parent = octx.prefix + octx.level -1;\n\n if (parent->type == ARRAY)\n\n count = parent->nb_elems;\n\n parent->nb_elems++;\n\n }\n\n\n\n octx.prefix[octx.level++] = (PrintElement){name, type, count, 0};\n\n}\n", + "output": "1", + "index": 11862 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_machine(gconstpointer data)\n\n{\n\n const char *machine = data;\n\n char *args;\n\n QDict *response;\n\n\n\n args = g_strdup_printf(\"-machine %s\", machine);\n\n qtest_start(args);\n\n\n\n test_properties(\"/machine\");\n\n\n\n response = qmp(\"{ 'execute': 'quit' }\");\n\n g_assert(qdict_haskey(response, \"return\"));\n\n\n\n qtest_end();\n\n g_free(args);\n\n}\n", + "output": "1", + "index": 22714 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int init_quantization_noise(DCAEncContext *c, int noise)\n\n{\n\n int ch, band, ret = 0;\n\n\n\n c->consumed_bits = 132 + 493 * c->fullband_channels;\n\n if (c->lfe_channel)\n\n c->consumed_bits += 72;\n\n\n\n /* attempt to guess the bit distribution based on the prevoius frame */\n\n for (ch = 0; ch < c->fullband_channels; ch++) {\n\n for (band = 0; band < 32; band++) {\n\n int snr_cb = c->peak_cb[band][ch] - c->band_masking_cb[band] - noise;\n\n\n\n if (snr_cb >= 1312) {\n\n c->abits[band][ch] = 26;\n\n ret |= USED_26ABITS;\n\n } else if (snr_cb >= 222) {\n\n c->abits[band][ch] = 8 + mul32(snr_cb - 222, 69000000);\n\n ret |= USED_NABITS;\n\n } else if (snr_cb >= 0) {\n\n c->abits[band][ch] = 2 + mul32(snr_cb, 106000000);\n\n ret |= USED_NABITS;\n\n } else {\n\n c->abits[band][ch] = 1;\n\n ret |= USED_1ABITS;\n\n }\n\n }\n\n }\n\n\n\n for (band = 0; band < 32; band++)\n\n for (ch = 0; ch < c->fullband_channels; ch++) {\n\n c->consumed_bits += bit_consumption[c->abits[band][ch]];\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 2932 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)\n\n{\n\n AcpiSystemResourceAffinityTable *srat;\n\n AcpiSratProcessorGiccAffinity *core;\n\n AcpiSratMemoryAffinity *numamem;\n\n int i, srat_start;\n\n uint64_t mem_base;\n\n MachineClass *mc = MACHINE_GET_CLASS(vms);\n\n const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms));\n\n\n\n srat_start = table_data->len;\n\n srat = acpi_data_push(table_data, sizeof(*srat));\n\n srat->reserved1 = cpu_to_le32(1);\n\n\n\n for (i = 0; i < cpu_list->len; ++i) {\n\n int node_id = cpu_list->cpus[i].props.has_node_id ?\n\n cpu_list->cpus[i].props.node_id : 0;\n\n core = acpi_data_push(table_data, sizeof(*core));\n\n core->type = ACPI_SRAT_PROCESSOR_GICC;\n\n core->length = sizeof(*core);\n\n core->proximity = cpu_to_le32(node_id);\n\n core->acpi_processor_uid = cpu_to_le32(i);\n\n core->flags = cpu_to_le32(1);\n\n }\n\n\n\n mem_base = vms->memmap[VIRT_MEM].base;\n\n for (i = 0; i < nb_numa_nodes; ++i) {\n\n numamem = acpi_data_push(table_data, sizeof(*numamem));\n\n build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i,\n\n MEM_AFFINITY_ENABLED);\n\n mem_base += numa_info[i].node_mem;\n\n }\n\n\n\n build_header(linker, table_data, (void *)srat, \"SRAT\",\n\n table_data->len - srat_start, 3, NULL, NULL);\n\n}\n", + "output": "0", + "index": 25205 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)\n\n{\n\n NE2000State *s;\n\n\n\n qemu_check_nic_model(nd, \"ne2k_isa\");\n\n\n\n s = qemu_mallocz(sizeof(NE2000State));\n\n\n\n register_ioport_write(base, 16, 1, ne2000_ioport_write, s);\n\n register_ioport_read(base, 16, 1, ne2000_ioport_read, s);\n\n\n\n register_ioport_write(base + 0x10, 1, 1, ne2000_asic_ioport_write, s);\n\n register_ioport_read(base + 0x10, 1, 1, ne2000_asic_ioport_read, s);\n\n register_ioport_write(base + 0x10, 2, 2, ne2000_asic_ioport_write, s);\n\n register_ioport_read(base + 0x10, 2, 2, ne2000_asic_ioport_read, s);\n\n\n\n register_ioport_write(base + 0x1f, 1, 1, ne2000_reset_ioport_write, s);\n\n register_ioport_read(base + 0x1f, 1, 1, ne2000_reset_ioport_read, s);\n\n s->irq = irq;\n\n memcpy(s->macaddr, nd->macaddr, 6);\n\n\n\n ne2000_reset(s);\n\n\n\n s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,\n\n ne2000_receive, ne2000_can_receive, s);\n\n\n\n qemu_format_nic_info_str(s->vc, s->macaddr);\n\n\n\n register_savevm(\"ne2000\", -1, 2, ne2000_save, ne2000_load, s);\n\n}\n", + "output": "1", + "index": 14348 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,\n\n const AVFrame *frame, int *got_packet_ptr)\n\n{\n\n int ret;\n\n int max_frame_bytes, sig_size = 256;\n\n VC2EncContext *s = avctx->priv_data;\n\n const char aux_data[] = \"FFmpeg version \"FFMPEG_VERSION;\n\n const int aux_data_size = sizeof(aux_data);\n\n const int header_size = 100 + aux_data_size;\n\n int64_t r_bitrate = avctx->bit_rate >> (s->interlaced);\n\n\n\n s->avctx = avctx;\n\n s->size_scaler = 1;\n\n s->prefix_bytes = 0;\n\n s->last_parse_code = 0;\n\n s->next_parse_offset = 0;\n\n\n\n /* Rate control */\n\n max_frame_bytes = (av_rescale(r_bitrate, s->avctx->time_base.num,\n\n s->avctx->time_base.den) >> 3) - header_size;\n\n\n\n /* Find an appropriate size scaler */\n\n while (sig_size > 255) {\n\n s->slice_max_bytes = FFALIGN(av_rescale(max_frame_bytes, 1,\n\n s->num_x*s->num_y), s->size_scaler);\n\n s->slice_max_bytes += 4 + s->prefix_bytes;\n\n sig_size = s->slice_max_bytes/s->size_scaler; /* Signalled slize size */\n\n s->size_scaler <<= 1;\n\n }\n\n\n\n ret = ff_alloc_packet2(avctx, avpkt, max_frame_bytes*2, 0);\n\n if (ret < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Error getting output packet.\\n\");\n\n return ret;\n\n } else {\n\n init_put_bits(&s->pb, avpkt->data, avpkt->size);\n\n }\n\n\n\n encode_frame(s, frame, aux_data, s->interlaced);\n\n if (s->interlaced)\n\n encode_frame(s, frame, NULL, 2);\n\n\n\n flush_put_bits(&s->pb);\n\n avpkt->size = put_bits_count(&s->pb) >> 3;\n\n\n\n *got_packet_ptr = 1;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 12512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void invalidate_and_set_dirty(target_phys_addr_t addr,\n\n target_phys_addr_t length)\n\n{\n\n if (!cpu_physical_memory_is_dirty(addr)) {\n\n /* invalidate code */\n\n tb_invalidate_phys_page_range(addr, addr + length, 0);\n\n /* set dirty bit */\n\n cpu_physical_memory_set_dirty_flags(addr, (0xff & ~CODE_DIRTY_FLAG));\n\n }\n\n xen_modified_memory(addr, length);\n\n}\n", + "output": "0", + "index": 7425 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int prefix_length, int calculate_checksum)\n\n{\n\n int64_t start, size, last_size;\n\n start= url_ftell(bc) - prefix_length;\n\n\n\n if(start != nut->packet_start + nut->written_packet_size){\n\n av_log(nut->avf, AV_LOG_ERROR, \"get_packetheader called at weird position\\n\");\n\n return -1;\n\n }\n\n \n\n if(calculate_checksum)\n\n init_checksum(bc, update_adler32, 0);\n\n\n\n size= get_v(bc);\n\n last_size= get_v(bc);\n\n if(nut->written_packet_size != last_size){\n\n av_log(nut->avf, AV_LOG_ERROR, \"packet size missmatch %d != %lld at %lld\\n\", nut->written_packet_size, last_size, start);\n\n return -1;\n\n }\n\n\n\n nut->last_packet_start = nut->packet_start;\n\n nut->packet_start = start;\n\n nut->written_packet_size= size;\n\n\n\n return size;\n\n}\n", + "output": "0", + "index": 7777 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *scsibus_get_dev_path(DeviceState *dev)\n\n{\n\n SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev);\n\n DeviceState *hba = dev->parent_bus->parent;\n\n char *id = NULL;\n\n\n\n if (hba && hba->parent_bus && hba->parent_bus->info->get_dev_path) {\n\n id = hba->parent_bus->info->get_dev_path(hba);\n\n }\n\n if (id) {\n\n return g_strdup_printf(\"%s/%d:%d:%d\", id, d->channel, d->id, d->lun);\n\n } else {\n\n return g_strdup_printf(\"%d:%d:%d\", d->channel, d->id, d->lun);\n\n }\n\n}\n", + "output": "1", + "index": 15239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler)\n\n{\n\n if (line >= 16 || line < 0)\n\n hw_error(\"%s: No GPIO line %i\\n\", __FUNCTION__, line);\n\n s->handler[line] = handler;\n\n}\n", + "output": "0", + "index": 16229 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static DisplaySurface *qemu_create_dummy_surface(void)\n\n{\n\n static const char msg[] =\n\n \"This VM has no graphic display device.\";\n\n DisplaySurface *surface = qemu_create_displaysurface(640, 480);\n\n pixman_color_t bg = color_table_rgb[0][COLOR_BLACK];\n\n pixman_color_t fg = color_table_rgb[0][COLOR_WHITE];\n\n pixman_image_t *glyph;\n\n int len, x, y, i;\n\n\n\n len = strlen(msg);\n\n x = (640/FONT_WIDTH - len) / 2;\n\n y = (480/FONT_HEIGHT - 1) / 2;\n\n for (i = 0; i < len; i++) {\n\n glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, msg[i]);\n\n qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg,\n\n x+i, y, FONT_WIDTH, FONT_HEIGHT);\n\n qemu_pixman_image_unref(glyph);\n\n }\n\n return surface;\n\n}\n", + "output": "0", + "index": 20226 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int64_t gb_get_v(GetBitContext *gb)\n\n{\n\n int64_t v = 0;\n\n int bits = 0;\n\n while(get_bits1(gb) && bits < 64-7){\n\n v <<= 7;\n\n v |= get_bits(gb, 7);\n\n bits += 7;\n\n }\n\n v <<= 7;\n\n v |= get_bits(gb, 7);\n\n\n\n return v;\n\n}\n", + "output": "1", + "index": 24666 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,\n\n int disabled, int clock, int it_shift)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n\n\n dev = qdev_create(NULL, \"escc\");\n\n qdev_prop_set_uint32(dev, \"disabled\", disabled);\n\n qdev_prop_set_uint32(dev, \"frequency\", clock);\n\n qdev_prop_set_uint32(dev, \"it_shift\", it_shift);\n\n qdev_prop_set_chr(dev, \"chrB\", NULL);\n\n qdev_prop_set_chr(dev, \"chrA\", NULL);\n\n qdev_prop_set_uint32(dev, \"chnBtype\", mouse);\n\n qdev_prop_set_uint32(dev, \"chnAtype\", kbd);\n\n qdev_init_nofail(dev);\n\n s = sysbus_from_qdev(dev);\n\n sysbus_connect_irq(s, 0, irq);\n\n sysbus_connect_irq(s, 1, irq);\n\n sysbus_mmio_map(s, 0, base);\n\n}\n", + "output": "0", + "index": 26007 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_cabac_mb_cbp_luma( H264Context *h) {\n\n int cbp_b, cbp_a, ctx, cbp = 0;\n\n\n\n cbp_a = h->slice_table[h->left_mb_xy[0]] == h->slice_num ? h->left_cbp : -1;\n\n cbp_b = h->slice_table[h->top_mb_xy] == h->slice_num ? h->top_cbp : -1;\n\n\n\n ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04);\n\n cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]);\n\n ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08);\n\n cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1;\n\n ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01);\n\n cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2;\n\n ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02);\n\n cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3;\n\n return cbp;\n\n}\n", + "output": "0", + "index": 3211 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ogm_dshow_header(AVFormatContext *s, int idx)\n{\n struct ogg *ogg = s->priv_data;\n struct ogg_stream *os = ogg->streams + idx;\n AVStream *st = s->streams[idx];\n uint8_t *p = os->buf + os->pstart;\n uint32_t t;\n if(!(*p & 1))\n return 0;\n if(*p != 1)\n return 1;\n t = AV_RL32(p + 96);\n if(t == 0x05589f80){\n st->codec->codec_type = AVMEDIA_TYPE_VIDEO;\n st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(p + 68));\n avpriv_set_pts_info(st, 64, AV_RL64(p + 164), 10000000);\n st->codec->width = AV_RL32(p + 176);\n st->codec->height = AV_RL32(p + 180);\n } else if(t == 0x05589f81){\n st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, AV_RL16(p + 124));\n st->codec->channels = AV_RL16(p + 126);\n st->codec->sample_rate = AV_RL32(p + 128);\n st->codec->bit_rate = AV_RL32(p + 132) * 8;\n }\n return 1;\n}", + "output": "1", + "index": 13723 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void watchdog_add_model(WatchdogTimerModel *model)\n\n{\n\n LIST_INSERT_HEAD(&watchdog_list, model, entry);\n\n}\n", + "output": "0", + "index": 3645 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,\n\n int *data_size, AVPacket *avpkt)\n\n{\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n AMRContext *s = avctx->priv_data;\n\n static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };\n\n enum Mode dec_mode;\n\n int packet_size;\n\n\n\n av_dlog(avctx, \"amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\\n\",\n\n buf, buf_size, avctx->frame_number);\n\n\n\n dec_mode = (buf[0] >> 3) & 0x000F;\n\n packet_size = block_size[dec_mode] + 1;\n\n\n\n if (packet_size > buf_size) {\n\n av_log(avctx, AV_LOG_ERROR, \"amr frame too short (%u, should be %u)\\n\",\n\n buf_size, packet_size);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n av_dlog(avctx, \"packet_size=%d buf= 0x%X %X %X %X\\n\",\n\n packet_size, buf[0], buf[1], buf[2], buf[3]);\n\n /* call decoder */\n\n Decoder_Interface_Decode(s->dec_state, buf, data, 0);\n\n *data_size = 160 * 2;\n\n\n\n return packet_size;\n\n}\n", + "output": "0", + "index": 22822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size)\n\n{\n\n int ret;\n\n\n\n switch(sector_size) {\n\n case 2048:\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct,\n\n 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);\n\n ret = bdrv_read(s->bs, (int64_t)lba << 2, buf, 4);\n\n block_acct_done(bdrv_get_stats(s->bs), &s->acct);\n\n break;\n\n case 2352:\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct,\n\n 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);\n\n ret = bdrv_read(s->bs, (int64_t)lba << 2, buf + 16, 4);\n\n block_acct_done(bdrv_get_stats(s->bs), &s->acct);\n\n if (ret < 0)\n\n return ret;\n\n cd_data_to_raw(buf, lba);\n\n break;\n\n default:\n\n ret = -EIO;\n\n break;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 22732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool migration_has_finished(MigrationState *s)\n\n{\n\n return s->state == MIG_STATE_COMPLETED;\n\n}\n", + "output": "1", + "index": 15366 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_ddiv (void)\n\n{\n\n if (T1 != 0) {\n\n lldiv_t res = lldiv((int64_t)T0, (int64_t)T1);\n\n env->LO[0][env->current_tc] = res.quot;\n\n env->HI[0][env->current_tc] = res.rem;\n\n }\n\n}\n", + "output": "1", + "index": 2675 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void slirp_cleanup(void)\n\n{\n\n WSACleanup();\n\n}\n", + "output": "1", + "index": 18836 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void null_end_frame(AVFilterLink *inlink) { }\n", + "output": "1", + "index": 13931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright, int _stride){\n\n pixel *src = (pixel*)_src;\n\n int stride = _stride/sizeof(pixel);\n\n ((pixel4*)(src+0*stride))[0]=\n\n ((pixel4*)(src+1*stride))[0]=\n\n ((pixel4*)(src+2*stride))[0]=\n\n ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1);\n\n}\n", + "output": "1", + "index": 26985 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t fd_put_buffer(void *opaque, const void *data, size_t size)\n\n{\n\n FdMigrationState *s = opaque;\n\n ssize_t ret;\n\n\n\n do {\n\n ret = write(s->fd, data, size);\n\n } while (ret == -1 && errno == EINTR);\n\n\n\n if (ret == -1)\n\n ret = -errno;\n\n\n\n if (ret == -EAGAIN)\n\n qemu_set_fd_handler2(s->fd, NULL, NULL, fd_put_notify, s);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 16087 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint8_t read_u8(uint8_t *data, size_t offset)\n\n{\n\n return data[offset];\n\n}\n", + "output": "0", + "index": 11779 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int swf_write_packet(AVFormatContext *s, int stream_index, \n\n const uint8_t *buf, int size, int64_t pts)\n\n{\n\n AVCodecContext *codec = &s->streams[stream_index]->codec;\n\n if (codec->codec_type == CODEC_TYPE_AUDIO)\n\n return swf_write_audio(s, buf, size);\n\n else\n\n return swf_write_video(s, codec, buf, size);\n\n}\n", + "output": "1", + "index": 14691 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_vp9dsp_init(VP9DSPContext *dsp)\n\n{\n\n vp9dsp_intrapred_init(dsp);\n\n vp9dsp_itxfm_init(dsp);\n\n vp9dsp_loopfilter_init(dsp);\n\n vp9dsp_mc_init(dsp);\n\n\n\n\n\n if (ARCH_X86)\n\n ff_vp9dsp_init_x86(dsp);\n\n}", + "output": "1", + "index": 17825 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void phys_page_set(target_phys_addr_t index, target_phys_addr_t nb,\n\n uint16_t leaf)\n\n{\n\n /* Wildly overreserve - it doesn't matter much. */\n\n phys_map_node_reserve(3 * P_L2_LEVELS);\n\n\n\n phys_page_set_level(&phys_map, &index, &nb, leaf, P_L2_LEVELS - 1);\n\n}\n", + "output": "0", + "index": 16569 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(simple_list)\n\n{\n\n int i;\n\n struct {\n\n const char *encoded;\n\n LiteralQObject decoded;\n\n } test_cases[] = {\n\n {\n\n .encoded = \"[43,42]\",\n\n .decoded = QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QINT(43),\n\n QLIT_QINT(42),\n\n { }\n\n })),\n\n },\n\n {\n\n .encoded = \"[43]\",\n\n .decoded = QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QINT(43),\n\n { }\n\n })),\n\n },\n\n {\n\n .encoded = \"[]\",\n\n .decoded = QLIT_QLIST(((LiteralQObject[]){\n\n { }\n\n })),\n\n },\n\n {\n\n .encoded = \"[{}]\",\n\n .decoded = QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QDICT(((LiteralQDictEntry[]){\n\n {},\n\n })),\n\n {},\n\n })),\n\n },\n\n { }\n\n };\n\n\n\n for (i = 0; test_cases[i].encoded; i++) {\n\n QObject *obj;\n\n QString *str;\n\n\n\n obj = qobject_from_json(test_cases[i].encoded);\n\n fail_unless(obj != NULL);\n\n fail_unless(qobject_type(obj) == QTYPE_QLIST);\n\n\n\n fail_unless(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);\n\n\n\n str = qobject_to_json(obj);\n\n qobject_decref(obj);\n\n\n\n obj = qobject_from_json(qstring_get_str(str));\n\n fail_unless(obj != NULL);\n\n fail_unless(qobject_type(obj) == QTYPE_QLIST);\n\n\n\n fail_unless(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);\n\n qobject_decref(obj);\n\n QDECREF(str);\n\n }\n\n}\n", + "output": "0", + "index": 9032 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int milkymist_memcard_init(SysBusDevice *dev)\n\n{\n\n MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev);\n\n DriveInfo *dinfo;\n\n BlockDriverState *bs;\n\n\n\n dinfo = drive_get_next(IF_SD);\n\n bs = dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL;\n\n s->card = sd_init(bs, false);\n\n if (s->card == NULL) {\n\n return -1;\n\n }\n\n\n\n s->enabled = bs && bdrv_is_inserted(bs);\n\n\n\n memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s,\n\n \"milkymist-memcard\", R_MAX * 4);\n\n sysbus_init_mmio(dev, &s->regs_region);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17587 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pm_update_sci(VT686PMState *s)\n\n{\n\n int sci_level, pmsts;\n\n\n\n pmsts = acpi_pm1_evt_get_sts(&s->ar, s->ar.tmr.overflow_time);\n\n sci_level = (((pmsts & s->ar.pm1.evt.en) &\n\n (ACPI_BITMASK_RT_CLOCK_ENABLE |\n\n ACPI_BITMASK_POWER_BUTTON_ENABLE |\n\n ACPI_BITMASK_GLOBAL_LOCK_ENABLE |\n\n ACPI_BITMASK_TIMER_ENABLE)) != 0);\n\n qemu_set_irq(s->dev.irq[0], sci_level);\n\n /* schedule a timer interruption if needed */\n\n acpi_pm_tmr_update(&s->ar, (s->ar.pm1.evt.en & ACPI_BITMASK_TIMER_ENABLE) &&\n\n !(pmsts & ACPI_BITMASK_TIMER_STATUS));\n\n}\n", + "output": "1", + "index": 26333 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,\n\n Error **errp)\n\n{\n\n VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);\n\n VirtIOSCSI *s = VIRTIO_SCSI(vdev);\n\n SCSIDevice *sd = SCSI_DEVICE(dev);\n\n\n\n if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) {\n\n virtio_scsi_push_event(s, sd,\n\n VIRTIO_SCSI_T_TRANSPORT_RESET,\n\n VIRTIO_SCSI_EVT_RESET_REMOVED);\n\n }\n\n\n\n if (s->ctx) {\n\n blk_op_unblock_all(sd->conf.blk, s->blocker);\n\n }\n\n qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);\n\n}\n", + "output": "0", + "index": 20994 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int cinvideo_decode_init(AVCodecContext *avctx)\n\n{\n\n CinVideoContext *cin = avctx->priv_data;\n\n unsigned int i;\n\n\n\n cin->avctx = avctx;\n\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n\n\n\n avcodec_get_frame_defaults(&cin->frame);\n\n cin->frame.data[0] = NULL;\n\n\n\n cin->bitmap_size = avctx->width * avctx->height;\n\n for (i = 0; i < 3; ++i) {\n\n cin->bitmap_table[i] = av_mallocz(cin->bitmap_size);\n\n if (!cin->bitmap_table[i])\n\n av_log(avctx, AV_LOG_ERROR, \"Can't allocate bitmap buffers.\\n\");\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 17283 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int l3_unscale(int value, int exponent)\n\n{\n\n unsigned int m;\n\n int e;\n\n\n\n e = table_4_3_exp [4 * value + (exponent & 3)];\n\n m = table_4_3_value[4 * value + (exponent & 3)];\n\n e -= exponent >> 2;\n\n#ifdef DEBUG\n\n if(e < 1)\n\n av_log(NULL, AV_LOG_WARNING, \"l3_unscale: e is %d\\n\", e);\n\n#endif\n\n if (e > (SUINT)31)\n\n return 0;\n\n m = (m + (1 << (e - 1))) >> e;\n\n\n\n return m;\n\n}\n", + "output": "1", + "index": 7735 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_S2prot(CPUARMState *env, int s2ap, int xn)\n\n{\n\n int prot = 0;\n\n\n\n if (s2ap & 1) {\n\n prot |= PAGE_READ;\n\n }\n\n if (s2ap & 2) {\n\n prot |= PAGE_WRITE;\n\n }\n\n if (!xn) {\n\n prot |= PAGE_EXEC;\n\n }\n\n return prot;\n\n}\n", + "output": "1", + "index": 10679 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int gdbserver_start(int port)\n\n{\n\n gdbserver_fd = gdbserver_open(port);\n\n if (gdbserver_fd < 0)\n\n return -1;\n\n /* accept connections */\n\n gdb_accept (NULL);\n\n return 0;\n\n}\n", + "output": "0", + "index": 22278 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_waiti(DisasContext *dc, uint32_t imm4)\n\n{\n\n TCGv_i32 pc = tcg_const_i32(dc->next_pc);\n\n TCGv_i32 intlevel = tcg_const_i32(imm4);\n\n\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_helper_waiti(cpu_env, pc, intlevel);\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n }\n\n tcg_temp_free(pc);\n\n tcg_temp_free(intlevel);\n\n gen_jumpi_check_loop_end(dc, 0);\n\n}\n", + "output": "1", + "index": 12517 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,\n\n vaddr addr, unsigned size,\n\n MMUAccessType access_type,\n\n int mmu_idx, MemTxAttrs attrs,\n\n MemTxResult response, uintptr_t retaddr)\n\n{\n\n ARMCPU *cpu = ARM_CPU(cs);\n\n ARMMMUFaultInfo fi = {};\n\n\n\n /* now we have a real cpu fault */\n\n cpu_restore_state(cs, retaddr);\n\n\n\n /* The EA bit in syndromes and fault status registers is an\n\n * IMPDEF classification of external aborts. ARM implementations\n\n * usually use this to indicate AXI bus Decode error (0) or\n\n * Slave error (1); in QEMU we follow that.\n\n */\n\n fi.ea = (response != MEMTX_DECODE_ERROR);\n\n fi.type = ARMFault_SyncExternal;\n\n deliver_fault(cpu, addr, access_type, mmu_idx, &fi);\n\n}\n", + "output": "1", + "index": 13257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift)\n\n{\n\n if (cap_ppc_rma >= 2) {\n\n return current_size;\n\n }\n\n return MIN(current_size,\n\n getrampagesize() << (hash_shift - 7));\n\n}\n", + "output": "0", + "index": 17090 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t coroutine_fn parallels_co_get_block_status(BlockDriverState *bs,\n\n int64_t sector_num, int nb_sectors, int *pnum)\n\n{\n\n BDRVParallelsState *s = bs->opaque;\n\n int64_t offset;\n\n\n\n qemu_co_mutex_lock(&s->lock);\n\n offset = block_status(s, sector_num, nb_sectors, pnum);\n\n qemu_co_mutex_unlock(&s->lock);\n\n\n\n if (offset < 0) {\n\n return 0;\n\n }\n\n\n\n return (offset << BDRV_SECTOR_BITS) |\n\n BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;\n\n}\n", + "output": "0", + "index": 27000 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpeg_decode_frame(AVCodecContext *avctx, void *data,\n\n int *got_output, AVPacket *avpkt)\n\n{\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n Mpeg1Context *s = avctx->priv_data;\n\n AVFrame *picture = data;\n\n MpegEncContext *s2 = &s->mpeg_enc_ctx;\n\n av_dlog(avctx, \"fill_buffer\\n\");\n\n\n\n if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {\n\n /* special case for last picture */\n\n if (s2->low_delay == 0 && s2->next_picture_ptr) {\n\n int ret = av_frame_ref(picture, &s2->next_picture_ptr->f);\n\n if (ret < 0)\n\n return ret;\n\n\n\n s2->next_picture_ptr = NULL;\n\n\n\n *got_output = 1;\n\n }\n\n return buf_size;\n\n }\n\n\n\n if (s2->flags & CODEC_FLAG_TRUNCATED) {\n\n int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf,\n\n buf_size, NULL);\n\n\n\n if (ff_combine_frame(&s2->parse_context, next,\n\n (const uint8_t **) &buf, &buf_size) < 0)\n\n return buf_size;\n\n }\n\n\n\n if (s->mpeg_enc_ctx_allocated == 0 && avctx->codec_tag == AV_RL32(\"VCR2\"))\n\n vcr2_init_sequence(avctx);\n\n\n\n s->slice_count = 0;\n\n\n\n if (avctx->extradata && !s->extradata_decoded) {\n\n int ret = decode_chunks(avctx, picture, got_output,\n\n avctx->extradata, avctx->extradata_size);\n\n s->extradata_decoded = 1;\n\n if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))\n\n return ret;\n\n }\n\n\n\n return decode_chunks(avctx, picture, got_output, buf, buf_size);\n\n}\n", + "output": "1", + "index": 25471 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright, int _stride){\n\n pixel *src = (pixel*)_src;\n\n int stride = _stride/sizeof(pixel);\n\n const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;\n\n\n\n ((pixel4*)(src+0*stride))[0]=\n\n ((pixel4*)(src+1*stride))[0]=\n\n ((pixel4*)(src+2*stride))[0]=\n\n ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);\n\n}\n", + "output": "1", + "index": 19715 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "build_hpet(GArray *table_data, GArray *linker)\n\n{\n\n Acpi20Hpet *hpet;\n\n\n\n hpet = acpi_data_push(table_data, sizeof(*hpet));\n\n /* Note timer_block_id value must be kept in sync with value advertised by\n\n * emulated hpet\n\n */\n\n hpet->timer_block_id = cpu_to_le32(0x8086a201);\n\n hpet->addr.address = cpu_to_le64(HPET_BASE);\n\n build_header(linker, table_data,\n\n (void *)hpet, \"HPET\", sizeof(*hpet), 1, NULL);\n\n}\n", + "output": "0", + "index": 23696 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static coroutine_fn void test_multi_co_schedule_entry(void *opaque)\n\n{\n\n g_assert(to_schedule[id] == NULL);\n\n atomic_mb_set(&to_schedule[id], qemu_coroutine_self());\n\n\n\n while (!atomic_mb_read(&now_stopping)) {\n\n int n;\n\n\n\n n = g_test_rand_int_range(0, NUM_CONTEXTS);\n\n schedule_next(n);\n\n qemu_coroutine_yield();\n\n\n\n g_assert(to_schedule[id] == NULL);\n\n atomic_mb_set(&to_schedule[id], qemu_coroutine_self());\n\n }\n\n}\n", + "output": "1", + "index": 382 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void put_fid(V9fsPDU *pdu, V9fsFidState *fidp)\n\n{\n\n BUG_ON(!fidp->ref);\n\n fidp->ref--;\n\n /*\n\n * Don't free the fid if it is in reclaim list\n\n */\n\n if (!fidp->ref && fidp->clunked) {\n\n if (fidp->fid == pdu->s->root_fid) {\n\n /*\n\n * if the clunked fid is root fid then we\n\n * have unmounted the fs on the client side.\n\n * delete the migration blocker. Ideally, this\n\n * should be hooked to transport close notification\n\n */\n\n if (pdu->s->migration_blocker) {\n\n migrate_del_blocker(pdu->s->migration_blocker);\n\n error_free(pdu->s->migration_blocker);\n\n pdu->s->migration_blocker = NULL;\n\n }\n\n }\n\n free_fid(pdu, fidp);\n\n }\n\n}\n", + "output": "0", + "index": 24729 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_acpi_one(const char *params, test_data *data)\n\n{\n\n char *args;\n\n uint8_t signature_low;\n\n uint8_t signature_high;\n\n uint16_t signature;\n\n int i;\n\n const char *device = \"\";\n\n\n\n if (!g_strcmp0(data->machine, MACHINE_Q35)) {\n\n device = \",id=hd -device ide-hd,drive=hd\";\n\n }\n\n\n\n args = g_strdup_printf(\"-net none -display none %s -drive file=%s%s,\",\n\n params ? params : \"\", disk, device);\n\n qtest_start(args);\n\n\n\n /* Wait at most 1 minute */\n\n#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)\n\n#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)\n\n\n\n /* Poll until code has run and modified memory. Once it has we know BIOS\n\n * initialization is done. TODO: check that IP reached the halt\n\n * instruction.\n\n */\n\n for (i = 0; i < TEST_CYCLES; ++i) {\n\n signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);\n\n signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);\n\n signature = (signature_high << 8) | signature_low;\n\n if (signature == SIGNATURE) {\n\n break;\n\n }\n\n g_usleep(TEST_DELAY);\n\n }\n\n g_assert_cmphex(signature, ==, SIGNATURE);\n\n\n\n test_acpi_rsdp_address(data);\n\n test_acpi_rsdp_table(data);\n\n test_acpi_rsdt_table(data);\n\n test_acpi_fadt_table(data);\n\n test_acpi_facs_table(data);\n\n test_acpi_dsdt_table(data);\n\n test_acpi_tables(data);\n\n\n\n if (iasl) {\n\n if (getenv(ACPI_REBUILD_EXPECTED_AML)) {\n\n dump_aml_files(data, true);\n\n } else {\n\n test_acpi_asl(data);\n\n }\n\n }\n\n\n\n test_smbios_ep_address(data);\n\n test_smbios_ep_table(data);\n\n test_smbios_structs(data);\n\n\n\n qtest_quit(global_qtest);\n\n g_free(args);\n\n}\n", + "output": "1", + "index": 7049 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie,\n\n QEMUSGList *sg, enum BlockAcctType type)\n\n{\n\n block_acct_start(bdrv_get_stats(bs), cookie, sg->size, type);\n\n}\n", + "output": "0", + "index": 3019 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_eval_coefs(int *coefs, const int *refl)\n\n{\n\n int buffer[LPC_ORDER];\n\n int *b1 = buffer;\n\n int *b2 = coefs;\n\n int i, j;\n\n\n\n for (i=0; i < LPC_ORDER; i++) {\n\n b1[i] = refl[i] * 16;\n\n\n\n for (j=0; j < i; j++)\n\n b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j];\n\n\n\n FFSWAP(int *, b1, b2);\n\n }\n\n\n\n for (i=0; i < LPC_ORDER; i++)\n\n coefs[i] >>= 4;\n\n}\n", + "output": "1", + "index": 20847 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int encode_close(AVCodecContext* avc_context)\n\n{\n\n TheoraContext *h = avc_context->priv_data;\n\n\n\n th_encode_free(h->t_state);\n\n av_freep(&h->stats);\n\n av_freep(&avc_context->coded_frame);\n\n av_freep(&avc_context->stats_out);\n\n av_freep(&avc_context->extradata);\n\n avc_context->extradata_size = 0;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 456 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_ide_none(void)\n\n{\n\n char *argv[256];\n\n\n\n setup_common(argv, ARRAY_SIZE(argv));\n\n qtest_start(g_strjoinv(\" \", argv));\n\n test_cmos();\n\n qtest_end();\n\n}\n", + "output": "1", + "index": 10403 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend,\n\n Error **errp)\n\n{\n\n const char *device = qemu_opt_get(opts, \"path\");\n\n\n\n if (device == NULL) {\n\n error_setg(errp, \"chardev: parallel: no device path given\");\n\n return;\n\n }\n\n backend->parallel = g_new0(ChardevHostdev, 1);\n\n backend->parallel->device = g_strdup(device);\n\n}\n", + "output": "0", + "index": 15789 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned tget_long(const uint8_t **p, int le)\n\n{\n\n unsigned v = le ? AV_RL32(*p) : AV_RB32(*p);\n\n *p += 4;\n\n return v;\n\n}\n", + "output": "1", + "index": 11299 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_andi64(TCGContext *s, TCGReg dst, TCGReg src, uint64_t c)\n\n{\n\n int mb, me;\n\n\n\n assert(TCG_TARGET_REG_BITS == 64);\n\n if (mask64_operand(c, &mb, &me)) {\n\n if (mb == 0) {\n\n tcg_out_rld(s, RLDICR, dst, src, 0, me);\n\n } else {\n\n tcg_out_rld(s, RLDICL, dst, src, 0, mb);\n\n }\n\n } else if ((c & 0xffff) == c) {\n\n tcg_out32(s, ANDI | SAI(src, dst, c));\n\n return;\n\n } else if ((c & 0xffff0000) == c) {\n\n tcg_out32(s, ANDIS | SAI(src, dst, c >> 16));\n\n return;\n\n } else {\n\n tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_R0, c);\n\n tcg_out32(s, AND | SAB(src, dst, TCG_REG_R0));\n\n }\n\n}\n", + "output": "0", + "index": 21415 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)\n\n{\n\n /* Estimate pending number of bytes to send */\n\n uint64_t pending;\n\n\n\n qemu_mutex_lock_iothread();\n\n blk_mig_lock();\n\n pending = get_remaining_dirty() +\n\n block_mig_state.submitted * BLOCK_SIZE +\n\n block_mig_state.read_done * BLOCK_SIZE;\n\n\n\n /* Report at least one block pending during bulk phase */\n\n if (pending == 0 && !block_mig_state.bulk_completed) {\n\n pending = BLOCK_SIZE;\n\n }\n\n blk_mig_unlock();\n\n qemu_mutex_unlock_iothread();\n\n\n\n DPRINTF(\"Enter save live pending %\" PRIu64 \"\\n\", pending);\n\n return pending;\n\n}\n", + "output": "1", + "index": 19707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_secondary_tcp_pkt(NetFilterState *nf,\n\n Connection *conn,\n\n Packet *pkt)\n\n{\n\n struct tcphdr *tcp_pkt;\n\n\n\n tcp_pkt = (struct tcphdr *)pkt->transport_header;\n\n\n\n if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) {\n\n char *sdebug, *ddebug;\n\n sdebug = strdup(inet_ntoa(pkt->ip->ip_src));\n\n ddebug = strdup(inet_ntoa(pkt->ip->ip_dst));\n\n trace_colo_filter_rewriter_pkt_info(__func__, sdebug, ddebug,\n\n ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),\n\n tcp_pkt->th_flags);\n\n trace_colo_filter_rewriter_conn_offset(conn->offset);\n\n g_free(sdebug);\n\n g_free(ddebug);\n\n }\n\n\n\n if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN))) {\n\n /*\n\n * save offset = secondary_seq and then\n\n * in handle_primary_tcp_pkt make offset\n\n * = secondary_seq - primary_seq\n\n */\n\n conn->offset = ntohl(tcp_pkt->th_seq);\n\n }\n\n\n\n if ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK) {\n\n /* handle packets to the primary from the secondary*/\n\n tcp_pkt->th_seq = htonl(ntohl(tcp_pkt->th_seq) - conn->offset);\n\n\n\n net_checksum_calculate((uint8_t *)pkt->data, pkt->size);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 22017 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline TCGv gen_extend(TCGv val, int opsize, int sign)\n\n{\n\n TCGv tmp;\n\n\n\n switch (opsize) {\n\n case OS_BYTE:\n\n tmp = tcg_temp_new();\n\n if (sign)\n\n tcg_gen_ext8s_i32(tmp, val);\n\n else\n\n tcg_gen_ext8u_i32(tmp, val);\n\n break;\n\n case OS_WORD:\n\n tmp = tcg_temp_new();\n\n if (sign)\n\n tcg_gen_ext16s_i32(tmp, val);\n\n else\n\n tcg_gen_ext16u_i32(tmp, val);\n\n break;\n\n case OS_LONG:\n\n case OS_SINGLE:\n\n tmp = val;\n\n break;\n\n default:\n\n qemu_assert(0, \"Bad operand size\");\n\n }\n\n return tmp;\n\n}\n", + "output": "1", + "index": 1596 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qio_channel_command_finalize(Object *obj)\n\n{\n\n QIOChannelCommand *ioc = QIO_CHANNEL_COMMAND(obj);\n\n if (ioc->readfd != -1) {\n\n close(ioc->readfd);\n\n ioc->readfd = -1;\n\n }\n\n if (ioc->writefd != -1) {\n\n close(ioc->writefd);\n\n ioc->writefd = -1;\n\n }\n\n if (ioc->pid > 0) {\n\n#ifndef WIN32\n\n qio_channel_command_abort(ioc, NULL);\n\n#endif\n\n }\n\n}\n", + "output": "1", + "index": 21135 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void os_host_main_loop_wait(int *timeout)\n\n{\n\n int ret, ret2, i;\n\n PollingEntry *pe;\n\n\n\n /* XXX: need to suppress polling by better using win32 events */\n\n ret = 0;\n\n for(pe = first_polling_entry; pe != NULL; pe = pe->next) {\n\n ret |= pe->func(pe->opaque);\n\n }\n\n if (ret == 0) {\n\n int err;\n\n WaitObjects *w = &wait_objects;\n\n\n\n qemu_mutex_unlock_iothread();\n\n ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout);\n\n qemu_mutex_lock_iothread();\n\n if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) {\n\n if (w->func[ret - WAIT_OBJECT_0])\n\n w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]);\n\n\n\n /* Check for additional signaled events */\n\n for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) {\n\n\n\n /* Check if event is signaled */\n\n ret2 = WaitForSingleObject(w->events[i], 0);\n\n if(ret2 == WAIT_OBJECT_0) {\n\n if (w->func[i])\n\n w->func[i](w->opaque[i]);\n\n } else if (ret2 == WAIT_TIMEOUT) {\n\n } else {\n\n err = GetLastError();\n\n fprintf(stderr, \"WaitForSingleObject error %d %d\\n\", i, err);\n\n }\n\n }\n\n } else if (ret == WAIT_TIMEOUT) {\n\n } else {\n\n err = GetLastError();\n\n fprintf(stderr, \"WaitForMultipleObjects error %d %d\\n\", ret, err);\n\n }\n\n }\n\n\n\n *timeout = 0;\n\n}\n", + "output": "0", + "index": 23177 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_pty(const char *id,\n\n ChardevBackend *backend,\n\n ChardevReturn *ret,\n\n Error **errp)\n\n{\n\n CharDriverState *chr;\n\n PtyCharDriver *s;\n\n int master_fd, slave_fd;\n\n char pty_name[PATH_MAX];\n\n\n\n master_fd = qemu_openpty_raw(&slave_fd, pty_name);\n\n if (master_fd < 0) {\n\n error_setg_errno(errp, errno, \"Failed to create PTY\");\n\n return NULL;\n\n }\n\n\n\n close(slave_fd);\n\n qemu_set_nonblock(master_fd);\n\n\n\n chr = qemu_chr_alloc();\n\n\n\n chr->filename = g_strdup_printf(\"pty:%s\", pty_name);\n\n ret->pty = g_strdup(pty_name);\n\n ret->has_pty = true;\n\n\n\n fprintf(stderr, \"char device redirected to %s (label %s)\\n\",\n\n pty_name, id);\n\n\n\n s = g_new0(PtyCharDriver, 1);\n\n chr->opaque = s;\n\n chr->chr_write = pty_chr_write;\n\n chr->chr_update_read_handler = pty_chr_update_read_handler;\n\n chr->chr_close = pty_chr_close;\n\n chr->chr_add_watch = pty_chr_add_watch;\n\n chr->explicit_be_open = true;\n\n\n\n s->fd = io_channel_from_fd(master_fd);\n\n s->timer_tag = 0;\n\n\n\n return chr;\n\n}\n", + "output": "0", + "index": 8854 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_write_sdr1 (void *opaque, int sprn)\n\n{\n\n DisasContext *ctx = opaque;\n\n\n\n gen_op_store_sdr1();\n\n RET_STOP(ctx);\n\n}\n", + "output": "0", + "index": 20159 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold void build_modpred(Indeo3DecodeContext *s)\n\n{\n\n int i, j;\n\n\n\n s->ModPred = av_malloc(8 * 128);\n\n\n\n for (i=0; i < 128; ++i) {\n\n s->ModPred[i+0*128] = i > 126 ? 254 : 2*(i + 1 - ((i + 1) % 2));\n\n s->ModPred[i+1*128] = i == 7 ? 20 :\n\n i == 119 ||\n\n i == 120 ? 236 : 2*(i + 2 - ((i + 1) % 3));\n\n s->ModPred[i+2*128] = i > 125 ? 248 : 2*(i + 2 - ((i + 2) % 4));\n\n s->ModPred[i+3*128] = 2*(i + 1 - ((i - 3) % 5));\n\n s->ModPred[i+4*128] = i == 8 ? 20 : 2*(i + 1 - ((i - 3) % 6));\n\n s->ModPred[i+5*128] = 2*(i + 4 - ((i + 3) % 7));\n\n s->ModPred[i+6*128] = i > 123 ? 240 : 2*(i + 4 - ((i + 4) % 8));\n\n s->ModPred[i+7*128] = 2*(i + 5 - ((i + 4) % 9));\n\n }\n\n\n\n s->corrector_type = av_malloc(24 * 256);\n\n\n\n for (i=0; i < 24; ++i) {\n\n for (j=0; j < 256; ++j) {\n\n s->corrector_type[i*256+j] = j < corrector_type_0[i] ? 1 :\n\n j < 248 || (i == 16 && j == 248) ? 0 :\n\n corrector_type_2[j - 248];\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 3658 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ppc_hash32_check_prot(int prot, int rw, int access_type)\n\n{\n\n int ret;\n\n\n\n if (access_type == ACCESS_CODE) {\n\n if (prot & PAGE_EXEC) {\n\n ret = 0;\n\n } else {\n\n ret = -2;\n\n }\n\n } else if (rw) {\n\n if (prot & PAGE_WRITE) {\n\n ret = 0;\n\n } else {\n\n ret = -2;\n\n }\n\n } else {\n\n if (prot & PAGE_READ) {\n\n ret = 0;\n\n } else {\n\n ret = -2;\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 6078 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int open_self_cmdline(void *cpu_env, int fd)\n\n{\n\n int fd_orig = -1;\n\n bool word_skipped = false;\n\n\n\n fd_orig = open(\"/proc/self/cmdline\", O_RDONLY);\n\n if (fd_orig < 0) {\n\n return fd_orig;\n\n }\n\n\n\n while (true) {\n\n ssize_t nb_read;\n\n char buf[128];\n\n char *cp_buf = buf;\n\n\n\n nb_read = read(fd_orig, buf, sizeof(buf));\n\n if (nb_read < 0) {\n\n int e = errno;\n\n fd_orig = close(fd_orig);\n\n errno = e;\n\n return -1;\n\n } else if (nb_read == 0) {\n\n break;\n\n }\n\n\n\n if (!word_skipped) {\n\n /* Skip the first string, which is the path to qemu-*-static\n\n instead of the actual command. */\n\n cp_buf = memchr(buf, 0, sizeof(buf));\n\n if (cp_buf) {\n\n /* Null byte found, skip one string */\n\n cp_buf++;\n\n nb_read -= cp_buf - buf;\n\n word_skipped = true;\n\n }\n\n }\n\n\n\n if (word_skipped) {\n\n if (write(fd, cp_buf, nb_read) != nb_read) {\n\n int e = errno;\n\n close(fd_orig);\n\n errno = e;\n\n return -1;\n\n }\n\n }\n\n }\n\n\n\n return close(fd_orig);\n\n}\n", + "output": "0", + "index": 10576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)\n\n{\n\n if (!strcasecmp(color_string, \"random\") || !strcasecmp(color_string, \"bikeshed\")) {\n\n int rgba = av_get_random_seed();\n\n rgba_color[0] = rgba >> 24;\n\n rgba_color[1] = rgba >> 16;\n\n rgba_color[2] = rgba >> 8;\n\n rgba_color[3] = rgba;\n\n } else\n\n if (!strncmp(color_string, \"0x\", 2)) {\n\n char *tail;\n\n int len = strlen(color_string);\n\n unsigned int rgba = strtoul(color_string, &tail, 16);\n\n\n\n if (*tail || (len != 8 && len != 10)) {\n\n av_log(log_ctx, AV_LOG_ERROR, \"Invalid 0xRRGGBB[AA] color string: '%s'\\n\", color_string);\n\n return AVERROR(EINVAL);\n\n }\n\n if (len == 10) {\n\n rgba_color[3] = rgba;\n\n rgba >>= 8;\n\n }\n\n rgba_color[0] = rgba >> 16;\n\n rgba_color[1] = rgba >> 8;\n\n rgba_color[2] = rgba;\n\n } else {\n\n const ColorEntry *entry = bsearch(color_string,\n\n color_table,\n\n FF_ARRAY_ELEMS(color_table),\n\n sizeof(ColorEntry),\n\n color_table_compare);\n\n if (!entry) {\n\n av_log(log_ctx, AV_LOG_ERROR, \"Cannot find color '%s'\\n\", color_string);\n\n return AVERROR(EINVAL);\n\n }\n\n memcpy(rgba_color, entry->rgba_color, 4);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void iwmmxt_load_reg(TCGv var, int reg)\n\n{\n\n tcg_gen_ld_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));\n\n}\n", + "output": "0", + "index": 18050 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_fcmpq(int fccno)\n\n{\n\n switch (fccno) {\n\n case 0:\n\n gen_helper_fcmpq(cpu_env);\n\n break;\n\n case 1:\n\n gen_helper_fcmpq_fcc1(cpu_env);\n\n break;\n\n case 2:\n\n gen_helper_fcmpq_fcc2(cpu_env);\n\n break;\n\n case 3:\n\n gen_helper_fcmpq_fcc3(cpu_env);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 25709 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void lsi53c895a_register_devices(void)\n\n{\n\n type_register_static(&lsi_info);\n\n type_register_static_alias(&lsi_info, \"lsi\");\n\n}\n", + "output": "0", + "index": 17152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vfio_start_eventfd_injection(VFIOINTp *intp)\n\n{\n\n int ret;\n\n\n\n ret = vfio_set_trigger_eventfd(intp, vfio_intp_interrupt);\n\n if (ret) {\n\n error_report(\"vfio: Error: Failed to pass IRQ fd to the driver: %m\");\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 26620 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void libschroedinger_flush(AVCodecContext *avctx)\n\n{\n\n /* Got a seek request. Free the decoded frames queue and then reset\n\n * the decoder */\n\n SchroDecoderParams *p_schro_params = avctx->priv_data;\n\n\n\n /* Free data in the output frame queue. */\n\n ff_schro_queue_free(&p_schro_params->dec_frame_queue,\n\n libschroedinger_decode_frame_free);\n\n\n\n ff_schro_queue_init(&p_schro_params->dec_frame_queue);\n\n schro_decoder_reset(p_schro_params->decoder);\n\n p_schro_params->eos_pulled = 0;\n\n p_schro_params->eos_signalled = 0;\n\n}\n", + "output": "1", + "index": 12964 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,\n\n socklen_t salen,\n\n Error **errp)\n\n{\n\n char host[NI_MAXHOST];\n\n char serv[NI_MAXSERV];\n\n SocketAddressLegacy *addr;\n\n InetSocketAddress *inet;\n\n int ret;\n\n\n\n ret = getnameinfo((struct sockaddr *)sa, salen,\n\n host, sizeof(host),\n\n serv, sizeof(serv),\n\n NI_NUMERICHOST | NI_NUMERICSERV);\n\n if (ret != 0) {\n\n error_setg(errp, \"Cannot format numeric socket address: %s\",\n\n gai_strerror(ret));\n\n return NULL;\n\n }\n\n\n\n addr = g_new0(SocketAddressLegacy, 1);\n\n addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;\n\n inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);\n\n inet->host = g_strdup(host);\n\n inet->port = g_strdup(serv);\n\n if (sa->ss_family == AF_INET) {\n\n inet->has_ipv4 = inet->ipv4 = true;\n\n } else {\n\n inet->has_ipv6 = inet->ipv6 = true;\n\n }\n\n\n\n return addr;\n\n}\n", + "output": "0", + "index": 11832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmxnet3_update_rx_mode(VMXNET3State *s)\n\n{\n\n s->rx_mode = VMXNET3_READ_DRV_SHARED32(s->drv_shmem,\n\n devRead.rxFilterConf.rxMode);\n\n VMW_CFPRN(\"RX mode: 0x%08X\", s->rx_mode);\n\n}\n", + "output": "1", + "index": 11556 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ehci_frame_timer(void *opaque)\n\n{\n\n EHCIState *ehci = opaque;\n\n int schedules = 0;\n\n int64_t expire_time, t_now;\n\n uint64_t ns_elapsed;\n\n int frames;\n\n int i;\n\n int skipped_frames = 0;\n\n\n\n t_now = qemu_get_clock_ns(vm_clock);\n\n ns_elapsed = t_now - ehci->last_run_ns;\n\n frames = ns_elapsed / FRAME_TIMER_NS;\n\n\n\n if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) {\n\n schedules++;\n\n expire_time = t_now + (get_ticks_per_sec() / FRAME_TIMER_FREQ);\n\n\n\n for (i = 0; i < frames; i++) {\n\n ehci_update_frindex(ehci, 1);\n\n\n\n if (frames - i > ehci->maxframes) {\n\n skipped_frames++;\n\n } else {\n\n ehci_advance_periodic_state(ehci);\n\n }\n\n\n\n ehci->last_run_ns += FRAME_TIMER_NS;\n\n }\n\n } else {\n\n if (ehci->async_stepdown < ehci->maxframes / 2) {\n\n ehci->async_stepdown++;\n\n }\n\n expire_time = t_now + (get_ticks_per_sec()\n\n * ehci->async_stepdown / FRAME_TIMER_FREQ);\n\n ehci_update_frindex(ehci, frames);\n\n ehci->last_run_ns += FRAME_TIMER_NS * frames;\n\n }\n\n\n\n#if 0\n\n if (skipped_frames) {\n\n DPRINTF(\"WARNING - EHCI skipped %d frames\\n\", skipped_frames);\n\n }\n\n#endif\n\n\n\n /* Async is not inside loop since it executes everything it can once\n\n * called\n\n */\n\n if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) {\n\n schedules++;\n\n qemu_bh_schedule(ehci->async_bh);\n\n }\n\n\n\n if (schedules) {\n\n qemu_mod_timer(ehci->frame_timer, expire_time);\n\n }\n\n}\n", + "output": "0", + "index": 16541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_add_table(GArray *table_offsets, GArray *table_data)\n\n{\n\n uint32_t offset = cpu_to_le32(table_data->len);\n\n g_array_append_val(table_offsets, offset);\n\n}\n", + "output": "0", + "index": 12689 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)\n\n{\n\n AVStream *st;\n\n int id;\n\n\n\n st = av_new_stream(s, 0);\n\n if (!st)\n\n return AVERROR_NOMEM;\n\n if (ap) {\n\n id = s->iformat->value;\n\n if (id == CODEC_ID_RAWVIDEO) {\n\n st->codec->codec_type = CODEC_TYPE_VIDEO;\n\n } else {\n\n st->codec->codec_type = CODEC_TYPE_AUDIO;\n\n }\n\n st->codec->codec_id = id;\n\n\n\n switch(st->codec->codec_type) {\n\n case CODEC_TYPE_AUDIO:\n\n st->codec->sample_rate = ap->sample_rate;\n\n st->codec->channels = ap->channels;\n\n av_set_pts_info(st, 64, 1, st->codec->sample_rate);\n\n break;\n\n case CODEC_TYPE_VIDEO:\n\n av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);\n\n st->codec->width = ap->width;\n\n st->codec->height = ap->height;\n\n st->codec->pix_fmt = ap->pix_fmt;\n\n if(st->codec->pix_fmt == PIX_FMT_NONE)\n\n st->codec->pix_fmt= PIX_FMT_YUV420P;\n\n break;\n\n default:\n\n return -1;\n\n }\n\n } else {\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 27019 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)\n\n{\n\n int ret = -ENOSYS;\n\n KVMState *s = kvm_state;\n\n\n\n if (s->coalesced_mmio) {\n\n struct kvm_coalesced_mmio_zone zone;\n\n\n\n zone.addr = start;\n\n zone.size = size;\n\n\n\n\n ret = kvm_vm_ioctl(s, KVM_UNREGISTER_COALESCED_MMIO, &zone);\n\n }\n\n\n\n return ret;\n\n}", + "output": "1", + "index": 1638 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstlen)\n\n{\n\n char *q;\n\n int len;\n\n\n\n if(dstlen > 0)\n\n dst[0]= 0;\n\n if(taglen < 1)\n\n return;\n\n\n\n taglen--; /* account for encoding type byte */\n\n dstlen--; /* Leave space for zero terminator */\n\n\n\n switch(get_byte(s->pb)) { /* encoding type */\n\n\n\n case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */\n\n q = dst;\n\n while(taglen--) {\n\n uint8_t tmp;\n\n PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;)\n\n }\n\n *q = '\\0';\n\n break;\n\n\n\n case 3: /* UTF-8 */\n\n len = FFMIN(taglen, dstlen);\n\n get_buffer(s->pb, dst, len);\n\n dst[len] = 0;\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 6173 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_arch_remove_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp)\n\n{\n\n uint8_t int3;\n\n\n\n if (cpu_memory_rw_debug(env, bp->pc, &int3, 1, 0) || int3 != 0xcc ||\n\n cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1))\n\n return -EINVAL;\n\n return 0;\n\n}\n", + "output": "0", + "index": 12622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dhcp_decode(const struct bootp_t *bp, int *pmsg_type,\n\n const struct in_addr **preq_addr)\n\n{\n\n const uint8_t *p, *p_end;\n\n int len, tag;\n\n\n\n *pmsg_type = 0;\n\n *preq_addr = NULL;\n\n\n\n p = bp->bp_vend;\n\n p_end = p + DHCP_OPT_LEN;\n\n if (memcmp(p, rfc1533_cookie, 4) != 0)\n\n return;\n\n p += 4;\n\n while (p < p_end) {\n\n tag = p[0];\n\n if (tag == RFC1533_PAD) {\n\n p++;\n\n } else if (tag == RFC1533_END) {\n\n break;\n\n } else {\n\n p++;\n\n if (p >= p_end)\n\n break;\n\n len = *p++;\n\n DPRINTF(\"dhcp: tag=%d len=%d\\n\", tag, len);\n\n\n\n switch(tag) {\n\n case RFC2132_MSG_TYPE:\n\n if (len >= 1)\n\n *pmsg_type = p[0];\n\n break;\n\n case RFC2132_REQ_ADDR:\n\n if (len >= 4)\n\n *preq_addr = (struct in_addr *)p;\n\n break;\n\n default:\n\n break;\n\n }\n\n p += len;\n\n }\n\n }\n\n if (*pmsg_type == DHCPREQUEST && !*preq_addr && bp->bp_ciaddr.s_addr) {\n\n *preq_addr = &bp->bp_ciaddr;\n\n }\n\n}\n", + "output": "0", + "index": 26001 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_proc_970MP (CPUPPCState *env)\n\n{\n\n gen_spr_ne_601(env);\n\n gen_spr_7xx(env);\n\n /* Time base */\n\n gen_tbl(env);\n\n /* Hardware implementation registers */\n\n /* XXX : not implemented */\n\n spr_register(env, SPR_HID0, \"HID0\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_clear,\n\n 0x60000000);\n\n /* XXX : not implemented */\n\n spr_register(env, SPR_HID1, \"HID1\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n /* XXX : not implemented */\n\n spr_register(env, SPR_970_HID5, \"HID5\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n POWERPC970_HID5_INIT);\n\n /* XXX : not implemented */\n\n /* Memory management */\n\n /* XXX: not correct */\n\n gen_low_BATs(env);\n\n spr_register(env, SPR_HIOR, \"SPR_HIOR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_hior, &spr_write_hior,\n\n 0x00000000);\n\n /* Logical partitionning */\n\n spr_register_kvm(env, SPR_LPCR, \"LPCR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n KVM_REG_PPC_LPCR, 0x00000000);\n\n#if !defined(CONFIG_USER_ONLY)\n\n env->slb_nr = 32;\n\n#endif\n\n init_excp_970(env);\n\n env->dcache_line_size = 128;\n\n env->icache_line_size = 128;\n\n /* Allocate hardware IRQ controller */\n\n ppc970_irq_init(env);\n\n /* Can't find information on what this should be on reset. This\n\n * value is the one used by 74xx processors. */\n\n vscr_init(env, 0x00010000);\n\n}\n", + "output": "0", + "index": 7943 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)\n{\n int ret, flush = 0;\n if (pkt) {\n AVStream *st = s->streams[pkt->stream_index];\n //FIXME/XXX/HACK drop zero sized packets\n if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size == 0)\n return 0;\n av_dlog(s, \"av_interleaved_write_frame size:%d dts:%\" PRId64 \" pts:%\" PRId64 \"\\n\",\n pkt->size, pkt->dts, pkt->pts);\n if ((ret = compute_pkt_fields2(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))\n if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))\n return AVERROR(EINVAL);\n } else {\n av_dlog(s, \"av_interleaved_write_frame FLUSH\\n\");\n flush = 1;\n }\n for (;; ) {\n AVPacket opkt;\n int ret = interleave_packet(s, &opkt, pkt, flush);\n if (ret <= 0) //FIXME cleanup needed for ret<0 ?\n ret = write_packet(s, &opkt);\n if (ret >= 0)\n s->streams[opkt.stream_index]->nb_frames++;\n av_free_packet(&opkt);\n pkt = NULL;\n }\n}", + "output": "1", + "index": 13623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg)\n\n{\n\n QEMUClockType type;\n\n bool progress = false;\n\n for (type = 0; type < QEMU_CLOCK_MAX; type++) {\n\n progress |= timerlist_run_timers(tlg->tl[type]);\n\n }\n\n return progress;\n\n}\n", + "output": "0", + "index": 14260 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *qemu_get_version(void)\n\n{\n\n return qemu_version;\n\n}\n", + "output": "0", + "index": 23815 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_rle_sgi(const SGIInfo *sgi_info, \n\n AVPicture *pict, ByteIOContext *f)\n\n{\n\n uint8_t *dest_row, *rle_data = NULL;\n\n unsigned long *start_table, *length_table;\n\n int y, z, xsize, ysize, zsize, tablen; \n\n long start_offset, run_length;\n\n int ret = 0;\n\n\n\n xsize = sgi_info->xsize;\n\n ysize = sgi_info->ysize;\n\n zsize = sgi_info->zsize;\n\n\n\n rle_data = av_malloc(xsize);\n\n\n\n /* skip header */ \n\n url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);\n\n\n\n /* size of rle offset and length tables */\n\n tablen = ysize * zsize * sizeof(long);\n\n\n\n start_table = (unsigned long *)av_malloc(tablen);\n\n length_table = (unsigned long *)av_malloc(tablen);\n\n\n\n if (!get_buffer(f, (uint8_t *)start_table, tablen)) {\n\n ret = -1;\n\n goto fail;\n\n }\n\n\n\n if (!get_buffer(f, (uint8_t *)length_table, tablen)) {\n\n ret = -1;\n\n goto fail;\n\n }\n\n\n\n for (z = 0; z < zsize; z++) {\n\n for (y = 0; y < ysize; y++) {\n\n dest_row = pict->data[0] + (ysize - 1 - y) * (xsize * zsize);\n\n\n\n start_offset = BE_32(&start_table[y + z * ysize]);\n\n run_length = BE_32(&length_table[y + z * ysize]);\n\n\n\n /* don't seek if already in the correct spot */\n\n if (url_ftell(f) != start_offset) {\n\n url_fseek(f, start_offset, SEEK_SET);\n\n }\n\n\n\n get_buffer(f, rle_data, run_length);\n\n \n\n expand_rle_row(dest_row, rle_data, z, zsize);\n\n }\n\n }\n\n\n\nfail:\n\n av_free(start_table);\n\n av_free(length_table);\n\n av_free(rle_data);\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 17226 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void opt_pad_color(const char *arg) {\n\n /* Input is expected to be six hex digits similar to\n\n how colors are expressed in html tags (but without the #) */\n\n int rgb = strtol(arg, NULL, 16);\n\n int r,g,b;\n\n\n\n r = (rgb >> 16);\n\n g = ((rgb >> 8) & 255);\n\n b = (rgb & 255);\n\n\n\n padcolor[0] = RGB_TO_Y(r,g,b);\n\n padcolor[1] = RGB_TO_U(r,g,b,0);\n\n padcolor[2] = RGB_TO_V(r,g,b,0);\n\n}\n", + "output": "0", + "index": 21586 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void downmix_mono_to_stereo(float *samples)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < 256; i++)\n\n samples[i + 256] = samples[i];\n\n}\n", + "output": "0", + "index": 20383 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool xen_host_pci_dev_is_virtfn(XenHostPCIDevice *d)\n\n{\n\n char path[PATH_MAX];\n\n struct stat buf;\n\n\n\n if (xen_host_pci_sysfs_path(d, \"physfn\", path, sizeof (path))) {\n\n return false;\n\n }\n\n return !stat(path, &buf);\n\n}\n", + "output": "1", + "index": 6638 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ram_addr_t qxl_rom_size(void)\n\n{\n\n uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +\n\n sizeof(qxl_modes);\n\n uint32_t rom_size = 8192; /* two pages */\n\n\n\n QEMU_BUILD_BUG_ON(required_rom_size > rom_size);\n\n return rom_size;\n\n}\n", + "output": "1", + "index": 10345 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void memory_region_initfn(Object *obj)\n\n{\n\n MemoryRegion *mr = MEMORY_REGION(obj);\n\n ObjectProperty *op;\n\n\n\n mr->ops = &unassigned_mem_ops;\n\n mr->enabled = true;\n\n mr->romd_mode = true;\n\n mr->global_locking = true;\n\n mr->destructor = memory_region_destructor_none;\n\n QTAILQ_INIT(&mr->subregions);\n\n QTAILQ_INIT(&mr->coalesced);\n\n\n\n op = object_property_add(OBJECT(mr), \"container\",\n\n \"link<\" TYPE_MEMORY_REGION \">\",\n\n memory_region_get_container,\n\n NULL, /* memory_region_set_container */\n\n NULL, NULL, &error_abort);\n\n op->resolve = memory_region_resolve_container;\n\n\n\n object_property_add(OBJECT(mr), \"addr\", \"uint64\",\n\n memory_region_get_addr,\n\n NULL, /* memory_region_set_addr */\n\n NULL, NULL, &error_abort);\n\n object_property_add(OBJECT(mr), \"priority\", \"uint32\",\n\n memory_region_get_priority,\n\n NULL, /* memory_region_set_priority */\n\n NULL, NULL, &error_abort);\n\n object_property_add_bool(OBJECT(mr), \"may-overlap\",\n\n memory_region_get_may_overlap,\n\n NULL, /* memory_region_set_may_overlap */\n\n &error_abort);\n\n object_property_add(OBJECT(mr), \"size\", \"uint64\",\n\n memory_region_get_size,\n\n NULL, /* memory_region_set_size, */\n\n NULL, NULL, &error_abort);\n\n}\n", + "output": "0", + "index": 3340 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)\n\n{\n\n VirtIOBlock *s = VIRTIO_BLK(vdev);\n\n BlockConf *conf = &s->conf.conf;\n\n struct virtio_blk_config blkcfg;\n\n uint64_t capacity;\n\n int blk_size = conf->logical_block_size;\n\n\n\n bdrv_get_geometry(s->bs, &capacity);\n\n memset(&blkcfg, 0, sizeof(blkcfg));\n\n virtio_stq_p(vdev, &blkcfg.capacity, capacity);\n\n virtio_stl_p(vdev, &blkcfg.seg_max, 128 - 2);\n\n virtio_stw_p(vdev, &blkcfg.cylinders, conf->cyls);\n\n virtio_stl_p(vdev, &blkcfg.blk_size, blk_size);\n\n virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size);\n\n virtio_stw_p(vdev, &blkcfg.opt_io_size, conf->opt_io_size / blk_size);\n\n blkcfg.heads = conf->heads;\n\n /*\n\n * We must ensure that the block device capacity is a multiple of\n\n * the logical block size. If that is not the case, let's use\n\n * sector_mask to adopt the geometry to have a correct picture.\n\n * For those devices where the capacity is ok for the given geometry\n\n * we don't touch the sector value of the geometry, since some devices\n\n * (like s390 dasd) need a specific value. Here the capacity is already\n\n * cyls*heads*secs*blk_size and the sector value is not block size\n\n * divided by 512 - instead it is the amount of blk_size blocks\n\n * per track (cylinder).\n\n */\n\n if (bdrv_getlength(s->bs) / conf->heads / conf->secs % blk_size) {\n\n blkcfg.sectors = conf->secs & ~s->sector_mask;\n\n } else {\n\n blkcfg.sectors = conf->secs;\n\n }\n\n blkcfg.size_max = 0;\n\n blkcfg.physical_block_exp = get_physical_block_exp(conf);\n\n blkcfg.alignment_offset = 0;\n\n blkcfg.wce = bdrv_enable_write_cache(s->bs);\n\n memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));\n\n}\n", + "output": "0", + "index": 15977 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t bonito_readl(void *opaque, target_phys_addr_t addr)\n\n{\n\n PCIBonitoState *s = opaque;\n\n uint32_t saddr;\n\n\n\n saddr = (addr - BONITO_REGBASE) >> 2;\n\n\n\n DPRINTF(\"bonito_readl \"TARGET_FMT_plx\" \\n\", addr);\n\n switch (saddr) {\n\n case BONITO_INTISR:\n\n return s->regs[saddr];\n\n default:\n\n return s->regs[saddr];\n\n }\n\n}\n", + "output": "0", + "index": 21513 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)\n\n{\n\n #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + CONFIG_HEVC_VAAPI_HWACCEL + CONFIG_HEVC_VDPAU_HWACCEL)\n\n enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;\n\n\n\n switch (sps->pix_fmt) {\n\n case AV_PIX_FMT_YUV420P:\n\n case AV_PIX_FMT_YUVJ420P:\n\n#if CONFIG_HEVC_DXVA2_HWACCEL\n\n *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n\n#endif\n\n#if CONFIG_HEVC_D3D11VA_HWACCEL\n\n *fmt++ = AV_PIX_FMT_D3D11VA_VLD;\n\n#endif\n\n#if CONFIG_HEVC_VAAPI_HWACCEL\n\n *fmt++ = AV_PIX_FMT_VAAPI;\n\n#endif\n\n#if CONFIG_HEVC_VDPAU_HWACCEL\n\n *fmt++ = AV_PIX_FMT_VDPAU;\n\n#endif\n\n break;\n\n case AV_PIX_FMT_YUV420P10:\n\n#if CONFIG_HEVC_DXVA2_HWACCEL\n\n *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n\n#endif\n\n#if CONFIG_HEVC_D3D11VA_HWACCEL\n\n *fmt++ = AV_PIX_FMT_D3D11VA_VLD;\n\n#endif\n\n#if CONFIG_HEVC_VAAPI_HWACCEL\n\n *fmt++ = AV_PIX_FMT_VAAPI;\n\n#endif\n\n break;\n\n }\n\n\n\n *fmt++ = sps->pix_fmt;\n\n *fmt = AV_PIX_FMT_NONE;\n\n\n\n return ff_thread_get_format(s->avctx, pix_fmts);\n\n}\n", + "output": "0", + "index": 5316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_pointer_type_change(Notifier *notifier, void *data)\n\n{\n\n VncState *vs = container_of(notifier, VncState, mouse_mode_notifier);\n\n int absolute = qemu_input_is_absolute();\n\n\n\n if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE) && vs->absolute != absolute) {\n\n vnc_lock_output(vs);\n\n vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);\n\n vnc_write_u8(vs, 0);\n\n vnc_write_u16(vs, 1);\n\n vnc_framebuffer_update(vs, absolute, 0,\n\n surface_width(vs->vd->ds),\n\n surface_height(vs->vd->ds),\n\n VNC_ENCODING_POINTER_TYPE_CHANGE);\n\n vnc_unlock_output(vs);\n\n vnc_flush(vs);\n\n }\n\n vs->absolute = absolute;\n\n}\n", + "output": "1", + "index": 524 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,\n\n const uint8_t *key, size_t nkey,\n\n Error **errp)\n\n{\n\n QCryptoHmac *hmac;\n\n void *ctx = NULL;\n\n Error *err2 = NULL;\n\n QCryptoHmacDriver *drv = NULL;\n\n\n\n#ifdef CONFIG_AF_ALG\n\n ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);\n\n if (ctx) {\n\n drv = &qcrypto_hmac_afalg_driver;\n\n }\n\n#endif\n\n\n\n if (!ctx) {\n\n ctx = qcrypto_hmac_ctx_new(alg, key, nkey, errp);\n\n if (!ctx) {\n\n return NULL;\n\n }\n\n\n\n drv = &qcrypto_hmac_lib_driver;\n\n error_free(err2);\n\n }\n\n\n\n hmac = g_new0(QCryptoHmac, 1);\n\n hmac->alg = alg;\n\n hmac->opaque = ctx;\n\n hmac->driver = (void *)drv;\n\n\n\n return hmac;\n\n}\n", + "output": "1", + "index": 24546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int png_decode_idat(PNGDecContext *s, int length)\n\n{\n\n int ret;\n\n s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb));\n\n s->zstream.next_in = (unsigned char *)s->gb.buffer;\n\n bytestream2_skip(&s->gb, length);\n\n\n\n /* decode one line if possible */\n\n while (s->zstream.avail_in > 0) {\n\n ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);\n\n if (ret != Z_OK && ret != Z_STREAM_END) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"inflate returned error %d\\n\", ret);\n\n return AVERROR_EXTERNAL;\n\n }\n\n if (s->zstream.avail_out == 0) {\n\n if (!(s->state & PNG_ALLIMAGE)) {\n\n png_handle_row(s);\n\n }\n\n s->zstream.avail_out = s->crow_size;\n\n s->zstream.next_out = s->crow_buf;\n\n }\n\n if (ret == Z_STREAM_END && s->zstream.avail_in > 0) {\n\n av_log(NULL, AV_LOG_WARNING,\n\n \"%d undecompressed bytes left in buffer\\n\", s->zstream.avail_in);\n\n return 0;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 10517 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void flush(AVCodecContext *avctx)\n\n{\n\n WmallDecodeCtx *s = avctx->priv_data;\n\n s->packet_loss = 1;\n\n s->packet_done = 0;\n\n s->num_saved_bits = 0;\n\n s->frame_offset = 0;\n\n s->next_packet_start = 0;\n\n s->cdlms[0][0].order = 0;\n\n s->frame.nb_samples = 0;\n\n init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);\n\n}\n", + "output": "1", + "index": 643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_synth_lsetxattr(FsContext *ctx, V9fsPath *path,\n\n const char *name, void *value,\n\n size_t size, int flags)\n\n{\n\n errno = ENOTSUP;\n\n return -1;\n\n}\n", + "output": "0", + "index": 15652 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void blockdev_mark_auto_del(BlockDriverState *bs)\n\n{\n\n BlockBackend *blk = bs->blk;\n\n DriveInfo *dinfo = blk_legacy_dinfo(blk);\n\n\n\n if (dinfo && !dinfo->enable_auto_del) {\n\n return;\n\n }\n\n\n\n if (bs->job) {\n\n block_job_cancel(bs->job);\n\n }\n\n if (dinfo) {\n\n dinfo->auto_del = 1;\n\n }\n\n}\n", + "output": "0", + "index": 16731 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,\n\n int *need_next_header, int *new_frame_start)\n\n{\n\n int err;\n\n union {\n\n uint64_t u64;\n\n uint8_t u8[8];\n\n } tmp = { av_be2ne64(state) };\n\n AC3HeaderInfo hdr, *phdr = &hdr;\n\n GetBitContext gbc;\n\n\n\n init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);\n\n err = avpriv_ac3_parse_header2(&gbc, &phdr);\n\n\n\n if(err < 0)\n\n return 0;\n\n\n\n hdr_info->sample_rate = hdr.sample_rate;\n\n hdr_info->bit_rate = hdr.bit_rate;\n\n hdr_info->channels = hdr.channels;\n\n hdr_info->channel_layout = hdr.channel_layout;\n\n hdr_info->samples = hdr.num_blocks * 256;\n\n hdr_info->service_type = hdr.bitstream_mode;\n\n if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)\n\n hdr_info->service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;\n\n if(hdr.bitstream_id>10)\n\n hdr_info->codec_id = AV_CODEC_ID_EAC3;\n\n else if (hdr_info->codec_id == AV_CODEC_ID_NONE)\n\n hdr_info->codec_id = AV_CODEC_ID_AC3;\n\n\n\n *need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT);\n\n *new_frame_start = (hdr.frame_type != EAC3_FRAME_TYPE_DEPENDENT);\n\n return hdr.frame_size;\n\n}\n", + "output": "1", + "index": 519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_rtc_reset(struct omap_rtc_s *s)\n\n{\n\n struct tm tm;\n\n\n\n s->interrupts = 0;\n\n s->comp_reg = 0;\n\n s->running = 0;\n\n s->pm_am = 0;\n\n s->auto_comp = 0;\n\n s->round = 0;\n\n s->tick = qemu_get_clock(rt_clock);\n\n memset(&s->alarm_tm, 0, sizeof(s->alarm_tm));\n\n s->alarm_tm.tm_mday = 0x01;\n\n s->status = 1 << 7;\n\n qemu_get_timedate(&tm, 0);\n\n s->ti = mktimegm(&tm);\n\n\n\n omap_rtc_alarm_update(s);\n\n omap_rtc_tick(s);\n\n}\n", + "output": "0", + "index": 11167 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool qemu_gluster_test_seek(struct glfs_fd *fd)\n\n{\n\n off_t ret, eof;\n\n\n\n eof = glfs_lseek(fd, 0, SEEK_END);\n\n if (eof < 0) {\n\n /* this should never occur */\n\n return false;\n\n }\n\n\n\n /* this should always fail with ENXIO if SEEK_DATA is supported */\n\n ret = glfs_lseek(fd, eof, SEEK_DATA);\n\n return (ret < 0) && (errno == ENXIO);\n\n}\n", + "output": "0", + "index": 3035 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int vp9_decode_free(AVCodecContext *ctx)\n\n{\n\n VP9Context *s = ctx->priv_data;\n\n int i;\n\n\n\n for (i = 0; i < 2; i++) {\n\n if (s->frames[i].tf.f->data[0])\n\n vp9_unref_frame(ctx, &s->frames[i]);\n\n av_frame_free(&s->frames[i].tf.f);\n\n }\n\n for (i = 0; i < 8; i++) {\n\n if (s->refs[i].f->data[0])\n\n ff_thread_release_buffer(ctx, &s->refs[i]);\n\n av_frame_free(&s->refs[i].f);\n\n if (s->next_refs[i].f->data[0])\n\n ff_thread_release_buffer(ctx, &s->next_refs[i]);\n\n av_frame_free(&s->next_refs[i].f);\n\n }\n\n av_freep(&s->above_partition_ctx);\n\n av_freep(&s->c_b);\n\n s->c_b_size = 0;\n\n av_freep(&s->b_base);\n\n av_freep(&s->block_base);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 25124 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void set_system_io_map(MemoryRegion *mr)\n\n{\n\n memory_region_transaction_begin();\n\n address_space_io.root = mr;\n\n memory_region_transaction_commit();\n\n}\n", + "output": "1", + "index": 17342 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_optimal_param(uint32_t sum, int n)\n\n{\n\n int k;\n\n uint32_t sum2;\n\n\n\n if (sum <= n >> 1)\n\n return 0;\n\n sum2 = sum - (n >> 1);\n\n k = av_log2(n < 256 ? FASTDIV(sum2, n) : sum2 / n);\n\n return FFMIN(k, MAX_RICE_PARAM);\n\n}\n", + "output": "1", + "index": 21905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,\n\n BlockCompletionFunc *completion_cb,\n\n void *opaque)\n\n{\n\n Error *local_err = NULL;\n\n int err;\n\n\n\n bdrv_add_key(bs, NULL, &local_err);\n\n if (!local_err) {\n\n if (completion_cb)\n\n completion_cb(opaque, 0);\n\n return 0;\n\n }\n\n\n\n /* Need a key for @bs */\n\n\n\n if (monitor_ctrl_mode(mon)) {\n\n qerror_report_err(local_err);\n\n\n return -1;\n\n }\n\n\n\n\n monitor_printf(mon, \"%s (%s) is encrypted.\\n\", bdrv_get_device_name(bs),\n\n bdrv_get_encrypted_filename(bs));\n\n\n\n mon->password_completion_cb = completion_cb;\n\n mon->password_opaque = opaque;\n\n\n\n err = monitor_read_password(mon, bdrv_password_cb, bs);\n\n\n\n if (err && completion_cb)\n\n completion_cb(opaque, err);\n\n\n\n return err;\n\n}", + "output": "1", + "index": 9159 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1,\n\n TCGv arg2, int add_ca, int compute_ca,\n\n int compute_ov)\n\n{\n\n TCGv t0, t1;\n\n\n\n if ((!compute_ca && !compute_ov) ||\n\n (!TCGV_EQUAL(ret,arg1) && !TCGV_EQUAL(ret, arg2))) {\n\n t0 = ret;\n\n } else {\n\n t0 = tcg_temp_local_new();\n\n }\n\n\n\n if (add_ca) {\n\n t1 = tcg_temp_local_new();\n\n tcg_gen_mov_tl(t1, cpu_ca);\n\n } else {\n\n TCGV_UNUSED(t1);\n\n }\n\n\n\n if (compute_ca) {\n\n /* Start with XER CA disabled, the most likely case */\n\n tcg_gen_movi_tl(cpu_ca, 0);\n\n }\n\n if (compute_ov) {\n\n /* Start with XER OV disabled, the most likely case */\n\n tcg_gen_movi_tl(cpu_ov, 0);\n\n }\n\n\n\n tcg_gen_add_tl(t0, arg1, arg2);\n\n\n\n if (compute_ca) {\n\n gen_op_arith_compute_ca(ctx, t0, arg1, 0);\n\n }\n\n if (add_ca) {\n\n tcg_gen_add_tl(t0, t0, t1);\n\n gen_op_arith_compute_ca(ctx, t0, t1, 0);\n\n tcg_temp_free(t1);\n\n }\n\n if (compute_ov) {\n\n gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 0);\n\n }\n\n\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, t0);\n\n\n\n if (!TCGV_EQUAL(t0, ret)) {\n\n tcg_gen_mov_tl(ret, t0);\n\n tcg_temp_free(t0);\n\n }\n\n}\n", + "output": "1", + "index": 1507 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,\n\n uint64_t value, unsigned size)\n\n{\n\n fw_cfg_write(opaque, (uint8_t)value);\n\n}\n", + "output": "0", + "index": 23138 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int vfio_container_ioctl(AddressSpace *as, int32_t groupid,\n\n int req, void *param)\n\n{\n\n /* We allow only certain ioctls to the container */\n\n switch (req) {\n\n case VFIO_CHECK_EXTENSION:\n\n case VFIO_IOMMU_SPAPR_TCE_GET_INFO:\n\n case VFIO_EEH_PE_OP:\n\n break;\n\n default:\n\n /* Return an error on unknown requests */\n\n error_report(\"vfio: unsupported ioctl %X\", req);\n\n return -1;\n\n }\n\n\n\n return vfio_container_do_ioctl(as, groupid, req, param);\n\n}\n", + "output": "0", + "index": 885 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len,\n\n uint64_t prp1, uint64_t prp2)\n\n{\n\n QEMUSGList qsg;\n\n QEMUIOVector iov;\n\n uint16_t status = NVME_SUCCESS;\n\n\n\n if (nvme_map_prp(&qsg, &iov, prp1, prp2, len, n)) {\n\n return NVME_INVALID_FIELD | NVME_DNR;\n\n }\n\n if (qsg.nsg > 0) {\n\n if (dma_buf_read(ptr, len, &qsg)) {\n\n status = NVME_INVALID_FIELD | NVME_DNR;\n\n }\n\n qemu_sglist_destroy(&qsg);\n\n } else {\n\n if (qemu_iovec_to_buf(&iov, 0, ptr, len) != len) {\n\n status = NVME_INVALID_FIELD | NVME_DNR;\n\n }\n\n qemu_iovec_destroy(&iov);\n\n }\n\n return status;\n\n}\n", + "output": "1", + "index": 5937 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilterFormats *avfilter_all_colorspaces(void)\n\n{\n\n return avfilter_make_format_list(35,\n\n PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,\n\n PIX_FMT_YUV411P, PIX_FMT_YUV410P,\n\n PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,\n\n PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,\n\n PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,\n\n PIX_FMT_RGB32, PIX_FMT_BGR32,\n\n PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,\n\n PIX_FMT_RGB24, PIX_FMT_BGR24,\n\n PIX_FMT_RGB565, PIX_FMT_BGR565,\n\n PIX_FMT_RGB555, PIX_FMT_BGR555,\n\n PIX_FMT_RGB8, PIX_FMT_BGR8,\n\n PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,\n\n PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,\n\n PIX_FMT_GRAY8, PIX_FMT_PAL8,\n\n PIX_FMT_MONOWHITE,PIX_FMT_MONOBLACK\n\n PIX_FMT_NV12, PIX_FMT_NV21);\n\n}\n", + "output": "0", + "index": 9576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int inet_aton(const char *str, struct in_addr *add)\n\n{\n\n return inet_aton(str, add);\n\n}\n", + "output": "0", + "index": 21165 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int open_in(HLSContext *c, AVIOContext **in, const char *url)\n\n{\n\n AVDictionary *tmp = NULL;\n\n int ret;\n\n\n\n av_dict_copy(&tmp, c->avio_opts, 0);\n\n\n\n ret = avio_open2(in, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);\n\n\n\n av_dict_free(&tmp);\n\n return ret;\n\n}\n", + "output": "0", + "index": 24266 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16],\n\n ptrdiff_t stride)\n\n{\n\n vp8_idct_dc_add_c(dst + 0, block[0], stride);\n\n vp8_idct_dc_add_c(dst + 4, block[1], stride);\n\n vp8_idct_dc_add_c(dst + 8, block[2], stride);\n\n vp8_idct_dc_add_c(dst + 12, block[3], stride);\n\n}\n", + "output": "1", + "index": 8354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int add_metadata(const uint8_t **buf, int count, int type,\n\n const char *name, const char *sep, TiffContext *s)\n\n{\n\n switch(type) {\n\n case TIFF_DOUBLE: return add_doubles_metadata(buf, count, name, sep, s);\n\n case TIFF_SHORT : return add_shorts_metadata(buf, count, name, sep, s);\n\n default : return AVERROR_INVALIDDATA;\n\n };\n\n}\n", + "output": "0", + "index": 6877 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pxa27x_register_keypad(struct pxa2xx_keypad_s *kp, struct keymap *map,\n\n int size)\n\n{\n\n kp->map = (struct keymap *) qemu_mallocz(sizeof(struct keymap) * size);\n\n\n\n if(!map || size < 0x80) {\n\n fprintf(stderr, \"%s - No PXA keypad map defined\\n\", __FUNCTION__);\n\n exit(-1);\n\n }\n\n\n\n kp->map = map;\n\n qemu_add_kbd_event_handler((QEMUPutKBDEvent *) pxa27x_keyboard_event, kp);\n\n}\n", + "output": "1", + "index": 19355 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth,\n\n const uint8_t *src_in[4],\n\n int srcW, int xInc, const int16_t *hChrFilter,\n\n const int16_t *hChrFilterPos, int hChrFilterSize,\n\n uint8_t *formatConvBuffer, uint32_t *pal)\n\n{\n\n const uint8_t *src1 = src_in[1], *src2 = src_in[2];\n\n if (c->chrToYV12) {\n\n uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * FFALIGN(c->srcBpc, 8) >> 3, 16);\n\n c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal);\n\n src1= formatConvBuffer;\n\n src2= buf2;\n\n } else if (c->readChrPlanar) {\n\n uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * FFALIGN(c->srcBpc, 8) >> 3, 16);\n\n c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW);\n\n src1= formatConvBuffer;\n\n src2= buf2;\n\n }\n\n\n\n if (!c->hcscale_fast) {\n\n c->hcScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize);\n\n c->hcScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize);\n\n } else { // fast bilinear upscale / crap downscale\n\n c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc);\n\n }\n\n\n\n if (c->chrConvertRange)\n\n c->chrConvertRange(dst1, dst2, dstWidth);\n\n}\n", + "output": "1", + "index": 3397 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_ldx(DisasContext *dc, uint32_t code, uint32_t flags)\n\n{\n\n I_TYPE(instr, code);\n\n\n\n TCGv addr = tcg_temp_new();\n\n TCGv data;\n\n\n\n /*\n\n * WARNING: Loads into R_ZERO are ignored, but we must generate the\n\n * memory access itself to emulate the CPU precisely. Load\n\n * from a protected page to R_ZERO will cause SIGSEGV on\n\n * the Nios2 CPU.\n\n */\n\n if (likely(instr.b != R_ZERO)) {\n\n data = dc->cpu_R[instr.b];\n\n } else {\n\n data = tcg_temp_new();\n\n }\n\n\n\n tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);\n\n tcg_gen_qemu_ld_tl(data, addr, dc->mem_idx, flags);\n\n\n\n if (unlikely(instr.b == R_ZERO)) {\n\n tcg_temp_free(data);\n\n }\n\n\n\n tcg_temp_free(addr);\n\n}\n", + "output": "1", + "index": 25940 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void json_end_array(QJSON *json)\n\n{\n\n qstring_append(json->str, \" ]\");\n\n json->omit_comma = false;\n\n}\n", + "output": "0", + "index": 14288 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv,\n\n const char *node_name, QDict *options,\n\n int open_flags, Error **errp)\n\n{\n\n Error *local_err = NULL;\n\n int ret;\n\n\n\n bdrv_assign_node_name(bs, node_name, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return -EINVAL;\n\n }\n\n\n\n bs->drv = drv;\n\n bs->read_only = !(bs->open_flags & BDRV_O_RDWR);\n\n bs->opaque = g_malloc0(drv->instance_size);\n\n\n\n if (drv->bdrv_file_open) {\n\n assert(!drv->bdrv_needs_filename || bs->filename[0]);\n\n ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);\n\n } else if (drv->bdrv_open) {\n\n ret = drv->bdrv_open(bs, options, open_flags, &local_err);\n\n } else {\n\n ret = 0;\n\n }\n\n\n\n if (ret < 0) {\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n } else if (bs->filename[0]) {\n\n error_setg_errno(errp, -ret, \"Could not open '%s'\", bs->filename);\n\n } else {\n\n error_setg_errno(errp, -ret, \"Could not open image\");\n\n }\n\n goto free_and_fail;\n\n }\n\n\n\n ret = refresh_total_sectors(bs, bs->total_sectors);\n\n if (ret < 0) {\n\n error_setg_errno(errp, -ret, \"Could not refresh total sector count\");\n\n goto free_and_fail;\n\n }\n\n\n\n bdrv_refresh_limits(bs, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n ret = -EINVAL;\n\n goto free_and_fail;\n\n }\n\n\n\n assert(bdrv_opt_mem_align(bs) != 0);\n\n assert(bdrv_min_mem_align(bs) != 0);\n\n assert(is_power_of_2(bs->bl.request_alignment));\n\n\n\n return 0;\n\n\n\nfree_and_fail:\n\n /* FIXME Close bs first if already opened*/\n\n g_free(bs->opaque);\n\n bs->opaque = NULL;\n\n bs->drv = NULL;\n\n return ret;\n\n}\n", + "output": "1", + "index": 21400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PowerPCCPU *ppc4xx_init(const char *cpu_model,\n\n clk_setup_t *cpu_clk, clk_setup_t *tb_clk,\n\n uint32_t sysclk)\n\n{\n\n PowerPCCPU *cpu;\n\n CPUPPCState *env;\n\n\n\n /* init CPUs */\n\n cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));\n\n if (cpu == NULL) {\n\n fprintf(stderr, \"Unable to find PowerPC %s CPU definition\\n\",\n\n cpu_model);\n\n exit(1);\n\n }\n\n env = &cpu->env;\n\n\n\n cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */\n\n cpu_clk->opaque = env;\n\n /* Set time-base frequency to sysclk */\n\n tb_clk->cb = ppc_40x_timers_init(env, sysclk, PPC_INTERRUPT_PIT);\n\n tb_clk->opaque = env;\n\n ppc_dcr_init(env, NULL, NULL);\n\n /* Register qemu callbacks */\n\n qemu_register_reset(ppc4xx_reset, cpu);\n\n\n\n return cpu;\n\n}\n", + "output": "1", + "index": 26282 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic,\n\n const uint8_t *src, int src_size,\n\n int id, int bpp)\n\n{\n\n int h;\n\n uint8_t *dst;\n\n int ret;\n\n\n\n if (src_size < avctx->width * avctx->height * bpp) {\n\n av_log(avctx, AV_LOG_ERROR, \"packet too small\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n avctx->pix_fmt = id;\n\n if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)\n\n return ret;\n\n\n\n dst = pic->data[0];\n\n for (h = 0; h < avctx->height; h++) {\n\n memcpy(dst, src, avctx->width * bpp);\n\n src += avctx->width * bpp;\n\n dst += pic->linesize[0];\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 21701 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void write_section_data(MpegTSContext *ts, MpegTSFilter *tss1,\n\n const uint8_t *buf, int buf_size, int is_start)\n\n{\n\n MpegTSSectionFilter *tss = &tss1->u.section_filter;\n\n int len;\n\n\n\n if (is_start) {\n\n memcpy(tss->section_buf, buf, buf_size);\n\n tss->section_index = buf_size;\n\n tss->section_h_size = -1;\n\n tss->end_of_section_reached = 0;\n\n } else {\n\n if (tss->end_of_section_reached)\n\n return;\n\n len = 4096 - tss->section_index;\n\n if (buf_size < len)\n\n len = buf_size;\n\n memcpy(tss->section_buf + tss->section_index, buf, len);\n\n tss->section_index += len;\n\n }\n\n\n\n /* compute section length if possible */\n\n if (tss->section_h_size == -1 && tss->section_index >= 3) {\n\n len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;\n\n if (len > 4096)\n\n return;\n\n tss->section_h_size = len;\n\n }\n\n\n\n if (tss->section_h_size != -1 &&\n\n tss->section_index >= tss->section_h_size) {\n\n int crc_valid = 1;\n\n tss->end_of_section_reached = 1;\n\n\n\n if (tss->check_crc) {\n\n crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);\n\n if (crc_valid) {\n\n ts->crc_validity[ tss1->pid ] = 100;\n\n }else if (ts->crc_validity[ tss1->pid ] > -10) {\n\n ts->crc_validity[ tss1->pid ]--;\n\n }else\n\n crc_valid = 2;\n\n }\n\n if (crc_valid)\n\n tss->section_cb(tss1, tss->section_buf, tss->section_h_size);\n\n }\n\n}\n", + "output": "1", + "index": 8795 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool pc_machine_get_aligned_dimm(Object *obj, Error **errp)\n\n{\n\n PCMachineState *pcms = PC_MACHINE(obj);\n\n\n\n return pcms->enforce_aligned_dimm;\n\n}\n", + "output": "0", + "index": 21555 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,\n\n unsigned long int req, void *buf,\n\n BlockDriverCompletionFunc *cb, void *opaque)\n\n{\n\n RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);\n\n\n\n acb->bs = bs;\n\n acb->aio_type = QEMU_AIO_IOCTL;\n\n acb->aio_fildes = fd;\n\n acb->aio_offset = 0;\n\n acb->aio_ioctl_buf = buf;\n\n acb->aio_ioctl_cmd = req;\n\n\n\n return thread_pool_submit_aio(aio_worker, acb, cb, opaque);\n\n}\n", + "output": "0", + "index": 3804 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "target_ulong helper_ldl(CPUMIPSState *env, target_ulong arg1,\n\n target_ulong arg2, int mem_idx)\n\n{\n\n uint64_t tmp;\n\n\n\n tmp = do_lbu(env, arg2, mem_idx);\n\n arg1 = (arg1 & 0x00FFFFFFFFFFFFFFULL) | (tmp << 56);\n\n\n\n if (GET_LMASK64(arg2) <= 6) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 1), mem_idx);\n\n arg1 = (arg1 & 0xFF00FFFFFFFFFFFFULL) | (tmp << 48);\n\n }\n\n\n\n if (GET_LMASK64(arg2) <= 5) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 2), mem_idx);\n\n arg1 = (arg1 & 0xFFFF00FFFFFFFFFFULL) | (tmp << 40);\n\n }\n\n\n\n if (GET_LMASK64(arg2) <= 4) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 3), mem_idx);\n\n arg1 = (arg1 & 0xFFFFFF00FFFFFFFFULL) | (tmp << 32);\n\n }\n\n\n\n if (GET_LMASK64(arg2) <= 3) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 4), mem_idx);\n\n arg1 = (arg1 & 0xFFFFFFFF00FFFFFFULL) | (tmp << 24);\n\n }\n\n\n\n if (GET_LMASK64(arg2) <= 2) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 5), mem_idx);\n\n arg1 = (arg1 & 0xFFFFFFFFFF00FFFFULL) | (tmp << 16);\n\n }\n\n\n\n if (GET_LMASK64(arg2) <= 1) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 6), mem_idx);\n\n arg1 = (arg1 & 0xFFFFFFFFFFFF00FFULL) | (tmp << 8);\n\n }\n\n\n\n if (GET_LMASK64(arg2) == 0) {\n\n tmp = do_lbu(env, GET_OFFSET(arg2, 7), mem_idx);\n\n arg1 = (arg1 & 0xFFFFFFFFFFFFFF00ULL) | tmp;\n\n }\n\n\n\n return arg1;\n\n}\n", + "output": "1", + "index": 23339 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s)\n{\n if (!s)\n return -1;\n s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ);\n precalc(s->private_data);\n return 0;\n}", + "output": "1", + "index": 7595 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)\n\n{\n\n snprintf(buf, buf_size, \"%s%s%s%s%s\",\n\n perms & AV_PERM_READ ? \"r\" : \"\",\n\n perms & AV_PERM_WRITE ? \"w\" : \"\",\n\n perms & AV_PERM_PRESERVE ? \"p\" : \"\",\n\n perms & AV_PERM_REUSE ? \"u\" : \"\",\n\n perms & AV_PERM_REUSE2 ? \"U\" : \"\");\n\n return buf;\n\n}\n", + "output": "0", + "index": 10563 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,\n\n struct virtio_gpu_ctrl_command *cmd,\n\n struct iovec **iov)\n\n{\n\n struct virtio_gpu_mem_entry *ents;\n\n size_t esize, s;\n\n int i;\n\n\n\n if (ab->nr_entries > 16384) {\n\n qemu_log_mask(LOG_GUEST_ERROR,\n\n \"%s: nr_entries is too big (%d > 1024)\\n\",\n\n __func__, ab->nr_entries);\n\n return -1;\n\n }\n\n\n\n esize = sizeof(*ents) * ab->nr_entries;\n\n ents = g_malloc(esize);\n\n s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num,\n\n sizeof(*ab), ents, esize);\n\n if (s != esize) {\n\n qemu_log_mask(LOG_GUEST_ERROR,\n\n \"%s: command data size incorrect %zu vs %zu\\n\",\n\n __func__, s, esize);\n\n g_free(ents);\n\n return -1;\n\n }\n\n\n\n *iov = g_malloc0(sizeof(struct iovec) * ab->nr_entries);\n\n for (i = 0; i < ab->nr_entries; i++) {\n\n hwaddr len = ents[i].length;\n\n (*iov)[i].iov_len = ents[i].length;\n\n (*iov)[i].iov_base = cpu_physical_memory_map(ents[i].addr, &len, 1);\n\n if (!(*iov)[i].iov_base || len != ents[i].length) {\n\n qemu_log_mask(LOG_GUEST_ERROR, \"%s: failed to map MMIO memory for\"\n\n \" resource %d element %d\\n\",\n\n __func__, ab->resource_id, i);\n\n virtio_gpu_cleanup_mapping_iov(*iov, i);\n\n g_free(ents);\n\n g_free(*iov);\n\n *iov = NULL;\n\n return -1;\n\n }\n\n }\n\n g_free(ents);\n\n return 0;\n\n}\n", + "output": "0", + "index": 16535 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static double block_angle(int x, int y, int cx, int cy, MotionVector *shift)\n\n{\n\n double a1, a2, diff;\n\n\n\n a1 = atan2(y - cy, x - cx);\n\n a2 = atan2(y - cy + shift->y, x - cx + shift->x);\n\n\n\n diff = a2 - a1;\n\n\n\n return (diff > M_PI) ? diff - 2 * M_PI :\n\n (diff < -M_PI) ? diff + 2 * M_PI :\n\n diff;\n\n}\n", + "output": "1", + "index": 9143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static coroutine_fn int cow_co_read(BlockDriverState *bs, int64_t sector_num,\n\n uint8_t *buf, int nb_sectors)\n\n{\n\n int ret;\n\n BDRVCowState *s = bs->opaque;\n\n qemu_co_mutex_lock(&s->lock);\n\n ret = cow_read(bs, sector_num, buf, nb_sectors);\n\n qemu_co_mutex_unlock(&s->lock);\n\n return ret;\n\n}\n", + "output": "0", + "index": 16013 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fill_table(uint8_t* table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize,\n\n const int inc, void *y_tab)\n\n{\n\n int i;\n\n uint8_t *y_table = y_tab;\n\n\n\n y_table -= elemsize * (inc >> 9);\n\n\n\n for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {\n\n int64_t cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;\n\n table[i] = y_table + elemsize * (cb >> 16);\n\n }\n\n}\n", + "output": "1", + "index": 21583 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg)\n\n{\n\n CPU_DoubleU farg;\n\n\n\n farg.ll = arg;\n\n\n\n if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {\n\n /* Reciprocal square root of a negative nonzero number */\n\n farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1);\n\n } else {\n\n if (unlikely(float64_is_signaling_nan(farg.d))) {\n\n /* sNaN reciprocal square root */\n\n fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);\n\n }\n\n farg.d = float64_sqrt(farg.d, &env->fp_status);\n\n farg.d = float64_div(float64_one, farg.d, &env->fp_status);\n\n }\n\n return farg.ll;\n\n}\n", + "output": "0", + "index": 1287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int net_init_nic(QemuOpts *opts, const char *name, VLANState *vlan)\n\n{\n\n int idx;\n\n NICInfo *nd;\n\n const char *netdev;\n\n\n\n idx = nic_get_free_idx();\n\n if (idx == -1 || nb_nics >= MAX_NICS) {\n\n error_report(\"Too Many NICs\");\n\n return -1;\n\n }\n\n\n\n nd = &nd_table[idx];\n\n\n\n memset(nd, 0, sizeof(*nd));\n\n\n\n if ((netdev = qemu_opt_get(opts, \"netdev\"))) {\n\n nd->netdev = qemu_find_netdev(netdev);\n\n if (!nd->netdev) {\n\n error_report(\"netdev '%s' not found\", netdev);\n\n return -1;\n\n }\n\n } else {\n\n assert(vlan);\n\n nd->vlan = vlan;\n\n }\n\n if (name) {\n\n nd->name = g_strdup(name);\n\n }\n\n if (qemu_opt_get(opts, \"model\")) {\n\n nd->model = g_strdup(qemu_opt_get(opts, \"model\"));\n\n }\n\n if (qemu_opt_get(opts, \"addr\")) {\n\n nd->devaddr = g_strdup(qemu_opt_get(opts, \"addr\"));\n\n }\n\n\n\n if (qemu_opt_get(opts, \"macaddr\") &&\n\n net_parse_macaddr(nd->macaddr.a, qemu_opt_get(opts, \"macaddr\")) < 0) {\n\n error_report(\"invalid syntax for ethernet address\");\n\n return -1;\n\n }\n\n qemu_macaddr_default_if_unset(&nd->macaddr);\n\n\n\n nd->nvectors = qemu_opt_get_number(opts, \"vectors\",\n\n DEV_NVECTORS_UNSPECIFIED);\n\n if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&\n\n (nd->nvectors < 0 || nd->nvectors > 0x7ffffff)) {\n\n error_report(\"invalid # of vectors: %d\", nd->nvectors);\n\n return -1;\n\n }\n\n\n\n nd->used = 1;\n\n nb_nics++;\n\n\n\n return idx;\n\n}\n", + "output": "1", + "index": 6711 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xbzrle_cache_zero_page(ram_addr_t current_addr)\n\n{\n\n if (ram_bulk_stage || !migrate_use_xbzrle()) {\n\n return;\n\n }\n\n\n\n /* We don't care if this fails to allocate a new cache page\n\n * as long as it updated an old one */\n\n cache_insert(XBZRLE.cache, current_addr, ZERO_TARGET_PAGE);\n\n}\n", + "output": "1", + "index": 23810 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static off_t read_uint32(BlockDriverState *bs, int64_t offset)\n\n{\n\n\tuint32_t buffer;\n\n\tif (bdrv_pread(bs->file, offset, &buffer, 4) < 4)\n\n\t\treturn 0;\n\n\treturn be32_to_cpu(buffer);\n\n}\n", + "output": "1", + "index": 9137 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static XICSState *try_create_xics(const char *type, int nr_servers,\n\n int nr_irqs)\n\n{\n\n DeviceState *dev;\n\n\n\n dev = qdev_create(NULL, type);\n\n qdev_prop_set_uint32(dev, \"nr_servers\", nr_servers);\n\n qdev_prop_set_uint32(dev, \"nr_irqs\", nr_irqs);\n\n if (qdev_init(dev) < 0) {\n\n return NULL;\n\n }\n\n\n\n return XICS_COMMON(dev);\n\n}\n", + "output": "1", + "index": 239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int match_format(const char *name, const char *names)\n\n{\n\n const char *p;\n\n int len, namelen;\n\n\n\n if (!name || !names)\n\n return 0;\n\n\n\n namelen = strlen(name);\n\n while ((p = strchr(names, ','))) {\n\n len = FFMAX(p - names, namelen);\n\n if (!av_strncasecmp(name, names, len))\n\n return 1;\n\n names = p + 1;\n\n }\n\n return !av_strcasecmp(name, names);\n\n}\n", + "output": "0", + "index": 9308 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_msd_class_initfn_bot(ObjectClass *klass, void *data)\n\n{\n\n USBDeviceClass *uc = USB_DEVICE_CLASS(klass);\n\n\n\n uc->realize = usb_msd_realize_bot;\n\n\n uc->attached_settable = true;\n\n}", + "output": "1", + "index": 4791 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdvideo_decode_init(AVCodecContext *avctx)\n\n{\n\n VmdVideoContext *s = avctx->priv_data;\n\n int i;\n\n unsigned int *palette32;\n\n int palette_index = 0;\n\n unsigned char r, g, b;\n\n unsigned char *vmd_header;\n\n unsigned char *raw_palette;\n\n\n\n s->avctx = avctx;\n\n avctx->pix_fmt = PIX_FMT_PAL8;\n\n dsputil_init(&s->dsp, avctx);\n\n\n\n /* make sure the VMD header made it */\n\n if (s->avctx->extradata_size != VMD_HEADER_SIZE) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"VMD video: expected extradata size of %d\\n\",\n\n VMD_HEADER_SIZE);\n\n return -1;\n\n }\n\n vmd_header = (unsigned char *)avctx->extradata;\n\n\n\n s->unpack_buffer_size = AV_RL32(&vmd_header[800]);\n\n s->unpack_buffer = av_malloc(s->unpack_buffer_size);\n\n if (!s->unpack_buffer)\n\n return -1;\n\n\n\n /* load up the initial palette */\n\n raw_palette = &vmd_header[28];\n\n palette32 = (unsigned int *)s->palette;\n\n for (i = 0; i < PALETTE_COUNT; i++) {\n\n r = raw_palette[palette_index++] * 4;\n\n g = raw_palette[palette_index++] * 4;\n\n b = raw_palette[palette_index++] * 4;\n\n palette32[i] = (r << 16) | (g << 8) | (b);\n\n }\n\n\n\n s->frame.data[0] = s->prev_frame.data[0] = NULL;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 19334 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtas_read_pci_config(sPAPREnvironment *spapr,\n\n uint32_t token, uint32_t nargs,\n\n target_ulong args,\n\n uint32_t nret, target_ulong rets)\n\n{\n\n uint32_t val, size, addr;\n\n PCIDevice *dev = find_dev(spapr, 0, rtas_ld(args, 0));\n\n\n\n if (!dev) {\n\n rtas_st(rets, 0, -1);\n\n return;\n\n }\n\n size = rtas_ld(args, 1);\n\n addr = rtas_pci_cfgaddr(rtas_ld(args, 0));\n\n val = pci_default_read_config(dev, addr, size);\n\n rtas_st(rets, 0, 0);\n\n rtas_st(rets, 1, val);\n\n}\n", + "output": "1", + "index": 6148 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "cpu_mips_check_sign_extensions (CPUMIPSState *env, FILE *f,\n\n fprintf_function cpu_fprintf,\n\n int flags)\n\n{\n\n int i;\n\n\n\n if (!SIGN_EXT_P(env->active_tc.PC))\n\n cpu_fprintf(f, \"BROKEN: pc=0x\" TARGET_FMT_lx \"\\n\", env->active_tc.PC);\n\n if (!SIGN_EXT_P(env->active_tc.HI[0]))\n\n cpu_fprintf(f, \"BROKEN: HI=0x\" TARGET_FMT_lx \"\\n\", env->active_tc.HI[0]);\n\n if (!SIGN_EXT_P(env->active_tc.LO[0]))\n\n cpu_fprintf(f, \"BROKEN: LO=0x\" TARGET_FMT_lx \"\\n\", env->active_tc.LO[0]);\n\n if (!SIGN_EXT_P(env->btarget))\n\n cpu_fprintf(f, \"BROKEN: btarget=0x\" TARGET_FMT_lx \"\\n\", env->btarget);\n\n\n\n for (i = 0; i < 32; i++) {\n\n if (!SIGN_EXT_P(env->active_tc.gpr[i]))\n\n cpu_fprintf(f, \"BROKEN: %s=0x\" TARGET_FMT_lx \"\\n\", regnames[i], env->active_tc.gpr[i]);\n\n }\n\n\n\n if (!SIGN_EXT_P(env->CP0_EPC))\n\n cpu_fprintf(f, \"BROKEN: EPC=0x\" TARGET_FMT_lx \"\\n\", env->CP0_EPC);\n\n if (!SIGN_EXT_P(env->lladdr))\n\n cpu_fprintf(f, \"BROKEN: LLAddr=0x\" TARGET_FMT_lx \"\\n\", env->lladdr);\n\n}\n", + "output": "1", + "index": 17294 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t mmsh_seek(URLContext *h, int64_t pos, int whence)\n\n{\n\n MMSHContext *mmsh = h->priv_data;\n\n MMSContext *mms = &mmsh->mms;\n\n\n\n if(pos == 0 && whence == SEEK_CUR)\n\n return mms->asf_header_read_size + mms->remaining_in_len + mmsh->chunk_seq * mms->asf_packet_len;\n\n return AVERROR(ENOSYS);\n\n}\n", + "output": "1", + "index": 21298 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ne2000_cleanup(NetClientState *nc)\n\n{\n\n NE2000State *s = qemu_get_nic_opaque(nc);\n\n\n\n s->nic = NULL;\n\n}\n", + "output": "0", + "index": 26670 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pci_device_reset(PCIDevice *dev)\n\n{\n\n int r;\n\n\n\n dev->irq_state = 0;\n\n pci_update_irq_status(dev);\n\n /* Clear all writeable bits */\n\n pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,\n\n pci_get_word(dev->wmask + PCI_COMMAND));\n\n dev->config[PCI_CACHE_LINE_SIZE] = 0x0;\n\n dev->config[PCI_INTERRUPT_LINE] = 0x0;\n\n for (r = 0; r < PCI_NUM_REGIONS; ++r) {\n\n PCIIORegion *region = &dev->io_regions[r];\n\n if (!region->size) {\n\n continue;\n\n }\n\n\n\n if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) &&\n\n region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {\n\n pci_set_quad(dev->config + pci_bar(dev, r), region->type);\n\n } else {\n\n pci_set_long(dev->config + pci_bar(dev, r), region->type);\n\n }\n\n }\n\n pci_update_mappings(dev);\n\n}\n", + "output": "0", + "index": 21478 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_int32(QEMUFile *f, void *pv, size_t size)\n\n{\n\n int32_t *v = pv;\n\n qemu_get_sbe32s(f, v);\n\n return 0;\n\n}\n", + "output": "1", + "index": 16108 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn bdrv_mirror_top_flush(BlockDriverState *bs)\n\n{\n\n\n\n\n\n return bdrv_co_flush(bs->backing->bs);\n", + "output": "1", + "index": 10781 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int json_lexer_flush(JSONLexer *lexer)\n\n{\n\n return lexer->state == IN_START ? 0 : json_lexer_feed_char(lexer, 0);\n\n}\n", + "output": "0", + "index": 10205 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blkdebug_co_flush(BlockDriverState *bs)\n\n{\n\n BDRVBlkdebugState *s = bs->opaque;\n\n BlkdebugRule *rule = NULL;\n\n\n\n QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {\n\n if (rule->options.inject.offset == -1) {\n\n break;\n\n }\n\n }\n\n\n\n if (rule && rule->options.inject.error) {\n\n return inject_error(bs, rule);\n\n }\n\n\n\n return bdrv_co_flush(bs->file->bs);\n\n}\n", + "output": "0", + "index": 20198 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32)\n\n{\n\n CPUX86State *saved_env;\n\n\n\n saved_env = env;\n\n env = s;\n\n \n\n helper_fsave(ptr, data32);\n\n\n\n env = saved_env;\n\n}\n", + "output": "0", + "index": 23141 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int show_bsfs(void *optctx, const char *opt, const char *arg)\n\n{\n\n AVBitStreamFilter *bsf = NULL;\n\n\n\n printf(\"Bitstream filters:\\n\");\n\n while ((bsf = av_bitstream_filter_next(bsf)))\n\n printf(\"%s\\n\", bsf->name);\n\n printf(\"\\n\");\n\n return 0;\n\n}\n", + "output": "1", + "index": 1530 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int targa_encode_close(AVCodecContext *avctx)\n\n{\n\n av_frame_free(&avctx->coded_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 14837 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,\n\n int nb_samples, enum AVSampleFormat sample_fmt, int align)\n\n{\n\n uint8_t *buf;\n\n int size = av_samples_get_buffer_size(NULL, nb_channels, nb_samples,\n\n sample_fmt, align);\n\n if (size < 0)\n\n return size;\n\n\n\n buf = av_mallocz(size);\n\n if (!buf)\n\n return AVERROR(ENOMEM);\n\n\n\n size = av_samples_fill_arrays(audio_data, linesize, buf, nb_channels,\n\n nb_samples, sample_fmt, align);\n\n if (size < 0) {\n\n av_free(buf);\n\n return size;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 15532 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s)\n\n{\n\n put_be32(pb, 0x14 ); /* size */\n\n put_tag(pb, \"ftyp\");\n\n\n\n if (!strcmp(\"3gp\", s->oformat->name))\n\n put_tag(pb, \"3gp4\");\n\n else\n\n put_tag(pb, \"isom\");\n\n\n\n put_be32(pb, 0x200 );\n\n\n\n if (!strcmp(\"3gp\", s->oformat->name))\n\n put_tag(pb, \"3gp4\");\n\n else\n\n put_tag(pb, \"mp41\");\n\n\n\n return 0x14;\n\n}\n", + "output": "0", + "index": 23883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mch_realize(PCIDevice *d, Error **errp)\n\n{\n\n int i;\n\n MCHPCIState *mch = MCH_PCI_DEVICE(d);\n\n\n\n /* setup pci memory mapping */\n\n pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,\n\n mch->pci_address_space);\n\n\n\n /* smram */\n\n cpu_smm_register(&mch_set_smm, mch);\n\n memory_region_init_alias(&mch->smram_region, OBJECT(mch), \"smram-region\",\n\n mch->pci_address_space, 0xa0000, 0x20000);\n\n memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,\n\n &mch->smram_region, 1);\n\n memory_region_set_enabled(&mch->smram_region, false);\n\n init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,\n\n mch->pci_address_space, &mch->pam_regions[0],\n\n PAM_BIOS_BASE, PAM_BIOS_SIZE);\n\n for (i = 0; i < 12; ++i) {\n\n init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,\n\n mch->pci_address_space, &mch->pam_regions[i+1],\n\n PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);\n\n }\n\n /* Intel IOMMU (VT-d) */\n\n if (qemu_opt_get_bool(qemu_get_machine_opts(), \"iommu\", false)) {\n\n mch_init_dmar(mch);\n\n }\n\n}\n", + "output": "1", + "index": 13639 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ssi_slave_init(DeviceState *dev, DeviceInfo *base_info)\n\n{\n\n SSISlaveInfo *info = container_of(base_info, SSISlaveInfo, qdev);\n\n SSISlave *s = SSI_SLAVE_FROM_QDEV(dev);\n\n SSIBus *bus;\n\n\n\n bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev));\n\n if (LIST_FIRST(&bus->qbus.children) != dev\n\n || LIST_NEXT(dev, sibling) != NULL) {\n\n hw_error(\"Too many devices on SSI bus\");\n\n }\n\n\n\n s->info = info;\n\n return info->init(s);\n\n}\n", + "output": "0", + "index": 15466 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t qemu_paio_return(struct qemu_paiocb *aiocb)\n\n{\n\n ssize_t ret;\n\n\n\n pthread_mutex_lock(&lock);\n\n ret = aiocb->ret;\n\n pthread_mutex_unlock(&lock);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 7564 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void neon_store_reg(int reg, int pass, TCGv var)\n\n{\n\n tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass));\n\n dead_tmp(var);\n\n}\n", + "output": "1", + "index": 3553 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_size, int pred_order)\n\n{\n\n int sum, i, j;\n\n int coeffs[pred_order];\n\n\n\n for (i=0; igb, LPCQUANT);\n\n\n\n for (i=0; i < s->blocksize; i++) {\n\n sum = s->lpcqoffset;\n\n for (j=0; jdecoded[channel][i-j-1];\n\n s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> LPCQUANT);\n\n }\n\n}\n", + "output": "1", + "index": 22003 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool memory_region_present(MemoryRegion *container, hwaddr addr)\n\n{\n\n MemoryRegion *mr = memory_region_find(container, addr, 1).mr;\n\n if (!mr || (mr == container)) {\n\n return false;\n\n }\n\n memory_region_unref(mr);\n\n return true;\n\n}\n", + "output": "1", + "index": 26860 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void onenand_reset(OneNANDState *s, int cold)\n\n{\n\n memset(&s->addr, 0, sizeof(s->addr));\n\n s->command = 0;\n\n s->count = 1;\n\n s->bufaddr = 0;\n\n s->config[0] = 0x40c0;\n\n s->config[1] = 0x0000;\n\n onenand_intr_update(s);\n\n qemu_irq_raise(s->rdy);\n\n s->status = 0x0000;\n\n s->intstatus = cold ? 0x8080 : 0x8010;\n\n s->unladdr[0] = 0;\n\n s->unladdr[1] = 0;\n\n s->wpstatus = 0x0002;\n\n s->cycle = 0;\n\n s->otpmode = 0;\n\n s->bdrv_cur = s->bdrv;\n\n s->current = s->image;\n\n s->secs_cur = s->secs;\n\n\n\n if (cold) {\n\n /* Lock the whole flash */\n\n memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);\n\n\n\n if (s->bdrv_cur && bdrv_read(s->bdrv_cur, 0, s->boot[0], 8) < 0) {\n\n hw_error(\"%s: Loading the BootRAM failed.\\n\", __func__);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 8989 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int jpeg_write_trailer(AVFormatContext *s1)\n\n{\n\n JpegContext *s = s1->priv_data;\n\n av_free(s);\n\n return 0;\n\n}\n", + "output": "1", + "index": 20120 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_physical (CPUState *env, mmu_ctx_t *ctx,\n\n target_ulong eaddr, int rw)\n\n{\n\n int in_plb, ret;\n\n\n\n ctx->raddr = eaddr;\n\n ctx->prot = PAGE_READ;\n\n ret = 0;\n\n switch (env->mmu_model) {\n\n case POWERPC_MMU_32B:\n\n case POWERPC_MMU_SOFT_6xx:\n\n case POWERPC_MMU_SOFT_74xx:\n\n case POWERPC_MMU_601:\n\n case POWERPC_MMU_SOFT_4xx:\n\n case POWERPC_MMU_REAL_4xx:\n\n case POWERPC_MMU_BOOKE:\n\n ctx->prot |= PAGE_WRITE;\n\n break;\n\n#if defined(TARGET_PPC64)\n\n case POWERPC_MMU_64B:\n\n case POWERPC_MMU_64BRIDGE:\n\n /* Real address are 60 bits long */\n\n ctx->raddr &= 0x0FFFFFFFFFFFFFFFULL;\n\n ctx->prot |= PAGE_WRITE;\n\n break;\n\n#endif\n\n case POWERPC_MMU_SOFT_4xx_Z:\n\n if (unlikely(msr_pe != 0)) {\n\n /* 403 family add some particular protections,\n\n * using PBL/PBU registers for accesses with no translation.\n\n */\n\n in_plb =\n\n /* Check PLB validity */\n\n (env->pb[0] < env->pb[1] &&\n\n /* and address in plb area */\n\n eaddr >= env->pb[0] && eaddr < env->pb[1]) ||\n\n (env->pb[2] < env->pb[3] &&\n\n eaddr >= env->pb[2] && eaddr < env->pb[3]) ? 1 : 0;\n\n if (in_plb ^ msr_px) {\n\n /* Access in protected area */\n\n if (rw == 1) {\n\n /* Access is not allowed */\n\n ret = -2;\n\n }\n\n } else {\n\n /* Read-write access is allowed */\n\n ctx->prot |= PAGE_WRITE;\n\n }\n\n }\n\n break;\n\n case POWERPC_MMU_BOOKE_FSL:\n\n /* XXX: TODO */\n\n cpu_abort(env, \"BookE FSL MMU model not implemented\\n\");\n\n break;\n\n default:\n\n cpu_abort(env, \"Unknown or invalid MMU model\\n\");\n\n return -1;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 16431 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Object *object_dynamic_cast_assert(Object *obj, const char *typename)\n\n{\n\n Object *inst;\n\n\n\n inst = object_dynamic_cast(obj, typename);\n\n\n\n if (!inst) {\n\n fprintf(stderr, \"Object %p is not an instance of type %s\\n\",\n\n obj, typename);\n\n abort();\n\n }\n\n\n\n return inst;\n\n}\n", + "output": "1", + "index": 26933 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_bd(VIOsPAPRVLANDevice *dev, vlan_bd_t bd,\n\n target_ulong alignment)\n\n{\n\n if ((VLAN_BD_ADDR(bd) % alignment)\n\n || (VLAN_BD_LEN(bd) % alignment)) {\n\n return -1;\n\n }\n\n\n\n if (spapr_vio_check_tces(&dev->sdev, VLAN_BD_ADDR(bd),\n\n VLAN_BD_LEN(bd), SPAPR_TCE_RW) != 0) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 11931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int sd_truncate(BlockDriverState *bs, int64_t offset)\n\n{\n\n BDRVSheepdogState *s = bs->opaque;\n\n int ret, fd;\n\n unsigned int datalen;\n\n\n\n if (offset < s->inode.vdi_size) {\n\n error_report(\"shrinking is not supported\");\n\n return -EINVAL;\n\n } else if (offset > SD_MAX_VDI_SIZE) {\n\n error_report(\"too big image size\");\n\n return -EINVAL;\n\n }\n\n\n\n fd = connect_to_sdog(s->addr, s->port);\n\n if (fd < 0) {\n\n return fd;\n\n }\n\n\n\n /* we don't need to update entire object */\n\n datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);\n\n s->inode.vdi_size = offset;\n\n ret = write_object(fd, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id),\n\n s->inode.nr_copies, datalen, 0, false, s->cache_enabled);\n\n close(fd);\n\n\n\n if (ret < 0) {\n\n error_report(\"failed to update an inode.\");\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 14951 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs,\n\n\tint64_t sector_num, int nb_sectors, int* n)\n\n{\n\n BDRVVVFATState* s = bs->opaque;\n\n *n = s->sector_count - sector_num;\n\n if (*n > nb_sectors) {\n\n *n = nb_sectors;\n\n } else if (*n < 0) {\n\n return 0;\n\n }\n\n return BDRV_BLOCK_DATA;\n\n}\n", + "output": "0", + "index": 4132 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);\n\n\n\n k->init = s390_virtio_blk_init;\n\n dc->props = s390_virtio_blk_properties;\n\n}\n", + "output": "1", + "index": 7713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void shix_init(MachineState *machine)\n\n{\n\n const char *cpu_model = machine->cpu_model;\n\n int ret;\n\n SuperHCPU *cpu;\n\n struct SH7750State *s;\n\n MemoryRegion *sysmem = get_system_memory();\n\n MemoryRegion *rom = g_new(MemoryRegion, 1);\n\n MemoryRegion *sdram = g_new(MemoryRegion, 2);\n\n \n\n if (!cpu_model)\n\n cpu_model = \"any\";\n\n\n\n cpu = SUPERH_CPU(cpu_generic_init(TYPE_SUPERH_CPU, cpu_model));\n\n if (cpu == NULL) {\n\n fprintf(stderr, \"Unable to find CPU definition\\n\");\n\n exit(1);\n\n }\n\n\n\n /* Allocate memory space */\n\n memory_region_init_ram(rom, NULL, \"shix.rom\", 0x4000, &error_fatal);\n\n memory_region_set_readonly(rom, true);\n\n memory_region_add_subregion(sysmem, 0x00000000, rom);\n\n memory_region_init_ram(&sdram[0], NULL, \"shix.sdram1\", 0x01000000,\n\n &error_fatal);\n\n memory_region_add_subregion(sysmem, 0x08000000, &sdram[0]);\n\n memory_region_init_ram(&sdram[1], NULL, \"shix.sdram2\", 0x01000000,\n\n &error_fatal);\n\n memory_region_add_subregion(sysmem, 0x0c000000, &sdram[1]);\n\n\n\n /* Load BIOS in 0 (and access it through P2, 0xA0000000) */\n\n if (bios_name == NULL)\n\n bios_name = BIOS_FILENAME;\n\n ret = load_image_targphys(bios_name, 0, 0x4000);\n\n if (ret < 0 && !qtest_enabled()) {\n\n error_report(\"Could not load SHIX bios '%s'\", bios_name);\n\n exit(1);\n\n }\n\n\n\n /* Register peripherals */\n\n s = sh7750_init(cpu, sysmem);\n\n /* XXXXX Check success */\n\n tc58128_init(s, \"shix_linux_nand.bin\", NULL);\n\n}\n", + "output": "1", + "index": 24121 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sdhci_end_transfer(SDHCIState *s)\n\n{\n\n /* Automatically send CMD12 to stop transfer if AutoCMD12 enabled */\n\n if ((s->trnmod & SDHC_TRNS_ACMD12) != 0) {\n\n SDRequest request;\n\n uint8_t response[16];\n\n\n\n request.cmd = 0x0C;\n\n request.arg = 0;\n\n DPRINT_L1(\"Automatically issue CMD%d %08x\\n\", request.cmd, request.arg);\n\n sdbus_do_command(&s->sdbus, &request, response);\n\n /* Auto CMD12 response goes to the upper Response register */\n\n s->rspreg[3] = (response[0] << 24) | (response[1] << 16) |\n\n (response[2] << 8) | response[3];\n\n }\n\n\n\n s->prnsts &= ~(SDHC_DOING_READ | SDHC_DOING_WRITE |\n\n SDHC_DAT_LINE_ACTIVE | SDHC_DATA_INHIBIT |\n\n SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE);\n\n\n\n if (s->norintstsen & SDHC_NISEN_TRSCMP) {\n\n s->norintsts |= SDHC_NIS_TRSCMP;\n\n }\n\n\n\n sdhci_update_irq(s);\n\n}\n", + "output": "1", + "index": 5134 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,\n\n uint8_t *buf, int buf_size)\n\n{\n\n int size, i;\n\n uint8_t *ppcm[4] = { 0 };\n\n\n\n if (buf_size < DV_PROFILE_BYTES ||\n\n !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||\n\n buf_size < c->sys->frame_size) {\n\n return -1; /* Broken frame, or not enough data */\n\n }\n\n\n\n /* Queueing audio packet */\n\n /* FIXME: in case of no audio/bad audio we have to do something */\n\n size = dv_extract_audio_info(c, buf);\n\n for (i = 0; i < c->ach; i++) {\n\n c->audio_pkt[i].size = size;\n\n c->audio_pkt[i].pts = c->abytes * 30000 * 8 /\n\n c->ast[i]->codec->bit_rate;\n\n ppcm[i] = c->audio_buf[i];\n\n }\n\n if (c->ach)\n\n dv_extract_audio(buf, ppcm, c->sys);\n\n\n\n /* We work with 720p frames split in half, thus even frames have\n\n * channels 0,1 and odd 2,3. */\n\n if (c->sys->height == 720) {\n\n if (buf[1] & 0x0C) {\n\n c->audio_pkt[2].size = c->audio_pkt[3].size = 0;\n\n } else {\n\n c->audio_pkt[0].size = c->audio_pkt[1].size = 0;\n\n c->abytes += size;\n\n }\n\n } else {\n\n c->abytes += size;\n\n }\n\n\n\n /* Now it's time to return video packet */\n\n size = dv_extract_video_info(c, buf);\n\n av_init_packet(pkt);\n\n pkt->data = buf;\n\n pkt->size = size;\n\n pkt->flags |= AV_PKT_FLAG_KEY;\n\n pkt->stream_index = c->vst->index;\n\n pkt->pts = c->frames;\n\n\n\n c->frames++;\n\n\n\n return size;\n\n}\n", + "output": "1", + "index": 3548 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void write_palette(const char *key, QObject *obj, void *opaque)\n\n{\n\n struct palette_cb_priv *priv = opaque;\n\n VncState *vs = priv->vs;\n\n uint32_t bytes = vs->clientds.pf.bytes_per_pixel;\n\n uint8_t idx = qint_get_int(qobject_to_qint(obj));\n\n\n\n if (bytes == 4) {\n\n uint32_t color = tight_palette_buf2rgb(32, (uint8_t *)key);\n\n\n\n ((uint32_t*)priv->header)[idx] = color;\n\n } else {\n\n uint16_t color = tight_palette_buf2rgb(16, (uint8_t *)key);\n\n\n\n ((uint16_t*)priv->header)[idx] = color;\n\n }\n\n}\n", + "output": "0", + "index": 13170 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_mutex_trylock(QemuMutex *mutex)\n\n{\n\n int owned;\n\n\n\n owned = TryEnterCriticalSection(&mutex->lock);\n\n if (owned) {\n\n assert(mutex->owner == 0);\n\n mutex->owner = GetCurrentThreadId();\n\n }\n\n return !owned;\n\n}\n", + "output": "1", + "index": 24969 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t HELPER(get_r13_banked)(CPUState *env, uint32_t mode)\n\n{\n\n return env->banked_r13[bank_number(mode)];\n\n}\n", + "output": "0", + "index": 8082 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_device_config(int type, const char *cmdline)\n\n{\n\n struct device_config *conf;\n\n\n\n conf = qemu_mallocz(sizeof(*conf));\n\n conf->type = type;\n\n conf->cmdline = cmdline;\n\n TAILQ_INSERT_TAIL(&device_configs, conf, next);\n\n}\n", + "output": "0", + "index": 8973 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,\n\n const char *filename)\n\n{\n\n char buf[1024];\n\n int ret;\n\n\n\n ret = avcodec_send_packet(dec_ctx, pkt);\n\n if (ret < 0) {\n\n fprintf(stderr, \"Error sending a packet for decoding\\n\");\n\n exit(1);\n\n }\n\n\n\n while (ret >= 0) {\n\n ret = avcodec_receive_frame(dec_ctx, frame);\n\n if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)\n\n return;\n\n else if (ret < 0) {\n\n fprintf(stderr, \"Error during decoding\\n\");\n\n exit(1);\n\n }\n\n\n\n printf(\"saving frame %3d\\n\", dec_ctx->frame_number);\n\n fflush(stdout);\n\n\n\n /* the picture is allocated by the decoder. no need to\n\n free it */\n\n snprintf(buf, sizeof(buf), filename, dec_ctx->frame_number);\n\n pgm_save(frame->data[0], frame->linesize[0],\n\n frame->width, frame->height, buf);\n\n }\n\n}\n", + "output": "1", + "index": 22043 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_key(const char **ropts, const char *delim, char *key, unsigned key_size)\n\n{\n\n unsigned key_pos = 0;\n\n const char *opts = *ropts;\n\n\n\n opts += strspn(opts, WHITESPACES);\n\n while (is_key_char(*opts)) {\n\n key[key_pos++] = *opts;\n\n if (key_pos == key_size)\n\n key_pos--;\n\n (opts)++;\n\n }\n\n opts += strspn(opts, WHITESPACES);\n\n if (!*opts || !strchr(delim, *opts))\n\n return AVERROR(EINVAL);\n\n opts++;\n\n key[key_pos++] = 0;\n\n if (key_pos == key_size)\n\n key[key_pos - 4] = key[key_pos - 3] = key[key_pos - 2] = '.';\n\n *ropts = opts;\n\n return 0;\n\n}\n", + "output": "0", + "index": 21502 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int cris_bound_b(int v, int b)\n\n{\n\n\tint r = v;\n\n\tasm (\"bound.b\\t%1, %0\\n\" : \"+r\" (r) : \"ri\" (b));\n\n\treturn r;\n\n}\n", + "output": "1", + "index": 12001 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n int ret, size;\n\n // AVStream *st = s->streams[0];\n\n\n\n size= MP3_PACKET_SIZE;\n\n\n\n ret= av_get_packet(s->pb, pkt, size);\n\n\n\n\n pkt->stream_index = 0;\n\n if (ret <= 0) {\n\n if(ret<0)\n\n return ret;\n\n return AVERROR_EOF;\n\n }\n\n\n\n if (ret > ID3v1_TAG_SIZE &&\n\n memcmp(&pkt->data[ret - ID3v1_TAG_SIZE], \"TAG\", 3) == 0)\n\n ret -= ID3v1_TAG_SIZE;\n\n\n\n /* note: we need to modify the packet size here to handle the last\n\n packet */\n\n pkt->size = ret;\n\n return ret;\n\n}", + "output": "1", + "index": 15257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t ide_data_readl(void *opaque, uint32_t addr)\n{\n IDEBus *bus = opaque;\n IDEState *s = idebus_active_if(bus);\n uint8_t *p;\n int ret;\n /* PIO data access allowed only when DRQ bit is set. The result of a read\n * during PIO in is indeterminate, return 0 and don't move forward. */\n if (!(s->status & DRQ_STAT) || !ide_is_pio_out(s)) {\n p = s->data_ptr;\n ret = cpu_to_le32(*(uint32_t *)p);\n p += 4;\n s->data_ptr = p;\n if (p >= s->data_end)\n s->end_transfer_func(s);\n return ret;", + "output": "1", + "index": 17400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int l2tpv3_can_send(void *opaque)\n\n{\n\n NetL2TPV3State *s = opaque;\n\n\n\n return qemu_can_send_packet(&s->nc);\n\n}\n", + "output": "0", + "index": 25359 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void clear_float_exceptions(CPUSPARCState *env)\n\n{\n\n set_float_exception_flags(0, &env->fp_status);\n\n}\n", + "output": "0", + "index": 12448 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void replay_finish_event(void)\n\n{\n\n replay_has_unread_data = 0;\n\n replay_fetch_data_kind();\n\n}\n", + "output": "0", + "index": 26199 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nut_write_trailer(AVFormatContext *s)\n\n{\n\n NUTContext *nut = s->priv_data;\n\n ByteIOContext *bc = &s->pb;\n\n\n\n update_packetheader(nut, bc, 0);\n\n\n\n#if 0\n\n int i;\n\n\n\n /* WRITE INDEX */\n\n\n\n for (i = 0; s->nb_streams; i++)\n\n {\n\n\tput_be64(bc, INDEX_STARTCODE);\n\n\tput_packetheader(nut, bc, 64);\n\n\tput_v(bc, s->streams[i]->id);\n\n\tput_v(bc, ...);\n\n\tput_be32(bc, 0); /* FIXME: checksum */\n\n update_packetheader(nut, bc, 0);\n\n }\n\n#endif\n\n\n\n put_flush_packet(bc);\n\n \n\n av_freep(&nut->stream);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 2426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)\n\n{\n\n uint8_t *key = av_strdup(t->key);\n\n uint8_t *p = key;\n\n const uint8_t *lang = NULL;\n\n ebml_master tag;\n\n\n\n if ((p = strrchr(p, '-')) &&\n\n (lang = av_convert_lang_to(p + 1, AV_LANG_ISO639_2_BIBL)))\n\n *p = 0;\n\n\n\n p = key;\n\n while (*p) {\n\n if (*p == ' ')\n\n *p = '_';\n\n else if (*p >= 'a' && *p <= 'z')\n\n *p -= 'a' - 'A';\n\n p++;\n\n }\n\n\n\n tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);\n\n put_ebml_string(pb, MATROSKA_ID_TAGNAME, key);\n\n if (lang)\n\n put_ebml_string(pb, MATROSKA_ID_TAGLANG, lang);\n\n put_ebml_string(pb, MATROSKA_ID_TAGSTRING, t->value);\n\n end_ebml_master(pb, tag);\n\n\n\n av_freep(&key);\n\n}\n", + "output": "0", + "index": 23879 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,\n\n const target_siginfo_t *info)\n\n{\n\n tswap_siginfo(tinfo, info);\n\n return 0;\n\n}\n", + "output": "0", + "index": 2504 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int iscsi_truncate(BlockDriverState *bs, int64_t offset)\n\n{\n\n IscsiLun *iscsilun = bs->opaque;\n\n Error *local_err = NULL;\n\n\n\n if (iscsilun->type != TYPE_DISK) {\n\n return -ENOTSUP;\n\n }\n\n\n\n iscsi_readcapacity_sync(iscsilun, &local_err);\n\n if (local_err != NULL) {\n\n error_free(local_err);\n\n return -EIO;\n\n }\n\n\n\n if (offset > iscsi_getlength(bs)) {\n\n return -EINVAL;\n\n }\n\n\n\n if (iscsilun->allocationmap != NULL) {\n\n g_free(iscsilun->allocationmap);\n\n iscsilun->allocationmap =\n\n bitmap_new(DIV_ROUND_UP(bs->total_sectors,\n\n iscsilun->cluster_sectors));\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 26932 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size, int size_min,\n\n int (*transfer_func)(URLContext *h, unsigned char *buf, int size))\n\n{\n\n int ret, len;\n\n int fast_retries = 5;\n\n int64_t wait_since = 0;\n\n\n\n len = 0;\n\n while (len < size_min) {\n\n ret = transfer_func(h, buf+len, size-len);\n\n if (ret == AVERROR(EINTR))\n\n continue;\n\n if (h->flags & AVIO_FLAG_NONBLOCK)\n\n return ret;\n\n if (ret == AVERROR(EAGAIN)) {\n\n ret = 0;\n\n if (fast_retries) {\n\n fast_retries--;\n\n } else {\n\n if (h->rw_timeout) {\n\n if (!wait_since)\n\n wait_since = av_gettime();\n\n else if (av_gettime() > wait_since + h->rw_timeout)\n\n return AVERROR(EIO);\n\n }\n\n av_usleep(1000);\n\n }\n\n } else if (ret < 1)\n\n return (ret < 0 && ret != AVERROR_EOF) ? ret : len;\n\n if (ret)\n\n fast_retries = FFMAX(fast_retries, 2);\n\n len += ret;\n\n if (len < size && ff_check_interrupt(&h->interrupt_callback))\n\n return AVERROR_EXIT;\n\n }\n\n return len;\n\n}\n", + "output": "0", + "index": 5879 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_nic_uninit(PCIDevice *dev)\n\n{\n\n PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, dev);\n\n EEPRO100State *s = &d->eepro100;\n\n\n\n cpu_unregister_io_memory(s->mmio_index);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 18782 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t ahci_mem_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n AHCIState *s = opaque;\n\n uint32_t val = 0;\n\n\n\n if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {\n\n switch (addr) {\n\n case HOST_CAP:\n\n val = s->control_regs.cap;\n\n break;\n\n case HOST_CTL:\n\n val = s->control_regs.ghc;\n\n break;\n\n case HOST_IRQ_STAT:\n\n val = s->control_regs.irqstatus;\n\n break;\n\n case HOST_PORTS_IMPL:\n\n val = s->control_regs.impl;\n\n break;\n\n case HOST_VERSION:\n\n val = s->control_regs.version;\n\n break;\n\n }\n\n\n\n DPRINTF(-1, \"(addr 0x%08X), val 0x%08X\\n\", (unsigned) addr, val);\n\n } else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&\n\n (addr < (AHCI_PORT_REGS_START_ADDR +\n\n (s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) {\n\n val = ahci_port_read(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7,\n\n addr & AHCI_PORT_ADDR_OFFSET_MASK);\n\n }\n\n\n\n return val;\n\n}\n", + "output": "0", + "index": 1204 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void idr(H264Context *h){\n\n int i;\n\n ff_h264_remove_all_refs(h);\n\n h->prev_frame_num= -1;\n\n h->prev_frame_num_offset= 0;\n\n h->prev_poc_msb= 1<<16;\n\n h->prev_poc_lsb= 0;\n\n for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)\n\n h->last_pocs[i] = INT_MIN;\n\n}\n", + "output": "0", + "index": 26390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void win_stdio_close(CharDriverState *chr)\n\n{\n\n WinStdioCharState *stdio = chr->opaque;\n\n\n\n if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {\n\n CloseHandle(stdio->hInputReadyEvent);\n\n }\n\n if (stdio->hInputDoneEvent != INVALID_HANDLE_VALUE) {\n\n CloseHandle(stdio->hInputDoneEvent);\n\n }\n\n if (stdio->hInputThread != INVALID_HANDLE_VALUE) {\n\n TerminateThread(stdio->hInputThread, 0);\n\n }\n\n\n\n g_free(chr->opaque);\n\n g_free(chr);\n\n}\n", + "output": "1", + "index": 25188 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_set_fd_handler2(int fd,\n IOCanReadHandler *fd_read_poll,\n IOHandler *fd_read,\n IOHandler *fd_write,\n void *opaque)\n{\n IOHandlerRecord *ioh;\n if (!fd_read && !fd_write) {\n QLIST_FOREACH(ioh, &io_handlers, next) {\n if (ioh->fd == fd) {\n ioh->deleted = 1;\n break;\n }\n }\n } else {\n QLIST_FOREACH(ioh, &io_handlers, next) {\n if (ioh->fd == fd)\n goto found;\n }\n ioh = g_malloc0(sizeof(IOHandlerRecord));\n QLIST_INSERT_HEAD(&io_handlers, ioh, next);\n found:\n ioh->fd = fd;\n ioh->fd_read_poll = fd_read_poll;\n ioh->fd_read = fd_read;\n ioh->fd_write = fd_write;\n ioh->opaque = opaque;\n ioh->deleted = 0;\n qemu_notify_event();\n }\n return 0;\n}", + "output": "1", + "index": 13699 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_expr_parse(AVExpr **expr, const char *s,\n\n const char * const *const_names,\n\n const char * const *func1_names, double (* const *funcs1)(void *, double),\n\n const char * const *func2_names, double (* const *funcs2)(void *, double, double),\n\n int log_offset, void *log_ctx)\n\n{\n\n Parser p;\n\n AVExpr *e = NULL;\n\n char *w = av_malloc(strlen(s) + 1);\n\n char *wp = w;\n\n const char *s0 = s;\n\n int ret = 0;\n\n\n\n if (!w)\n\n return AVERROR(ENOMEM);\n\n\n\n while (*s)\n\n if (!isspace(*s++)) *wp++ = s[-1];\n\n *wp++ = 0;\n\n\n\n p.class = &class;\n\n p.stack_index=100;\n\n p.s= w;\n\n p.const_names = const_names;\n\n p.funcs1 = funcs1;\n\n p.func1_names = func1_names;\n\n p.funcs2 = funcs2;\n\n p.func2_names = func2_names;\n\n p.log_offset = log_offset;\n\n p.log_ctx = log_ctx;\n\n\n\n if ((ret = parse_expr(&e, &p)) < 0)\n\n goto end;\n\n if (*p.s) {\n\n av_log(&p, AV_LOG_ERROR, \"Invalid chars '%s' at the end of expression '%s'\\n\", p.s, s0);\n\n ret = AVERROR(EINVAL);\n\n goto end;\n\n }\n\n if (!verify_expr(e)) {\n\n av_expr_free(e);\n\n ret = AVERROR(EINVAL);\n\n goto end;\n\n }\n\n *expr = e;\n\nend:\n\n av_free(w);\n\n return ret;\n\n}\n", + "output": "0", + "index": 5633 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf)\n\n{\n\n KBDState *s = ADB_KEYBOARD(d);\n\n int keycode;\n\n int olen;\n\n\n\n olen = 0;\n\n if (s->count == 0) {\n\n return 0;\n\n }\n\n keycode = s->data[s->rptr];\n\n s->rptr++;\n\n if (s->rptr == sizeof(s->data)) {\n\n s->rptr = 0;\n\n }\n\n s->count--;\n\n /*\n\n * The power key is the only two byte value key, so it is a special case.\n\n * Since 0x7f is not a used keycode for ADB we overload it to indicate the\n\n * power button when we're storing keycodes in our internal buffer, and\n\n * expand it out to two bytes when we send to the guest.\n\n */\n\n if (keycode == 0x7f) {\n\n obuf[0] = 0x7f;\n\n obuf[1] = 0x7f;\n\n olen = 2;\n\n } else {\n\n obuf[0] = keycode;\n\n /* NOTE: the power key key-up is the two byte sequence 0xff 0xff;\n\n * otherwise we could in theory send a second keycode in the second\n\n * byte, but choose not to bother.\n\n */\n\n obuf[1] = 0xff;\n\n olen = 2;\n\n }\n\n\n\n return olen;\n\n}\n", + "output": "1", + "index": 23298 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_lcreate(void *opaque)\n\n{\n\n int32_t dfid, flags, mode;\n\n gid_t gid;\n\n ssize_t err = 0;\n\n ssize_t offset = 7;\n\n V9fsString name;\n\n V9fsFidState *fidp;\n\n struct stat stbuf;\n\n V9fsQID qid;\n\n int32_t iounit;\n\n V9fsPDU *pdu = opaque;\n\n\n\n pdu_unmarshal(pdu, offset, \"dsddd\", &dfid, &name, &flags,\n\n &mode, &gid);\n\n\n\n\n fidp = get_fid(pdu, dfid);\n\n if (fidp == NULL) {\n\n err = -ENOENT;\n\n goto out_nofid;\n\n }\n\n\n\n flags = get_dotl_openflags(pdu->s, flags);\n\n err = v9fs_co_open2(pdu, fidp, &name, gid,\n\n flags | O_CREAT, mode, &stbuf);\n\n if (err < 0) {\n\n goto out;\n\n }\n\n fidp->fid_type = P9_FID_FILE;\n\n fidp->open_flags = flags;\n\n if (flags & O_EXCL) {\n\n /*\n\n * We let the host file system do O_EXCL check\n\n * We should not reclaim such fd\n\n */\n\n fidp->flags |= FID_NON_RECLAIMABLE;\n\n }\n\n iounit = get_iounit(pdu, &fidp->path);\n\n stat_to_qid(&stbuf, &qid);\n\n offset += pdu_marshal(pdu, offset, \"Qd\", &qid, iounit);\n\n err = offset;\n\nout:\n\n put_fid(pdu, fidp);\n\nout_nofid:\n\n trace_v9fs_lcreate_return(pdu->tag, pdu->id,\n\n qid.type, qid.version, qid.path, iounit);\n\n complete_pdu(pdu->s, pdu, err);\n\n v9fs_string_free(&name);\n\n}", + "output": "1", + "index": 11055 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mtv_probe(AVProbeData *p)\n\n{\n\n if(p->buf_size < 3)\n\n return 0;\n\n\n\n /* Magic is 'AMV' */\n\n\n\n if(*(p->buf) != 'A' || *(p->buf+1) != 'M' || *(p->buf+2) != 'V')\n\n return 0;\n\n\n\n return AVPROBE_SCORE_MAX;\n\n}\n", + "output": "0", + "index": 18420 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void register_avcodec(AVCodec *codec)\n\n{\n\n AVCodec **p;\n\n\n p = &first_avcodec;\n\n while (*p != NULL) p = &(*p)->next;\n\n *p = codec;\n\n codec->next = NULL;\n\n}", + "output": "1", + "index": 10852 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hda_audio_init(HDACodecDevice *hda, const struct desc_codec *desc)\n\n{\n\n HDAAudioState *a = HDA_AUDIO(hda);\n\n HDAAudioStream *st;\n\n const desc_node *node;\n\n const desc_param *param;\n\n uint32_t i, type;\n\n\n\n a->desc = desc;\n\n a->name = object_get_typename(OBJECT(a));\n\n dprint(a, 1, \"%s: cad %d\\n\", __FUNCTION__, a->hda.cad);\n\n\n\n AUD_register_card(\"hda\", &a->card);\n\n for (i = 0; i < a->desc->nnodes; i++) {\n\n node = a->desc->nodes + i;\n\n param = hda_codec_find_param(node, AC_PAR_AUDIO_WIDGET_CAP);\n\n if (param == NULL) {\n\n continue;\n\n }\n\n type = (param->val & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;\n\n switch (type) {\n\n case AC_WID_AUD_OUT:\n\n case AC_WID_AUD_IN:\n\n assert(node->stindex < ARRAY_SIZE(a->st));\n\n st = a->st + node->stindex;\n\n st->state = a;\n\n st->node = node;\n\n if (type == AC_WID_AUD_OUT) {\n\n /* unmute output by default */\n\n st->gain_left = QEMU_HDA_AMP_STEPS;\n\n st->gain_right = QEMU_HDA_AMP_STEPS;\n\n st->bpos = sizeof(st->buf);\n\n st->output = true;\n\n } else {\n\n st->output = false;\n\n }\n\n st->format = AC_FMT_TYPE_PCM | AC_FMT_BITS_16 |\n\n (1 << AC_FMT_CHAN_SHIFT);\n\n hda_codec_parse_fmt(st->format, &st->as);\n\n hda_audio_setup(st);\n\n break;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 12756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)\n\n{\n\n seekdir(fs->dir, off);\n\n}\n", + "output": "0", + "index": 27052 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void sparc_iommu_memory_rw(void *opaque, target_phys_addr_t addr,\n\n uint8_t *buf, int len, int is_write)\n\n{\n\n int l;\n\n uint32_t flags;\n\n target_phys_addr_t page, phys_addr;\n\n\n\n while (len > 0) {\n\n page = addr & TARGET_PAGE_MASK;\n\n l = (page + TARGET_PAGE_SIZE) - addr;\n\n if (l > len)\n\n l = len;\n\n flags = iommu_page_get_flags(opaque, page);\n\n if (!(flags & IOPTE_VALID))\n\n return;\n\n phys_addr = iommu_translate_pa(opaque, addr, flags);\n\n if (is_write) {\n\n if (!(flags & IOPTE_WRITE))\n\n return;\n\n cpu_physical_memory_write(phys_addr, buf, len);\n\n } else {\n\n cpu_physical_memory_read(phys_addr, buf, len);\n\n }\n\n len -= l;\n\n buf += l;\n\n addr += l;\n\n }\n\n}\n", + "output": "0", + "index": 13176 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_write_header_metadata_sets(AVFormatContext *s)\n\n{\n\n AVStream *st;\n\n MXFStreamContext *sc = NULL;\n\n int i;\n\n\n\n mxf_write_preface(s);\n\n mxf_write_identification(s);\n\n mxf_write_content_storage(s);\n\n\n\n for (i = 0; i < s->nb_streams; i++) {\n\n st = s->streams[i];\n\n sc = av_mallocz(sizeof(MXFStreamContext));\n\n if (!sc)\n\n return AVERROR(ENOMEM);\n\n st->priv_data = sc;\n\n // set pts information\n\n if (st->codec->codec_type == CODEC_TYPE_VIDEO)\n\n av_set_pts_info(st, 64, 1, st->codec->time_base.den);\n\n else if (st->codec->codec_type == CODEC_TYPE_AUDIO)\n\n av_set_pts_info(st, 64, 1, st->codec->sample_rate);\n\n }\n\n\n\n mxf_build_structural_metadata(s, MaterialPackage);\n\n mxf_build_structural_metadata(s, SourcePackage);\n\n return 0;\n\n}\n", + "output": "0", + "index": 14611 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_vaapi_commit_slices(FFVAContext *vactx)\n\n{\n\n VABufferID *slice_buf_ids;\n\n VABufferID slice_param_buf_id, slice_data_buf_id;\n\n\n\n if (vactx->slice_count == 0)\n\n return 0;\n\n\n\n slice_buf_ids =\n\n av_fast_realloc(vactx->slice_buf_ids,\n\n &vactx->slice_buf_ids_alloc,\n\n (vactx->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0]));\n\n if (!slice_buf_ids)\n\n return -1;\n\n vactx->slice_buf_ids = slice_buf_ids;\n\n\n\n slice_param_buf_id = 0;\n\n if (vaCreateBuffer(vactx->display, vactx->context_id,\n\n VASliceParameterBufferType,\n\n vactx->slice_param_size,\n\n vactx->slice_count, vactx->slice_params,\n\n &slice_param_buf_id) != VA_STATUS_SUCCESS)\n\n return -1;\n\n vactx->slice_count = 0;\n\n\n\n slice_data_buf_id = 0;\n\n if (vaCreateBuffer(vactx->display, vactx->context_id,\n\n VASliceDataBufferType,\n\n vactx->slice_data_size,\n\n 1, (void *)vactx->slice_data,\n\n &slice_data_buf_id) != VA_STATUS_SUCCESS)\n\n return -1;\n\n vactx->slice_data = NULL;\n\n vactx->slice_data_size = 0;\n\n\n\n slice_buf_ids[vactx->n_slice_buf_ids++] = slice_param_buf_id;\n\n slice_buf_ids[vactx->n_slice_buf_ids++] = slice_data_buf_id;\n\n return 0;\n\n}\n", + "output": "0", + "index": 19931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int gdbserver_start(const char *port)\n\n{\n\n GDBState *s;\n\n char gdbstub_port_name[128];\n\n int port_num;\n\n char *p;\n\n CharDriverState *chr;\n\n\n\n if (!port || !*port)\n\n return -1;\n\n\n\n port_num = strtol(port, &p, 10);\n\n if (*p == 0) {\n\n /* A numeric value is interpreted as a port number. */\n\n snprintf(gdbstub_port_name, sizeof(gdbstub_port_name),\n\n \"tcp::%d,nowait,nodelay,server\", port_num);\n\n port = gdbstub_port_name;\n\n }\n\n\n\n chr = qemu_chr_open(\"gdb\", port);\n\n if (!chr)\n\n return -1;\n\n\n\n s = qemu_mallocz(sizeof(GDBState));\n\n if (!s) {\n\n return -1;\n\n }\n\n s->env = first_cpu; /* XXX: allow to change CPU */\n\n s->chr = chr;\n\n qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,\n\n gdb_chr_event, s);\n\n qemu_add_vm_stop_handler(gdb_vm_stopped, s);\n\n return 0;\n\n}\n", + "output": "0", + "index": 3011 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vga_update_memory_access(VGACommonState *s)\n\n{\n\n hwaddr base, offset, size;\n\n\n\n if (s->legacy_address_space == NULL) {\n\n return;\n\n }\n\n\n\n if (s->has_chain4_alias) {\n\n memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias);\n\n object_unparent(OBJECT(&s->chain4_alias));\n\n s->has_chain4_alias = false;\n\n s->plane_updated = 0xf;\n\n }\n\n if ((s->sr[VGA_SEQ_PLANE_WRITE] & VGA_SR02_ALL_PLANES) ==\n\n VGA_SR02_ALL_PLANES && s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {\n\n offset = 0;\n\n switch ((s->gr[VGA_GFX_MISC] >> 2) & 3) {\n\n case 0:\n\n base = 0xa0000;\n\n size = 0x20000;\n\n break;\n\n case 1:\n\n base = 0xa0000;\n\n size = 0x10000;\n\n offset = s->bank_offset;\n\n break;\n\n case 2:\n\n base = 0xb0000;\n\n size = 0x8000;\n\n break;\n\n case 3:\n\n default:\n\n base = 0xb8000;\n\n size = 0x8000;\n\n break;\n\n }\n\n assert(offset + size <= s->vram_size);\n\n memory_region_init_alias(&s->chain4_alias, memory_region_owner(&s->vram),\n\n \"vga.chain4\", &s->vram, offset, size);\n\n memory_region_add_subregion_overlap(s->legacy_address_space, base,\n\n &s->chain4_alias, 2);\n\n s->has_chain4_alias = true;\n\n }\n\n}\n", + "output": "1", + "index": 11549 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_flush_io_queue(BlockDriverState *bs)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n if (drv && drv->bdrv_flush_io_queue) {\n\n drv->bdrv_flush_io_queue(bs);\n\n } else if (bs->file) {\n\n bdrv_flush_io_queue(bs->file);\n\n }\n\n}\n", + "output": "0", + "index": 15438 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data,\n\n void *opaque)\n\n{\n\n struct IscsiTask *itask = opaque;\n\n struct scsi_task *task = command_data;\n\n struct scsi_inquiry_standard *inq;\n\n\n\n if (status != 0) {\n\n itask->status = 1;\n\n itask->complete = 1;\n\n scsi_free_scsi_task(task);\n\n return;\n\n }\n\n\n\n inq = scsi_datain_unmarshall(task);\n\n if (inq == NULL) {\n\n error_report(\"iSCSI: Failed to unmarshall inquiry data.\");\n\n itask->status = 1;\n\n itask->complete = 1;\n\n scsi_free_scsi_task(task);\n\n return;\n\n }\n\n\n\n itask->iscsilun->type = inq->periperal_device_type;\n\n\n\n scsi_free_scsi_task(task);\n\n\n\n switch (itask->iscsilun->type) {\n\n case TYPE_DISK:\n\n task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun,\n\n iscsi_readcapacity16_cb, opaque);\n\n if (task == NULL) {\n\n error_report(\"iSCSI: failed to send readcapacity16 command.\");\n\n itask->status = 1;\n\n itask->complete = 1;\n\n return;\n\n }\n\n break;\n\n case TYPE_ROM:\n\n task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun,\n\n 0, 0,\n\n iscsi_readcapacity10_cb, opaque);\n\n if (task == NULL) {\n\n error_report(\"iSCSI: failed to send readcapacity16 command.\");\n\n itask->status = 1;\n\n itask->complete = 1;\n\n return;\n\n }\n\n break;\n\n default:\n\n itask->status = 0;\n\n itask->complete = 1;\n\n }\n\n}\n", + "output": "1", + "index": 16618 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int pcx_encode_close(AVCodecContext *avctx)\n\n{\n\n av_frame_free(&avctx->coded_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 24701 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)\n\n{\n\n int x, y, v;\n\n FILE *f;\n\n char fname[40], fname2[40];\n\n char command[1024];\n\n\n\n snprintf(fname, 40, \"%s.ppm\", filename);\n\n\n\n f = fopen(fname, \"w\");\n\n if (!f) {\n\n perror(fname);\n\n exit(1);\n\n }\n\n fprintf(f, \"P6\\n\"\n\n \"%d %d\\n\"\n\n \"%d\\n\",\n\n w, h, 255);\n\n for(y = 0; y < h; y++) {\n\n for(x = 0; x < w; x++) {\n\n v = bitmap[y * w + x];\n\n putc((v >> 16) & 0xff, f);\n\n putc((v >> 8) & 0xff, f);\n\n putc((v >> 0) & 0xff, f);\n\n }\n\n }\n\n fclose(f);\n\n\n\n\n\n snprintf(fname2, 40, \"%s-a.pgm\", filename);\n\n\n\n f = fopen(fname2, \"w\");\n\n if (!f) {\n\n perror(fname2);\n\n exit(1);\n\n }\n\n fprintf(f, \"P5\\n\"\n\n \"%d %d\\n\"\n\n \"%d\\n\",\n\n w, h, 255);\n\n for(y = 0; y < h; y++) {\n\n for(x = 0; x < w; x++) {\n\n v = bitmap[y * w + x];\n\n putc((v >> 24) & 0xff, f);\n\n }\n\n }\n\n fclose(f);\n\n\n\n snprintf(command, 1024, \"pnmtopng -alpha %s %s > %s.png 2> /dev/null\", fname2, fname, filename);\n\n system(command);\n\n\n\n snprintf(command, 1024, \"rm %s %s\", fname, fname2);\n\n system(command);\n\n}\n", + "output": "0", + "index": 22512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_wrteei(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n#else\n\n if (unlikely(ctx->pr)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n return;\n\n }\n\n if (ctx->opcode & 0x00008000) {\n\n tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));\n\n /* Stop translation to have a chance to raise an exception */\n\n gen_stop_exception(ctx);\n\n } else {\n\n tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));\n\n }\n\n#endif\n\n}\n", + "output": "1", + "index": 25270 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static long getrampagesize(void)\n\n{\n\n long hpsize = LONG_MAX;\n\n Object *memdev_root;\n\n\n\n if (mem_path) {\n\n return gethugepagesize(mem_path);\n\n }\n\n\n\n /* it's possible we have memory-backend objects with\n\n * hugepage-backed RAM. these may get mapped into system\n\n * address space via -numa parameters or memory hotplug\n\n * hooks. we want to take these into account, but we\n\n * also want to make sure these supported hugepage\n\n * sizes are applicable across the entire range of memory\n\n * we may boot from, so we take the min across all\n\n * backends, and assume normal pages in cases where a\n\n * backend isn't backed by hugepages.\n\n */\n\n memdev_root = object_resolve_path(\"/objects\", NULL);\n\n if (!memdev_root) {\n\n return getpagesize();\n\n }\n\n\n\n object_child_foreach(memdev_root, find_max_supported_pagesize, &hpsize);\n\n\n\n if (hpsize == LONG_MAX) {\n\n return getpagesize();\n\n }\n\n\n\n if (nb_numa_nodes == 0 && hpsize > getpagesize()) {\n\n /* No NUMA nodes and normal RAM without -mem-path ==> no huge pages! */\n\n static bool warned;\n\n if (!warned) {\n\n error_report(\"Huge page support disabled (n/a for main memory).\");\n\n warned = true;\n\n }\n\n return getpagesize();\n\n }\n\n\n\n return hpsize;\n\n}\n", + "output": "1", + "index": 2686 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int MP3lame_encode_frame(AVCodecContext *avctx,\n\n unsigned char *frame, int buf_size, void *data)\n\n{\n\n Mp3AudioContext *s = avctx->priv_data;\n\n int len;\n\n int lame_result;\n\n\n\n /* lame 3.91 dies on '1-channel interleaved' data */\n\n\n\n if(data){\n\n if (s->stereo) {\n\n lame_result = lame_encode_buffer_interleaved(\n\n s->gfp,\n\n data,\n\n avctx->frame_size,\n\n s->buffer + s->buffer_index,\n\n BUFFER_SIZE - s->buffer_index\n\n );\n\n } else {\n\n lame_result = lame_encode_buffer(\n\n s->gfp,\n\n data,\n\n data,\n\n avctx->frame_size,\n\n s->buffer + s->buffer_index,\n\n BUFFER_SIZE - s->buffer_index\n\n );\n\n }\n\n }else{\n\n lame_result= lame_encode_flush(\n\n s->gfp,\n\n s->buffer + s->buffer_index,\n\n BUFFER_SIZE - s->buffer_index\n\n );\n\n }\n\n\n\n if(lame_result==-1) {\n\n /* output buffer too small */\n\n av_log(avctx, AV_LOG_ERROR, \"lame: output buffer too small (buffer index: %d, free bytes: %d)\\n\", s->buffer_index, BUFFER_SIZE - s->buffer_index);\n\n return 0;\n\n }\n\n\n\n s->buffer_index += lame_result;\n\n\n\n if(s->buffer_index<4)\n\n return 0;\n\n\n\n len= mp3len(s->buffer, NULL, NULL);\n\n//av_log(avctx, AV_LOG_DEBUG, \"in:%d packet-len:%d index:%d\\n\", avctx->frame_size, len, s->buffer_index);\n\n if(len <= s->buffer_index){\n\n memcpy(frame, s->buffer, len);\n\n s->buffer_index -= len;\n\n\n\n memmove(s->buffer, s->buffer+len, s->buffer_index);\n\n //FIXME fix the audio codec API, so we do not need the memcpy()\n\n/*for(i=0; iavctx, AV_LOG_WARNING, \"truncated header\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n s->width = AV_RL16(&buf[4]);\n\n s->height = AV_RL16(&buf[6]);\n\n\n\n ret = ff_set_dimensions(s->avctx, s->width, s->height);\n\n if (ret < 0)\n\n return ret;\n\n\n\n s->avctx->time_base.num = 1;\n\n s->avctx->time_base.den = AV_RL16(&buf[10]);\n\n\n\n pal_start = AV_RL16(&buf[12]);\n\n pal_count = AV_RL16(&buf[14]);\n\n\n\n buf += 16;\n\n for (i=pal_start; i= 3; i++) {\n\n s->palette[i] = AV_RB24(buf);\n\n buf += 3;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 20636 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_lzw_decode_init(LZWState *p, int csize, uint8_t *buf, int buf_size, int mode)\n\n{\n\n struct LZWState *s = (struct LZWState *)p;\n\n\n\n if(csize < 1 || csize > LZW_MAXBITS)\n\n return -1;\n\n /* read buffer */\n\n s->eob_reached = 0;\n\n s->pbuf = buf;\n\n s->ebuf = s->pbuf + buf_size;\n\n s->bbuf = 0;\n\n s->bbits = 0;\n\n s->bs = 0;\n\n\n\n /* decoder */\n\n s->codesize = csize;\n\n s->cursize = s->codesize + 1;\n\n s->curmask = mask[s->cursize];\n\n s->top_slot = 1 << s->cursize;\n\n s->clear_code = 1 << s->codesize;\n\n s->end_code = s->clear_code + 1;\n\n s->slot = s->newcodes = s->clear_code + 2;\n\n s->oc = s->fc = 0;\n\n s->sp = s->stack;\n\n\n\n s->mode = mode;\n\n switch(s->mode){\n\n case FF_LZW_GIF:\n\n s->extra_slot= 0;\n\n break;\n\n case FF_LZW_TIFF:\n\n s->extra_slot= 1;\n\n break;\n\n default:\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 21815 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "hwaddr ppc_hash32_get_phys_page_debug(CPUPPCState *env, target_ulong addr)\n\n{\n\n struct mmu_ctx_hash32 ctx;\n\n\n\n if (unlikely(ppc_hash32_get_physical_address(env, &ctx, addr, 0, ACCESS_INT)\n\n != 0)) {\n\n return -1;\n\n }\n\n\n\n return ctx.raddr & TARGET_PAGE_MASK;\n\n}\n", + "output": "0", + "index": 1687 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vda_h264_decode_slice(AVCodecContext *avctx,\n\n const uint8_t *buffer,\n\n uint32_t size)\n\n{\n\n VDAContext *vda = avctx->internal->hwaccel_priv_data;\n\n struct vda_context *vda_ctx = avctx->hwaccel_context;\n\n void *tmp;\n\n\n\n if (!vda_ctx->decoder)\n\n return -1;\n\n\n\n tmp = av_fast_realloc(vda->bitstream,\n\n &vda->allocated_size,\n\n vda->bitstream_size + size + 4);\n\n if (!tmp)\n\n return AVERROR(ENOMEM);\n\n\n\n vda->bitstream = tmp;\n\n\n\n AV_WB32(vda->bitstream + vda->bitstream_size, size);\n\n memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);\n\n\n\n vda->bitstream_size += size + 4;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13476 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_tco1_status_bits(void)\n\n{\n\n TestData d;\n\n uint16_t ticks = 8;\n\n uint16_t val;\n\n int ret;\n\n\n\n d.args = NULL;\n\n d.noreboot = true;\n\n test_init(&d);\n\n\n\n stop_tco(&d);\n\n clear_tco_status(&d);\n\n reset_on_second_timeout(false);\n\n set_tco_timeout(&d, ticks);\n\n load_tco(&d);\n\n start_tco(&d);\n\n clock_step(ticks * TCO_TICK_NSEC);\n\n\n\n qpci_io_writeb(d.dev, d.tco_io_base + TCO_DAT_IN, 0);\n\n qpci_io_writeb(d.dev, d.tco_io_base + TCO_DAT_OUT, 0);\n\n val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);\n\n ret = val & (TCO_TIMEOUT | SW_TCO_SMI | TCO_INT_STS) ? 1 : 0;\n\n g_assert(ret == 1);\n\n qpci_io_writew(d.dev, d.tco_io_base + TCO1_STS, val);\n\n g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS), ==, 0);\n\n qtest_end();\n\n}\n", + "output": "1", + "index": 20835 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,\n\n HEVCPPS *pps, HEVCSPS *sps) {\n\n int i;\n\n\n\n if (pps->transform_skip_enabled_flag) {\n\n pps->log2_max_transform_skip_block_size = get_ue_golomb_long(gb) + 2;\n\n }\n\n pps->cross_component_prediction_enabled_flag = get_bits1(gb);\n\n pps->chroma_qp_offset_list_enabled_flag = get_bits1(gb);\n\n if (pps->chroma_qp_offset_list_enabled_flag) {\n\n pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(gb);\n\n pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(gb);\n\n if (pps->chroma_qp_offset_list_len_minus1 && pps->chroma_qp_offset_list_len_minus1 >= 5) {\n\n av_log(avctx, AV_LOG_ERROR,\n\n \"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n for (i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) {\n\n pps->cb_qp_offset_list[i] = get_se_golomb_long(gb);\n\n if (pps->cb_qp_offset_list[i]) {\n\n av_log(avctx, AV_LOG_WARNING,\n\n \"cb_qp_offset_list not tested yet.\\n\");\n\n }\n\n pps->cr_qp_offset_list[i] = get_se_golomb_long(gb);\n\n if (pps->cr_qp_offset_list[i]) {\n\n av_log(avctx, AV_LOG_WARNING,\n\n \"cb_qp_offset_list not tested yet.\\n\");\n\n }\n\n }\n\n }\n\n pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);\n\n pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);\n\n\n\n return(0);\n\n}\n", + "output": "0", + "index": 22823 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *aio_thread(void *unused)\n\n{\n\n pid_t pid;\n\n sigset_t set;\n\n\n\n pid = getpid();\n\n\n\n /* block all signals */\n\n if (sigfillset(&set)) die(\"sigfillset\");\n\n if (sigprocmask(SIG_BLOCK, &set, NULL)) die(\"sigprocmask\");\n\n\n\n while (1) {\n\n struct qemu_paiocb *aiocb;\n\n size_t ret = 0;\n\n qemu_timeval tv;\n\n struct timespec ts;\n\n\n\n qemu_gettimeofday(&tv);\n\n ts.tv_sec = tv.tv_sec + 10;\n\n ts.tv_nsec = 0;\n\n\n\n mutex_lock(&lock);\n\n\n\n while (TAILQ_EMPTY(&request_list) &&\n\n !(ret == ETIMEDOUT)) {\n\n ret = cond_timedwait(&cond, &lock, &ts);\n\n }\n\n\n\n if (TAILQ_EMPTY(&request_list))\n\n break;\n\n\n\n aiocb = TAILQ_FIRST(&request_list);\n\n TAILQ_REMOVE(&request_list, aiocb, node);\n\n aiocb->active = 1;\n\n idle_threads--;\n\n mutex_unlock(&lock);\n\n\n\n switch (aiocb->aio_type) {\n\n case QEMU_PAIO_READ:\n\n case QEMU_PAIO_WRITE:\n\n\t\tret = handle_aiocb_rw(aiocb);\n\n\t\tbreak;\n\n case QEMU_PAIO_IOCTL:\n\n\t\tret = handle_aiocb_ioctl(aiocb);\n\n\t\tbreak;\n\n\tdefault:\n\n\t\tfprintf(stderr, \"invalid aio request (0x%x)\\n\", aiocb->aio_type);\n\n\t\tret = -EINVAL;\n\n\t\tbreak;\n\n\t}\n\n\n\n mutex_lock(&lock);\n\n aiocb->ret = ret;\n\n idle_threads++;\n\n mutex_unlock(&lock);\n\n\n\n if (kill(pid, aiocb->ev_signo)) die(\"kill failed\");\n\n }\n\n\n\n idle_threads--;\n\n cur_threads--;\n\n mutex_unlock(&lock);\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 4278 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static coroutine_fn void reconnect_to_sdog(void *opaque)\n\n{\n\n Error *local_err = NULL;\n\n BDRVSheepdogState *s = opaque;\n\n AIOReq *aio_req, *next;\n\n\n\n aio_set_fd_handler(s->aio_context, s->fd, NULL, NULL, NULL);\n\n close(s->fd);\n\n s->fd = -1;\n\n\n\n /* Wait for outstanding write requests to be completed. */\n\n while (s->co_send != NULL) {\n\n co_write_request(opaque);\n\n }\n\n\n\n /* Try to reconnect the sheepdog server every one second. */\n\n while (s->fd < 0) {\n\n s->fd = get_sheep_fd(s, &local_err);\n\n if (s->fd < 0) {\n\n DPRINTF(\"Wait for connection to be established\\n\");\n\n error_report(\"%s\", error_get_pretty(local_err));\n\n error_free(local_err);\n\n co_aio_sleep_ns(bdrv_get_aio_context(s->bs), QEMU_CLOCK_REALTIME,\n\n 1000000000ULL);\n\n }\n\n };\n\n\n\n /*\n\n * Now we have to resend all the request in the inflight queue. However,\n\n * resend_aioreq() can yield and newly created requests can be added to the\n\n * inflight queue before the coroutine is resumed. To avoid mixing them, we\n\n * have to move all the inflight requests to the failed queue before\n\n * resend_aioreq() is called.\n\n */\n\n QLIST_FOREACH_SAFE(aio_req, &s->inflight_aio_head, aio_siblings, next) {\n\n QLIST_REMOVE(aio_req, aio_siblings);\n\n QLIST_INSERT_HEAD(&s->failed_aio_head, aio_req, aio_siblings);\n\n }\n\n\n\n /* Resend all the failed aio requests. */\n\n while (!QLIST_EMPTY(&s->failed_aio_head)) {\n\n aio_req = QLIST_FIRST(&s->failed_aio_head);\n\n QLIST_REMOVE(aio_req, aio_siblings);\n\n QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);\n\n resend_aioreq(s, aio_req);\n\n }\n\n}\n", + "output": "1", + "index": 7146 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void packet_id_queue_add(struct PacketIdQueue *q, uint64_t id)\n\n{\n\n USBRedirDevice *dev = q->dev;\n\n struct PacketIdQueueEntry *e;\n\n\n\n DPRINTF(\"adding packet id %\"PRIu64\" to %s queue\\n\", id, q->name);\n\n\n\n e = g_malloc0(sizeof(struct PacketIdQueueEntry));\n\n e->id = id;\n\n QTAILQ_INSERT_TAIL(&q->head, e, next);\n\n q->size++;\n\n}\n", + "output": "1", + "index": 3083 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_readline_cb(void *opaque, const char *input)\n\n{\n\n pstrcpy(monitor_readline_buf, monitor_readline_buf_size, input);\n\n monitor_readline_started = 0;\n\n}\n", + "output": "0", + "index": 18041 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int gen_set_psr(DisasContext *s, uint32_t mask, int spsr, TCGv t0)\n\n{\n\n TCGv tmp;\n\n if (spsr) {\n\n /* ??? This is also undefined in system mode. */\n\n if (IS_USER(s))\n\n return 1;\n\n\n\n tmp = load_cpu_field(spsr);\n\n tcg_gen_andi_i32(tmp, tmp, ~mask);\n\n tcg_gen_andi_i32(t0, t0, mask);\n\n tcg_gen_or_i32(tmp, tmp, t0);\n\n store_cpu_field(tmp, spsr);\n\n } else {\n\n gen_set_cpsr(t0, mask);\n\n }\n\n dead_tmp(t0);\n\n gen_lookup_tb(s);\n\n return 0;\n\n}\n", + "output": "1", + "index": 21930 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,\n\n Error **errp)\n\n{\n\n const char *host = qemu_opt_get(opts, \"host\");\n\n const char *port = qemu_opt_get(opts, \"port\");\n\n const char *localaddr = qemu_opt_get(opts, \"localaddr\");\n\n const char *localport = qemu_opt_get(opts, \"localport\");\n\n bool has_local = false;\n\n SocketAddress *addr;\n\n\n\n if (host == NULL || strlen(host) == 0) {\n\n host = \"localhost\";\n\n }\n\n if (port == NULL || strlen(port) == 0) {\n\n error_setg(errp, \"chardev: udp: remote port not specified\");\n\n return;\n\n }\n\n if (localport == NULL || strlen(localport) == 0) {\n\n localport = \"0\";\n\n } else {\n\n has_local = true;\n\n }\n\n if (localaddr == NULL || strlen(localaddr) == 0) {\n\n localaddr = \"\";\n\n } else {\n\n has_local = true;\n\n }\n\n\n\n backend->udp = g_new0(ChardevUdp, 1);\n\n\n\n addr = g_new0(SocketAddress, 1);\n\n addr->kind = SOCKET_ADDRESS_KIND_INET;\n\n addr->inet = g_new0(InetSocketAddress, 1);\n\n addr->inet->host = g_strdup(host);\n\n addr->inet->port = g_strdup(port);\n\n addr->inet->has_ipv4 = qemu_opt_get(opts, \"ipv4\");\n\n addr->inet->ipv4 = qemu_opt_get_bool(opts, \"ipv4\", 0);\n\n addr->inet->has_ipv6 = qemu_opt_get(opts, \"ipv6\");\n\n addr->inet->ipv6 = qemu_opt_get_bool(opts, \"ipv6\", 0);\n\n backend->udp->remote = addr;\n\n\n\n if (has_local) {\n\n backend->udp->has_local = true;\n\n addr = g_new0(SocketAddress, 1);\n\n addr->kind = SOCKET_ADDRESS_KIND_INET;\n\n addr->inet = g_new0(InetSocketAddress, 1);\n\n addr->inet->host = g_strdup(localaddr);\n\n addr->inet->port = g_strdup(localport);\n\n backend->udp->local = addr;\n\n }\n\n}\n", + "output": "0", + "index": 7453 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n\n\n if (!drv) {\n\n return -ENOMEDIUM;\n\n } else if (drv->bdrv_save_vmstate) {\n\n return drv->bdrv_save_vmstate(bs, qiov, pos);\n\n } else if (bs->file) {\n\n return bdrv_writev_vmstate(bs->file, qiov, pos);\n\n }\n\n\n\n return -ENOTSUP;\n\n}\n", + "output": "0", + "index": 26573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_replaygain(MOVContext *c, AVIOContext *pb, int size)\n\n{\n\n int64_t end = avio_tell(pb) + size;\n\n uint8_t *key = NULL, *val = NULL;\n\n int i;\n\n\n\n for (i = 0; i < 2; i++) {\n\n uint8_t **p;\n\n uint32_t len, tag;\n\n\n\n if (end - avio_tell(pb) <= 12)\n\n break;\n\n\n\n len = avio_rb32(pb);\n\n tag = avio_rl32(pb);\n\n avio_skip(pb, 4); // flags\n\n\n\n if (len < 12 || len - 12 > end - avio_tell(pb))\n\n break;\n\n len -= 12;\n\n\n\n if (tag == MKTAG('n', 'a', 'm', 'e'))\n\n p = &key;\n\n else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) {\n\n avio_skip(pb, 4);\n\n len -= 4;\n\n p = &val;\n\n } else\n\n break;\n\n\n\n *p = av_malloc(len + 1);\n\n if (!*p)\n\n break;\n\n avio_read(pb, *p, len);\n\n (*p)[len] = 0;\n\n }\n\n\n\n if (key && val) {\n\n av_dict_set(&c->fc->metadata, key, val,\n\n AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);\n\n key = val = NULL;\n\n }\n\n\n\n avio_seek(pb, end, SEEK_SET);\n\n av_freep(&key);\n\n av_freep(&val);\n\n return 0;\n\n}\n", + "output": "1", + "index": 17483 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void compute_pts_dts(AVStream *st, int64_t *ppts, int64_t *pdts, \n\n int64_t timestamp)\n\n{\n\n int frame_delay;\n\n int64_t pts, dts;\n\n\n\n if (st->codec.codec_type == CODEC_TYPE_VIDEO && \n\n st->codec.max_b_frames != 0) {\n\n frame_delay = (st->codec.frame_rate_base * 90000LL) / \n\n st->codec.frame_rate;\n\n if (timestamp == 0) {\n\n /* specific case for first frame : DTS just before */\n\n pts = timestamp;\n\n dts = timestamp - frame_delay;\n\n } else {\n\n timestamp -= frame_delay;\n\n if (st->codec.coded_frame->pict_type == FF_B_TYPE) {\n\n /* B frames has identical pts/dts */\n\n pts = timestamp;\n\n dts = timestamp;\n\n } else {\n\n /* a reference frame has a pts equal to the dts of the\n\n _next_ one */\n\n dts = timestamp;\n\n pts = timestamp + (st->codec.max_b_frames + 1) * frame_delay;\n\n }\n\n }\n\n#if 1\n\n av_log(&st->codec, AV_LOG_DEBUG, \"pts=%0.3f dts=%0.3f pict_type=%c\\n\", \n\n pts / 90000.0, dts / 90000.0, \n\n av_get_pict_type_char(st->codec.coded_frame->pict_type));\n\n#endif\n\n } else {\n\n pts = timestamp;\n\n dts = timestamp;\n\n }\n\n\n\n *ppts = pts & ((1LL << 33) - 1);\n\n *pdts = dts & ((1LL << 33) - 1);\n\n}\n", + "output": "0", + "index": 2230 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_getput_regs(CPUState *env, int set)\n\n{\n\n struct kvm_regs regs;\n\n int ret = 0;\n\n\n\n if (!set) {\n\n ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, ®s);\n\n if (ret < 0)\n\n return ret;\n\n }\n\n\n\n kvm_getput_reg(®s.rax, &env->regs[R_EAX], set);\n\n kvm_getput_reg(®s.rbx, &env->regs[R_EBX], set);\n\n kvm_getput_reg(®s.rcx, &env->regs[R_ECX], set);\n\n kvm_getput_reg(®s.rdx, &env->regs[R_EDX], set);\n\n kvm_getput_reg(®s.rsi, &env->regs[R_ESI], set);\n\n kvm_getput_reg(®s.rdi, &env->regs[R_EDI], set);\n\n kvm_getput_reg(®s.rsp, &env->regs[R_ESP], set);\n\n kvm_getput_reg(®s.rbp, &env->regs[R_EBP], set);\n\n#ifdef TARGET_X86_64\n\n kvm_getput_reg(®s.r8, &env->regs[8], set);\n\n kvm_getput_reg(®s.r9, &env->regs[9], set);\n\n kvm_getput_reg(®s.r10, &env->regs[10], set);\n\n kvm_getput_reg(®s.r11, &env->regs[11], set);\n\n kvm_getput_reg(®s.r12, &env->regs[12], set);\n\n kvm_getput_reg(®s.r13, &env->regs[13], set);\n\n kvm_getput_reg(®s.r14, &env->regs[14], set);\n\n kvm_getput_reg(®s.r15, &env->regs[15], set);\n\n#endif\n\n\n\n kvm_getput_reg(®s.rflags, &env->eflags, set);\n\n kvm_getput_reg(®s.rip, &env->eip, set);\n\n\n\n if (set)\n\n ret = kvm_vcpu_ioctl(env, KVM_SET_REGS, ®s);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 18783 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void update_rice(APERice *rice, int x)\n\n{\n\n rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5);\n\n\n\n if (rice->k == 0)\n\n rice->k = 1;\n\n else if (rice->ksum < (1 << (rice->k + 4)))\n\n rice->k--;\n\n else if (rice->ksum >= (1 << (rice->k + 5)))\n\n rice->k++;\n\n}\n", + "output": "0", + "index": 11500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,\n\n const char *typename,\n\n const char *file, int line,\n\n const char *func)\n\n{\n\n ObjectClass *ret = object_class_dynamic_cast(class, typename);\n\n\n\n if (!ret && class) {\n\n fprintf(stderr, \"%s:%d:%s: Object %p is not an instance of type %s\\n\",\n\n file, line, func, class, typename);\n\n abort();\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 4583 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment)\n\n{\n\n size_t align = QEMU_VMALLOC_ALIGN;\n\n size_t total = size + align - getpagesize();\n\n void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n\n size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr;\n\n void *ptr1;\n\n\n\n if (ptr == MAP_FAILED) {\n\n return NULL;\n\n }\n\n\n\n if (alignment) {\n\n *alignment = align;\n\n }\n\n\n\n ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE,\n\n MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n\n if (ptr1 == MAP_FAILED) {\n\n munmap(ptr, total);\n\n return NULL;\n\n }\n\n\n\n ptr += offset;\n\n total -= offset;\n\n\n\n if (offset > 0) {\n\n munmap(ptr - offset, offset);\n\n }\n\n if (total > size) {\n\n munmap(ptr + size, total - size);\n\n }\n\n\n\n trace_qemu_anon_ram_alloc(size, ptr);\n\n return ptr;\n\n}\n", + "output": "1", + "index": 22918 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_reconnect(void)\n\n{\n\n gchar *path = g_strdup_printf(\"/%s/vhost-user/reconnect/subprocess\",\n\n qtest_get_arch());\n\n g_test_trap_subprocess(path, 0, 0);\n\n g_test_trap_assert_passed();\n\n\n}", + "output": "1", + "index": 15119 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cmp_func_names(const char *a, const char *b)\n\n{\n\n int ascii_diff, digit_diff;\n\n\n\n for (; !(ascii_diff = *a - *b) && *a; a++, b++);\n\n for (; av_isdigit(*a) && av_isdigit(*b); a++, b++);\n\n\n\n return (digit_diff = av_isdigit(*a) - av_isdigit(*b)) ? digit_diff : ascii_diff;\n\n}\n", + "output": "0", + "index": 8113 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilterContext *avfilter_open(AVFilter *filter, char *inst_name)\n\n{\n\n AVFilterContext *ret = av_malloc(sizeof(AVFilterContext));\n\n\n\n ret->av_class = av_mallocz(sizeof(AVClass));\n\n ret->av_class->item_name = filter_name;\n\n ret->filter = filter;\n\n ret->name = inst_name ? av_strdup(inst_name) : NULL;\n\n ret->priv = av_mallocz(filter->priv_size);\n\n\n\n ret->input_count = pad_count(filter->inputs);\n\n ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);\n\n memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad)*ret->input_count);\n\n ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);\n\n\n\n ret->output_count = pad_count(filter->outputs);\n\n ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);\n\n memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad)*ret->output_count);\n\n ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 15135 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void put_line(uint8_t *dst, int size, int width, const int *runs)\n\n{\n\n PutBitContext pb;\n\n int run, mode = ~0, pix_left = width, run_idx = 0;\n\n\n\n init_put_bits(&pb, dst, size * 8);\n\n while (pix_left > 0) {\n\n run = runs[run_idx++];\n\n mode = ~mode;\n\n pix_left -= run;\n\n for (; run > 16; run -= 16)\n\n put_sbits(&pb, 16, mode);\n\n if (run)\n\n put_sbits(&pb, run, mode);\n\n }\n\n flush_put_bits(&pb);\n\n}\n", + "output": "1", + "index": 19915 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tftp_send_next_block(struct tftp_session *spt,\n\n struct tftp_t *recv_tp)\n\n{\n\n struct sockaddr_in saddr, daddr;\n\n struct mbuf *m;\n\n struct tftp_t *tp;\n\n int nobytes;\n\n\n\n m = m_get(spt->slirp);\n\n\n\n if (!m) {\n\n return;\n\n }\n\n\n\n memset(m->m_data, 0, m->m_size);\n\n\n\n m->m_data += IF_MAXLINKHDR;\n\n tp = (void *)m->m_data;\n\n m->m_data += sizeof(struct udpiphdr);\n\n\n\n tp->tp_op = htons(TFTP_DATA);\n\n tp->x.tp_data.tp_block_nr = htons((spt->block_nr + 1) & 0xffff);\n\n\n\n saddr.sin_addr = recv_tp->ip.ip_dst;\n\n saddr.sin_port = recv_tp->udp.uh_dport;\n\n\n\n daddr.sin_addr = spt->client_ip;\n\n daddr.sin_port = spt->client_port;\n\n\n\n nobytes = tftp_read_data(spt, spt->block_nr, tp->x.tp_data.tp_buf, 512);\n\n\n\n if (nobytes < 0) {\n\n m_free(m);\n\n\n\n /* send \"file not found\" error back */\n\n\n\n tftp_send_error(spt, 1, \"File not found\", tp);\n\n\n\n return;\n\n }\n\n\n\n m->m_len = sizeof(struct tftp_t) - (512 - nobytes) -\n\n sizeof(struct ip) - sizeof(struct udphdr);\n\n\n\n udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);\n\n\n\n if (nobytes == 512) {\n\n tftp_session_update(spt);\n\n }\n\n else {\n\n tftp_session_terminate(spt);\n\n }\n\n\n\n spt->block_nr++;\n\n}\n", + "output": "0", + "index": 16841 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool remove_objects(BDRVSheepdogState *s)\n\n{\n\n int fd, i = 0, nr_objs = 0;\n\n Error *local_err = NULL;\n\n int ret = 0;\n\n bool result = true;\n\n SheepdogInode *inode = &s->inode;\n\n\n\n fd = connect_to_sdog(s, &local_err);\n\n if (fd < 0) {\n\n error_report_err(local_err);\n\n return false;\n\n }\n\n\n\n nr_objs = count_data_objs(inode);\n\n while (i < nr_objs) {\n\n int start_idx, nr_filled_idx;\n\n\n\n while (i < nr_objs && !inode->data_vdi_id[i]) {\n\n i++;\n\n }\n\n start_idx = i;\n\n\n\n nr_filled_idx = 0;\n\n while (i < nr_objs && nr_filled_idx < NR_BATCHED_DISCARD) {\n\n if (inode->data_vdi_id[i]) {\n\n inode->data_vdi_id[i] = 0;\n\n nr_filled_idx++;\n\n }\n\n\n\n i++;\n\n }\n\n\n\n ret = write_object(fd, s->bs,\n\n (char *)&inode->data_vdi_id[start_idx],\n\n vid_to_vdi_oid(s->inode.vdi_id), inode->nr_copies,\n\n (i - start_idx) * sizeof(uint32_t),\n\n offsetof(struct SheepdogInode,\n\n data_vdi_id[start_idx]),\n\n false, s->cache_flags);\n\n if (ret < 0) {\n\n error_report(\"failed to discard snapshot inode.\");\n\n result = false;\n\n goto out;\n\n }\n\n }\n\n\n\nout:\n\n closesocket(fd);\n\n return result;\n\n}\n", + "output": "1", + "index": 20704 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,\n\n qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,\n\n int kvm_enabled)\n\n{\n\n PCIDevice *dev;\n\n PIIX4PMState *s;\n\n\n\n dev = pci_create(bus, devfn, \"PIIX4_PM\");\n\n qdev_prop_set_uint32(&dev->qdev, \"smb_io_base\", smb_io_base);\n\n\n\n s = DO_UPCAST(PIIX4PMState, dev, dev);\n\n s->irq = sci_irq;\n\n acpi_pm1_cnt_init(&s->ar, cmos_s3);\n\n s->smi_irq = smi_irq;\n\n s->kvm_enabled = kvm_enabled;\n\n\n\n qdev_init_nofail(&dev->qdev);\n\n\n\n return s->smb.smbus;\n\n}\n", + "output": "0", + "index": 11681 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void invalidate_and_set_dirty(hwaddr addr,\n\n hwaddr length)\n\n{\n\n if (cpu_physical_memory_range_includes_clean(addr, length)) {\n\n tb_invalidate_phys_range(addr, addr + length, 0);\n\n cpu_physical_memory_set_dirty_range_nocode(addr, length);\n\n }\n\n xen_modified_memory(addr, length);\n\n}\n", + "output": "0", + "index": 26263 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)\n\n{\n\n CURLState *s = ((CURLState*)opaque);\n\n size_t realsize = size * nmemb;\n\n int i;\n\n\n\n DPRINTF(\"CURL: Just reading %zd bytes\\n\", realsize);\n\n\n\n if (!s || !s->orig_buf)\n\n goto read_end;\n\n\n\n\n\n\n\n\n memcpy(s->orig_buf + s->buf_off, ptr, realsize);\n\n s->buf_off += realsize;\n\n\n\n for(i=0; iacb[i];\n\n\n\n if (!acb)\n\n continue;\n\n\n\n if ((s->buf_off >= acb->end)) {\n\n qemu_iovec_from_buf(acb->qiov, 0, s->orig_buf + acb->start,\n\n acb->end - acb->start);\n\n acb->common.cb(acb->common.opaque, 0);\n\n qemu_aio_release(acb);\n\n s->acb[i] = NULL;\n\n\n\n\n\nread_end:\n\n return realsize;\n", + "output": "1", + "index": 7604 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int wc3_read_close(AVFormatContext *s)\n\n{\n\n Wc3DemuxContext *wc3 = s->priv_data;\n\n\n\n av_free(wc3->palettes);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 13716 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int openpic_load(QEMUFile* f, void *opaque, int version_id)\n\n{\n\n OpenPICState *opp = (OpenPICState *)opaque;\n\n unsigned int i;\n\n\n\n if (version_id != 1) {\n\n return -EINVAL;\n\n }\n\n\n\n qemu_get_be32s(f, &opp->gcr);\n\n qemu_get_be32s(f, &opp->vir);\n\n qemu_get_be32s(f, &opp->pir);\n\n qemu_get_be32s(f, &opp->spve);\n\n qemu_get_be32s(f, &opp->tfrr);\n\n\n\n qemu_get_be32s(f, &opp->nb_cpus);\n\n\n\n for (i = 0; i < opp->nb_cpus; i++) {\n\n qemu_get_sbe32s(f, &opp->dst[i].ctpr);\n\n openpic_load_IRQ_queue(f, &opp->dst[i].raised);\n\n openpic_load_IRQ_queue(f, &opp->dst[i].servicing);\n\n qemu_get_buffer(f, (uint8_t *)&opp->dst[i].outputs_active,\n\n sizeof(opp->dst[i].outputs_active));\n\n }\n\n\n\n for (i = 0; i < OPENPIC_MAX_TMR; i++) {\n\n qemu_get_be32s(f, &opp->timers[i].tccr);\n\n qemu_get_be32s(f, &opp->timers[i].tbcr);\n\n }\n\n\n\n for (i = 0; i < opp->max_irq; i++) {\n\n uint32_t val;\n\n\n\n val = qemu_get_be32(f);\n\n write_IRQreg_idr(opp, i, val);\n\n val = qemu_get_be32(f);\n\n write_IRQreg_ivpr(opp, i, val);\n\n\n\n qemu_get_be32s(f, &opp->src[i].ivpr);\n\n qemu_get_be32s(f, &opp->src[i].idr);\n\n qemu_get_be32s(f, &opp->src[i].destmask);\n\n qemu_get_sbe32s(f, &opp->src[i].last_cpu);\n\n qemu_get_sbe32s(f, &opp->src[i].pending);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 6821 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void stw_be_phys(target_phys_addr_t addr, uint32_t val)\n\n{\n\n stw_phys_internal(addr, val, DEVICE_BIG_ENDIAN);\n\n}\n", + "output": "0", + "index": 8751 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int intel_hda_init(PCIDevice *pci)\n\n{\n\n IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci);\n\n uint8_t *conf = d->pci.config;\n\n\n\n d->name = d->pci.qdev.info->name;\n\n\n\n pci_config_set_vendor_id(conf, PCI_VENDOR_ID_INTEL);\n\n pci_config_set_device_id(conf, 0x2668);\n\n pci_config_set_revision(conf, 1);\n\n pci_config_set_class(conf, PCI_CLASS_MULTIMEDIA_HD_AUDIO);\n\n pci_config_set_interrupt_pin(conf, 1);\n\n\n\n /* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */\n\n conf[0x40] = 0x01;\n\n\n\n d->mmio_addr = cpu_register_io_memory(intel_hda_mmio_read,\n\n intel_hda_mmio_write, d,\n\n DEVICE_NATIVE_ENDIAN);\n\n pci_register_bar_simple(&d->pci, 0, 0x4000, 0, d->mmio_addr);\n\n if (d->msi) {\n\n msi_init(&d->pci, 0x50, 1, true, false);\n\n }\n\n\n\n hda_codec_bus_init(&d->pci.qdev, &d->codecs,\n\n intel_hda_response, intel_hda_xfer);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 9956 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fd_put_buffer(void *opaque, const uint8_t *buf,\n\n int64_t pos, int size)\n\n{\n\n QEMUFileFD *s = opaque;\n\n ssize_t len;\n\n\n\n do {\n\n len = write(s->fd, buf, size);\n\n } while (len == -1 && errno == EINTR);\n\n\n\n if (len == -1)\n\n len = -errno;\n\n\n\n /* When the fd becomes writable again, register a callback to do\n\n * a put notify */\n\n if (len == -EAGAIN)\n\n qemu_set_fd_handler2(s->fd, NULL, NULL, fd_put_notify, s);\n\n}\n", + "output": "0", + "index": 16152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename)\n\n{\n\n const QCowHeader *cow_header = (const void *)buf;\n\n\n\n if (buf_size >= sizeof(QCowHeader) &&\n\n be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&\n\n be32_to_cpu(cow_header->version) >= QCOW_VERSION)\n\n return 100;\n\n else\n\n return 0;\n\n}\n", + "output": "0", + "index": 4963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_tsch(S390CPU *cpu)\n\n{\n\n CPUS390XState *env = &cpu->env;\n\n CPUState *cs = CPU(cpu);\n\n struct kvm_run *run = cs->kvm_run;\n\n int ret;\n\n\n\n cpu_synchronize_state(cs);\n\n\n\n ret = ioinst_handle_tsch(env, env->regs[1], run->s390_tsch.ipb);\n\n if (ret >= 0) {\n\n /* Success; set condition code. */\n\n setcc(cpu, ret);\n\n ret = 0;\n\n } else if (ret < -1) {\n\n /*\n\n * Failure.\n\n * If an I/O interrupt had been dequeued, we have to reinject it.\n\n */\n\n if (run->s390_tsch.dequeued) {\n\n uint16_t subchannel_id = run->s390_tsch.subchannel_id;\n\n uint16_t subchannel_nr = run->s390_tsch.subchannel_nr;\n\n uint32_t io_int_parm = run->s390_tsch.io_int_parm;\n\n uint32_t io_int_word = run->s390_tsch.io_int_word;\n\n uint32_t type = ((subchannel_id & 0xff00) << 24) |\n\n ((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);\n\n\n\n kvm_s390_interrupt_internal(cpu, type,\n\n ((uint32_t)subchannel_id << 16)\n\n | subchannel_nr,\n\n ((uint64_t)io_int_parm << 32)\n\n | io_int_word, 1);\n\n }\n\n ret = 0;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 1123 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void block_job_detach_aio_context(void *opaque)\n\n{\n\n BlockJob *job = opaque;\n\n\n\n /* In case the job terminates during aio_poll()... */\n\n block_job_ref(job);\n\n\n\n block_job_pause(job);\n\n\n\n if (!job->paused) {\n\n /* If job is !job->busy this kicks it into the next pause point. */\n\n block_job_enter(job);\n\n }\n\n while (!job->paused && !job->completed) {\n\n aio_poll(block_job_get_aio_context(job), true);\n\n }\n\n\n\n block_job_unref(job);\n\n}\n", + "output": "0", + "index": 2732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ReadLineState *readline_init(Monitor *mon,\n\n ReadLineCompletionFunc *completion_finder)\n\n{\n\n ReadLineState *rs = g_malloc0(sizeof(*rs));\n\n\n\n rs->hist_entry = -1;\n\n rs->mon = mon;\n\n rs->completion_finder = completion_finder;\n\n\n\n return rs;\n\n}\n", + "output": "0", + "index": 20284 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sigbus_handler(int signal)\n\n{\n\n siglongjmp(sigjump, 1);\n\n}\n", + "output": "1", + "index": 2094 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "processed(OptsVisitor *ov, const char *name)\n\n{\n\n if (ov->repeated_opts == NULL) {\n\n g_hash_table_remove(ov->unprocessed_opts, name);\n\n }\n\n}\n", + "output": "0", + "index": 1294 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_tls_client_cleanup(VncState *vs)\n\n{\n\n if (vs->tls.session) {\n\n gnutls_deinit(vs->tls.session);\n\n vs->tls.session = NULL;\n\n }\n\n g_free(vs->tls.dname);\n\n}\n", + "output": "1", + "index": 14032 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)\n\n{\n\n int x, y, plane;\n\n int score = 0;\n\n int64_t score64 = 0;\n\n\n\n for (plane = 0; plane < 3; plane++) {\n\n const int stride = p->f.linesize[plane];\n\n const int bw = plane ? 1 : 2;\n\n for (y = 0; y < s->mb_height * bw; y++) {\n\n for (x = 0; x < s->mb_width * bw; x++) {\n\n int off = p->shared ? 0 : 16;\n\n uint8_t *dptr = p->f.data[plane] + 8 * (x + y * stride) + off;\n\n uint8_t *rptr = ref->f.data[plane] + 8 * (x + y * stride);\n\n int v = s->dsp.frame_skip_cmp[1](s, dptr, rptr, stride, 8);\n\n\n\n switch (s->avctx->frame_skip_exp) {\n\n case 0: score = FFMAX(score, v); break;\n\n case 1: score += FFABS(v); break;\n\n case 2: score += v * v; break;\n\n case 3: score64 += FFABS(v * v * (int64_t)v); break;\n\n case 4: score64 += v * v * (int64_t)(v * v); break;\n\n }\n\n }\n\n }\n\n }\n\n\n\n if (score)\n\n score64 = score;\n\n\n\n if (score64 < s->avctx->frame_skip_threshold)\n\n return 1;\n\n if (score64 < ((s->avctx->frame_skip_factor * (int64_t)s->lambda) >> 8))\n\n return 1;\n\n return 0;\n\n}\n", + "output": "1", + "index": 2831 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_and_aver_dst_8x8_msa(src - 2,\n\n src - (stride * 2),\n\n stride, dst, stride);\n\n}\n", + "output": "0", + "index": 4040 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void write_dt(void *ptr, unsigned long addr, unsigned long limit,\n\n int flags)\n\n{\n\n unsigned int e1, e2;\n\n uint32_t *p;\n\n e1 = (addr << 16) | (limit & 0xffff);\n\n e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000);\n\n e2 |= flags;\n\n p = ptr;\n\n p[0] = tswapl(e1);\n\n p[1] = tswapl(e2);\n\n}\n", + "output": "0", + "index": 21307 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int vp56_free(AVCodecContext *avctx)\n{\n VP56Context *s = avctx->priv_data;\n int pt;\n av_freep(&s->qscale_table);\n av_freep(&s->above_blocks);\n av_freep(&s->macroblocks);\n av_freep(&s->edge_emu_buffer_alloc);\n if (s->framep[VP56_FRAME_GOLDEN]->data[0])\n avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]);\n if (s->framep[VP56_FRAME_GOLDEN2]->data[0])\n avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN2]);\n if (s->framep[VP56_FRAME_PREVIOUS]->data[0])\n avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);\n return 0;", + "output": "1", + "index": 25855 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_co_readv_1(NbdClientSession *client, int64_t sector_num,\n\n int nb_sectors, QEMUIOVector *qiov,\n\n int offset)\n\n{\n\n struct nbd_request request = { .type = NBD_CMD_READ };\n\n struct nbd_reply reply;\n\n ssize_t ret;\n\n\n\n request.from = sector_num * 512;\n\n request.len = nb_sectors * 512;\n\n\n\n nbd_coroutine_start(client, &request);\n\n ret = nbd_co_send_request(client, &request, NULL, 0);\n\n if (ret < 0) {\n\n reply.error = -ret;\n\n } else {\n\n nbd_co_receive_reply(client, &request, &reply, qiov, offset);\n\n }\n\n nbd_coroutine_end(client, &request);\n\n return -reply.error;\n\n\n\n}\n", + "output": "0", + "index": 2277 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep,\n\n uint64_t id)\n\n{\n\n struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);\n\n USBPacket *p;\n\n\n\n while ((p = QTAILQ_FIRST(&uep->queue)) != NULL) {\n\n if (p->id == id) {\n\n return p;\n\n }\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "1", + "index": 4059 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openpic_reset (void *opaque)\n\n{\n\n openpic_t *opp = (openpic_t *)opaque;\n\n int i;\n\n\n\n opp->glbc = 0x80000000;\n\n /* Initialise controller registers */\n\n opp->frep = ((OPENPIC_EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;\n\n opp->veni = VENI;\n\n opp->pint = 0x00000000;\n\n opp->spve = 0x000000FF;\n\n opp->tifr = 0x003F7A00;\n\n /* ? */\n\n opp->micr = 0x00000000;\n\n /* Initialise IRQ sources */\n\n for (i = 0; i < opp->max_irq; i++) {\n\n\topp->src[i].ipvp = 0xA0000000;\n\n\topp->src[i].ide = 0x00000000;\n\n }\n\n /* Initialise IRQ destinations */\n\n for (i = 0; i < MAX_CPU; i++) {\n\n\topp->dst[i].pctp = 0x0000000F;\n\n\topp->dst[i].pcsr = 0x00000000;\n\n\tmemset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));\n\n\n\tmemset(&opp->dst[i].servicing, 0, sizeof(IRQ_queue_t));\n\n\n }\n\n /* Initialise timers */\n\n for (i = 0; i < MAX_TMR; i++) {\n\n\topp->timers[i].ticc = 0x00000000;\n\n\topp->timers[i].tibc = 0x80000000;\n\n }\n\n /* Initialise doorbells */\n\n#if MAX_DBL > 0\n\n opp->dar = 0x00000000;\n\n for (i = 0; i < MAX_DBL; i++) {\n\n\topp->doorbells[i].dmr = 0x00000000;\n\n }\n\n#endif\n\n /* Initialise mailboxes */\n\n#if MAX_MBX > 0\n\n for (i = 0; i < MAX_MBX; i++) { /* ? */\n\n\topp->mailboxes[i].mbr = 0x00000000;\n\n }\n\n#endif\n\n /* Go out of RESET state */\n\n opp->glbc = 0x00000000;\n\n}", + "output": "1", + "index": 17115 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fdt_add_psci_node(const VirtBoardInfo *vbi)\n\n{\n\n void *fdt = vbi->fdt;\n\n ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(0));\n\n\n\n /* No PSCI for TCG yet */\n\n if (kvm_enabled()) {\n\n qemu_fdt_add_subnode(fdt, \"/psci\");\n\n if (armcpu->psci_version == 2) {\n\n const char comp[] = \"arm,psci-0.2\\0arm,psci\";\n\n qemu_fdt_setprop(fdt, \"/psci\", \"compatible\", comp, sizeof(comp));\n\n } else {\n\n qemu_fdt_setprop_string(fdt, \"/psci\", \"compatible\", \"arm,psci\");\n\n }\n\n\n\n qemu_fdt_setprop_string(fdt, \"/psci\", \"method\", \"hvc\");\n\n qemu_fdt_setprop_cell(fdt, \"/psci\", \"cpu_suspend\",\n\n QEMU_PSCI_0_1_FN_CPU_SUSPEND);\n\n qemu_fdt_setprop_cell(fdt, \"/psci\", \"cpu_off\", QEMU_PSCI_0_1_FN_CPU_OFF);\n\n qemu_fdt_setprop_cell(fdt, \"/psci\", \"cpu_on\", QEMU_PSCI_0_1_FN_CPU_ON);\n\n qemu_fdt_setprop_cell(fdt, \"/psci\", \"migrate\", QEMU_PSCI_0_1_FN_MIGRATE);\n\n }\n\n}\n", + "output": "0", + "index": 7748 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void continue_send(IPMIBmcExtern *ibe)\n\n{\n\n if (ibe->outlen == 0) {\n\n goto check_reset;\n\n }\n\n send:\n\n ibe->outpos += qemu_chr_fe_write(ibe->chr, ibe->outbuf + ibe->outpos,\n\n ibe->outlen - ibe->outpos);\n\n if (ibe->outpos < ibe->outlen) {\n\n /* Not fully transmitted, try again in a 10ms */\n\n timer_mod_ns(ibe->extern_timer,\n\n qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 10000000);\n\n } else {\n\n /* Sent */\n\n ibe->outlen = 0;\n\n ibe->outpos = 0;\n\n if (!ibe->sending_cmd) {\n\n ibe->waiting_rsp = true;\n\n } else {\n\n ibe->sending_cmd = false;\n\n }\n\n check_reset:\n\n if (ibe->connected && ibe->send_reset) {\n\n /* Send the reset */\n\n ibe->outbuf[0] = VM_CMD_RESET;\n\n ibe->outbuf[1] = VM_CMD_CHAR;\n\n ibe->outlen = 2;\n\n ibe->outpos = 0;\n\n ibe->send_reset = false;\n\n ibe->sending_cmd = true;\n\n goto send;\n\n }\n\n\n\n if (ibe->waiting_rsp) {\n\n /* Make sure we get a response within 4 seconds. */\n\n timer_mod_ns(ibe->extern_timer,\n\n qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 4000000000ULL);\n\n }\n\n }\n\n return;\n\n}\n", + "output": "1", + "index": 13254 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int float32_is_nan( float32 a1 )\n\n{\n\n float32u u;\n\n uint64_t a;\n\n u.f = a1;\n\n a = u.i;\n\n return ( 0xFF800000 < ( a<<1 ) );\n\n}\n", + "output": "0", + "index": 2627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vp3_decode_end(AVCodecContext *avctx)\n{\n Vp3DecodeContext *s = avctx->priv_data;\n int i;\n av_free(s->superblock_coding);\n av_free(s->all_fragments);\n av_free(s->coeffs);\n av_free(s->coded_fragment_list);\n av_free(s->superblock_fragments);\n av_free(s->superblock_macroblocks);\n av_free(s->macroblock_fragments);\n av_free(s->macroblock_coding);\n /* release all frames */\n if (s->golden_frame.data[0] && s->golden_frame.data[0] != s->last_frame.data[0])\n avctx->release_buffer(avctx, &s->golden_frame);\n if (s->last_frame.data[0])\n avctx->release_buffer(avctx, &s->last_frame);\n /* no need to release the current_frame since it will always be pointing\n * to the same frame as either the golden or last frame */\n return 0;", + "output": "1", + "index": 2261 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void css_adapter_interrupt(uint8_t isc)\n\n{\n\n S390CPU *cpu = s390_cpu_addr2state(0);\n\n uint32_t io_int_word = (isc << 27) | IO_INT_WORD_AI;\n\n\n\n trace_css_adapter_interrupt(isc);\n\n s390_io_interrupt(cpu, 0, 0, 0, io_int_word);\n\n}\n", + "output": "0", + "index": 9386 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TRBCCode xhci_disable_ep(XHCIState *xhci, unsigned int slotid,\n\n unsigned int epid)\n\n{\n\n XHCISlot *slot;\n\n XHCIEPContext *epctx;\n\n int i;\n\n\n\n trace_usb_xhci_ep_disable(slotid, epid);\n\n assert(slotid >= 1 && slotid <= xhci->numslots);\n\n assert(epid >= 1 && epid <= 31);\n\n\n\n slot = &xhci->slots[slotid-1];\n\n\n\n if (!slot->eps[epid-1]) {\n\n DPRINTF(\"xhci: slot %d ep %d already disabled\\n\", slotid, epid);\n\n return CC_SUCCESS;\n\n }\n\n\n\n xhci_ep_nuke_xfers(xhci, slotid, epid, 0);\n\n\n\n epctx = slot->eps[epid-1];\n\n\n\n if (epctx->nr_pstreams) {\n\n xhci_free_streams(epctx);\n\n }\n\n\n\n for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) {\n\n usb_packet_cleanup(&epctx->transfers[i].packet);\n\n }\n\n\n\n /* only touch guest RAM if we're not resetting the HC */\n\n if (xhci->dcbaap_low || xhci->dcbaap_high) {\n\n xhci_set_ep_state(xhci, epctx, NULL, EP_DISABLED);\n\n }\n\n\n\n timer_free(epctx->kick_timer);\n\n g_free(epctx);\n\n slot->eps[epid-1] = NULL;\n\n\n\n return CC_SUCCESS;\n\n}\n", + "output": "0", + "index": 26393 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)\n\n{\n\n uint32_t exit_at_level[33] = { 404 };\n\n unsigned i, j, p, code;\n\n\n\n for (p = 0; (bits[p] == 0) && (p < num); ++p)\n\n ;\n\n if (p == num)\n\n return 0;\n\n\n\n codes[p] = 0;\n\n if (bits[p] > 32)\n\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < bits[p]; ++i)\n\n exit_at_level[i+1] = 1 << i;\n\n\n\n ++p;\n\n\n\n for (i = p; (bits[i] == 0) && (i < num); ++i)\n\n ;\n\n if (i == num)\n\n return 0;\n\n\n\n for (; p < num; ++p) {\n\n if (bits[p] > 32)\n\n return AVERROR_INVALIDDATA;\n\n if (bits[p] == 0)\n\n continue;\n\n // find corresponding exit(node which the tree can grow further from)\n\n for (i = bits[p]; i > 0; --i)\n\n if (exit_at_level[i])\n\n break;\n\n if (!i) // overspecified tree\n\n return AVERROR_INVALIDDATA;\n\n code = exit_at_level[i];\n\n exit_at_level[i] = 0;\n\n // construct code (append 0s to end) and introduce new exits\n\n for (j = i + 1 ;j <= bits[p]; ++j)\n\n exit_at_level[j] = code + (1 << (j - 1));\n\n codes[p] = code;\n\n }\n\n\n\n //no exits should be left (underspecified tree - ie. unused valid vlcs - not allowed by SPEC)\n\n for (p = 1; p < 33; p++)\n\n if (exit_at_level[p])\n\n return AVERROR_INVALIDDATA;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 25782 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ipvideo_decode_block_opcode_0xC(IpvideoContext *s)\n\n{\n\n int x, y;\n\n\n\n /* 16-color block encoding: each 2x2 block is a different color */\n\n CHECK_STREAM_PTR(16);\n\n\n\n for (y = 0; y < 8; y += 2) {\n\n for (x = 0; x < 8; x += 2) {\n\n s->pixel_ptr[x ] =\n\n s->pixel_ptr[x + 1 ] =\n\n s->pixel_ptr[x + s->stride] =\n\n s->pixel_ptr[x + 1 + s->stride] = *s->stream_ptr++;\n\n }\n\n s->pixel_ptr += s->stride * 2;\n\n }\n\n\n\n /* report success */\n\n return 0;\n\n}\n", + "output": "0", + "index": 4958 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)\n\n{\n\n BufferSinkContext *buf = ctx->priv;\n\n AVFilterLink *inlink = ctx->inputs[0];\n\n int ret;\n\n AVFrame *cur_frame;\n\n\n\n /* no picref available, fetch it from the filterchain */\n\n if (!av_fifo_size(buf->fifo)) {\n\n if (inlink->closed)\n\n return AVERROR_EOF;\n\n if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)\n\n return AVERROR(EAGAIN);\n\n if ((ret = ff_request_frame(inlink)) < 0)\n\n return ret;\n\n }\n\n\n\n if (!av_fifo_size(buf->fifo))\n\n return AVERROR(EINVAL);\n\n\n\n if (flags & AV_BUFFERSINK_FLAG_PEEK) {\n\n cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));\n\n if ((ret = av_frame_ref(frame, cur_frame)) < 0)\n\n return ret;\n\n } else {\n\n av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);\n\n av_frame_move_ref(frame, cur_frame);\n\n av_frame_free(&cur_frame);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17343 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){\n\n int i;\n\n InternalBuffer *buf, *last;\n\n AVCodecInternal *avci = s->internal;\n\n\n\n assert(s->codec_type == AVMEDIA_TYPE_VIDEO);\n\n\n\n assert(pic->type==FF_BUFFER_TYPE_INTERNAL);\n\n assert(avci->buffer_count);\n\n\n\n if (avci->buffer) {\n\n buf = NULL; /* avoids warning */\n\n for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize\n\n buf = &avci->buffer[i];\n\n if (buf->data[0] == pic->data[0])\n\n break;\n\n }\n\n assert(i < avci->buffer_count);\n\n avci->buffer_count--;\n\n last = &avci->buffer[avci->buffer_count];\n\n\n\n FFSWAP(InternalBuffer, *buf, *last);\n\n }\n\n\n\n for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {\n\n pic->data[i]=NULL;\n\n// pic->base[i]=NULL;\n\n }\n\n//printf(\"R%X\\n\", pic->opaque);\n\n\n\n if(s->debug&FF_DEBUG_BUFFERS)\n\n av_log(s, AV_LOG_DEBUG, \"default_release_buffer called on pic %p, %d \"\n\n \"buffers used\\n\", pic, avci->buffer_count);\n\n}\n", + "output": "0", + "index": 10659 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *postcopy_get_tmp_page(MigrationIncomingState *mis)\n\n{\n\n if (!mis->postcopy_tmp_page) {\n\n mis->postcopy_tmp_page = mmap(NULL, getpagesize(),\n\n PROT_READ | PROT_WRITE, MAP_PRIVATE |\n\n MAP_ANONYMOUS, -1, 0);\n\n if (!mis->postcopy_tmp_page) {\n\n error_report(\"%s: %s\", __func__, strerror(errno));\n\n return NULL;\n\n }\n\n }\n\n\n\n return mis->postcopy_tmp_page;\n\n}\n", + "output": "1", + "index": 18776 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "sprintf_len(char *string, const char *format, ...)\n\n#else\n\nsprintf_len(va_alist) va_dcl\n\n#endif\n\n{\n\n\tva_list args;\n\n#ifdef __STDC__\n\n\tva_start(args, format);\n\n#else\n\n\tchar *string;\n\n\tchar *format;\n\n\tva_start(args);\n\n\tstring = va_arg(args, char *);\n\n\tformat = va_arg(args, char *);\n\n#endif\n\n\tvsprintf(string, format, args);\n\n\treturn strlen(string);\n\n}\n", + "output": "0", + "index": 25167 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_descriptor_load(PXA2xxLCDState *s)\n\n{\n\n PXAFrameDescriptor desc;\n\n target_phys_addr_t descptr;\n\n int i;\n\n\n\n for (i = 0; i < PXA_LCDDMA_CHANS; i ++) {\n\n s->dma_ch[i].source = 0;\n\n\n\n if (!s->dma_ch[i].up)\n\n continue;\n\n\n\n if (s->dma_ch[i].branch & FBR_BRA) {\n\n descptr = s->dma_ch[i].branch & FBR_SRCADDR;\n\n if (s->dma_ch[i].branch & FBR_BINT)\n\n pxa2xx_dma_bs_set(s, i);\n\n s->dma_ch[i].branch &= ~FBR_BRA;\n\n } else\n\n descptr = s->dma_ch[i].descriptor;\n\n\n\n if (!(descptr >= PXA2XX_SDRAM_BASE && descptr +\n\n sizeof(desc) <= PXA2XX_SDRAM_BASE + ram_size))\n\n continue;\n\n\n\n cpu_physical_memory_read(descptr, (void *)&desc, sizeof(desc));\n\n s->dma_ch[i].descriptor = tswap32(desc.fdaddr);\n\n s->dma_ch[i].source = tswap32(desc.fsaddr);\n\n s->dma_ch[i].id = tswap32(desc.fidr);\n\n s->dma_ch[i].command = tswap32(desc.ldcmd);\n\n }\n\n}\n", + "output": "0", + "index": 5228 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n AVFilterLink *outlink = ctx->outputs[0];\n\n AVFilterBufferRef *outpicref = outlink->out_buf;\n\n OverlayContext *over = ctx->priv;\n\n\n\n if (over->overpicref &&\n\n !(over->x >= outpicref->video->w || over->y >= outpicref->video->h ||\n\n y+h < over->y || y >= over->y + over->overpicref->video->h)) {\n\n blend_slice(ctx, outpicref, over->overpicref, over->x, over->y,\n\n over->overpicref->video->w, over->overpicref->video->h,\n\n y, outpicref->video->w, h);\n\n }\n\n avfilter_draw_slice(outlink, y, h, slice_dir);\n\n}\n", + "output": "1", + "index": 6419 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_POWER_divso (void)\n\n{\n\n if (((int32_t)T0 == INT32_MIN && (int32_t)T1 == -1) || (int32_t)T1 == 0) {\n\n T0 = (long)((-1) * (T0 >> 31));\n\n env->spr[SPR_MQ] = 0;\n\n xer_ov = 1;\n\n xer_so = 1;\n\n } else {\n\n T0 = (int32_t)T0 / (int32_t)T1;\n\n env->spr[SPR_MQ] = (int32_t)T0 % (int32_t)T1;\n\n xer_ov = 0;\n\n }\n\n}\n", + "output": "1", + "index": 26924 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_sector_write(IDEState *s)\n{\n int64_t sector_num;\n int n;\n s->status = READY_STAT | SEEK_STAT | BUSY_STAT;\n sector_num = ide_get_sector(s);\n#if defined(DEBUG_IDE)\n printf(\"sector=%\" PRId64 \"\\n\", sector_num);\n#endif\n n = s->nsector;\n if (n > s->req_nb_sectors) {\n n = s->req_nb_sectors;\n s->iov.iov_base = s->io_buffer;\n s->iov.iov_len = n * BDRV_SECTOR_SIZE;\n qemu_iovec_init_external(&s->qiov, &s->iov, 1);\n bdrv_acct_start(s->bs, &s->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);\n s->pio_aiocb = bdrv_aio_writev(s->bs, sector_num, &s->qiov, n,\n ide_sector_write_cb, s);", + "output": "1", + "index": 18566 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,\n\n const GraphicHwOps *hw_ops,\n\n void *opaque)\n\n{\n\n int width = 640;\n\n int height = 480;\n\n QemuConsole *s;\n\n DisplayState *ds;\n\n\n\n ds = get_alloc_displaystate();\n\n trace_console_gfx_new();\n\n s = new_console(ds, GRAPHIC_CONSOLE, head);\n\n s->hw_ops = hw_ops;\n\n s->hw = opaque;\n\n if (dev) {\n\n object_property_set_link(OBJECT(s), OBJECT(dev), \"device\",\n\n &error_abort);\n\n }\n\n\n\n s->surface = qemu_create_displaysurface(width, height);\n\n return s;\n\n}\n", + "output": "0", + "index": 14912 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dequantization_int(int x, int y, Jpeg2000Cblk *cblk,\n\n Jpeg2000Component *comp,\n\n Jpeg2000T1Context *t1, Jpeg2000Band *band)\n\n{\n\n int i, j, idx;\n\n int32_t *datap =\n\n (int32_t *) &comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x];\n\n for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j)\n\n for (i = 0; i < (cblk->coord[0][1] - cblk->coord[0][0]); ++i) {\n\n idx = (comp->coord[0][1] - comp->coord[0][0]) * j + i;\n\n datap[idx] =\n\n ((int32_t)(t1->data[j][i]) * band->i_stepsize + (1 << 15)) >> 16;\n\n }\n\n}\n", + "output": "1", + "index": 11077 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned do_stfle(CPUS390XState *env, uint64_t words[MAX_STFL_WORDS])\n\n{\n\n S390CPU *cpu = s390_env_get_cpu(env);\n\n const unsigned long *features = cpu->model->features;\n\n unsigned max_bit = 0;\n\n S390Feat feat;\n\n\n\n memset(words, 0, sizeof(uint64_t) * MAX_STFL_WORDS);\n\n\n\n if (test_bit(S390_FEAT_ZARCH, features)) {\n\n /* z/Architecture is always active if around */\n\n words[0] = 1ull << (63 - 2);\n\n }\n\n\n\n for (feat = find_first_bit(features, S390_FEAT_MAX);\n\n feat < S390_FEAT_MAX;\n\n feat = find_next_bit(features, S390_FEAT_MAX, feat + 1)) {\n\n const S390FeatDef *def = s390_feat_def(feat);\n\n if (def->type == S390_FEAT_TYPE_STFL) {\n\n unsigned bit = def->bit;\n\n if (bit > max_bit) {\n\n max_bit = bit;\n\n }\n\n assert(bit / 64 < MAX_STFL_WORDS);\n\n words[bit / 64] |= 1ULL << (63 - bit % 64);\n\n }\n\n }\n\n\n\n return max_bit / 64;\n\n}\n", + "output": "0", + "index": 8247 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int gen_jz_ecx_string(DisasContext *s, target_ulong next_eip)\n\n{\n\n int l1, l2;\n\n\n\n l1 = gen_new_label();\n\n l2 = gen_new_label();\n\n gen_op_jnz_ecx[s->aflag](l1);\n\n gen_set_label(l2);\n\n gen_jmp_tb(s, next_eip, 1);\n\n gen_set_label(l1);\n\n return l2;\n\n}\n", + "output": "0", + "index": 4117 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx)\n\n{\n\n int mm_flags = av_get_cpu_flags();\n\n\n\n if (mm_flags & AV_CPU_FLAG_MMX) {\n\n#if HAVE_YASM\n\n c->float_interleave = float_interleave_mmx;\n\n\n\n if(mm_flags & AV_CPU_FLAG_3DNOW){\n\n if(!(avctx->flags & CODEC_FLAG_BITEXACT)){\n\n c->float_to_int16 = ff_float_to_int16_3dnow;\n\n c->float_to_int16_interleave = float_to_int16_interleave_3dnow;\n\n }\n\n }\n\n if(mm_flags & AV_CPU_FLAG_3DNOWEXT){\n\n if(!(avctx->flags & CODEC_FLAG_BITEXACT)){\n\n c->float_to_int16_interleave = float_to_int16_interleave_3dn2;\n\n }\n\n }\n\n#endif\n\n if(mm_flags & AV_CPU_FLAG_SSE){\n\n c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;\n\n#if HAVE_YASM\n\n c->float_to_int16 = ff_float_to_int16_sse;\n\n c->float_to_int16_interleave = float_to_int16_interleave_sse;\n\n c->float_interleave = float_interleave_sse;\n\n#endif\n\n }\n\n if(mm_flags & AV_CPU_FLAG_SSE2){\n\n c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;\n\n#if HAVE_YASM\n\n c->float_to_int16 = ff_float_to_int16_sse2;\n\n c->float_to_int16_interleave = float_to_int16_interleave_sse2;\n\n#endif\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 19852 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)\n\n{\n\n PCIBus *bus;\n\n\n\n do {\n\n bus = dev->bus;\n\n pin = bus->map_irq(dev, pin);\n\n dev = bus->parent_dev;\n\n } while (dev);\n\n assert(bus->route_intx_to_irq);\n\n return bus->route_intx_to_irq(bus->irq_opaque, pin);\n\n}\n", + "output": "0", + "index": 18682 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t rtas_set_allocation_state(uint32_t idx, uint32_t state)\n\n{\n\n sPAPRDRConnector *drc = spapr_drc_by_index(idx);\n\n sPAPRDRConnectorClass *drck;\n\n\n\n if (!drc) {\n\n return RTAS_OUT_PARAM_ERROR;\n\n }\n\n\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n return drck->set_allocation_state(drc, state);\n\n}\n", + "output": "0", + "index": 20971 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_get_xsave(CPUState *env)\n\n{\n\n#ifdef KVM_CAP_XSAVE\n\n struct kvm_xsave* xsave;\n\n int ret, i;\n\n uint16_t cwd, swd, twd, fop;\n\n\n\n if (!kvm_has_xsave())\n\n return kvm_get_fpu(env);\n\n\n\n xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));\n\n ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);\n\n if (ret < 0) {\n\n qemu_free(xsave);\n\n return ret;\n\n }\n\n\n\n cwd = (uint16_t)xsave->region[0];\n\n swd = (uint16_t)(xsave->region[0] >> 16);\n\n twd = (uint16_t)xsave->region[1];\n\n fop = (uint16_t)(xsave->region[1] >> 16);\n\n env->fpstt = (swd >> 11) & 7;\n\n env->fpus = swd;\n\n env->fpuc = cwd;\n\n for (i = 0; i < 8; ++i)\n\n env->fptags[i] = !((twd >> i) & 1);\n\n env->mxcsr = xsave->region[XSAVE_MXCSR];\n\n memcpy(env->fpregs, &xsave->region[XSAVE_ST_SPACE],\n\n sizeof env->fpregs);\n\n memcpy(env->xmm_regs, &xsave->region[XSAVE_XMM_SPACE],\n\n sizeof env->xmm_regs);\n\n env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];\n\n memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],\n\n sizeof env->ymmh_regs);\n\n qemu_free(xsave);\n\n return 0;\n\n#else\n\n return kvm_get_fpu(env);\n\n#endif\n\n}\n", + "output": "0", + "index": 14567 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int fw_cfg_add_file(FWCfgState *s, const char *filename, uint8_t *data,\n\n uint32_t len)\n\n{\n\n int i, index;\n\n\n\n if (!s->files) {\n\n int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;\n\n s->files = g_malloc0(dsize);\n\n fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);\n\n }\n\n\n\n index = be32_to_cpu(s->files->count);\n\n if (index == FW_CFG_FILE_SLOTS) {\n\n fprintf(stderr, \"fw_cfg: out of file slots\\n\");\n\n return 0;\n\n }\n\n\n\n fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len);\n\n\n\n pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name),\n\n filename);\n\n for (i = 0; i < index; i++) {\n\n if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {\n\n trace_fw_cfg_add_file_dupe(s, s->files->f[index].name);\n\n return 1;\n\n }\n\n }\n\n\n\n s->files->f[index].size = cpu_to_be32(len);\n\n s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);\n\n trace_fw_cfg_add_file(s, index, s->files->f[index].name, len);\n\n\n\n s->files->count = cpu_to_be32(index+1);\n\n return 1;\n\n}\n", + "output": "1", + "index": 3910 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void copy_bits(PutBitContext *pb, UINT8 *src, int length)\n\n{\n\n#if 1\n\n int bytes= length>>4;\n\n int bits= length&15;\n\n int i;\n\n\n\n for(i=0; i>(16-bits));\n\n#else\n\n int bytes= length>>3;\n\n int bits= length&7;\n\n int i;\n\n\n\n for(i=0; i>(8-bits));\n\n#endif\n\n}\n", + "output": "0", + "index": 17531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ide_init1(IDEBus *bus, int unit)\n\n{\n\n static int drive_serial = 1;\n\n IDEState *s = &bus->ifs[unit];\n\n\n\n s->bus = bus;\n\n s->unit = unit;\n\n s->drive_serial = drive_serial++;\n\n /* we need at least 2k alignment for accessing CDROMs using O_DIRECT */\n\n s->io_buffer_total_len = IDE_DMA_BUF_SECTORS*512 + 4;\n\n s->io_buffer = qemu_memalign(2048, s->io_buffer_total_len);\n\n memset(s->io_buffer, 0, s->io_buffer_total_len);\n\n\n\n s->smart_selftest_data = qemu_blockalign(s->bs, 512);\n\n memset(s->smart_selftest_data, 0, 512);\n\n\n\n s->sector_write_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,\n\n ide_sector_write_timer_cb, s);\n\n}\n", + "output": "0", + "index": 16903 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_host_initfn(Object *obj)\n\n{\n\n VirtIOInputHostPCI *dev = VIRTIO_INPUT_HOST_PCI(obj);\n\n\n\n virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),\n\n TYPE_VIRTIO_INPUT_HOST);\n\n}\n", + "output": "1", + "index": 24059 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t nbd_wr_syncv(QIOChannel *ioc,\n\n struct iovec *iov,\n\n size_t niov,\n\n size_t length,\n\n bool do_read,\n\n Error **errp)\n\n{\n\n ssize_t done = 0;\n\n struct iovec *local_iov = g_new(struct iovec, niov);\n\n struct iovec *local_iov_head = local_iov;\n\n unsigned int nlocal_iov = niov;\n\n\n\n nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, 0, length);\n\n\n\n while (nlocal_iov > 0) {\n\n ssize_t len;\n\n if (do_read) {\n\n len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);\n\n } else {\n\n len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);\n\n }\n\n if (len == QIO_CHANNEL_ERR_BLOCK) {\n\n /* errp should not be set */\n\n assert(qemu_in_coroutine());\n\n qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);\n\n continue;\n\n }\n\n if (len < 0) {\n\n done = -EIO;\n\n goto cleanup;\n\n }\n\n\n\n if (do_read && len == 0) {\n\n break;\n\n }\n\n\n\n iov_discard_front(&local_iov, &nlocal_iov, len);\n\n done += len;\n\n }\n\n\n\n cleanup:\n\n g_free(local_iov_head);\n\n return done;\n\n}\n", + "output": "0", + "index": 21363 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)\n\n{\n\n#if defined(TARGET_I386)\n\n cpu_synchronize_state(s->c_cpu);\n\n s->c_cpu->eip = pc;\n\n#elif defined (TARGET_PPC)\n\n s->c_cpu->nip = pc;\n\n#elif defined (TARGET_SPARC)\n\n s->c_cpu->pc = pc;\n\n s->c_cpu->npc = pc + 4;\n\n#elif defined (TARGET_ARM)\n\n s->c_cpu->regs[15] = pc;\n\n#elif defined (TARGET_SH4)\n\n s->c_cpu->pc = pc;\n\n#elif defined (TARGET_MIPS)\n\n s->c_cpu->active_tc.PC = pc;\n\n#elif defined (TARGET_MICROBLAZE)\n\n s->c_cpu->sregs[SR_PC] = pc;\n\n#elif defined (TARGET_CRIS)\n\n s->c_cpu->pc = pc;\n\n#elif defined (TARGET_ALPHA)\n\n s->c_cpu->pc = pc;\n\n#elif defined (TARGET_S390X)\n\n cpu_synchronize_state(s->c_cpu);\n\n s->c_cpu->psw.addr = pc;\n\n#endif\n\n}\n", + "output": "0", + "index": 15709 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,\n\n MemoryRegion *address_space, MemoryRegion *io)\n\n{\n\n s->scratch_size = SVGA_SCRATCH_SIZE;\n\n s->scratch = g_malloc(s->scratch_size * 4);\n\n\n\n s->vga.con = graphic_console_init(dev, 0, &vmsvga_ops, s);\n\n\n\n s->fifo_size = SVGA_FIFO_SIZE;\n\n memory_region_init_ram(&s->fifo_ram, NULL, \"vmsvga.fifo\", s->fifo_size,\n\n &error_abort);\n\n vmstate_register_ram_global(&s->fifo_ram);\n\n s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);\n\n\n\n vga_common_init(&s->vga, OBJECT(dev), true);\n\n vga_init(&s->vga, OBJECT(dev), address_space, io, true);\n\n vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);\n\n s->new_depth = 32;\n\n}\n", + "output": "1", + "index": 13790 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)\n\n{\n\n migration_dirty_pages +=\n\n cpu_physical_memory_sync_dirty_bitmap(migration_bitmap, start, length);\n\n}\n", + "output": "0", + "index": 15954 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ram_save_setup(QEMUFile *f, void *opaque)\n\n{\n\n RAMBlock *block;\n\n int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;\n\n\n\n migration_bitmap = bitmap_new(ram_pages);\n\n bitmap_set(migration_bitmap, 0, ram_pages);\n\n migration_dirty_pages = ram_pages;\n\n mig_throttle_on = false;\n\n dirty_rate_high_cnt = 0;\n\n\n\n if (migrate_use_xbzrle()) {\n\n qemu_mutex_lock_iothread();\n\n XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /\n\n TARGET_PAGE_SIZE,\n\n TARGET_PAGE_SIZE);\n\n if (!XBZRLE.cache) {\n\n qemu_mutex_unlock_iothread();\n\n DPRINTF(\"Error creating cache\\n\");\n\n return -1;\n\n }\n\n qemu_mutex_init(&XBZRLE.lock);\n\n qemu_mutex_unlock_iothread();\n\n\n\n /* We prefer not to abort if there is no memory */\n\n XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);\n\n if (!XBZRLE.encoded_buf) {\n\n DPRINTF(\"Error allocating encoded_buf\\n\");\n\n return -1;\n\n }\n\n\n\n XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);\n\n if (!XBZRLE.current_buf) {\n\n DPRINTF(\"Error allocating current_buf\\n\");\n\n g_free(XBZRLE.encoded_buf);\n\n XBZRLE.encoded_buf = NULL;\n\n return -1;\n\n }\n\n\n\n acct_clear();\n\n }\n\n\n\n qemu_mutex_lock_iothread();\n\n qemu_mutex_lock_ramlist();\n\n bytes_transferred = 0;\n\n reset_ram_globals();\n\n\n\n memory_global_dirty_log_start();\n\n migration_bitmap_sync();\n\n qemu_mutex_unlock_iothread();\n\n\n\n qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);\n\n\n\n QTAILQ_FOREACH(block, &ram_list.blocks, next) {\n\n qemu_put_byte(f, strlen(block->idstr));\n\n qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));\n\n qemu_put_be64(f, block->length);\n\n }\n\n\n\n qemu_mutex_unlock_ramlist();\n\n\n\n ram_control_before_iterate(f, RAM_CONTROL_SETUP);\n\n ram_control_after_iterate(f, RAM_CONTROL_SETUP);\n\n\n\n qemu_put_be64(f, RAM_SAVE_FLAG_EOS);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 16970 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void flush_dpb(AVCodecContext *avctx){\n\n H264Context *h= avctx->priv_data;\n\n int i;\n\n for(i=0; i<16; i++)\n\n h->delayed_pic[i]= NULL;\n\n h->delayed_output_pic= NULL;\n\n idr(h);\n\n\n}", + "output": "1", + "index": 19816 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hl_decode_mb(H264Context *h){\n\n MpegEncContext * const s = &h->s;\n\n const int mb_xy= h->mb_xy;\n\n const int mb_type= s->current_picture.mb_type[mb_xy];\n\n int is_complex = h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;\n\n\n\n if(ENABLE_H264_ENCODER && !s->decode)\n\n return;\n\n\n\n if (is_complex)\n\n hl_decode_mb_complex(h);\n\n else hl_decode_mb_simple(h);\n\n}\n", + "output": "0", + "index": 13833 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_close(AVFormatContext *s)\n\n{\n\n int i;\n\n MOVContext *mov = s->priv_data;\n\n for(i=0; itotal_streams; i++)\n\n mov_free_stream_context(mov->streams[i]);\n\n for(i=0; inb_streams; i++)\n\n av_free(s->streams[i]);\n\n return 0;\n\n}\n", + "output": "1", + "index": 25601 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_command_complete(SCSIRequest *r, uint32_t status,\n\n size_t resid)\n\n{\n\n VirtIOSCSIReq *req = r->hba_private;\n\n uint8_t sense[SCSI_SENSE_BUF_SIZE];\n\n uint32_t sense_len;\n\n\n\n if (r->io_canceled) {\n\n return;\n\n }\n\n\n\n req->resp.cmd->response = VIRTIO_SCSI_S_OK;\n\n req->resp.cmd->status = status;\n\n if (req->resp.cmd->status == GOOD) {\n\n req->resp.cmd->resid = tswap32(resid);\n\n } else {\n\n req->resp.cmd->resid = 0;\n\n sense_len = scsi_req_get_sense(r, sense, sizeof(sense));\n\n sense_len = MIN(sense_len, req->resp_size - sizeof(req->resp.cmd));\n\n memcpy(req->resp.cmd->sense, sense, sense_len);\n\n req->resp.cmd->sense_len = tswap32(sense_len);\n\n }\n\n virtio_scsi_complete_cmd_req(req);\n\n}\n", + "output": "0", + "index": 14712 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void isa_ne2000_cleanup(NetClientState *nc)\n\n{\n\n NE2000State *s = qemu_get_nic_opaque(nc);\n\n\n\n s->nic = NULL;\n\n}\n", + "output": "0", + "index": 12135 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_io_channel_ipv6(bool async)\n\n{\n\n SocketAddress *listen_addr = g_new0(SocketAddress, 1);\n\n SocketAddress *connect_addr = g_new0(SocketAddress, 1);\n\n\n\n listen_addr->type = SOCKET_ADDRESS_KIND_INET;\n\n listen_addr->u.inet = g_new(InetSocketAddress, 1);\n\n *listen_addr->u.inet = (InetSocketAddress) {\n\n .host = g_strdup(\"::1\"),\n\n .port = NULL, /* Auto-select */\n\n };\n\n\n\n connect_addr->type = SOCKET_ADDRESS_KIND_INET;\n\n connect_addr->u.inet = g_new(InetSocketAddress, 1);\n\n *connect_addr->u.inet = (InetSocketAddress) {\n\n .host = g_strdup(\"::1\"),\n\n .port = NULL, /* Filled in later */\n\n };\n\n\n\n test_io_channel(async, listen_addr, connect_addr, false);\n\n\n\n qapi_free_SocketAddress(listen_addr);\n\n qapi_free_SocketAddress(connect_addr);\n\n}\n", + "output": "0", + "index": 13179 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,\n\n VirtIOBlockDataPlane **dataplane,\n\n Error **errp)\n\n{\n\n VirtIOBlockDataPlane *s;\n\n Error *local_err = NULL;\n\n\n\n *dataplane = NULL;\n\n\n\n if (!blk->data_plane) {\n\n return;\n\n }\n\n\n\n if (blk->scsi) {\n\n error_setg(errp,\n\n \"device is incompatible with x-data-plane, use scsi=off\");\n\n return;\n\n }\n\n\n\n if (blk->config_wce) {\n\n error_setg(errp, \"device is incompatible with x-data-plane, \"\n\n \"use config-wce=off\");\n\n return;\n\n }\n\n\n\n /* If dataplane is (re-)enabled while the guest is running there could be\n\n * block jobs that can conflict.\n\n */\n\n if (bdrv_op_is_blocked(blk->conf.bs, BLOCK_OP_TYPE_DATAPLANE, &local_err)) {\n\n error_report(\"cannot start dataplane thread: %s\",\n\n error_get_pretty(local_err));\n\n error_free(local_err);\n\n return;\n\n }\n\n\n\n s = g_new0(VirtIOBlockDataPlane, 1);\n\n s->vdev = vdev;\n\n s->blk = blk;\n\n\n\n if (blk->iothread) {\n\n s->iothread = blk->iothread;\n\n object_ref(OBJECT(s->iothread));\n\n } else {\n\n /* Create per-device IOThread if none specified. This is for\n\n * x-data-plane option compatibility. If x-data-plane is removed we\n\n * can drop this.\n\n */\n\n object_initialize(&s->internal_iothread_obj,\n\n sizeof(s->internal_iothread_obj),\n\n TYPE_IOTHREAD);\n\n user_creatable_complete(OBJECT(&s->internal_iothread_obj), &error_abort);\n\n s->iothread = &s->internal_iothread_obj;\n\n }\n\n s->ctx = iothread_get_aio_context(s->iothread);\n\n\n\n error_setg(&s->blocker, \"block device is in use by data plane\");\n\n bdrv_op_block_all(blk->conf.bs, s->blocker);\n\n\n\n *dataplane = s;\n\n}\n", + "output": "0", + "index": 14111 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright, int _stride){\n\n pixel *src = (pixel*)_src;\n\n int stride = _stride/sizeof(pixel);\n\n const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]\n\n + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;\n\n\n\n ((pixel4*)(src+0*stride))[0]=\n\n ((pixel4*)(src+1*stride))[0]=\n\n ((pixel4*)(src+2*stride))[0]=\n\n ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);\n\n}\n", + "output": "1", + "index": 18828 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void memory_region_finalize(Object *obj)\n\n{\n\n MemoryRegion *mr = MEMORY_REGION(obj);\n\n\n\n assert(QTAILQ_EMPTY(&mr->subregions));\n\n assert(memory_region_transaction_depth == 0);\n\n mr->destructor(mr);\n\n memory_region_clear_coalescing(mr);\n\n g_free((char *)mr->name);\n\n g_free(mr->ioeventfds);\n\n}\n", + "output": "0", + "index": 24152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,\n\n qemu_irq irq)\n\n{\n\n OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));\n\n\n\n usb_ohci_init(ohci, num_ports, devfn, irq,\n\n OHCI_TYPE_PXA, \"OHCI USB\");\n\n ohci->mem_base = base;\n\n\n\n cpu_register_physical_memory(ohci->mem_base, 0xfff, ohci->mem);\n\n}\n", + "output": "1", + "index": 16338 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_openrisc_load_kernel(ram_addr_t ram_size,\n\n const char *kernel_filename,\n\n OpenRISCCPU *cpu)\n\n{\n\n long kernel_size;\n\n uint64_t elf_entry;\n\n hwaddr entry;\n\n\n\n if (kernel_filename && !qtest_enabled()) {\n\n kernel_size = load_elf(kernel_filename, NULL, NULL,\n\n &elf_entry, NULL, NULL, 1, ELF_MACHINE, 1);\n\n entry = elf_entry;\n\n if (kernel_size < 0) {\n\n kernel_size = load_uimage(kernel_filename,\n\n &entry, NULL, NULL);\n\n }\n\n if (kernel_size < 0) {\n\n kernel_size = load_image_targphys(kernel_filename,\n\n KERNEL_LOAD_ADDR,\n\n ram_size - KERNEL_LOAD_ADDR);\n\n entry = KERNEL_LOAD_ADDR;\n\n }\n\n\n\n if (kernel_size < 0) {\n\n fprintf(stderr, \"QEMU: couldn't load the kernel '%s'\\n\",\n\n kernel_filename);\n\n exit(1);\n\n }\n\n }\n\n\n\n cpu->env.pc = entry;\n\n}\n", + "output": "1", + "index": 20424 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ff_mpeg4_init_direct_mv(MpegEncContext *s){\n\n //FIXME table is stored in MpegEncContext for thread-safety,\n\n // but a static array would be faster\n\n static const int tab_size = sizeof(s->direct_scale_mv[0])/sizeof(int16_t);\n\n static const int tab_bias = (tab_size/2);\n\n int i;\n\n for(i=0; idirect_scale_mv[0][i] = (i-tab_bias)*s->pb_time/s->pp_time;\n\n s->direct_scale_mv[1][i] = (i-tab_bias)*(s->pb_time-s->pp_time)/s->pp_time;\n\n }\n\n}\n", + "output": "1", + "index": 13106 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int configure_accelerator(MachineState *ms)\n\n{\n\n const char *p;\n\n char buf[10];\n\n int ret;\n\n bool accel_initialised = false;\n\n bool init_failed = false;\n\n AccelClass *acc = NULL;\n\n\n\n p = qemu_opt_get(qemu_get_machine_opts(), \"accel\");\n\n if (p == NULL) {\n\n /* Use the default \"accelerator\", tcg */\n\n p = \"tcg\";\n\n }\n\n\n\n while (!accel_initialised && *p != '\\0') {\n\n if (*p == ':') {\n\n p++;\n\n }\n\n p = get_opt_name(buf, sizeof(buf), p, ':');\n\n acc = accel_find(buf);\n\n if (!acc) {\n\n fprintf(stderr, \"\\\"%s\\\" accelerator not found.\\n\", buf);\n\n continue;\n\n }\n\n if (acc->available && !acc->available()) {\n\n printf(\"%s not supported for this target\\n\",\n\n acc->name);\n\n continue;\n\n }\n\n ret = accel_init_machine(acc, ms);\n\n if (ret < 0) {\n\n init_failed = true;\n\n fprintf(stderr, \"failed to initialize %s: %s\\n\",\n\n acc->name,\n\n strerror(-ret));\n\n } else {\n\n accel_initialised = true;\n\n }\n\n }\n\n\n\n if (!accel_initialised) {\n\n if (!init_failed) {\n\n fprintf(stderr, \"No accelerator found!\\n\");\n\n }\n\n exit(1);\n\n }\n\n\n\n if (init_failed) {\n\n fprintf(stderr, \"Back to %s accelerator.\\n\", acc->name);\n\n }\n\n\n\n return !accel_initialised;\n\n}\n", + "output": "0", + "index": 18246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my, int i){\n\n static const int tab_size = sizeof(s->direct_scale_mv[0])/sizeof(int16_t);\n\n static const int tab_bias = (tab_size/2);\n\n int xy= s->block_index[i];\n\n uint16_t time_pp= s->pp_time;\n\n uint16_t time_pb= s->pb_time;\n\n int p_mx, p_my;\n\n\n\n p_mx= s->next_picture.motion_val[0][xy][0];\n\n if((unsigned)(p_mx + tab_bias) < tab_size){\n\n s->mv[0][i][0] = s->direct_scale_mv[0][p_mx + tab_bias] + mx;\n\n s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx\n\n : s->direct_scale_mv[1][p_mx + tab_bias];\n\n }else{\n\n s->mv[0][i][0] = p_mx*time_pb/time_pp + mx;\n\n s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx\n\n : p_mx*(time_pb - time_pp)/time_pp;\n\n }\n\n p_my= s->next_picture.motion_val[0][xy][1];\n\n if((unsigned)(p_my + tab_bias) < tab_size){\n\n s->mv[0][i][1] = s->direct_scale_mv[0][p_my + tab_bias] + my;\n\n s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my\n\n : s->direct_scale_mv[1][p_my + tab_bias];\n\n }else{\n\n s->mv[0][i][1] = p_my*time_pb/time_pp + my;\n\n s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my\n\n : p_my*(time_pb - time_pp)/time_pp;\n\n }\n\n}\n", + "output": "1", + "index": 21825 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xenfb_send_position(struct XenInput *xenfb,\n\n\t\t\t int abs_x, int abs_y, int z)\n\n{\n\n union xenkbd_in_event event;\n\n\n\n memset(&event, 0, XENKBD_IN_EVENT_SIZE);\n\n event.type = XENKBD_TYPE_POS;\n\n event.pos.abs_x = abs_x;\n\n event.pos.abs_y = abs_y;\n\n#if __XEN_LATEST_INTERFACE_VERSION__ == 0x00030207\n\n event.pos.abs_z = z;\n\n#endif\n\n#if __XEN_LATEST_INTERFACE_VERSION__ >= 0x00030208\n\n event.pos.rel_z = z;\n\n#endif\n\n\n\n return xenfb_kbd_event(xenfb, &event);\n\n}\n", + "output": "0", + "index": 2605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_mce_inj_srar_dataload(CPUState *env, target_phys_addr_t paddr)\n\n{\n\n struct kvm_x86_mce mce = {\n\n .bank = 9,\n\n .status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN\n\n | MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S\n\n | MCI_STATUS_AR | 0x134,\n\n .mcg_status = MCG_STATUS_MCIP | MCG_STATUS_EIPV,\n\n .addr = paddr,\n\n .misc = (MCM_ADDR_PHYS << 6) | 0xc,\n\n };\n\n int r;\n\n\n\n r = kvm_set_mce(env, &mce);\n\n if (r < 0) {\n\n fprintf(stderr, \"kvm_set_mce: %s\\n\", strerror(errno));\n\n abort();\n\n }\n\n kvm_mce_broadcast_rest(env);\n\n}\n", + "output": "0", + "index": 7385 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_recommended_vcpus(KVMState *s)\n\n{\n\n int ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);\n\n return (ret) ? ret : 4;\n\n}\n", + "output": "1", + "index": 379 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int raw_eject(BlockDriverState *bs, int eject_flag)\n\n{\n\n BDRVRawState *s = bs->opaque;\n\n\n\n switch(s->type) {\n\n case FTYPE_CD:\n\n if (eject_flag) {\n\n if (ioctl (s->fd, CDROMEJECT, NULL) < 0)\n\n perror(\"CDROMEJECT\");\n\n } else {\n\n if (ioctl (s->fd, CDROMCLOSETRAY, NULL) < 0)\n\n perror(\"CDROMEJECT\");\n\n }\n\n break;\n\n case FTYPE_FD:\n\n {\n\n int fd;\n\n if (s->fd >= 0) {\n\n close(s->fd);\n\n s->fd = -1;\n\n raw_close_fd_pool(s);\n\n }\n\n fd = open(bs->filename, s->fd_open_flags | O_NONBLOCK);\n\n if (fd >= 0) {\n\n if (ioctl(fd, FDEJECT, 0) < 0)\n\n perror(\"FDEJECT\");\n\n close(fd);\n\n }\n\n }\n\n break;\n\n default:\n\n return -ENOTSUP;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 1159 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)\n\n{\n\n USBHubState *s = (USBHubState *)dev;\n\n int ret;\n\n\n\n switch(p->pid) {\n\n case USB_TOKEN_IN:\n\n if (p->devep == 1) {\n\n USBHubPort *port;\n\n unsigned int status;\n\n int i, n;\n\n n = (NUM_PORTS + 1 + 7) / 8;\n\n if (p->len == 1) { /* FreeBSD workaround */\n\n n = 1;\n\n } else if (n > p->len) {\n\n return USB_RET_BABBLE;\n\n }\n\n status = 0;\n\n for(i = 0; i < NUM_PORTS; i++) {\n\n port = &s->ports[i];\n\n if (port->wPortChange)\n\n status |= (1 << (i + 1));\n\n }\n\n if (status != 0) {\n\n for(i = 0; i < n; i++) {\n\n p->data[i] = status >> (8 * i);\n\n }\n\n ret = n;\n\n } else {\n\n ret = USB_RET_NAK; /* usb11 11.13.1 */\n\n }\n\n } else {\n\n goto fail;\n\n }\n\n break;\n\n case USB_TOKEN_OUT:\n\n default:\n\n fail:\n\n ret = USB_RET_STALL;\n\n break;\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 22848 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,\n\n int64_t sector_num,\n\n QEMUIOVector *qiov,\n\n int nb_sectors,\n\n BdrvRequestFlags flags,\n\n BlockCompletionFunc *cb,\n\n void *opaque,\n\n bool is_write)\n\n{\n\n Coroutine *co;\n\n BlockAIOCBCoroutine *acb;\n\n\n\n acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);\n\n acb->need_bh = true;\n\n acb->req.error = -EINPROGRESS;\n\n acb->req.sector = sector_num;\n\n acb->req.nb_sectors = nb_sectors;\n\n acb->req.qiov = qiov;\n\n acb->req.flags = flags;\n\n acb->is_write = is_write;\n\n\n\n co = qemu_coroutine_create(bdrv_co_do_rw);\n\n qemu_coroutine_enter(co, acb);\n\n\n\n bdrv_co_maybe_schedule_bh(acb);\n\n return &acb->common;\n\n}\n", + "output": "0", + "index": 9808 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpl2_probe(AVProbeData *p)\n\n{\n\n int i;\n\n char c;\n\n int64_t start, end;\n\n const unsigned char *ptr = p->buf;\n\n const unsigned char *ptr_end = ptr + p->buf_size;\n\n\n\n for (i = 0; i < 2; i++) {\n\n if (sscanf(ptr, \"[%\"SCNd64\"][%\"SCNd64\"]%c\", &start, &end, &c) != 3 &&\n\n sscanf(ptr, \"[%\"SCNd64\"][]%c\", &start, &c) != 2)\n\n return 0;\n\n ptr += strcspn(ptr, \"\\n\") + 1;\n\n if (ptr >= ptr_end)\n\n return 0;\n\n }\n\n return AVPROBE_SCORE_MAX;\n\n}\n", + "output": "1", + "index": 9005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int rom_load_fw(void *fw_cfg)\n\n{\n\n Rom *rom;\n\n\n\n QTAILQ_FOREACH(rom, &roms, next) {\n\n if (!rom->fw_file) {\n\n continue;\n\n }\n\n fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 15716 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aasc_decode_frame(AVCodecContext *avctx,\n void *data, int *got_frame,\n AVPacket *avpkt)\n{\n const uint8_t *buf = avpkt->data;\n int buf_size = avpkt->size;\n AascContext *s = avctx->priv_data;\n int compr, i, stride, ret;\n if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {\n av_log(avctx, AV_LOG_ERROR, \"reget_buffer() failed\\n\");\n return ret;\n }\n compr = AV_RL32(buf);\n buf += 4;\n buf_size -= 4;\n switch (compr) {\n case 0:\n stride = (avctx->width * 3 + 3) & ~3;\n if (buf_size < stride * avctx->height)\n for (i = avctx->height - 1; i >= 0; i--) {\n memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * 3);\n buf += stride;\n }\n break;\n case 1:\n bytestream2_init(&s->gb, buf, buf_size);\n ff_msrle_decode(avctx, (AVPicture*)s->frame, 8, &s->gb);\n break;\n default:\n av_log(avctx, AV_LOG_ERROR, \"Unknown compression type %d\\n\", compr);\n }\n *got_frame = 1;\n if ((ret = av_frame_ref(data, s->frame)) < 0)\n return ret;\n /* report that the buffer was completely consumed */\n return buf_size;\n}", + "output": "1", + "index": 22585 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hypercall_register_types(void)\n\n{\n\n /* hcall-pft */\n\n spapr_register_hypercall(H_ENTER, h_enter);\n\n spapr_register_hypercall(H_REMOVE, h_remove);\n\n spapr_register_hypercall(H_PROTECT, h_protect);\n\n spapr_register_hypercall(H_READ, h_read);\n\n\n\n /* hcall-bulk */\n\n spapr_register_hypercall(H_BULK_REMOVE, h_bulk_remove);\n\n\n\n /* hcall-dabr */\n\n spapr_register_hypercall(H_SET_DABR, h_set_dabr);\n\n\n\n /* hcall-splpar */\n\n spapr_register_hypercall(H_REGISTER_VPA, h_register_vpa);\n\n spapr_register_hypercall(H_CEDE, h_cede);\n\n\n\n /* processor register resource access h-calls */\n\n spapr_register_hypercall(H_SET_SPRG0, h_set_sprg0);\n\n spapr_register_hypercall(H_SET_MODE, h_set_mode);\n\n\n\n /* \"debugger\" hcalls (also used by SLOF). Note: We do -not- differenciate\n\n * here between the \"CI\" and the \"CACHE\" variants, they will use whatever\n\n * mapping attributes qemu is using. When using KVM, the kernel will\n\n * enforce the attributes more strongly\n\n */\n\n spapr_register_hypercall(H_LOGICAL_CI_LOAD, h_logical_load);\n\n spapr_register_hypercall(H_LOGICAL_CI_STORE, h_logical_store);\n\n spapr_register_hypercall(H_LOGICAL_CACHE_LOAD, h_logical_load);\n\n spapr_register_hypercall(H_LOGICAL_CACHE_STORE, h_logical_store);\n\n spapr_register_hypercall(H_LOGICAL_ICBI, h_logical_icbi);\n\n spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf);\n\n spapr_register_hypercall(KVMPPC_H_LOGICAL_MEMOP, h_logical_memop);\n\n\n\n /* qemu/KVM-PPC specific hcalls */\n\n spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas);\n\n\n\n /* ibm,client-architecture-support support */\n\n spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support);\n\n}\n", + "output": "0", + "index": 15965 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vmxnet3_pop_next_tx_descr(VMXNET3State *s,\n\n int qidx,\n\n struct Vmxnet3_TxDesc *txd,\n\n uint32_t *descr_idx)\n\n{\n\n Vmxnet3Ring *ring = &s->txq_descr[qidx].tx_ring;\n\n PCIDevice *d = PCI_DEVICE(s);\n\n\n\n vmxnet3_ring_read_curr_cell(d, ring, txd);\n\n if (txd->gen == vmxnet3_ring_curr_gen(ring)) {\n\n /* Only read after generation field verification */\n\n smp_rmb();\n\n /* Re-read to be sure we got the latest version */\n\n vmxnet3_ring_read_curr_cell(d, ring, txd);\n\n VMXNET3_RING_DUMP(VMW_RIPRN, \"TX\", qidx, ring);\n\n *descr_idx = vmxnet3_ring_curr_cell_idx(ring);\n\n vmxnet3_inc_tx_consumption_counter(s, qidx);\n\n return true;\n\n }\n\n\n\n return false;\n\n}\n", + "output": "1", + "index": 345 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void address_space_write(AddressSpace *as, target_phys_addr_t addr,\n\n const uint8_t *buf, int len)\n\n{\n\n address_space_rw(as, addr, (uint8_t *)buf, len, true);\n\n}\n", + "output": "0", + "index": 20743 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_check_align(DisasContext *ctx, TCGv EA, int mask)\n\n{\n\n int l1 = gen_new_label();\n\n TCGv t0 = tcg_temp_new();\n\n TCGv_i32 t1, t2;\n\n /* NIP cannot be restored if the memory exception comes from an helper */\n\n gen_update_nip(ctx, ctx->nip - 4);\n\n tcg_gen_andi_tl(t0, EA, mask);\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);\n\n t1 = tcg_const_i32(POWERPC_EXCP_ALIGN);\n\n t2 = tcg_const_i32(0);\n\n gen_helper_raise_exception_err(cpu_env, t1, t2);\n\n tcg_temp_free_i32(t1);\n\n tcg_temp_free_i32(t2);\n\n gen_set_label(l1);\n\n tcg_temp_free(t0);\n\n}\n", + "output": "0", + "index": 16305 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void http_log(char *fmt, ...)\n\n{\n\n va_list ap;\n\n va_start(ap, fmt);\n\n \n\n if (logfile)\n\n vfprintf(logfile, fmt, ap);\n\n va_end(ap);\n\n}\n", + "output": "1", + "index": 18387 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void *host_from_stream_offset(QEMUFile *f,\n\n ram_addr_t offset,\n\n int flags)\n\n{\n\n static RAMBlock *block = NULL;\n\n char id[256];\n\n uint8_t len;\n\n\n\n if (flags & RAM_SAVE_FLAG_CONTINUE) {\n\n if (!block) {\n\n error_report(\"Ack, bad migration stream!\");\n\n return NULL;\n\n }\n\n\n\n return memory_region_get_ram_ptr(block->mr) + offset;\n\n }\n\n\n\n len = qemu_get_byte(f);\n\n qemu_get_buffer(f, (uint8_t *)id, len);\n\n id[len] = 0;\n\n\n\n QTAILQ_FOREACH(block, &ram_list.blocks, next) {\n\n if (!strncmp(id, block->idstr, sizeof(id)))\n\n return memory_region_get_ram_ptr(block->mr) + offset;\n\n }\n\n\n\n error_report(\"Can't find block %s!\", id);\n\n return NULL;\n\n}\n", + "output": "1", + "index": 11700 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_time(int wiggle)\n\n{\n\n struct tm start, date[4], end;\n\n struct tm *datep;\n\n time_t ts;\n\n\n\n /*\n\n * This check assumes a few things. First, we cannot guarantee that we get\n\n * a consistent reading from the wall clock because we may hit an edge of\n\n * the clock while reading. To work around this, we read four clock readings\n\n * such that at least two of them should match. We need to assume that one\n\n * reading is corrupt so we need four readings to ensure that we have at\n\n * least two consecutive identical readings\n\n *\n\n * It's also possible that we'll cross an edge reading the host clock so\n\n * simply check to make sure that the clock reading is within the period of\n\n * when we expect it to be.\n\n */\n\n\n\n ts = time(NULL);\n\n gmtime_r(&ts, &start);\n\n\n\n cmos_get_date_time(&date[0]);\n\n cmos_get_date_time(&date[1]);\n\n cmos_get_date_time(&date[2]);\n\n cmos_get_date_time(&date[3]);\n\n\n\n ts = time(NULL);\n\n gmtime_r(&ts, &end);\n\n\n\n if (tm_cmp(&date[0], &date[1]) == 0) {\n\n datep = &date[0];\n\n } else if (tm_cmp(&date[1], &date[2]) == 0) {\n\n datep = &date[1];\n\n } else if (tm_cmp(&date[2], &date[3]) == 0) {\n\n datep = &date[2];\n\n } else {\n\n g_assert_not_reached();\n\n }\n\n\n\n if (!(tm_cmp(&start, datep) <= 0 && tm_cmp(datep, &end) <= 0)) {\n\n time_t t, s;\n\n\n\n start.tm_isdst = datep->tm_isdst;\n\n\n\n t = mktime(datep);\n\n s = mktime(&start);\n\n if (t < s) {\n\n g_test_message(\"RTC is %ld second(s) behind wall-clock\\n\", (s - t));\n\n } else {\n\n g_test_message(\"RTC is %ld second(s) ahead of wall-clock\\n\", (t - s));\n\n }\n\n\n\n g_assert_cmpint(ABS(t - s), <=, wiggle);\n\n }\n\n}\n", + "output": "0", + "index": 1066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n RMDemuxContext *rm = s->priv_data;\n\n AVStream *st;\n\n int i, len, res, seq = 1;\n\n int64_t timestamp, pos;\n\n int flags;\n\n\n\n for (;;) {\n\n if (rm->audio_pkt_cnt) {\n\n // If there are queued audio packet return them first\n\n st = s->streams[rm->audio_stream_num];\n\n res = ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);\n\n if(res < 0)\n\n return res;\n\n flags = 0;\n\n } else {\n\n if (rm->old_format) {\n\n RMStream *ast;\n\n\n\n st = s->streams[0];\n\n ast = st->priv_data;\n\n timestamp = AV_NOPTS_VALUE;\n\n len = !ast->audio_framesize ? RAW_PACKET_SIZE :\n\n ast->coded_framesize * ast->sub_packet_h / 2;\n\n flags = (seq++ == 1) ? 2 : 0;\n\n pos = avio_tell(s->pb);\n\n } else {\n\n len=sync(s, ×tamp, &flags, &i, &pos);\n\n if (len > 0)\n\n st = s->streams[i];\n\n }\n\n\n\n if(len<0 || url_feof(s->pb))\n\n return AVERROR(EIO);\n\n\n\n res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,\n\n &seq, flags, timestamp);\n\n if((flags&2) && (seq&0x7F) == 1)\n\n av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);\n\n if (res)\n\n continue;\n\n }\n\n\n\n if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))\n\n || st->discard >= AVDISCARD_ALL){\n\n av_free_packet(pkt);\n\n } else\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 16854 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int block_save_complete(QEMUFile *f, void *opaque)\n\n{\n\n int ret;\n\n\n\n DPRINTF(\"Enter save live complete submitted %d transferred %d\\n\",\n\n block_mig_state.submitted, block_mig_state.transferred);\n\n\n\n ret = flush_blks(f);\n\n if (ret) {\n\n return ret;\n\n }\n\n\n\n blk_mig_reset_dirty_cursor();\n\n\n\n /* we know for sure that save bulk is completed and\n\n all async read completed */\n\n blk_mig_lock();\n\n assert(block_mig_state.submitted == 0);\n\n blk_mig_unlock();\n\n\n\n do {\n\n ret = blk_mig_save_dirty_block(f, 0);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n } while (ret == 0);\n\n\n\n /* report completion */\n\n qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS);\n\n\n\n DPRINTF(\"Block migration completed\\n\");\n\n\n\n qemu_put_be64(f, BLK_MIG_FLAG_EOS);\n\n\n\n blk_mig_cleanup();\n\n return 0;\n\n}\n", + "output": "1", + "index": 17411 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void parallel_isa_realizefn(DeviceState *dev, Error **errp)\n\n{\n\n static int index;\n\n ISADevice *isadev = ISA_DEVICE(dev);\n\n ISAParallelState *isa = ISA_PARALLEL(dev);\n\n ParallelState *s = &isa->state;\n\n int base;\n\n uint8_t dummy;\n\n\n\n if (!s->chr) {\n\n error_setg(errp, \"Can't create parallel device, empty char device\");\n\n return;\n\n }\n\n\n\n if (isa->index == -1) {\n\n isa->index = index;\n\n }\n\n if (isa->index >= MAX_PARALLEL_PORTS) {\n\n error_setg(errp, \"Max. supported number of parallel ports is %d.\",\n\n MAX_PARALLEL_PORTS);\n\n return;\n\n }\n\n if (isa->iobase == -1) {\n\n isa->iobase = isa_parallel_io[isa->index];\n\n }\n\n index++;\n\n\n\n base = isa->iobase;\n\n isa_init_irq(isadev, &s->irq, isa->isairq);\n\n qemu_register_reset(parallel_reset, s);\n\n\n\n if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) {\n\n s->hw_driver = 1;\n\n s->status = dummy;\n\n }\n\n\n\n isa_register_portio_list(isadev, base,\n\n (s->hw_driver\n\n ? &isa_parallel_portio_hw_list[0]\n\n : &isa_parallel_portio_sw_list[0]),\n\n s, \"parallel\");\n\n}\n", + "output": "1", + "index": 7157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_host_device_remove(Monitor *mon, int vlan_id, const char *device)\n\n{\n\n VLANState *vlan;\n\n VLANClientState *vc;\n\n\n\n vlan = qemu_find_vlan(vlan_id);\n\n\n\n for(vc = vlan->first_client; vc != NULL; vc = vc->next)\n\n if (!strcmp(vc->name, device))\n\n break;\n\n\n\n if (!vc) {\n\n monitor_printf(mon, \"can't find device %s\\n\", device);\n\n return;\n\n }\n\n qemu_del_vlan_client(vc);\n\n}\n", + "output": "0", + "index": 4209 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static attribute_align_arg void *frame_worker_thread(void *arg)\n\n{\n\n PerThreadContext *p = arg;\n\n FrameThreadContext *fctx = p->parent;\n\n AVCodecContext *avctx = p->avctx;\n\n AVCodec *codec = avctx->codec;\n\n\n\n while (1) {\n\n int i;\n\n if (p->state == STATE_INPUT_READY && !fctx->die) {\n\n pthread_mutex_lock(&p->mutex);\n\n while (p->state == STATE_INPUT_READY && !fctx->die)\n\n pthread_cond_wait(&p->input_cond, &p->mutex);\n\n pthread_mutex_unlock(&p->mutex);\n\n }\n\n\n\n if (fctx->die) break;\n\n\n\n if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer))\n\n ff_thread_finish_setup(avctx);\n\n\n\n pthread_mutex_lock(&p->mutex);\n\n avcodec_get_frame_defaults(&p->frame);\n\n p->got_frame = 0;\n\n p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt);\n\n\n\n if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx);\n\n\n\n pthread_mutex_lock(&p->progress_mutex);\n\n for (i = 0; i < MAX_BUFFERS; i++)\n\n if (p->progress_used[i]) {\n\n p->progress[i][0] = INT_MAX;\n\n p->progress[i][1] = INT_MAX;\n\n }\n\n p->state = STATE_INPUT_READY;\n\n\n\n pthread_cond_broadcast(&p->progress_cond);\n\n pthread_cond_signal(&p->output_cond);\n\n pthread_mutex_unlock(&p->progress_mutex);\n\n\n\n pthread_mutex_unlock(&p->mutex);\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "1", + "index": 17384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void object_set_link_property(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n Object **child = opaque;\n\n bool ambiguous = false;\n\n const char *type;\n\n char *path;\n\n\n\n type = object_property_get_type(obj, name, NULL);\n\n\n\n visit_type_str(v, &path, name, errp);\n\n\n\n if (*child) {\n\n object_unref(*child);\n\n }\n\n\n\n if (strcmp(path, \"\") != 0) {\n\n Object *target;\n\n\n\n target = object_resolve_path(path, &ambiguous);\n\n if (target) {\n\n gchar *target_type;\n\n\n\n target_type = g_strdup_printf(\"link<%s>\",\n\n object_get_typename(OBJECT(target)));\n\n if (strcmp(target_type, type) == 0) {\n\n *child = target;\n\n object_ref(target);\n\n } else {\n\n error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type);\n\n }\n\n\n\n g_free(target_type);\n\n } else {\n\n error_set(errp, QERR_DEVICE_NOT_FOUND, path);\n\n }\n\n } else {\n\n *child = NULL;\n\n }\n\n\n\n g_free(path);\n\n}\n", + "output": "0", + "index": 19181 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pty_chr_state(CharDriverState *chr, int connected)\n\n{\n\n PtyCharDriver *s = chr->opaque;\n\n\n\n if (!connected) {\n\n if (s->fd_tag) {\n\n io_remove_watch_poll(s->fd_tag);\n\n s->fd_tag = 0;\n\n }\n\n s->connected = 0;\n\n /* (re-)connect poll interval for idle guests: once per second.\n\n * We check more frequently in case the guests sends data to\n\n * the virtual device linked to our pty. */\n\n pty_chr_rearm_timer(chr, 1000);\n\n } else {\n\n if (s->timer_tag) {\n\n g_source_remove(s->timer_tag);\n\n s->timer_tag = 0;\n\n }\n\n if (!s->connected) {\n\n qemu_chr_be_generic_open(chr);\n\n s->connected = 1;\n\n s->fd_tag = io_add_watch_poll(s->fd, pty_chr_read_poll, pty_chr_read, chr);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 26286 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,\n\n InputEvent *evt)\n\n{\n\n ChannelState *s = (ChannelState *)dev;\n\n int qcode, keycode;\n\n InputKeyEvent *key;\n\n\n\n assert(evt->type == INPUT_EVENT_KIND_KEY);\n\n key = evt->u.key;\n\n qcode = qemu_input_key_value_to_qcode(key->key);\n\n trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode],\n\n key->down);\n\n\n\n if (qcode == Q_KEY_CODE_CAPS_LOCK) {\n\n if (key->down) {\n\n s->caps_lock_mode ^= 1;\n\n if (s->caps_lock_mode == 2) {\n\n return; /* Drop second press */\n\n }\n\n } else {\n\n s->caps_lock_mode ^= 2;\n\n if (s->caps_lock_mode == 3) {\n\n return; /* Drop first release */\n\n }\n\n }\n\n }\n\n\n\n if (qcode == Q_KEY_CODE_NUM_LOCK) {\n\n if (key->down) {\n\n s->num_lock_mode ^= 1;\n\n if (s->num_lock_mode == 2) {\n\n return; /* Drop second press */\n\n }\n\n } else {\n\n s->num_lock_mode ^= 2;\n\n if (s->num_lock_mode == 3) {\n\n return; /* Drop first release */\n\n }\n\n }\n\n }\n\n\n\n keycode = qcode_to_keycode[qcode];\n\n if (!key->down) {\n\n keycode |= 0x80;\n\n }\n\n trace_escc_sunkbd_event_out(keycode);\n\n put_queue(s, keycode);\n\n}\n", + "output": "0", + "index": 15030 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int openfile(char *name, int flags)\n\n{\n\n\tif (bs) {\n\n\t\tfprintf(stderr, \"file open already, try 'help close'\\n\");\n\n\t\treturn 1;\n\n\t}\n\n\n\n\tbs = bdrv_new(\"hda\");\n\n\tif (!bs)\n\n\t\treturn 1;\n\n\n\n\tif (bdrv_open(bs, name, flags) == -1) {\n\n\t\tfprintf(stderr, \"%s: can't open device %s\\n\", progname, name);\n\n\t\tbs = NULL;\n\n\t\treturn 1;\n\n\t}\n\n\n\n\treturn 0;\n\n}\n", + "output": "0", + "index": 14589 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vf_open(vf_instance_t *vf, char *args)\n\n{\n\n vf->config=config;\n\n vf->query_format=query_format;\n\n vf->put_image=put_image;\n\n vf->uninit=uninit;\n\n\n\n vf->priv = calloc(1, sizeof (struct vf_priv_s));\n\n vf->priv->skipline = 0;\n\n vf->priv->scalew = 1;\n\n vf->priv->scaleh = 2;\n\n if (args) sscanf(args, \"%d:%d:%d\", &vf->priv->skipline, &vf->priv->scalew, &vf->priv->scaleh);\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 11485 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_validate_fail_struct_nested(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefTwo *udp = NULL;\n\n Error *err = NULL;\n\n Visitor *v;\n\n\n\n v = validate_test_init(data, \"{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}\");\n\n\n\n visit_type_UserDefTwo(v, NULL, &udp, &err);\n\n error_free_or_abort(&err);\n\n qapi_free_UserDefTwo(udp);\n\n}\n", + "output": "1", + "index": 13734 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bswap_shdr(struct elf_shdr *shdr)\n\n{\n\n bswap32s(&shdr->sh_name);\n\n bswap32s(&shdr->sh_type);\n\n bswaptls(&shdr->sh_flags);\n\n bswaptls(&shdr->sh_addr);\n\n bswaptls(&shdr->sh_offset);\n\n bswaptls(&shdr->sh_size);\n\n bswap32s(&shdr->sh_link);\n\n bswap32s(&shdr->sh_info);\n\n bswaptls(&shdr->sh_addralign);\n\n bswaptls(&shdr->sh_entsize);\n\n}\n", + "output": "0", + "index": 13160 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,\n\n unsigned long vga_ram_offset, int vga_ram_size)\n\n{\n\n CirrusVGAState *s;\n\n\n\n s = qemu_mallocz(sizeof(CirrusVGAState));\n\n\n\n vga_common_init((VGAState *)s,\n\n ds, vga_ram_base, vga_ram_offset, vga_ram_size);\n\n cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);\n\n s->console = graphic_console_init(s->ds, s->update, s->invalidate,\n\n s->screen_dump, s->text_update, s);\n\n /* XXX ISA-LFB support */\n\n}\n", + "output": "0", + "index": 11259 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){\n\n int64_t pos = avio_tell(pb);\n\n avio_wb32(pb, 0); /* size */\n\n ffio_wfourcc(pb, \"name\"); /* Data format */\n\n avio_wb16(pb, strlen(reel_name)); /* string size */\n\n avio_wb16(pb, track->language); /* langcode */\n\n avio_write(pb, reel_name, strlen(reel_name)); /* reel name */\n\n return update_size(pb,pos);\n\n}\n", + "output": "0", + "index": 9341 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void guess_chs_for_size(BlockDriverState *bs,\n\n uint32_t *pcyls, uint32_t *pheads, uint32_t *psecs)\n\n{\n\n uint64_t nb_sectors;\n\n int cylinders;\n\n\n\n bdrv_get_geometry(bs, &nb_sectors);\n\n\n\n cylinders = nb_sectors / (16 * 63);\n\n if (cylinders > 16383) {\n\n cylinders = 16383;\n\n } else if (cylinders < 2) {\n\n cylinders = 2;\n\n }\n\n *pcyls = cylinders;\n\n *pheads = 16;\n\n *psecs = 63;\n\n}\n", + "output": "0", + "index": 15790 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_mov_reg_v(int ot, int reg, TCGv t0)\n\n{\n\n switch(ot) {\n\n case OT_BYTE:\n\n if (reg < 4 X86_64_DEF( || reg >= 8 || x86_64_hregs)) {\n\n tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 8);\n\n } else {\n\n tcg_gen_deposit_tl(cpu_regs[reg - 4], cpu_regs[reg - 4], t0, 8, 8);\n\n }\n\n break;\n\n case OT_WORD:\n\n tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 16);\n\n break;\n\n default: /* XXX this shouldn't be reached; abort? */\n\n case OT_LONG:\n\n /* For x86_64, this sets the higher half of register to zero.\n\n For i386, this is equivalent to a mov. */\n\n tcg_gen_ext32u_tl(cpu_regs[reg], t0);\n\n break;\n\n#ifdef TARGET_X86_64\n\n case OT_QUAD:\n\n tcg_gen_mov_tl(cpu_regs[reg], t0);\n\n break;\n\n#endif\n\n }\n\n}\n", + "output": "0", + "index": 25286 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void piix4_ide_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);\n\n\n\n k->no_hotplug = 1;\n\n k->init = pci_piix_ide_initfn;\n\n k->exit = pci_piix_ide_exitfn;\n\n k->vendor_id = PCI_VENDOR_ID_INTEL;\n\n k->device_id = PCI_DEVICE_ID_INTEL_82371AB;\n\n k->class_id = PCI_CLASS_STORAGE_IDE;\n\n set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);\n\n dc->no_user = 1;\n\n}\n", + "output": "1", + "index": 17938 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_info_vnc(void)\n\n{\n\n if (vnc_state == NULL)\n\n\tterm_printf(\"VNC server disabled\\n\");\n\n else {\n\n\tterm_printf(\"VNC server active on: \");\n\n\tterm_print_filename(vnc_state->display);\n\n\tterm_printf(\"\\n\");\n\n\n\n\tif (vnc_state->csock == -1)\n\n\t term_printf(\"No client connected\\n\");\n\n\telse\n\n\t term_printf(\"Client connected\\n\");\n\n }\n\n}\n", + "output": "1", + "index": 6479 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type)\n\n{\n\n ByteIOContext *pb = mxf->fc->pb;\n\n MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;\n\n uint64_t klv_end = url_ftell(pb) + klv->length;\n\n\n\n if (!ctx)\n\n return -1;\n\n while (url_ftell(pb) + 4 < klv_end) {\n\n int tag = get_be16(pb);\n\n int size = get_be16(pb); /* KLV specified by 0x53 */\n\n uint64_t next = url_ftell(pb) + size;\n\n UID uid;\n\n\n\n if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */\n\n av_log(mxf->fc, AV_LOG_ERROR, \"local tag 0x%04X with 0 size\\n\", tag);\n\n continue;\n\n }\n\n if (tag > 0x7FFF) { /* dynamic tag */\n\n int i;\n\n for (i = 0; i < mxf->local_tags_count; i++) {\n\n int local_tag = AV_RB16(mxf->local_tags+i*18);\n\n if (local_tag == tag) {\n\n memcpy(uid, mxf->local_tags+i*18+2, 16);\n\n dprintf(mxf->fc, \"local tag 0x%04X\\n\", local_tag);\n\n#ifdef DEBUG\n\n PRINT_KEY(mxf->fc, \"uid\", uid);\n\n#endif\n\n }\n\n }\n\n }\n\n if (ctx_size && tag == 0x3C0A)\n\n get_buffer(pb, ctx->uid, 16);\n\n else\n\n read_child(ctx, pb, tag, size, uid);\n\n\n\n url_fseek(pb, next, SEEK_SET);\n\n }\n\n if (ctx_size) ctx->type = type;\n\n return ctx_size ? mxf_add_metadata_set(mxf, ctx) : 0;\n\n}\n", + "output": "0", + "index": 22599 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static MigrationState *migrate_init(const MigrationParams *params)\n\n{\n\n MigrationState *s = migrate_get_current();\n\n int64_t bandwidth_limit = s->bandwidth_limit;\n\n bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];\n\n int64_t xbzrle_cache_size = s->xbzrle_cache_size;\n\n\n\n memcpy(enabled_capabilities, s->enabled_capabilities,\n\n sizeof(enabled_capabilities));\n\n\n\n memset(s, 0, sizeof(*s));\n\n s->params = *params;\n\n memcpy(s->enabled_capabilities, enabled_capabilities,\n\n sizeof(enabled_capabilities));\n\n s->xbzrle_cache_size = xbzrle_cache_size;\n\n\n\n s->bandwidth_limit = bandwidth_limit;\n\n s->state = MIG_STATE_SETUP;\n\n trace_migrate_set_state(MIG_STATE_SETUP);\n\n\n\n s->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);\n\n return s;\n\n}\n", + "output": "1", + "index": 24024 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool qht_reset_size(struct qht *ht, size_t n_elems)\n\n{\n\n struct qht_map *new;\n\n struct qht_map *map;\n\n size_t n_buckets;\n\n bool resize = false;\n\n\n\n n_buckets = qht_elems_to_buckets(n_elems);\n\n\n\n qemu_mutex_lock(&ht->lock);\n\n map = ht->map;\n\n if (n_buckets != map->n_buckets) {\n\n new = qht_map_create(n_buckets);\n\n resize = true;\n\n }\n\n\n\n qht_map_lock_buckets(map);\n\n qht_map_reset__all_locked(map);\n\n if (resize) {\n\n qht_do_resize(ht, new);\n\n }\n\n qht_map_unlock_buckets(map);\n\n qemu_mutex_unlock(&ht->lock);\n\n\n\n return resize;\n\n}\n", + "output": "0", + "index": 7456 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_qdev_init(DeviceState *qdev)\n\n{\n\n SCSIDevice *dev = SCSI_DEVICE(qdev);\n\n SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);\n\n SCSIDevice *d;\n\n int rc = -1;\n\n\n\n if (dev->channel > bus->info->max_channel) {\n\n error_report(\"bad scsi channel id: %d\", dev->channel);\n\n goto err;\n\n }\n\n if (dev->id != -1 && dev->id > bus->info->max_target) {\n\n error_report(\"bad scsi device id: %d\", dev->id);\n\n goto err;\n\n }\n\n\n\n if (dev->id == -1) {\n\n int id = -1;\n\n if (dev->lun == -1) {\n\n dev->lun = 0;\n\n }\n\n do {\n\n d = scsi_device_find(bus, dev->channel, ++id, dev->lun);\n\n } while (d && d->lun == dev->lun && id <= bus->info->max_target);\n\n if (id > bus->info->max_target) {\n\n error_report(\"no free target\");\n\n goto err;\n\n }\n\n dev->id = id;\n\n } else if (dev->lun == -1) {\n\n int lun = -1;\n\n do {\n\n d = scsi_device_find(bus, dev->channel, dev->id, ++lun);\n\n } while (d && d->lun == lun && lun < bus->info->max_lun);\n\n if (lun > bus->info->max_lun) {\n\n error_report(\"no free lun\");\n\n goto err;\n\n }\n\n dev->lun = lun;\n\n } else {\n\n d = scsi_device_find(bus, dev->channel, dev->id, dev->lun);\n\n if (dev->lun == d->lun && dev != d) {\n\n qdev_free(&d->qdev);\n\n }\n\n }\n\n\n\n QTAILQ_INIT(&dev->requests);\n\n rc = scsi_device_init(dev);\n\n if (rc == 0) {\n\n dev->vmsentry = qemu_add_vm_change_state_handler(scsi_dma_restart_cb,\n\n dev);\n\n }\n\n\n\nerr:\n\n return rc;\n\n}\n", + "output": "1", + "index": 14186 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void taihu_cpld_writew (void *opaque,\n\n hwaddr addr, uint32_t value)\n\n{\n\n taihu_cpld_writeb(opaque, addr, (value >> 8) & 0xFF);\n\n taihu_cpld_writeb(opaque, addr + 1, value & 0xFF);\n\n}\n", + "output": "0", + "index": 14273 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)\n\n{\n\n int ret;\n\n struct flock fl = {\n\n .l_whence = SEEK_SET,\n\n .l_start = start,\n\n .l_len = len,\n\n .l_type = exclusive ? F_WRLCK : F_RDLCK,\n\n };\n\n ret = fcntl(fd, QEMU_GETLK, &fl);\n\n if (ret == -1) {\n\n return -errno;\n\n } else {\n\n return fl.l_type == F_UNLCK ? 0 : -EAGAIN;\n\n }\n\n}\n", + "output": "0", + "index": 6760 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)\n\n{\n\n AVStream *st = s->streams[stream_index];\n\n MPCContext *c = s->priv_data;\n\n AVPacket pkt1, *pkt = &pkt1;\n\n int ret;\n\n int index = av_index_search_timestamp(st, timestamp - DELAY_FRAMES, flags);\n\n uint32_t lastframe;\n\n\n\n /* if found, seek there */\n\n if (index >= 0){\n\n c->curframe = st->index_entries[index].pos;\n\n return 0;\n\n }\n\n /* if timestamp is out of bounds, return error */\n\n if(timestamp < 0 || timestamp >= c->fcount)\n\n return -1;\n\n timestamp -= DELAY_FRAMES;\n\n /* seek to the furthest known position and read packets until\n\n we reach desired position */\n\n lastframe = c->curframe;\n\n if(c->frames_noted) c->curframe = c->frames_noted - 1;\n\n while(c->curframe < timestamp){\n\n ret = av_read_frame(s, pkt);\n\n if (ret < 0){\n\n c->curframe = lastframe;\n\n return ret;\n\n }\n\n av_free_packet(pkt);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 14950 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void aarch64_cpu_register_types(void)\n\n{\n\n int i;\n\n\n\n type_register_static(&aarch64_cpu_type_info);\n\n for (i = 0; i < ARRAY_SIZE(aarch64_cpus); i++) {\n\n aarch64_cpu_register(&aarch64_cpus[i]);\n\n }\n\n}\n", + "output": "0", + "index": 16842 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void patch_reloc(tcg_insn_unit *code_ptr, int type,\n\n intptr_t value, intptr_t addend)\n\n{\n\n assert(addend == 0);\n\n switch (type) {\n\n case R_AARCH64_JUMP26:\n\n case R_AARCH64_CALL26:\n\n reloc_pc26(code_ptr, (tcg_insn_unit *)value);\n\n break;\n\n case R_AARCH64_CONDBR19:\n\n reloc_pc19(code_ptr, (tcg_insn_unit *)value);\n\n break;\n\n default:\n\n tcg_abort();\n\n }\n\n}\n", + "output": "0", + "index": 15648 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ehci_reset(void *opaque)\n\n{\n\n EHCIState *s = opaque;\n\n int i;\n\n USBDevice *devs[NB_PORTS];\n\n\n\n trace_usb_ehci_reset();\n\n\n\n /*\n\n * Do the detach before touching portsc, so that it correctly gets send to\n\n * us or to our companion based on PORTSC_POWNER before the reset.\n\n */\n\n for(i = 0; i < NB_PORTS; i++) {\n\n devs[i] = s->ports[i].dev;\n\n if (devs[i] && devs[i]->attached) {\n\n usb_detach(&s->ports[i]);\n\n }\n\n }\n\n\n\n memset(&s->mmio[OPREGBASE], 0x00, MMIO_SIZE - OPREGBASE);\n\n\n\n s->usbcmd = NB_MAXINTRATE << USBCMD_ITC_SH;\n\n s->usbsts = USBSTS_HALT;\n\n s->usbsts_pending = 0;\n\n s->usbsts_frindex = 0;\n\n\n\n s->astate = EST_INACTIVE;\n\n s->pstate = EST_INACTIVE;\n\n\n\n for(i = 0; i < NB_PORTS; i++) {\n\n if (s->companion_ports[i]) {\n\n s->portsc[i] = PORTSC_POWNER | PORTSC_PPOWER;\n\n } else {\n\n s->portsc[i] = PORTSC_PPOWER;\n\n }\n\n if (devs[i] && devs[i]->attached) {\n\n usb_attach(&s->ports[i]);\n\n usb_device_reset(devs[i]);\n\n }\n\n }\n\n ehci_queues_rip_all(s, 0);\n\n ehci_queues_rip_all(s, 1);\n\n qemu_del_timer(s->frame_timer);\n\n qemu_bh_cancel(s->async_bh);\n\n}\n", + "output": "1", + "index": 13447 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vpc_write(BlockDriverState *bs, int64_t sector_num,\n\n const uint8_t *buf, int nb_sectors)\n\n{\n\n BDRVVPCState *s = bs->opaque;\n\n int64_t offset;\n\n int64_t sectors, sectors_per_block;\n\n int ret;\n\n VHDFooter *footer = (VHDFooter *) s->footer_buf;\n\n\n\n if (cpu_to_be32(footer->type) == VHD_FIXED) {\n\n return bdrv_write(bs->file, sector_num, buf, nb_sectors);\n\n }\n\n while (nb_sectors > 0) {\n\n offset = get_sector_offset(bs, sector_num, 1);\n\n\n\n sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;\n\n sectors = sectors_per_block - (sector_num % sectors_per_block);\n\n if (sectors > nb_sectors) {\n\n sectors = nb_sectors;\n\n }\n\n\n\n if (offset == -1) {\n\n offset = alloc_block(bs, sector_num);\n\n if (offset < 0)\n\n return -1;\n\n }\n\n\n\n ret = bdrv_pwrite(bs->file, offset, buf, sectors * BDRV_SECTOR_SIZE);\n\n if (ret != sectors * BDRV_SECTOR_SIZE) {\n\n return -1;\n\n }\n\n\n\n nb_sectors -= sectors;\n\n sector_num += sectors;\n\n buf += sectors * BDRV_SECTOR_SIZE;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 25741 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_finalize_fdt(sPAPREnvironment *spapr,\n\n target_phys_addr_t fdt_addr,\n\n target_phys_addr_t rtas_addr,\n\n target_phys_addr_t rtas_size)\n\n{\n\n int ret;\n\n void *fdt;\n\n sPAPRPHBState *phb;\n\n\n\n fdt = g_malloc(FDT_MAX_SIZE);\n\n\n\n /* open out the base tree into a temp buffer for the final tweaks */\n\n _FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));\n\n\n\n ret = spapr_populate_vdevice(spapr->vio_bus, fdt);\n\n if (ret < 0) {\n\n fprintf(stderr, \"couldn't setup vio devices in fdt\\n\");\n\n exit(1);\n\n }\n\n\n\n QLIST_FOREACH(phb, &spapr->phbs, list) {\n\n ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);\n\n }\n\n\n\n if (ret < 0) {\n\n fprintf(stderr, \"couldn't setup PCI devices in fdt\\n\");\n\n exit(1);\n\n }\n\n\n\n /* RTAS */\n\n ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);\n\n if (ret < 0) {\n\n fprintf(stderr, \"Couldn't set up RTAS device tree properties\\n\");\n\n }\n\n\n\n /* Advertise NUMA via ibm,associativity */\n\n if (nb_numa_nodes > 1) {\n\n ret = spapr_set_associativity(fdt, spapr);\n\n if (ret < 0) {\n\n fprintf(stderr, \"Couldn't set up NUMA device tree properties\\n\");\n\n }\n\n }\n\n\n\n if (!spapr->has_graphics) {\n\n spapr_populate_chosen_stdout(fdt, spapr->vio_bus);\n\n }\n\n\n\n _FDT((fdt_pack(fdt)));\n\n\n\n if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {\n\n hw_error(\"FDT too big ! 0x%x bytes (max is 0x%x)\\n\",\n\n fdt_totalsize(fdt), FDT_MAX_SIZE);\n\n exit(1);\n\n }\n\n\n\n cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));\n\n\n\n g_free(fdt);\n\n}\n", + "output": "1", + "index": 3892 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int h263_decode_gob_header(MpegEncContext *s)\n\n{\n\n unsigned int val, gob_number;\n\n int left;\n\n\n\n /* Check for GOB Start Code */\n\n val = show_bits(&s->gb, 16);\n\n if(val)\n\n return -1;\n\n\n\n /* We have a GBSC probably with GSTUFF */\n\n skip_bits(&s->gb, 16); /* Drop the zeros */\n\n left= get_bits_left(&s->gb);\n\n\n //MN: we must check the bits left or we might end in an infinite loop (or segfault)\n\n for(;left>13; left--){\n\n if(get_bits1(&s->gb)) break; /* Seek the '1' bit */\n\n }\n\n if(left<=13)\n\n return -1;\n\n\n\n if(s->h263_slice_structured){\n\n if(check_marker(s->avctx, &s->gb, \"before MBA\")==0)\n\n return -1;\n\n\n\n ff_h263_decode_mba(s);\n\n\n\n if(s->mb_num > 1583)\n\n if(check_marker(s->avctx, &s->gb, \"after MBA\")==0)\n\n return -1;\n\n\n\n s->qscale = get_bits(&s->gb, 5); /* SQUANT */\n\n if(check_marker(s->avctx, &s->gb, \"after SQUANT\")==0)\n\n return -1;\n\n skip_bits(&s->gb, 2); /* GFID */\n\n }else{\n\n gob_number = get_bits(&s->gb, 5); /* GN */\n\n s->mb_x= 0;\n\n s->mb_y= s->gob_index* gob_number;\n\n skip_bits(&s->gb, 2); /* GFID */\n\n s->qscale = get_bits(&s->gb, 5); /* GQUANT */\n\n }\n\n\n\n if(s->mb_y >= s->mb_height)\n\n return -1;\n\n\n\n if(s->qscale==0)\n\n return -1;\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 6882 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "dma_read(void *opaque, target_phys_addr_t addr, unsigned int size)\n\n{\n\n struct fs_dma_ctrl *ctrl = opaque;\n\n\tint c;\n\n\tuint32_t r = 0;\n\n\n\n\tif (size != 4) {\n\n\t\tdma_rinvalid(opaque, addr);\n\n\t}\n\n\n\n\t/* Make addr relative to this channel and bounded to nr regs. */\n\n\tc = fs_channel(addr);\n\n\taddr &= 0xff;\n\n\taddr >>= 2;\n\n\tswitch (addr)\n\n\t{\n\n\t\tcase RW_STAT:\n\n\t\t\tr = ctrl->channels[c].state & 7;\n\n\t\t\tr |= ctrl->channels[c].eol << 5;\n\n\t\t\tr |= ctrl->channels[c].stream_cmd_src << 8;\n\n\t\t\tbreak;\n\n\n\n\t\tdefault:\n\n\t\t\tr = ctrl->channels[c].regs[addr];\n\n\t\t\tD(printf (\"%s c=%d addr=\" TARGET_FMT_plx \"\\n\",\n\n\t\t\t\t __func__, c, addr));\n\n\t\t\tbreak;\n\n\t}\n\n\treturn r;\n\n}\n", + "output": "0", + "index": 26451 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pci_spapr_set_irq(void *opaque, int irq_num, int level)\n\n{\n\n /*\n\n * Here we use the number returned by pci_spapr_map_irq to find a\n\n * corresponding qemu_irq.\n\n */\n\n sPAPRPHBState *phb = opaque;\n\n\n\n qemu_set_irq(phb->lsi_table[irq_num].qirq, level);\n\n}\n", + "output": "0", + "index": 23588 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_read_xer (DisasContext *ctx, int gprn, int sprn)\n\n{\n\n gen_read_xer(cpu_gpr[gprn]);\n\n}\n", + "output": "1", + "index": 13118 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st)\n\n{\n\n GetByteContext gb;\n\n uint8_t *data = st->codecpar->extradata;\n\n int data_size = st->codecpar->extradata_size;\n\n int tag, offset;\n\n\n\n if (!data || data_size < 8) {\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n bytestream2_init(&gb, data, data_size);\n\n\n\n tag = bytestream2_get_le32(&gb);\n\n\n\n switch (tag) {\n\n case MKTAG('A', 'V', 'I', 'F'):\n\n // skip 4 byte padding\n\n bytestream2_skip(&gb, 4);\n\n offset = bytestream2_tell(&gb);\n\n bytestream2_init(&gb, data + offset, data_size - offset);\n\n\n\n // decode EXIF tags from IFD, AVI is always little-endian\n\n return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata);\n\n break;\n\n case MKTAG('C', 'A', 'S', 'I'):\n\n avpriv_request_sample(s, \"RIFF stream data tag type CASI (%u)\", tag);\n\n break;\n\n case MKTAG('Z', 'o', 'r', 'a'):\n\n avpriv_request_sample(s, \"RIFF stream data tag type Zora (%u)\", tag);\n\n break;\n\n default:\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22722 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cirrus_bitblt_videotovideo_copy(CirrusVGAState * s)\n\n{\n\n if (blit_is_unsafe(s))\n\n return 0;\n\n\n\n return cirrus_do_copy(s, s->cirrus_blt_dstaddr - s->vga.start_addr,\n\n s->cirrus_blt_srcaddr - s->vga.start_addr,\n\n s->cirrus_blt_width, s->cirrus_blt_height);\n\n}\n", + "output": "1", + "index": 13853 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_timestamp_to_str(uint64_t timestamp, char **str)\n{\n struct tm time = { 0 };\n time.tm_year = (timestamp >> 48) - 1900;\n time.tm_mon = (timestamp >> 40 & 0xFF) - 1;\n time.tm_mday = (timestamp >> 32 & 0xFF);\n time.tm_hour = (timestamp >> 24 & 0xFF);\n time.tm_min = (timestamp >> 16 & 0xFF);\n time.tm_sec = (timestamp >> 8 & 0xFF);\n *str = av_mallocz(32);\n if (!*str)\n return AVERROR(ENOMEM);\n strftime(*str, 32, \"%Y-%m-%d %H:%M:%S\", &time);\n return 0;\n}", + "output": "1", + "index": 5780 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_machine_device_post_plug_cb(HotplugHandler *hotplug_dev,\n\n DeviceState *dev, Error **errp)\n\n{\n\n if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {\n\n pc_dimm_post_plug(hotplug_dev, dev, errp);\n\n }\n\n}\n", + "output": "0", + "index": 9052 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)\n\n{\n\n VirtIODevice *vdev = VIRTIO_DEVICE(dev);\n\n VirtIOBalloon *s = VIRTIO_BALLOON(dev);\n\n int ret;\n\n\n\n virtio_init(vdev, \"virtio-balloon\", VIRTIO_ID_BALLOON,\n\n sizeof(struct virtio_balloon_config));\n\n\n\n ret = qemu_add_balloon_handler(virtio_balloon_to_target,\n\n virtio_balloon_stat, s);\n\n\n\n if (ret < 0) {\n\n error_setg(errp, \"Adding balloon handler failed\");\n\n virtio_cleanup(vdev);\n\n return;\n\n }\n\n\n\n s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);\n\n s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);\n\n s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);\n\n\n\n reset_stats(s);\n\n\n\n register_savevm(dev, \"virtio-balloon\", -1, 1,\n\n virtio_balloon_save, virtio_balloon_load, s);\n\n\n\n object_property_add(OBJECT(dev), \"guest-stats\", \"guest statistics\",\n\n balloon_stats_get_all, NULL, NULL, s, NULL);\n\n\n\n object_property_add(OBJECT(dev), \"guest-stats-polling-interval\", \"int\",\n\n balloon_stats_get_poll_interval,\n\n balloon_stats_set_poll_interval,\n\n NULL, s, NULL);\n\n}\n", + "output": "1", + "index": 4061 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void visit_nested_struct(Visitor *v, void **native, Error **errp)\n\n{\n\n visit_type_UserDefNested(v, (UserDefNested **)native, NULL, errp);\n\n}\n", + "output": "0", + "index": 1079 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)\n\n{\n\n if (xen_enabled()) {\n\n return xen_map_cache(addr, *size, 1);\n\n } else {\n\n RAMBlock *block;\n\n\n\n QLIST_FOREACH(block, &ram_list.blocks, next) {\n\n if (addr - block->offset < block->length) {\n\n if (addr - block->offset + *size > block->length)\n\n *size = block->length - addr + block->offset;\n\n return block->host + (addr - block->offset);\n\n }\n\n }\n\n\n\n fprintf(stderr, \"Bad ram offset %\" PRIx64 \"\\n\", (uint64_t)addr);\n\n abort();\n\n\n\n *size = 0;\n\n return NULL;\n\n }\n\n}\n", + "output": "0", + "index": 1245 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)\n\n{\n\n\tsize_t *sizes = calloc(nr_iov, sizeof(size_t));\n\n\tsize_t count = 0;\n\n\tvoid *buf, *p;\n\n\tint i;\n\n\n\n\tfor (i = 0; i < nr_iov; i++) {\n\n\t\tchar *arg = argv[i];\n\n\t\tlong long len;\n\n\n\n\t\tlen = cvtnum(arg);\n\n\t\tif (len < 0) {\n\n\t\t\tprintf(\"non-numeric length argument -- %s\\n\", arg);\n\n\t\t\treturn NULL;\n\n\t\t}\n\n\n\n\t\t/* should be SIZE_T_MAX, but that doesn't exist */\n\n\t\tif (len > UINT_MAX) {\n\n\t\t\tprintf(\"too large length argument -- %s\\n\", arg);\n\n\t\t\treturn NULL;\n\n\t\t}\n\n\n\n\t\tif (len & 0x1ff) {\n\n\t\t\tprintf(\"length argument %lld is not sector aligned\\n\",\n\n\t\t\t\tlen);\n\n\t\t\treturn NULL;\n\n\t\t}\n\n\n\n\t\tsizes[i] = len;\n\n\t\tcount += len;\n\n\t}\n\n\n\n\tqemu_iovec_init(qiov, nr_iov);\n\n\n\n\tbuf = p = qemu_io_alloc(count, pattern);\n\n\n\n\tfor (i = 0; i < nr_iov; i++) {\n\n\t\tqemu_iovec_add(qiov, p, sizes[i]);\n\n\t\tp += sizes[i];\n\n\t}\n\n\n\n\tfree(sizes);\n\n\treturn buf;\n\n}\n", + "output": "1", + "index": 25052 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool io_mem_read(MemoryRegion *mr, hwaddr addr, uint64_t *pval, unsigned size)\n\n{\n\n return memory_region_dispatch_read(mr, addr, pval, size);\n\n}\n", + "output": "1", + "index": 3071 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void host_cpuid(uint32_t function, uint32_t count,\n\n uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)\n\n{\n\n#if defined(CONFIG_KVM)\n\n uint32_t vec[4];\n\n\n\n#ifdef __x86_64__\n\n asm volatile(\"cpuid\"\n\n : \"=a\"(vec[0]), \"=b\"(vec[1]),\n\n \"=c\"(vec[2]), \"=d\"(vec[3])\n\n : \"0\"(function), \"c\"(count) : \"cc\");\n\n#else\n\n asm volatile(\"pusha \\n\\t\"\n\n \"cpuid \\n\\t\"\n\n \"mov %%eax, 0(%2) \\n\\t\"\n\n \"mov %%ebx, 4(%2) \\n\\t\"\n\n \"mov %%ecx, 8(%2) \\n\\t\"\n\n \"mov %%edx, 12(%2) \\n\\t\"\n\n \"popa\"\n\n : : \"a\"(function), \"c\"(count), \"S\"(vec)\n\n : \"memory\", \"cc\");\n\n#endif\n\n\n\n if (eax)\n\n *eax = vec[0];\n\n if (ebx)\n\n *ebx = vec[1];\n\n if (ecx)\n\n *ecx = vec[2];\n\n if (edx)\n\n *edx = vec[3];\n\n#endif\n\n}\n", + "output": "0", + "index": 3358 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_add_child_watch(pid_t pid)\n\n{\n\n ChildProcessRecord *rec;\n\n\n\n if (!sigchld_bh) {\n\n qemu_init_child_watch();\n\n }\n\n\n\n QLIST_FOREACH(rec, &child_watches, next) {\n\n if (rec->pid == pid) {\n\n return 1;\n\n }\n\n }\n\n rec = g_malloc0(sizeof(ChildProcessRecord));\n\n rec->pid = pid;\n\n QLIST_INSERT_HEAD(&child_watches, rec, next);\n\n return 0;\n\n}\n", + "output": "0", + "index": 3359 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_x_input_send_event(bool has_console, int64_t console,\n\n InputEventList *events, Error **errp)\n\n{\n\n InputEventList *e;\n\n QemuConsole *con;\n\n\n\n con = NULL;\n\n if (has_console) {\n\n con = qemu_console_lookup_by_index(console);\n\n if (!con) {\n\n error_setg(errp, \"console %\" PRId64 \" not found\", console);\n\n return;\n\n }\n\n }\n\n\n\n if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {\n\n error_setg(errp, \"VM not running\");\n\n return;\n\n }\n\n\n\n for (e = events; e != NULL; e = e->next) {\n\n InputEvent *event = e->value;\n\n\n\n if (!qemu_input_find_handler(1 << event->kind, con)) {\n\n error_setg(errp, \"Input handler not found for \"\n\n \"event type %s\",\n\n InputEventKind_lookup[event->kind]);\n\n return;\n\n }\n\n }\n\n\n\n for (e = events; e != NULL; e = e->next) {\n\n InputEvent *event = e->value;\n\n\n\n qemu_input_event_send(con, event);\n\n }\n\n\n\n qemu_input_event_sync();\n\n}\n", + "output": "0", + "index": 11683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint8_t cpu_inb(CPUState *env, pio_addr_t addr)\n\n{\n\n uint8_t val;\n\n val = ioport_read(0, addr);\n\n LOG_IOPORT(\"inb : %04\"FMT_pioaddr\" %02\"PRIx8\"\\n\", addr, val);\n\n#ifdef CONFIG_KQEMU\n\n if (env)\n\n env->last_io_time = cpu_get_time_fast();\n\n#endif\n\n return val;\n\n}\n", + "output": "0", + "index": 2163 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void drive_backup_prepare(BlkTransactionState *common, Error **errp)\n\n{\n\n DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);\n\n BlockBackend *blk;\n\n DriveBackup *backup;\n\n Error *local_err = NULL;\n\n\n\n assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);\n\n backup = common->action->drive_backup;\n\n\n\n blk = blk_by_name(backup->device);\n\n if (!blk) {\n\n error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,\n\n \"Device '%s' not found\", backup->device);\n\n return;\n\n }\n\n\n\n /* AioContext is released in .clean() */\n\n state->aio_context = blk_get_aio_context(blk);\n\n aio_context_acquire(state->aio_context);\n\n\n\n qmp_drive_backup(backup->device, backup->target,\n\n backup->has_format, backup->format,\n\n backup->sync,\n\n backup->has_mode, backup->mode,\n\n backup->has_speed, backup->speed,\n\n backup->has_bitmap, backup->bitmap,\n\n backup->has_on_source_error, backup->on_source_error,\n\n backup->has_on_target_error, backup->on_target_error,\n\n &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n state->bs = blk_bs(blk);\n\n state->job = state->bs->job;\n\n}\n", + "output": "0", + "index": 9541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int monitor_check_qmp_args(const mon_cmd_t *cmd, QDict *args)\n\n{\n\n int err;\n\n const char *p;\n\n CmdArgs cmd_args;\n\n QemuOptsList *opts_list;\n\n\n\n if (cmd->args_type == NULL) {\n\n return (qdict_size(args) == 0 ? 0 : -1);\n\n }\n\n\n\n err = 0;\n\n cmd_args_init(&cmd_args);\n\n opts_list = NULL;\n\n\n\n for (p = cmd->args_type;; p++) {\n\n if (*p == ':') {\n\n cmd_args.type = *++p;\n\n p++;\n\n if (cmd_args.type == '-') {\n\n cmd_args.flag = *p++;\n\n cmd_args.optional = 1;\n\n } else if (cmd_args.type == 'O') {\n\n opts_list = qemu_find_opts(qstring_get_str(cmd_args.name));\n\n assert(opts_list);\n\n } else if (*p == '?') {\n\n cmd_args.optional = 1;\n\n p++;\n\n }\n\n\n\n assert(*p == ',' || *p == '\\0');\n\n if (opts_list) {\n\n err = check_opts(opts_list, args);\n\n opts_list = NULL;\n\n } else {\n\n err = check_arg(&cmd_args, args);\n\n QDECREF(cmd_args.name);\n\n cmd_args_init(&cmd_args);\n\n }\n\n\n\n if (err < 0) {\n\n break;\n\n }\n\n } else {\n\n qstring_append_chr(cmd_args.name, *p);\n\n }\n\n\n\n if (*p == '\\0') {\n\n break;\n\n }\n\n }\n\n\n\n QDECREF(cmd_args.name);\n\n return err;\n\n}\n", + "output": "0", + "index": 4207 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void downmix_2f_2r_to_mono(float *samples)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < 256; i++) {\n\n samples[i] += (samples[i + 256] + samples[i + 512] + samples[i + 768]);\n\n samples[i + 256] = samples[i + 512] = samples[i + 768] = 0;\n\n }\n\n}\n", + "output": "0", + "index": 26429 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int filter_packet(void *log_ctx, AVPacket *pkt,\n\n AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)\n\n{\n\n AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec;\n\n int ret;\n\n\n\n while (bsf_ctx) {\n\n AVPacket new_pkt = *pkt;\n\n ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL,\n\n &new_pkt.data, &new_pkt.size,\n\n pkt->data, pkt->size,\n\n pkt->flags & AV_PKT_FLAG_KEY);\n\n if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) {\n\n if ((ret = av_copy_packet(&new_pkt, pkt)) < 0)\n\n break;\n\n ret = 1;\n\n }\n\n\n\n if (ret > 0) {\n\n av_free_packet(pkt);\n\n new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,\n\n av_buffer_default_free, NULL, 0);\n\n if (!new_pkt.buf)\n\n break;\n\n }\n\n *pkt = new_pkt;\n\n\n\n bsf_ctx = bsf_ctx->next;\n\n }\n\n\n\n if (ret < 0) {\n\n av_log(log_ctx, AV_LOG_ERROR,\n\n \"Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\\n\",\n\n bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename,\n\n avcodec_get_name(enc_ctx->codec_id));\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 16379 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,\n\n const char *vendor_string)\n\n{\n\n bytestream_put_le32(p, strlen(vendor_string));\n\n bytestream_put_buffer(p, vendor_string, strlen(vendor_string));\n\n if (*m) {\n\n int count = av_dict_count(*m);\n\n AVDictionaryEntry *tag = NULL;\n\n bytestream_put_le32(p, count);\n\n while ((tag = av_dict_get(*m, \"\", tag, AV_DICT_IGNORE_SUFFIX))) {\n\n unsigned int len1 = strlen(tag->key);\n\n unsigned int len2 = strlen(tag->value);\n\n bytestream_put_le32(p, len1+1+len2);\n\n bytestream_put_buffer(p, tag->key, len1);\n\n bytestream_put_byte(p, '=');\n\n bytestream_put_buffer(p, tag->value, len2);\n\n }\n\n } else\n\n bytestream_put_le32(p, 0);\n\n return 0;\n\n}\n", + "output": "0", + "index": 18012 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n RMDemuxContext *rm = s->priv_data;\n\n AVStream *st;\n\n int i, len, res, seq = 1;\n\n int64_t timestamp, pos;\n\n int flags;\n\n\n\n for (;;) {\n\n if (rm->audio_pkt_cnt) {\n\n // If there are queued audio packet return them first\n\n st = s->streams[rm->audio_stream_num];\n\n ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);\n\n flags = 0;\n\n } else {\n\n if (rm->old_format) {\n\n RMStream *ast;\n\n\n\n st = s->streams[0];\n\n ast = st->priv_data;\n\n timestamp = AV_NOPTS_VALUE;\n\n len = !ast->audio_framesize ? RAW_PACKET_SIZE :\n\n ast->coded_framesize * ast->sub_packet_h / 2;\n\n flags = (seq++ == 1) ? 2 : 0;\n\n pos = avio_tell(s->pb);\n\n } else {\n\n len=sync(s, ×tamp, &flags, &i, &pos);\n\n if (len > 0)\n\n st = s->streams[i];\n\n }\n\n\n\n if(len<0 || s->pb->eof_reached)\n\n return AVERROR(EIO);\n\n\n\n res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,\n\n &seq, flags, timestamp);\n\n if((flags&2) && (seq&0x7F) == 1)\n\n av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);\n\n if (res)\n\n continue;\n\n }\n\n\n\n if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))\n\n || st->discard >= AVDISCARD_ALL){\n\n av_free_packet(pkt);\n\n } else\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 9990 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MigrationState *tcp_start_outgoing_migration(const char *host_port,\n\n\t\t\t\t\t int64_t bandwidth_limit,\n\n\t\t\t\t\t int async)\n\n{\n\n struct sockaddr_in addr;\n\n FdMigrationState *s;\n\n int ret;\n\n\n\n if (parse_host_port(&addr, host_port) < 0)\n\n return NULL;\n\n\n\n s = qemu_mallocz(sizeof(*s));\n\n if (s == NULL)\n\n return NULL;\n\n\n\n s->mig_state.cancel = tcp_cancel;\n\n s->mig_state.get_status = tcp_get_status;\n\n s->mig_state.release = tcp_release;\n\n\n\n s->state = MIG_STATE_ACTIVE;\n\n s->detach = !async;\n\n s->bandwidth_limit = bandwidth_limit;\n\n s->fd = socket(PF_INET, SOCK_STREAM, 0);\n\n if (s->fd == -1) {\n\n qemu_free(s);\n\n\treturn NULL;\n\n }\n\n\n\n fcntl(s->fd, F_SETFL, O_NONBLOCK);\n\n\n\n if (s->detach == 1) {\n\n dprintf(\"detaching from monitor\\n\");\n\n monitor_suspend();\n\n\ts->detach = 2;\n\n }\n\n\n\n do {\n\n ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));\n\n if (ret == -1)\n\n ret = -errno;\n\n\n\n if (ret == -EINPROGRESS)\n\n qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);\n\n } while (ret == -EINTR);\n\n\n\n if (ret < 0 && ret != -EINPROGRESS) {\n\n dprintf(\"connect failed\\n\");\n\n close(s->fd);\n\n qemu_free(s);\n\n\ts = NULL;\n\n } else if (ret >= 0)\n\n tcp_connect_migrate(s);\n\n\n\n return &s->mig_state;\n\n}\n", + "output": "0", + "index": 18037 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t av_gettime_relative(void)\n\n{\n\n#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)\n\n struct timespec ts;\n\n clock_gettime(CLOCK_MONOTONIC, &ts);\n\n return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;\n\n#else\n\n return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);\n\n#endif\n\n}\n", + "output": "0", + "index": 10444 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_expr_parse(AVExpr **expr, const char *s,\n\n const char * const *const_names,\n\n const char * const *func1_names, double (* const *funcs1)(void *, double),\n\n const char * const *func2_names, double (* const *funcs2)(void *, double, double),\n\n int log_offset, void *log_ctx)\n\n{\n\n Parser p = { 0 };\n\n AVExpr *e = NULL;\n\n char *w = av_malloc(strlen(s) + 1);\n\n char *wp = w;\n\n const char *s0 = s;\n\n int ret = 0;\n\n\n\n if (!w)\n\n return AVERROR(ENOMEM);\n\n\n\n while (*s)\n\n if (!av_isspace(*s++)) *wp++ = s[-1];\n\n *wp++ = 0;\n\n\n\n p.class = &eval_class;\n\n p.stack_index=100;\n\n p.s= w;\n\n p.const_names = const_names;\n\n p.funcs1 = funcs1;\n\n p.func1_names = func1_names;\n\n p.funcs2 = funcs2;\n\n p.func2_names = func2_names;\n\n p.log_offset = log_offset;\n\n p.log_ctx = log_ctx;\n\n\n\n if ((ret = parse_expr(&e, &p)) < 0)\n\n\n if (*p.s) {\n\n av_log(&p, AV_LOG_ERROR, \"Invalid chars '%s' at the end of expression '%s'\\n\", p.s, s0);\n\n ret = AVERROR(EINVAL);\n\n\n\n if (!verify_expr(e)) {\n\n ret = AVERROR(EINVAL);\n\n\n\n e->var= av_mallocz(sizeof(double) *VARS);\n\n\n\n\n\n *expr = e;\n\n e = NULL;\n\nend:\n\n av_expr_free(e);\n\n av_free(w);\n\n return ret;\n", + "output": "1", + "index": 7338 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUClockType timerlist_get_clock(QEMUTimerList *timer_list)\n\n{\n\n return timer_list->clock->type;\n\n}\n", + "output": "0", + "index": 21110 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static VncServerInfo *vnc_server_info_get(VncDisplay *vd)\n\n{\n\n VncServerInfo *info;\n\n Error *err = NULL;\n\n\n\n info = g_malloc(sizeof(*info));\n\n info->base = g_malloc(sizeof(*info->base));\n\n vnc_init_basic_info_from_server_addr(vd->lsock, info->base, &err);\n\n info->has_auth = true;\n\n info->auth = g_strdup(vnc_auth_name(vd));\n\n if (err) {\n\n qapi_free_VncServerInfo(info);\n\n info = NULL;\n\n error_free(err);\n\n }\n\n return info;\n\n}\n", + "output": "0", + "index": 14119 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_intercept(S390CPU *cpu)\n\n{\n\n CPUState *cs = CPU(cpu);\n\n struct kvm_run *run = cs->kvm_run;\n\n int icpt_code = run->s390_sieic.icptcode;\n\n int r = 0;\n\n\n\n DPRINTF(\"intercept: 0x%x (at 0x%lx)\\n\", icpt_code,\n\n (long)cs->kvm_run->psw_addr);\n\n switch (icpt_code) {\n\n case ICPT_INSTRUCTION:\n\n r = handle_instruction(cpu, run);\n\n break;\n\n case ICPT_WAITPSW:\n\n /* disabled wait, since enabled wait is handled in kernel */\n\n if (s390_del_running_cpu(cpu) == 0) {\n\n if (is_special_wait_psw(cs)) {\n\n qemu_system_shutdown_request();\n\n } else {\n\n QObject *data;\n\n\n\n data = qobject_from_jsonf(\"{ 'action': %s }\", \"pause\");\n\n monitor_protocol_event(QEVENT_GUEST_PANICKED, data);\n\n qobject_decref(data);\n\n vm_stop(RUN_STATE_GUEST_PANICKED);\n\n }\n\n }\n\n r = EXCP_HALTED;\n\n break;\n\n case ICPT_CPU_STOP:\n\n if (s390_del_running_cpu(cpu) == 0) {\n\n qemu_system_shutdown_request();\n\n }\n\n r = EXCP_HALTED;\n\n break;\n\n case ICPT_SOFT_INTERCEPT:\n\n fprintf(stderr, \"KVM unimplemented icpt SOFT\\n\");\n\n exit(1);\n\n break;\n\n case ICPT_IO:\n\n fprintf(stderr, \"KVM unimplemented icpt IO\\n\");\n\n exit(1);\n\n break;\n\n default:\n\n fprintf(stderr, \"Unknown intercept code: %d\\n\", icpt_code);\n\n exit(1);\n\n break;\n\n }\n\n\n\n return r;\n\n}\n", + "output": "1", + "index": 10165 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usbredir_interrupt_packet(void *priv, uint32_t id,\n\n struct usb_redir_interrupt_packet_header *interrupt_packet,\n\n uint8_t *data, int data_len)\n\n{\n\n USBRedirDevice *dev = priv;\n\n uint8_t ep = interrupt_packet->endpoint;\n\n\n\n DPRINTF(\"interrupt-in status %d ep %02X len %d id %u\\n\",\n\n interrupt_packet->status, ep, data_len, id);\n\n\n\n if (dev->endpoint[EP2I(ep)].type != USB_ENDPOINT_XFER_INT) {\n\n ERROR(\"received int packet for non interrupt endpoint %02X\\n\", ep);\n\n free(data);\n\n return;\n\n }\n\n\n\n if (ep & USB_DIR_IN) {\n\n if (dev->endpoint[EP2I(ep)].interrupt_started == 0) {\n\n DPRINTF(\"received int packet while not started ep %02X\\n\", ep);\n\n free(data);\n\n return;\n\n }\n\n\n\n /* bufp_alloc also adds the packet to the ep queue */\n\n bufp_alloc(dev, data, data_len, interrupt_packet->status, ep);\n\n } else {\n\n int len = interrupt_packet->length;\n\n\n\n AsyncURB *aurb = async_find(dev, id);\n\n if (!aurb) {\n\n return;\n\n }\n\n\n\n if (aurb->interrupt_packet.endpoint != interrupt_packet->endpoint) {\n\n ERROR(\"return int packet mismatch, please report this!\\n\");\n\n len = USB_RET_NAK;\n\n }\n\n\n\n if (aurb->packet) {\n\n aurb->packet->result = usbredir_handle_status(dev,\n\n interrupt_packet->status, len);\n\n usb_packet_complete(&dev->dev, aurb->packet);\n\n }\n\n async_free(dev, aurb);\n\n }\n\n}\n", + "output": "0", + "index": 11949 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_bpcc(TCGContext *s, int scond, int flags, int label)\n\n{\n\n TCGLabel *l = &s->labels[label];\n\n int off19;\n\n\n\n if (l->has_value) {\n\n off19 = INSN_OFF19(tcg_pcrel_diff(s, l->u.value_ptr));\n\n } else {\n\n /* Make sure to preserve destinations during retranslation. */\n\n off19 = *s->code_ptr & INSN_OFF19(-1);\n\n tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP19, label, 0);\n\n }\n\n tcg_out_bpcc0(s, scond, flags, off19);\n\n}\n", + "output": "0", + "index": 23005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h)\n\n{\n\n ptr[0] = ((x & 0x0F) << 4) | (y & 0x0F);\n\n ptr[1] = (((w - 1) & 0x0F) << 4) | ((h - 1) & 0x0F);\n\n}\n", + "output": "0", + "index": 24943 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_sysenter(CPUX86State *env)\n\n{\n\n if (env->sysenter_cs == 0) {\n\n raise_exception_err(env, EXCP0D_GPF, 0);\n\n }\n\n env->eflags &= ~(VM_MASK | IF_MASK | RF_MASK);\n\n cpu_x86_set_cpl(env, 0);\n\n\n\n#ifdef TARGET_X86_64\n\n if (env->hflags & HF_LMA_MASK) {\n\n cpu_x86_load_seg_cache(env, R_CS, env->sysenter_cs & 0xfffc,\n\n 0, 0xffffffff,\n\n DESC_G_MASK | DESC_B_MASK | DESC_P_MASK |\n\n DESC_S_MASK |\n\n DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK |\n\n DESC_L_MASK);\n\n } else\n\n#endif\n\n {\n\n cpu_x86_load_seg_cache(env, R_CS, env->sysenter_cs & 0xfffc,\n\n 0, 0xffffffff,\n\n DESC_G_MASK | DESC_B_MASK | DESC_P_MASK |\n\n DESC_S_MASK |\n\n DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK);\n\n }\n\n cpu_x86_load_seg_cache(env, R_SS, (env->sysenter_cs + 8) & 0xfffc,\n\n 0, 0xffffffff,\n\n DESC_G_MASK | DESC_B_MASK | DESC_P_MASK |\n\n DESC_S_MASK |\n\n DESC_W_MASK | DESC_A_MASK);\n\n env->regs[R_ESP] = env->sysenter_esp;\n\n env->eip = env->sysenter_eip;\n\n}\n", + "output": "0", + "index": 20740 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_read_command(Monitor *mon, int show_prompt)\n\n{\n\n if (!mon->rs)\n\n return;\n\n\n\n readline_start(mon->rs, \"(qemu) \", 0, monitor_command_cb, NULL);\n\n if (show_prompt)\n\n readline_show_prompt(mon->rs);\n\n}\n", + "output": "0", + "index": 6037 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int small_diamond_search4MV(MpegEncContext * s, int *best, int dmin,\n\n UINT8 *new_pic, UINT8 *old_pic, int pic_stride,\n\n int pred_x, int pred_y, UINT16 *mv_penalty, int quant,\n\n int xmin, int ymin, int xmax, int ymax, int shift)\n\n{\n\n int next_dir=-1;\n\n\n\n for(;;){\n\n int d;\n\n const int dir= next_dir;\n\n const int x= best[0];\n\n const int y= best[1];\n\n next_dir=-1;\n\n\n\n//printf(\"%d\", dir);\n\n if(dir!=2 && x>xmin) CHECK_MV4_DIR(x-1, y , 0)\n\n if(dir!=3 && y>ymin) CHECK_MV4_DIR(x , y-1, 1)\n\n if(dir!=0 && xpriv_data;\n\n ByteIOContext *pb = &s->pb;\n\n int packet_read = 0;\n\n unsigned int size;\n\n int magic;\n\n int ret = 0;\n\n unsigned char preamble[FLIC_PREAMBLE_SIZE];\n\n\n\n while (!packet_read) {\n\n\n\n if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) !=\n\n FLIC_PREAMBLE_SIZE) {\n\n ret = AVERROR_IO;\n\n break;\n\n }\n\n\n\n size = LE_32(&preamble[0]);\n\n magic = LE_16(&preamble[4]);\n\n\n\n if ((magic == FLIC_CHUNK_MAGIC_1) || (magic == FLIC_CHUNK_MAGIC_2)) {\n\n if (av_new_packet(pkt, size)) {\n\n ret = AVERROR_IO;\n\n break;\n\n }\n\n pkt->stream_index = flic->video_stream_index;\n\n pkt->pts = flic->pts;\n\n memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);\n\n ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE, \n\n size - FLIC_PREAMBLE_SIZE);\n\n if (ret != size - FLIC_PREAMBLE_SIZE) {\n\n av_free_packet(pkt);\n\n ret = AVERROR_IO;\n\n }\n\n flic->pts += flic->frame_pts_inc;\n\n packet_read = 1;\n\n } else {\n\n /* not interested in this chunk */\n\n url_fseek(pb, size - 6, SEEK_CUR);\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 24223 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,\n\n void *opaque, Error **errp)\n\n{\n\n Error *err = NULL;\n\n VirtIOBalloon *s = opaque;\n\n int i;\n\n\n\n visit_start_struct(v, name, NULL, 0, &err);\n\n if (err) {\n\n goto out;\n\n }\n\n visit_type_int(v, \"last-update\", &s->stats_last_update, &err);\n\n if (err) {\n\n goto out_end;\n\n }\n\n\n\n visit_start_struct(v, \"stats\", NULL, 0, &err);\n\n if (err) {\n\n goto out_end;\n\n }\n\n for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {\n\n visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err);\n\n if (err) {\n\n break;\n\n }\n\n }\n\n error_propagate(errp, err);\n\n err = NULL;\n\n visit_end_struct(v, &err);\n\n\n\nout_end:\n\n error_propagate(errp, err);\n\n err = NULL;\n\n visit_end_struct(v, &err);\n\nout:\n\n error_propagate(errp, err);\n\n}\n", + "output": "1", + "index": 25158 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_eval_bgu(TCGv dst, TCGv_i32 src)\n\n{\n\n gen_mov_reg_Z(cpu_tmp0, src);\n\n gen_mov_reg_C(dst, src);\n\n tcg_gen_or_tl(dst, dst, cpu_tmp0);\n\n tcg_gen_xori_tl(dst, dst, 0x1);\n\n}\n", + "output": "0", + "index": 20436 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_pulses(Pulse *pulse, GetBitContext *gb,\n\n const uint16_t *swb_offset, int num_swb)\n\n{\n\n int i, pulse_swb;\n\n pulse->num_pulse = get_bits(gb, 2) + 1;\n\n pulse_swb = get_bits(gb, 6);\n\n if (pulse_swb >= num_swb)\n\n return -1;\n\n pulse->pos[0] = swb_offset[pulse_swb];\n\n pulse->pos[0] += get_bits(gb, 5);\n\n if (pulse->pos[0] > 1023)\n\n return -1;\n\n pulse->amp[0] = get_bits(gb, 4);\n\n for (i = 1; i < pulse->num_pulse; i++) {\n\n pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];\n\n if (pulse->pos[i] > 1023)\n\n return -1;\n\n pulse->amp[i] = get_bits(gb, 4);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 19653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n AlphaMergeContext *merge = ctx->priv;\n\n\n\n int is_alpha = (inlink == ctx->inputs[1]);\n\n struct FFBufQueue *queue =\n\n (is_alpha ? &merge->queue_alpha : &merge->queue_main);\n\n ff_bufqueue_add(ctx, queue, buf);\n\n\n\n while (1) {\n\n AVFilterBufferRef *main_buf, *alpha_buf;\n\n\n\n if (!ff_bufqueue_peek(&merge->queue_main, 0) ||\n\n !ff_bufqueue_peek(&merge->queue_alpha, 0)) break;\n\n\n\n main_buf = ff_bufqueue_get(&merge->queue_main);\n\n alpha_buf = ff_bufqueue_get(&merge->queue_alpha);\n\n\n\n merge->frame_requested = 0;\n\n draw_frame(ctx, main_buf, alpha_buf);\n\n ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0));\n\n avfilter_unref_buffer(alpha_buf);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 6172 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gus_realizefn (DeviceState *dev, Error **errp)\n\n{\n\n ISADevice *d = ISA_DEVICE(dev);\n\n GUSState *s = GUS (dev);\n\n IsaDmaClass *k;\n\n struct audsettings as;\n\n\n\n AUD_register_card (\"gus\", &s->card);\n\n\n\n as.freq = s->freq;\n\n as.nchannels = 2;\n\n as.fmt = AUD_FMT_S16;\n\n as.endianness = GUS_ENDIANNESS;\n\n\n\n s->voice = AUD_open_out (\n\n &s->card,\n\n NULL,\n\n \"gus\",\n\n s,\n\n GUS_callback,\n\n &as\n\n );\n\n\n\n if (!s->voice) {\n\n AUD_remove_card (&s->card);\n\n error_setg(errp, \"No voice\");\n\n return;\n\n }\n\n\n\n s->shift = 2;\n\n s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift;\n\n s->mixbuf = g_malloc0 (s->samples << s->shift);\n\n\n\n isa_register_portio_list (d, s->port, gus_portio_list1, s, \"gus\");\n\n isa_register_portio_list (d, (s->port + 0x100) & 0xf00,\n\n gus_portio_list2, s, \"gus\");\n\n\n\n s->isa_dma = isa_get_dma(isa_bus_from_device(d), s->emu.gusdma);\n\n k = ISADMA_GET_CLASS(s->isa_dma);\n\n k->register_channel(s->isa_dma, s->emu.gusdma, GUS_read_DMA, s);\n\n s->emu.himemaddr = s->himem;\n\n s->emu.gusdatapos = s->emu.himemaddr + 1024 * 1024 + 32;\n\n s->emu.opaque = s;\n\n isa_init_irq (d, &s->pic, s->emu.gusirq);\n\n\n\n AUD_set_active_out (s->voice, 1);\n\n}\n", + "output": "1", + "index": 6461 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t ecc_mem_readl(void *opaque, target_phys_addr_t addr)\n\n{\n\n ECCState *s = opaque;\n\n uint32_t ret = 0;\n\n\n\n switch (addr & ECC_ADDR_MASK) {\n\n case ECC_MER:\n\n ret = s->regs[0];\n\n DPRINTF(\"Read memory enable %08x\\n\", ret);\n\n break;\n\n case ECC_MDR:\n\n ret = s->regs[1];\n\n DPRINTF(\"Read memory delay %08x\\n\", ret);\n\n break;\n\n case ECC_MFSR:\n\n ret = s->regs[2];\n\n DPRINTF(\"Read memory fault status %08x\\n\", ret);\n\n break;\n\n case ECC_VCR:\n\n ret = s->regs[3];\n\n DPRINTF(\"Read slot configuration %08x\\n\", ret);\n\n break;\n\n case ECC_MFAR0:\n\n ret = s->regs[4];\n\n DPRINTF(\"Read memory fault address 0 %08x\\n\", ret);\n\n break;\n\n case ECC_MFAR1:\n\n ret = s->regs[5];\n\n DPRINTF(\"Read memory fault address 1 %08x\\n\", ret);\n\n break;\n\n case ECC_DR:\n\n ret = s->regs[6];\n\n DPRINTF(\"Read diagnostic %08x\\n\", ret);\n\n break;\n\n case ECC_ECR0:\n\n ret = s->regs[7];\n\n DPRINTF(\"Read event count 1 %08x\\n\", ret);\n\n break;\n\n case ECC_ECR1:\n\n ret = s->regs[7];\n\n DPRINTF(\"Read event count 2 %08x\\n\", ret);\n\n break;\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 92 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockBackend *img_open_opts(const char *optstr,\n\n QemuOpts *opts, int flags, bool writethrough,\n\n bool quiet, bool force_share)\n\n{\n\n QDict *options;\n\n Error *local_err = NULL;\n\n BlockBackend *blk;\n\n options = qemu_opts_to_qdict(opts, NULL);\n\n if (force_share) {\n\n if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE)\n\n && !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) {\n\n error_report(\"--force-share/-U conflicts with image options\");\n\n\n return NULL;\n\n }\n\n qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));\n\n }\n\n blk = blk_new_open(NULL, NULL, options, flags, &local_err);\n\n if (!blk) {\n\n error_reportf_err(local_err, \"Could not open '%s': \", optstr);\n\n return NULL;\n\n }\n\n blk_set_enable_write_cache(blk, !writethrough);\n\n\n\n if (img_open_password(blk, optstr, flags, quiet) < 0) {\n\n blk_unref(blk);\n\n return NULL;\n\n }\n\n return blk;\n\n}", + "output": "1", + "index": 9013 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ds1225y_set_to_mode(ds1225y_t *NVRAM, nvram_open_mode mode, const char *filemode)\r\n\n{\r\n\n if (NVRAM->open_mode != mode)\r\n\n {\r\n\n if (NVRAM->file)\r\n\n qemu_fclose(NVRAM->file);\r\n\n NVRAM->file = qemu_fopen(NVRAM->filename, filemode);\r\n\n NVRAM->open_mode = mode;\r\n\n }\r\n\n return (NVRAM->file != NULL);\r\n\n}\r\n", + "output": "1", + "index": 13792 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void co_run_in_worker_bh(void *opaque)\n\n{\n\n Coroutine *co = opaque;\n\n thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),\n\n coroutine_enter_func, co, coroutine_enter_cb, co);\n\n}\n", + "output": "0", + "index": 26798 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void gdb_exit(CPUState *env, int code)\n\n{\n\n GDBState *s;\n\n char buf[4];\n\n\n\n s = &gdbserver_state;\n\n if (gdbserver_fd < 0 || s->fd < 0)\n\n return;\n\n\n\n snprintf(buf, sizeof(buf), \"W%02x\", code);\n\n put_packet(s, buf);\n\n}\n", + "output": "0", + "index": 909 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_pc_test_case(const char *mname)\n\n{\n\n char *path;\n\n PlugTestData *data;\n\n\n\n if (!g_str_has_prefix(mname, \"pc-\")) {\n\n return;\n\n }\n\n data = g_new(PlugTestData, 1);\n\n data->machine = g_strdup(mname);\n\n data->cpu_model = \"Haswell\"; /* 1.3+ theoretically */\n\n data->sockets = 1;\n\n data->cores = 3;\n\n data->threads = 2;\n\n data->maxcpus = data->sockets * data->cores * data->threads * 2;\n\n if (g_str_has_suffix(mname, \"-1.4\") ||\n\n (strcmp(mname, \"pc-1.3\") == 0) ||\n\n (strcmp(mname, \"pc-1.2\") == 0) ||\n\n (strcmp(mname, \"pc-1.1\") == 0) ||\n\n (strcmp(mname, \"pc-1.0\") == 0) ||\n\n (strcmp(mname, \"pc-0.15\") == 0) ||\n\n (strcmp(mname, \"pc-0.14\") == 0) ||\n\n (strcmp(mname, \"pc-0.13\") == 0) ||\n\n (strcmp(mname, \"pc-0.12\") == 0) ||\n\n (strcmp(mname, \"pc-0.11\") == 0) ||\n\n (strcmp(mname, \"pc-0.10\") == 0)) {\n\n path = g_strdup_printf(\"cpu/%s/init/%ux%ux%u&maxcpus=%u\",\n\n mname, data->sockets, data->cores,\n\n data->threads, data->maxcpus);\n\n qtest_add_data_func_full(path, data, test_plug_without_cpu_add,\n\n test_data_free);\n\n g_free(path);\n\n } else {\n\n path = g_strdup_printf(\"cpu/%s/add/%ux%ux%u&maxcpus=%u\",\n\n mname, data->sockets, data->cores,\n\n data->threads, data->maxcpus);\n\n qtest_add_data_func_full(path, data, test_plug_with_cpu_add,\n\n test_data_free);\n\n g_free(path);\n\n }\n\n}\n", + "output": "0", + "index": 20796 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int net_init_slirp(const Netdev *netdev, const char *name,\n\n NetClientState *peer, Error **errp)\n\n{\n\n /* FIXME error_setg(errp, ...) on failure */\n\n struct slirp_config_str *config;\n\n char *vnet;\n\n int ret;\n\n const NetdevUserOptions *user;\n\n const char **dnssearch;\n\n bool ipv4 = true, ipv6 = true;\n\n\n\n assert(netdev->type == NET_CLIENT_DRIVER_USER);\n\n user = &netdev->u.user;\n\n\n\n if ((user->has_ipv6 && user->ipv6 && !user->has_ipv4) ||\n\n (user->has_ipv4 && !user->ipv4)) {\n\n ipv4 = 0;\n\n }\n\n if ((user->has_ipv4 && user->ipv4 && !user->has_ipv6) ||\n\n (user->has_ipv6 && !user->ipv6)) {\n\n ipv6 = 0;\n\n }\n\n\n\n vnet = user->has_net ? g_strdup(user->net) :\n\n user->has_ip ? g_strdup_printf(\"%s/24\", user->ip) :\n\n NULL;\n\n\n\n dnssearch = slirp_dnssearch(user->dnssearch);\n\n\n\n /* all optional fields are initialized to \"all bits zero\" */\n\n\n\n net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD);\n\n net_init_slirp_configs(user->guestfwd, 0);\n\n\n\n ret = net_slirp_init(peer, \"user\", name, user->q_restrict,\n\n ipv4, vnet, user->host,\n\n ipv6, user->ipv6_prefix, user->ipv6_prefixlen,\n\n user->ipv6_host, user->hostname, user->tftp,\n\n user->bootfile, user->dhcpstart,\n\n user->dns, user->ipv6_dns, user->smb,\n\n user->smbserver, dnssearch);\n\n\n\n while (slirp_configs) {\n\n config = slirp_configs;\n\n slirp_configs = config->next;\n\n g_free(config);\n\n }\n\n\n\n g_free(vnet);\n\n g_free(dnssearch);\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 19248 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(single_quote_string)\n\n{\n\n int i;\n\n struct {\n\n const char *encoded;\n\n const char *decoded;\n\n } test_cases[] = {\n\n { \"'hello world'\", \"hello world\" },\n\n { \"'the quick brown fox \\\\' jumped over the fence'\",\n\n \"the quick brown fox ' jumped over the fence\" },\n\n {}\n\n };\n\n\n\n for (i = 0; test_cases[i].encoded; i++) {\n\n QObject *obj;\n\n QString *str;\n\n\n\n obj = qobject_from_json(test_cases[i].encoded);\n\n\n\n fail_unless(obj != NULL);\n\n fail_unless(qobject_type(obj) == QTYPE_QSTRING);\n\n \n\n str = qobject_to_qstring(obj);\n\n fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);\n\n\n\n QDECREF(str);\n\n }\n\n}\n", + "output": "0", + "index": 25520 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t HELPER(diag)(CPUS390XState *env, uint32_t num, uint64_t mem,\n\n uint64_t code)\n\n{\n\n uint64_t r;\n\n\n\n switch (num) {\n\n case 0x500:\n\n /* KVM hypercall */\n\n r = s390_virtio_hypercall(env);\n\n break;\n\n case 0x44:\n\n /* yield */\n\n r = 0;\n\n break;\n\n case 0x308:\n\n /* ipl */\n\n r = 0;\n\n break;\n\n default:\n\n r = -1;\n\n break;\n\n }\n\n\n\n if (r) {\n\n program_interrupt(env, PGM_OPERATION, ILEN_LATER_INC);\n\n }\n\n\n\n return r;\n\n}\n", + "output": "0", + "index": 1228 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_win_path(const char *filename,\n\n Error **errp)\n\n{\n\n CharDriverState *chr;\n\n WinCharState *s;\n\n\n\n chr = qemu_chr_alloc();\n\n s = g_new0(WinCharState, 1);\n\n chr->opaque = s;\n\n chr->chr_write = win_chr_write;\n\n chr->chr_close = win_chr_close;\n\n\n\n if (win_chr_init(chr, filename, errp) < 0) {\n\n g_free(s);\n\n g_free(chr);\n\n return NULL;\n\n }\n\n return chr;\n\n}\n", + "output": "0", + "index": 5812 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_arch_init_vcpu(CPUState *cenv)\n\n{\n\n int ret = 0;\n\n struct kvm_sregs sregs;\n\n\n\n sregs.pvr = cenv->spr[SPR_PVR];\n\n ret = kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);\n\n\n\n idle_timer = qemu_new_timer_ns(vm_clock, kvm_kick_env, cenv);\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 20644 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_sllq(DisasContext *ctx)\n\n{\n\n int l1 = gen_new_label();\n\n int l2 = gen_new_label();\n\n TCGv t0 = tcg_temp_local_new();\n\n TCGv t1 = tcg_temp_local_new();\n\n TCGv t2 = tcg_temp_local_new();\n\n tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);\n\n tcg_gen_movi_tl(t1, 0xFFFFFFFF);\n\n tcg_gen_shl_tl(t1, t1, t2);\n\n tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);\n\n gen_load_spr(t0, SPR_MQ);\n\n tcg_gen_and_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);\n\n tcg_gen_br(l2);\n\n gen_set_label(l1);\n\n tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);\n\n gen_load_spr(t2, SPR_MQ);\n\n tcg_gen_andc_tl(t1, t2, t1);\n\n tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);\n\n gen_set_label(l2);\n\n tcg_temp_free(t0);\n\n tcg_temp_free(t1);\n\n tcg_temp_free(t2);\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);\n\n}\n", + "output": "0", + "index": 2821 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_out_empty(TestOutputVisitorData *data,\n\n const void *unused)\n\n{\n\n QObject *arg;\n\n\n\n arg = qmp_output_get_qobject(data->qov);\n\n g_assert(qobject_type(arg) == QTYPE_QNULL);\n\n /* Check that qnull reference counting is sane */\n\n g_assert(arg->refcnt == 2);\n\n qobject_decref(arg);\n\n}\n", + "output": "0", + "index": 17968 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void host_signal_handler(int host_signum, siginfo_t *info,\n\n void *puc)\n\n{\n\n CPUArchState *env = thread_cpu->env_ptr;\n\n CPUState *cpu = ENV_GET_CPU(env);\n\n TaskState *ts = cpu->opaque;\n\n\n\n int sig;\n\n target_siginfo_t tinfo;\n\n ucontext_t *uc = puc;\n\n struct emulated_sigtable *k;\n\n\n\n /* the CPU emulator uses some host signals to detect exceptions,\n\n we forward to it some signals */\n\n if ((host_signum == SIGSEGV || host_signum == SIGBUS)\n\n && info->si_code > 0) {\n\n if (cpu_signal_handler(host_signum, info, puc))\n\n return;\n\n }\n\n\n\n /* get target signal number */\n\n sig = host_to_target_signal(host_signum);\n\n if (sig < 1 || sig > TARGET_NSIG)\n\n return;\n\n trace_user_host_signal(env, host_signum, sig);\n\n\n\n rewind_if_in_safe_syscall(puc);\n\n\n\n host_to_target_siginfo_noswap(&tinfo, info);\n\n k = &ts->sigtab[sig - 1];\n\n k->info = tinfo;\n\n k->pending = sig;\n\n ts->signal_pending = 1;\n\n\n\n /* Block host signals until target signal handler entered. We\n\n * can't block SIGSEGV or SIGBUS while we're executing guest\n\n * code in case the guest code provokes one in the window between\n\n * now and it getting out to the main loop. Signals will be\n\n * unblocked again in process_pending_signals().\n\n */\n\n sigfillset(&uc->uc_sigmask);\n\n sigdelset(&uc->uc_sigmask, SIGSEGV);\n\n sigdelset(&uc->uc_sigmask, SIGBUS);\n\n\n\n /* interrupt the virtual CPU as soon as possible */\n\n cpu_exit(thread_cpu);\n\n}\n", + "output": "1", + "index": 9881 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong h_set_mode_resouce_addr_trans_mode(PowerPCCPU *cpu,\n\n target_ulong mflags,\n\n target_ulong value1,\n\n target_ulong value2)\n\n{\n\n CPUState *cs;\n\n PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);\n\n target_ulong prefix;\n\n\n\n if (!(pcc->insns_flags2 & PPC2_ISA207S)) {\n\n return H_P2;\n\n }\n\n if (value1) {\n\n return H_P3;\n\n }\n\n if (value2) {\n\n return H_P4;\n\n }\n\n\n\n switch (mflags) {\n\n case H_SET_MODE_ADDR_TRANS_NONE:\n\n prefix = 0;\n\n break;\n\n case H_SET_MODE_ADDR_TRANS_0001_8000:\n\n prefix = 0x18000;\n\n break;\n\n case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000:\n\n prefix = 0xC000000000004000;\n\n break;\n\n default:\n\n return H_UNSUPPORTED_FLAG;\n\n }\n\n\n\n CPU_FOREACH(cs) {\n\n CPUPPCState *env = &POWERPC_CPU(cpu)->env;\n\n\n\n set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SHIFT, LPCR_AIL);\n\n env->excp_prefix = prefix;\n\n }\n\n\n\n return H_SUCCESS;\n\n}\n", + "output": "0", + "index": 6739 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void openrisc_cpu_do_interrupt(CPUState *cs)\n\n{\n\n#ifndef CONFIG_USER_ONLY\n\n OpenRISCCPU *cpu = OPENRISC_CPU(cs);\n\n CPUOpenRISCState *env = &cpu->env;\n\n\n\n env->epcr = env->pc;\n\n if (env->flags & D_FLAG) {\n\n env->flags &= ~D_FLAG;\n\n env->sr |= SR_DSX;\n\n env->epcr -= 4;\n\n\n\n\n if (cs->exception_index == EXCP_SYSCALL) {\n\n env->epcr += 4;\n\n\n\n\n\n\n\n\n\n /* For machine-state changed between user-mode and supervisor mode,\n\n we need flush TLB when we enter&exit EXCP. */\n\n tlb_flush(cs);\n\n\n\n env->esr = env->sr;\n\n env->sr &= ~SR_DME;\n\n env->sr &= ~SR_IME;\n\n env->sr |= SR_SM;\n\n env->sr &= ~SR_IEE;\n\n env->sr &= ~SR_TEE;\n\n env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu;\n\n env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu;\n\n\n\n if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) {\n\n env->pc = (cs->exception_index << 8);\n\n\n cpu_abort(cs, \"Unhandled exception 0x%x\\n\", cs->exception_index);\n\n\n#endif\n\n\n\n cs->exception_index = -1;\n", + "output": "1", + "index": 19397 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline bool extended_addresses_enabled(CPUARMState *env)\n\n{\n\n return arm_feature(env, ARM_FEATURE_LPAE)\n\n && (env->cp15.c2_control & (1 << 31));\n\n}\n", + "output": "1", + "index": 12522 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void conv_to_int32(int32_t *loc, float *samples, int num, float norm)\n\n{\n\n int i;\n\n for (i = 0; i < num; i++)\n\n loc[i] = ceilf((samples[i]/norm)*INT32_MAX);\n\n}\n", + "output": "0", + "index": 4836 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t m5206_mbar_readl(void *opaque, target_phys_addr_t offset)\n\n{\n\n m5206_mbar_state *s = (m5206_mbar_state *)opaque;\n\n int width;\n\n offset &= 0x3ff;\n\n if (offset >= 0x200) {\n\n hw_error(\"Bad MBAR read offset 0x%x\", (int)offset);\n\n }\n\n width = m5206_mbar_width[offset >> 2];\n\n if (width < 4) {\n\n uint32_t val;\n\n val = m5206_mbar_readw(opaque, offset) << 16;\n\n val |= m5206_mbar_readw(opaque, offset + 2);\n\n return val;\n\n }\n\n return m5206_mbar_read(s, offset, 4);\n\n}\n", + "output": "0", + "index": 7819 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openrisc_sim_net_init(MemoryRegion *address_space,\n\n hwaddr base,\n\n hwaddr descriptors,\n\n qemu_irq irq, NICInfo *nd)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n\n\n dev = qdev_create(NULL, \"open_eth\");\n\n qdev_set_nic_properties(dev, nd);\n\n qdev_init_nofail(dev);\n\n\n\n s = SYS_BUS_DEVICE(dev);\n\n sysbus_connect_irq(s, 0, irq);\n\n memory_region_add_subregion(address_space, base,\n\n sysbus_mmio_get_region(s, 0));\n\n memory_region_add_subregion(address_space, descriptors,\n\n sysbus_mmio_get_region(s, 1));\n\n}\n", + "output": "0", + "index": 10926 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_mfra(MOVContext *c, AVIOContext *f)\n\n{\n\n int64_t stream_size = avio_size(f);\n\n int64_t original_pos = avio_tell(f);\n\n int64_t seek_ret;\n\n int32_t mfra_size;\n\n int ret = -1;\n\n if ((seek_ret = avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {\n\n ret = seek_ret;\n\n goto fail;\n\n }\n\n mfra_size = avio_rb32(f);\n\n if (mfra_size < 0 || mfra_size > stream_size) {\n\n av_log(c->fc, AV_LOG_DEBUG, \"doesn't look like mfra (unreasonable size)\\n\");\n\n goto fail;\n\n }\n\n if ((seek_ret = avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {\n\n ret = seek_ret;\n\n goto fail;\n\n }\n\n if (avio_rb32(f) != mfra_size) {\n\n av_log(c->fc, AV_LOG_DEBUG, \"doesn't look like mfra (size mismatch)\\n\");\n\n goto fail;\n\n }\n\n if (avio_rb32(f) != MKBETAG('m', 'f', 'r', 'a')) {\n\n av_log(c->fc, AV_LOG_DEBUG, \"doesn't look like mfra (tag mismatch)\\n\");\n\n goto fail;\n\n }\n\n ret = 0;\n\n av_log(c->fc, AV_LOG_VERBOSE, \"stream has mfra\\n\");\n\n while (!read_tfra(c, f)) {\n\n /* Empty */\n\n }\n\nfail:\n\n seek_ret = avio_seek(f, original_pos, SEEK_SET);\n\n if (seek_ret < 0) {\n\n av_log(c->fc, AV_LOG_ERROR,\n\n \"failed to seek back after looking for mfra\\n\");\n\n ret = seek_ret;\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 18429 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_disk_initfn(SCSIDevice *dev)\n{\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);\n int is_cd;\n DriveInfo *dinfo;\n if (!s->qdev.conf.bs) {\n error_report(\"scsi-disk: drive property not set\");\n s->bs = s->qdev.conf.bs;\n is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;\n if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {\n error_report(\"Device doesn't support drive option rerror\");\n if (!s->serial) {\n /* try to fall back to value set with legacy -drive serial=... */\n dinfo = drive_get_by_blockdev(s->bs);\n s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : \"0\");\n if (!s->version) {\n s->version = qemu_strdup(QEMU_VERSION);\n if (bdrv_is_sg(s->bs)) {\n error_report(\"scsi-disk: unwanted /dev/sg*\");\n if (is_cd) {\n s->qdev.blocksize = 2048;\n } else {\n s->qdev.blocksize = s->qdev.conf.logical_block_size;\n s->cluster_size = s->qdev.blocksize / 512;\n s->qdev.type = TYPE_DISK;\n qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);\n bdrv_set_removable(s->bs, is_cd);\n return 0;", + "output": "1", + "index": 1795 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque)\n\n{\n\n BdrvCoGetBlockStatusData *data = opaque;\n\n\n\n data->ret = bdrv_co_get_block_status_above(data->bs, data->base,\n\n data->sector_num,\n\n data->nb_sectors,\n\n data->pnum);\n\n data->done = true;\n\n}\n", + "output": "0", + "index": 12714 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path,\n\n const struct timespec *buf)\n\n{\n\n int fd, ret;\n\n struct handle_data *data = (struct handle_data *)ctx->private;\n\n\n\n fd = open_by_handle(data->mountfd, fs_path->data, O_NONBLOCK);\n\n if (fd < 0) {\n\n return fd;\n\n }\n\n ret = futimens(fd, buf);\n\n close(fd);\n\n return ret;\n\n}\n", + "output": "0", + "index": 23407 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ecc_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)\n\n{\n\n ECCState *s = opaque;\n\n\n\n switch (addr & ECC_ADDR_MASK) {\n\n case ECC_MER:\n\n s->regs[0] = (s->regs[0] & (ECC_MER_VER | ECC_MER_IMPL)) |\n\n (val & ~(ECC_MER_VER | ECC_MER_IMPL));\n\n DPRINTF(\"Write memory enable %08x\\n\", val);\n\n break;\n\n case ECC_MDR:\n\n s->regs[1] = val & ECC_MDR_MASK;\n\n DPRINTF(\"Write memory delay %08x\\n\", val);\n\n break;\n\n case ECC_MFSR:\n\n s->regs[2] = val;\n\n DPRINTF(\"Write memory fault status %08x\\n\", val);\n\n break;\n\n case ECC_VCR:\n\n s->regs[3] = val;\n\n DPRINTF(\"Write slot configuration %08x\\n\", val);\n\n break;\n\n case ECC_DR:\n\n s->regs[6] = val;\n\n DPRINTF(\"Write diagnosiic %08x\\n\", val);\n\n break;\n\n case ECC_ECR0:\n\n s->regs[7] = val;\n\n DPRINTF(\"Write event count 1 %08x\\n\", val);\n\n break;\n\n case ECC_ECR1:\n\n s->regs[7] = val;\n\n DPRINTF(\"Write event count 2 %08x\\n\", val);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 8589 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cg3_initfn(Object *obj)\n\n{\n\n SysBusDevice *sbd = SYS_BUS_DEVICE(obj);\n\n CG3State *s = CG3(obj);\n\n\n\n memory_region_init_ram(&s->rom, NULL, \"cg3.prom\", FCODE_MAX_ROM_SIZE,\n\n &error_abort);\n\n memory_region_set_readonly(&s->rom, true);\n\n sysbus_init_mmio(sbd, &s->rom);\n\n\n\n memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, \"cg3.reg\",\n\n CG3_REG_SIZE);\n\n sysbus_init_mmio(sbd, &s->reg);\n\n}\n", + "output": "1", + "index": 154 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "writev_f(int argc, char **argv)\n\n{\n\n\tstruct timeval t1, t2;\n\n\tint Cflag = 0, qflag = 0;\n\n\tint c, cnt;\n\n\tchar *buf;\n\n\tint64_t offset;\n\n\tint total;\n\n\tint nr_iov;\n\n\tint pattern = 0xcd;\n\n\tQEMUIOVector qiov;\n\n\n\n\twhile ((c = getopt(argc, argv, \"CqP:\")) != EOF) {\n\n\t\tswitch (c) {\n\n\t\tcase 'C':\n\n\t\t\tCflag = 1;\n\n\t\t\tbreak;\n\n\t\tcase 'q':\n\n\t\t\tqflag = 1;\n\n\t\t\tbreak;\n\n\t\tcase 'P':\n\n\t\t\tpattern = atoi(optarg);\n\n\t\t\tbreak;\n\n\t\tdefault:\n\n\t\t\treturn command_usage(&writev_cmd);\n\n\t\t}\n\n\t}\n\n\n\n\tif (optind > argc - 2)\n\n\t\treturn command_usage(&writev_cmd);\n\n\n\n\toffset = cvtnum(argv[optind]);\n\n\tif (offset < 0) {\n\n\t\tprintf(\"non-numeric length argument -- %s\\n\", argv[optind]);\n\n\t\treturn 0;\n\n\t}\n\n\toptind++;\n\n\n\n\tif (offset & 0x1ff) {\n\n\t\tprintf(\"offset %lld is not sector aligned\\n\",\n\n\t\t\t(long long)offset);\n\n\t\treturn 0;\n\n\t}\n\n\n\n\tnr_iov = argc - optind;\n\n\tbuf = create_iovec(&qiov, &argv[optind], nr_iov, pattern);\n\n\n\n\tgettimeofday(&t1, NULL);\n\n\tcnt = do_aio_writev(&qiov, offset, &total);\n\n\tgettimeofday(&t2, NULL);\n\n\n\n\tif (cnt < 0) {\n\n\t\tprintf(\"writev failed: %s\\n\", strerror(-cnt));\n\n\t\treturn 0;\n\n\t}\n\n\n\n\tif (qflag)\n\n\t\treturn 0;\n\n\n\n\t/* Finally, report back -- -C gives a parsable format */\n\n\tt2 = tsub(t2, t1);\n\n\tprint_report(\"wrote\", &t2, offset, qiov.size, total, cnt, Cflag);\n\n\n\n\tqemu_io_free(buf);\n\n\n\n\treturn 0;\n\n}\n", + "output": "1", + "index": 4357 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC,\n\n int xBase, int yBase, int log2_cb_size)\n\n{\n\n int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size);\n\n\n\n if (s->HEVClc->tu.cu_qp_delta != 0) {\n\n int off = s->sps->qp_bd_offset;\n\n s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) %\n\n (52 + off)) - off;\n\n } else\n\n s->HEVClc->qp_y = qp_y;\n\n}\n", + "output": "1", + "index": 717 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void setup_sigframe_v2(struct target_ucontext_v2 *uc,\n\n target_sigset_t *set, CPUState *env)\n\n{\n\n struct target_sigaltstack stack;\n\n int i;\n\n\n\n /* Clear all the bits of the ucontext we don't use. */\n\n memset(uc, 0, offsetof(struct target_ucontext_v2, tuc_mcontext));\n\n\n\n memset(&stack, 0, sizeof(stack));\n\n __put_user(target_sigaltstack_used.ss_sp, &stack.ss_sp);\n\n __put_user(target_sigaltstack_used.ss_size, &stack.ss_size);\n\n __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &stack.ss_flags);\n\n memcpy(&uc->tuc_stack, &stack, sizeof(stack));\n\n\n\n setup_sigcontext(&uc->tuc_mcontext, env, set->sig[0]);\n\n /* FIXME: Save coprocessor signal frame. */\n\n for(i = 0; i < TARGET_NSIG_WORDS; i++) {\n\n __put_user(set->sig[i], &uc->tuc_sigmask.sig[i]);\n\n }\n\n}\n", + "output": "0", + "index": 7098 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rwpipe_read_ppm_header( rwpipe *rw, int *width, int *height )\n\n{\n\n char line[ 3 ];\n\n FILE *in = rwpipe_reader( rw );\n\n int max;\n\n\n\n fgets( line, 3, in );\n\n if ( !strncmp( line, \"P6\", 2 ) )\n\n {\n\n *width = rwpipe_read_number( rw );\n\n *height = rwpipe_read_number( rw );\n\n max = rwpipe_read_number( rw );\n\n return max != 255 || *width <= 0 || *height <= 0;\n\n }\n\n return 1;\n\n}\n", + "output": "0", + "index": 4575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t imx_timerp_read(void *opaque, target_phys_addr_t offset,\n\n unsigned size)\n\n{\n\n IMXTimerPState *s = (IMXTimerPState *)opaque;\n\n\n\n DPRINTF(\"p-read(offset=%x)\", offset >> 2);\n\n switch (offset >> 2) {\n\n case 0: /* Control Register */\n\n DPRINTF(\"cr %x\\n\", s->cr);\n\n return s->cr;\n\n\n\n case 1: /* Status Register */\n\n DPRINTF(\"int_level %x\\n\", s->int_level);\n\n return s->int_level;\n\n\n\n case 2: /* LR - ticks*/\n\n DPRINTF(\"lr %x\\n\", s->lr);\n\n return s->lr;\n\n\n\n case 3: /* CMP */\n\n DPRINTF(\"cmp %x\\n\", s->cmp);\n\n return s->cmp;\n\n\n\n case 4: /* CNT */\n\n return ptimer_get_count(s->timer);\n\n }\n\n IPRINTF(\"imx_timerp_read: Bad offset %x\\n\",\n\n (int)offset >> 2);\n\n return 0;\n\n}\n", + "output": "0", + "index": 27093 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong get_psr(void)\n\n{\n\n helper_compute_psr();\n\n\n\n#if !defined (TARGET_SPARC64)\n\n return env->version | (env->psr & PSR_ICC) |\n\n (env->psref? PSR_EF : 0) |\n\n (env->psrpil << 8) |\n\n (env->psrs? PSR_S : 0) |\n\n (env->psrps? PSR_PS : 0) |\n\n (env->psret? PSR_ET : 0) | env->cwp;\n\n#else\n\n return env->version | (env->psr & PSR_ICC) |\n\n (env->psref? PSR_EF : 0) |\n\n (env->psrpil << 8) |\n\n (env->psrs? PSR_S : 0) |\n\n (env->psrps? PSR_PS : 0) | env->cwp;\n\n#endif\n\n}\n", + "output": "1", + "index": 1140 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs,\n\n int64_t sector_num, const uint8_t *buf, int nb_sectors,\n\n BlockDriverCompletionFunc *cb, void *opaque)\n\n{\n\n RawAIOCB *acb;\n\n\n\n /*\n\n * If O_DIRECT is used and the buffer is not aligned fall back\n\n * to synchronous IO.\n\n */\n\n BDRVRawState *s = bs->opaque;\n\n\n\n if (unlikely(s->aligned_buf != NULL && ((uintptr_t) buf % 512))) {\n\n QEMUBH *bh;\n\n acb = qemu_aio_get(bs, cb, opaque);\n\n acb->ret = raw_pwrite(bs, 512 * sector_num, buf, 512 * nb_sectors);\n\n bh = qemu_bh_new(raw_aio_em_cb, acb);\n\n qemu_bh_schedule(bh);\n\n return &acb->common;\n\n }\n\n\n\n acb = raw_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque);\n\n if (!acb)\n\n return NULL;\n\n if (aio_write(&acb->aiocb) < 0) {\n\n qemu_aio_release(acb);\n\n return NULL;\n\n }\n\n return &acb->common;\n\n}\n", + "output": "0", + "index": 7114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint32_t mipsdsp_sub32(int32_t a, int32_t b, CPUMIPSState *env)\n\n{\n\n int32_t temp;\n\n\n\n temp = a - b;\n\n if (MIPSDSP_OVERFLOW(a, -b, temp, 0x80000000)) {\n\n set_DSPControl_overflow_flag(1, 20, env);\n\n }\n\n\n\n return temp;\n\n}\n", + "output": "1", + "index": 15204 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void softusb_usbdev_datain(void *opaque)\n\n{\n\n MilkymistSoftUsbState *s = opaque;\n\n\n\n USBPacket p;\n\n\n\n p.pid = USB_TOKEN_IN;\n\n p.devep = 1;\n\n p.data = s->kbd_usb_buffer;\n\n p.len = sizeof(s->kbd_usb_buffer);\n\n s->usbdev->info->handle_data(s->usbdev, &p);\n\n\n\n softusb_kbd_changed(s);\n\n}\n", + "output": "1", + "index": 4744 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void simple_dict(void)\n\n{\n\n int i;\n\n struct {\n\n const char *encoded;\n\n LiteralQObject decoded;\n\n } test_cases[] = {\n\n {\n\n .encoded = \"{\\\"foo\\\": 42, \\\"bar\\\": \\\"hello world\\\"}\",\n\n .decoded = QLIT_QDICT(((LiteralQDictEntry[]){\n\n { \"foo\", QLIT_QINT(42) },\n\n { \"bar\", QLIT_QSTR(\"hello world\") },\n\n { }\n\n })),\n\n }, {\n\n .encoded = \"{}\",\n\n .decoded = QLIT_QDICT(((LiteralQDictEntry[]){\n\n { }\n\n })),\n\n }, {\n\n .encoded = \"{\\\"foo\\\": 43}\",\n\n .decoded = QLIT_QDICT(((LiteralQDictEntry[]){\n\n { \"foo\", QLIT_QINT(43) },\n\n { }\n\n })),\n\n },\n\n { }\n\n };\n\n\n\n for (i = 0; test_cases[i].encoded; i++) {\n\n QObject *obj;\n\n QString *str;\n\n\n\n obj = qobject_from_json(test_cases[i].encoded, NULL);\n\n g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);\n\n\n\n str = qobject_to_json(obj);\n\n qobject_decref(obj);\n\n\n\n obj = qobject_from_json(qstring_get_str(str), NULL);\n\n g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);\n\n qobject_decref(obj);\n\n QDECREF(str);\n\n }\n\n}\n", + "output": "1", + "index": 13019 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void host_signal_handler(int host_signum, siginfo_t *info, \n\n void *puc)\n\n{\n\n int sig;\n\n target_siginfo_t tinfo;\n\n\n\n /* the CPU emulator uses some host signals to detect exceptions,\n\n we we forward to it some signals */\n\n if (host_signum == SIGSEGV || host_signum == SIGBUS) {\n\n if (cpu_signal_handler(host_signum, info, puc))\n\n return;\n\n }\n\n\n\n /* get target signal number */\n\n sig = host_to_target_signal(host_signum);\n\n if (sig < 1 || sig > TARGET_NSIG)\n\n return;\n\n#if defined(DEBUG_SIGNAL)\n\n fprintf(stderr, \"qemu: got signal %d\\n\", sig);\n\n dump_regs(puc);\n\n#endif\n\n host_to_target_siginfo_noswap(&tinfo, info);\n\n if (queue_signal(sig, &tinfo) == 1) {\n\n /* interrupt the virtual CPU as soon as possible */\n\n cpu_interrupt(global_env, CPU_INTERRUPT_EXIT);\n\n }\n\n}\n", + "output": "1", + "index": 8443 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void t_gen_sext(TCGv d, TCGv s, int size)\n\n{\n\n\tif (size == 1)\n\n\t\ttcg_gen_ext8s_i32(d, s);\n\n\telse if (size == 2)\n\n\t\ttcg_gen_ext16s_i32(d, s);\n\n\telse if(GET_TCGV(d) != GET_TCGV(s))\n\n\t\ttcg_gen_mov_tl(d, s);\n\n}\n", + "output": "0", + "index": 10294 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface)\n\n{\n\n VABufferID va_buffers[3];\n\n unsigned int n_va_buffers = 0;\n\n\n\n if (!vactx->pic_param_buf_id)\n\n return 0;\n\n\n\n vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id);\n\n va_buffers[n_va_buffers++] = vactx->pic_param_buf_id;\n\n\n\n if (vactx->iq_matrix_buf_id) {\n\n vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id);\n\n va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id;\n\n }\n\n\n\n if (vactx->bitplane_buf_id) {\n\n vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id);\n\n va_buffers[n_va_buffers++] = vactx->bitplane_buf_id;\n\n }\n\n\n\n if (vaBeginPicture(vactx->display, vactx->context_id,\n\n surface) != VA_STATUS_SUCCESS)\n\n return -1;\n\n\n\n if (vaRenderPicture(vactx->display, vactx->context_id,\n\n va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)\n\n return -1;\n\n\n\n if (vaRenderPicture(vactx->display, vactx->context_id,\n\n vactx->slice_buf_ids,\n\n vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS)\n\n return -1;\n\n\n\n if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)\n\n return -1;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,\n\n uint8_t *iv, int decrypt)\n\n{\n\n int i;\n\n\n\n while (count > 0) {\n\n if (decrypt) {\n\n xtea_crypt_ecb(ctx, dst, src, decrypt);\n\n\n\n if (iv) {\n\n for (i = 0; i < 8; i++)\n\n dst[i] = dst[i] ^ iv[i];\n\n memcpy(iv, src, 8);\n\n }\n\n } else {\n\n if (iv) {\n\n for (i = 0; i < 8; i++)\n\n dst[i] = src[i] ^ iv[i];\n\n xtea_crypt_ecb(ctx, dst, dst, decrypt);\n\n memcpy(iv, dst, 8);\n\n } else {\n\n xtea_crypt_ecb(ctx, dst, src, decrypt);\n\n }\n\n }\n\n\n\n src += 8;\n\n dst += 8;\n\n count -= 8;\n\n }\n\n}\n", + "output": "0", + "index": 16795 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,\n VirtIOBlockDataPlane **dataplane)\n{\n VirtIOBlockDataPlane *s;\n int fd;\n *dataplane = NULL;\n if (!blk->data_plane) {\n return true;\n if (blk->scsi) {\n error_report(\"device is incompatible with x-data-plane, use scsi=off\");\n if (blk->config_wce) {\n error_report(\"device is incompatible with x-data-plane, \"\n \"use config-wce=off\");\n fd = raw_get_aio_fd(blk->conf.bs);\n if (fd < 0) {\n error_report(\"drive is incompatible with x-data-plane, \"\n \"use format=raw,cache=none,aio=native\");\n s = g_new0(VirtIOBlockDataPlane, 1);\n s->vdev = vdev;\n s->fd = fd;\n s->blk = blk;\n /* Prevent block operations that conflict with data plane thread */\n bdrv_set_in_use(blk->conf.bs, 1);\n *dataplane = s;\n return true;", + "output": "1", + "index": 8233 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void xan_wc3_copy_pixel_run(XanContext *s,\n\n int x, int y, int pixel_count, int motion_x, int motion_y)\n\n{\n\n int stride;\n\n int line_inc;\n\n int curframe_index, prevframe_index;\n\n int curframe_x, prevframe_x;\n\n int width = s->avctx->width;\n\n unsigned char *palette_plane, *prev_palette_plane;\n\n\n\n palette_plane = s->current_frame.data[0];\n\n prev_palette_plane = s->last_frame.data[0];\n\n\n\n stride = s->current_frame.linesize[0];\n\n line_inc = stride - width;\n\n curframe_index = y * stride + x;\n\n curframe_x = x;\n\n prevframe_index = (y + motion_y) * stride + x + motion_x;\n\n prevframe_x = x + motion_x;\n\n while(pixel_count && (curframe_index < s->frame_size)) {\n\n int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x);\n\n\n\n memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count);\n\n pixel_count -= count;\n\n curframe_index += count;\n\n prevframe_index += count;\n\n curframe_x += count;\n\n prevframe_x += count;\n\n\n\n if (curframe_x >= width) {\n\n curframe_index += line_inc;\n\n curframe_x = 0;\n\n }\n\n\n\n if (prevframe_x >= width) {\n\n prevframe_index += line_inc;\n\n prevframe_x = 0;\n\n }\n\n }\n\n}", + "output": "1", + "index": 12246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void count_colors(AVCodecContext *avctx, unsigned hits[33],\n\n const AVSubtitleRect *r)\n\n{\n\n DVDSubtitleContext *dvdc = avctx->priv_data;\n\n unsigned count[256] = { 0 };\n\n uint32_t *palette = (uint32_t *)r->pict.data[1];\n\n uint32_t color;\n\n int x, y, i, j, match, d, best_d, av_uninit(best_j);\n\n uint8_t *p = r->pict.data[0];\n\n\n\n for (y = 0; y < r->h; y++) {\n\n for (x = 0; x < r->w; x++)\n\n count[*(p++)]++;\n\n p += r->pict.linesize[0] - r->w;\n\n }\n\n for (i = 0; i < 256; i++) {\n\n if (!count[i]) /* avoid useless search */\n\n continue;\n\n color = palette[i];\n\n /* 0: transparent, 1-16: semi-transparent, 17-33 opaque */\n\n match = color < 0x33000000 ? 0 : color < 0xCC000000 ? 1 : 17;\n\n if (match) {\n\n best_d = INT_MAX;\n\n for (j = 0; j < 16; j++) {\n\n d = color_distance(color & 0xFFFFFF, dvdc->global_palette[j]);\n\n if (d < best_d) {\n\n best_d = d;\n\n best_j = j;\n\n }\n\n }\n\n match += best_j;\n\n }\n\n hits[match] += count[i];\n\n }\n\n}\n", + "output": "1", + "index": 13780 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void audio_run_capture (AudioState *s)\n\n{\n\n CaptureVoiceOut *cap;\n\n\n\n for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {\n\n int live, rpos, captured;\n\n HWVoiceOut *hw = &cap->hw;\n\n SWVoiceOut *sw;\n\n\n\n captured = live = audio_pcm_hw_get_live_out (hw);\n\n rpos = hw->rpos;\n\n while (live) {\n\n int left = hw->samples - rpos;\n\n int to_capture = audio_MIN (live, left);\n\n st_sample_t *src;\n\n struct capture_callback *cb;\n\n\n\n src = hw->mix_buf + rpos;\n\n hw->clip (cap->buf, src, to_capture);\n\n mixeng_clear (src, to_capture);\n\n\n\n for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {\n\n cb->ops.capture (cb->opaque, cap->buf,\n\n to_capture << hw->info.shift);\n\n }\n\n rpos = (rpos + to_capture) % hw->samples;\n\n live -= to_capture;\n\n }\n\n hw->rpos = rpos;\n\n\n\n for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {\n\n if (!sw->active && sw->empty) {\n\n continue;\n\n }\n\n\n\n if (audio_bug (AUDIO_FUNC, captured > sw->total_hw_samples_mixed)) {\n\n dolog (\"captured=%d sw->total_hw_samples_mixed=%d\\n\",\n\n captured, sw->total_hw_samples_mixed);\n\n captured = sw->total_hw_samples_mixed;\n\n }\n\n\n\n sw->total_hw_samples_mixed -= captured;\n\n sw->empty = sw->total_hw_samples_mixed == 0;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 20751 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr)\n\n{\n\n SubStream *s = &m->substream[substr];\n\n unsigned int i;\n\n uint32_t seed = s->noisegen_seed;\n\n unsigned int maxchan = s->max_matrix_channel;\n\n\n\n for (i = 0; i < s->blockpos; i++) {\n\n uint16_t seed_shr7 = seed >> 7;\n\n m->sample_buffer[i][maxchan+1] = ((int8_t)(seed >> 15)) << s->noise_shift;\n\n m->sample_buffer[i][maxchan+2] = ((int8_t) seed_shr7) << s->noise_shift;\n\n\n\n seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);\n\n }\n\n\n\n s->noisegen_seed = seed;\n\n}\n", + "output": "1", + "index": 9596 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void macio_nvram_writeb(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n MacIONVRAMState *s = opaque;\n\n\n\n addr = (addr >> s->it_shift) & (s->size - 1);\n\n s->data[addr] = value;\n\n NVR_DPRINTF(\"writeb addr %04x val %x\\n\", (int)addr, value);\n\n}\n", + "output": "0", + "index": 18358 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx)\n\n{\n\n unsigned int head;\n\n\n\n /* Grab the next descriptor number they're advertising, and increment\n\n * the index we've seen. */\n\n head = vring_avail_ring(vq, idx % vq->vring.num);\n\n\n\n /* If their number is silly, that's a fatal mistake. */\n\n if (head >= vq->vring.num) {\n\n error_report(\"Guest says index %u is available\", head);\n\n exit(1);\n\n }\n\n\n\n return head;\n\n}\n", + "output": "1", + "index": 13940 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_rdhwr(DisasContext *ctx, int rt, int rd)\n\n{\n\n TCGv t0;\n\n\n\n#if !defined(CONFIG_USER_ONLY)\n\n /* The Linux kernel will emulate rdhwr if it's not supported natively.\n\n Therefore only check the ISA in system mode. */\n\n check_insn(ctx, ISA_MIPS32R2);\n\n#endif\n\n t0 = tcg_temp_new();\n\n\n\n switch (rd) {\n\n case 0:\n\n gen_helper_rdhwr_cpunum(t0, cpu_env);\n\n gen_store_gpr(t0, rt);\n\n break;\n\n case 1:\n\n gen_helper_rdhwr_synci_step(t0, cpu_env);\n\n gen_store_gpr(t0, rt);\n\n break;\n\n case 2:\n\n gen_helper_rdhwr_cc(t0, cpu_env);\n\n gen_store_gpr(t0, rt);\n\n break;\n\n case 3:\n\n gen_helper_rdhwr_ccres(t0, cpu_env);\n\n gen_store_gpr(t0, rt);\n\n break;\n\n case 29:\n\n#if defined(CONFIG_USER_ONLY)\n\n tcg_gen_ld_tl(t0, cpu_env,\n\n offsetof(CPUMIPSState, active_tc.CP0_UserLocal));\n\n gen_store_gpr(t0, rt);\n\n break;\n\n#else\n\n if ((ctx->hflags & MIPS_HFLAG_CP0) ||\n\n (ctx->hflags & MIPS_HFLAG_HWRENA_ULR)) {\n\n tcg_gen_ld_tl(t0, cpu_env,\n\n offsetof(CPUMIPSState, active_tc.CP0_UserLocal));\n\n gen_store_gpr(t0, rt);\n\n } else {\n\n generate_exception_end(ctx, EXCP_RI);\n\n }\n\n break;\n\n#endif\n\n default: /* Invalid */\n\n MIPS_INVAL(\"rdhwr\");\n\n generate_exception_end(ctx, EXCP_RI);\n\n break;\n\n }\n\n tcg_temp_free(t0);\n\n}\n", + "output": "0", + "index": 27250 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sd_reset(SDState *sd, BlockDriverState *bdrv)\n\n{\n\n uint64_t size;\n\n uint64_t sect;\n\n\n\n if (bdrv) {\n\n bdrv_get_geometry(bdrv, §);\n\n } else {\n\n sect = 0;\n\n }\n\n sect <<= 9;\n\n\n\n size = sect + 1;\n\n\n\n sect = (size >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) + 1;\n\n\n\n sd->state = sd_idle_state;\n\n sd->rca = 0x0000;\n\n sd_set_ocr(sd);\n\n sd_set_scr(sd);\n\n sd_set_cid(sd);\n\n sd_set_csd(sd, size);\n\n sd_set_cardstatus(sd);\n\n sd_set_sdstatus(sd);\n\n\n\n sd->bdrv = bdrv;\n\n\n\n if (sd->wp_groups)\n\n qemu_free(sd->wp_groups);\n\n sd->wp_switch = bdrv ? bdrv_is_read_only(bdrv) : 0;\n\n sd->wp_groups = (int *) qemu_mallocz(sizeof(int) * sect);\n\n memset(sd->function_group, 0, sizeof(int) * 6);\n\n sd->erase_start = 0;\n\n sd->erase_end = 0;\n\n sd->size = size;\n\n sd->blk_len = 0x200;\n\n sd->pwd_len = 0;\n\n}\n", + "output": "1", + "index": 18531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint64_t tcg_opc_movi_a(int qp, TCGReg dst, int64_t src)\n\n{\n\n assert(src == sextract64(src, 0, 22));\n\n return tcg_opc_a5(qp, OPC_ADDL_A5, dst, src, TCG_REG_R0);\n\n}\n", + "output": "0", + "index": 13578 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline int dv_rl2vlc_size(int run, int l)\n\n{\n\n int level = (l ^ (l >> 8)) - (l >> 8);\n\n int size;\n\n \n\n if (run < DV_VLC_MAP_RUN_SIZE && level < DV_VLC_MAP_LEV_SIZE) {\n\n\tsize = dv_vlc_map[run][level].size; \n\n }\n\n else { \n\n\tsize = (level < DV_VLC_MAP_LEV_SIZE) ? dv_vlc_map[0][level].size : 16;\n\n\tif (run) {\n\n\t size += (run < 16) ? dv_vlc_map[run-1][0].size : 13;\n\n\t}\n\n }\n\n return size;\n\n}\n", + "output": "0", + "index": 12007 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)\n\n{\n\n struct kvm_irq_routing_entry kroute;\n\n int virq;\n\n\n\n if (!kvm_gsi_routing_enabled()) {\n\n return -ENOSYS;\n\n }\n\n\n\n virq = kvm_irqchip_get_virq(s);\n\n if (virq < 0) {\n\n return virq;\n\n }\n\n\n\n kroute.gsi = virq;\n\n kroute.type = KVM_IRQ_ROUTING_MSI;\n\n kroute.flags = 0;\n\n kroute.u.msi.address_lo = (uint32_t)msg.address;\n\n kroute.u.msi.address_hi = msg.address >> 32;\n\n kroute.u.msi.data = msg.data;\n\n\n\n kvm_add_routing_entry(s, &kroute);\n\n\n\n return virq;\n\n}\n", + "output": "0", + "index": 5249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tusb6010_init(SysBusDevice *dev)\n\n{\n\n TUSBState *s = FROM_SYSBUS(TUSBState, dev);\n\n qemu_irq *musb_irqs;\n\n int i;\n\n s->otg_timer = qemu_new_timer_ns(vm_clock, tusb_otg_tick, s);\n\n s->pwr_timer = qemu_new_timer_ns(vm_clock, tusb_power_tick, s);\n\n memory_region_init_io(&s->iomem[1], &tusb_async_ops, s, \"tusb-async\",\n\n UINT32_MAX);\n\n sysbus_init_mmio_region(dev, &s->iomem[0]);\n\n sysbus_init_mmio_region(dev, &s->iomem[1]);\n\n sysbus_init_irq(dev, &s->irq);\n\n qdev_init_gpio_in(&dev->qdev, tusb6010_irq, musb_irq_max + 1);\n\n musb_irqs = g_new0(qemu_irq, musb_irq_max);\n\n for (i = 0; i < musb_irq_max; i++) {\n\n musb_irqs[i] = qdev_get_gpio_in(&dev->qdev, i + 1);\n\n }\n\n s->musb = musb_init(musb_irqs);\n\n return 0;\n\n}\n", + "output": "0", + "index": 3048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_blocks(SnowContext *s){\n\n int x, y;\n\n int w= s->b_width;\n\n int h= s->b_height;\n\n int res;\n\n\n\n for(y=0; ybase = base;\n\n s->pic = pic;\n\n s->lines = lines;\n\n s->cpu_env = env;\n\n\n\n iomemtype = cpu_register_io_memory(0, pxa2xx_gpio_readfn,\n\n pxa2xx_gpio_writefn, s);\n\n cpu_register_physical_memory(base, 0x00000fff, iomemtype);\n\n\n\n register_savevm(\"pxa2xx_gpio\", 0, 0,\n\n pxa2xx_gpio_save, pxa2xx_gpio_load, s);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 21072 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hmp_memchar_write(Monitor *mon, const QDict *qdict)\n\n{\n\n uint32_t size;\n\n const char *chardev = qdict_get_str(qdict, \"device\");\n\n const char *data = qdict_get_str(qdict, \"data\");\n\n Error *errp = NULL;\n\n\n\n size = strlen(data);\n\n qmp_memchar_write(chardev, size, data, false, 0, &errp);\n\n\n\n hmp_handle_error(mon, &errp);\n\n}\n", + "output": "1", + "index": 23656 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int raw_inactivate(BlockDriverState *bs)\n\n{\n\n int ret;\n\n uint64_t perm = 0;\n\n uint64_t shared = BLK_PERM_ALL;\n\n\n\n ret = raw_handle_perm_lock(bs, RAW_PL_PREPARE, perm, shared, NULL);\n\n if (ret) {\n\n return ret;\n\n }\n\n raw_handle_perm_lock(bs, RAW_PL_COMMIT, perm, shared, NULL);\n\n return 0;\n\n}\n", + "output": "0", + "index": 16274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void eth_send(mv88w8618_eth_state *s, int queue_index)\n\n{\n\n uint32_t desc_addr = s->tx_queue[queue_index];\n\n mv88w8618_tx_desc desc;\n\n uint8_t buf[2048];\n\n int len;\n\n\n\n\n\n do {\n\n eth_tx_desc_get(desc_addr, &desc);\n\n if (desc.cmdstat & MP_ETH_TX_OWN) {\n\n len = desc.bytes;\n\n if (len < 2048) {\n\n cpu_physical_memory_read(desc.buffer, buf, len);\n\n qemu_send_packet(s->vc, buf, len);\n\n }\n\n desc.cmdstat &= ~MP_ETH_TX_OWN;\n\n s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);\n\n eth_tx_desc_put(desc_addr, &desc);\n\n }\n\n desc_addr = desc.next;\n\n } while (desc_addr != s->tx_queue[queue_index]);\n\n}\n", + "output": "0", + "index": 4944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool migration_object_check(MigrationState *ms, Error **errp)\n\n{\n\n if (!migrate_params_check(&ms->parameters, errp)) {\n\n return false;\n\n }\n\n\n\n return true;\n\n}\n", + "output": "0", + "index": 8060 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_mlpdsp_init(MLPDSPContext *c)\n\n{\n\n c->mlp_filter_channel = mlp_filter_channel;\n\n\n\n if (ARCH_X86)\n\n ff_mlpdsp_init_x86(c);\n\n}", + "output": "1", + "index": 6211 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_finish_row(H264Context *h, H264SliceContext *sl)\n\n{\n\n int top = 16 * (h->mb_y >> FIELD_PICTURE(h));\n\n int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h);\n\n int height = 16 << FRAME_MBAFF(h);\n\n int deblock_border = (16 + 4) << FRAME_MBAFF(h);\n\n\n\n if (h->deblocking_filter) {\n\n if ((top + height) >= pic_height)\n\n height += deblock_border;\n\n top -= deblock_border;\n\n }\n\n\n\n if (top >= pic_height || (top + height) < 0)\n\n return;\n\n\n\n height = FFMIN(height, pic_height - top);\n\n if (top < 0) {\n\n height = top + height;\n\n top = 0;\n\n }\n\n\n\n ff_h264_draw_horiz_band(h, sl, top, height);\n\n\n\n if (h->droppable)\n\n return;\n\n\n\n ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1,\n\n h->picture_structure == PICT_BOTTOM_FIELD);\n\n}\n", + "output": "0", + "index": 16985 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs)\n\n{\n\n if (lhs->type != qobject_type(rhs)) {\n\n return 0;\n\n }\n\n\n\n switch (lhs->type) {\n\n case QTYPE_QINT:\n\n return lhs->value.qint == qint_get_int(qobject_to_qint(rhs));\n\n case QTYPE_QSTRING:\n\n return (strcmp(lhs->value.qstr, qstring_get_str(qobject_to_qstring(rhs))) == 0);\n\n case QTYPE_QDICT: {\n\n int i;\n\n\n\n for (i = 0; lhs->value.qdict[i].key; i++) {\n\n QObject *obj = qdict_get(qobject_to_qdict(rhs), lhs->value.qdict[i].key);\n\n\n\n if (!compare_litqobj_to_qobj(&lhs->value.qdict[i].value, obj)) {\n\n return 0;\n\n }\n\n }\n\n\n\n return 1;\n\n }\n\n case QTYPE_QLIST: {\n\n QListCompareHelper helper;\n\n\n\n helper.index = 0;\n\n helper.objs = lhs->value.qlist;\n\n helper.result = 1;\n\n \n\n qlist_iter(qobject_to_qlist(rhs), compare_helper, &helper);\n\n\n\n return helper.result;\n\n }\n\n default:\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15068 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void msix_handle_mask_update(PCIDevice *dev, int vector)\n\n{\n\n if (!msix_is_masked(dev, vector) && msix_is_pending(dev, vector)) {\n\n msix_clr_pending(dev, vector);\n\n msix_notify(dev, vector);\n\n }\n\n}\n", + "output": "1", + "index": 20001 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)\n\n{\n\n Visitor *v;\n\n QDict *pdict;\n\n Object *obj;\n\n const char *id = qemu_opts_id(opts);\n\n const char *type = qemu_opt_get(opts, \"qom-type\");\n\n\n\n if (!type) {\n\n error_setg(errp, QERR_MISSING_PARAMETER, \"qom-type\");\n\n return NULL;\n\n }\n\n if (!id) {\n\n error_setg(errp, QERR_MISSING_PARAMETER, \"id\");\n\n return NULL;\n\n }\n\n\n\n pdict = qemu_opts_to_qdict(opts, NULL);\n\n qdict_del(pdict, \"qom-type\");\n\n qdict_del(pdict, \"id\");\n\n\n\n v = opts_visitor_new(opts);\n\n obj = user_creatable_add_type(type, id, pdict, v, errp);\n\n visit_free(v);\n\n\n\n QDECREF(pdict);\n\n return obj;\n\n}\n", + "output": "0", + "index": 2544 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,\n\n const uint8_t *src, int srcW, int xInc)\n\n{\n\n int i;\n\n unsigned int xpos=0;\n\n for (i=0;i>16;\n\n register unsigned int xalpha=(xpos&0xFFFF)>>9;\n\n dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;\n\n xpos+=xInc;\n\n }\n\n\n\n}", + "output": "1", + "index": 26435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_check_nic_model(NICInfo *nd, const char *model)\n\n{\n\n const char *models[2];\n\n\n\n models[0] = model;\n\n models[1] = NULL;\n\n\n\n qemu_check_nic_model_list(nd, models, model);\n\n}\n", + "output": "1", + "index": 22910 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_old_huffman_tables(HYuvContext *s)\n\n{\n\n GetBitContext gb;\n\n int i;\n\n\n\n init_get_bits(&gb, classic_shift_luma,\n\n classic_shift_luma_table_size * 8);\n\n if (read_len_table(s->len[0], &gb) < 0)\n\n return -1;\n\n\n\n init_get_bits(&gb, classic_shift_chroma,\n\n classic_shift_chroma_table_size * 8);\n\n if (read_len_table(s->len[1], &gb) < 0)\n\n return -1;\n\n\n\n for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];\n\n for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];\n\n\n\n if (s->bitstream_bpp >= 24) {\n\n memcpy(s->bits[1], s->bits[0], 256 * sizeof(uint32_t));\n\n memcpy(s->len[1] , s->len [0], 256 * sizeof(uint8_t));\n\n }\n\n memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t));\n\n memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t));\n\n\n\n for (i = 0; i < 3; i++) {\n\n ff_free_vlc(&s->vlc[i]);\n\n init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,\n\n s->bits[i], 4, 4, 0);\n\n }\n\n\n\n generate_joint_tables(s);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 26077 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_queue_set_notification(VirtQueue *vq, int enable)\n\n{\n\n vq->notification = enable;\n\n if (vq->vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) {\n\n vring_avail_event(vq, vring_avail_idx(vq));\n\n } else if (enable) {\n\n vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY);\n\n } else {\n\n vring_used_flags_set_bit(vq, VRING_USED_F_NO_NOTIFY);\n\n\n\n\n\n", + "output": "1", + "index": 7707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl)\n\n{\n\n int i;\n\n const int8_t (*tab)[2];\n\n const int slice_qp = av_clip(sl->qscale - 6*(h->sps.bit_depth_luma-8), 0, 51);\n\n\n\n if (sl->slice_type_nos == AV_PICTURE_TYPE_I) tab = cabac_context_init_I;\n\n else tab = cabac_context_init_PB[sl->cabac_init_idc];\n\n\n\n /* calculate pre-state */\n\n for( i= 0; i < 1024; i++ ) {\n\n int pre = 2*(((tab[i][0] * slice_qp) >>4 ) + tab[i][1]) - 127;\n\n\n\n pre^= pre>>31;\n\n if(pre > 124)\n\n pre= 124 + (pre&1);\n\n\n\n sl->cabac_state[i] = pre;\n\n }\n\n}\n", + "output": "0", + "index": 2176 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_chr_free_common(CharDriverState *chr)\n\n{\n\n\n\n\n g_free(chr->filename);\n\n g_free(chr->label);\n\n if (chr->logfd != -1) {\n\n close(chr->logfd);\n\n\n qemu_mutex_destroy(&chr->chr_write_lock);\n\n g_free(chr);\n", + "output": "1", + "index": 7290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)\n\n{\n\n QmpInputVisitor *qiv = to_qiv(v);\n\n QObject *qobj = qmp_input_get_object(qiv, name, true, errp);\n\n\n\n if (!qobj) {\n\n return;\n\n }\n\n\n\n if (qobject_type(qobj) != QTYPE_QNULL) {\n\n error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",\n\n \"null\");\n\n }\n\n}\n", + "output": "0", + "index": 5210 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data)\n\n{\n\n MachineClass *mc = MACHINE_CLASS(oc);\n\n\n\n mc->name = \"pseries-2.3\";\n\n mc->desc = \"pSeries Logical Partition (PAPR compliant) v2.3\";\n\n mc->alias = \"pseries\";\n\n mc->is_default = 1;\n\n}\n", + "output": "0", + "index": 7411 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int is_async_return(const QObject *data)\n\n{\n\n if (data && qobject_type(data) == QTYPE_QDICT) {\n\n return qdict_haskey(qobject_to_qdict(data), \"__mon_async\");\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 1483 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int decode_residual_inter(AVSContext *h) {\n\n int block;\n\n\n\n /* get coded block pattern */\n\n int cbp= get_ue_golomb(&h->s.gb);\n\n if(cbp > 63){\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"illegal inter cbp\\n\");\n\n return -1;\n\n }\n\n h->cbp = cbp_tab[cbp][1];\n\n\n\n /* get quantizer */\n\n if(h->cbp && !h->qp_fixed)\n\n h->qp = (h->qp + get_se_golomb(&h->s.gb)) & 63;\n\n for(block=0;block<4;block++)\n\n if(h->cbp & (1<s.gb,ff_cavs_inter_dec,0,h->qp,\n\n h->cy + h->luma_scan[block], h->l_stride);\n\n decode_residual_chroma(h);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 1388 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static float voice_factor(float *p_vector, float p_gain,\n\n float *f_vector, float f_gain,\n\n CELPMContext *ctx)\n\n{\n\n double p_ener = (double) ctx->dot_productf(p_vector, p_vector,\n\n AMRWB_SFR_SIZE) *\n\n p_gain * p_gain;\n\n double f_ener = (double) ctx->dot_productf(f_vector, f_vector,\n\n AMRWB_SFR_SIZE) *\n\n f_gain * f_gain;\n\n\n\n return (p_ener - f_ener) / (p_ener + f_ener);\n\n}\n", + "output": "1", + "index": 9500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)\n\n{\n\n#ifdef HAVE_MMX\n\n\tasm volatile(\n\n\t\t\"movq \"MANGLE(bm01010101)\", %%mm4\\n\\t\"\n\n\t\t\"mov %0, %%\"REG_a\"\t\t\\n\\t\"\n\n\t\t\"1:\t\t\t\t\\n\\t\"\n\n\t\t\"movq (%1, %%\"REG_a\",4), %%mm0\t\\n\\t\"\n\n\t\t\"movq 8(%1, %%\"REG_a\",4), %%mm1\t\\n\\t\"\n\n\t\t\"psrlw $8, %%mm0\t\t\\n\\t\"\n\n\t\t\"psrlw $8, %%mm1\t\t\\n\\t\"\n\n\t\t\"packuswb %%mm1, %%mm0\t\t\\n\\t\"\n\n\t\t\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\n\t\t\"psrlw $8, %%mm0\t\t\\n\\t\"\n\n\t\t\"pand %%mm4, %%mm1\t\t\\n\\t\"\n\n\t\t\"packuswb %%mm0, %%mm0\t\t\\n\\t\"\n\n\t\t\"packuswb %%mm1, %%mm1\t\t\\n\\t\"\n\n\t\t\"movd %%mm0, (%3, %%\"REG_a\")\t\\n\\t\"\n\n\t\t\"movd %%mm1, (%2, %%\"REG_a\")\t\\n\\t\"\n\n\t\t\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\n\t\t\" js 1b\t\t\t\t\\n\\t\"\n\n\t\t: : \"g\" (-width), \"r\" (src1+width*4), \"r\" (dstU+width), \"r\" (dstV+width)\n\n\t\t: \"%\"REG_a\n\n\t);\n\n#else\n\n\tint i;\n\n\tfor(i=0; isrc_bitmap);\n\n qxl_log_image(qxl, copy->src_bitmap, group_id);\n\n fprintf(stderr, \" area\");\n\n qxl_log_rect(©->src_area);\n\n fprintf(stderr, \" rop %d\", copy->rop_descriptor);\n\n}\n", + "output": "0", + "index": 4446 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)\n\n{\n\n BlockDriverState *bs;\n\n int force = qdict_get_int(qdict, \"force\");\n\n const char *filename = qdict_get_str(qdict, \"device\");\n\n\n\n bs = bdrv_find(filename);\n\n if (!bs) {\n\n qerror_report(QERR_DEVICE_NOT_FOUND, filename);\n\n return -1;\n\n }\n\n return eject_device(mon, bs, force);\n\n}\n", + "output": "0", + "index": 23936 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_system_shutdown_request(void)\n\n{\n\n trace_qemu_system_shutdown_request();\n\n replay_shutdown_request();\n\n shutdown_requested = 1;\n\n qemu_notify_event();\n\n}\n", + "output": "1", + "index": 5534 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVOpenCLExternalEnv *av_opencl_alloc_external_env(void)\n\n{\n\n AVOpenCLExternalEnv *ext = av_mallocz(sizeof(AVOpenCLExternalEnv));\n\n if (!ext) {\n\n av_log(&openclutils, AV_LOG_ERROR,\n\n \"Could not malloc external opencl environment data space\\n\");\n\n }\n\n return ext;\n\n}\n", + "output": "0", + "index": 8276 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_pipe_signaling(PCIQXLDevice *d)\n\n{\n\n if (pipe(d->pipe) < 0) {\n\n dprint(d, 1, \"%s: pipe creation failed\\n\", __FUNCTION__);\n\n return;\n\n }\n\n#ifdef CONFIG_IOTHREAD\n\n fcntl(d->pipe[0], F_SETFL, O_NONBLOCK);\n\n#else\n\n fcntl(d->pipe[0], F_SETFL, O_NONBLOCK /* | O_ASYNC */);\n\n#endif\n\n fcntl(d->pipe[1], F_SETFL, O_NONBLOCK);\n\n fcntl(d->pipe[0], F_SETOWN, getpid());\n\n\n\n d->main = pthread_self();\n\n qemu_set_fd_handler(d->pipe[0], pipe_read, NULL, d);\n\n}\n", + "output": "1", + "index": 17743 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ERROR(const char *str)\n\n{\n\n fprintf(stderr, \"%s\\n\", str);\n\n exit(1);\n\n}\n", + "output": "1", + "index": 3194 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void mix_3f_to_mono(AC3DecodeContext *ctx)\n\n{\n\n int i;\n\n float (*output)[256] = ctx->audio_block.block_output;\n\n\n\n for (i = 0; i < 256; i++)\n\n output[1][i] += (output[2][i] + output[3][i]);\n\n memset(output[2], 0, sizeof(output[2]));\n\n memset(output[3], 0, sizeof(output[3]));\n\n}\n", + "output": "0", + "index": 17914 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,\n\n QEMUIOVector *qiov, int flags)\n\n{\n\n BDRVVPCState *s = bs->opaque;\n\n int64_t image_offset;\n\n int64_t n_bytes;\n\n int64_t bytes_done = 0;\n\n int ret;\n\n VHDFooter *footer = (VHDFooter *) s->footer_buf;\n\n QEMUIOVector local_qiov;\n\n\n\n if (be32_to_cpu(footer->type) == VHD_FIXED) {\n\n return bdrv_co_pwritev(bs->file, offset, bytes, qiov, 0);\n\n }\n\n\n\n qemu_co_mutex_lock(&s->lock);\n\n qemu_iovec_init(&local_qiov, qiov->niov);\n\n\n\n while (bytes > 0) {\n\n image_offset = get_image_offset(bs, offset, true);\n\n n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));\n\n\n\n if (image_offset == -1) {\n\n image_offset = alloc_block(bs, offset);\n\n if (image_offset < 0) {\n\n ret = image_offset;\n\n goto fail;\n\n }\n\n }\n\n\n\n qemu_iovec_reset(&local_qiov);\n\n qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);\n\n\n\n ret = bdrv_co_pwritev(bs->file, image_offset, n_bytes,\n\n &local_qiov, 0);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n bytes -= n_bytes;\n\n offset += n_bytes;\n\n bytes_done += n_bytes;\n\n }\n\n\n\n ret = 0;\n\nfail:\n\n qemu_iovec_destroy(&local_qiov);\n\n qemu_co_mutex_unlock(&s->lock);\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 26859 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void unix_start_outgoing_migration(MigrationState *s,\n\n const char *path,\n\n Error **errp)\n\n{\n\n SocketAddressLegacy *saddr = unix_build_address(path);\n\n socket_start_outgoing_migration(s, saddr, errp);\n\n}\n", + "output": "0", + "index": 22085 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,\n\n const float *v1, const float *v2)\n\n{\n\n float cprod, oprod;\n\n int ret;\n\n\n\n cprod = cdsp->scalarproduct_float(v1, v2, LEN);\n\n oprod = fdsp->scalarproduct_float(v1, v2, LEN);\n\n\n\n if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))\n\n av_log(NULL, AV_LOG_ERROR, \"scalarproduct_float failed\\n\");\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 17898 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vga_screen_dump_blank(VGAState *s, const char *filename)\n\n{\n\n FILE *f;\n\n unsigned int y, x, w, h;\n\n\n\n w = s->last_scr_width * sizeof(uint32_t);\n\n h = s->last_scr_height;\n\n\n\n f = fopen(filename, \"wb\");\n\n if (!f)\n\n return;\n\n fprintf(f, \"P6\\n%d %d\\n%d\\n\", w, h, 255);\n\n for (y = 0; y < h; y++) {\n\n for (x = 0; x < w; x++) {\n\n fputc(0, f);\n\n }\n\n }\n\n fclose(f);\n\n}\n", + "output": "0", + "index": 4286 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int scsi_bus_legacy_handle_cmdline(SCSIBus *bus)\n\n{\n\n Location loc;\n\n DriveInfo *dinfo;\n\n int res = 0, unit;\n\n\n\n loc_push_none(&loc);\n\n for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {\n\n dinfo = drive_get(IF_SCSI, bus->busnr, unit);\n\n if (dinfo == NULL) {\n\n continue;\n\n }\n\n qemu_opts_loc_restore(dinfo->opts);\n\n if (!scsi_bus_legacy_add_drive(bus, dinfo->bdrv, unit)) {\n\n res = -1;\n\n break;\n\n }\n\n }\n\n loc_pop(&loc);\n\n return res;\n\n}\n", + "output": "0", + "index": 9686 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_ppc_decr_cb(void *opaque)\n\n{\n\n PowerPCCPU *cpu = opaque;\n\n\n\n _cpu_ppc_store_decr(cpu, 0x00000000, 0xFFFFFFFF, 1);\n\n}\n", + "output": "0", + "index": 10710 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sigp_store_adtl_status(CPUState *cs, run_on_cpu_data arg)\n\n{\n\n S390CPU *cpu = S390_CPU(cs);\n\n SigpInfo *si = arg.host_ptr;\n\n\n\n if (!s390_has_feat(S390_FEAT_VECTOR)) {\n\n set_sigp_status(si, SIGP_STAT_INVALID_ORDER);\n\n return;\n\n }\n\n\n\n /* cpu has to be stopped */\n\n if (s390_cpu_get_state(cpu) != CPU_STATE_STOPPED) {\n\n set_sigp_status(si, SIGP_STAT_INCORRECT_STATE);\n\n return;\n\n }\n\n\n\n /* parameter must be aligned to 1024-byte boundary */\n\n if (si->param & 0x3ff) {\n\n set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER);\n\n return;\n\n }\n\n\n\n cpu_synchronize_state(cs);\n\n\n\n if (kvm_s390_store_adtl_status(cpu, si->param)) {\n\n set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER);\n\n return;\n\n }\n\n si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;\n\n}\n", + "output": "0", + "index": 2911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool has_help_option(const char *param)\n\n{\n\n size_t buflen = strlen(param) + 1;\n\n char *buf = g_malloc(buflen);\n\n const char *p = param;\n\n bool result = false;\n\n\n\n while (*p) {\n\n p = get_opt_value(buf, buflen, p);\n\n if (*p) {\n\n p++;\n\n }\n\n\n\n if (is_help_option(buf)) {\n\n result = true;\n\n goto out;\n\n }\n\n }\n\n\n\nout:\n\n free(buf);\n\n return result;\n\n}\n", + "output": "0", + "index": 14280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "envlist_create(void)\n\n{\n\n\tenvlist_t *envlist;\n\n\n\n\tif ((envlist = malloc(sizeof (*envlist))) == NULL)\n\n\t\treturn (NULL);\n\n\n\n\tLIST_INIT(&envlist->el_entries);\n\n\tenvlist->el_count = 0;\n\n\n\n\treturn (envlist);\n\n}\n", + "output": "0", + "index": 12440 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t ivshmem_io_read(void *opaque, hwaddr addr,\n\n unsigned size)\n\n{\n\n\n\n IVShmemState *s = opaque;\n\n uint32_t ret;\n\n\n\n switch (addr)\n\n {\n\n case INTRMASK:\n\n ret = ivshmem_IntrMask_read(s);\n\n break;\n\n\n\n case INTRSTATUS:\n\n ret = ivshmem_IntrStatus_read(s);\n\n break;\n\n\n\n case IVPOSITION:\n\n /* return my VM ID if the memory is mapped */\n\n if (s->shm_fd >= 0) {\n\n ret = s->vm_id;\n\n } else {\n\n ret = -1;\n\n }\n\n break;\n\n\n\n default:\n\n IVSHMEM_DPRINTF(\"why are we reading \" TARGET_FMT_plx \"\\n\", addr);\n\n ret = 0;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 13029 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockAIOCB *bdrv_aio_writev_em(BlockDriverState *bs,\n\n int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\n\n BlockCompletionFunc *cb, void *opaque)\n\n{\n\n return bdrv_aio_rw_vector(bs, sector_num, qiov, nb_sectors, cb, opaque, 1);\n\n}\n", + "output": "0", + "index": 22541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "e1000_autoneg_timer(void *opaque)\n\n{\n\n E1000State *s = opaque;\n\n if (!qemu_get_queue(s->nic)->link_down) {\n\n e1000_link_up(s);\n\n }\n\n s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;\n\n DBGOUT(PHY, \"Auto negotiation is completed\\n\");\n\n}\n", + "output": "0", + "index": 23486 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void libschroedinger_free_frame(void *data)\n\n{\n\n FFSchroEncodedFrame *enc_frame = data;\n\n\n\n av_freep(&enc_frame->p_encbuf);\n\n av_free(enc_frame);\n\n}\n", + "output": "1", + "index": 19054 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_client_sync_dirty_bitmap(struct CPUPhysMemoryClient *client,\n\n target_phys_addr_t start_addr,\n\n target_phys_addr_t end_addr)\n\n{\n\n return kvm_physical_sync_dirty_bitmap(start_addr, end_addr);\n\n}\n", + "output": "1", + "index": 21511 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dec_mul(DisasContext *dc)\n\n{\n\n if (dc->format == OP_FMT_RI) {\n\n LOG_DIS(\"muli r%d, r%d, %d\\n\", dc->r0, dc->r1,\n\n sign_extend(dc->imm16, 16));\n\n } else {\n\n LOG_DIS(\"mul r%d, r%d, r%d\\n\", dc->r2, dc->r0, dc->r1);\n\n }\n\n\n\n if (!(dc->env->features & LM32_FEATURE_MULTIPLY)) {\n\n cpu_abort(dc->env, \"hardware multiplier is not available\\n\");\n\n }\n\n\n\n if (dc->format == OP_FMT_RI) {\n\n tcg_gen_muli_tl(cpu_R[dc->r1], cpu_R[dc->r0],\n\n sign_extend(dc->imm16, 16));\n\n } else {\n\n tcg_gen_mul_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);\n\n }\n\n}\n", + "output": "1", + "index": 12164 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend,\n\n Error **errp)\n\n{\n\n int val;\n\n\n\n backend->vc = g_new0(ChardevVC, 1);\n\n\n\n val = qemu_opt_get_number(opts, \"width\", 0);\n\n if (val != 0) {\n\n backend->vc->has_width = true;\n\n backend->vc->width = val;\n\n }\n\n\n\n val = qemu_opt_get_number(opts, \"height\", 0);\n\n if (val != 0) {\n\n backend->vc->has_height = true;\n\n backend->vc->height = val;\n\n }\n\n\n\n val = qemu_opt_get_number(opts, \"cols\", 0);\n\n if (val != 0) {\n\n backend->vc->has_cols = true;\n\n backend->vc->cols = val;\n\n }\n\n\n\n val = qemu_opt_get_number(opts, \"rows\", 0);\n\n if (val != 0) {\n\n backend->vc->has_rows = true;\n\n backend->vc->rows = val;\n\n }\n\n}\n", + "output": "0", + "index": 25024 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void prodsum(float *tgt, float *src, int len, int n)\n\n{\n\n unsigned int x;\n\n float *p1, *p2;\n\n double sum;\n\n\n\n while (n >= 0) {\n\n p1 = (p2 = src) - n;\n\n for (sum=0, x=len; x--; sum += (*p1++) * (*p2++));\n\n tgt[n--] = sum;\n\n }\n\n}\n", + "output": "0", + "index": 5374 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_eject(BlockDriverState *bs, int eject_flag)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n\n\n if (bs->locked) {\n\n return -EBUSY;\n\n }\n\n\n\n if (drv && drv->bdrv_eject) {\n\n drv->bdrv_eject(bs, eject_flag);\n\n }\n\n bs->tray_open = eject_flag;\n\n return 0;\n\n}\n", + "output": "0", + "index": 25016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtol_whitespace(void)\n\n{\n\n const char *str = \" \\t \";\n\n char f = 'X';\n\n const char *endptr = &f;\n\n long res = 999;\n\n int err;\n\n\n\n err = qemu_strtol(str, &endptr, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, 0);\n\n g_assert(endptr == str);\n\n}\n", + "output": "1", + "index": 12966 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_validate_qmp_introspect(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n do_test_validate_qmp_introspect(data, test_qmp_schema_json);\n\n do_test_validate_qmp_introspect(data, qmp_schema_json);\n\n}\n", + "output": "0", + "index": 1977 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_device_type(SCSIDiskState *s)\n\n{\n\n BlockDriverState *bdrv = s->qdev.conf.bs;\n\n uint8_t cmd[16];\n\n uint8_t buf[36];\n\n uint8_t sensebuf[8];\n\n sg_io_hdr_t io_header;\n\n int ret;\n\n\n\n memset(cmd, 0, sizeof(cmd));\n\n memset(buf, 0, sizeof(buf));\n\n cmd[0] = INQUIRY;\n\n cmd[4] = sizeof(buf);\n\n\n\n memset(&io_header, 0, sizeof(io_header));\n\n io_header.interface_id = 'S';\n\n io_header.dxfer_direction = SG_DXFER_FROM_DEV;\n\n io_header.dxfer_len = sizeof(buf);\n\n io_header.dxferp = buf;\n\n io_header.cmdp = cmd;\n\n io_header.cmd_len = sizeof(cmd);\n\n io_header.mx_sb_len = sizeof(sensebuf);\n\n io_header.sbp = sensebuf;\n\n io_header.timeout = 6000; /* XXX */\n\n\n\n ret = bdrv_ioctl(bdrv, SG_IO, &io_header);\n\n if (ret < 0 || io_header.driver_status || io_header.host_status) {\n\n return -1;\n\n }\n\n s->qdev.type = buf[0];\n\n if (buf[1] & 0x80) {\n\n s->features |= 1 << SCSI_DISK_F_REMOVABLE;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 4398 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)\n\n{\n\n char line[1024], group[64], id[64], arg[64], value[1024];\n\n Location loc;\n\n QemuOptsList *list = NULL;\n\n Error *local_err = NULL;\n\n QemuOpts *opts = NULL;\n\n int res = -1, lno = 0;\n\n\n\n loc_push_none(&loc);\n\n while (fgets(line, sizeof(line), fp) != NULL) {\n\n loc_set_file(fname, ++lno);\n\n if (line[0] == '\\n') {\n\n /* skip empty lines */\n\n continue;\n\n }\n\n if (line[0] == '#') {\n\n /* comment */\n\n continue;\n\n }\n\n if (sscanf(line, \"[%63s \\\"%63[^\\\"]\\\"]\", group, id) == 2) {\n\n /* group with id */\n\n list = find_list(lists, group, &local_err);\n\n if (local_err) {\n\n error_report_err(local_err);\n\n goto out;\n\n }\n\n opts = qemu_opts_create(list, id, 1, NULL);\n\n continue;\n\n }\n\n if (sscanf(line, \"[%63[^]]]\", group) == 1) {\n\n /* group without id */\n\n list = find_list(lists, group, &local_err);\n\n if (local_err) {\n\n error_report_err(local_err);\n\n goto out;\n\n }\n\n opts = qemu_opts_create(list, NULL, 0, &error_abort);\n\n continue;\n\n }\n\n value[0] = '\\0';\n\n if (sscanf(line, \" %63s = \\\"%1023[^\\\"]\\\"\", arg, value) == 2 ||\n\n sscanf(line, \" %63s = \\\"\\\"\", arg) == 1) {\n\n /* arg = value */\n\n if (opts == NULL) {\n\n error_report(\"no group defined\");\n\n goto out;\n\n }\n\n qemu_opt_set(opts, arg, value, &local_err);\n\n if (local_err) {\n\n error_report_err(local_err);\n\n goto out;\n\n }\n\n continue;\n\n }\n\n error_report(\"parse error\");\n\n goto out;\n\n }\n\n if (ferror(fp)) {\n\n error_report(\"error reading file\");\n\n goto out;\n\n }\n\n res = 0;\n\nout:\n\n loc_pop(&loc);\n\n return res;\n\n}\n", + "output": "0", + "index": 8299 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_ppc_set_tb_clk (void *opaque, uint32_t freq)\n\n{\n\n CPUState *env = opaque;\n\n ppc_tb_t *tb_env = env->tb_env;\n\n\n\n tb_env->tb_freq = freq;\n\n tb_env->decr_freq = freq;\n\n /* There is a bug in Linux 2.4 kernels:\n\n * if a decrementer exception is pending when it enables msr_ee at startup,\n\n * it's not ready to handle it...\n\n */\n\n _cpu_ppc_store_decr(env, 0xFFFFFFFF, 0xFFFFFFFF, 0);\n\n#if defined(TARGET_PPC64H)\n\n _cpu_ppc_store_hdecr(env, 0xFFFFFFFF, 0xFFFFFFFF, 0);\n\n cpu_ppc_store_purr(env, 0x0000000000000000ULL);\n\n#endif /* defined(TARGET_PPC64H) */\n\n}\n", + "output": "0", + "index": 26898 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TCGv_i64 read_fp_dreg(DisasContext *s, int reg)\n\n{\n\n TCGv_i64 v = tcg_temp_new_i64();\n\n\n\n tcg_gen_ld_i64(v, cpu_env, fp_reg_offset(reg, MO_64));\n\n return v;\n\n}\n", + "output": "0", + "index": 21720 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void mix_3f_2r_to_stereo(AC3DecodeContext *ctx)\n\n{\n\n int i;\n\n float (*output)[256] = ctx->audio_block.block_output;\n\n\n\n for (i = 0; i < 256; i++) {\n\n output[1][i] += (output[2][i] + output[4][i]);\n\n output[2][i] += (output[3][i] + output[5][i]);\n\n }\n\n memset(output[3], 0, sizeof(output[3]));\n\n memset(output[4], 0, sizeof(output[4]));\n\n memset(output[5], 0, sizeof(output[5]));\n\n}\n", + "output": "0", + "index": 16161 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,\n\n const AVIOInterruptCB *int_cb, AVDictionary **options)\n\n{\n\n return avio_open2(pb, url, flags, int_cb, options);\n\n}\n", + "output": "0", + "index": 18322 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path)\n\n{\n\n Object *mem_obj = object_resolve_path(obj_path, NULL);\n\n char *mempath = object_property_get_str(mem_obj, \"mem-path\", NULL);\n\n long pagesize;\n\n\n\n if (mempath) {\n\n pagesize = qemu_mempath_getpagesize(mempath);\n\n\n } else {\n\n pagesize = getpagesize();\n\n }\n\n\n\n return pagesize >= max_cpu_page_size;\n\n}", + "output": "1", + "index": 22444 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *sdp_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type)\n\n{\n\n char *config = NULL;\n\n\n\n switch (c->codec_id) {\n\n case CODEC_ID_MPEG4:\n\n if (c->flags & CODEC_FLAG_GLOBAL_HEADER) {\n\n config = extradata2config(c->extradata, c->extradata_size);\n\n }\n\n av_strlcatf(buff, size, \"a=rtpmap:%d MP4V-ES/90000\\r\\n\"\n\n \"a=fmtp:%d profile-level-id=1%s\\r\\n\",\n\n payload_type,\n\n payload_type, config ? config : \"\");\n\n break;\n\n case CODEC_ID_AAC:\n\n if (c->flags & CODEC_FLAG_GLOBAL_HEADER) {\n\n config = extradata2config(c->extradata, c->extradata_size);\n\n } else {\n\n /* FIXME: maybe we can forge config information based on the\n\n * codec parameters...\n\n */\n\n av_log(NULL, AV_LOG_ERROR, \"AAC with no global headers is currently not supported\\n\");\n\n return NULL;\n\n }\n\n if (config == NULL) {\n\n return NULL;\n\n }\n\n av_strlcatf(buff, size, \"a=rtpmap:%d MPEG4-GENERIC/%d/%d\\r\\n\"\n\n \"a=fmtp:%d profile-level-id=1;\"\n\n \"mode=AAC-hbr;sizelength=13;indexlength=3;\"\n\n \"indexdeltalength=3%s\\r\\n\",\n\n payload_type, c->sample_rate, c->channels,\n\n payload_type, config);\n\n break;\n\n default:\n\n /* Nothing special to do, here... */\n\n break;\n\n }\n\n\n\n av_free(config);\n\n\n\n return buff;\n\n}\n", + "output": "0", + "index": 20390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,\n\n ulong subchan_id, void *load_addr)\n\n{\n\n u8 status;\n\n int sec = rec_list1;\n\n int sec_num = ((rec_list2 >> 32) & 0xffff) + 1;\n\n int sec_len = rec_list2 >> 48;\n\n ulong addr = (ulong)load_addr;\n\n\n\n if (sec_len != virtio_get_block_size()) {\n\n return -1;\n\n }\n\n\n\n sclp_print(\".\");\n\n status = virtio_read_many(sec, (void *)addr, sec_num);\n\n if (status) {\n\n virtio_panic(\"I/O Error\");\n\n }\n\n addr += sec_num * virtio_get_block_size();\n\n\n\n return addr;\n\n}\n", + "output": "1", + "index": 3177 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_watchpoint_remove_by_ref(CPUState *env, CPUWatchpoint *watchpoint)\n\n{\n\n TAILQ_REMOVE(&env->watchpoints, watchpoint, entry);\n\n\n\n tlb_flush_page(env, watchpoint->vaddr);\n\n\n\n qemu_free(watchpoint);\n\n}\n", + "output": "0", + "index": 6197 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int len)\n\n{\n\n int x;\n\n for (x = 0; x < len; x++) {\n\n float r, g, b;\n\n r = calculate_gamma(FFMIN(1.0f, v[x].re), gamma);\n\n g = calculate_gamma(FFMIN(1.0f, 0.5f * (v[x].re + v[x].im)), gamma);\n\n b = calculate_gamma(FFMIN(1.0f, v[x].im), gamma);\n\n c[x].yuv.y = 16.0f + 65.481f * r + 128.553f * g + 24.966f * b;\n\n c[x].yuv.u = 128.0f - 37.797f * r - 74.203f * g + 112.0f * b;\n\n c[x].yuv.v = 128.0f + 112.0f * r - 93.786f * g - 18.214 * b;\n\n }\n\n}\n", + "output": "0", + "index": 18366 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "float32 uint64_to_float32( uint64 a STATUS_PARAM )\n\n{\n\n int8 shiftCount;\n\n\n\n if ( a == 0 ) return 0;\n\n shiftCount = countLeadingZeros64( a ) - 40;\n\n if ( 0 <= shiftCount ) {\n\n return packFloat32( 1 > 0, 0x95 - shiftCount, a< 0, 0x9C - shiftCount, a STATUS_VAR );\n\n }\n\n}\n", + "output": "0", + "index": 5048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void avc_luma_hv_qrt_16w_msa(const uint8_t *src_x, const uint8_t *src_y,\n\n int32_t src_stride, uint8_t *dst,\n\n int32_t dst_stride, int32_t height)\n\n{\n\n uint32_t multiple8_cnt;\n\n\n\n for (multiple8_cnt = 2; multiple8_cnt--;) {\n\n avc_luma_hv_qrt_8w_msa(src_x, src_y, src_stride, dst, dst_stride,\n\n height);\n\n\n\n src_x += 8;\n\n src_y += 8;\n\n dst += 8;\n\n }\n\n}\n", + "output": "0", + "index": 10918 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_out_native_list_int16(TestOutputVisitorData *data,\n\n const void *unused)\n\n{\n\n test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S16);\n\n}\n", + "output": "0", + "index": 1545 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ea_read_header(AVFormatContext *s)\n\n{\n\n EaDemuxContext *ea = s->priv_data;\n\n AVStream *st;\n\n\n\n if (process_ea_header(s)<=0)\n\n return AVERROR(EIO);\n\n\n\n if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha))\n\n return AVERROR(ENOMEM);\n\n\n\n if (ea->audio_codec) {\n\n if (ea->num_channels <= 0 || ea->num_channels > 2) {\n\n av_log(s, AV_LOG_WARNING,\n\n \"Unsupported number of channels: %d\\n\", ea->num_channels);\n\n ea->audio_codec = 0;\n\n return 1;\n\n }\n\n if (ea->sample_rate <= 0) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"Unsupported sample rate: %d\\n\", ea->sample_rate);\n\n ea->audio_codec = 0;\n\n return 1;\n\n }\n\n if (ea->bytes <= 0) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"Invalid number of bytes per sample: %d\\n\", ea->bytes);\n\n ea->audio_codec = AV_CODEC_ID_NONE;\n\n return 1;\n\n }\n\n\n\n /* initialize the audio decoder stream */\n\n st = avformat_new_stream(s, NULL);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n avpriv_set_pts_info(st, 33, 1, ea->sample_rate);\n\n st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;\n\n st->codecpar->codec_id = ea->audio_codec;\n\n st->codecpar->codec_tag = 0; /* no tag */\n\n st->codecpar->channels = ea->num_channels;\n\n st->codecpar->sample_rate = ea->sample_rate;\n\n st->codecpar->bits_per_coded_sample = ea->bytes * 8;\n\n st->codecpar->bit_rate = (int64_t)st->codecpar->channels *\n\n st->codecpar->sample_rate *\n\n st->codecpar->bits_per_coded_sample / 4;\n\n st->codecpar->block_align = st->codecpar->channels *\n\n st->codecpar->bits_per_coded_sample;\n\n ea->audio_stream_index = st->index;\n\n st->start_time = 0;\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 17360 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_celp_lp_zero_synthesis_filterf(float *out,\n\n const float* filter_coeffs,\n\n const float* in,\n\n int buffer_length,\n\n int filter_length)\n\n{\n\n int i,n;\n\n\n\n // Avoids a +1 in the inner loop.\n\n filter_length++;\n\n\n\n for (n = 0; n < buffer_length; n++) {\n\n out[n] = in[n];\n\n for (i = 1; i < filter_length; i++)\n\n out[n] += filter_coeffs[i-1] * in[n-i];\n\n }\n\n}\n", + "output": "0", + "index": 10763 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse)\n\n{\n\n if (cse && cse < n)\n\n n = cse + 1;\n\n if (sloc < n-1)\n\n cpu_to_be16wu((uint16_t *)(data + sloc),\n\n do_cksum(data + css, data + n));\n\n}\n", + "output": "0", + "index": 11602 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn bdrv_rw_co_entry(void *opaque)\n\n{\n\n RwCo *rwco = opaque;\n\n\n\n if (!rwco->is_write) {\n\n rwco->ret = bdrv_co_do_preadv(rwco->bs, rwco->offset,\n\n rwco->qiov->size, rwco->qiov,\n\n rwco->flags);\n\n } else {\n\n rwco->ret = bdrv_co_do_pwritev(rwco->bs, rwco->offset,\n\n rwco->qiov->size, rwco->qiov,\n\n rwco->flags);\n\n }\n\n}\n", + "output": "0", + "index": 13590 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){\n\n int i, j;\n\n int dc = (((dctcoef*)block)[0] + 32) >> 6;\n\n INIT_CLIP\n\n pixel *dst = (pixel*)_dst;\n\n stride /= sizeof(pixel);\n\n for( j = 0; j < 4; j++ )\n\n {\n\n for( i = 0; i < 4; i++ )\n\n dst[i] = CLIP( dst[i] + dc );\n\n dst += stride;\n\n }\n\n}\n", + "output": "1", + "index": 12547 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int load_uboot(const char *filename, target_ulong *ep, int *is_linux)\n\n{\n\n\n\n int fd;\n\n int size;\n\n uboot_image_header_t h;\n\n uboot_image_header_t *hdr = &h;\n\n uint8_t *data = NULL;\n\n\n\n fd = open(filename, O_RDONLY | O_BINARY);\n\n if (fd < 0)\n\n return -1;\n\n\n\n size = read(fd, hdr, sizeof(uboot_image_header_t));\n\n if (size < 0)\n\n goto fail;\n\n\n\n bswap_uboot_header(hdr);\n\n\n\n if (hdr->ih_magic != IH_MAGIC)\n\n goto fail;\n\n\n\n /* TODO: Implement Multi-File images. */\n\n if (hdr->ih_type == IH_TYPE_MULTI) {\n\n fprintf(stderr, \"Unable to load multi-file u-boot images\\n\");\n\n goto fail;\n\n }\n\n\n\n /* TODO: Implement compressed images. */\n\n if (hdr->ih_comp != IH_COMP_NONE) {\n\n fprintf(stderr, \"Unable to load compressed u-boot images\\n\");\n\n goto fail;\n\n }\n\n\n\n /* TODO: Check CPU type. */\n\n if (is_linux) {\n\n if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)\n\n *is_linux = 1;\n\n else\n\n *is_linux = 0;\n\n }\n\n\n\n *ep = hdr->ih_ep;\n\n data = qemu_malloc(hdr->ih_size);\n\n if (!data)\n\n goto fail;\n\n\n\n if (read(fd, data, hdr->ih_size) != hdr->ih_size) {\n\n fprintf(stderr, \"Error reading file\\n\");\n\n goto fail;\n\n }\n\n\n\n cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);\n\n\n\n return hdr->ih_size;\n\n\n\nfail:\n\n if (data)\n\n qemu_free(data);\n\n close(fd);\n\n return -1;\n\n}\n", + "output": "1", + "index": 26041 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_clock_init(QEMUClockType type)\n{\n QEMUClock *clock = qemu_clock_ptr(type);\n clock->type = type;\n clock->enabled = true;\n clock->last = INT64_MIN;\n QLIST_INIT(&clock->timerlists);\n notifier_list_init(&clock->reset_notifiers);\n main_loop_tlg.tl[type] = timerlist_new(type, NULL, NULL);\n}", + "output": "1", + "index": 10653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char * avdevice_configuration(void)\n\n{\n\n return FFMPEG_CONFIGURATION;\n\n}\n", + "output": "0", + "index": 8126 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_port(int port)\n\n{\n\n struct qhc uhci;\n\n\n\n g_assert(port > 0);\n\n qusb_pci_init_one(qs->pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4);\n\n uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS);\n\n\n}", + "output": "1", + "index": 5531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int locate_option(int argc, char **argv, const OptionDef *options,\n\n const char *optname)\n\n{\n\n const OptionDef *po;\n\n int i;\n\n\n\n for (i = 1; i < argc; i++) {\n\n const char *cur_opt = argv[i];\n\n\n\n if (*cur_opt++ != '-')\n\n continue;\n\n\n\n po = find_option(options, cur_opt);\n\n if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o')\n\n po = find_option(options, cur_opt + 2);\n\n\n\n if ((!po->name && !strcmp(cur_opt, optname)) ||\n\n (po->name && !strcmp(optname, po->name)))\n\n return i;\n\n\n\n if (!po || po->flags & HAS_ARG)\n\n i++;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 17730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val)\n\n{\n\n val = tswap64(val);\n\n spapr_tce_dma_write(dev, taddr, &val, sizeof(val));\n\n}\n", + "output": "1", + "index": 26987 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_16w_msa(src - 2,\n\n src - (stride * 2), stride, dst, stride, 16);\n\n}\n", + "output": "0", + "index": 9988 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_tcg_init_vcpu(CPUState *cpu)\n\n{\n\n char thread_name[VCPU_THREAD_NAME_SIZE];\n\n static QemuCond *tcg_halt_cond;\n\n static QemuThread *tcg_cpu_thread;\n\n\n\n tcg_cpu_address_space_init(cpu, cpu->as);\n\n\n\n /* share a single thread for all cpus with TCG */\n\n if (!tcg_cpu_thread) {\n\n cpu->thread = g_malloc0(sizeof(QemuThread));\n\n cpu->halt_cond = g_malloc0(sizeof(QemuCond));\n\n qemu_cond_init(cpu->halt_cond);\n\n tcg_halt_cond = cpu->halt_cond;\n\n snprintf(thread_name, VCPU_THREAD_NAME_SIZE, \"CPU %d/TCG\",\n\n cpu->cpu_index);\n\n qemu_thread_create(cpu->thread, thread_name, qemu_tcg_cpu_thread_fn,\n\n cpu, QEMU_THREAD_JOINABLE);\n\n#ifdef _WIN32\n\n cpu->hThread = qemu_thread_get_handle(cpu->thread);\n\n#endif\n\n while (!cpu->created) {\n\n qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);\n\n }\n\n tcg_cpu_thread = cpu->thread;\n\n } else {\n\n cpu->thread = tcg_cpu_thread;\n\n cpu->halt_cond = tcg_halt_cond;\n\n }\n\n}\n", + "output": "0", + "index": 24314 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_co_rwlock_unlock(CoRwlock *lock)\n{\n assert(qemu_in_coroutine());\n if (lock->writer) {\n lock->writer = false;\n qemu_co_queue_restart_all(&lock->queue);\n } else {\n lock->reader--;\n assert(lock->reader >= 0);\n /* Wakeup only one waiting writer */\n if (!lock->reader) {\n qemu_co_queue_next(&lock->queue);\n }\n }\n}", + "output": "1", + "index": 25653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void co_write_request(void *opaque)\n\n{\n\n BDRVSheepdogState *s = opaque;\n\n\n\n qemu_coroutine_enter(s->co_send, NULL);\n\n}\n", + "output": "1", + "index": 24895 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int stdio_fclose(void *opaque)\n\n{\n\n QEMUFileStdio *s = opaque;\n\n int ret = 0;\n\n\n\n if (s->file->ops->put_buffer || s->file->ops->writev_buffer) {\n\n int fd = fileno(s->stdio_file);\n\n struct stat st;\n\n\n\n ret = fstat(fd, &st);\n\n if (ret == 0 && S_ISREG(st.st_mode)) {\n\n /*\n\n * If the file handle is a regular file make sure the\n\n * data is flushed to disk before signaling success.\n\n */\n\n ret = fsync(fd);\n\n if (ret != 0) {\n\n ret = -errno;\n\n return ret;\n\n }\n\n }\n\n }\n\n if (fclose(s->stdio_file) == EOF) {\n\n ret = -errno;\n\n }\n\n g_free(s);\n\n return ret;\n\n}\n", + "output": "0", + "index": 20533 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "block_crypto_open_opts_init(QCryptoBlockFormat format,\n\n QemuOpts *opts,\n\n Error **errp)\n\n{\n\n Visitor *v;\n\n QCryptoBlockOpenOptions *ret = NULL;\n\n Error *local_err = NULL;\n\n\n\n ret = g_new0(QCryptoBlockOpenOptions, 1);\n\n ret->format = format;\n\n\n\n v = opts_visitor_new(opts);\n\n\n\n visit_start_struct(v, NULL, NULL, 0, &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n\n\n switch (format) {\n\n case Q_CRYPTO_BLOCK_FORMAT_LUKS:\n\n visit_type_QCryptoBlockOptionsLUKS_members(\n\n v, &ret->u.luks, &local_err);\n\n break;\n\n\n\n default:\n\n error_setg(&local_err, \"Unsupported block format %d\", format);\n\n break;\n\n }\n\n if (!local_err) {\n\n visit_check_struct(v, &local_err);\n\n }\n\n\n\n visit_end_struct(v, NULL);\n\n\n\n out:\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n qapi_free_QCryptoBlockOpenOptions(ret);\n\n ret = NULL;\n\n }\n\n visit_free(v);\n\n return ret;\n\n}\n", + "output": "0", + "index": 14810 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_transaction(TransactionActionList *dev_list, Error **errp)\n\n{\n\n TransactionActionList *dev_entry = dev_list;\n\n BlkTransactionState *state, *next;\n\n Error *local_err = NULL;\n\n\n\n QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionState) snap_bdrv_states;\n\n QSIMPLEQ_INIT(&snap_bdrv_states);\n\n\n\n /* drain all i/o before any operations */\n\n bdrv_drain_all();\n\n\n\n /* We don't do anything in this loop that commits us to the operations */\n\n while (NULL != dev_entry) {\n\n TransactionAction *dev_info = NULL;\n\n const BdrvActionOps *ops;\n\n\n\n dev_info = dev_entry->value;\n\n dev_entry = dev_entry->next;\n\n\n\n assert(dev_info->kind < ARRAY_SIZE(actions));\n\n\n\n ops = &actions[dev_info->kind];\n\n assert(ops->instance_size > 0);\n\n\n\n state = g_malloc0(ops->instance_size);\n\n state->ops = ops;\n\n state->action = dev_info;\n\n QSIMPLEQ_INSERT_TAIL(&snap_bdrv_states, state, entry);\n\n\n\n state->ops->prepare(state, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n goto delete_and_fail;\n\n }\n\n }\n\n\n\n QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) {\n\n if (state->ops->commit) {\n\n state->ops->commit(state);\n\n }\n\n }\n\n\n\n /* success */\n\n goto exit;\n\n\n\ndelete_and_fail:\n\n /* failure, and it is all-or-none; roll back all operations */\n\n QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) {\n\n if (state->ops->abort) {\n\n state->ops->abort(state);\n\n }\n\n }\n\nexit:\n\n QSIMPLEQ_FOREACH_SAFE(state, &snap_bdrv_states, entry, next) {\n\n if (state->ops->clean) {\n\n state->ops->clean(state);\n\n }\n\n g_free(state);\n\n }\n\n}\n", + "output": "0", + "index": 9943 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nbd_restart_write(void *opaque)\n\n{\n\n NbdClientSession *s = opaque;\n\n\n\n qemu_coroutine_enter(s->send_coroutine, NULL);\n\n}\n", + "output": "0", + "index": 7575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void find_compressor(char * compressor_name, int len, MOVTrack *track)\n\n{\n\n AVDictionaryEntry *encoder;\n\n int xdcam_res = (track->par->width == 1280 && track->par->height == 720)\n\n || (track->par->width == 1440 && track->par->height == 1080)\n\n || (track->par->width == 1920 && track->par->height == 1080);\n\n\n\n if (track->mode == MODE_MOV &&\n\n (encoder = av_dict_get(track->st->metadata, \"encoder\", NULL, 0))) {\n\n av_strlcpy(compressor_name, encoder->value, 32);\n\n } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {\n\n int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;\n\n AVStream *st = track->st;\n\n int rate = av_q2d(find_fps(NULL, st));\n\n av_strlcatf(compressor_name, len, \"XDCAM\");\n\n if (track->par->format == AV_PIX_FMT_YUV422P) {\n\n av_strlcatf(compressor_name, len, \" HD422\");\n\n } else if(track->par->width == 1440) {\n\n av_strlcatf(compressor_name, len, \" HD\");\n\n } else\n\n av_strlcatf(compressor_name, len, \" EX\");\n\n\n\n av_strlcatf(compressor_name, len, \" %d%c\", track->par->height, interlaced ? 'i' : 'p');\n\n\n\n av_strlcatf(compressor_name, len, \"%d\", rate * (interlaced + 1));\n\n }\n\n}\n", + "output": "1", + "index": 18494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,\n\n ThreadFrame *ref, const VP56mv *mv,\n\n int x_off, int y_off, int block_w, int block_h,\n\n int width, int height, int linesize,\n\n vp8_mc_func mc_func[3][3])\n\n{\n\n uint8_t *src = ref->f->data[0];\n\n\n\n if (AV_RN32A(mv)) {\n\n\n\n int mx = (mv->x << 1)&7, mx_idx = subpel_idx[0][mx];\n\n int my = (mv->y << 1)&7, my_idx = subpel_idx[0][my];\n\n\n\n x_off += mv->x >> 2;\n\n y_off += mv->y >> 2;\n\n\n\n // edge emulation\n\n ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 4, 0);\n\n src += y_off * linesize + x_off;\n\n if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||\n\n y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {\n\n s->vdsp.emulated_edge_mc(td->edge_emu_buffer, src - my_idx * linesize - mx_idx, linesize,\n\n block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],\n\n x_off - mx_idx, y_off - my_idx, width, height);\n\n src = td->edge_emu_buffer + mx_idx + linesize * my_idx;\n\n }\n\n mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my);\n\n } else {\n\n ff_thread_await_progress(ref, (3 + y_off + block_h) >> 4, 0);\n\n mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0);\n\n }\n\n}\n", + "output": "1", + "index": 9440 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int au_read_packet(AVFormatContext *s,\n\n AVPacket *pkt)\n\n{\n\n int ret;\n\n\n\n ret= av_get_packet(s->pb, pkt, BLOCK_SIZE *\n\n s->streams[0]->codec->channels *\n\n av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);\n\n if (ret < 0)\n\n return ret;\n\n\n pkt->stream_index = 0;\n\n\n\n /* note: we need to modify the packet size here to handle the last\n\n packet */\n\n pkt->size = ret;\n\n return 0;\n\n}", + "output": "1", + "index": 25087 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_dealloc_partial(void)\n\n{\n\n static const char text[] = \"don't leak me\";\n\n\n\n UserDefTwo *ud2 = NULL;\n\n Error *err = NULL;\n\n\n\n /* create partial object */\n\n {\n\n QDict *ud2_dict;\n\n QmpInputVisitor *qiv;\n\n\n\n ud2_dict = qdict_new();\n\n qdict_put_obj(ud2_dict, \"string0\", QOBJECT(qstring_from_str(text)));\n\n\n\n qiv = qmp_input_visitor_new(QOBJECT(ud2_dict), false);\n\n visit_type_UserDefTwo(qmp_input_get_visitor(qiv), NULL, &ud2, &err);\n\n qmp_input_visitor_cleanup(qiv);\n\n QDECREF(ud2_dict);\n\n }\n\n\n\n /* verify partial success */\n\n assert(ud2 != NULL);\n\n assert(ud2->string0 != NULL);\n\n assert(strcmp(ud2->string0, text) == 0);\n\n assert(ud2->dict1 == NULL);\n\n\n\n /* confirm & release construction error */\n\n error_free_or_abort(&err);\n\n\n\n /* tear down partial object */\n\n qapi_free_UserDefTwo(ud2);\n\n}\n", + "output": "0", + "index": 12137 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int write_target_commit(BlockDriverState *bs, int64_t sector_num,\n\n\tconst uint8_t* buffer, int nb_sectors) {\n\n BDRVVVFATState* s = bs->opaque;\n\n return try_commit(s);\n\n}\n", + "output": "1", + "index": 17553 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_snapshot_create(BlockDriverState *bs,\n\n QEMUSnapshotInfo *sn_info)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n if (!drv)\n\n return -ENOMEDIUM;\n\n if (drv->bdrv_snapshot_create)\n\n return drv->bdrv_snapshot_create(bs, sn_info);\n\n if (bs->file)\n\n return bdrv_snapshot_create(bs->file, sn_info);\n\n return -ENOTSUP;\n\n}\n", + "output": "0", + "index": 20414 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,\n\n uint8_t *data, uint32_t len)\n\n{\n\n const char *basename;\n\n int index;\n\n\n\n if (!s->files) {\n\n int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;\n\n s->files = qemu_mallocz(dsize);\n\n fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);\n\n }\n\n\n\n index = be32_to_cpu(s->files->count);\n\n if (index == FW_CFG_FILE_SLOTS) {\n\n fprintf(stderr, \"fw_cfg: out of file slots\\n\");\n\n return 0;\n\n }\n\n\n\n fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len);\n\n\n\n basename = strrchr(filename, '/');\n\n if (basename) {\n\n basename++;\n\n } else {\n\n basename = filename;\n\n }\n\n if (dir) {\n\n snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),\n\n \"%s/%s\", dir, basename);\n\n } else {\n\n snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),\n\n \"%s\", basename);\n\n }\n\n s->files->f[index].size = cpu_to_be32(len);\n\n s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);\n\n FW_CFG_DPRINTF(\"%s: #%d: %s (%d bytes)\\n\", __FUNCTION__,\n\n index, s->files->f[index].name, len);\n\n\n\n s->files->count = cpu_to_be32(index+1);\n\n return 1;\n\n}\n", + "output": "0", + "index": 6221 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)\n\n{\n\n int predictor;\n\n\n\n predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;\n\n predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;\n\n\n\n c->sample2 = c->sample1;\n\n c->sample1 = av_clip_int16(predictor);\n\n c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;\n\n if (c->idelta < 16) c->idelta = 16;\n\n\n\n\n\n\n\n return c->sample1;\n", + "output": "1", + "index": 20578 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_put_xcrs(X86CPU *cpu)\n\n{\n\n CPUX86State *env = &cpu->env;\n\n struct kvm_xcrs xcrs = {};\n\n\n\n if (!kvm_has_xcrs()) {\n\n return 0;\n\n }\n\n\n\n xcrs.nr_xcrs = 1;\n\n xcrs.flags = 0;\n\n xcrs.xcrs[0].xcr = 0;\n\n xcrs.xcrs[0].value = env->xcr0;\n\n return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XCRS, &xcrs);\n\n}\n", + "output": "0", + "index": 14502 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QObject *qlist_peek(QList *qlist)\n\n{\n\n QListEntry *entry;\n\n QObject *ret;\n\n\n\n if (qlist == NULL || QTAILQ_EMPTY(&qlist->head)) {\n\n return NULL;\n\n }\n\n\n\n entry = QTAILQ_FIRST(&qlist->head);\n\n\n\n ret = entry->value;\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 11171 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_synth_statfs(FsContext *s, V9fsPath *fs_path,\n\n struct statfs *stbuf)\n\n{\n\n stbuf->f_type = 0xABCD;\n\n stbuf->f_bsize = 512;\n\n stbuf->f_blocks = 0;\n\n stbuf->f_files = v9fs_synth_node_count;\n\n stbuf->f_namelen = NAME_MAX;\n\n return 0;\n\n}\n", + "output": "0", + "index": 26972 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void blk_mig_unlock(void)\n\n{\n\n qemu_mutex_unlock(&block_mig_state.lock);\n\n}\n", + "output": "1", + "index": 724 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unicore_ii_cpu_initfn(Object *obj)\n\n{\n\n UniCore32CPU *cpu = UNICORE32_CPU(obj);\n\n CPUUniCore32State *env = &cpu->env;\n\n\n\n env->cp0.c0_cpuid = 0x40010863;\n\n\n\n set_feature(env, UC32_HWCAP_CMOV);\n\n set_feature(env, UC32_HWCAP_UCF64);\n\n env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;\n\n env->cp0.c0_cachetype = 0x1dd20d2;\n\n env->cp0.c1_sys = 0x00090078;\n\n}\n", + "output": "0", + "index": 17685 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rstrip_spaces_buf(AVBPrint *buf)\n\n{\n\n while (buf->len > 0 && buf->str[buf->len - 1] == ' ')\n\n buf->str[--buf->len] = 0;\n\n}\n", + "output": "1", + "index": 25477 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usbredir_do_attach(void *opaque)\n\n{\n\n USBRedirDevice *dev = opaque;\n\n\n\n /* In order to work properly with XHCI controllers we need these caps */\n\n if ((dev->dev.port->speedmask & USB_SPEED_MASK_SUPER) && !(\n\n usbredirparser_peer_has_cap(dev->parser,\n\n usb_redir_cap_ep_info_max_packet_size) &&\n\n usbredirparser_peer_has_cap(dev->parser,\n\n usb_redir_cap_32bits_bulk_length) &&\n\n usbredirparser_peer_has_cap(dev->parser,\n\n usb_redir_cap_64bits_ids))) {\n\n ERROR(\"usb-redir-host lacks capabilities needed for use with XHCI\\n\");\n\n usbredir_reject_device(dev);\n\n return;\n\n }\n\n\n\n if (usb_device_attach(&dev->dev) != 0) {\n\n WARNING(\"rejecting device due to speed mismatch\\n\");\n\n usbredir_reject_device(dev);\n\n }\n\n}\n", + "output": "0", + "index": 8838 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int t15(InterplayACMContext *s, unsigned ind, unsigned col)\n\n{\n\n GetBitContext *gb = &s->gb;\n\n unsigned i, b;\n\n int n1, n2, n3;\n\n\n\n for (i = 0; i < s->rows; i++) {\n\n /* b = (x1) + (x2 * 3) + (x3 * 9) */\n\n b = get_bits(gb, 5);\n\n\n\n\n\n\n\n n1 = (mul_3x3[b] & 0x0F) - 1;\n\n n2 = ((mul_3x3[b] >> 4) & 0x0F) - 1;\n\n n3 = ((mul_3x3[b] >> 8) & 0x0F) - 1;\n\n\n\n set_pos(s, i++, col, n1);\n\n if (i >= s->rows)\n\n break;\n\n set_pos(s, i++, col, n2);\n\n if (i >= s->rows)\n\n break;\n\n set_pos(s, i, col, n3);\n\n\n return 0;\n", + "output": "1", + "index": 770 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void flatview_ref(FlatView *view)\n\n{\n\n atomic_inc(&view->ref);\n\n}\n", + "output": "1", + "index": 19809 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "writev_f(int argc, char **argv)\n\n{\n\n\tstruct timeval t1, t2;\n\n\tint Cflag = 0, qflag = 0;\n\n\tint c, cnt;\n\n\tchar *buf;\n\n\tint64_t offset;\n\n\tint total;\n\n\tint nr_iov;\n\n\tint pattern = 0xcd;\n\n\tQEMUIOVector qiov;\n\n\n\n\twhile ((c = getopt(argc, argv, \"CqP:\")) != EOF) {\n\n\t\tswitch (c) {\n\n\t\tcase 'C':\n\n\t\t\tCflag = 1;\n\n\t\t\tbreak;\n\n\t\tcase 'q':\n\n\t\t\tqflag = 1;\n\n\t\t\tbreak;\n\n\t\tcase 'P':\n\n\t\t\tpattern = atoi(optarg);\n\n\t\t\tbreak;\n\n\t\tdefault:\n\n\t\t\treturn command_usage(&writev_cmd);\n\n\t\t}\n\n\t}\n\n\n\n\tif (optind > argc - 2)\n\n\t\treturn command_usage(&writev_cmd);\n\n\n\n\toffset = cvtnum(argv[optind]);\n\n\tif (offset < 0) {\n\n\t\tprintf(\"non-numeric length argument -- %s\\n\", argv[optind]);\n\n\t\treturn 0;\n\n\t}\n\n\toptind++;\n\n\n\n\tif (offset & 0x1ff) {\n\n\t\tprintf(\"offset %lld is not sector aligned\\n\",\n\n\t\t\t(long long)offset);\n\n\t\treturn 0;\n\n\t}\n\n\n\n\tnr_iov = argc - optind;\n\n\tbuf = create_iovec(&qiov, &argv[optind], nr_iov, pattern);\n\n\n\n\tgettimeofday(&t1, NULL);\n\n\tcnt = do_aio_writev(&qiov, offset, &total);\n\n\tgettimeofday(&t2, NULL);\n\n\n\n\tif (cnt < 0) {\n\n\t\tprintf(\"writev failed: %s\\n\", strerror(-cnt));\n\n\t\tgoto out;\n\n\t}\n\n\n\n\tif (qflag)\n\n\t\tgoto out;\n\n\n\n\t/* Finally, report back -- -C gives a parsable format */\n\n\tt2 = tsub(t2, t1);\n\n\tprint_report(\"wrote\", &t2, offset, qiov.size, total, cnt, Cflag);\n\nout:\n\n\tqemu_io_free(buf);\n\n\treturn 0;\n\n}\n", + "output": "0", + "index": 27091 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool qemu_clock_run_all_timers(void)\n\n{\n\n bool progress = false;\n\n QEMUClockType type;\n\n\n\n for (type = 0; type < QEMU_CLOCK_MAX; type++) {\n\n progress |= qemu_clock_run_timers(type);\n\n }\n\n\n\n return progress;\n\n}\n", + "output": "0", + "index": 11960 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vf_open(vf_instance_t *vf, char *args){\n\n vf->config=config;\n\n vf->put_image=put_image;\n\n vf->get_image=get_image;\n\n vf->query_format=query_format;\n\n vf->uninit=uninit;\n\n vf->control= control;\n\n vf->priv=malloc(sizeof(struct vf_priv_s));\n\n memset(vf->priv, 0, sizeof(struct vf_priv_s));\n\n\n\n if (args) sscanf(args, \"%d:%d\", &vf->priv->qp, &vf->priv->mode);\n\n\n\n if(vf->priv->qp < 0)\n\n vf->priv->qp = 0;\n\n\n\n init_thres2();\n\n\n\n switch(vf->priv->mode){\n\n case 0: requantize= hardthresh_c; break;\n\n case 1: requantize= softthresh_c; break;\n\n default:\n\n case 2: requantize= mediumthresh_c; break;\n\n }\n\n\n\n#if HAVE_MMX\n\n if(ff_gCpuCaps.hasMMX){\n\n dctB= dctB_mmx;\n\n }\n\n#endif\n\n#if 0\n\n if(ff_gCpuCaps.hasMMX){\n\n switch(vf->priv->mode){\n\n case 0: requantize= hardthresh_mmx; break;\n\n case 1: requantize= softthresh_mmx; break;\n\n }\n\n }\n\n#endif\n\n\n\n return 1;\n\n}\n", + "output": "0", + "index": 20387 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qdict_teardown(void)\n\n{\n\n QDECREF(tests_dict);\n\n tests_dict = NULL;\n\n}\n", + "output": "0", + "index": 22554 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoll_empty(void)\n\n{\n\n const char *str = \"\";\n\n char f = 'X';\n\n const char *endptr = &f;\n\n int64_t res = 999;\n\n int err;\n\n\n\n err = qemu_strtoll(str, &endptr, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, 0);\n\n g_assert(endptr == str);\n\n}\n", + "output": "1", + "index": 6465 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,\n\n ptrdiff_t stride, int h)\n\n{\n\n const uint8_t *scantable = s->intra_scantable.permutated;\n\n LOCAL_ALIGNED_16(int16_t, temp, [64]);\n\n int i, last, run, bits, level, start_i;\n\n const int esc_length = s->ac_esc_length;\n\n uint8_t *length, *last_length;\n\n\n\n av_assert2(h == 8);\n\n\n\n s->pdsp.diff_pixels(temp, src1, src2, stride);\n\n\n\n s->block_last_index[0 /* FIXME */] =\n\n last =\n\n s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);\n\n\n\n bits = 0;\n\n\n\n if (s->mb_intra) {\n\n start_i = 1;\n\n length = s->intra_ac_vlc_length;\n\n last_length = s->intra_ac_vlc_last_length;\n\n bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma\n\n } else {\n\n start_i = 0;\n\n length = s->inter_ac_vlc_length;\n\n last_length = s->inter_ac_vlc_last_length;\n\n }\n\n\n\n if (last >= start_i) {\n\n run = 0;\n\n for (i = start_i; i < last; i++) {\n\n int j = scantable[i];\n\n level = temp[j];\n\n\n\n if (level) {\n\n level += 64;\n\n if ((level & (~127)) == 0)\n\n bits += length[UNI_AC_ENC_INDEX(run, level)];\n\n else\n\n bits += esc_length;\n\n run = 0;\n\n } else\n\n run++;\n\n }\n\n i = scantable[last];\n\n\n\n level = temp[i] + 64;\n\n\n\n av_assert2(level - 64);\n\n\n\n if ((level & (~127)) == 0)\n\n bits += last_length[UNI_AC_ENC_INDEX(run, level)];\n\n else\n\n bits += esc_length;\n\n }\n\n\n\n return bits;\n\n}\n", + "output": "1", + "index": 146 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void memory_region_add_eventfd(MemoryRegion *mr,\n hwaddr addr,\n unsigned size,\n bool match_data,\n uint64_t data,\n EventNotifier *e)\n{\n MemoryRegionIoeventfd mrfd = {\n .addr.start = int128_make64(addr),\n .addr.size = int128_make64(size),\n .match_data = match_data,\n .data = data,\n .e = e,\n };\n unsigned i;\n if (size) {\n adjust_endianness(mr, &mrfd.data, size);\n memory_region_transaction_begin();\n for (i = 0; i < mr->ioeventfd_nb; ++i) {\n if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) {\n break;\n ++mr->ioeventfd_nb;\n mr->ioeventfds = g_realloc(mr->ioeventfds,\n sizeof(*mr->ioeventfds) * mr->ioeventfd_nb);\n memmove(&mr->ioeventfds[i+1], &mr->ioeventfds[i],\n sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));\n mr->ioeventfds[i] = mrfd;\n ioeventfd_update_pending |= mr->enabled;\n memory_region_transaction_commit();", + "output": "1", + "index": 23092 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "pvscsi_on_cmd_setup_msg_ring(PVSCSIState *s)\n\n{\n\n PVSCSICmdDescSetupMsgRing *rc =\n\n (PVSCSICmdDescSetupMsgRing *) s->curr_cmd_data;\n\n\n\n trace_pvscsi_on_cmd_arrived(\"PVSCSI_CMD_SETUP_MSG_RING\");\n\n\n\n if (!s->use_msg) {\n\n return PVSCSI_COMMAND_PROCESSING_FAILED;\n\n }\n\n\n\n if (s->rings_info_valid) {\n\n pvscsi_ring_init_msg(&s->rings, rc);\n\n s->msg_ring_info_valid = TRUE;\n\n }\n\n return sizeof(PVSCSICmdDescSetupMsgRing) / sizeof(uint32_t);\n\n}\n", + "output": "1", + "index": 15244 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int openfile(char *name, int flags, int growable)\n\n{\n\n\tif (bs) {\n\n\t\tfprintf(stderr, \"file open already, try 'help close'\\n\");\n\n\t\treturn 1;\n\n\t}\n\n\n\n\tbs = bdrv_new(\"hda\");\n\n\tif (!bs)\n\n\t\treturn 1;\n\n\n\n\tif (bdrv_open(bs, name, flags) == -1) {\n\n\t\tfprintf(stderr, \"%s: can't open device %s\\n\", progname, name);\n\n\t\tbs = NULL;\n\n\t\treturn 1;\n\n\t}\n\n\n\n\n\n\tif (growable) {\n\n\t\tif (!bs->drv || !bs->drv->protocol_name) {\n\n\t\t\tfprintf(stderr,\n\n\t\t\t\t\"%s: only protocols can be opened growable\\n\",\n\n\t\t\t\tprogname);\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tbs->growable = 1;\n\n\t}\n\n\n\n\treturn 0;\n\n}\n", + "output": "1", + "index": 9279 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void help(int exitcode)\n\n{\n\n const char *options_help =\n\n#define QEMU_OPTIONS_GENERATE_HELP\n\n#include \"qemu-options-wrapper.h\"\n\n ;\n\n version();\n\n printf(\"usage: %s [options] [disk_image]\\n\"\n\n \"\\n\"\n\n \"'disk_image' is a raw hard disk image for IDE hard disk 0\\n\"\n\n \"\\n\"\n\n \"%s\\n\"\n\n \"During emulation, the following keys are useful:\\n\"\n\n \"ctrl-alt-f toggle full screen\\n\"\n\n \"ctrl-alt-n switch to virtual console 'n'\\n\"\n\n \"ctrl-alt toggle mouse and keyboard grab\\n\"\n\n \"\\n\"\n\n \"When using -nographic, press 'ctrl-a h' to get some help.\\n\",\n\n error_get_progname(),\n\n options_help);\n\n exit(exitcode);\n\n}\n", + "output": "0", + "index": 25200 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int socket_listen(SocketAddress *addr, Error **errp)\n\n{\n\n QemuOpts *opts;\n\n int fd;\n\n\n\n opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);\n\n switch (addr->kind) {\n\n case SOCKET_ADDRESS_KIND_INET:\n\n inet_addr_to_opts(opts, addr->inet);\n\n fd = inet_listen_opts(opts, 0, errp);\n\n break;\n\n\n\n case SOCKET_ADDRESS_KIND_UNIX:\n\n qemu_opt_set(opts, \"path\", addr->q_unix->path, &error_abort);\n\n fd = unix_listen_opts(opts, errp);\n\n break;\n\n\n\n case SOCKET_ADDRESS_KIND_FD:\n\n fd = monitor_get_fd(cur_mon, addr->fd->str, errp);\n\n break;\n\n\n\n default:\n\n abort();\n\n }\n\n qemu_opts_del(opts);\n\n return fd;\n\n}\n", + "output": "0", + "index": 25288 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void AUD_remove_card (QEMUSoundCard *card)\n\n{\n\n LIST_REMOVE (card, entries);\n\n qemu_free (card->name);\n\n}\n", + "output": "0", + "index": 14968 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_mtc0_index(CPUMIPSState *env, target_ulong arg1)\n\n{\n\n int num = 1;\n\n unsigned int tmp = env->tlb->nb_tlb;\n\n\n\n do {\n\n tmp >>= 1;\n\n num <<= 1;\n\n } while (tmp);\n\n env->CP0_Index = (env->CP0_Index & 0x80000000) | (arg1 & (num - 1));\n\n}\n", + "output": "0", + "index": 16746 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scale_vaapi_query_formats(AVFilterContext *avctx)\n\n{\n\n enum AVPixelFormat pix_fmts[] = {\n\n AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,\n\n };\n\n\n\n ff_formats_ref(ff_make_format_list(pix_fmts),\n\n &avctx->inputs[0]->out_formats);\n\n ff_formats_ref(ff_make_format_list(pix_fmts),\n\n &avctx->outputs[0]->in_formats);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17617 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nand_realize(DeviceState *dev, Error **errp)\n\n{\n\n int pagesize;\n\n NANDFlashState *s = NAND(dev);\n\n\n\n s->buswidth = nand_flash_ids[s->chip_id].width >> 3;\n\n s->size = nand_flash_ids[s->chip_id].size << 20;\n\n if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) {\n\n s->page_shift = 11;\n\n s->erase_shift = 6;\n\n } else {\n\n s->page_shift = nand_flash_ids[s->chip_id].page_shift;\n\n s->erase_shift = nand_flash_ids[s->chip_id].erase_shift;\n\n }\n\n\n\n switch (1 << s->page_shift) {\n\n case 256:\n\n nand_init_256(s);\n\n break;\n\n case 512:\n\n nand_init_512(s);\n\n break;\n\n case 2048:\n\n nand_init_2048(s);\n\n break;\n\n default:\n\n error_setg(errp, \"Unsupported NAND block size %#x\\n\",\n\n 1 << s->page_shift);\n\n return;\n\n }\n\n\n\n pagesize = 1 << s->oob_shift;\n\n s->mem_oob = 1;\n\n if (s->bdrv) {\n\n if (bdrv_is_read_only(s->bdrv)) {\n\n error_setg(errp, \"Can't use a read-only drive\");\n\n return;\n\n }\n\n if (bdrv_getlength(s->bdrv) >=\n\n (s->pages << s->page_shift) + (s->pages << s->oob_shift)) {\n\n pagesize = 0;\n\n s->mem_oob = 0;\n\n }\n\n } else {\n\n pagesize += 1 << s->page_shift;\n\n }\n\n if (pagesize) {\n\n s->storage = (uint8_t *) memset(g_malloc(s->pages * pagesize),\n\n 0xff, s->pages * pagesize);\n\n }\n\n /* Give s->ioaddr a sane value in case we save state before it is used. */\n\n s->ioaddr = s->io;\n\n}\n", + "output": "0", + "index": 20952 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tap_cleanup(VLANClientState *nc)\n\n{\n\n TAPState *s = DO_UPCAST(TAPState, nc, nc);\n\n\n\n if (s->vhost_net) {\n\n vhost_net_cleanup(s->vhost_net);\n\n\n }\n\n\n\n qemu_purge_queued_packets(nc);\n\n\n\n if (s->down_script[0])\n\n launch_script(s->down_script, s->down_script_arg, s->fd);\n\n\n\n tap_read_poll(s, 0);\n\n tap_write_poll(s, 0);\n\n close(s->fd);\n\n}", + "output": "1", + "index": 26438 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mux_chr_update_read_handler(CharDriverState *chr,\n\n GMainContext *context)\n\n{\n\n MuxDriver *d = chr->opaque;\n\n int idx;\n\n\n\n if (d->mux_cnt >= MAX_MUX) {\n\n fprintf(stderr, \"Cannot add I/O handlers, MUX array is full\\n\");\n\n return;\n\n }\n\n\n\n if (chr->mux_idx == -1) {\n\n chr->mux_idx = d->mux_cnt++;\n\n }\n\n\n\n idx = chr->mux_idx;\n\n d->ext_opaque[idx] = chr->handler_opaque;\n\n d->chr_can_read[idx] = chr->chr_can_read;\n\n d->chr_read[idx] = chr->chr_read;\n\n d->chr_event[idx] = chr->chr_event;\n\n\n\n /* Fix up the real driver with mux routines */\n\n if (d->mux_cnt == 1) {\n\n qemu_chr_add_handlers_full(d->drv, mux_chr_can_read,\n\n mux_chr_read,\n\n mux_chr_event,\n\n chr, context);\n\n }\n\n if (d->focus != -1) {\n\n mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);\n\n }\n\n d->focus = idx;\n\n mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);\n\n}\n", + "output": "1", + "index": 2682 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoull_octal(void)\n\n{\n\n const char *str = \"0123\";\n\n char f = 'X';\n\n const char *endptr = &f;\n\n uint64_t res = 999;\n\n int err;\n\n\n\n err = qemu_strtoull(str, &endptr, 8, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, 0123);\n\n g_assert(endptr == str + strlen(str));\n\n\n\n endptr = &f;\n\n res = 999;\n\n err = qemu_strtoull(str, &endptr, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, 0123);\n\n g_assert(endptr == str + strlen(str));\n\n}\n", + "output": "0", + "index": 14785 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,\n\n DeviceState *dev, Error **errp)\n\n{\n\n sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_dev);\n\n Error *local_err = NULL;\n\n PCDIMMDevice *dimm = PC_DIMM(dev);\n\n PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);\n\n MemoryRegion *mr = ddc->get_memory_region(dimm);\n\n uint64_t size = memory_region_size(mr);\n\n uint32_t nr_lmbs = size / SPAPR_MEMORY_BLOCK_SIZE;\n\n uint64_t addr_start, addr;\n\n int i;\n\n sPAPRDRConnector *drc;\n\n sPAPRDRConnectorClass *drck;\n\n sPAPRDIMMState *ds;\n\n\n\n addr_start = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,\n\n &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n\n\n ds = g_malloc0(sizeof(sPAPRDIMMState));\n\n ds->nr_lmbs = nr_lmbs;\n\n ds->dimm = dimm;\n\n spapr_pending_dimm_unplugs_add(spapr, ds);\n\n\n\n addr = addr_start;\n\n for (i = 0; i < nr_lmbs; i++) {\n\n drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n addr / SPAPR_MEMORY_BLOCK_SIZE);\n\n g_assert(drc);\n\n\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n drck->detach(drc, dev, spapr_lmb_release, NULL, errp);\n\n addr += SPAPR_MEMORY_BLOCK_SIZE;\n\n }\n\n\n\n drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n addr_start / SPAPR_MEMORY_BLOCK_SIZE);\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,\n\n nr_lmbs,\n\n drck->get_index(drc));\n\nout:\n\n error_propagate(errp, local_err);\n\n}\n", + "output": "0", + "index": 598 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_iret_protected(int shift)\n\n{\n\n helper_ret_protected(shift, 1, 0);\n\n}\n", + "output": "0", + "index": 18020 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_can_accept(void)\n\n{\n\n return nb_fds < shared;\n\n}\n", + "output": "1", + "index": 5171 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent)\n\n{\n\n AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev));\n\n AUXSlave *s;\n\n\n\n /* Don't print anything if the device is I2C \"bridge\". */\n\n if (aux_bus_is_bridge(bus, dev)) {\n\n return;\n\n }\n\n\n\n s = AUX_SLAVE(dev);\n\n\n\n monitor_printf(mon, \"%*smemory \" TARGET_FMT_plx \"/\" TARGET_FMT_plx \"\\n\",\n\n indent, \"\",\n\n object_property_get_int(OBJECT(s->mmio), \"addr\", NULL),\n\n memory_region_size(s->mmio));\n\n}\n", + "output": "1", + "index": 13474 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ReadLineState *readline_init(ReadLinePrintfFunc *printf_func,\n\n ReadLineFlushFunc *flush_func,\n\n void *opaque,\n\n ReadLineCompletionFunc *completion_finder)\n\n{\n\n ReadLineState *rs = g_malloc0(sizeof(*rs));\n\n\n\n rs->hist_entry = -1;\n\n rs->opaque = opaque;\n\n rs->printf_func = printf_func;\n\n rs->flush_func = flush_func;\n\n rs->completion_finder = completion_finder;\n\n\n\n return rs;\n\n}\n", + "output": "1", + "index": 4978 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ppc_hash32_pte_update_flags(struct mmu_ctx_hash32 *ctx, target_ulong *pte1p,\n\n int ret, int rw)\n\n{\n\n int store = 0;\n\n\n\n /* Update page flags */\n\n if (!(*pte1p & HPTE32_R_R)) {\n\n /* Update accessed flag */\n\n *pte1p |= HPTE32_R_R;\n\n store = 1;\n\n }\n\n if (!(*pte1p & HPTE32_R_C)) {\n\n if (rw == 1 && ret == 0) {\n\n /* Update changed flag */\n\n *pte1p |= HPTE32_R_C;\n\n store = 1;\n\n } else {\n\n /* Force page fault for first write access */\n\n ctx->prot &= ~PAGE_WRITE;\n\n }\n\n }\n\n\n\n return store;\n\n}\n", + "output": "0", + "index": 19164 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_tco_ticks_counter(void)\n\n{\n\n TestData d;\n\n uint16_t ticks = TCO_SECS_TO_TICKS(8);\n\n uint16_t rld;\n\n\n\n d.args = NULL;\n\n d.noreboot = true;\n\n test_init(&d);\n\n\n\n stop_tco(&d);\n\n clear_tco_status(&d);\n\n reset_on_second_timeout(false);\n\n set_tco_timeout(&d, ticks);\n\n load_tco(&d);\n\n start_tco(&d);\n\n\n\n do {\n\n rld = qpci_io_readw(d.dev, d.tco_io_bar, TCO_RLD) & TCO_RLD_MASK;\n\n g_assert_cmpint(rld, ==, ticks);\n\n clock_step(TCO_TICK_NSEC);\n\n ticks--;\n\n } while (!(qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS) & TCO_TIMEOUT));\n\n\n\n stop_tco(&d);\n\n qtest_end();\n\n}\n", + "output": "1", + "index": 2573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tpm_passthrough_test_tpmdev(int fd)\n\n{\n\n struct tpm_req_hdr req = {\n\n .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),\n\n .len = cpu_to_be32(sizeof(req)),\n\n .ordinal = cpu_to_be32(TPM_ORD_GetTicks),\n\n };\n\n struct tpm_resp_hdr *resp;\n\n fd_set readfds;\n\n int n;\n\n struct timeval tv = {\n\n .tv_sec = 1,\n\n .tv_usec = 0,\n\n };\n\n unsigned char buf[1024];\n\n\n\n n = write(fd, &req, sizeof(req));\n\n if (n < 0) {\n\n return errno;\n\n }\n\n if (n != sizeof(req)) {\n\n return EFAULT;\n\n }\n\n\n\n FD_ZERO(&readfds);\n\n FD_SET(fd, &readfds);\n\n\n\n /* wait for a second */\n\n n = select(fd + 1, &readfds, NULL, NULL, &tv);\n\n if (n != 1) {\n\n return errno;\n\n }\n\n\n\n n = read(fd, &buf, sizeof(buf));\n\n if (n < sizeof(struct tpm_resp_hdr)) {\n\n return EFAULT;\n\n }\n\n\n\n resp = (struct tpm_resp_hdr *)buf;\n\n /* check the header */\n\n if (be16_to_cpu(resp->tag) != TPM_TAG_RSP_COMMAND ||\n\n be32_to_cpu(resp->len) != n) {\n\n return EBADMSG;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 9946 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_interrupt_user(CPUX86State *env, int intno, int is_int,\n\n int error_code, target_ulong next_eip)\n\n{\n\n SegmentCache *dt;\n\n target_ulong ptr;\n\n int dpl, cpl, shift;\n\n uint32_t e2;\n\n\n\n dt = &env->idt;\n\n if (env->hflags & HF_LMA_MASK) {\n\n shift = 4;\n\n } else {\n\n shift = 3;\n\n }\n\n ptr = dt->base + (intno << shift);\n\n e2 = cpu_ldl_kernel(env, ptr + 4);\n\n\n\n dpl = (e2 >> DESC_DPL_SHIFT) & 3;\n\n cpl = env->hflags & HF_CPL_MASK;\n\n /* check privilege if software int */\n\n if (is_int && dpl < cpl) {\n\n raise_exception_err(env, EXCP0D_GPF, (intno << shift) + 2);\n\n }\n\n\n\n /* Since we emulate only user space, we cannot do more than\n\n exiting the emulation with the suitable exception and error\n\n code. So update EIP for INT 0x80 and EXCP_SYSCALL. */\n\n if (is_int || intno == EXCP_SYSCALL) {\n\n env->eip = next_eip;\n\n }\n\n}\n", + "output": "1", + "index": 845 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SYNTH_FILTER_FUNC(sse2)\n\nSYNTH_FILTER_FUNC(avx)\n\nSYNTH_FILTER_FUNC(fma3)\n\n#endif /* HAVE_YASM */\n\n\n\nav_cold void ff_synth_filter_init_x86(SynthFilterContext *s)\n\n{\n\n#if HAVE_YASM\n\n int cpu_flags = av_get_cpu_flags();\n\n\n\n#if ARCH_X86_32\n\n if (EXTERNAL_SSE(cpu_flags)) {\n\n s->synth_filter_float = synth_filter_sse;\n\n }\n\n#endif\n\n if (EXTERNAL_SSE2(cpu_flags)) {\n\n s->synth_filter_float = synth_filter_sse2;\n\n }\n\n if (EXTERNAL_AVX(cpu_flags)) {\n\n s->synth_filter_float = synth_filter_avx;\n\n }\n\n if (EXTERNAL_FMA3(cpu_flags)) {\n\n s->synth_filter_float = synth_filter_fma3;\n\n }\n\n#endif /* HAVE_YASM */\n\n}\n", + "output": "0", + "index": 736 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,\n\n int bytes, uint8_t *_dst, int coeffs)\n\n{\n\n int i, b, c_idx = 0;\n\n int32_t *dst = (int32_t *)_dst;\n\n DiracGolombLUT *future[4], *l = &lut_ctx[2*LUT_SIZE + buf[0]];\n\n INIT_RESIDUE(res, 0, 0);\n\n\n\n#define APPEND_RESIDUE(N, M) \\\n\n N |= M >> (N ## _bits); \\\n\n N ## _bits += (M ## _bits)\n\n\n\n for (b = 1; b <= bytes; b++) {\n\n future[0] = &lut_ctx[buf[b]];\n\n future[1] = future[0] + 1*LUT_SIZE;\n\n future[2] = future[0] + 2*LUT_SIZE;\n\n future[3] = future[0] + 3*LUT_SIZE;\n\n\n\n if ((c_idx + 1) > coeffs)\n\n return c_idx;\n\n\n\n /* res_bits is a hint for better branch prediction */\n\n if (res_bits && l->sign) {\n\n int32_t coeff = 1;\n\n APPEND_RESIDUE(res, l->preamble);\n\n for (i = 0; i < (res_bits >> 1) - 1; i++) {\n\n coeff <<= 1;\n\n coeff |= (res >> (RSIZE_BITS - 2*i - 2)) & 1;\n\n }\n\n dst[c_idx++] = l->sign * (coeff - 1);\n\n res_bits = res = 0;\n\n }\n\n\n\n memcpy(&dst[c_idx], l->ready, LUT_BITS*sizeof(int32_t));\n\n c_idx += l->ready_num;\n\n\n\n APPEND_RESIDUE(res, l->leftover);\n\n\n\n l = future[l->need_s ? 3 : !res_bits ? 2 : res_bits & 1];\n\n }\n\n\n\n return c_idx;\n\n}\n", + "output": "1", + "index": 20869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_physical_memory_write_rom(target_phys_addr_t addr,\n\n const uint8_t *buf, int len)\n\n{\n\n int l;\n\n uint8_t *ptr;\n\n target_phys_addr_t page;\n\n MemoryRegionSection *section;\n\n\n\n while (len > 0) {\n\n page = addr & TARGET_PAGE_MASK;\n\n l = (page + TARGET_PAGE_SIZE) - addr;\n\n if (l > len)\n\n l = len;\n\n section = phys_page_find(page >> TARGET_PAGE_BITS);\n\n\n\n if (!(memory_region_is_ram(section->mr) ||\n\n memory_region_is_romd(section->mr))) {\n\n /* do nothing */\n\n } else {\n\n unsigned long addr1;\n\n addr1 = memory_region_get_ram_addr(section->mr)\n\n + memory_region_section_addr(section, addr);\n\n /* ROM/RAM case */\n\n ptr = qemu_get_ram_ptr(addr1);\n\n memcpy(ptr, buf, l);\n\n\n\n\n\n\n\n\n qemu_put_ram_ptr(ptr);\n\n\n len -= l;\n\n buf += l;\n\n addr += l;\n\n", + "output": "1", + "index": 17197 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void i440fx_update_memory_mappings(PCII440FXState *d)\n\n{\n\n int i, r;\n\n uint32_t smram;\n\n bool smram_enabled;\n\n\n\n memory_region_transaction_begin();\n\n update_pam(d, 0xf0000, 0x100000, (d->dev.config[I440FX_PAM] >> 4) & 3,\n\n &d->pam_regions[0]);\n\n for(i = 0; i < 12; i++) {\n\n r = (d->dev.config[(i >> 1) + (I440FX_PAM + 1)] >> ((i & 1) * 4)) & 3;\n\n update_pam(d, 0xc0000 + 0x4000 * i, 0xc0000 + 0x4000 * (i + 1), r,\n\n &d->pam_regions[i+1]);\n\n }\n\n smram = d->dev.config[I440FX_SMRAM];\n\n smram_enabled = (d->smm_enabled && (smram & 0x08)) || (smram & 0x40);\n\n memory_region_set_enabled(&d->smram_region, !smram_enabled);\n\n memory_region_transaction_commit();\n\n}\n", + "output": "1", + "index": 4360 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)\n\n{\n\n TranslationBlock *tb;\n\n tb = ctx->tb;\n\n if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {\n\n if (n == 0)\n\n gen_op_goto_tb0(TBPARAM(tb));\n\n else\n\n gen_op_goto_tb1(TBPARAM(tb));\n\n gen_op_set_T1(dest);\n\n gen_op_b_T1();\n\n gen_op_set_T0((long)tb + n);\n\n if (ctx->singlestep_enabled)\n\n gen_op_debug();\n\n gen_op_exit_tb();\n\n } else {\n\n gen_op_set_T1(dest);\n\n gen_op_b_T1();\n\n gen_op_reset_T0();\n\n if (ctx->singlestep_enabled)\n\n gen_op_debug();\n\n gen_op_exit_tb();\n\n }\n\n}\n", + "output": "1", + "index": 11232 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)\n\n{\n\n int err;\n\n char *buffer;\n\n char *path = fs_path->data;\n\n\n\n buffer = rpath(fs_ctx, path);\n\n err = lstat(buffer, stbuf);\n\n if (err) {\n\n goto err_out;\n\n }\n\n if (fs_ctx->export_flags & V9FS_SM_MAPPED) {\n\n /* Actual credentials are part of extended attrs */\n\n uid_t tmp_uid;\n\n gid_t tmp_gid;\n\n mode_t tmp_mode;\n\n dev_t tmp_dev;\n\n if (getxattr(buffer, \"user.virtfs.uid\", &tmp_uid, sizeof(uid_t)) > 0) {\n\n stbuf->st_uid = le32_to_cpu(tmp_uid);\n\n }\n\n if (getxattr(buffer, \"user.virtfs.gid\", &tmp_gid, sizeof(gid_t)) > 0) {\n\n stbuf->st_gid = le32_to_cpu(tmp_gid);\n\n }\n\n if (getxattr(buffer, \"user.virtfs.mode\",\n\n &tmp_mode, sizeof(mode_t)) > 0) {\n\n stbuf->st_mode = le32_to_cpu(tmp_mode);\n\n }\n\n if (getxattr(buffer, \"user.virtfs.rdev\", &tmp_dev, sizeof(dev_t)) > 0) {\n\n stbuf->st_rdev = le64_to_cpu(tmp_dev);\n\n }\n\n } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n\n local_mapped_file_attr(fs_ctx, path, stbuf);\n\n }\n\n\n\nerr_out:\n\n g_free(buffer);\n\n return err;\n\n}\n", + "output": "1", + "index": 1741 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "matroska_ebmlnum_uint (uint8_t *data,\n\n uint32_t size,\n\n uint64_t *num)\n\n{\n\n int len_mask = 0x80, read = 1, n = 1, num_ffs = 0;\n\n uint64_t total;\n\n\n\n if (size <= 0)\n\n return AVERROR_INVALIDDATA;\n\n\n\n total = data[0];\n\n while (read <= 8 && !(total & len_mask)) {\n\n read++;\n\n len_mask >>= 1;\n\n }\n\n if (read > 8)\n\n return AVERROR_INVALIDDATA;\n\n\n\n if ((total &= (len_mask - 1)) == len_mask - 1)\n\n num_ffs++;\n\n if (size < read)\n\n return AVERROR_INVALIDDATA;\n\n while (n < read) {\n\n if (data[n] == 0xff)\n\n num_ffs++;\n\n total = (total << 8) | data[n];\n\n n++;\n\n }\n\n\n\n if (!total)\n\n return AVERROR_INVALIDDATA;\n\n\n\n if (read == num_ffs)\n\n *num = (uint64_t)-1;\n\n else\n\n *num = total;\n\n\n\n return read;\n\n}\n", + "output": "0", + "index": 19146 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xvid_strip_vol_header(AVCodecContext *avctx,\n\n AVPacket *pkt,\n\n unsigned int header_len,\n\n unsigned int frame_len) {\n\n int vo_len = 0, i;\n\n\n\n for( i = 0; i < header_len - 3; i++ ) {\n\n if( pkt->data[i] == 0x00 &&\n\n pkt->data[i+1] == 0x00 &&\n\n pkt->data[i+2] == 0x01 &&\n\n pkt->data[i+3] == 0xB6 ) {\n\n vo_len = i;\n\n break;\n\n }\n\n }\n\n\n\n if( vo_len > 0 ) {\n\n /* We need to store the header, so extract it */\n\n if( avctx->extradata == NULL ) {\n\n avctx->extradata = av_malloc(vo_len);\n\n memcpy(avctx->extradata, pkt->data, vo_len);\n\n avctx->extradata_size = vo_len;\n\n }\n\n /* Less dangerous now, memmove properly copies the two\n\n chunks of overlapping data */\n\n memmove(pkt->data, &pkt->data[vo_len], frame_len - vo_len);\n\n pkt->size = frame_len - vo_len;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 19304 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockBackend *blk_new_open(const char *filename, const char *reference,\n\n QDict *options, int flags, Error **errp)\n\n{\n\n BlockBackend *blk;\n\n BlockDriverState *bs;\n\n uint64_t perm;\n\n\n\n /* blk_new_open() is mainly used in .bdrv_create implementations and the\n\n * tools where sharing isn't a concern because the BDS stays private, so we\n\n * just request permission according to the flags.\n\n *\n\n * The exceptions are xen_disk and blockdev_init(); in these cases, the\n\n * caller of blk_new_open() doesn't make use of the permissions, but they\n\n * shouldn't hurt either. We can still share everything here because the\n\n * guest devices will add their own blockers if they can't share. */\n\n perm = BLK_PERM_CONSISTENT_READ;\n\n if (flags & BDRV_O_RDWR) {\n\n perm |= BLK_PERM_WRITE;\n\n }\n\n if (flags & BDRV_O_RESIZE) {\n\n perm |= BLK_PERM_RESIZE;\n\n }\n\n\n\n blk = blk_new(perm, BLK_PERM_ALL);\n\n bs = bdrv_open(filename, reference, options, flags, errp);\n\n if (!bs) {\n\n blk_unref(blk);\n\n return NULL;\n\n }\n\n\n\n blk->root = bdrv_root_attach_child(bs, \"root\", &child_root,\n\n perm, BLK_PERM_ALL, blk, &error_abort);\n\n\n\n return blk;\n\n}\n", + "output": "1", + "index": 2531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,\n\n struct vfio_irq_info info)\n\n{\n\n int ret;\n\n VFIOPlatformDevice *vdev =\n\n container_of(vbasedev, VFIOPlatformDevice, vbasedev);\n\n SysBusDevice *sbdev = SYS_BUS_DEVICE(vdev);\n\n VFIOINTp *intp;\n\n\n\n intp = g_malloc0(sizeof(*intp));\n\n intp->vdev = vdev;\n\n intp->pin = info.index;\n\n intp->flags = info.flags;\n\n intp->state = VFIO_IRQ_INACTIVE;\n\n intp->kvm_accel = false;\n\n\n\n sysbus_init_irq(sbdev, &intp->qemuirq);\n\n\n\n /* Get an eventfd for trigger */\n\n ret = event_notifier_init(&intp->interrupt, 0);\n\n if (ret) {\n\n g_free(intp);\n\n error_report(\"vfio: Error: trigger event_notifier_init failed \");\n\n return NULL;\n\n }\n\n /* Get an eventfd for resample/unmask */\n\n ret = event_notifier_init(&intp->unmask, 0);\n\n if (ret) {\n\n g_free(intp);\n\n error_report(\"vfio: Error: resamplefd event_notifier_init failed\");\n\n return NULL;\n\n }\n\n\n\n QLIST_INSERT_HEAD(&vdev->intp_list, intp, next);\n\n return intp;\n\n}\n", + "output": "0", + "index": 2273 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_start_alternate(Visitor *v, const char *name,\n\n GenericAlternate **obj, size_t size,\n\n bool promote_int, Error **errp)\n\n{\n\n Error *err = NULL;\n\n\n\n assert(obj && size >= sizeof(GenericAlternate));\n\n assert(v->type != VISITOR_OUTPUT || *obj);\n\n if (v->start_alternate) {\n\n v->start_alternate(v, name, obj, size, promote_int, &err);\n\n }\n\n if (v->type == VISITOR_INPUT) {\n\n assert(v->start_alternate && !err != !*obj);\n\n }\n\n error_propagate(errp, err);\n\n}\n", + "output": "1", + "index": 7617 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void release_buffer(AVCodecContext *avctx, AVFrame *pic)\n\n{\n\n int i;\n\n\n\n CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3];\n\n CVPixelBufferUnlockBaseAddress(cv_buffer, 0);\n\n CVPixelBufferRelease(cv_buffer);\n\n\n\n for (i = 0; i < 4; i++)\n\n pic->data[i] = NULL;\n\n}\n", + "output": "1", + "index": 26524 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_mov_v_reg(int ot, TCGv t0, int reg)\n\n{\n\n switch(ot) {\n\n case OT_BYTE:\n\n if (reg < 4 X86_64_DEF( || reg >= 8 || x86_64_hregs)) {\n\n goto std_case;\n\n } else {\n\n tcg_gen_shri_tl(t0, cpu_regs[reg - 4], 8);\n\n tcg_gen_ext8u_tl(t0, t0);\n\n }\n\n break;\n\n default:\n\n std_case:\n\n tcg_gen_mov_tl(t0, cpu_regs[reg]);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 2895 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn bdrv_co_do_readv(BdrvChild *child,\n\n int64_t sector_num, int nb_sectors, QEMUIOVector *qiov,\n\n BdrvRequestFlags flags)\n\n{\n\n if (nb_sectors < 0 || nb_sectors > BDRV_REQUEST_MAX_SECTORS) {\n\n return -EINVAL;\n\n }\n\n\n\n return bdrv_co_preadv(child->bs, sector_num << BDRV_SECTOR_BITS,\n\n nb_sectors << BDRV_SECTOR_BITS, qiov, flags);\n\n}\n", + "output": "0", + "index": 23405 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf)\n\n{\n\n int dy = y1 - y0;\n\n int adx = x1 - x0;\n\n int ady = FFABS(dy);\n\n int sy = dy < 0 ? -1 : 1;\n\n buf[x0] = ff_vorbis_floor1_inverse_db_table[y0];\n\n if (ady*2 <= adx) { // optimized common case\n\n render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);\n\n } else {\n\n int base = dy / adx;\n\n int x = x0;\n\n uint8_t y = y0;\n\n int err = -adx;\n\n ady -= FFABS(base) * adx;\n\n while (++x < x1) {\n\n y += base;\n\n err += ady;\n\n if (err >= 0) {\n\n err -= adx;\n\n y += sy;\n\n }\n\n buf[x] = ff_vorbis_floor1_inverse_db_table[y];\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 25729 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_savevm_state(QEMUFile *f)\n\n{\n\n SaveStateEntry *se;\n\n int len, ret;\n\n int64_t cur_pos, len_pos, total_len_pos;\n\n\n\n qemu_put_be32(f, QEMU_VM_FILE_MAGIC);\n\n qemu_put_be32(f, QEMU_VM_FILE_VERSION);\n\n total_len_pos = qemu_ftell(f);\n\n qemu_put_be64(f, 0); /* total size */\n\n\n\n for(se = first_se; se != NULL; se = se->next) {\n\n\tif (se->save_state == NULL)\n\n\t /* this one has a loader only, for backwards compatibility */\n\n\t continue;\n\n\n\n /* ID string */\n\n len = strlen(se->idstr);\n\n qemu_put_byte(f, len);\n\n qemu_put_buffer(f, (uint8_t *)se->idstr, len);\n\n\n\n qemu_put_be32(f, se->instance_id);\n\n qemu_put_be32(f, se->version_id);\n\n\n\n /* record size: filled later */\n\n len_pos = qemu_ftell(f);\n\n qemu_put_be32(f, 0);\n\n se->save_state(f, se->opaque);\n\n\n\n /* fill record size */\n\n cur_pos = qemu_ftell(f);\n\n len = cur_pos - len_pos - 4;\n\n qemu_fseek(f, len_pos, SEEK_SET);\n\n qemu_put_be32(f, len);\n\n qemu_fseek(f, cur_pos, SEEK_SET);\n\n }\n\n cur_pos = qemu_ftell(f);\n\n qemu_fseek(f, total_len_pos, SEEK_SET);\n\n qemu_put_be64(f, cur_pos - total_len_pos - 8);\n\n qemu_fseek(f, cur_pos, SEEK_SET);\n\n\n\n ret = 0;\n\n return ret;\n\n}\n", + "output": "1", + "index": 7303 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_mjpeg_encode_stuffing(MpegEncContext *s)\n\n{\n\n int i;\n\n PutBitContext *pbc = &s->pb;\n\n int mb_y = s->mb_y - !s->mb_x;\n\n int ret;\n\n MJpegContext *m;\n\n\n\n m = s->mjpeg_ctx;\n\n\n\n if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {\n\n ff_mjpeg_build_optimal_huffman(m);\n\n\n\n // Replace the VLCs with the optimal ones.\n\n // The default ones may be used for trellis during quantization.\n\n ff_init_uni_ac_vlc(m->huff_size_ac_luminance, m->uni_ac_vlc_len);\n\n ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);\n\n s->intra_ac_vlc_length =\n\n s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;\n\n s->intra_chroma_ac_vlc_length =\n\n s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len;\n\n }\n\n\n\n ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,\n\n s->pred, s->intra_matrix, s->chroma_intra_matrix);\n\n ff_mjpeg_encode_picture_frame(s);\n\n\n\n ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,\n\n put_bits_count(&s->pb) / 4 + 1000);\n\n\n\n if (ret < 0) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"Buffer reallocation failed\\n\");\n\n goto fail;\n\n }\n\n\n\n ff_mjpeg_escape_FF(pbc, s->esc_pos);\n\n\n\n if((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height)\n\n put_marker(pbc, RST0 + (mb_y&7));\n\n s->esc_pos = put_bits_count(pbc) >> 3;\n\nfail:\n\n\n\n for(i=0; i<3; i++)\n\n s->last_dc[i] = 128 << s->intra_dc_precision;\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 15332 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool aio_epoll_check_poll(AioContext *ctx, GPollFD *pfds,\n\n unsigned npfd, int64_t timeout)\n\n{\n\n return false;\n\n}\n", + "output": "0", + "index": 25519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_balloon_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);\n\n\n\n k->init = virtio_balloon_init_pci;\n\n k->exit = virtio_balloon_exit_pci;\n\n k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;\n\n k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON;\n\n k->revision = VIRTIO_PCI_ABI_VERSION;\n\n k->class_id = PCI_CLASS_MEMORY_RAM;\n\n dc->alias = \"virtio-balloon\";\n\n dc->reset = virtio_pci_reset;\n\n dc->props = virtio_balloon_properties;\n\n}\n", + "output": "0", + "index": 105 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)\n\n{\n\n int64_t size;\n\n AVIOContext *pb = s->pb;\n\n WAVContext *wav = s->priv_data;\n\n AVStream *st;\n\n uint8_t guid[16];\n\n\n\n avio_read(pb, guid, 16);\n\n if (memcmp(guid, guid_riff, 16))\n\n return -1;\n\n\n\n if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */\n\n return -1;\n\n\n\n avio_read(pb, guid, 16);\n\n if (memcmp(guid, guid_wave, 16)) {\n\n av_log(s, AV_LOG_ERROR, \"could not find wave guid\\n\");\n\n return -1;\n\n }\n\n\n\n size = find_guid(pb, guid_fmt);\n\n if (size < 0) {\n\n av_log(s, AV_LOG_ERROR, \"could not find fmt guid\\n\");\n\n return -1;\n\n }\n\n\n\n st = av_new_stream(s, 0);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n /* subtract chunk header size - normal wav file doesn't count it */\n\n ff_get_wav_header(pb, st->codec, size - 24);\n\n avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);\n\n\n\n st->need_parsing = AVSTREAM_PARSE_FULL;\n\n\n\n av_set_pts_info(st, 64, 1, st->codec->sample_rate);\n\n\n\n size = find_guid(pb, guid_data);\n\n if (size < 0) {\n\n av_log(s, AV_LOG_ERROR, \"could not find data guid\\n\");\n\n return -1;\n\n }\n\n wav->data_end = avio_tell(pb) + size - 24;\n\n wav->w64 = 1;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 25868 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "TCGv_i64 tcg_global_reg_new_i64(int reg, const char *name)\n\n{\n\n int idx;\n\n\n\n idx = tcg_global_reg_new_internal(TCG_TYPE_I64, reg, name);\n\n return MAKE_TCGV_I64(idx);\n\n}\n", + "output": "0", + "index": 24308 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tlb_info_pae32(Monitor *mon, CPUState *env)\n\n{\n\n int l1, l2, l3;\n\n uint64_t pdpe, pde, pte;\n\n uint64_t pdp_addr, pd_addr, pt_addr;\n\n\n\n pdp_addr = env->cr[3] & ~0x1f;\n\n for (l1 = 0; l1 < 4; l1++) {\n\n cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);\n\n pdpe = le64_to_cpu(pdpe);\n\n if (pdpe & PG_PRESENT_MASK) {\n\n pd_addr = pdpe & 0x3fffffffff000ULL;\n\n for (l2 = 0; l2 < 512; l2++) {\n\n cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);\n\n pde = le64_to_cpu(pde);\n\n if (pde & PG_PRESENT_MASK) {\n\n if (pde & PG_PSE_MASK) {\n\n /* 2M pages with PAE, CR4.PSE is ignored */\n\n print_pte(mon, (l1 << 30 ) + (l2 << 21), pde,\n\n ~((target_phys_addr_t)(1 << 20) - 1));\n\n } else {\n\n pt_addr = pde & 0x3fffffffff000ULL;\n\n for (l3 = 0; l3 < 512; l3++) {\n\n cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);\n\n pte = le64_to_cpu(pte);\n\n if (pte & PG_PRESENT_MASK) {\n\n print_pte(mon, (l1 << 30 ) + (l2 << 21)\n\n + (l3 << 12),\n\n pte & ~PG_PSE_MASK,\n\n ~(target_phys_addr_t)0xfff);\n\n }\n\n }\n\n }\n\n }\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 7388 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void load_seg(int seg_reg, int selector)\n\n{\n\n SegmentCache *sc;\n\n SegmentDescriptorTable *dt;\n\n int index;\n\n uint32_t e1, e2;\n\n uint8_t *ptr;\n\n\n\n env->segs[seg_reg] = selector;\n\n sc = &env->seg_cache[seg_reg];\n\n if (env->eflags & VM_MASK) {\n\n sc->base = (void *)(selector << 4);\n\n sc->limit = 0xffff;\n\n sc->seg_32bit = 0;\n\n } else {\n\n if (selector & 0x4)\n\n dt = &env->ldt;\n\n else\n\n dt = &env->gdt;\n\n index = selector & ~7;\n\n if ((index + 7) > dt->limit)\n\n raise_exception_err(EXCP0D_GPF, selector);\n\n ptr = dt->base + index;\n\n e1 = ldl(ptr);\n\n e2 = ldl(ptr + 4);\n\n sc->base = (void *)((e1 >> 16) | ((e2 & 0xff) << 16) | (e2 & 0xff000000));\n\n sc->limit = (e1 & 0xffff) | (e2 & 0x000f0000);\n\n if (e2 & (1 << 23))\n\n sc->limit = (sc->limit << 12) | 0xfff;\n\n sc->seg_32bit = (e2 >> 22) & 1;\n\n#if 0\n\n fprintf(logfile, \"load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx seg_32bit=%d\\n\", \n\n selector, (unsigned long)sc->base, sc->limit, sc->seg_32bit);\n\n#endif\n\n }\n\n}\n", + "output": "0", + "index": 21724 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void uuid_generate(uuid_t out)\n\n{\n\n memset(out, 0, sizeof(uuid_t));\n\n}\n", + "output": "0", + "index": 3844 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags)\n\n{\n\n BlockDriverState *bs;\n\n int ret;\n\n\n\n bs = bdrv_new(\"\");\n\n if (!bs)\n\n return -ENOMEM;\n\n ret = bdrv_open2(bs, filename, flags | BDRV_O_FILE, NULL);\n\n if (ret < 0) {\n\n bdrv_delete(bs);\n\n return ret;\n\n }\n\n\n *pbs = bs;\n\n return 0;\n\n}", + "output": "1", + "index": 13987 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_strtox_error(const char **next, char *endptr,\n\n int err)\n\n{\n\n if (!next && *endptr) {\n\n return -EINVAL;\n\n }\n\n if (next) {\n\n *next = endptr;\n\n }\n\n return -err;\n\n}\n", + "output": "1", + "index": 12819 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_mpv_frame_end(MpegEncContext *s)\n\n{\n\n#if FF_API_XVMC\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n /* redraw edges for the frame if decoding didn't complete */\n\n // just to make sure that all data is rendered.\n\n if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) {\n\n ff_xvmc_field_end(s);\n\n } else\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif /* FF_API_XVMC */\n\n\n\n emms_c();\n\n\n\n if (s->current_picture.reference)\n\n ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);\n\n}\n", + "output": "0", + "index": 6140 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ram_find_and_save_block(RAMState *rs, bool last_stage)\n\n{\n\n PageSearchStatus pss;\n\n int pages = 0;\n\n bool again, found;\n\n ram_addr_t dirty_ram_abs; /* Address of the start of the dirty page in\n\n ram_addr_t space */\n\n\n\n /* No dirty page as there is zero RAM */\n\n if (!ram_bytes_total()) {\n\n return pages;\n\n }\n\n\n\n pss.block = rs->last_seen_block;\n\n pss.offset = rs->last_offset;\n\n pss.complete_round = false;\n\n\n\n if (!pss.block) {\n\n pss.block = QLIST_FIRST_RCU(&ram_list.blocks);\n\n }\n\n\n\n do {\n\n again = true;\n\n found = get_queued_page(rs, &pss, &dirty_ram_abs);\n\n\n\n if (!found) {\n\n /* priority queue empty, so just search for something dirty */\n\n found = find_dirty_block(rs, &pss, &again, &dirty_ram_abs);\n\n }\n\n\n\n if (found) {\n\n pages = ram_save_host_page(rs, &pss, last_stage, dirty_ram_abs);\n\n }\n\n } while (!pages && again);\n\n\n\n rs->last_seen_block = pss.block;\n\n rs->last_offset = pss.offset;\n\n\n\n return pages;\n\n}\n", + "output": "1", + "index": 17762 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_timedate_diff(struct tm *tm)\n\n{\n\n time_t seconds;\n\n\n\n if (rtc_date_offset == -1)\n\n if (rtc_utc)\n\n seconds = mktimegm(tm);\n\n else {\n\n struct tm tmp = *tm;\n\n tmp.tm_isdst = -1; /* use timezone to figure it out */\n\n seconds = mktime(&tmp);\n\n\t}\n\n else\n\n seconds = mktimegm(tm) + rtc_date_offset;\n\n\n\n return seconds - time(NULL);\n\n}\n", + "output": "0", + "index": 2875 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fd_revalidate(FDrive *drv)\n\n{\n\n int rc;\n\n\n\n FLOPPY_DPRINTF(\"revalidate\\n\");\n\n if (drv->blk != NULL) {\n\n drv->ro = blk_is_read_only(drv->blk);\n\n if (!blk_is_inserted(drv->blk)) {\n\n FLOPPY_DPRINTF(\"No disk in drive\\n\");\n\n drv->disk = FLOPPY_DRIVE_TYPE_NONE;\n\n\n } else if (!drv->media_validated) {\n\n rc = pick_geometry(drv);\n\n if (rc) {\n\n FLOPPY_DPRINTF(\"Could not validate floppy drive media\");\n\n } else {\n\n drv->media_validated = true;\n\n FLOPPY_DPRINTF(\"Floppy disk (%d h %d t %d s) %s\\n\",\n\n (drv->flags & FDISK_DBL_SIDES) ? 2 : 1,\n\n drv->max_track, drv->last_sect,\n\n drv->ro ? \"ro\" : \"rw\");\n\n }\n\n }\n\n } else {\n\n FLOPPY_DPRINTF(\"No drive connected\\n\");\n\n drv->last_sect = 0;\n\n drv->max_track = 0;\n\n drv->flags &= ~FDISK_DBL_SIDES;\n\n drv->drive = FLOPPY_DRIVE_TYPE_NONE;\n\n drv->disk = FLOPPY_DRIVE_TYPE_NONE;\n\n }\n\n}", + "output": "1", + "index": 7145 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)\n\n{\n\n AVStream *st = c->fc->streams[c->fc->nb_streams-1];\n\n MOVStreamContext *sc = st->priv_data;\n\n unsigned int i, entries;\n\n int64_t duration=0;\n\n int64_t total_sample_count=0;\n\n\n\n get_byte(pb); /* version */\n\n get_be24(pb); /* flags */\n\n entries = get_be32(pb);\n\n\n\n dprintf(c->fc, \"track[%i].stts.entries = %i\\n\", c->fc->nb_streams-1, entries);\n\n\n\n if(entries >= UINT_MAX / sizeof(*sc->stts_data))\n\n return -1;\n\n sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));\n\n if (!sc->stts_data)\n\n return AVERROR(ENOMEM);\n\n sc->stts_count = entries;\n\n\n\n for(i=0; istts_data[i].count= sample_count;\n\n sc->stts_data[i].duration= sample_duration;\n\n\n\n dprintf(c->fc, \"sample_count=%d, sample_duration=%d\\n\",sample_count,sample_duration);\n\n\n\n duration+=(int64_t)sample_duration*sample_count;\n\n total_sample_count+=sample_count;\n\n }\n\n\n\n st->nb_frames= total_sample_count;\n\n if(duration)\n\n st->duration= duration;\n\n return 0;\n\n}\n", + "output": "0", + "index": 25703 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int mpeg4_is_resync(MpegEncContext *s){\n\n const int bits_count= get_bits_count(&s->gb);\n\n \n\n if(s->workaround_bugs&FF_BUG_NO_PADDING){\n\n return 0;\n\n }\n\n\n\n if(bits_count + 8 >= s->gb.size*8){\n\n int v= show_bits(&s->gb, 8);\n\n v|= 0x7F >> (7-(bits_count&7));\n\n \n\n if(v==0x7F)\n\n return 1;\n\n }else{\n\n if(show_bits(&s->gb, 16) == ff_mpeg4_resync_prefix[bits_count&7]){\n\n int len;\n\n GetBitContext gb= s->gb;\n\n \n\n skip_bits(&s->gb, 1);\n\n align_get_bits(&s->gb);\n\n \n\n for(len=0; len<32; len++){\n\n if(get_bits1(&s->gb)) break;\n\n }\n\n\n\n s->gb= gb;\n\n\n\n if(len>=ff_mpeg4_get_video_packet_prefix_length(s))\n\n return 1;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 20416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)\n\n{\n\n int ret;\n\n\n\n av_assert0(!dst->f.buf[0]);\n\n av_assert0(src->f.buf[0]);\n\n\n\n src->tf.f = &src->f;\n\n dst->tf.f = &dst->f;\n\n ret = ff_thread_ref_frame(&dst->tf, &src->tf);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n ret = update_picture_tables(dst, src);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n if (src->hwaccel_picture_private) {\n\n dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);\n\n if (!dst->hwaccel_priv_buf)\n\n goto fail;\n\n dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;\n\n }\n\n\n\n dst->field_picture = src->field_picture;\n\n dst->mb_var_sum = src->mb_var_sum;\n\n dst->mc_mb_var_sum = src->mc_mb_var_sum;\n\n dst->b_frame_score = src->b_frame_score;\n\n dst->needs_realloc = src->needs_realloc;\n\n dst->reference = src->reference;\n\n dst->shared = src->shared;\n\n\n\n return 0;\n\nfail:\n\n ff_mpeg_unref_picture(s, dst);\n\n return ret;\n\n}\n", + "output": "1", + "index": 2768 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_create(const char *filename, QEMUOptionParameter *options)\n\n{\n\n const char *backing_file = NULL;\n\n const char *backing_fmt = NULL;\n\n uint64_t sectors = 0;\n\n int flags = 0;\n\n size_t cluster_size = DEFAULT_CLUSTER_SIZE;\n\n int prealloc = 0;\n\n\n\n /* Read out options */\n\n while (options && options->name) {\n\n if (!strcmp(options->name, BLOCK_OPT_SIZE)) {\n\n sectors = options->value.n / 512;\n\n } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {\n\n backing_file = options->value.s;\n\n } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) {\n\n backing_fmt = options->value.s;\n\n } else if (!strcmp(options->name, BLOCK_OPT_ENCRYPT)) {\n\n flags |= options->value.n ? BLOCK_FLAG_ENCRYPT : 0;\n\n } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {\n\n if (options->value.n) {\n\n cluster_size = options->value.n;\n\n }\n\n } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) {\n\n if (!options->value.s || !strcmp(options->value.s, \"off\")) {\n\n prealloc = 0;\n\n } else if (!strcmp(options->value.s, \"metadata\")) {\n\n prealloc = 1;\n\n } else {\n\n fprintf(stderr, \"Invalid preallocation mode: '%s'\\n\",\n\n options->value.s);\n\n return -EINVAL;\n\n }\n\n }\n\n options++;\n\n }\n\n\n\n if (backing_file && prealloc) {\n\n fprintf(stderr, \"Backing file and preallocation cannot be used at \"\n\n \"the same time\\n\");\n\n return -EINVAL;\n\n }\n\n\n\n return qcow2_create2(filename, sectors, backing_file, backing_fmt, flags,\n\n cluster_size, prealloc, options);\n\n}\n", + "output": "0", + "index": 877 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int encode_close(AVCodecContext *avctx)\n\n{\n\n av_frame_free(&avctx->coded_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 16412 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void block_job_complete(BlockJob *job, Error **errp)\n\n{\n\n if (job->paused || job->cancelled || !job->driver->complete) {\n\n error_set(errp, QERR_BLOCK_JOB_NOT_READY,\n\n bdrv_get_device_name(job->bs));\n\n return;\n\n }\n\n\n\n job->driver->complete(job, errp);\n\n}\n", + "output": "0", + "index": 22108 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)\n\n{\n\n Mpeg1Context *s1 = avctx->priv_data;\n\n MpegEncContext *s = &s1->mpeg_enc_ctx;\n\n const enum AVPixelFormat *pix_fmts;\n\n\n\n#if FF_API_XVMC\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n if (avctx->xvmc_acceleration)\n\n return ff_get_format(avctx, pixfmt_xvmc_mpg2_420);\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif /* FF_API_XVMC */\n\n\n\n if (s->chroma_format < 2)\n\n pix_fmts = mpeg12_hwaccel_pixfmt_list_420;\n\n else if (s->chroma_format == 2)\n\n pix_fmts = mpeg12_pixfmt_list_422;\n\n else\n\n pix_fmts = mpeg12_pixfmt_list_444;\n\n\n\n return ff_get_format(avctx, pix_fmts);\n\n}\n", + "output": "0", + "index": 9823 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void write_dump_header(DumpState *s, Error **errp)\n\n{\n\n Error *local_err = NULL;\n\n\n\n if (s->dump_info.d_class == ELFCLASS32) {\n\n create_header32(s, &local_err);\n\n } else {\n\n create_header64(s, &local_err);\n\n }\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n }\n\n}\n", + "output": "0", + "index": 23748 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)\n\n{\n\n VideoState *is = opaque;\n\n int audio_size, len1, silence = 0;\n\n\n\n audio_callback_time = av_gettime_relative();\n\n\n\n while (len > 0) {\n\n if (is->audio_buf_index >= is->audio_buf_size) {\n\n audio_size = audio_decode_frame(is);\n\n if (audio_size < 0) {\n\n /* if error, just output silence */\n\n silence = 1;\n\n is->audio_buf_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_tgt.frame_size * is->audio_tgt.frame_size;\n\n } else {\n\n if (is->show_mode != SHOW_MODE_VIDEO)\n\n update_sample_display(is, (int16_t *)is->audio_buf, audio_size);\n\n is->audio_buf_size = audio_size;\n\n }\n\n is->audio_buf_index = 0;\n\n }\n\n len1 = is->audio_buf_size - is->audio_buf_index;\n\n if (len1 > len)\n\n len1 = len;\n\n if (!is->muted && !silence && is->audio_volume == SDL_MIX_MAXVOLUME)\n\n memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);\n\n else {\n\n memset(stream, 0, len1);\n\n if (!is->muted && !silence)\n\n SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);\n\n }\n\n len -= len1;\n\n stream += len1;\n\n is->audio_buf_index += len1;\n\n }\n\n is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;\n\n /* Let's assume the audio driver that is used by SDL has two periods. */\n\n if (!isnan(is->audio_clock)) {\n\n set_clock_at(&is->audclk, is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / is->audio_tgt.bytes_per_sec, is->audio_clock_serial, audio_callback_time / 1000000.0);\n\n sync_clock_to_slave(&is->extclk, &is->audclk);\n\n }\n\n}\n", + "output": "1", + "index": 3133 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilter **av_filter_next(AVFilter **filter)\n\n{\n\n return filter ? ++filter : ®istered_avfilters[0];\n\n}\n", + "output": "0", + "index": 22344 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_dynamic_globalprop(void)\n\n{\n\n MyType *mt;\n\n static GlobalProperty props[] = {\n\n { TYPE_DYNAMIC_PROPS, \"prop1\", \"101\" },\n\n { TYPE_DYNAMIC_PROPS, \"prop2\", \"102\" },\n\n { TYPE_DYNAMIC_PROPS\"-bad\", \"prop3\", \"103\", true },\n\n {}\n\n };\n\n int all_used;\n\n\n\n qdev_prop_register_global_list(props);\n\n\n\n mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));\n\n qdev_init_nofail(DEVICE(mt));\n\n\n\n g_assert_cmpuint(mt->prop1, ==, 101);\n\n g_assert_cmpuint(mt->prop2, ==, 102);\n\n\n\n}", + "output": "1", + "index": 19649 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,\n\n uint16_t *y_list, int *flag,\n\n int multiplier, float *out, int samples)\n\n{\n\n int lx, ly, i;\n\n lx = 0;\n\n ly = y_list[0] * multiplier;\n\n for (i = 1; i < values; i++) {\n\n int pos = list[i].sort;\n\n if (flag[pos]) {\n\n int x1 = list[pos].x;\n\n int y1 = y_list[pos] * multiplier;\n\n if (lx < samples)\n\n render_line(lx, ly, FFMIN(x1,samples), y1, out);\n\n lx = x1;\n\n ly = y1;\n\n }\n\n if (lx >= samples)\n\n break;\n\n }\n\n if (lx < samples)\n\n render_line(lx, ly, samples, ly, out);\n\n}\n", + "output": "1", + "index": 19467 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift,\n\n Error **errp)\n\n{\n\n long rc;\n\n\n\n /* Clean up any HPT info from a previous boot */\n\n g_free(spapr->htab);\n\n spapr->htab = NULL;\n\n spapr->htab_shift = 0;\n\n close_htab_fd(spapr);\n\n\n\n rc = kvmppc_reset_htab(shift);\n\n if (rc < 0) {\n\n /* kernel-side HPT needed, but couldn't allocate one */\n\n error_setg_errno(errp, errno,\n\n \"Failed to allocate KVM HPT of order %d (try smaller maxmem?)\",\n\n shift);\n\n /* This is almost certainly fatal, but if the caller really\n\n * wants to carry on with shift == 0, it's welcome to try */\n\n } else if (rc > 0) {\n\n /* kernel-side HPT allocated */\n\n if (rc != shift) {\n\n error_setg(errp,\n\n \"Requested order %d HPT, but kernel allocated order %ld (try smaller maxmem?)\",\n\n shift, rc);\n\n }\n\n\n\n spapr->htab_shift = shift;\n\n kvmppc_kern_htab = true;\n\n } else {\n\n /* kernel-side HPT not needed, allocate in userspace instead */\n\n size_t size = 1ULL << shift;\n\n int i;\n\n\n\n spapr->htab = qemu_memalign(size, size);\n\n if (!spapr->htab) {\n\n error_setg_errno(errp, errno,\n\n \"Could not allocate HPT of order %d\", shift);\n\n return;\n\n }\n\n\n\n memset(spapr->htab, 0, size);\n\n spapr->htab_shift = shift;\n\n kvmppc_kern_htab = false;\n\n\n\n for (i = 0; i < size / HASH_PTE_SIZE_64; i++) {\n\n DIRTY_HPTE(HPTE(spapr->htab, i));\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 18025 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint32_t efsctsiz(uint32_t val)\n\n{\n\n CPU_FloatU u;\n\n\n\n u.l = val;\n\n /* NaN are not treated the same way IEEE 754 does */\n\n if (unlikely(float32_is_nan(u.f)))\n\n return 0;\n\n\n\n return float32_to_int32_round_to_zero(u.f, &env->vec_status);\n\n}\n", + "output": "0", + "index": 1098 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xhci_runtime_write(void *ptr, hwaddr reg,\n\n uint64_t val, unsigned size)\n\n{\n\n XHCIState *xhci = ptr;\n\n int v = (reg - 0x20) / 0x20;\n\n XHCIInterrupter *intr = &xhci->intr[v];\n\n trace_usb_xhci_runtime_write(reg, val);\n\n\n\n if (reg < 0x20) {\n\n trace_usb_xhci_unimplemented(\"runtime write\", reg);\n\n return;\n\n\n\n\n switch (reg & 0x1f) {\n\n case 0x00: /* IMAN */\n\n if (val & IMAN_IP) {\n\n intr->iman &= ~IMAN_IP;\n\n\n intr->iman &= ~IMAN_IE;\n\n intr->iman |= val & IMAN_IE;\n\n if (v == 0) {\n\n xhci_intx_update(xhci);\n\n\n xhci_msix_update(xhci, v);\n\n break;\n\n case 0x04: /* IMOD */\n\n intr->imod = val;\n\n break;\n\n case 0x08: /* ERSTSZ */\n\n intr->erstsz = val & 0xffff;\n\n break;\n\n case 0x10: /* ERSTBA low */\n\n /* XXX NEC driver bug: it doesn't align this to 64 bytes\n\n intr->erstba_low = val & 0xffffffc0; */\n\n intr->erstba_low = val & 0xfffffff0;\n\n break;\n\n case 0x14: /* ERSTBA high */\n\n intr->erstba_high = val;\n\n xhci_er_reset(xhci, v);\n\n break;\n\n case 0x18: /* ERDP low */\n\n\n intr->erdp_low &= ~ERDP_EHB;\n\n\n intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);\n\n\n\n\n\n\n\n\n\n\n break;\n\n case 0x1c: /* ERDP high */\n\n intr->erdp_high = val;\n\n xhci_events_update(xhci, v);\n\n break;\n\n default:\n\n trace_usb_xhci_unimplemented(\"oper write\", reg);\n\n", + "output": "1", + "index": 10402 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int op_to_movi(int op)\n\n{\n\n switch (op_bits(op)) {\n\n case 32:\n\n return INDEX_op_movi_i32;\n\n#if TCG_TARGET_REG_BITS == 64\n\n case 64:\n\n return INDEX_op_movi_i64;\n\n#endif\n\n default:\n\n fprintf(stderr, \"op_to_movi: unexpected return value of \"\n\n \"function op_bits.\\n\");\n\n tcg_abort();\n\n }\n\n}\n", + "output": "0", + "index": 21546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int pcx_end(AVCodecContext *avctx) {\n\n PCXContext *s = avctx->priv_data;\n\n\n\n if(s->picture.data[0])\n\n avctx->release_buffer(avctx, &s->picture);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 19735 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num,\n\n int nb_sectors, int *pnum)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int index_in_cluster, n;\n\n uint64_t cluster_offset;\n\n\n\n cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);\n\n index_in_cluster = sector_num & (s->cluster_sectors - 1);\n\n n = s->cluster_sectors - index_in_cluster;\n\n if (n > nb_sectors)\n\n n = nb_sectors;\n\n *pnum = n;\n\n return (cluster_offset != 0);\n\n}\n", + "output": "0", + "index": 21317 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_put_group(VFIOGroup *group)\n\n{\n\n if (!QLIST_EMPTY(&group->device_list)) {\n\n return;\n\n }\n\n\n\n vfio_kvm_device_del_group(group);\n\n vfio_disconnect_container(group);\n\n QLIST_REMOVE(group, next);\n\n trace_vfio_put_group(group->fd);\n\n close(group->fd);\n\n g_free(group);\n\n\n\n if (QLIST_EMPTY(&group_list)) {\n\n qemu_unregister_reset(vfio_pci_reset_handler, NULL);\n\n }\n\n}\n", + "output": "0", + "index": 13376 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t get_pts(const char **buf, int *duration,\n\n int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2)\n\n{\n\n int i;\n\n\n\n for (i=0; i<2; i++) {\n\n int hh1, mm1, ss1, ms1;\n\n int hh2, mm2, ss2, ms2;\n\n if (sscanf(*buf, \"%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d\"\n\n \"%*[ ]X1:%u X2:%u Y1:%u Y2:%u\",\n\n &hh1, &mm1, &ss1, &ms1,\n\n &hh2, &mm2, &ss2, &ms2,\n\n x1, x2, y1, y2) >= 8) {\n\n int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1;\n\n int64_t end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2;\n\n *duration = end - start;\n\n *buf += strcspn(*buf, \"\\n\") + 1;\n\n return start;\n\n }\n\n *buf += strcspn(*buf, \"\\n\") + 1;\n\n }\n\n return AV_NOPTS_VALUE;\n\n}\n", + "output": "1", + "index": 7526 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)\n\n{\n\n h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta);\n\n}\n", + "output": "0", + "index": 24977 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)\n\n{\n\n struct kvm_create_spapr_tce args = {\n\n .liobn = liobn,\n\n .window_size = window_size,\n\n };\n\n long len;\n\n int fd;\n\n void *table;\n\n\n\n /* Must set fd to -1 so we don't try to munmap when called for\n\n * destroying the table, which the upper layers -will- do\n\n */\n\n *pfd = -1;\n\n if (!cap_spapr_tce) {\n\n return NULL;\n\n }\n\n\n\n fd = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &args);\n\n if (fd < 0) {\n\n fprintf(stderr, \"KVM: Failed to create TCE table for liobn 0x%x\\n\",\n\n liobn);\n\n return NULL;\n\n }\n\n\n\n len = (window_size / SPAPR_TCE_PAGE_SIZE) * sizeof(sPAPRTCE);\n\n /* FIXME: round this up to page size */\n\n\n\n table = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);\n\n if (table == MAP_FAILED) {\n\n fprintf(stderr, \"KVM: Failed to map TCE table for liobn 0x%x\\n\",\n\n liobn);\n\n close(fd);\n\n return NULL;\n\n }\n\n\n\n *pfd = fd;\n\n return table;\n\n}\n", + "output": "0", + "index": 9799 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tgen_ext8u(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)\n\n{\n\n if (facilities & FACILITY_EXT_IMM) {\n\n tcg_out_insn(s, RRE, LLGCR, dest, src);\n\n return;\n\n }\n\n\n\n if (dest == src) {\n\n tcg_out_movi(s, type, TCG_TMP0, 0xff);\n\n src = TCG_TMP0;\n\n } else {\n\n tcg_out_movi(s, type, dest, 0xff);\n\n }\n\n if (type == TCG_TYPE_I32) {\n\n tcg_out_insn(s, RR, NR, dest, src);\n\n } else {\n\n tcg_out_insn(s, RRE, NGR, dest, src);\n\n }\n\n}\n", + "output": "0", + "index": 15026 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)\n\n{\n\n sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));\n\n sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));\n\n size_t size = object_type_get_instance_size(scc->cpu_type);\n\n CPUCore *cc = CPU_CORE(dev);\n\n int i;\n\n\n\n for (i = 0; i < cc->nr_threads; i++) {\n\n void *obj = sc->threads + i * size;\n\n DeviceState *dev = DEVICE(obj);\n\n CPUState *cs = CPU(dev);\n\n PowerPCCPU *cpu = POWERPC_CPU(cs);\n\n\n\n spapr_cpu_destroy(cpu);\n\n object_unparent(cpu->intc);\n\n cpu_remove_sync(cs);\n\n object_unparent(obj);\n\n }\n\n g_free(sc->threads);\n\n}\n", + "output": "0", + "index": 881 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint8_t *ff_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,\n\n int size)\n\n{\n\n AVPacketSideData *sd, *tmp;\n\n int i;\n\n uint8_t *data = av_malloc(size);\n\n\n\n if (!data)\n\n return NULL;\n\n\n\n for (i = 0; i < st->nb_side_data; i++) {\n\n sd = &st->side_data[i];\n\n\n\n if (sd->type == type) {\n\n av_freep(&sd->data);\n\n sd->data = data;\n\n sd->size = size;\n\n return sd->data;\n\n }\n\n }\n\n\n\n tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));\n\n if (!tmp) {\n\n av_freep(&data);\n\n return NULL;\n\n }\n\n\n\n st->side_data = tmp;\n\n st->nb_side_data++;\n\n\n\n sd = &st->side_data[st->nb_side_data - 1];\n\n sd->type = type;\n\n sd->data = data;\n\n sd->size = size;\n\n return data;\n\n}\n", + "output": "0", + "index": 22138 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qcrypto_cipher_setiv(QCryptoCipher *cipher,\n\n const uint8_t *iv, size_t niv,\n\n Error **errp)\n\n{\n\n QCryptoCipherNettle *ctx = cipher->opaque;\n\n if (niv != ctx->niv) {\n\n error_setg(errp, \"Expected IV size %zu not %zu\",\n\n ctx->niv, niv);\n\n return -1;\n\n }\n\n memcpy(ctx->iv, iv, niv);\n\n return 0;\n\n}\n", + "output": "1", + "index": 16443 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void set_system_memory_map(MemoryRegion *mr)\n\n{\n\n memory_region_transaction_begin();\n\n address_space_memory.root = mr;\n\n memory_region_transaction_commit();\n\n}\n", + "output": "1", + "index": 16449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_packet_split_and_drop_side_data(AVPacket *pkt){\n\n if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){\n\n int i;\n\n unsigned int size;\n\n uint8_t *p;\n\n\n\n p = pkt->data + pkt->size - 8 - 5;\n\n for (i=1; ; i++){\n\n size = AV_RB32(p);\n\n if (size>INT_MAX - 5 || p - pkt->data < size)\n\n\n if (p[4]&128)\n\n break;\n\n if (p - pkt->data < size + 5)\n\n\n p-= size+5;\n\n\n\n }\n\n pkt->size = p - pkt->data - size;\n\n av_assert0(pkt->size >= 0);\n\n return 1;\n\n }\n\n\n}", + "output": "1", + "index": 17925 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int pci_device_load(PCIDevice *s, QEMUFile *f)\n\n{\n\n uint32_t version_id;\n\n int i;\n\n\n\n version_id = qemu_get_be32(f);\n\n if (version_id > 2)\n\n return -EINVAL;\n\n qemu_get_buffer(f, s->config, 256);\n\n pci_update_mappings(s);\n\n\n\n if (version_id >= 2)\n\n for (i = 0; i < 4; i ++)\n\n s->irq_state[i] = qemu_get_be32(f);\n\n return 0;\n\n}\n", + "output": "1", + "index": 9979 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply)\n\n{\n\n uint8_t buf[NBD_REPLY_SIZE];\n\n uint32_t magic;\n\n ssize_t ret;\n\n\n\n ret = read_sync(ioc, buf, sizeof(buf));\n\n if (ret <= 0) {\n\n return ret;\n\n }\n\n\n\n if (ret != sizeof(buf)) {\n\n LOG(\"read failed\");\n\n return -EINVAL;\n\n }\n\n\n\n /* Reply\n\n [ 0 .. 3] magic (NBD_REPLY_MAGIC)\n\n [ 4 .. 7] error (0 == no error)\n\n [ 7 .. 15] handle\n\n */\n\n\n\n magic = ldl_be_p(buf);\n\n reply->error = ldl_be_p(buf + 4);\n\n reply->handle = ldq_be_p(buf + 8);\n\n\n\n reply->error = nbd_errno_to_system_errno(reply->error);\n\n\n\n if (reply->error == ESHUTDOWN) {\n\n /* This works even on mingw which lacks a native ESHUTDOWN */\n\n LOG(\"server shutting down\");\n\n return -EINVAL;\n\n }\n\n TRACE(\"Got reply: { magic = 0x%\" PRIx32 \", .error = % \" PRId32\n\n \", handle = %\" PRIu64\" }\",\n\n magic, reply->error, reply->handle);\n\n\n\n if (magic != NBD_REPLY_MAGIC) {\n\n LOG(\"invalid magic (got 0x%\" PRIx32 \")\", magic);\n\n return -EINVAL;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 13181 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "opts_end_list(Visitor *v)\n\n{\n\n OptsVisitor *ov = to_ov(v);\n\n\n\n assert(ov->list_mode == LM_STARTED ||\n\n ov->list_mode == LM_IN_PROGRESS ||\n\n ov->list_mode == LM_SIGNED_INTERVAL ||\n\n ov->list_mode == LM_UNSIGNED_INTERVAL);\n\n ov->repeated_opts = NULL;\n\n ov->list_mode = LM_NONE;\n\n}\n", + "output": "0", + "index": 16627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "udp_listen(port, laddr, lport, flags)\n\n\tu_int port;\n\n\tu_int32_t laddr;\n\n\tu_int lport;\n\n\tint flags;\n\n{\n\n\tstruct sockaddr_in addr;\n\n\tstruct socket *so;\n\n\tint addrlen = sizeof(struct sockaddr_in), opt = 1;\n\n\n\n\tif ((so = socreate()) == NULL) {\n\n\t\tfree(so);\n\n\t\treturn NULL;\n\n\t}\n\n\tso->s = socket(AF_INET,SOCK_DGRAM,0);\n\n\tso->so_expire = curtime + SO_EXPIRE;\n\n\tinsque(so,&udb);\n\n\n\n\taddr.sin_family = AF_INET;\n\n\taddr.sin_addr.s_addr = INADDR_ANY;\n\n\taddr.sin_port = port;\n\n\n\n\tif (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {\n\n\t\tudp_detach(so);\n\n\t\treturn NULL;\n\n\t}\n\n\tsetsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));\n\n/*\tsetsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); */\n\n\n\n\tgetsockname(so->s,(struct sockaddr *)&addr,&addrlen);\n\n\tso->so_fport = addr.sin_port;\n\n\tif (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)\n\n\t so->so_faddr = alias_addr;\n\n\telse\n\n\t so->so_faddr = addr.sin_addr;\n\n\n\n\tso->so_lport = lport;\n\n\tso->so_laddr.s_addr = laddr;\n\n\tif (flags != SS_FACCEPTONCE)\n\n\t so->so_expire = 0;\n\n\n\n\tso->so_state = SS_ISFCONNECTED;\n\n\n\n\treturn so;\n\n}\n", + "output": "0", + "index": 3810 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void extract_mpeg4_header(AVFormatContext *infile)\n\n{\n\n int mpeg4_count, i, size;\n\n AVPacket pkt;\n\n AVStream *st;\n\n const uint8_t *p;\n\n\n\n mpeg4_count = 0;\n\n for(i=0;inb_streams;i++) {\n\n st = infile->streams[i];\n\n if (st->codec.codec_id == CODEC_ID_MPEG4 &&\n\n st->codec.extradata_size == 0) {\n\n mpeg4_count++;\n\n }\n\n }\n\n if (!mpeg4_count)\n\n return;\n\n\n\n printf(\"MPEG4 without extra data: trying to find header\\n\");\n\n while (mpeg4_count > 0) {\n\n if (av_read_packet(infile, &pkt) < 0)\n\n break;\n\n st = infile->streams[pkt.stream_index];\n\n if (st->codec.codec_id == CODEC_ID_MPEG4 &&\n\n st->codec.extradata_size == 0) {\n\n av_freep(&st->codec.extradata);\n\n /* fill extradata with the header */\n\n /* XXX: we make hard suppositions here ! */\n\n p = pkt.data;\n\n while (p < pkt.data + pkt.size - 4) {\n\n /* stop when vop header is found */\n\n if (p[0] == 0x00 && p[1] == 0x00 && \n\n p[2] == 0x01 && p[3] == 0xb6) {\n\n size = p - pkt.data;\n\n // av_hex_dump(pkt.data, size);\n\n st->codec.extradata = av_malloc(size);\n\n st->codec.extradata_size = size;\n\n memcpy(st->codec.extradata, pkt.data, size);\n\n break;\n\n }\n\n p++;\n\n }\n\n mpeg4_count--;\n\n }\n\n av_free_packet(&pkt);\n\n }\n\n}\n", + "output": "1", + "index": 10690 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr,\n\n uint32_t type, uint64_t asc, int rw)\n\n{\n\n CPUState *cs = CPU(s390_env_get_cpu(env));\n\n int ilen = ILEN_LATER;\n\n int bits = trans_bits(env, asc);\n\n\n\n /* Code accesses have an undefined ilc. */\n\n if (rw == 2) {\n\n ilen = 2;\n\n }\n\n\n\n DPRINTF(\"%s: vaddr=%016\" PRIx64 \" bits=%d\\n\", __func__, vaddr, bits);\n\n\n\n stq_phys(cs->as,\n\n env->psa + offsetof(LowCore, trans_exc_code), vaddr | bits);\n\n trigger_pgm_exception(env, type, ilen);\n\n}\n", + "output": "0", + "index": 14266 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void address_space_init(AddressSpace *as, MemoryRegion *root)\n\n{\n\n memory_region_transaction_begin();\n\n as->root = root;\n\n as->current_map = g_new(FlatView, 1);\n\n flatview_init(as->current_map);\n\n as->ioeventfd_nb = 0;\n\n as->ioeventfds = NULL;\n\n QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);\n\n as->name = NULL;\n\n memory_region_transaction_commit();\n\n address_space_init_dispatch(as);\n\n}\n", + "output": "0", + "index": 20527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "do_gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf, TCGv jr)\n\n{\n\n gen_update_cc_op(s);\n\n\n\n /* If several instructions disable interrupts, only the first does it. */\n\n if (inhibit && !(s->flags & HF_INHIBIT_IRQ_MASK)) {\n\n gen_set_hflag(s, HF_INHIBIT_IRQ_MASK);\n\n } else {\n\n gen_reset_hflag(s, HF_INHIBIT_IRQ_MASK);\n\n }\n\n\n\n if (s->tb->flags & HF_RF_MASK) {\n\n gen_helper_reset_rf(cpu_env);\n\n }\n\n if (s->singlestep_enabled) {\n\n gen_helper_debug(cpu_env);\n\n } else if (recheck_tf) {\n\n gen_helper_rechecking_single_step(cpu_env);\n\n tcg_gen_exit_tb(0);\n\n } else if (s->tf) {\n\n gen_helper_single_step(cpu_env);\n\n } else if (!TCGV_IS_UNUSED(jr)) {\n\n TCGv vaddr = tcg_temp_new();\n\n\n\n tcg_gen_add_tl(vaddr, jr, cpu_seg_base[R_CS]);\n\n tcg_gen_lookup_and_goto_ptr(vaddr);\n\n tcg_temp_free(vaddr);\n\n } else {\n\n tcg_gen_exit_tb(0);\n\n }\n\n s->is_jmp = DISAS_TB_JUMP;\n\n}\n", + "output": "0", + "index": 5894 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port,\n\n int class_id, int vendor_id, int product_id,\n\n const char *product_name, int speed)\n\n{\n\n struct USBAutoFilter *f;\n\n struct USBHostDevice *s;\n\n\n\n /* Ignore hubs */\n\n if (class_id == 9)\n\n return 0;\n\n\n\n QTAILQ_FOREACH(s, &hostdevs, next) {\n\n f = &s->match;\n\n\n\n if (f->bus_num > 0 && f->bus_num != bus_num) {\n\n continue;\n\n }\n\n if (f->addr > 0 && f->addr != addr) {\n\n continue;\n\n }\n\n if (f->port != NULL && (port == NULL || strcmp(f->port, port) != 0)) {\n\n continue;\n\n }\n\n\n\n if (f->vendor_id > 0 && f->vendor_id != vendor_id) {\n\n continue;\n\n }\n\n\n\n if (f->product_id > 0 && f->product_id != product_id) {\n\n continue;\n\n }\n\n /* We got a match */\n\n\n\n /* Already attached ? */\n\n if (s->fd != -1) {\n\n return 0;\n\n }\n\n DPRINTF(\"husb: auto open: bus_num %d addr %d\\n\", bus_num, addr);\n\n\n\n usb_host_open(s, bus_num, addr, port, product_name, speed);\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 2178 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int jpeg_read_close(AVFormatContext *s1)\n\n{\n\n JpegContext *s = s1->priv_data;\n\n av_free(s);\n\n return 0;\n\n}\n", + "output": "1", + "index": 18182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint8_t *ram_chunk_start(const RDMALocalBlock *rdma_ram_block,\n\n uint64_t i)\n\n{\n\n return (uint8_t *) (((uintptr_t) rdma_ram_block->local_host_addr)\n\n + (i << RDMA_REG_CHUNK_SHIFT));\n\n}\n", + "output": "1", + "index": 10744 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PITState *pit_init(int base, qemu_irq irq)\n\n{\n\n PITState *pit = &pit_state;\n\n PITChannelState *s;\n\n\n\n s = &pit->channels[0];\n\n /* the timer 0 is connected to an IRQ */\n\n s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);\n\n s->irq = irq;\n\n\n\n vmstate_register(base, &vmstate_pit, pit);\n\n qemu_register_reset(pit_reset, pit);\n\n register_ioport_write(base, 4, 1, pit_ioport_write, pit);\n\n register_ioport_read(base, 3, 1, pit_ioport_read, pit);\n\n\n\n pit_reset(pit);\n\n\n\n return pit;\n\n}\n", + "output": "0", + "index": 7322 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)\n\n{\n\n int *lendst = (int *)(dst + 1);\n\n uint8_t *bin, *ptr;\n\n int len = strlen(val);\n\n\n\n av_freep(dst);\n\n *lendst = 0;\n\n\n\n if (len & 1)\n\n return AVERROR(EINVAL);\n\n len /= 2;\n\n\n\n ptr = bin = av_malloc(len);\n\n while (*val) {\n\n int a = hexchar2int(*val++);\n\n int b = hexchar2int(*val++);\n\n if (a < 0 || b < 0) {\n\n av_free(bin);\n\n return AVERROR(EINVAL);\n\n }\n\n *ptr++ = (a << 4) | b;\n\n }\n\n *dst = bin;\n\n *lendst = len;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 21178 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void yop_paint_block(YopDecContext *s, int tag)\n\n{\n\n s->dstptr[0] = s->srcptr[0];\n\n s->dstptr[1] = s->srcptr[paint_lut[tag][0]];\n\n s->dstptr[s->frame.linesize[0]] = s->srcptr[paint_lut[tag][1]];\n\n s->dstptr[s->frame.linesize[0] + 1] = s->srcptr[paint_lut[tag][2]];\n\n\n\n // The number of src bytes consumed is in the last part of the lut entry.\n\n s->srcptr += paint_lut[tag][3];\n\n}\n", + "output": "1", + "index": 17057 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_exec_nocache(int max_cycles, TranslationBlock *orig_tb)\n\n{\n\n unsigned long next_tb;\n\n TranslationBlock *tb;\n\n\n\n /* Should never happen.\n\n We only end up here when an existing TB is too long. */\n\n if (max_cycles > CF_COUNT_MASK)\n\n max_cycles = CF_COUNT_MASK;\n\n\n\n tb = tb_gen_code(env, orig_tb->pc, orig_tb->cs_base, orig_tb->flags,\n\n max_cycles);\n\n env->current_tb = tb;\n\n /* execute the generated code */\n\n next_tb = tcg_qemu_tb_exec(tb->tc_ptr);\n\n env->current_tb = NULL;\n\n\n\n if ((next_tb & 3) == 2) {\n\n /* Restore PC. This may happen if async event occurs before\n\n the TB starts executing. */\n\n cpu_pc_from_tb(env, tb);\n\n }\n\n tb_phys_invalidate(tb, -1);\n\n tb_free(tb);\n\n}\n", + "output": "0", + "index": 213 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_do_read(void *opaque, int ret)\n\n{\n\n SCSIDiskReq *r = opaque;\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n\n uint32_t n;\n\n\n\n if (r->req.aiocb != NULL) {\n\n r->req.aiocb = NULL;\n\n bdrv_acct_done(s->qdev.conf.bs, &r->acct);\n\n }\n\n\n\n if (ret < 0) {\n\n if (scsi_handle_rw_error(r, -ret)) {\n\n goto done;\n\n }\n\n }\n\n\n\n if (r->req.io_canceled) {\n\n return;\n\n }\n\n\n\n /* The request is used as the AIO opaque value, so add a ref. */\n\n scsi_req_ref(&r->req);\n\n\n\n if (r->req.sg) {\n\n dma_acct_start(s->qdev.conf.bs, &r->acct, r->req.sg, BDRV_ACCT_READ);\n\n r->req.resid -= r->req.sg->size;\n\n r->req.aiocb = dma_bdrv_read(s->qdev.conf.bs, r->req.sg, r->sector,\n\n scsi_dma_complete, r);\n\n } else {\n\n n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);\n\n bdrv_acct_start(s->qdev.conf.bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);\n\n r->req.aiocb = bdrv_aio_readv(s->qdev.conf.bs, r->sector, &r->qiov, n,\n\n scsi_read_complete, r);\n\n }\n\n\n\ndone:\n\n if (!r->req.io_canceled) {\n\n scsi_req_unref(&r->req);\n\n }\n\n}\n", + "output": "0", + "index": 12047 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "sdhci_readfn(void *opaque, hwaddr offset, unsigned size)\n\n{\n\n SDHCIState *s = (SDHCIState *)opaque;\n\n\n\n return SDHCI_GET_CLASS(s)->mem_read(s, offset, size);\n\n}\n", + "output": "0", + "index": 18685 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_release_unused_pictures(MpegEncContext *s, int remove_current)\n\n{\n\n int i;\n\n\n\n /* release non reference frames */\n\n for(i=0; ipicture_count; i++){\n\n if(s->picture[i].data[0] && !s->picture[i].reference\n\n && s->picture[i].owner2 == s\n\n && (remove_current || &s->picture[i] != s->current_picture_ptr)\n\n /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){\n\n free_frame_buffer(s, &s->picture[i]);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 24641 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)\n\n{\n\n SaveStateEntry *se, *new_se;\n\n char id[256] = \"\";\n\n\n\n if (dev) {\n\n char *path = qdev_get_dev_path(dev);\n\n if (path) {\n\n pstrcpy(id, sizeof(id), path);\n\n pstrcat(id, sizeof(id), \"/\");\n\n g_free(path);\n\n }\n\n }\n\n pstrcat(id, sizeof(id), idstr);\n\n\n\n QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {\n\n if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {\n\n QTAILQ_REMOVE(&savevm_state.handlers, se, entry);\n\n if (se->compat) {\n\n g_free(se->compat);\n\n }\n\n g_free(se->ops);\n\n g_free(se);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 3030 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,\n\n TranslationBlock **last_tb, int *tb_exit)\n\n{\n\n uintptr_t ret;\n\n int32_t insns_left;\n\n\n\n if (unlikely(atomic_read(&cpu->exit_request))) {\n\n return;\n\n }\n\n\n\n trace_exec_tb(tb, tb->pc);\n\n ret = cpu_tb_exec(cpu, tb);\n\n tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);\n\n *tb_exit = ret & TB_EXIT_MASK;\n\n if (*tb_exit != TB_EXIT_REQUESTED) {\n\n *last_tb = tb;\n\n return;\n\n }\n\n\n\n *last_tb = NULL;\n\n insns_left = atomic_read(&cpu->icount_decr.u32);\n\n atomic_set(&cpu->icount_decr.u16.high, 0);\n\n if (insns_left < 0) {\n\n /* Something asked us to stop executing\n\n * chained TBs; just continue round the main\n\n * loop. Whatever requested the exit will also\n\n * have set something else (eg exit_request or\n\n * interrupt_request) which we will handle\n\n * next time around the loop. But we need to\n\n * ensure the zeroing of tcg_exit_req (see cpu_tb_exec)\n\n * comes before the next read of cpu->exit_request\n\n * or cpu->interrupt_request.\n\n */\n\n smp_mb();\n\n return;\n\n }\n\n\n\n /* Instruction counter expired. */\n\n assert(use_icount);\n\n#ifndef CONFIG_USER_ONLY\n\n if (cpu->icount_extra) {\n\n /* Refill decrementer and continue execution. */\n\n cpu->icount_extra += insns_left;\n\n insns_left = MIN(0xffff, cpu->icount_extra);\n\n cpu->icount_extra -= insns_left;\n\n cpu->icount_decr.u16.low = insns_left;\n\n } else {\n\n /* Execute any remaining instructions, then let the main loop\n\n * handle the next event.\n\n */\n\n if (insns_left > 0) {\n\n cpu_exec_nocache(cpu, insns_left, tb, false);\n\n }\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 873 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ide_atapi_cmd_read_pio(IDEState *s, int lba, int nb_sectors,\n\n int sector_size)\n\n{\n\n s->lba = lba;\n\n s->packet_transfer_size = nb_sectors * sector_size;\n\n s->elementary_transfer_size = 0;\n\n s->io_buffer_index = sector_size;\n\n s->cd_sector_size = sector_size;\n\n\n\n s->status = READY_STAT;\n\n ide_atapi_cmd_reply_end(s);\n\n}\n", + "output": "0", + "index": 21274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)\n\n{\n\n CharDriverState *chr;\n\n const char *chardev;\n\n const char *mode;\n\n int flags;\n\n\n\n mode = qemu_opt_get(opts, \"mode\");\n\n if (mode == NULL) {\n\n mode = \"readline\";\n\n }\n\n if (strcmp(mode, \"readline\") == 0) {\n\n flags = MONITOR_USE_READLINE;\n\n } else if (strcmp(mode, \"control\") == 0) {\n\n flags = MONITOR_USE_CONTROL;\n\n } else {\n\n fprintf(stderr, \"unknown monitor mode \\\"%s\\\"\\n\", mode);\n\n exit(1);\n\n }\n\n\n\n if (qemu_opt_get_bool(opts, \"pretty\", 0))\n\n flags |= MONITOR_USE_PRETTY;\n\n\n\n if (qemu_opt_get_bool(opts, \"default\", 0))\n\n flags |= MONITOR_IS_DEFAULT;\n\n\n\n chardev = qemu_opt_get(opts, \"chardev\");\n\n chr = qemu_chr_find(chardev);\n\n if (chr == NULL) {\n\n fprintf(stderr, \"chardev \\\"%s\\\" not found\\n\", chardev);\n\n exit(1);\n\n }\n\n\n\n qemu_chr_fe_claim_no_fail(chr);\n\n monitor_init(chr, flags);\n\n return 0;\n\n}\n", + "output": "0", + "index": 17960 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)\n\n{\n\n QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);\n\n QXLCursor *cursor;\n\n QEMUCursor *c;\n\n\n\n if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {\n\n return;\n\n }\n\n\n\n if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {\n\n fprintf(stderr, \"%s\", __FUNCTION__);\n\n qxl_log_cmd_cursor(qxl, cmd, ext->group_id);\n\n fprintf(stderr, \"\\n\");\n\n }\n\n switch (cmd->type) {\n\n case QXL_CURSOR_SET:\n\n cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);\n\n if (cursor->chunk.data_size != cursor->data_size) {\n\n fprintf(stderr, \"%s: multiple chunks\\n\", __FUNCTION__);\n\n return;\n\n }\n\n c = qxl_cursor(qxl, cursor);\n\n if (c == NULL) {\n\n c = cursor_builtin_left_ptr();\n\n }\n\n qemu_mutex_lock(&qxl->ssd.lock);\n\n if (qxl->ssd.cursor) {\n\n cursor_put(qxl->ssd.cursor);\n\n }\n\n qxl->ssd.cursor = c;\n\n qxl->ssd.mouse_x = cmd->u.set.position.x;\n\n qxl->ssd.mouse_y = cmd->u.set.position.y;\n\n qemu_mutex_unlock(&qxl->ssd.lock);\n\n break;\n\n case QXL_CURSOR_MOVE:\n\n qemu_mutex_lock(&qxl->ssd.lock);\n\n qxl->ssd.mouse_x = cmd->u.position.x;\n\n qxl->ssd.mouse_y = cmd->u.position.y;\n\n qemu_mutex_unlock(&qxl->ssd.lock);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 22346 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_divdo (void)\n\n{\n\n if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) ||\n\n (int64_t)T1 == 0))) {\n\n xer_ov = 0;\n\n T0 = (int64_t)T0 / (int64_t)T1;\n\n } else {\n\n xer_so = 1;\n\n xer_ov = 1;\n\n T0 = (-1ULL) * ((uint64_t)T0 >> 63);\n\n }\n\n}\n", + "output": "1", + "index": 19043 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usbredir_interface_info(void *priv,\n\n struct usb_redir_interface_info_header *interface_info)\n\n{\n\n USBRedirDevice *dev = priv;\n\n\n\n dev->interface_info = *interface_info;\n\n\n\n /*\n\n * If we receive interface info after the device has already been\n\n * connected (ie on a set_config), re-check the filter.\n\n */\n\n if (qemu_timer_pending(dev->attach_timer) || dev->dev.attached) {\n\n if (usbredir_check_filter(dev)) {\n\n ERROR(\"Device no longer matches filter after interface info \"\n\n \"change, disconnecting!\\n\");\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 13737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,\n\n DeviceState *dev, Error **errp)\n\n{\n\n MemStatus *mdev;\n\n\n\n mdev = acpi_memory_slot_status(mem_st, dev, errp);\n\n if (!mdev) {\n\n return;\n\n }\n\n\n\n mdev->dimm = dev;\n\n mdev->is_enabled = true;\n\n mdev->is_inserting = true;\n\n\n\n /* do ACPI magic */\n\n acpi_send_gpe_event(ar, irq, ACPI_MEMORY_HOTPLUG_STATUS);\n\n return;\n\n}\n", + "output": "0", + "index": 22477 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,\n\n struct image_info *info)\n\n{\n\n abi_ulong stack_base, size, error;\n\n int i;\n\n\n\n /* Create enough stack to hold everything. If we don't use\n\n * it for args, we'll use it for something else...\n\n */\n\n size = x86_stack_size;\n\n if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE)\n\n size = MAX_ARG_PAGES*TARGET_PAGE_SIZE;\n\n error = target_mmap(0,\n\n size + qemu_host_page_size,\n\n PROT_READ | PROT_WRITE,\n\n MAP_PRIVATE | MAP_ANONYMOUS,\n\n -1, 0);\n\n if (error == -1) {\n\n perror(\"stk mmap\");\n\n exit(-1);\n\n }\n\n /* we reserve one extra page at the top of the stack as guard */\n\n target_mprotect(error + size, qemu_host_page_size, PROT_NONE);\n\n\n\n stack_base = error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE;\n\n p += stack_base;\n\n\n\n for (i = 0 ; i < MAX_ARG_PAGES ; i++) {\n\n\tif (bprm->page[i]) {\n\n\t info->rss++;\n\n /* FIXME - check return value of memcpy_to_target() for failure */\n\n\t memcpy_to_target(stack_base, bprm->page[i], TARGET_PAGE_SIZE);\n\n\t free(bprm->page[i]);\n\n\t}\n\n stack_base += TARGET_PAGE_SIZE;\n\n }\n\n return p;\n\n}\n", + "output": "1", + "index": 12166 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_ivshmem_memdev(void)\n\n{\n\n IVState state;\n\n\n\n /* just for the sake of checking memory-backend property */\n\n setup_vm_cmd(&state, \"-object memory-backend-ram,size=1M,id=mb1\"\n\n \" -device ivshmem,x-memdev=mb1\", false);\n\n\n\n qtest_quit(state.qtest);\n\n}\n", + "output": "1", + "index": 3572 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int os_host_main_loop_wait(uint32_t timeout)\n\n{\n\n int ret;\n\n\n\n glib_select_fill(&nfds, &rfds, &wfds, &xfds, &timeout);\n\n\n\n if (timeout > 0) {\n\n qemu_mutex_unlock_iothread();\n\n }\n\n\n\n /* We'll eventually drop fd_set completely. But for now we still have\n\n * *_fill() and *_poll() functions that use rfds/wfds/xfds.\n\n */\n\n gpollfds_from_select();\n\n\n\n ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout);\n\n\n\n gpollfds_to_select(ret);\n\n\n\n if (timeout > 0) {\n\n qemu_mutex_lock_iothread();\n\n }\n\n\n\n glib_select_poll(&rfds, &wfds, &xfds, (ret < 0));\n\n return ret;\n\n}\n", + "output": "0", + "index": 18273 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t shpc_get_status(SHPCDevice *shpc, int slot, uint16_t msk)\n\n{\n\n uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot);\n\n return (pci_get_word(status) & msk) >> (ffs(msk) - 1);\n\n}\n", + "output": "0", + "index": 9268 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)\n\n{\n\n const mon_cmd_t *cmd;\n\n const char *item = qdict_get_try_str(qdict, \"item\");\n\n\n\n if (!item)\n\n goto help;\n\n\n\n for (cmd = info_cmds; cmd->name != NULL; cmd++) {\n\n if (compare_cmd(item, cmd->name))\n\n break;\n\n }\n\n\n\n if (cmd->name == NULL)\n\n goto help;\n\n\n\n if (monitor_handler_ported(cmd)) {\n\n cmd->mhandler.info_new(mon, ret_data);\n\n if (*ret_data)\n\n cmd->user_print(mon, *ret_data);\n\n } else {\n\n cmd->mhandler.info(mon);\n\n }\n\n\n\n return;\n\n\n\nhelp:\n\n help_cmd(mon, \"info\");\n\n}\n", + "output": "0", + "index": 21735 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t throttle_compute_wait(LeakyBucket *bkt)\n\n{\n\n double extra; /* the number of extra units blocking the io */\n\n double bucket_size; /* I/O before throttling to bkt->avg */\n\n double burst_bucket_size; /* Before throttling to bkt->max */\n\n\n\n if (!bkt->avg) {\n\n return 0;\n\n }\n\n\n\n if (!bkt->max) {\n\n /* If bkt->max is 0 we still want to allow short bursts of I/O\n\n * from the guest, otherwise every other request will be throttled\n\n * and performance will suffer considerably. */\n\n bucket_size = (double) bkt->avg / 10;\n\n burst_bucket_size = 0;\n\n } else {\n\n /* If we have a burst limit then we have to wait until all I/O\n\n * at burst rate has finished before throttling to bkt->avg */\n\n bucket_size = bkt->max * bkt->burst_length;\n\n burst_bucket_size = (double) bkt->max / 10;\n\n }\n\n\n\n /* If the main bucket is full then we have to wait */\n\n extra = bkt->level - bucket_size;\n\n if (extra > 0) {\n\n return throttle_do_compute_wait(bkt->avg, extra);\n\n }\n\n\n\n /* If the main bucket is not full yet we still have to check the\n\n * burst bucket in order to enforce the burst limit */\n\n if (bkt->burst_length > 1) {\n\n\n extra = bkt->burst_level - burst_bucket_size;\n\n if (extra > 0) {\n\n return throttle_do_compute_wait(bkt->max, extra);\n\n }\n\n }\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 10872 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ircam_read_header(AVFormatContext *s)\n\n{\n\n uint32_t magic, sample_rate, channels, tag;\n\n const AVCodecTag *tags;\n\n int le = -1, i;\n\n AVStream *st;\n\n\n\n magic = avio_rl32(s->pb);\n\n for (i = 0; i < 7; i++) {\n\n if (magic == table[i].magic) {\n\n le = table[i].is_le;\n\n break;\n\n }\n\n }\n\n\n\n if (le == 1) {\n\n sample_rate = av_int2float(avio_rl32(s->pb));\n\n channels = avio_rl32(s->pb);\n\n tag = avio_rl32(s->pb);\n\n tags = ff_codec_ircam_le_tags;\n\n } else if (le == 0) {\n\n sample_rate = av_int2float(avio_rb32(s->pb));\n\n channels = avio_rb32(s->pb);\n\n tag = avio_rb32(s->pb);\n\n tags = ff_codec_ircam_be_tags;\n\n } else {\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n if (!channels || !sample_rate)\n\n return AVERROR_INVALIDDATA;\n\n\n\n st = avformat_new_stream(s, NULL);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;\n\n st->codecpar->channels = channels;\n\n\n\n st->codecpar->sample_rate = sample_rate;\n\n\n\n st->codecpar->codec_id = ff_codec_get_id(tags, tag);\n\n if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {\n\n av_log(s, AV_LOG_ERROR, \"unknown tag %X\\n\", tag);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);\n\n st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;\n\n avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);\n\n avio_skip(s->pb, 1008);\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 2144 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_cpsr(QEMUFile *f, void *opaque, size_t size,\n\n VMStateField *field)\n\n{\n\n ARMCPU *cpu = opaque;\n\n CPUARMState *env = &cpu->env;\n\n uint32_t val = qemu_get_be32(f);\n\n\n\n if (arm_feature(env, ARM_FEATURE_M)) {\n\n if (val & XPSR_EXCP) {\n\n /* This is a CPSR format value from an older QEMU. (We can tell\n\n * because values transferred in XPSR format always have zero\n\n * for the EXCP field, and CPSR format will always have bit 4\n\n * set in CPSR_M.) Rearrange it into XPSR format. The significant\n\n * differences are that the T bit is not in the same place, the\n\n * primask/faultmask info may be in the CPSR I and F bits, and\n\n * we do not want the mode bits.\n\n */\n\n uint32_t newval = val;\n\n\n\n newval &= (CPSR_NZCV | CPSR_Q | CPSR_IT | CPSR_GE);\n\n if (val & CPSR_T) {\n\n newval |= XPSR_T;\n\n }\n\n /* If the I or F bits are set then this is a migration from\n\n * an old QEMU which still stored the M profile FAULTMASK\n\n * and PRIMASK in env->daif. For a new QEMU, the data is\n\n * transferred using the vmstate_m_faultmask_primask subsection.\n\n */\n\n if (val & CPSR_F) {\n\n env->v7m.faultmask = 1;\n\n }\n\n if (val & CPSR_I) {\n\n env->v7m.primask = 1;\n\n }\n\n val = newval;\n\n }\n\n /* Ignore the low bits, they are handled by vmstate_m. */\n\n xpsr_write(env, val, ~XPSR_EXCP);\n\n return 0;\n\n }\n\n\n\n env->aarch64 = ((val & PSTATE_nRW) == 0);\n\n\n\n if (is_a64(env)) {\n\n pstate_write(env, val);\n\n return 0;\n\n }\n\n\n\n cpsr_write(env, val, 0xffffffff, CPSRWriteRaw);\n\n return 0;\n\n}\n", + "output": "0", + "index": 7797 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool object_create_initial(const char *type)\n{\n if (g_str_equal(type, \"rng-egd\")) {\n /*\n * return false for concrete netfilters since\n * they depend on netdevs already existing\n if (g_str_equal(type, \"filter-buffer\") ||\n g_str_equal(type, \"filter-dump\") ||\n g_str_equal(type, \"filter-mirror\") ||\n g_str_equal(type, \"filter-redirector\")) {\n return true;", + "output": "1", + "index": 24417 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void wdt_ib700_init(void)\n\n{\n\n watchdog_add_model(&model);\n\n timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL);\n\n}\n", + "output": "1", + "index": 14515 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td, USBEndpoint *ep)\n\n{\n\n uint32_t token = uhci_queue_token(td);\n\n UHCIQueue *queue;\n\n\n\n QTAILQ_FOREACH(queue, &s->queues, next) {\n\n if (queue->token == token) {\n\n return queue;\n\n }\n\n }\n\n\n\n queue = g_new0(UHCIQueue, 1);\n\n queue->uhci = s;\n\n queue->token = token;\n\n queue->ep = ep;\n\n QTAILQ_INIT(&queue->asyncs);\n\n QTAILQ_INSERT_HEAD(&s->queues, queue, next);\n\n trace_usb_uhci_queue_add(queue->token);\n\n return queue;\n\n}\n", + "output": "1", + "index": 14326 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int libx265_encode_close(AVCodecContext *avctx)\n\n{\n\n libx265Context *ctx = avctx->priv_data;\n\n\n\n av_frame_free(&avctx->coded_frame);\n\n\n\n ctx->api->param_free(ctx->params);\n\n\n\n if (ctx->encoder)\n\n ctx->api->encoder_close(ctx->encoder);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 1788 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_co_complete(BlockAIOCBCoroutine *acb)\n\n{\n\n if (!acb->need_bh) {\n\n acb->common.cb(acb->common.opaque, acb->req.error);\n\n qemu_aio_unref(acb);\n\n }\n\n}\n", + "output": "0", + "index": 4634 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void axienet_eth_rx_notify(void *opaque)\n\n{\n\n XilinxAXIEnet *s = XILINX_AXI_ENET(opaque);\n\n\n\n while (s->rxsize && stream_can_push(s->tx_dev, axienet_eth_rx_notify, s)) {\n\n size_t ret = stream_push(s->tx_dev, (void *)s->rxmem + s->rxpos,\n\n s->rxsize, s->rxapp);\n\n s->rxsize -= ret;\n\n s->rxpos += ret;\n\n if (!s->rxsize) {\n\n s->regs[R_IS] |= IS_RX_COMPLETE;\n\n g_free(s->rxapp);\n\n }\n\n }\n\n enet_update_irq(s);\n\n}\n", + "output": "0", + "index": 26455 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)\n\n{\n\n uint32_t * palette = (uint32_t *)frame->data[1];\n\n int a;\n\n\n\n if (buf_size < 256*3)\n\n return AVERROR_INVALIDDATA;\n\n\n\n for(a = 0; a < 256; a++){\n\n palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;\n\n }\n\n frame->palette_has_changed = 1;\n\n return 256*3;\n\n}\n", + "output": "1", + "index": 15280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)\n\n{\n\n int fd, ret;\n\n\n\n /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).\n\n * Unfortunately, the linux kernel doesn't implement it yet. As an\n\n * alternative, let's open the file and use fchmod() instead. This\n\n * may fail depending on the permissions of the file, but it is the\n\n * best we can do to avoid TOCTTOU. We first try to open read-only\n\n * in case name points to a directory. If that fails, we try write-only\n\n * in case name doesn't point to a directory.\n\n */\n\n fd = openat_file(dirfd, name, O_RDONLY, 0);\n\n if (fd == -1) {\n\n /* In case the file is writable-only and isn't a directory. */\n\n if (errno == EACCES) {\n\n fd = openat_file(dirfd, name, O_WRONLY, 0);\n\n }\n\n if (fd == -1 && errno == EISDIR) {\n\n errno = EACCES;\n\n }\n\n }\n\n if (fd == -1) {\n\n return -1;\n\n }\n\n ret = fchmod(fd, mode);\n\n close_preserve_errno(fd);\n\n return ret;\n\n}\n", + "output": "1", + "index": 3225 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)\n\n{\n\n CharDriverState *chr;\n\n FDCharDriver *s;\n\n\n\n chr = qemu_chr_alloc();\n\n s = g_malloc0(sizeof(FDCharDriver));\n\n s->fd_in = io_channel_from_fd(fd_in);\n\n s->fd_out = io_channel_from_fd(fd_out);\n\n qemu_set_nonblock(fd_out);\n\n s->chr = chr;\n\n chr->opaque = s;\n\n chr->chr_add_watch = fd_chr_add_watch;\n\n chr->chr_write = fd_chr_write;\n\n chr->chr_update_read_handler = fd_chr_update_read_handler;\n\n chr->chr_close = fd_chr_close;\n\n\n\n return chr;\n\n}\n", + "output": "1", + "index": 4655 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QObject *parse_literal(JSONParserContext *ctxt)\n\n{\n\n QObject *token;\n\n\n\n token = parser_context_pop_token(ctxt);\n\n assert(token);\n\n\n\n switch (token_get_type(token)) {\n\n case JSON_STRING:\n\n return QOBJECT(qstring_from_escaped_str(ctxt, token));\n\n case JSON_INTEGER: {\n\n /* A possibility exists that this is a whole-valued float where the\n\n * fractional part was left out due to being 0 (.0). It's not a big\n\n * deal to treat these as ints in the parser, so long as users of the\n\n * resulting QObject know to expect a QInt in place of a QFloat in\n\n * cases like these.\n\n *\n\n * However, in some cases these values will overflow/underflow a\n\n * QInt/int64 container, thus we should assume these are to be handled\n\n * as QFloats/doubles rather than silently changing their values.\n\n *\n\n * strtoll() indicates these instances by setting errno to ERANGE\n\n */\n\n int64_t value;\n\n\n\n errno = 0; /* strtoll doesn't set errno on success */\n\n value = strtoll(token_get_value(token), NULL, 10);\n\n if (errno != ERANGE) {\n\n return QOBJECT(qint_from_int(value));\n\n }\n\n /* fall through to JSON_FLOAT */\n\n }\n\n case JSON_FLOAT:\n\n /* FIXME dependent on locale */\n\n return QOBJECT(qfloat_from_double(strtod(token_get_value(token),\n\n NULL)));\n\n default:\n\n abort();\n\n }\n\n}\n", + "output": "0", + "index": 7076 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void piix4_reset(void *opaque)\n\n{\n\n\tPIIX4PMState *s = opaque;\n\n\tuint8_t *pci_conf = s->dev.config;\n\n\n\n\tpci_conf[0x58] = 0;\n\n\tpci_conf[0x59] = 0;\n\n\tpci_conf[0x5a] = 0;\n\n\tpci_conf[0x5b] = 0;\n\n}\n", + "output": "0", + "index": 13584 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_block(ALSDecContext *ctx, ALSBlockData *bd)\n\n{\n\n GetBitContext *gb = &ctx->gb;\n\n\n\n *bd->shift_lsbs = 0;\n\n // read block type flag and read the samples accordingly\n\n if (get_bits1(gb)) {\n\n if (read_var_block_data(ctx, bd))\n\n return -1;\n\n } else {\n\n read_const_block_data(ctx, bd);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21163 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_probe(AVProbeData *p)\n\n{\n\n int64_t offset;\n\n uint32_t tag;\n\n int score = 0;\n\n\n\n /* check file header */\n\n offset = 0;\n\n for (;;) {\n\n /* ignore invalid offset */\n\n if ((offset + 8) > (unsigned int)p->buf_size)\n\n return score;\n\n tag = AV_RL32(p->buf + offset + 4);\n\n switch(tag) {\n\n /* check for obvious tags */\n\n case MKTAG('j','P',' ',' '): /* jpeg 2000 signature */\n\n case MKTAG('m','o','o','v'):\n\n case MKTAG('m','d','a','t'):\n\n case MKTAG('p','n','o','t'): /* detect movs with preview pics like ew.mov and april.mov */\n\n case MKTAG('u','d','t','a'): /* Packet Video PVAuthor adds this and a lot of more junk */\n\n case MKTAG('f','t','y','p'):\n\n return AVPROBE_SCORE_MAX;\n\n /* those are more common words, so rate then a bit less */\n\n case MKTAG('e','d','i','w'): /* xdcam files have reverted first tags */\n\n case MKTAG('w','i','d','e'):\n\n case MKTAG('f','r','e','e'):\n\n case MKTAG('j','u','n','k'):\n\n case MKTAG('p','i','c','t'):\n\n return AVPROBE_SCORE_MAX - 5;\n\n case MKTAG(0x82,0x82,0x7f,0x7d):\n\n case MKTAG('s','k','i','p'):\n\n case MKTAG('u','u','i','d'):\n\n case MKTAG('p','r','f','l'):\n\n offset = AV_RB32(p->buf+offset) + offset;\n\n /* if we only find those cause probedata is too small at least rate them */\n\n score = AVPROBE_SCORE_MAX - 50;\n\n break;\n\n default:\n\n /* unrecognized tag */\n\n return score;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 12394 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_lock(void *opaque)\n{\n int8_t status;\n V9fsFlock *flock;\n size_t offset = 7;\n struct stat stbuf;\n V9fsFidState *fidp;\n int32_t fid, err = 0;\n V9fsPDU *pdu = opaque;\n V9fsState *s = pdu->s;\n flock = g_malloc(sizeof(*flock));\n pdu_unmarshal(pdu, offset, \"dbdqqds\", &fid, &flock->type,\n &flock->flags, &flock->start, &flock->length,\n &flock->proc_id, &flock->client_id);\n status = P9_LOCK_ERROR;\n /* We support only block flag now (that too ignored currently) */\n if (flock->flags & ~P9_LOCK_FLAGS_BLOCK) {\n err = -EINVAL;\n goto out_nofid;\n }\n fidp = get_fid(pdu, fid);\n if (fidp == NULL) {\n err = -ENOENT;\n goto out_nofid;\n }\n err = v9fs_co_fstat(pdu, fidp->fs.fd, &stbuf);\n if (err < 0) {\n goto out;\n }\n status = P9_LOCK_SUCCESS;\nout:\n put_fid(pdu, fidp);\nout_nofid:\n err = offset;\n err += pdu_marshal(pdu, offset, \"b\", status);\n trace_v9fs_lock_return(pdu->tag, pdu->id, status);\n complete_pdu(s, pdu, err);\n v9fs_string_free(&flock->client_id);\n g_free(flock);\n}", + "output": "1", + "index": 18071 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)\n\n{\n\n switch(tag) {\n\n case 0x0202:\n\n source_clip->duration = get_be64(pb);\n\n break;\n\n case 0x1201:\n\n source_clip->start_position = get_be64(pb);\n\n break;\n\n case 0x1101:\n\n /* UMID, only get last 16 bytes */\n\n url_fskip(pb, 16);\n\n get_buffer(pb, source_clip->source_package_uid, 16);\n\n break;\n\n case 0x1102:\n\n source_clip->source_track_id = get_be32(pb);\n\n break;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 13918 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)\n\n{\n\n int ret;\n\n\n\n ret = build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,\n\n avpriv_mjpeg_val_dc, 12, 0);\n\n if (ret)\n\n return ret;\n\n ret = build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,\n\n avpriv_mjpeg_val_dc, 12, 0);\n\n if (ret)\n\n return ret;\n\n ret = build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,\n\n avpriv_mjpeg_val_ac_luminance, 251, 1);\n\n if (ret)\n\n return ret;\n\n ret = build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,\n\n avpriv_mjpeg_val_ac_chrominance, 251, 1);\n\n if (ret)\n\n return ret;\n\n\n\n ff_blockdsp_init(&c->bdsp, avctx);\n\n ff_idctdsp_init(&c->idsp, avctx);\n\n ff_init_scantable(c->idsp.idct_permutation, &c->scantable,\n\n ff_zigzag_direct);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 10915 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QObject* bdrv_info_stats_bs(BlockDriverState *bs)\n\n{\n\n QObject *res;\n\n QDict *dict;\n\n\n\n res = qobject_from_jsonf(\"{ 'stats': {\"\n\n \"'rd_bytes': %\" PRId64 \",\"\n\n \"'wr_bytes': %\" PRId64 \",\"\n\n \"'rd_operations': %\" PRId64 \",\"\n\n \"'wr_operations': %\" PRId64 \",\"\n\n \"'wr_highest_offset': %\" PRId64 \",\"\n\n \"'flush_operations': %\" PRId64\n\n \"} }\",\n\n bs->nr_bytes[BDRV_ACCT_READ],\n\n bs->nr_bytes[BDRV_ACCT_WRITE],\n\n bs->nr_ops[BDRV_ACCT_READ],\n\n bs->nr_ops[BDRV_ACCT_WRITE],\n\n bs->wr_highest_sector *\n\n (uint64_t)BDRV_SECTOR_SIZE,\n\n bs->nr_ops[BDRV_ACCT_FLUSH]);\n\n dict = qobject_to_qdict(res);\n\n\n\n if (*bs->device_name) {\n\n qdict_put(dict, \"device\", qstring_from_str(bs->device_name));\n\n }\n\n\n\n if (bs->file) {\n\n QObject *parent = bdrv_info_stats_bs(bs->file);\n\n qdict_put_obj(dict, \"parent\", parent);\n\n }\n\n\n\n return res;\n\n}\n", + "output": "0", + "index": 5832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)\n\n{\n\n KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);\n\n struct kvm_create_device cd = {0};\n\n struct kvm_device_attr test_attr = {0};\n\n int ret;\n\n Error *errp_local = NULL;\n\n\n\n\n\n\n\n flic_state->fd = -1;\n\n if (!kvm_check_extension(kvm_state, KVM_CAP_DEVICE_CTRL)) {\n\n error_setg_errno(&errp_local, errno, \"KVM is missing capability\"\n\n \" KVM_CAP_DEVICE_CTRL\");\n\n trace_flic_no_device_api(errno);\n\n\n\n\n\n cd.type = KVM_DEV_TYPE_FLIC;\n\n ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);\n\n if (ret < 0) {\n\n error_setg_errno(&errp_local, errno, \"Creating the KVM device failed\");\n\n trace_flic_create_device(errno);\n\n\n\n flic_state->fd = cd.fd;\n\n\n\n /* Check clear_io_irq support */\n\n test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ;\n\n flic_state->clear_io_supported = !ioctl(flic_state->fd,\n\n KVM_HAS_DEVICE_ATTR, test_attr);\n\n\n\n return;\n\nfail:\n\n error_propagate(errp, errp_local);\n", + "output": "1", + "index": 22236 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void memory_region_oldmmio_read_accessor(MemoryRegion *mr,\n\n hwaddr addr,\n\n uint64_t *value,\n\n unsigned size,\n\n unsigned shift,\n\n uint64_t mask)\n\n{\n\n uint64_t tmp;\n\n\n\n tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);\n\n trace_memory_region_ops_read(mr, addr, tmp, size);\n\n *value |= (tmp & mask) << shift;\n\n}\n", + "output": "1", + "index": 16470 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_wrpsr(CPUSPARCState *env, target_ulong new_psr)\n\n{\n\n if ((new_psr & PSR_CWP) >= env->nwindows) {\n\n cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC());\n\n } else {\n\n\n\n cpu_put_psr(env, new_psr);\n\n\n }\n\n}", + "output": "1", + "index": 4354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_proc_401x2 (CPUPPCState *env)\n\n{\n\n}\n", + "output": "0", + "index": 14972 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void serial_exit_core(SerialState *s)\n{\n qemu_chr_fe_deinit(&s->chr);\n qemu_unregister_reset(serial_reset, s);\n}", + "output": "1", + "index": 9446 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int load_bitmap_data(BlockDriverState *bs,\n\n const uint64_t *bitmap_table,\n\n uint32_t bitmap_table_size,\n\n BdrvDirtyBitmap *bitmap)\n\n{\n\n int ret = 0;\n\n BDRVQcow2State *s = bs->opaque;\n\n uint64_t sector, sbc;\n\n uint64_t bm_size = bdrv_dirty_bitmap_size(bitmap);\n\n uint64_t bm_sectors = DIV_ROUND_UP(bm_size, BDRV_SECTOR_SIZE);\n\n uint8_t *buf = NULL;\n\n uint64_t i, tab_size =\n\n size_to_clusters(s,\n\n bdrv_dirty_bitmap_serialization_size(bitmap, 0, bm_sectors));\n\n\n\n if (tab_size != bitmap_table_size || tab_size > BME_MAX_TABLE_SIZE) {\n\n return -EINVAL;\n\n }\n\n\n\n buf = g_malloc(s->cluster_size);\n\n sbc = sectors_covered_by_bitmap_cluster(s, bitmap);\n\n for (i = 0, sector = 0; i < tab_size; ++i, sector += sbc) {\n\n uint64_t count = MIN(bm_sectors - sector, sbc);\n\n uint64_t entry = bitmap_table[i];\n\n uint64_t offset = entry & BME_TABLE_ENTRY_OFFSET_MASK;\n\n\n\n assert(check_table_entry(entry, s->cluster_size) == 0);\n\n\n\n if (offset == 0) {\n\n if (entry & BME_TABLE_ENTRY_FLAG_ALL_ONES) {\n\n bdrv_dirty_bitmap_deserialize_ones(bitmap, sector, count,\n\n false);\n\n } else {\n\n /* No need to deserialize zeros because the dirty bitmap is\n\n * already cleared */\n\n }\n\n } else {\n\n ret = bdrv_pread(bs->file, offset, buf, s->cluster_size);\n\n if (ret < 0) {\n\n goto finish;\n\n }\n\n bdrv_dirty_bitmap_deserialize_part(bitmap, buf, sector, count,\n\n false);\n\n }\n\n }\n\n ret = 0;\n\n\n\n bdrv_dirty_bitmap_deserialize_finish(bitmap);\n\n\n\nfinish:\n\n g_free(buf);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 22857 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_qcx(J2kDecoderContext *s, int n, J2kQuantStyle *q)\n\n{\n\n int i, x;\n\n\n\n if (s->buf_end - s->buf < 1)\n\n return AVERROR(EINVAL);\n\n\n\n x = bytestream_get_byte(&s->buf); // Sqcd\n\n\n\n q->nguardbits = x >> 5;\n\n q->quantsty = x & 0x1f;\n\n\n\n if (q->quantsty == J2K_QSTY_NONE){\n\n n -= 3;\n\n if (s->buf_end - s->buf < n)\n\n return AVERROR(EINVAL);\n\n for (i = 0; i < n; i++)\n\n q->expn[i] = bytestream_get_byte(&s->buf) >> 3;\n\n } else if (q->quantsty == J2K_QSTY_SI){\n\n if (s->buf_end - s->buf < 2)\n\n return AVERROR(EINVAL);\n\n x = bytestream_get_be16(&s->buf);\n\n q->expn[0] = x >> 11;\n\n q->mant[0] = x & 0x7ff;\n\n for (i = 1; i < 32 * 3; i++){\n\n int curexpn = FFMAX(0, q->expn[0] - (i-1)/3);\n\n q->expn[i] = curexpn;\n\n q->mant[i] = q->mant[0];\n\n }\n\n } else{\n\n n = (n - 3) >> 1;\n\n if (s->buf_end - s->buf < n)\n\n return AVERROR(EINVAL);\n\n for (i = 0; i < n; i++){\n\n x = bytestream_get_be16(&s->buf);\n\n q->expn[i] = x >> 11;\n\n q->mant[i] = x & 0x7ff;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 21016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_open(FsContext *ctx, V9fsPath *fs_path,\n\n int flags, V9fsFidOpenState *fs)\n\n{\n\n char buffer[PATH_MAX];\n\n char *path = fs_path->data;\n\n\n\n fs->fd = open(rpath(ctx, path, buffer), flags | O_NOFOLLOW);\n\n return fs->fd;\n\n}\n", + "output": "0", + "index": 14861 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_register_machine(QEMUMachine *m)\n\n{\n\n TypeInfo ti = {\n\n .name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL),\n\n .parent = TYPE_MACHINE,\n\n .class_init = machine_class_init,\n\n .class_data = (void *)m,\n\n };\n\n\n\n type_register(&ti);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18197 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void check_audio_video_inputs(int *has_video_ptr, int *has_audio_ptr)\n\n{\n\n int has_video, has_audio, i, j;\n\n AVFormatContext *ic;\n\n\n\n has_video = 0;\n\n has_audio = 0;\n\n for(j=0;jnb_streams;i++) {\n\n AVCodecContext *enc = &ic->streams[i]->codec;\n\n switch(enc->codec_type) {\n\n case CODEC_TYPE_AUDIO:\n\n has_audio = 1;\n\n break;\n\n case CODEC_TYPE_VIDEO:\n\n has_video = 1;\n\n break;\n\n default:\n\n abort();\n\n }\n\n }\n\n }\n\n *has_video_ptr = has_video;\n\n *has_audio_ptr = has_audio;\n\n}\n", + "output": "0", + "index": 20153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fix_bitshift(ShortenContext *s, int32_t *buffer)\n\n{\n\n int i;\n\n\n\n if (s->bitshift != 0)\n\n for (i = 0; i < s->blocksize; i++)\n\n buffer[s->nwrap + i] <<= s->bitshift;\n\n}\n", + "output": "1", + "index": 3425 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)\n\n{\n\n uint64_t *copy;\n\n\n\n copy = g_malloc(sizeof(value));\n\n *copy = cpu_to_le64(value);\n\n return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));\n\n}\n", + "output": "1", + "index": 6815 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_dimm_realize(DeviceState *dev, Error **errp)\n\n{\n\n PCDIMMDevice *dimm = PC_DIMM(dev);\n\n\n\n if (!dimm->hostmem) {\n\n error_setg(errp, \"'\" PC_DIMM_MEMDEV_PROP \"' property is not set\");\n\n return;\n\n }\n\n if (dimm->node >= nb_numa_nodes) {\n\n error_setg(errp, \"'DIMM property \" PC_DIMM_NODE_PROP \" has value %\"\n\n PRIu32 \"' which exceeds the number of numa nodes: %d\",\n\n dimm->node, nb_numa_nodes);\n\n return;\n\n }\n\n}\n", + "output": "0", + "index": 21354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){\n\n long i;\n\n for(i=0; i<=w-sizeof(long); i+=sizeof(long)){\n\n long a = *(long*)(src+i);\n\n long b = *(long*)(dst+i);\n\n *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);\n\n }\n\n for(; iwidth, 64);\n\n uint8_t *src_line;\n\n uint8_t *dst = buf;\n\n\n\n if (buf_size < 4 * aligned_width * avctx->height) {\n\n av_log(avctx, AV_LOG_ERROR, \"output buffer too small\\n\");\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n avctx->coded_frame->reference = 0;\n\n avctx->coded_frame->key_frame = 1;\n\n avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;\n\n src_line = pic->data[0];\n\n\n\n for (i = 0; i < avctx->height; i++) {\n\n uint16_t *src = (uint16_t *)src_line;\n\n for (j = 0; j < avctx->width; j++) {\n\n uint32_t pixel;\n\n uint16_t r = *src++ >> 6;\n\n uint16_t g = *src++ >> 6;\n\n uint16_t b = *src++ >> 4;\n\n if (avctx->codec_id == CODEC_ID_R210)\n\n pixel = (r << 20) | (g << 10) | b >> 2;\n\n else\n\n pixel = (r << 22) | (g << 12) | b;\n\n if (avctx->codec_id == CODEC_ID_AVRP)\n\n bytestream_put_le32(&dst, pixel);\n\n else\n\n bytestream_put_be32(&dst, pixel);\n\n }\n\n dst += (aligned_width - avctx->width) * 4;\n\n src_line += pic->linesize[0];\n\n }\n\n\n\n return 4 * aligned_width * avctx->height;\n\n}\n", + "output": "1", + "index": 11397 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,\n\n Error **errp)\n\n{\n\n BDRVBlkverifyState *s = bs->opaque;\n\n QemuOpts *opts;\n\n Error *local_err = NULL;\n\n int ret;\n\n\n\n opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);\n\n qemu_opts_absorb_qdict(opts, options, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n ret = -EINVAL;\n\n goto fail;\n\n\n\n\n /* Open the raw file */\n\n bs->file = bdrv_open_child(qemu_opt_get(opts, \"x-raw\"), options, \"raw\",\n\n bs, &child_file, false, &local_err);\n\n if (local_err) {\n\n ret = -EINVAL;\n\n error_propagate(errp, local_err);\n\n goto fail;\n\n\n\n\n /* Open the test file */\n\n s->test_file = bdrv_open_child(qemu_opt_get(opts, \"x-image\"), options,\n\n \"test\", bs, &child_format, false,\n\n &local_err);\n\n if (local_err) {\n\n ret = -EINVAL;\n\n error_propagate(errp, local_err);\n\n goto fail;\n\n\n\n\n ret = 0;\n\nfail:\n\n\n\n\n qemu_opts_del(opts);\n\n return ret;\n", + "output": "1", + "index": 3279 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_excp_620 (CPUPPCState *env)\n\n{\n\n#if !defined(CONFIG_USER_ONLY)\n\n env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100;\n\n env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200;\n\n env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300;\n\n env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400;\n\n env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;\n\n env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600;\n\n env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700;\n\n env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800;\n\n env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900;\n\n env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00;\n\n env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00;\n\n env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00;\n\n env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00;\n\n env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300;\n\n env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400;\n\n /* Hardware reset vector */\n\n env->hreset_vector = 0x0000000000000100ULL; /* ? */\n\n#endif\n\n}\n", + "output": "1", + "index": 3547 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_mutex_lock_iothread(void)\n\n{\n\n if (!tcg_enabled()) {\n\n qemu_mutex_lock(&qemu_global_mutex);\n\n } else {\n\n iothread_requesting_mutex = true;\n\n if (qemu_mutex_trylock(&qemu_global_mutex)) {\n\n qemu_cpu_kick_thread(first_cpu);\n\n qemu_mutex_lock(&qemu_global_mutex);\n\n }\n\n iothread_requesting_mutex = false;\n\n qemu_cond_broadcast(&qemu_io_proceeded_cond);\n\n }\n\n}\n", + "output": "1", + "index": 22534 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_pipe(ChardevHostdev *opts)\n\n{\n\n const char *filename = opts->device;\n\n CharDriverState *chr;\n\n WinCharState *s;\n\n\n\n chr = qemu_chr_alloc();\n\n s = g_malloc0(sizeof(WinCharState));\n\n chr->opaque = s;\n\n chr->chr_write = win_chr_write;\n\n chr->chr_close = win_chr_close;\n\n\n\n if (win_chr_pipe_init(chr, filename) < 0) {\n\n g_free(s);\n\n g_free(chr);\n\n return NULL;\n\n }\n\n return chr;\n\n}\n", + "output": "1", + "index": 26848 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_cli(void)\n\n{\n\n raise_exception(EXCP0D_GPF);\n\n}\n", + "output": "0", + "index": 12890 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *ts_value_string (char *buf, int buf_size, int64_t ts)\n\n{\n\n if (ts == AV_NOPTS_VALUE) {\n\n snprintf(buf, buf_size, \"N/A\");\n\n } else {\n\n snprintf(buf, buf_size, \"%\"PRId64, ts);\n\n }\n\n\n\n return buf;\n\n}\n", + "output": "0", + "index": 21329 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static UHCIAsync *uhci_async_alloc(UHCIState *s)\n\n{\n\n UHCIAsync *async = g_malloc(sizeof(UHCIAsync));\n\n\n\n memset(&async->packet, 0, sizeof(async->packet));\n\n async->uhci = s;\n\n async->valid = 0;\n\n async->td = 0;\n\n async->token = 0;\n\n async->done = 0;\n\n async->isoc = 0;\n\n usb_packet_init(&async->packet);\n\n qemu_sglist_init(&async->sgl, 1);\n\n\n\n return async;\n\n}\n", + "output": "0", + "index": 2081 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void t_gen_cc_jmp(TCGv pc_true, TCGv pc_false)\n\n{\n\n\tTCGv btaken;\n\n\tint l1;\n\n\n\n\tl1 = gen_new_label();\n\n\tbtaken = tcg_temp_new(TCG_TYPE_TL);\n\n\n\n\t/* Conditional jmp. */\n\n\ttcg_gen_mov_tl(btaken, env_btaken);\n\n\ttcg_gen_mov_tl(env_pc, pc_false);\n\n\ttcg_gen_brcondi_tl(TCG_COND_EQ, btaken, 0, l1);\n\n\ttcg_gen_mov_tl(env_pc, pc_true);\n\n\tgen_set_label(l1);\n\n\n\n\ttcg_temp_free(btaken);\n\n}\n", + "output": "0", + "index": 22546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void direct_ref_list_init(H264Context * const h){\n\n MpegEncContext * const s = &h->s;\n\n Picture * const ref1 = &h->ref_list[1][0];\n\n Picture * const cur = s->current_picture_ptr;\n\n int list, i, j;\n\n int sidx= s->picture_structure&1;\n\n int ref1sidx= ref1->reference&1;\n\n for(list=0; list<2; list++){\n\n cur->ref_count[sidx][list] = h->ref_count[list];\n\n for(j=0; jref_count[list]; j++)\n\n cur->ref_poc[sidx][list][j] = h->ref_list[list][j].poc;\n\n }\n\n if(s->picture_structure == PICT_FRAME){\n\n memcpy(cur->ref_count[0], cur->ref_count[1], sizeof(cur->ref_count[0]));\n\n memcpy(cur->ref_poc [0], cur->ref_poc [1], sizeof(cur->ref_poc [0]));\n\n }\n\n if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred)\n\n return;\n\n for(list=0; list<2; list++){\n\n for(i=0; iref_count[ref1sidx][list]; i++){\n\n const int poc = ref1->ref_poc[ref1sidx][list][i];\n\n h->map_col_to_list0[list][i] = 0; /* bogus; fills in for missing frames */\n\n for(j=0; jref_count[list]; j++)\n\n if(h->ref_list[list][j].poc == poc){\n\n h->map_col_to_list0[list][i] = j;\n\n break;\n\n }\n\n }\n\n }\n\n if(FRAME_MBAFF){\n\n for(list=0; list<2; list++){\n\n for(i=0; iref_count[ref1sidx][list]; i++){\n\n j = h->map_col_to_list0[list][i];\n\n h->map_col_to_list0_field[list][2*i] = 2*j;\n\n h->map_col_to_list0_field[list][2*i+1] = 2*j+1;\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 18508 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nvme_set_bootindex(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n NvmeCtrl *s = NVME(obj);\n\n int32_t boot_index;\n\n Error *local_err = NULL;\n\n\n\n visit_type_int32(v, &boot_index, name, &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n /* check whether bootindex is present in fw_boot_order list */\n\n check_boot_index(boot_index, &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n /* change bootindex to a new one */\n\n s->conf.bootindex = boot_index;\n\n\n\nout:\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n }\n\n}\n", + "output": "1", + "index": 4594 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_slirp_smb(const char *exported_dir)\n\n{\n\n struct in_addr vserver_addr = { .s_addr = 0 };\n\n\n\n if (legacy_smb_export) {\n\n fprintf(stderr, \"-smb given twice\\n\");\n\n exit(1);\n\n }\n\n legacy_smb_export = exported_dir;\n\n if (!QTAILQ_EMPTY(&slirp_stacks)) {\n\n slirp_smb(QTAILQ_FIRST(&slirp_stacks), NULL, exported_dir,\n\n vserver_addr);\n\n }\n\n}\n", + "output": "1", + "index": 19239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void test_server_connect(TestServer *server)\n\n{\n\n test_server_create_chr(server, \",reconnect=1\");\n\n}\n", + "output": "1", + "index": 24393 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)\n\n{\n\n uint8_t byte;\n\n\n\n if (s->buf_end - s->buf < 5)\n\n return AVERROR(EINVAL);\n\n c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution levels - 1\n\n\n\n /* compute number of resolution levels to decode */\n\n if (c->nreslevels < s->reduction_factor)\n\n c->nreslevels2decode = 1;\n\n else\n\n c->nreslevels2decode = c->nreslevels - s->reduction_factor;\n\n\n\n c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; // cblk width\n\n c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; // cblk height\n\n\n\n c->cblk_style = bytestream_get_byte(&s->buf);\n\n if (c->cblk_style != 0) { // cblk style\n\n av_log(s->avctx, AV_LOG_ERROR, \"no extra cblk styles supported\\n\");\n\n return -1;\n\n }\n\n c->transform = bytestream_get_byte(&s->buf); // DWT transformation type\n\n /* set integer 9/7 DWT in case of BITEXACT flag */\n\n if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))\n\n c->transform = FF_DWT97_INT;\n\n\n\n if (c->csty & JPEG2000_CSTY_PREC) {\n\n int i;\n\n for (i = 0; i < c->nreslevels; i++) {\n\n byte = bytestream_get_byte(&s->buf);\n\n c->log2_prec_widths[i] = byte & 0x0F; // precinct PPx\n\n c->log2_prec_heights[i] = (byte >> 4) & 0x0F; // precinct PPy\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 12010 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address, int rw)\n\n{\n\n hwaddr physical;\n\n int prot;\n\n int access_type;\n\n int ret = 0;\n\n\n\n /* data access */\n\n access_type = ACCESS_INT;\n\n ret = get_physical_address(env, &physical, &prot,\n\n address, rw, access_type);\n\n if (ret != TLBRET_MATCH) {\n\n raise_mmu_exception(env, address, rw, ret);\n\n return -1LL;\n\n } else {\n\n return physical;\n\n }\n\n}\n", + "output": "1", + "index": 7623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n copy_width16_msa(src, stride, dst, stride, 16);\n\n}\n", + "output": "0", + "index": 20015 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void aio_context_setup(AioContext *ctx)\n\n{\n\n}\n", + "output": "0", + "index": 57 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t vfio_bar_read(void *opaque,\n\n hwaddr addr, unsigned size)\n\n{\n\n VFIOBAR *bar = opaque;\n\n union {\n\n uint8_t byte;\n\n uint16_t word;\n\n uint32_t dword;\n\n uint64_t qword;\n\n } buf;\n\n uint64_t data = 0;\n\n\n\n if (pread(bar->fd, &buf, size, bar->fd_offset + addr) != size) {\n\n error_report(\"%s(,0x%\"HWADDR_PRIx\", %d) failed: %m\",\n\n __func__, addr, size);\n\n return (uint64_t)-1;\n\n }\n\n\n\n switch (size) {\n\n case 1:\n\n data = buf.byte;\n\n break;\n\n case 2:\n\n data = le16_to_cpu(buf.word);\n\n break;\n\n case 4:\n\n data = le32_to_cpu(buf.dword);\n\n break;\n\n default:\n\n hw_error(\"vfio: unsupported read size, %d bytes\\n\", size);\n\n break;\n\n }\n\n\n\n DPRINTF(\"%s(BAR%d+0x%\"HWADDR_PRIx\", %d) = 0x%\"PRIx64\"\\n\",\n\n __func__, bar->nr, addr, size, data);\n\n\n\n /* Same as write above */\n\n vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));\n\n\n\n return data;\n\n}\n", + "output": "0", + "index": 25358 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void idiv64(uint64_t *plow, uint64_t *phigh, int64_t b)\n\n{\n\n int sa, sb;\n\n sa = ((int64_t)*phigh < 0);\n\n if (sa)\n\n neg128(plow, phigh);\n\n sb = (b < 0);\n\n if (sb)\n\n b = -b;\n\n div64(plow, phigh, b);\n\n if (sa ^ sb)\n\n *plow = - *plow;\n\n if (sa)\n\n *phigh = - *phigh;\n\n}\n", + "output": "1", + "index": 848 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_tcg_configure(QemuOpts *opts, Error **errp)\n\n{\n\n const char *t = qemu_opt_get(opts, \"thread\");\n\n if (t) {\n\n if (strcmp(t, \"multi\") == 0) {\n\n if (TCG_OVERSIZED_GUEST) {\n\n error_setg(errp, \"No MTTCG when guest word size > hosts\");\n\n } else if (use_icount) {\n\n error_setg(errp, \"No MTTCG when icount is enabled\");\n\n } else {\n\n\n\n\n\n if (!check_tcg_memory_orders_compatible()) {\n\n error_report(\"Guest expects a stronger memory ordering \"\n\n \"than the host provides\");\n\n error_printf(\"This may cause strange/hard to debug errors\");\n\n }\n\n mttcg_enabled = true;\n\n }\n\n } else if (strcmp(t, \"single\") == 0) {\n\n mttcg_enabled = false;\n\n } else {\n\n error_setg(errp, \"Invalid 'thread' setting %s\", t);\n\n }\n\n } else {\n\n mttcg_enabled = default_mttcg_enabled();\n\n }\n\n}", + "output": "1", + "index": 8736 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,\n\n AVFilterBufferRef *ref)\n\n{\n\n AVFilterLink *outlink = ctx->outputs[0];\n\n AVFilterBufferRef *buf;\n\n int channels, data_size, i;\n\n\n\n switch (outlink->type) {\n\n\n\n case AVMEDIA_TYPE_VIDEO:\n\n buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,\n\n ref->video->w, ref->video->h);\n\n\n\n av_image_copy(buf->data, buf->linesize,\n\n (void*)ref->data, ref->linesize,\n\n ref->format, ref->video->w, ref->video->h);\n\n break;\n\n\n\n case AVMEDIA_TYPE_AUDIO:\n\n buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,\n\n ref->audio->nb_samples);\n\n\n\n channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);\n\n av_samples_copy(buf->extended_data, ref->buf->extended_data,\n\n 0, 0, ref->audio->nb_samples,\n\n channels,\n\n ref->format);\n\n break;\n\n\n\n default:\n\n\n }\n\n avfilter_copy_buffer_ref_props(buf, ref);\n\n return buf;\n\n}", + "output": "1", + "index": 384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_disk_reset(DeviceState *dev)\n\n{\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev.qdev, dev);\n\n uint64_t nb_sectors;\n\n\n\n scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET));\n\n\n\n bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);\n\n nb_sectors /= s->qdev.blocksize / 512;\n\n if (nb_sectors) {\n\n nb_sectors--;\n\n }\n\n s->qdev.max_lba = nb_sectors;\n\n /* reset tray statuses */\n\n s->tray_locked = 0;\n\n s->tray_open = 0;\n\n}\n", + "output": "0", + "index": 5054 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vc1_filter_line(uint8_t* src, int stride, int pq){\n\n int a0, a1, a2, a3, d, clip, filt3 = 0;\n\n uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;\n\n if(FFABS(a0) < pq){\n\n a1 = (2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3;\n\n a2 = (2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3;\n\n a3 = FFMIN(FFABS(a1), FFABS(a2));\n\n if(a3 < FFABS(a0)){\n\n d = 5 * ((a0 >=0 ? a3 : -a3) - a0) / 8;\n\n clip = (src[-1*stride] - src[ 0*stride])/2;\n\n if(clip){\n\n filt3 = 1;\n\n if(clip > 0)\n\n d = av_clip(d, 0, clip);\n\n else\n\n d = av_clip(d, clip, 0);\n\n src[-1*stride] = cm[src[-1*stride] - d];\n\n src[ 0*stride] = cm[src[ 0*stride] + d];\n\n }\n\n }\n\n }\n\n return filt3;\n\n}\n", + "output": "0", + "index": 18646 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs)\n\n{\n\n int i;\n\n NetClientState *nc;\n\n\n\n n->mergeable_rx_bufs = mergeable_rx_bufs;\n\n\n\n n->guest_hdr_len = n->mergeable_rx_bufs ?\n\n sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);\n\n\n\n for (i = 0; i < n->max_queues; i++) {\n\n nc = qemu_get_subqueue(n->nic, i);\n\n\n\n if (peer_has_vnet_hdr(n) &&\n\n tap_has_vnet_hdr_len(nc->peer, n->guest_hdr_len)) {\n\n tap_set_vnet_hdr_len(nc->peer, n->guest_hdr_len);\n\n n->host_hdr_len = n->guest_hdr_len;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 9682 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,\n\n const char *name, V9fsPath *target)\n\n{\n\n if (dir_path) {\n\n v9fs_path_sprintf(target, \"%s/%s\", dir_path->data, name);\n\n } else {\n\n v9fs_path_sprintf(target, \"%s\", name);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 8548 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t helper_mulldo(CPUPPCState *env, uint64_t arg1, uint64_t arg2)\n\n{\n\n int64_t th;\n\n uint64_t tl;\n\n\n\n muls64(&tl, (uint64_t *)&th, arg1, arg2);\n\n /* If th != 0 && th != -1, then we had an overflow */\n\n if (likely((uint64_t)(th + 1) <= 1)) {\n\n env->ov = 0;\n\n } else {\n\n env->so = env->ov = 1;\n\n }\n\n return (int64_t)tl;\n\n}\n", + "output": "1", + "index": 3729 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CharDriverState *qemu_chr_alloc(void)\n\n{\n\n CharDriverState *chr = g_malloc0(sizeof(CharDriverState));\n\n\n return chr;\n\n}", + "output": "1", + "index": 20761 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvmppc_update_sdr1(target_ulong sdr1)\n\n{\n\n CPUState *cs;\n\n\n\n CPU_FOREACH(cs) {\n\n run_on_cpu(cs, kvmppc_pivot_hpt_cpu, RUN_ON_CPU_TARGET_PTR(sdr1));\n\n }\n\n}\n", + "output": "0", + "index": 25232 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode,\n\n int lim_q1, int lim_p1,\n\n int alpha, int beta, int beta2, int chroma, int edge){\n\n rv40_adaptive_loop_filter(src, stride, 1, dmode, lim_q1, lim_p1,\n\n alpha, beta, beta2, chroma, edge);\n\n}\n", + "output": "0", + "index": 22182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1,\n\n TCGv arg2, int add_ca, int compute_ca,\n\n int compute_ov)\n\n{\n\n TCGv t0, t1;\n\n\n\n if ((!compute_ca && !compute_ov) ||\n\n (!TCGV_EQUAL(ret, arg1) && !TCGV_EQUAL(ret, arg2))) {\n\n t0 = ret;\n\n } else {\n\n t0 = tcg_temp_local_new();\n\n }\n\n\n\n if (add_ca) {\n\n t1 = tcg_temp_local_new();\n\n tcg_gen_mov_tl(t1, cpu_ca);\n\n } else {\n\n TCGV_UNUSED(t1);\n\n }\n\n\n\n if (compute_ca) {\n\n /* Start with XER CA disabled, the most likely case */\n\n tcg_gen_movi_tl(cpu_ca, 0);\n\n }\n\n if (compute_ov) {\n\n /* Start with XER OV disabled, the most likely case */\n\n tcg_gen_movi_tl(cpu_ov, 0);\n\n }\n\n\n\n if (add_ca) {\n\n tcg_gen_not_tl(t0, arg1);\n\n tcg_gen_add_tl(t0, t0, arg2);\n\n gen_op_arith_compute_ca(ctx, t0, arg2, 0);\n\n tcg_gen_add_tl(t0, t0, t1);\n\n gen_op_arith_compute_ca(ctx, t0, t1, 0);\n\n tcg_temp_free(t1);\n\n } else {\n\n tcg_gen_sub_tl(t0, arg2, arg1);\n\n if (compute_ca) {\n\n gen_op_arith_compute_ca(ctx, t0, arg2, 1);\n\n }\n\n }\n\n if (compute_ov) {\n\n gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);\n\n }\n\n\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, t0);\n\n\n\n if (!TCGV_EQUAL(t0, ret)) {\n\n tcg_gen_mov_tl(ret, t0);\n\n tcg_temp_free(t0);\n\n }\n\n}\n", + "output": "1", + "index": 249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tcg_op_remove(TCGContext *s, TCGOp *op)\n\n{\n\n int next = op->next;\n\n int prev = op->prev;\n\n\n\n /* We should never attempt to remove the list terminator. */\n\n tcg_debug_assert(op != &s->gen_op_buf[0]);\n\n\n\n s->gen_op_buf[next].prev = prev;\n\n s->gen_op_buf[prev].next = next;\n\n\n\n memset(op, 0, sizeof(*op));\n\n\n\n#ifdef CONFIG_PROFILER\n\n atomic_set(&s->prof.del_op_count, s->prof.del_op_count + 1);\n\n#endif\n\n}\n", + "output": "1", + "index": 6578 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rom_reset(void *unused)\n\n{\n\n Rom *rom;\n\n\n\n QTAILQ_FOREACH(rom, &roms, next) {\n\n if (rom->fw_file) {\n\n continue;\n\n }\n\n if (rom->data == NULL)\n\n continue;\n\n cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);\n\n if (rom->isrom) {\n\n /* rom needs to be written only once */\n\n qemu_free(rom->data);\n\n rom->data = NULL;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 15529 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtsp_read_seek(AVFormatContext *s, int stream_index,\n\n int64_t timestamp, int flags)\n\n{\n\n RTSPState *rt = s->priv_data;\n\n\n\n rt->seek_timestamp = av_rescale_q(timestamp, s->streams[stream_index]->time_base, AV_TIME_BASE_Q);\n\n switch(rt->state) {\n\n default:\n\n case RTSP_STATE_IDLE:\n\n break;\n\n case RTSP_STATE_PLAYING:\n\n if (rtsp_read_pause(s) != 0)\n\n return -1;\n\n rt->state = RTSP_STATE_SEEKING;\n\n if (rtsp_read_play(s) != 0)\n\n return -1;\n\n break;\n\n case RTSP_STATE_PAUSED:\n\n rt->state = RTSP_STATE_IDLE;\n\n break;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 5733 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(entry)(CPUXtensaState *env, uint32_t pc, uint32_t s, uint32_t imm)\n{\n int callinc = (env->sregs[PS] & PS_CALLINC) >> PS_CALLINC_SHIFT;\n if (s > 3 || ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) != 0) {\n qemu_log(\"Illegal entry instruction(pc = %08x), PS = %08x\\n\",\n pc, env->sregs[PS]);\n HELPER(exception_cause)(env, pc, ILLEGAL_INSTRUCTION_CAUSE);\n } else {\n env->regs[(callinc << 2) | (s & 3)] = env->regs[s] - (imm << 3);\n rotate_window(env, callinc);\n env->sregs[WINDOW_START] |=\n windowstart_bit(env->sregs[WINDOW_BASE], env);", + "output": "1", + "index": 20309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *visitor_get(TestOutputVisitorData *data)\n\n{\n\n data->str = string_output_get_string(data->sov);\n\n g_assert(data->str);\n\n return data->str;\n\n}\n", + "output": "0", + "index": 4273 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int applehttp_open(URLContext *h, const char *uri, int flags)\n\n{\n\n AppleHTTPContext *s;\n\n int ret, i;\n\n const char *nested_url;\n\n\n\n if (flags & AVIO_FLAG_WRITE)\n\n return AVERROR(ENOSYS);\n\n\n\n s = av_mallocz(sizeof(AppleHTTPContext));\n\n if (!s)\n\n return AVERROR(ENOMEM);\n\n h->priv_data = s;\n\n h->is_streamed = 1;\n\n\n\n if (av_strstart(uri, \"applehttp+\", &nested_url)) {\n\n av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));\n\n } else if (av_strstart(uri, \"applehttp://\", &nested_url)) {\n\n av_strlcpy(s->playlisturl, \"http://\", sizeof(s->playlisturl));\n\n av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));\n\n } else {\n\n av_log(h, AV_LOG_ERROR, \"Unsupported url %s\\n\", uri);\n\n ret = AVERROR(EINVAL);\n\n goto fail;\n\n }\n\n\n\n if ((ret = parse_playlist(h, s->playlisturl)) < 0)\n\n goto fail;\n\n\n\n if (s->n_segments == 0 && s->n_variants > 0) {\n\n int max_bandwidth = 0, maxvar = -1;\n\n for (i = 0; i < s->n_variants; i++) {\n\n if (s->variants[i]->bandwidth > max_bandwidth || i == 0) {\n\n max_bandwidth = s->variants[i]->bandwidth;\n\n maxvar = i;\n\n }\n\n }\n\n av_strlcpy(s->playlisturl, s->variants[maxvar]->url,\n\n sizeof(s->playlisturl));\n\n if ((ret = parse_playlist(h, s->playlisturl)) < 0)\n\n goto fail;\n\n }\n\n\n\n if (s->n_segments == 0) {\n\n av_log(h, AV_LOG_WARNING, \"Empty playlist\\n\");\n\n ret = AVERROR(EIO);\n\n goto fail;\n\n }\n\n s->cur_seq_no = s->start_seq_no;\n\n if (!s->finished && s->n_segments >= 3)\n\n s->cur_seq_no = s->start_seq_no + s->n_segments - 3;\n\n\n\n return 0;\n\n\n\nfail:\n\n av_free(s);\n\n return ret;\n\n}\n", + "output": "1", + "index": 8516 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,\n\n int track_index, int sample)\n\n{\n\n MOVMuxContext *mov = s->priv_data;\n\n MOVTrack *trk = &mov->tracks[track_index];\n\n AVFormatContext *rtp_ctx = trk->rtp_ctx;\n\n uint8_t *buf = NULL;\n\n int size;\n\n AVIOContext *hintbuf = NULL;\n\n AVPacket hint_pkt;\n\n int ret = 0, count;\n\n\n\n if (!rtp_ctx)\n\n return AVERROR(ENOENT);\n\n if (!rtp_ctx->pb)\n\n return AVERROR(ENOMEM);\n\n\n\n sample_queue_push(&trk->sample_queue, pkt, sample);\n\n\n\n /* Feed the packet to the RTP muxer */\n\n ff_write_chained(rtp_ctx, 0, pkt, s);\n\n\n\n /* Fetch the output from the RTP muxer, open a new output buffer\n\n * for next time. */\n\n size = avio_close_dyn_buf(rtp_ctx->pb, &buf);\n\n if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb,\n\n RTP_MAX_PACKET_SIZE)) < 0)\n\n goto done;\n\n\n\n if (size <= 0)\n\n goto done;\n\n\n\n /* Open a buffer for writing the hint */\n\n if ((ret = avio_open_dyn_buf(&hintbuf)) < 0)\n\n goto done;\n\n av_init_packet(&hint_pkt);\n\n count = write_hint_packets(hintbuf, buf, size, trk, &hint_pkt.dts);\n\n av_freep(&buf);\n\n\n\n /* Write the hint data into the hint track */\n\n hint_pkt.size = size = avio_close_dyn_buf(hintbuf, &buf);\n\n hint_pkt.data = buf;\n\n hint_pkt.pts = hint_pkt.dts;\n\n hint_pkt.stream_index = track_index;\n\n if (pkt->flags & AV_PKT_FLAG_KEY)\n\n hint_pkt.flags |= AV_PKT_FLAG_KEY;\n\n if (count > 0)\n\n ff_mov_write_packet(s, &hint_pkt);\n\ndone:\n\n av_free(buf);\n\n sample_queue_retain(&trk->sample_queue);\n\n return ret;\n\n}\n", + "output": "0", + "index": 26343 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void x86_cpu_enable_xsave_components(X86CPU *cpu)\n\n{\n\n CPUX86State *env = &cpu->env;\n\n int i;\n\n\n\n if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) {\n\n return;\n\n }\n\n\n\n env->xsave_components = (XSTATE_FP_MASK | XSTATE_SSE_MASK);\n\n for (i = 2; i < ARRAY_SIZE(x86_ext_save_areas); i++) {\n\n const ExtSaveArea *esa = &x86_ext_save_areas[i];\n\n if (env->features[esa->feature] & esa->bits) {\n\n env->xsave_components |= (1ULL << i);\n\n }\n\n }\n\n\n\n if (kvm_enabled()) {\n\n KVMState *s = kvm_state;\n\n uint64_t kvm_mask = kvm_arch_get_supported_cpuid(s, 0xd, 0, R_EDX);\n\n kvm_mask <<= 32;\n\n kvm_mask |= kvm_arch_get_supported_cpuid(s, 0xd, 0, R_EAX);\n\n env->xsave_components &= kvm_mask;\n\n }\n\n}\n", + "output": "0", + "index": 21473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_pci_load_rom(VFIODevice *vdev)\n\n{\n\n struct vfio_region_info reg_info = {\n\n .argsz = sizeof(reg_info),\n\n .index = VFIO_PCI_ROM_REGION_INDEX\n\n };\n\n uint64_t size;\n\n off_t off = 0;\n\n size_t bytes;\n\n\n\n if (ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {\n\n error_report(\"vfio: Error getting ROM info: %m\");\n\n return;\n\n }\n\n\n\n DPRINTF(\"Device %04x:%02x:%02x.%x ROM:\\n\", vdev->host.domain,\n\n vdev->host.bus, vdev->host.slot, vdev->host.function);\n\n DPRINTF(\" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\\n\",\n\n (unsigned long)reg_info.size, (unsigned long)reg_info.offset,\n\n (unsigned long)reg_info.flags);\n\n\n\n vdev->rom_size = size = reg_info.size;\n\n vdev->rom_offset = reg_info.offset;\n\n\n\n if (!vdev->rom_size) {\n\n\n error_report(\"vfio-pci: Cannot read device rom at \"\n\n \"%04x:%02x:%02x.%x\\n\",\n\n vdev->host.domain, vdev->host.bus, vdev->host.slot,\n\n vdev->host.function);\n\n error_printf(\"Device option ROM contents are probably invalid \"\n\n \"(check dmesg).\\nSkip option ROM probe with rombar=0, \"\n\n \"or load from file with romfile=\\n\");\n\n return;\n\n }\n\n\n\n vdev->rom = g_malloc(size);\n\n memset(vdev->rom, 0xff, size);\n\n\n\n while (size) {\n\n bytes = pread(vdev->fd, vdev->rom + off, size, vdev->rom_offset + off);\n\n if (bytes == 0) {\n\n break;\n\n } else if (bytes > 0) {\n\n off += bytes;\n\n size -= bytes;\n\n } else {\n\n if (errno == EINTR || errno == EAGAIN) {\n\n continue;\n\n }\n\n error_report(\"vfio: Error reading device ROM: %m\");\n\n break;\n\n }\n\n }\n\n}", + "output": "1", + "index": 12275 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void checkasm_check_fixed_dsp(void)\n\n{\n\n LOCAL_ALIGNED_32(int32_t, src0, [BUF_SIZE]);\n\n LOCAL_ALIGNED_32(int32_t, src1, [BUF_SIZE]);\n\n LOCAL_ALIGNED_32(int32_t, src2, [BUF_SIZE]);\n\n AVFixedDSPContext *fdsp = avpriv_alloc_fixed_dsp(1);\n\n\n\n randomize_buffers();\n\n if (check_func(fdsp->vector_fmul, \"vector_fmul\"))\n\n check_vector_fmul(src0, src1);\n\n if (check_func(fdsp->vector_fmul_add, \"vector_fmul_add\"))\n\n check_vector_fmul_add(src0, src1, src2);\n\n if (check_func(fdsp->vector_fmul_reverse, \"vector_fmul_reverse\"))\n\n check_vector_fmul(src0, src1);\n\n if (check_func(fdsp->vector_fmul_window, \"vector_fmul_window\"))\n\n check_vector_fmul_window(src0, src1, src2);\n\n if (check_func(fdsp->vector_fmul_window_scaled, \"vector_fmul_window_scaled\"))\n\n check_vector_fmul_window_scaled(src0, src1, src2);\n\n report(\"vector_fmul\");\n\n if (check_func(fdsp->butterflies_fixed, \"butterflies_fixed\"))\n\n check_butterflies(src0, src1);\n\n report(\"butterflies_fixed\");\n\n if (check_func(fdsp->scalarproduct_fixed, \"scalarproduct_fixed\"))\n\n check_scalarproduct_fixed(src0, src1);\n\n report(\"scalarproduct_fixed\");\n\n\n\n av_freep(&fdsp);\n\n}\n", + "output": "0", + "index": 4514 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,\n\n Error **errp)\n\n{\n\n TCXState *s = opaque;\n\n FILE *f;\n\n uint8_t *d, *d1, v;\n\n int ret, y, x;\n\n\n\n f = fopen(filename, \"wb\");\n\n if (!f) {\n\n error_setg(errp, \"failed to open file '%s': %s\", filename,\n\n strerror(errno));\n\n return;\n\n }\n\n ret = fprintf(f, \"P6\\n%d %d\\n%d\\n\", s->width, s->height, 255);\n\n if (ret < 0) {\n\n goto write_err;\n\n }\n\n d1 = s->vram;\n\n for(y = 0; y < s->height; y++) {\n\n d = d1;\n\n for(x = 0; x < s->width; x++) {\n\n v = *d;\n\n ret = fputc(s->r[v], f);\n\n if (ret == EOF) {\n\n goto write_err;\n\n }\n\n ret = fputc(s->g[v], f);\n\n if (ret == EOF) {\n\n goto write_err;\n\n }\n\n ret = fputc(s->b[v], f);\n\n if (ret == EOF) {\n\n goto write_err;\n\n }\n\n d++;\n\n }\n\n d1 += MAXX;\n\n }\n\n\n\nout:\n\n fclose(f);\n\n return;\n\n\n\nwrite_err:\n\n error_setg(errp, \"failed to write to file '%s': %s\", filename,\n\n strerror(errno));\n\n unlink(filename);\n\n goto out;\n\n}\n", + "output": "0", + "index": 18039 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dump_json_image_info_list(ImageInfoList *list)\n\n{\n\n Error *local_err = NULL;\n\n QString *str;\n\n QmpOutputVisitor *ov = qmp_output_visitor_new();\n\n QObject *obj;\n\n visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list,\n\n &local_err);\n\n obj = qmp_output_get_qobject(ov);\n\n str = qobject_to_json_pretty(obj);\n\n assert(str != NULL);\n\n printf(\"%s\\n\", qstring_get_str(str));\n\n qobject_decref(obj);\n\n qmp_output_visitor_cleanup(ov);\n\n QDECREF(str);\n\n}\n", + "output": "1", + "index": 5766 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,\n\n int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\n\n BlockDriverCompletionFunc *cb, void *opaque)\n\n{\n\n CURLAIOCB *acb;\n\n\n\n acb = qemu_aio_get(&curl_aiocb_info, bs, cb, opaque);\n\n\n\n acb->qiov = qiov;\n\n acb->sector_num = sector_num;\n\n acb->nb_sectors = nb_sectors;\n\n\n\n acb->bh = qemu_bh_new(curl_readv_bh_cb, acb);\n\n qemu_bh_schedule(acb->bh);\n\n return &acb->common;\n\n}\n", + "output": "0", + "index": 10249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void wdt_i6300esb_init(void)\n\n{\n\n watchdog_add_model(&model);\n\n}\n", + "output": "1", + "index": 12914 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, MatroskaMuxContext *mkv,\n\n ebml_master master)\n\n{\n\n uint8_t *buf, crc[4];\n\n int size;\n\n\n\n if (pb->seekable) {\n\n size = avio_close_dyn_buf(*dyn_cp, &buf);\n\n if (mkv->write_crc && mkv->mode != MODE_WEBM) {\n\n AV_WL32(crc, av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), UINT32_MAX, buf, size) ^ UINT32_MAX);\n\n put_ebml_binary(pb, EBML_ID_CRC32, crc, sizeof(crc));\n\n }\n\n avio_write(pb, buf, size);\n\n end_ebml_master(pb, master);\n\n } else {\n\n end_ebml_master(*dyn_cp, master);\n\n size = avio_close_dyn_buf(*dyn_cp, &buf);\n\n avio_write(pb, buf, size);\n\n }\n\n av_free(buf);\n\n *dyn_cp = NULL;\n\n}\n", + "output": "0", + "index": 5589 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ff_h264_idct_add16_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){\n\n int i;\n\n for(i=0; i<16; i++){\n\n int nnz = nnzc[ scan8[i] ];\n\n if(nnz){\n\n if(nnz==1 && block[i*16]) ff_h264_idct_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);\n\n else ff_h264_idct_add_mmx (dst + block_offset[i], block + i*16, stride);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 24688 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vncws_tls_handshake_io(void *opaque)\n\n{\n\n struct VncState *vs = (struct VncState *)opaque;\n\n\n\n VNC_DEBUG(\"Handshake IO continue\\n\");\n\n vncws_start_tls_handshake(vs);\n\n}\n", + "output": "0", + "index": 15629 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn qed_co_pwrite_zeroes_cb(void *opaque, int ret)\n\n{\n\n QEDWriteZeroesCB *cb = opaque;\n\n\n\n cb->done = true;\n\n cb->ret = ret;\n\n if (cb->co) {\n\n qemu_coroutine_enter(cb->co, NULL);\n\n }\n\n}\n", + "output": "1", + "index": 4153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_gpu_resource_create_2d(VirtIOGPU *g,\n\n struct virtio_gpu_ctrl_command *cmd)\n\n{\n\n pixman_format_code_t pformat;\n\n struct virtio_gpu_simple_resource *res;\n\n struct virtio_gpu_resource_create_2d c2d;\n\n\n\n VIRTIO_GPU_FILL_CMD(c2d);\n\n trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format,\n\n c2d.width, c2d.height);\n\n\n\n if (c2d.resource_id == 0) {\n\n qemu_log_mask(LOG_GUEST_ERROR, \"%s: resource id 0 is not allowed\\n\",\n\n __func__);\n\n cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;\n\n return;\n\n }\n\n\n\n res = virtio_gpu_find_resource(g, c2d.resource_id);\n\n if (res) {\n\n qemu_log_mask(LOG_GUEST_ERROR, \"%s: resource already exists %d\\n\",\n\n __func__, c2d.resource_id);\n\n cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;\n\n return;\n\n }\n\n\n\n res = g_new0(struct virtio_gpu_simple_resource, 1);\n\n\n\n res->width = c2d.width;\n\n res->height = c2d.height;\n\n res->format = c2d.format;\n\n res->resource_id = c2d.resource_id;\n\n\n\n pformat = get_pixman_format(c2d.format);\n\n if (!pformat) {\n\n qemu_log_mask(LOG_GUEST_ERROR,\n\n \"%s: host couldn't handle guest format %d\\n\",\n\n __func__, c2d.format);\n\n g_free(res);\n\n cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;\n\n return;\n\n }\n\n res->image = pixman_image_create_bits(pformat,\n\n c2d.width,\n\n c2d.height,\n\n NULL, 0);\n\n\n\n if (!res->image) {\n\n qemu_log_mask(LOG_GUEST_ERROR,\n\n \"%s: resource creation failed %d %d %d\\n\",\n\n __func__, c2d.resource_id, c2d.width, c2d.height);\n\n g_free(res);\n\n cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;\n\n return;\n\n }\n\n\n\n QTAILQ_INSERT_HEAD(&g->reslist, res, next);\n\n}\n", + "output": "1", + "index": 7003 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_thread_set_name(QemuThread *thread, const char *name)\n\n{\n\n#ifdef CONFIG_PTHREAD_SETNAME_NP\n\n pthread_setname_np(thread->thread, name);\n\n#endif\n\n}\n", + "output": "1", + "index": 5623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "matroska_parse_cluster (MatroskaDemuxContext *matroska)\n\n{\n\n int res = 0;\n\n uint32_t id;\n\n uint64_t cluster_time = 0;\n\n uint8_t *data;\n\n int64_t pos;\n\n int size;\n\n\n\n av_log(matroska->ctx, AV_LOG_DEBUG,\n\n \"parsing cluster at %\"PRId64\"\\n\", url_ftell(&matroska->ctx->pb));\n\n\n\n while (res == 0) {\n\n if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {\n\n res = AVERROR_IO;\n\n break;\n\n } else if (matroska->level_up) {\n\n matroska->level_up--;\n\n break;\n\n }\n\n\n\n switch (id) {\n\n /* cluster timecode */\n\n case MATROSKA_ID_CLUSTERTIMECODE: {\n\n uint64_t num;\n\n if ((res = ebml_read_uint(matroska, &id, &num)) < 0)\n\n break;\n\n cluster_time = num;\n\n break;\n\n }\n\n\n\n /* a group of blocks inside a cluster */\n\n case MATROSKA_ID_BLOCKGROUP:\n\n if ((res = ebml_read_master(matroska, &id)) < 0)\n\n break;\n\n res = matroska_parse_blockgroup(matroska, cluster_time);\n\n break;\n\n\n\n case MATROSKA_ID_SIMPLEBLOCK:\n\n pos = url_ftell(&matroska->ctx->pb);\n\n res = ebml_read_binary(matroska, &id, &data, &size);\n\n if (res == 0)\n\n res = matroska_parse_block(matroska, data, size, pos,\n\n cluster_time, -1, NULL, NULL);\n\n break;\n\n\n\n default:\n\n av_log(matroska->ctx, AV_LOG_INFO,\n\n \"Unknown entry 0x%x in cluster data\\n\", id);\n\n /* fall-through */\n\n\n\n case EBML_ID_VOID:\n\n res = ebml_read_skip(matroska);\n\n break;\n\n }\n\n\n\n if (matroska->level_up) {\n\n matroska->level_up--;\n\n break;\n\n }\n\n }\n\n\n\n return res;\n\n}\n", + "output": "0", + "index": 10096 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "get_sigframe(struct emulated_sigaction *ka, CPUX86State *env, size_t frame_size)\n\n{\n\n\tunsigned long esp;\n\n\n\n\t/* Default to using normal stack */\n\n\tesp = env->regs[R_ESP];\n\n#if 0\n\n\t/* This is the X/Open sanctioned signal stack switching. */\n\n\tif (ka->sa.sa_flags & SA_ONSTACK) {\n\n\t\tif (sas_ss_flags(esp) == 0)\n\n\t\t\tesp = current->sas_ss_sp + current->sas_ss_size;\n\n\t}\n\n\n\n\t/* This is the legacy signal stack switching. */\n\n\telse if ((regs->xss & 0xffff) != __USER_DS &&\n\n\t\t !(ka->sa.sa_flags & SA_RESTORER) &&\n\n\t\t ka->sa.sa_restorer) {\n\n\t\tesp = (unsigned long) ka->sa.sa_restorer;\n\n\t}\n\n#endif\n\n\treturn (void *)((esp - frame_size) & -8ul);\n\n}\n", + "output": "1", + "index": 527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_change(const char *device, const char *target, const char *fmt)\n\n{\n\n if (strcmp(device, \"vnc\") == 0) {\n\n\tdo_change_vnc(target);\n\n } else {\n\n\tdo_change_block(device, target, fmt);\n\n }\n\n}\n", + "output": "0", + "index": 3443 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void handle_mousemotion(SDL_Event *ev)\n\n{\n\n int max_x, max_y;\n\n struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);\n\n\n\n if (qemu_input_is_absolute() || absolute_enabled) {\n\n int scr_w, scr_h;\n\n SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h);\n\n max_x = scr_w - 1;\n\n max_y = scr_h - 1;\n\n if (gui_grab && (ev->motion.x == 0 || ev->motion.y == 0 ||\n\n ev->motion.x == max_x || ev->motion.y == max_y)) {\n\n sdl_grab_end(scon);\n\n }\n\n if (!gui_grab &&\n\n (ev->motion.x > 0 && ev->motion.x < max_x &&\n\n ev->motion.y > 0 && ev->motion.y < max_y)) {\n\n sdl_grab_start(scon);\n\n }\n\n }\n\n if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {\n\n sdl_send_mouse_event(scon, ev->motion.xrel, ev->motion.yrel,\n\n ev->motion.x, ev->motion.y, ev->motion.state);\n\n }\n\n}\n", + "output": "0", + "index": 294 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void rtsp_close_streams(AVFormatContext *s)\n\n{\n\n RTSPState *rt = s->priv_data;\n\n int i;\n\n RTSPStream *rtsp_st;\n\n\n\n for (i = 0; i < rt->nb_rtsp_streams; i++) {\n\n rtsp_st = rt->rtsp_streams[i];\n\n if (rtsp_st) {\n\n if (rtsp_st->transport_priv) {\n\n if (s->oformat) {\n\n AVFormatContext *rtpctx = rtsp_st->transport_priv;\n\n av_write_trailer(rtpctx);\n\n url_fclose(rtpctx->pb);\n\n\n\n av_free(rtpctx->streams[0]);\n\n av_free(rtpctx);\n\n } else if (rt->transport == RTSP_TRANSPORT_RDT)\n\n ff_rdt_parse_close(rtsp_st->transport_priv);\n\n else\n\n rtp_parse_close(rtsp_st->transport_priv);\n\n }\n\n if (rtsp_st->rtp_handle)\n\n url_close(rtsp_st->rtp_handle);\n\n if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)\n\n rtsp_st->dynamic_handler->close(\n\n rtsp_st->dynamic_protocol_context);\n\n }\n\n }\n\n av_free(rt->rtsp_streams);\n\n if (rt->asf_ctx) {\n\n av_close_input_stream (rt->asf_ctx);\n\n rt->asf_ctx = NULL;\n\n }\n\n av_freep(&rt->auth_b64);\n\n}", + "output": "1", + "index": 2452 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize)\n\n{\n\n#if 0\n\n\tstruct {\n\n\t\tuint32_t offset; /* 0x80000000 + sample start - 4 */\n\n\t\tunsigned char unknown1[3]; /* 03 12 04 */\n\n\t\tunsigned char channel; /* 1 or 2 */\n\n\t\tuint32_t freq;\n\n\t\tuint32_t size;\n\n\t\tuint32_t unknown2; /* 01 f4 03 00 */\n\n\t\tuint32_t unknown3; /* 00 00 00 00 */\n\n\t\tuint32_t unknown4; /* 00 00 00 00 */\n\n\n\n\t/* if loop\n\n\t\tunknown3 00 15 00 01\n\n\t\tunknown4 00 00 00 01\n\n\t\tlong loop_start_sample;\n\n\t\tlong loop_start_byte;\n\n\t\tlong loop_end_sample;\n\n\t\tlong loop_end_byte;\n\n\t\tlong \n\n\t*/\n\n\t} adxhdr; /* big endian */\n\n\t/* offset-6 \"(c)CRI\" */\n\n#endif\n\n\twrite_long(buf+0x00,0x80000000|0x20);\n\n\twrite_long(buf+0x04,0x03120400|avctx->channels);\n\n\twrite_long(buf+0x08,avctx->sample_rate);\n\n\twrite_long(buf+0x0c,0); /* FIXME: set after */\n\n\twrite_long(buf+0x10,0x01040300);\n\n\twrite_long(buf+0x14,0x00000000);\n\n\twrite_long(buf+0x18,0x00000000);\n\n\tmemcpy(buf+0x1c,\"\\0\\0(c)CRI\",8);\n\n\treturn 0x20+4;\n\n}\n", + "output": "1", + "index": 17395 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int read_targphys(const char *name,\n\n int fd, target_phys_addr_t dst_addr, size_t nbytes)\n\n{\n\n uint8_t *buf;\n\n size_t did;\n\n\n\n buf = g_malloc(nbytes);\n\n did = read(fd, buf, nbytes);\n\n if (did > 0)\n\n rom_add_blob_fixed(\"read\", buf, did, dst_addr);\n\n g_free(buf);\n\n return did;\n\n}\n", + "output": "1", + "index": 1959 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gdb_accept(void)\n\n{\n\n GDBState *s;\n\n struct sockaddr_in sockaddr;\n\n socklen_t len;\n\n int fd;\n\n\n\n for(;;) {\n\n len = sizeof(sockaddr);\n\n fd = accept(gdbserver_fd, (struct sockaddr *)&sockaddr, &len);\n\n if (fd < 0 && errno != EINTR) {\n\n perror(\"accept\");\n\n return;\n\n } else if (fd >= 0) {\n\n#ifndef _WIN32\n\n fcntl(fd, F_SETFD, FD_CLOEXEC);\n\n#endif\n\n break;\n\n }\n\n }\n\n\n\n /* set short latency */\n\n socket_set_nodelay(fd);\n\n\n\n s = g_malloc0(sizeof(GDBState));\n\n s->c_cpu = first_cpu;\n\n s->g_cpu = first_cpu;\n\n s->fd = fd;\n\n gdb_has_xml = false;\n\n\n\n gdbserver_state = s;\n\n\n\n fcntl(fd, F_SETFL, O_NONBLOCK);\n\n}\n", + "output": "0", + "index": 23855 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int submit_stats(AVCodecContext *avctx)\n\n{\n\n#ifdef TH_ENCCTL_2PASS_IN\n\n TheoraContext *h = avctx->priv_data;\n\n int bytes;\n\n\n if (!avctx->stats_in) {\n\n av_log(avctx, AV_LOG_ERROR, \"No statsfile for second pass\\n\");\n\n return AVERROR(EINVAL);\n\n\n h->stats_size = strlen(avctx->stats_in) * 3/4;\n\n h->stats = av_malloc(h->stats_size);\n\n\n\n\n\n h->stats_size = av_base64_decode(h->stats, avctx->stats_in, h->stats_size);\n\n\n while (h->stats_size - h->stats_offset > 0) {\n\n bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_IN,\n\n h->stats + h->stats_offset,\n\n h->stats_size - h->stats_offset);\n\n if (bytes < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Error submitting stats\\n\");\n\n return AVERROR_EXTERNAL;\n\n\n if (!bytes)\n\n return 0;\n\n h->stats_offset += bytes;\n\n\n return 0;\n\n#else\n\n av_log(avctx, AV_LOG_ERROR, \"libtheora too old to support 2pass\\n\");\n\n return AVERROR(ENOSUP);\n\n#endif\n", + "output": "1", + "index": 24919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct pathelem *add_dir_maybe(struct pathelem *path)\n\n{\n\n DIR *dir;\n\n\n\n if ((dir = opendir(path->pathname)) != NULL) {\n\n struct dirent *dirent;\n\n\n\n while ((dirent = readdir(dir)) != NULL) {\n\n if (!streq(dirent->d_name,\".\") && !streq(dirent->d_name,\"..\")){\n\n path = add_entry(path, dirent->d_name);\n\n }\n\n }\n\n closedir(dir);\n\n }\n\n return path;\n\n}\n", + "output": "1", + "index": 13729 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void flat_print_str(WriterContext *wctx, const char *key, const char *value)\n\n{\n\n FlatContext *flat = wctx->priv;\n\n AVBPrint buf;\n\n\n\n flat_print_key_prefix(wctx);\n\n av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);\n\n printf(\"%s=\", flat_escape_key_str(&buf, key, flat->sep));\n\n av_bprint_clear(&buf);\n\n printf(\"\\\"%s\\\"\\n\", flat_escape_value_str(&buf, value));\n\n av_bprint_finalize(&buf, NULL);\n\n}\n", + "output": "0", + "index": 19034 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_movs(DisasContext *s, int ot)\n\n{\n\n gen_string_movl_A0_ESI(s);\n\n gen_op_ld_T0_A0(ot + s->mem_index);\n\n gen_string_movl_A0_EDI(s);\n\n gen_op_st_T0_A0(ot + s->mem_index);\n\n gen_op_movl_T0_Dshift[ot]();\n\n#ifdef TARGET_X86_64\n\n if (s->aflag == 2) {\n\n gen_op_addq_ESI_T0();\n\n gen_op_addq_EDI_T0();\n\n } else\n\n#endif\n\n if (s->aflag) {\n\n gen_op_addl_ESI_T0();\n\n gen_op_addl_EDI_T0();\n\n } else {\n\n gen_op_addw_ESI_T0();\n\n gen_op_addw_EDI_T0();\n\n }\n\n}\n", + "output": "0", + "index": 10489 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx)\n\n{\n\n#if HAVE_7REGS && HAVE_TEN_OPERANDS\n\n c->mlp_filter_channel = mlp_filter_channel_x86;\n\n#endif\n\n}\n", + "output": "1", + "index": 5731 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int32 floatx80_to_int32_round_to_zero( floatx80 a STATUS_PARAM )\n\n{\n\n flag aSign;\n\n int32 aExp, shiftCount;\n\n uint64_t aSig, savedASig;\n\n int32 z;\n\n\n\n aSig = extractFloatx80Frac( a );\n\n aExp = extractFloatx80Exp( a );\n\n aSign = extractFloatx80Sign( a );\n\n if ( 0x401E < aExp ) {\n\n if ( ( aExp == 0x7FFF ) && (uint64_t) ( aSig<<1 ) ) aSign = 0;\n\n goto invalid;\n\n }\n\n else if ( aExp < 0x3FFF ) {\n\n if ( aExp || aSig ) STATUS(float_exception_flags) |= float_flag_inexact;\n\n return 0;\n\n }\n\n shiftCount = 0x403E - aExp;\n\n savedASig = aSig;\n\n aSig >>= shiftCount;\n\n z = aSig;\n\n if ( aSign ) z = - z;\n\n if ( ( z < 0 ) ^ aSign ) {\n\n invalid:\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;\n\n }\n\n if ( ( aSig<op1, dc->op2));\n\n\tcris_cc_mask(dc, 0);\n\n\n\n\tt[0] = tcg_temp_new(TCG_TYPE_TL);\n\n\tif (dc->op2 == PR_CCS) {\n\n\t\tcris_evaluate_flags(dc);\n\n\t\tt_gen_mov_TN_reg(t[0], dc->op1);\n\n\t\tif (dc->tb_flags & U_FLAG) {\n\n\t\t\tt[1] = tcg_temp_new(TCG_TYPE_TL);\n\n\t\t\t/* User space is not allowed to touch all flags. */\n\n\t\t\ttcg_gen_andi_tl(t[0], t[0], 0x39f);\n\n\t\t\ttcg_gen_andi_tl(t[1], cpu_PR[PR_CCS], ~0x39f);\n\n\t\t\ttcg_gen_or_tl(t[0], t[1], t[0]);\n\n\t\t\ttcg_temp_free(t[1]);\n\n\t\t}\n\n\t}\n\n\telse\n\n\t\tt_gen_mov_TN_reg(t[0], dc->op1);\n\n\n\n\tt_gen_mov_preg_TN(dc, dc->op2, t[0]);\n\n\tif (dc->op2 == PR_CCS) {\n\n\t\tcris_update_cc_op(dc, CC_OP_FLAGS, 4);\n\n\t\tdc->flags_uptodate = 1;\n\n\t}\n\n\ttcg_temp_free(t[0]);\n\n\treturn 2;\n\n}\n", + "output": "0", + "index": 810 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int postcopy_ram_enable_notify(MigrationIncomingState *mis)\n\n{\n\n /* Open the fd for the kernel to give us userfaults */\n\n mis->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n\n if (mis->userfault_fd == -1) {\n\n error_report(\"%s: Failed to open userfault fd: %s\", __func__,\n\n strerror(errno));\n\n return -1;\n\n }\n\n\n\n /*\n\n * Although the host check already tested the API, we need to\n\n * do the check again as an ABI handshake on the new fd.\n\n */\n\n if (!ufd_version_check(mis->userfault_fd)) {\n\n return -1;\n\n }\n\n\n\n /* Now an eventfd we use to tell the fault-thread to quit */\n\n mis->userfault_quit_fd = eventfd(0, EFD_CLOEXEC);\n\n if (mis->userfault_quit_fd == -1) {\n\n error_report(\"%s: Opening userfault_quit_fd: %s\", __func__,\n\n strerror(errno));\n\n close(mis->userfault_fd);\n\n return -1;\n\n }\n\n\n\n qemu_sem_init(&mis->fault_thread_sem, 0);\n\n qemu_thread_create(&mis->fault_thread, \"postcopy/fault\",\n\n postcopy_ram_fault_thread, mis, QEMU_THREAD_JOINABLE);\n\n qemu_sem_wait(&mis->fault_thread_sem);\n\n qemu_sem_destroy(&mis->fault_thread_sem);\n\n mis->have_fault_thread = true;\n\n\n\n /* Mark so that we get notified of accesses to unwritten areas */\n\n if (qemu_ram_foreach_block(ram_block_enable_notify, mis)) {\n\n return -1;\n\n }\n\n\n\n /*\n\n * Ballooning can mark pages as absent while we're postcopying\n\n * that would cause false userfaults.\n\n */\n\n qemu_balloon_inhibit(true);\n\n\n\n trace_postcopy_ram_enable_notify();\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13003 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ahci_shutdown(AHCIQState *ahci)\n\n{\n\n QOSState *qs = ahci->parent;\n\n\n\n ahci_clean_mem(ahci);\n\n free_ahci_device(ahci->dev);\n\n g_free(ahci);\n\n qtest_shutdown(qs);\n\n}\n", + "output": "0", + "index": 25321 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_gpio_set(void *opaque, int line, int level)\n\n{\n\n PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;\n\n CPUState *cpu = CPU(s->cpu);\n\n int bank;\n\n uint32_t mask;\n\n\n\n if (line >= s->lines) {\n\n printf(\"%s: No GPIO pin %i\\n\", __FUNCTION__, line);\n\n return;\n\n }\n\n\n\n bank = line >> 5;\n\n mask = 1U << (line & 31);\n\n\n\n if (level) {\n\n s->status[bank] |= s->rising[bank] & mask &\n\n ~s->ilevel[bank] & ~s->dir[bank];\n\n s->ilevel[bank] |= mask;\n\n } else {\n\n s->status[bank] |= s->falling[bank] & mask &\n\n s->ilevel[bank] & ~s->dir[bank];\n\n s->ilevel[bank] &= ~mask;\n\n }\n\n\n\n if (s->status[bank] & mask)\n\n pxa2xx_gpio_irq_update(s);\n\n\n\n /* Wake-up GPIOs */\n\n if (cpu->halted && (mask & ~s->dir[bank] & pxa2xx_gpio_wake[bank])) {\n\n cpu_interrupt(cpu, CPU_INTERRUPT_EXITTB);\n\n }\n\n}\n", + "output": "0", + "index": 23150 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void IRQ_setbit(IRQ_queue_t *q, int n_IRQ)\n\n{\n\n q->pending++;\n\n set_bit(q->queue, n_IRQ);\n\n}\n", + "output": "1", + "index": 5263 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_blocksize(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n DeviceState *dev = DEVICE(obj);\n\n Property *prop = opaque;\n\n uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);\n\n Error *local_err = NULL;\n\n const int64_t min = 512;\n\n const int64_t max = 32768;\n\n\n\n if (dev->realized) {\n\n qdev_prop_set_after_realize(dev, name, errp);\n\n return;\n\n }\n\n\n\n visit_type_uint16(v, &value, name, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n if (value < min || value > max) {\n\n error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,\n\n dev->id?:\"\", name, (int64_t)value, min, max);\n\n return;\n\n }\n\n\n\n /* We rely on power-of-2 blocksizes for bitmasks */\n\n if ((value & (value - 1)) != 0) {\n\n error_setg(errp,\n\n \"Property %s.%s doesn't take value '%\" PRId64 \"', it's not a power of 2\",\n\n dev->id ?: \"\", name, (int64_t)value);\n\n return;\n\n }\n\n\n\n *ptr = value;\n\n}\n", + "output": "0", + "index": 3028 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_uint64(QEMUFile *f, void *pv, size_t size)\n\n{\n\n uint64_t *v = pv;\n\n qemu_get_be64s(f, v);\n\n return 0;\n\n}\n", + "output": "1", + "index": 11817 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ast_read_header(AVFormatContext *s)\n\n{\n\n int codec;\n\n AVStream *st;\n\n\n\n st = avformat_new_stream(s, NULL);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n avio_skip(s->pb, 8);\n\n codec = avio_rb16(s->pb);\n\n switch (codec) {\n\n case 1:\n\n st->codec->codec_id = AV_CODEC_ID_PCM_S16BE_PLANAR;\n\n break;\n\n default:\n\n av_log(s, AV_LOG_ERROR, \"unsupported codec %d\\n\", codec);\n\n }\n\n\n\n avio_skip(s->pb, 2);\n\n\n\n st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n\n st->codec->channels = avio_rb16(s->pb);\n\n if (!st->codec->channels)\n\n return AVERROR_INVALIDDATA;\n\n\n\n if (st->codec->channels == 2)\n\n st->codec->channel_layout = AV_CH_LAYOUT_STEREO;\n\n else if (st->codec->channels == 4)\n\n st->codec->channel_layout = AV_CH_LAYOUT_4POINT0;\n\n\n\n avio_skip(s->pb, 2);\n\n st->codec->sample_rate = avio_rb32(s->pb);\n\n if (st->codec->sample_rate <= 0)\n\n return AVERROR_INVALIDDATA;\n\n st->start_time = 0;\n\n st->duration = avio_rb32(s->pb);\n\n avio_skip(s->pb, 40);\n\n avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 24055 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t qemu_enqueue_packet_iov(VLANClientState *sender,\n\n const struct iovec *iov, int iovcnt,\n\n NetPacketSent *sent_cb)\n\n{\n\n VLANPacket *packet;\n\n size_t max_len = 0;\n\n int i;\n\n\n\n max_len = calc_iov_length(iov, iovcnt);\n\n\n\n packet = qemu_malloc(sizeof(VLANPacket) + max_len);\n\n packet->sender = sender;\n\n packet->sent_cb = sent_cb;\n\n packet->size = 0;\n\n\n\n for (i = 0; i < iovcnt; i++) {\n\n size_t len = iov[i].iov_len;\n\n\n\n memcpy(packet->data + packet->size, iov[i].iov_base, len);\n\n packet->size += len;\n\n }\n\n\n\n TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry);\n\n\n\n return packet->size;\n\n}\n", + "output": "0", + "index": 5685 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_readdir_r(FsContext *ctx, V9fsFidOpenState *fs,\n\n struct dirent *entry,\n\n struct dirent **result)\n\n{\n\n return readdir_r(fs->dir, entry, result);\n\n}\n", + "output": "0", + "index": 21429 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rc4030_unrealize(DeviceState *dev, Error **errp)\n\n{\n\n rc4030State *s = RC4030(dev);\n\n int i;\n\n\n\n timer_free(s->periodic_timer);\n\n\n\n address_space_destroy(&s->dma_as);\n\n object_unparent(OBJECT(&s->dma_tt));\n\n object_unparent(OBJECT(&s->dma_tt_alias));\n\n object_unparent(OBJECT(&s->dma_mr));\n\n for (i = 0; i < MAX_TL_ENTRIES; ++i) {\n\n memory_region_del_subregion(&s->dma_mr, &s->dma_mrs[i]);\n\n object_unparent(OBJECT(&s->dma_mrs[i]));\n\n }\n\n}\n", + "output": "1", + "index": 12225 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ohci_reset(OHCIState *ohci)\n\n{\n\n OHCIPort *port;\n\n int i;\n\n\n\n ohci->ctl = 0;\n\n ohci->old_ctl = 0;\n\n ohci->status = 0;\n\n ohci->intr_status = 0;\n\n ohci->intr = OHCI_INTR_MIE;\n\n\n\n ohci->hcca = 0;\n\n ohci->ctrl_head = ohci->ctrl_cur = 0;\n\n ohci->bulk_head = ohci->bulk_cur = 0;\n\n ohci->per_cur = 0;\n\n ohci->done = 0;\n\n ohci->done_count = 7;\n\n\n\n /* FSMPS is marked TBD in OCHI 1.0, what gives ffs?\n\n * I took the value linux sets ...\n\n */\n\n ohci->fsmps = 0x2778;\n\n ohci->fi = 0x2edf;\n\n ohci->fit = 0;\n\n ohci->frt = 0;\n\n ohci->frame_number = 0;\n\n ohci->pstart = 0;\n\n ohci->lst = OHCI_LS_THRESH;\n\n\n\n ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports;\n\n ohci->rhdesc_b = 0x0; /* Impl. specific */\n\n ohci->rhstatus = 0;\n\n\n\n for (i = 0; i < ohci->num_ports; i++)\n\n {\n\n port = &ohci->rhport[i];\n\n port->ctrl = 0;\n\n if (port->port.dev)\n\n ohci_attach(&port->port, port->port.dev);\n\n }\n\n if (ohci->async_td) {\n\n usb_cancel_packet(&ohci->usb_packet);\n\n ohci->async_td = 0;\n\n }\n\n dprintf(\"usb-ohci: Reset %s\\n\", ohci->name);\n\n}\n", + "output": "1", + "index": 13934 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove)\n\n{\n\n MonFdset *mon_fdset;\n\n MonFdsetFd *mon_fdset_fd_dup;\n\n\n\n QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {\n\n QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {\n\n if (mon_fdset_fd_dup->fd == dup_fd) {\n\n if (remove) {\n\n QLIST_REMOVE(mon_fdset_fd_dup, next);\n\n if (QLIST_EMPTY(&mon_fdset->dup_fds)) {\n\n monitor_fdset_cleanup(mon_fdset);\n\n }\n\n }\n\n return mon_fdset->id;\n\n }\n\n }\n\n }\n\n return -1;\n\n}\n", + "output": "1", + "index": 23306 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct omap_sdrc_s *omap_sdrc_init(MemoryRegion *sysmem,\n\n hwaddr base)\n\n{\n\n struct omap_sdrc_s *s = (struct omap_sdrc_s *)\n\n g_malloc0(sizeof(struct omap_sdrc_s));\n\n\n\n omap_sdrc_reset(s);\n\n\n\n memory_region_init_io(&s->iomem, NULL, &omap_sdrc_ops, s, \"omap.sdrc\", 0x1000);\n\n memory_region_add_subregion(sysmem, base, &s->iomem);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 15767 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_scale_idx(GetBitContext *gb, int ref)\n\n{\n\n int t = get_vlc2(gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;\n\n if (t == 8)\n\n return get_bits(gb, 6);\n\n return ref + t;\n\n}\n", + "output": "0", + "index": 8551 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len)\n\n{\n\n int ret = 0;\n\n const uint8_t *buf_offset;\n\n\n\n SCLPConsoleLM *scon = SCLPLM_CONSOLE(event);\n\n\n\n if (!scon->chr) {\n\n /* If there's no backend, we can just say we consumed all data. */\n\n return len;\n\n }\n\n\n\n buf_offset = buf;\n\n while (len > 0) {\n\n ret = qemu_chr_fe_write(scon->chr, buf, len);\n\n if (ret == 0) {\n\n /* a pty doesn't seem to be connected - no error */\n\n len = 0;\n\n } else if (ret == -EAGAIN || (ret > 0 && ret < len)) {\n\n len -= ret;\n\n buf_offset += ret;\n\n } else {\n\n len = 0;\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 3361 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parallel_parse(const char *devname)\n\n{\n\n static int index = 0;\n\n char label[32];\n\n\n\n if (strcmp(devname, \"none\") == 0)\n\n return 0;\n\n if (index == MAX_PARALLEL_PORTS) {\n\n fprintf(stderr, \"qemu: too many parallel ports\\n\");\n\n exit(1);\n\n }\n\n snprintf(label, sizeof(label), \"parallel%d\", index);\n\n parallel_hds[index] = qemu_chr_new(label, devname, NULL);\n\n if (!parallel_hds[index]) {\n\n fprintf(stderr, \"qemu: could not connect parallel device\"\n\n \" to character backend '%s'\\n\", devname);\n\n return -1;\n\n }\n\n index++;\n\n return 0;\n\n}\n", + "output": "0", + "index": 12667 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xv_write_trailer(AVFormatContext *s)\n\n{\n\n XVContext *xv = s->priv_data;\n\n\n\n XShmDetach(xv->display, &xv->yuv_shminfo);\n\n shmdt(xv->yuv_image->data);\n\n XFree(xv->yuv_image);\n\n\n XCloseDisplay(xv->display);\n\n return 0;\n\n}", + "output": "1", + "index": 15319 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t bitband_readb(void *opaque, target_phys_addr_t offset)\n\n{\n\n uint8_t v;\n\n cpu_physical_memory_read(bitband_addr(opaque, offset), &v, 1);\n\n return (v & (1 << ((offset >> 2) & 7))) != 0;\n\n}\n", + "output": "0", + "index": 7846 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,\n unsigned size, MemTxAttrs attrs)\n{\n GICv3State *s = opaque;\n GICv3CPUState *cs;\n MemTxResult r;\n int cpuidx;\n /* This region covers all the redistributor pages; there are\n * (for GICv3) two 64K pages per CPU. At the moment they are\n * all contiguous (ie in this one region), though we might later\n * want to allow splitting of redistributor pages into several\n * blocks so we can support more CPUs.\n */\n cpuidx = offset / 0x20000;\n offset %= 0x20000;\n assert(cpuidx < s->num_cpu);\n cs = &s->cpu[cpuidx];\n switch (size) {\n case 1:\n r = gicr_readb(cs, offset, data, attrs);\n break;\n case 4:\n r = gicr_readl(cs, offset, data, attrs);\n break;\n case 8:\n r = gicr_readll(cs, offset, data, attrs);\n break;\n default:\n r = MEMTX_ERROR;\n break;\n }\n if (r == MEMTX_ERROR) {\n qemu_log_mask(LOG_GUEST_ERROR,\n \"%s: invalid guest read at offset \" TARGET_FMT_plx\n \"size %u\\n\", __func__, offset, size);\n trace_gicv3_redist_badread(gicv3_redist_affid(cs), offset,\n size, attrs.secure);\n } else {\n trace_gicv3_redist_read(gicv3_redist_affid(cs), offset, *data,\n size, attrs.secure);\n }\n return r;\n}", + "output": "1", + "index": 9228 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "net_rx_pkt_pull_data(struct NetRxPkt *pkt,\n\n const struct iovec *iov, int iovcnt,\n\n size_t ploff)\n\n{\n\n if (pkt->vlan_stripped) {\n\n net_rx_pkt_iovec_realloc(pkt, iovcnt + 1);\n\n\n\n pkt->vec[0].iov_base = pkt->ehdr_buf;\n\n pkt->vec[0].iov_len = sizeof(pkt->ehdr_buf);\n\n\n\n pkt->tot_len =\n\n iov_size(iov, iovcnt) - ploff + sizeof(struct eth_header);\n\n\n\n pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1,\n\n iov, iovcnt, ploff, pkt->tot_len);\n\n } else {\n\n net_rx_pkt_iovec_realloc(pkt, iovcnt);\n\n\n\n pkt->tot_len = iov_size(iov, iovcnt) - ploff;\n\n pkt->vec_len = iov_copy(pkt->vec, pkt->vec_len_total,\n\n iov, iovcnt, ploff, pkt->tot_len);\n\n }\n\n\n\n eth_get_protocols(pkt->vec, pkt->vec_len, &pkt->isip4, &pkt->isip6,\n\n &pkt->isudp, &pkt->istcp,\n\n &pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off,\n\n &pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_info);\n\n\n\n trace_net_rx_pkt_parsed(pkt->isip4, pkt->isip6, pkt->isudp, pkt->istcp,\n\n pkt->l3hdr_off, pkt->l4hdr_off, pkt->l5hdr_off);\n\n}\n", + "output": "1", + "index": 13606 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vtd_realize(DeviceState *dev, Error **errp)\n\n{\n\n MachineState *ms = MACHINE(qdev_get_machine());\n\n MachineClass *mc = MACHINE_GET_CLASS(ms);\n\n PCMachineState *pcms =\n\n PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));\n\n PCIBus *bus;\n\n IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);\n\n X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev);\n\n\n\n if (!pcms) {\n\n error_setg(errp, \"Machine-type '%s' not supported by intel-iommu\",\n\n mc->name);\n\n return;\n\n }\n\n\n\n bus = pcms->bus;\n\n x86_iommu->type = TYPE_INTEL;\n\n\n\n if (!vtd_decide_config(s, errp)) {\n\n return;\n\n }\n\n\n\n QLIST_INIT(&s->notifiers_list);\n\n memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));\n\n memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,\n\n \"intel_iommu\", DMAR_REG_SIZE);\n\n sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);\n\n /* No corresponding destroy */\n\n s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,\n\n g_free, g_free);\n\n s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,\n\n g_free, g_free);\n\n vtd_init(s);\n\n sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);\n\n pci_setup_iommu(bus, vtd_host_dma_iommu, dev);\n\n /* Pseudo address space under root PCI bus. */\n\n pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);\n\n}\n", + "output": "0", + "index": 1753 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sun4m_common_init(int ram_size, int boot_device, DisplayState *ds,\n\n const char *kernel_filename, const char *kernel_cmdline,\n\n const char *initrd_filename, const char *cpu_model,\n\n unsigned int machine)\n\n{\n\n sun4m_hw_init(&hwdefs[machine], ram_size, ds, cpu_model);\n\n\n\n sun4m_load_kernel(hwdefs[machine].vram_size, ram_size, boot_device,\n\n kernel_filename, kernel_cmdline, initrd_filename,\n\n hwdefs[machine].machine_id);\n\n}\n", + "output": "0", + "index": 5833 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,\n\n const char *name,\n\n BlockDriverState **pbs,\n\n AioContext **paio,\n\n Error **errp)\n\n{\n\n BlockDriverState *bs;\n\n BdrvDirtyBitmap *bitmap;\n\n AioContext *aio_context;\n\n\n\n if (!node) {\n\n error_setg(errp, \"Node cannot be NULL\");\n\n return NULL;\n\n }\n\n if (!name) {\n\n error_setg(errp, \"Bitmap name cannot be NULL\");\n\n return NULL;\n\n }\n\n bs = bdrv_lookup_bs(node, node, NULL);\n\n if (!bs) {\n\n error_setg(errp, \"Node '%s' not found\", node);\n\n return NULL;\n\n }\n\n\n\n aio_context = bdrv_get_aio_context(bs);\n\n aio_context_acquire(aio_context);\n\n\n\n bitmap = bdrv_find_dirty_bitmap(bs, name);\n\n if (!bitmap) {\n\n error_setg(errp, \"Dirty bitmap '%s' not found\", name);\n\n goto fail;\n\n }\n\n\n\n if (pbs) {\n\n *pbs = bs;\n\n }\n\n if (paio) {\n\n *paio = aio_context;\n\n } else {\n\n aio_context_release(aio_context);\n\n }\n\n\n\n return bitmap;\n\n\n\n fail:\n\n aio_context_release(aio_context);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 10583 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,\n\n void *value, size_t size, int flags)\n\n{\n\n char buffer[PATH_MAX];\n\n if (strncmp(name, \"user.virtfs.\", 12) == 0) {\n\n /*\n\n * Don't allow fetch of user.virtfs namesapce\n\n * in case of mapped security\n\n */\n\n errno = EACCES;\n\n return -1;\n\n }\n\n return lsetxattr(rpath(ctx, path, buffer), name, value, size, flags);\n\n}\n", + "output": "0", + "index": 23500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n\n{\n\n uint32_t minor_ver;\n\n int comp_brand_size;\n\n char minor_ver_str[11]; /* 32 bit integer -> 10 digits + null */\n\n char* comp_brands_str;\n\n uint8_t type[5] = {0};\n\n\n\n avio_read(pb, type, 4);\n\n if (strcmp(type, \"qt \"))\n\n c->isom = 1;\n\n av_log(c->fc, AV_LOG_DEBUG, \"ISO: File Type Major Brand: %.4s\\n\",(char *)&type);\n\n av_dict_set(&c->fc->metadata, \"major_brand\", type, 0);\n\n minor_ver = avio_rb32(pb); /* minor version */\n\n snprintf(minor_ver_str, sizeof(minor_ver_str), \"%\"PRIu32\"\", minor_ver);\n\n av_dict_set(&c->fc->metadata, \"minor_version\", minor_ver_str, 0);\n\n\n\n comp_brand_size = atom.size - 8;\n\n if (comp_brand_size < 0)\n\n return AVERROR_INVALIDDATA;\n\n comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */\n\n if (!comp_brands_str)\n\n return AVERROR(ENOMEM);\n\n avio_read(pb, comp_brands_str, comp_brand_size);\n\n comp_brands_str[comp_brand_size] = 0;\n\n av_dict_set(&c->fc->metadata, \"compatible_brands\", comp_brands_str, 0);\n\n av_freep(&comp_brands_str);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 11979 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int libquvi_probe(AVProbeData *p)\n\n{\n\n int score;\n\n quvi_t q;\n\n QUVIcode rc;\n\n\n\n rc = quvi_init(&q);\n\n if (rc != QUVI_OK)\n\n return AVERROR(ENOMEM);\n\n score = quvi_supported(q, (char *)p->filename) == QUVI_OK ? AVPROBE_SCORE_EXTENSION : 0;\n\n quvi_close(&q);\n\n return score;\n\n}\n", + "output": "1", + "index": 21954 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static USBPort *xhci_lookup_uport(XHCIState *xhci, uint32_t *slot_ctx)\n\n{\n\n USBPort *uport;\n\n char path[32];\n\n int i, pos, port;\n\n\n\n port = (slot_ctx[1]>>16) & 0xFF;\n\n\n\n\n port = xhci->ports[port-1].uport->index+1;\n\n pos = snprintf(path, sizeof(path), \"%d\", port);\n\n for (i = 0; i < 5; i++) {\n\n port = (slot_ctx[0] >> 4*i) & 0x0f;\n\n if (!port) {\n\n break;\n\n\n pos += snprintf(path + pos, sizeof(path) - pos, \".%d\", port);\n\n\n\n\n QTAILQ_FOREACH(uport, &xhci->bus.used, next) {\n\n if (strcmp(uport->path, path) == 0) {\n\n return uport;\n\n\n\n", + "output": "1", + "index": 24547 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void exynos4210_init_board_irqs(Exynos4210Irq *s)\n\n{\n\n uint32_t grp, bit, irq_id, n;\n\n\n\n for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) {\n\n s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n],\n\n s->ext_combiner_irq[n]);\n\n\n\n irq_id = 0;\n\n if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) ||\n\n n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) {\n\n /* MCT_G0 is passed to External GIC */\n\n irq_id = EXT_GIC_ID_MCT_G0;\n\n }\n\n if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) ||\n\n n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) {\n\n /* MCT_G1 is passed to External and GIC */\n\n irq_id = EXT_GIC_ID_MCT_G1;\n\n }\n\n if (irq_id) {\n\n s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n],\n\n s->ext_gic_irq[irq_id-32]);\n\n }\n\n\n\n }\n\n for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) {\n\n /* these IDs are passed to Internal Combiner and External GIC */\n\n grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n);\n\n bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n);\n\n irq_id = combiner_grp_to_gic_id[grp -\n\n EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit];\n\n\n\n if (irq_id) {\n\n s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n],\n\n s->ext_gic_irq[irq_id-32]);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 7178 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool qio_task_propagate_error(QIOTask *task,\n\n Error **errp)\n\n{\n\n if (task->err) {\n\n error_propagate(errp, task->err);\n\n\n return true;\n\n }\n\n\n\n return false;\n\n}", + "output": "1", + "index": 8111 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void tcg_out_ldst(TCGContext *s, int ret, int addr,\n\n int offset, int op)\n\n{\n\n if (check_fit_tl(offset, 13)) {\n\n tcg_out32(s, op | INSN_RD(ret) | INSN_RS1(addr) |\n\n INSN_IMM13(offset));\n\n } else {\n\n tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T1, offset);\n\n tcg_out_ldst_rr(s, ret, addr, TCG_REG_T1, op);\n\n }\n\n}\n", + "output": "0", + "index": 5583 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vc1test_write_header(AVFormatContext *s)\n\n{\n\n AVCodecContext *avc = s->streams[0]->codec;\n\n AVIOContext *pb = s->pb;\n\n\n\n if (avc->codec_id != CODEC_ID_WMV3) {\n\n av_log(s, AV_LOG_ERROR, \"Only WMV3 is accepted!\\n\");\n\n return -1;\n\n }\n\n avio_wl24(pb, 0); //frames count will be here\n\n avio_w8(pb, 0xC5);\n\n avio_wl32(pb, 4);\n\n avio_write(pb, avc->extradata, 4);\n\n avio_wl32(pb, avc->height);\n\n avio_wl32(pb, avc->width);\n\n avio_wl32(pb, 0xC);\n\n avio_wl24(pb, 0); // hrd_buffer\n\n avio_w8(pb, 0x80); // level|cbr|res1\n\n avio_wl32(pb, 0); // hrd_rate\n\n if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1)\n\n avio_wl32(pb, s->streams[0]->r_frame_rate.den);\n\n else\n\n avio_wl32(pb, 0xFFFFFFFF); //variable framerate\n\n avpriv_set_pts_info(s->streams[0], 32, 1, 1000);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 26332 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_out_struct_errors(TestOutputVisitorData *data,\n\n const void *unused)\n\n{\n\n EnumOne bad_values[] = { ENUM_ONE_MAX, -1 };\n\n UserDefZero b;\n\n UserDefOne u = { .base = &b }, *pu = &u;\n\n Error *err;\n\n int i;\n\n\n\n for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {\n\n err = NULL;\n\n u.has_enum1 = true;\n\n u.enum1 = bad_values[i];\n\n visit_type_UserDefOne(data->ov, &pu, \"unused\", &err);\n\n g_assert(err);\n\n error_free(err);\n\n }\n\n}\n", + "output": "0", + "index": 8004 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *get_register_name_32(unsigned int reg)\n\n{\n\n if (reg > CPU_NB_REGS32) {\n\n return NULL;\n\n }\n\n return x86_reg_info_32[reg].name;\n\n}\n", + "output": "1", + "index": 18296 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,\n\n Error **errp)\n\n{\n\n int index;\n\n sPAPRDRConnector *drc;\n\n sPAPRDRConnectorClass *drck;\n\n Error *local_err = NULL;\n\n CPUCore *cc = CPU_CORE(dev);\n\n int smt = kvmppc_smt_threads();\n\n\n\n if (!spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index)) {\n\n error_setg(errp, \"Unable to find CPU core with core-id: %d\",\n\n cc->core_id);\n\n return;\n\n }\n\n if (index == 0) {\n\n error_setg(errp, \"Boot CPU core may not be unplugged\");\n\n return;\n\n }\n\n\n\n drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt);\n\n g_assert(drc);\n\n\n\n drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n drck->detach(drc, dev, spapr_core_release, NULL, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n spapr_hotplug_req_remove_by_index(drc);\n\n}\n", + "output": "0", + "index": 7837 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void windowing_and_mdct_ltp(AACContext *ac, float *out,\n\n float *in, IndividualChannelStream *ics)\n\n{\n\n const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;\n\n const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;\n\n const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;\n\n const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;\n\n\n\n if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {\n\n ac->dsp.vector_fmul(in, in, lwindow_prev, 1024);\n\n } else {\n\n memset(in, 0, 448 * sizeof(float));\n\n ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128);\n\n memcpy(in + 576, in + 576, 448 * sizeof(float));\n\n }\n\n if (ics->window_sequence[0] != LONG_START_SEQUENCE) {\n\n ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);\n\n } else {\n\n memcpy(in + 1024, in + 1024, 448 * sizeof(float));\n\n ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);\n\n memset(in + 1024 + 576, 0, 448 * sizeof(float));\n\n }\n\n ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in);\n\n}\n", + "output": "1", + "index": 689 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scoop_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)\n\n{\n\n ScoopInfo *s = (ScoopInfo *) opaque;\n\n value &= 0xffff;\n\n\n\n switch (addr) {\n\n case SCOOP_MCR:\n\n s->mcr = value;\n\n break;\n\n case SCOOP_CDR:\n\n s->cdr = value;\n\n break;\n\n case SCOOP_CPR:\n\n s->power = value;\n\n if (value & 0x80)\n\n s->power |= 0x8040;\n\n break;\n\n case SCOOP_CCR:\n\n s->ccr = value;\n\n break;\n\n case SCOOP_IRR_IRM:\n\n s->irr = value;\n\n break;\n\n case SCOOP_IMR:\n\n s->imr = value;\n\n break;\n\n case SCOOP_ISR:\n\n s->isr = value;\n\n break;\n\n case SCOOP_GPCR:\n\n s->gpio_dir = value;\n\n scoop_gpio_handler_update(s);\n\n break;\n\n case SCOOP_GPWR:\n\n case SCOOP_GPRR:\t/* GPRR is probably R/O in real HW */\n\n s->gpio_level = value & s->gpio_dir;\n\n scoop_gpio_handler_update(s);\n\n break;\n\n default:\n\n zaurus_printf(\"Bad register offset \" REG_FMT \"\\n\", (unsigned long)addr);\n\n }\n\n}\n", + "output": "0", + "index": 9214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_rtc_piupdate(PXA2xxRTCState *s)\n\n{\n\n int64_t rt = qemu_get_clock(rt_clock);\n\n if (s->rtsr & (1 << 15))\n\n s->last_swcr += rt - s->last_pi;\n\n s->last_pi = rt;\n\n}\n", + "output": "0", + "index": 11671 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int eightsvx_decode_close(AVCodecContext *avctx)\n\n{\n\n EightSvxContext *esc = avctx->priv_data;\n\n\n\n av_freep(&esc->samples);\n\n esc->samples_size = 0;\n\n esc->samples_idx = 0;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17616 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ffurl_register_protocol(URLProtocol *protocol, int size)\n\n{\n\n URLProtocol **p;\n\n if (size < sizeof(URLProtocol)) {\n\n URLProtocol *temp = av_mallocz(sizeof(URLProtocol));\n\n memcpy(temp, protocol, size);\n\n protocol = temp;\n\n }\n\n p = &first_protocol;\n\n while (*p != NULL)\n\n p = &(*p)->next;\n\n *p = protocol;\n\n protocol->next = NULL;\n\n return 0;\n\n}\n", + "output": "1", + "index": 23566 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim)\n\n{\n\n LOAD_PIXELS\n\n return 2 * FFABS(p0 - q0) + (FFABS(p1 - q1) >> 1) <= flim;\n\n}\n", + "output": "1", + "index": 16975 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void lcd_refresh(void *opaque)\n\n{\n\n musicpal_lcd_state *s = opaque;\n\n int x, y;\n\n\n\n for (x = 0; x < 128; x++)\n\n for (y = 0; y < 64; y++)\n\n if (s->video_ram[x + (y/8)*128] & (1 << (y % 8)))\n\n set_lcd_pixel(s, x, y, MP_LCD_TEXTCOLOR);\n\n else\n\n set_lcd_pixel(s, x, y, 0);\n\n\n\n dpy_update(s->ds, 0, 0, 128*3, 64*3);\n\n}\n", + "output": "0", + "index": 18068 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void monitor_flush(Monitor *mon)\n\n{\n\n int i;\n\n if (term_outbuf_index > 0) {\n\n for (i = 0; i < MAX_MON; i++)\n\n if (monitor_hd[i] && monitor_hd[i]->focus == 0)\n\n qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index);\n\n term_outbuf_index = 0;\n\n }\n\n}\n", + "output": "0", + "index": 406 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static InputEvent *qapi_clone_InputEvent(InputEvent *src)\n\n{\n\n QmpOutputVisitor *qov;\n\n QmpInputVisitor *qiv;\n\n Visitor *ov, *iv;\n\n QObject *obj;\n\n InputEvent *dst = NULL;\n\n\n\n qov = qmp_output_visitor_new();\n\n ov = qmp_output_get_visitor(qov);\n\n visit_type_InputEvent(ov, NULL, &src, &error_abort);\n\n obj = qmp_output_get_qobject(qov);\n\n qmp_output_visitor_cleanup(qov);\n\n if (!obj) {\n\n return NULL;\n\n }\n\n\n\n qiv = qmp_input_visitor_new(obj, false);\n\n iv = qmp_input_get_visitor(qiv);\n\n visit_type_InputEvent(iv, NULL, &dst, &error_abort);\n\n qmp_input_visitor_cleanup(qiv);\n\n qobject_decref(obj);\n\n\n\n return dst;\n\n}\n", + "output": "0", + "index": 18897 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_log_stop(CPUPhysMemoryClient *client,\n\n target_phys_addr_t phys_addr, ram_addr_t size)\n\n{\n\n return kvm_dirty_pages_log_change(phys_addr, size, false);\n\n}\n", + "output": "1", + "index": 140 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_memchar_write(const char *device, int64_t size,\n\n const char *data, bool has_format,\n\n enum DataFormat format,\n\n Error **errp)\n\n{\n\n CharDriverState *chr;\n\n guchar *write_data;\n\n int ret;\n\n gsize write_count;\n\n\n\n chr = qemu_chr_find(device);\n\n if (!chr) {\n\n error_set(errp, QERR_DEVICE_NOT_FOUND, device);\n\n return;\n\n }\n\n\n\n if (qemu_is_chr(chr, \"memory\")) {\n\n error_setg(errp,\"%s is not memory char device\", device);\n\n return;\n\n }\n\n\n\n write_count = (gsize)size;\n\n\n\n if (has_format && (format == DATA_FORMAT_BASE64)) {\n\n write_data = g_base64_decode(data, &write_count);\n\n } else {\n\n write_data = (uint8_t *)data;\n\n }\n\n\n\n ret = cirmem_chr_write(chr, write_data, write_count);\n\n\n\n if (ret < 0) {\n\n error_setg(errp, \"Failed to write to device %s\", device);\n\n return;\n\n }\n\n}\n", + "output": "1", + "index": 11986 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s)\n\n{\n\n signed char x, y;\n\n\n\n /* copy a block from the previous frame using an expanded range;\n\n * need 2 more bytes */\n\n CHECK_STREAM_PTR(2);\n\n\n\n x = *s->stream_ptr++;\n\n y = *s->stream_ptr++;\n\n\n\n debug_interplay (\" motion bytes = %d, %d\\n\", x, y);\n\n return copy_from(s, &s->last_frame, x, y);\n\n}\n", + "output": "0", + "index": 12510 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ccid_initfn(USBDevice *dev)\n\n{\n\n USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);\n\n\n\n s->bus = ccid_bus_new(&dev->qdev);\n\n s->card = NULL;\n\n s->cardinfo = NULL;\n\n s->migration_state = MIGRATION_NONE;\n\n s->migration_target_ip = 0;\n\n s->migration_target_port = 0;\n\n s->dev.speed = USB_SPEED_FULL;\n\n s->notify_slot_change = false;\n\n s->powered = true;\n\n s->pending_answers_num = 0;\n\n s->last_answer_error = 0;\n\n s->bulk_in_pending_start = 0;\n\n s->bulk_in_pending_end = 0;\n\n s->current_bulk_in = NULL;\n\n ccid_reset_error_status(s);\n\n s->bulk_out_pos = 0;\n\n ccid_reset_parameters(s);\n\n ccid_reset(s);\n\n return 0;\n\n}\n", + "output": "1", + "index": 6500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xlnx_ep108_init(MachineState *machine)\n\n{\n\n XlnxEP108 *s = g_new0(XlnxEP108, 1);\n\n Error *err = NULL;\n\n\n\n object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);\n\n object_property_add_child(OBJECT(machine), \"soc\", OBJECT(&s->soc),\n\n &error_abort);\n\n\n\n object_property_set_bool(OBJECT(&s->soc), true, \"realized\", &err);\n\n if (err) {\n\n error_report(\"%s\", error_get_pretty(err));\n\n exit(1);\n\n }\n\n\n\n if (machine->ram_size > EP108_MAX_RAM_SIZE) {\n\n error_report(\"WARNING: RAM size \" RAM_ADDR_FMT \" above max supported, \"\n\n \"reduced to %llx\", machine->ram_size, EP108_MAX_RAM_SIZE);\n\n machine->ram_size = EP108_MAX_RAM_SIZE;\n\n }\n\n\n\n if (machine->ram_size <= 0x08000000) {\n\n qemu_log(\"WARNING: RAM size \" RAM_ADDR_FMT \" is small for EP108\",\n\n machine->ram_size);\n\n }\n\n\n\n memory_region_allocate_system_memory(&s->ddr_ram, NULL, \"ddr-ram\",\n\n machine->ram_size);\n\n memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram);\n\n\n\n xlnx_ep108_binfo.ram_size = machine->ram_size;\n\n xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;\n\n xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;\n\n xlnx_ep108_binfo.initrd_filename = machine->initrd_filename;\n\n xlnx_ep108_binfo.loader_start = 0;\n\n arm_load_kernel(s->soc.boot_cpu_ptr, &xlnx_ep108_binfo);\n\n}\n", + "output": "1", + "index": 15288 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned char **data)\n\n{\n\n if (s->buf_end - s->buf_ptr >= size && !s->write_flag) {\n\n *data = s->buf_ptr;\n\n s->buf_ptr += size;\n\n return size;\n\n } else {\n\n *data = buf;\n\n return avio_read(s, buf, size);\n\n }\n\n}\n", + "output": "1", + "index": 12947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void scsi_req_build_sense(SCSIRequest *req, SCSISense sense)\n\n{\n\n trace_scsi_req_build_sense(req->dev->id, req->lun, req->tag,\n\n sense.key, sense.asc, sense.ascq);\n\n memset(req->sense, 0, 18);\n\n req->sense[0] = 0xf0;\n\n req->sense[2] = sense.key;\n\n req->sense[7] = 10;\n\n req->sense[12] = sense.asc;\n\n req->sense[13] = sense.ascq;\n\n req->sense_len = 18;\n\n}\n", + "output": "0", + "index": 5083 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)\n\n{\n\n if (ctx->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]);\n\n if (ctx->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n gen_stop_exception(ctx);\n\n }\n\n}\n", + "output": "1", + "index": 25274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)\n\n{\n\n char layout_name[256];\n\n AVCodecContext *enc = ost->st->codec;\n\n AVCodecContext *dec = ist->st->codec;\n\n\n\n if (!dec->channel_layout) {\n\n if (enc->channel_layout && dec->channels == enc->channels) {\n\n dec->channel_layout = enc->channel_layout;\n\n } else {\n\n dec->channel_layout = av_get_default_channel_layout(dec->channels);\n\n\n\n if (!dec->channel_layout) {\n\n av_log(NULL, AV_LOG_FATAL, \"Unable to find default channel \"\n\n \"layout for Input Stream #%d.%d\\n\", ist->file_index,\n\n ist->st->index);\n\n exit_program(1);\n\n }\n\n }\n\n av_get_channel_layout_string(layout_name, sizeof(layout_name),\n\n dec->channels, dec->channel_layout);\n\n av_log(NULL, AV_LOG_WARNING, \"Guessed Channel Layout for Input Stream \"\n\n \"#%d.%d : %s\\n\", ist->file_index, ist->st->index, layout_name);\n\n }\n\n if (!enc->channel_layout) {\n\n if (dec->channels == enc->channels) {\n\n enc->channel_layout = dec->channel_layout;\n\n return;\n\n } else {\n\n enc->channel_layout = av_get_default_channel_layout(enc->channels);\n\n }\n\n if (!enc->channel_layout) {\n\n av_log(NULL, AV_LOG_FATAL, \"Unable to find default channel layout \"\n\n \"for Output Stream #%d.%d\\n\", ost->file_index,\n\n ost->st->index);\n\n exit_program(1);\n\n }\n\n av_get_channel_layout_string(layout_name, sizeof(layout_name),\n\n enc->channels, enc->channel_layout);\n\n av_log(NULL, AV_LOG_WARNING, \"Guessed Channel Layout for Output Stream \"\n\n \"#%d.%d : %s\\n\", ost->file_index, ost->st->index, layout_name);\n\n }\n\n}\n", + "output": "0", + "index": 7470 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_log_start(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n /* FIXME: implement */\n\n}\n", + "output": "0", + "index": 9849 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t v9fs_synth_preadv(FsContext *ctx, V9fsFidOpenState *fs,\n\n const struct iovec *iov,\n\n int iovcnt, off_t offset)\n\n{\n\n int i, count = 0, rcount;\n\n V9fsSynthOpenState *synth_open = fs->private;\n\n V9fsSynthNode *node = synth_open->node;\n\n if (!node->attr->read) {\n\n errno = EPERM;\n\n return -1;\n\n }\n\n for (i = 0; i < iovcnt; i++) {\n\n rcount = node->attr->read(iov[i].iov_base, iov[i].iov_len,\n\n offset, node->private);\n\n offset += rcount;\n\n count += rcount;\n\n /* If we read less than requested. we are done */\n\n if (rcount < iov[i].iov_len) {\n\n break;\n\n }\n\n }\n\n return count;\n\n}\n", + "output": "0", + "index": 4275 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t qemu_archipelago_getlength(BlockDriverState *bs)\n\n{\n\n int64_t ret;\n\n BDRVArchipelagoState *s = bs->opaque;\n\n\n\n ret = archipelago_volume_info(s);\n\n return ret;\n\n}\n", + "output": "0", + "index": 15534 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pl181_send_command(pl181_state *s)\n\n{\n\n SDRequest request;\n\n uint8_t response[16];\n\n int rlen;\n\n\n\n request.cmd = s->cmd & PL181_CMD_INDEX;\n\n request.arg = s->cmdarg;\n\n DPRINTF(\"Command %d %08x\\n\", request.cmd, request.arg);\n\n rlen = sd_do_command(s->card, &request, response);\n\n if (rlen < 0)\n\n goto error;\n\n if (s->cmd & PL181_CMD_RESPONSE) {\n\n#define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \\\n\n | (response[n + 2] << 8) | response[n + 3])\n\n if (rlen == 0 || (rlen == 4 && (s->cmd & PL181_CMD_LONGRESP)))\n\n goto error;\n\n if (rlen != 4 && rlen != 16)\n\n goto error;\n\n s->response[0] = RWORD(0);\n\n if (rlen == 4) {\n\n s->response[1] = s->response[2] = s->response[3] = 0;\n\n } else {\n\n s->response[1] = RWORD(4);\n\n s->response[2] = RWORD(8);\n\n s->response[3] = RWORD(12) & ~1;\n\n }\n\n DPRINTF(\"Response received\\n\");\n\n s->status |= PL181_STATUS_CMDRESPEND;\n\n#undef RWORD\n\n } else {\n\n DPRINTF(\"Command sent\\n\");\n\n s->status |= PL181_STATUS_CMDSENT;\n\n }\n\n return;\n\n\n\nerror:\n\n DPRINTF(\"Timeout\\n\");\n\n s->status |= PL181_STATUS_CMDTIMEOUT;\n\n}\n", + "output": "1", + "index": 18528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_kill_report(void)\n\n{\n\n if (!qtest_driver() && shutdown_signal != -1) {\n\n fprintf(stderr, \"qemu: terminating on signal %d\", shutdown_signal);\n\n if (shutdown_pid == 0) {\n\n /* This happens for eg ^C at the terminal, so it's worth\n\n * avoiding printing an odd message in that case.\n\n */\n\n fputc('\\n', stderr);\n\n } else {\n\n fprintf(stderr, \" from pid \" FMT_pid \"\\n\", shutdown_pid);\n\n }\n\n shutdown_signal = -1;\n\n }\n\n}\n", + "output": "0", + "index": 11963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_and_aver_dst_8x8_msa(src + stride - 2,\n\n src - (stride * 2),\n\n stride, dst, stride);\n\n}\n", + "output": "0", + "index": 1549 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_mkdir(void *opaque)\n\n{\n\n V9fsPDU *pdu = opaque;\n\n size_t offset = 7;\n\n int32_t fid;\n\n struct stat stbuf;\n\n V9fsQID qid;\n\n V9fsString name;\n\n V9fsFidState *fidp;\n\n gid_t gid;\n\n int mode;\n\n int err = 0;\n\n\n\n pdu_unmarshal(pdu, offset, \"dsdd\", &fid, &name, &mode, &gid);\n\n\n\n trace_v9fs_mkdir(pdu->tag, pdu->id, fid, name.data, mode, gid);\n\n\n\n fidp = get_fid(pdu, fid);\n\n if (fidp == NULL) {\n\n err = -ENOENT;\n\n goto out_nofid;\n\n }\n\n err = v9fs_co_mkdir(pdu, fidp, &name, mode, fidp->uid, gid, &stbuf);\n\n if (err < 0) {\n\n goto out;\n\n }\n\n stat_to_qid(&stbuf, &qid);\n\n offset += pdu_marshal(pdu, offset, \"Q\", &qid);\n\n err = offset;\n\n trace_v9fs_mkdir_return(pdu->tag, pdu->id,\n\n qid.type, qid.version, qid.path, err);\n\nout:\n\n put_fid(pdu, fidp);\n\nout_nofid:\n\n complete_pdu(pdu->s, pdu, err);\n\n v9fs_string_free(&name);\n\n}\n", + "output": "0", + "index": 16912 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_blck(uint8_t *frame, int width, int height,\n\n const uint8_t *src, const uint8_t *src_end)\n\n{\n\n memset(frame, 0, width * height);\n\n return 0;\n\n}\n", + "output": "1", + "index": 21669 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)\n\n{\n\n struct kvm_s390_vm_cpu_processor prop = {\n\n .fac_list = { 0 },\n\n };\n\n struct kvm_device_attr attr = {\n\n .group = KVM_S390_VM_CPU_MODEL,\n\n .attr = KVM_S390_VM_CPU_PROCESSOR,\n\n .addr = (uint64_t) &prop,\n\n };\n\n int rc;\n\n\n\n if (!model) {\n\n /* compatibility handling if cpu models are disabled */\n\n if (kvm_s390_cmma_available() && !mem_path) {\n\n kvm_s390_enable_cmma();\n\n }\n\n return;\n\n }\n\n if (!kvm_s390_cpu_models_supported()) {\n\n error_setg(errp, \"KVM doesn't support CPU models\");\n\n return;\n\n }\n\n prop.cpuid = s390_cpuid_from_cpu_model(model);\n\n prop.ibc = s390_ibc_from_cpu_model(model);\n\n /* configure cpu features indicated via STFL(e) */\n\n s390_fill_feat_block(model->features, S390_FEAT_TYPE_STFL,\n\n (uint8_t *) prop.fac_list);\n\n rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);\n\n if (rc) {\n\n error_setg(errp, \"KVM: Error configuring the CPU model: %d\", rc);\n\n return;\n\n }\n\n /* configure cpu features indicated e.g. via SCLP */\n\n rc = configure_cpu_feat(model->features);\n\n if (rc) {\n\n error_setg(errp, \"KVM: Error configuring CPU features: %d\", rc);\n\n return;\n\n }\n\n /* configure cpu subfunctions indicated via query / test bit */\n\n rc = configure_cpu_subfunc(model->features);\n\n if (rc) {\n\n error_setg(errp, \"KVM: Error configuring CPU subfunctions: %d\", rc);\n\n return;\n\n }\n\n /* enable CMM via CMMA - disable on hugetlbfs */\n\n if (test_bit(S390_FEAT_CMM, model->features)) {\n\n if (mem_path) {\n\n error_report(\"Warning: CMM will not be enabled because it is not \"\n\n \"compatible to hugetlbfs.\");\n\n } else {\n\n kvm_s390_enable_cmma();\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 7432 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s)\n\n{\n\n unsigned char B;\n\n int x, y;\n\n\n\n /* copy block from 2 frames ago using a motion vector; need 1 more byte */\n\n CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1);\n\n B = *s->stream_ptr++;\n\n\n\n if (B < 56) {\n\n x = 8 + (B % 7);\n\n y = B / 7;\n\n } else {\n\n x = -14 + ((B - 56) % 29);\n\n y = 8 + ((B - 56) / 29);\n\n }\n\n\n\n debug_interplay (\" motion byte = %d, (x, y) = (%d, %d)\\n\", B, x, y);\n\n return copy_from(s, &s->second_last_frame, x, y);\n\n}\n", + "output": "0", + "index": 488 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict)\n\n{\n\n Monitor *mon;\n\n\n\n trace_monitor_protocol_event_emit(event, qdict);\n\n QLIST_FOREACH(mon, &mon_list, entry) {\n\n if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {\n\n monitor_json_emitter(mon, QOBJECT(qdict));\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 23131 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avg_width4_msa(src, stride, dst, stride, 4);\n\n}\n", + "output": "0", + "index": 23111 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline void gen_fcmov (void *func,\n\n int ra, int rb, int rc)\n\n{\n\n int l1;\n\n TCGv tmp;\n\n\n\n if (unlikely(rc == 31))\n\n return;\n\n\n\n l1 = gen_new_label();\n\n tmp = tcg_temp_new(TCG_TYPE_I64);\n\n if (ra != 31) {\n\n tmp = tcg_temp_new(TCG_TYPE_I64);\n\n tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);\n\n } else {\n\n tmp = tcg_const_i64(0);\n\n tcg_gen_helper_1_1(func, tmp, tmp);\n\n }\n\n tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, l1);\n\n if (rb != 31)\n\n tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);\n\n else\n\n tcg_gen_movi_i64(cpu_fir[rc], 0);\n\n gen_set_label(l1);\n\n}\n", + "output": "0", + "index": 24504 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_write_data(SCSIDevice *d, uint32_t tag)\n\n{\n\n SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);\n\n SCSIGenericReq *r;\n\n int ret;\n\n\n\n DPRINTF(\"scsi_write_data 0x%x\\n\", tag);\n\n r = scsi_find_request(s, tag);\n\n if (!r) {\n\n BADF(\"Bad write tag 0x%x\\n\", tag);\n\n /* ??? This is the wrong error. */\n\n scsi_command_complete(r, -EINVAL);\n\n return 0;\n\n }\n\n\n\n if (r->len == 0) {\n\n r->len = r->buflen;\n\n scsi_req_data(&r->req, r->len);\n\n return 0;\n\n }\n\n\n\n ret = execute_command(s->bs, r, SG_DXFER_TO_DEV, scsi_write_complete);\n\n if (ret == -1) {\n\n scsi_command_complete(r, -EINVAL);\n\n return 1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18530 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void blur(CoverContext *cover, AVFrame *in, int offx, int offy)\n\n{\n\n int x, y, p;\n\n\n\n for (p=0; p<3; p++) {\n\n int ox = offx>>!!p;\n\n int oy = offy>>!!p;\n\n int stride = in->linesize[p];\n\n uint8_t *data = in->data[p] + ox + oy * stride;\n\n int w = FF_CEIL_RSHIFT(cover->width , !!p);\n\n int h = FF_CEIL_RSHIFT(cover->height, !!p);\n\n int iw = FF_CEIL_RSHIFT(in->width , !!p);\n\n int ih = FF_CEIL_RSHIFT(in->height, !!p);\n\n for (y = 0; y < h; y++) {\n\n for (x = 0; x < w; x++) {\n\n int c = 0;\n\n int s = 0;\n\n if (ox) {\n\n int scale = 65536 / (x + 1);\n\n s += data[-1 + y*stride] * scale;\n\n c += scale;\n\n }\n\n if (oy) {\n\n int scale = 65536 / (y + 1);\n\n s += data[x - stride] * scale;\n\n c += scale;\n\n }\n\n if (ox + w < iw) {\n\n int scale = 65536 / (w - x);\n\n s += data[w + y*stride] * scale;\n\n c += scale;\n\n }\n\n if (oy + h < ih) {\n\n int scale = 65536 / (h - y);\n\n s += data[x + h*stride] * scale;\n\n c += scale;\n\n }\n\n data[x + y*stride] = (s + (c>>1)) / c;\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 25473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_req_dequeue(SCSIRequest *req)\n\n{\n\n trace_scsi_req_dequeue(req->dev->id, req->lun, req->tag);\n\n if (req->enqueued) {\n\n QTAILQ_REMOVE(&req->dev->requests, req, next);\n\n req->enqueued = false;\n\n }\n\n}\n", + "output": "1", + "index": 25148 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ts_str(char buffer[60], int64_t ts, AVRational base)\n\n{\n\n if (ts == AV_NOPTS_VALUE) {\n\n strcpy(buffer, \" NOPTS \");\n\n return;\n\n }\n\n ts= av_rescale_q(ts, base, (AVRational){1, 1000000});\n\n snprintf(buffer, 60, \"%c%Ld.%06Ld\", ts<0 ? '-' : ' ', FFABS(ts)/1000000, FFABS(ts)%1000000);\n\n}\n", + "output": "0", + "index": 24048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,\n\n struct in_addr addr, int port)\n\n{\n\n\tstruct ex_list *tmp_ptr;\n\n\n\n\t/* First, check if the port is \"bound\" */\n\n\tfor (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) {\n\n\t\tif (port == tmp_ptr->ex_fport &&\n\n\t\t addr.s_addr == tmp_ptr->ex_addr.s_addr)\n\n\t\t\treturn -1;\n\n\t}\n\n\n\n\ttmp_ptr = *ex_ptr;\n\n\t*ex_ptr = (struct ex_list *)malloc(sizeof(struct ex_list));\n\n\t(*ex_ptr)->ex_fport = port;\n\n\t(*ex_ptr)->ex_addr = addr;\n\n\t(*ex_ptr)->ex_pty = do_pty;\n\n\t(*ex_ptr)->ex_exec = (do_pty == 3) ? exec : strdup(exec);\n\n\t(*ex_ptr)->ex_next = tmp_ptr;\n\n\treturn 0;\n\n}\n", + "output": "1", + "index": 15091 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)\n\n{\n\n ParallelState *s;\n\n int io_sw;\n\n\n\n s = qemu_mallocz(sizeof(ParallelState));\n\n s->irq = irq;\n\n s->chr = chr;\n\n s->it_shift = it_shift;\n\n qemu_register_reset(parallel_reset, s);\n\n\n\n io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,\n\n s, DEVICE_NATIVE_ENDIAN);\n\n cpu_register_physical_memory(base, 8 << it_shift, io_sw);\n\n return s;\n\n}\n", + "output": "0", + "index": 26021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)\n\n{\n\n BlockDriverState *bs = self->bs;\n\n BdrvTrackedRequest *req;\n\n bool retry;\n\n\n\n if (!bs->serialising_in_flight) {\n\n return;\n\n }\n\n\n\n do {\n\n retry = false;\n\n QLIST_FOREACH(req, &bs->tracked_requests, list) {\n\n if (req == self || (!req->serialising && !self->serialising)) {\n\n continue;\n\n }\n\n if (tracked_request_overlaps(req, self->overlap_offset,\n\n self->overlap_bytes))\n\n {\n\n /* Hitting this means there was a reentrant request, for\n\n * example, a block driver issuing nested requests. This must\n\n * never happen since it means deadlock.\n\n */\n\n assert(qemu_coroutine_self() != req->co);\n\n\n\n qemu_co_queue_wait(&req->wait_queue);\n\n retry = true;\n\n break;\n\n }\n\n }\n\n } while (retry);\n\n}\n", + "output": "1", + "index": 27035 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockDriverState *check_to_replace_node(const char *node_name, Error **errp)\n\n{\n\n BlockDriverState *to_replace_bs = bdrv_find_node(node_name);\n\n AioContext *aio_context;\n\n\n\n if (!to_replace_bs) {\n\n error_setg(errp, \"Node name '%s' not found\", node_name);\n\n return NULL;\n\n }\n\n\n\n aio_context = bdrv_get_aio_context(to_replace_bs);\n\n aio_context_acquire(aio_context);\n\n\n\n if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) {\n\n to_replace_bs = NULL;\n\n goto out;\n\n }\n\n\n\n /* We don't want arbitrary node of the BDS chain to be replaced only the top\n\n * most non filter in order to prevent data corruption.\n\n * Another benefit is that this tests exclude backing files which are\n\n * blocked by the backing blockers.\n\n */\n\n if (!bdrv_is_first_non_filter(to_replace_bs)) {\n\n error_setg(errp, \"Only top most non filter can be replaced\");\n\n to_replace_bs = NULL;\n\n goto out;\n\n }\n\n\n\nout:\n\n aio_context_release(aio_context);\n\n return to_replace_bs;\n\n}\n", + "output": "0", + "index": 25283 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque)\n\n{\n\n DisplayChangeListener *dcl = opaque.host_ptr;\n\n\n dcl->ops->dpy_refresh(dcl);\n\n\n}", + "output": "1", + "index": 11519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int gif_read_extension(GifState *s)\n\n{\n\n ByteIOContext *f = s->f;\n\n int ext_code, ext_len, i, gce_flags, gce_transparent_index;\n\n\n\n /* extension */\n\n ext_code = get_byte(f);\n\n ext_len = get_byte(f);\n\n#ifdef DEBUG\n\n printf(\"gif: ext_code=0x%x len=%d\\n\", ext_code, ext_len);\n\n#endif\n\n switch(ext_code) {\n\n case 0xf9:\n\n if (ext_len != 4)\n\n goto discard_ext;\n\n s->transparent_color_index = -1;\n\n gce_flags = get_byte(f);\n\n s->gce_delay = get_le16(f);\n\n gce_transparent_index = get_byte(f);\n\n if (gce_flags & 0x01)\n\n s->transparent_color_index = gce_transparent_index;\n\n else\n\n s->transparent_color_index = -1;\n\n s->gce_disposal = (gce_flags >> 2) & 0x7;\n\n#ifdef DEBUG\n\n printf(\"gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\\n\",\n\n gce_flags, s->gce_delay,\n\n s->transparent_color_index, s->gce_disposal);\n\n#endif\n\n ext_len = get_byte(f);\n\n break;\n\n }\n\n\n\n /* NOTE: many extension blocks can come after */\n\n discard_ext:\n\n while (ext_len != 0) {\n\n for (i = 0; i < ext_len; i++)\n\n get_byte(f);\n\n ext_len = get_byte(f);\n\n#ifdef DEBUG\n\n printf(\"gif: ext_len1=%d\\n\", ext_len);\n\n#endif\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 11587 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s)\n\n{\n\n int x, y;\n\n unsigned char P[2];\n\n unsigned int flags;\n\n\n\n /* 2-color encoding */\n\n CHECK_STREAM_PTR(2);\n\n\n\n P[0] = *s->stream_ptr++;\n\n P[1] = *s->stream_ptr++;\n\n\n\n if (P[0] <= P[1]) {\n\n\n\n /* need 8 more bytes from the stream */\n\n CHECK_STREAM_PTR(8);\n\n\n\n for (y = 0; y < 8; y++) {\n\n flags = *s->stream_ptr++ | 0x100;\n\n for (; flags != 1; flags >>= 1)\n\n *s->pixel_ptr++ = P[flags & 1];\n\n s->pixel_ptr += s->line_inc;\n\n }\n\n\n\n } else {\n\n\n\n /* need 2 more bytes from the stream */\n\n CHECK_STREAM_PTR(2);\n\n\n\n flags = bytestream_get_le16(&s->stream_ptr);\n\n for (y = 0; y < 8; y += 2) {\n\n for (x = 0; x < 8; x += 2, flags >>= 1) {\n\n s->pixel_ptr[x ] =\n\n s->pixel_ptr[x + 1 ] =\n\n s->pixel_ptr[x + s->stride] =\n\n s->pixel_ptr[x + 1 + s->stride] = P[flags & 1];\n\n }\n\n s->pixel_ptr += s->stride * 2;\n\n }\n\n }\n\n\n\n /* report success */\n\n return 0;\n\n}\n", + "output": "0", + "index": 6059 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void x86_cpu_register_feature_bit_props(X86CPU *cpu,\n\n FeatureWord w,\n\n int bitnr)\n\n{\n\n Object *obj = OBJECT(cpu);\n\n int i;\n\n char **names;\n\n FeatureWordInfo *fi = &feature_word_info[w];\n\n\n\n if (!fi->feat_names[bitnr]) {\n\n return;\n\n }\n\n\n\n names = g_strsplit(fi->feat_names[bitnr], \"|\", 0);\n\n\n\n feat2prop(names[0]);\n\n x86_cpu_register_bit_prop(cpu, names[0], &cpu->env.features[w], bitnr);\n\n\n\n for (i = 1; names[i]; i++) {\n\n feat2prop(names[i]);\n\n object_property_add_alias(obj, names[i], obj, names[0],\n\n &error_abort);\n\n }\n\n\n\n g_strfreev(names);\n\n}\n", + "output": "0", + "index": 13164 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_handle_guest_debug(CPUState *env)\n\n{\n\n gdb_set_stop_cpu(env);\n\n qemu_system_debug_request();\n\n#ifdef CONFIG_IOTHREAD\n\n env->stopped = 1;\n\n#endif\n\n}\n", + "output": "1", + "index": 4032 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dv_read_header(AVFormatContext *s,\n\n AVFormatParameters *ap)\n\n{\n\n RawDVContext *c = s->priv_data;\n\n c->dv_demux = dv_init_demux(s);\n\n \n\n return c->dv_demux ? 0 : -1;\n\n}\n", + "output": "0", + "index": 12937 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void object_property_set_link(Object *obj, Object *value,\n\n const char *name, Error **errp)\n\n{\n\n object_property_set_str(obj, object_get_canonical_path(value),\n\n name, errp);\n\n}\n", + "output": "1", + "index": 5550 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virt_machine_class_init(ObjectClass *oc, void *data)\n\n{\n\n MachineClass *mc = MACHINE_CLASS(oc);\n\n\n\n mc->init = machvirt_init;\n\n /* Start max_cpus at the maximum QEMU supports. We'll further restrict\n\n * it later in machvirt_init, where we have more information about the\n\n * configuration of the particular instance.\n\n */\n\n mc->max_cpus = MAX_CPUMASK_BITS;\n\n mc->has_dynamic_sysbus = true;\n\n mc->block_default_type = IF_VIRTIO;\n\n mc->no_cdrom = 1;\n\n mc->pci_allow_0_address = true;\n\n}\n", + "output": "0", + "index": 6236 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usbnet_can_receive(NetClientState *nc)\n{\n USBNetState *s = qemu_get_nic_opaque(nc);\n if (is_rndis(s) && s->rndis_state != RNDIS_DATA_INITIALIZED) {\n return 1;\n return !s->in_len;", + "output": "1", + "index": 24007 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)\n\n{\n\n unsigned int nRc = 0;\n\n// unsigned long flags;\n\n FPA11 *fpa11;\n\n// save_flags(flags); sti();\n\n\n\n qemufpa=qfpa;\n\n user_registers=qregs;\n\n\n\n#if 0\n\n fprintf(stderr,\"emulating FP insn 0x%08x, PC=0x%08x\\n\",\n\n opcode, qregs[REG_PC]);\n\n#endif\n\n fpa11 = GET_FPA11();\n\n\n\n if (fpa11->initflag == 0)\t\t/* good place for __builtin_expect */\n\n {\n\n resetFPA11();\n\n SetRoundingMode(ROUND_TO_NEAREST);\n\n SetRoundingPrecision(ROUND_EXTENDED);\n\n fpa11->initflag = 1;\n\n }\n\n\n\n set_float_exception_flags(0, &fpa11->fp_status);\n\n\n\n if (TEST_OPCODE(opcode,MASK_CPRT))\n\n {\n\n //fprintf(stderr,\"emulating CPRT\\n\");\n\n /* Emulate conversion opcodes. */\n\n /* Emulate register transfer opcodes. */\n\n /* Emulate comparison opcodes. */\n\n nRc = EmulateCPRT(opcode);\n\n }\n\n else if (TEST_OPCODE(opcode,MASK_CPDO))\n\n {\n\n //fprintf(stderr,\"emulating CPDO\\n\");\n\n /* Emulate monadic arithmetic opcodes. */\n\n /* Emulate dyadic arithmetic opcodes. */\n\n nRc = EmulateCPDO(opcode);\n\n }\n\n else if (TEST_OPCODE(opcode,MASK_CPDT))\n\n {\n\n //fprintf(stderr,\"emulating CPDT\\n\");\n\n /* Emulate load/store opcodes. */\n\n /* Emulate load/store multiple opcodes. */\n\n nRc = EmulateCPDT(opcode);\n\n }\n\n else\n\n {\n\n /* Invalid instruction detected. Return FALSE. */\n\n nRc = 0;\n\n }\n\n\n\n// restore_flags(flags);\n\n if(nRc == 1 && get_float_exception_flags(&fpa11->fp_status))\n\n {\n\n //printf(\"fef 0x%x\\n\",float_exception_flags);\n\n nRc -= get_float_exception_flags(&fpa11->fp_status);\n\n }\n\n\n\n //printf(\"returning %d\\n\",nRc);\n\n return(nRc);\n\n}\n", + "output": "0", + "index": 22480 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_validate_fail_struct(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n TestStruct *p = NULL;\n\n Error *err = NULL;\n\n Visitor *v;\n\n\n\n v = validate_test_init(data, \"{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }\");\n\n\n\n visit_type_TestStruct(v, &p, NULL, &err);\n\n g_assert(err);\n\n error_free(err);\n\n if (p) {\n\n g_free(p->string);\n\n }\n\n g_free(p);\n\n}\n", + "output": "1", + "index": 17333 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,\n\n AVInputFormat *fmt,\n\n int buf_size,\n\n AVFormatParameters *ap)\n\n{\n\n int err;\n\n AVProbeData probe_data, *pd = &probe_data;\n\n ByteIOContext *pb = NULL;\n\n void *logctx= ap && ap->prealloced_context ? *ic_ptr : NULL;\n\n\n\n pd->filename = \"\";\n\n if (filename)\n\n pd->filename = filename;\n\n pd->buf = NULL;\n\n pd->buf_size = 0;\n\n\n\n if (!fmt) {\n\n /* guess format if no file can be opened */\n\n fmt = av_probe_input_format(pd, 0);\n\n }\n\n\n\n /* Do not open file if the format does not need it. XXX: specific\n\n hack needed to handle RTSP/TCP */\n\n if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {\n\n /* if no file needed do not try to open one */\n\n if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {\n\n goto fail;\n\n }\n\n if (buf_size > 0) {\n\n url_setbufsize(pb, buf_size);\n\n }\n\n if ((err = ff_probe_input_buffer(&pb, &fmt, filename, logctx, 0, 0)) < 0) {\n\n goto fail;\n\n }\n\n }\n\n\n\n /* if still no format found, error */\n\n if (!fmt) {\n\n err = AVERROR_NOFMT;\n\n goto fail;\n\n }\n\n\n\n /* check filename in case an image number is expected */\n\n if (fmt->flags & AVFMT_NEEDNUMBER) {\n\n if (!av_filename_number_test(filename)) {\n\n err = AVERROR_NUMEXPECTED;\n\n goto fail;\n\n }\n\n }\n\n err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);\n\n if (err)\n\n goto fail;\n\n return 0;\n\n fail:\n\n av_freep(&pd->buf);\n\n if (pb)\n\n url_fclose(pb);\n\n if (ap && ap->prealloced_context)\n\n av_free(*ic_ptr);\n\n *ic_ptr = NULL;\n\n return err;\n\n\n\n}\n", + "output": "0", + "index": 15046 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_smbios_ep_address(test_data *data)\n\n{\n\n uint32_t off;\n\n\n\n /* find smbios entry point structure */\n\n for (off = 0xf0000; off < 0x100000; off += 0x10) {\n\n uint8_t sig[] = \"_SM_\";\n\n int i;\n\n\n\n for (i = 0; i < sizeof sig - 1; ++i) {\n\n sig[i] = readb(off + i);\n\n }\n\n\n\n if (!memcmp(sig, \"_SM_\", sizeof sig)) {\n\n break;\n\n }\n\n }\n\n\n\n g_assert_cmphex(off, <, 0x100000);\n\n data->smbios_ep_addr = off;\n\n}\n", + "output": "1", + "index": 21383 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)\n\n{\n\n SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);\n\n\n\n switch (buf[0]) {\n\n case REPORT_LUNS:\n\n if (!scsi_target_emulate_report_luns(r)) {\n\n goto illegal_request;\n\n }\n\n break;\n\n case INQUIRY:\n\n if (!scsi_target_emulate_inquiry(r)) {\n\n goto illegal_request;\n\n }\n\n break;\n\n case REQUEST_SENSE:\n\n r->len = scsi_device_get_sense(r->req.dev, r->buf,\n\n MIN(req->cmd.xfer, sizeof r->buf),\n\n (req->cmd.buf[1] & 1) == 0);\n\n if (r->req.dev->sense_is_ua) {\n\n scsi_device_unit_attention_reported(req->dev);\n\n r->req.dev->sense_len = 0;\n\n r->req.dev->sense_is_ua = false;\n\n }\n\n break;\n\n default:\n\n scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));\n\n scsi_req_complete(req, CHECK_CONDITION);\n\n return 0;\n\n illegal_request:\n\n scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));\n\n scsi_req_complete(req, CHECK_CONDITION);\n\n return 0;\n\n }\n\n\n\n if (!r->len) {\n\n scsi_req_complete(req, GOOD);\n\n }\n\n return r->len;\n\n}\n", + "output": "1", + "index": 2315 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uart_write(void *opaque, hwaddr addr,\n\n uint64_t val64, unsigned int size)\n\n{\n\n XilinxUARTLite *s = opaque;\n\n uint32_t value = val64;\n\n unsigned char ch = value;\n\n\n\n addr >>= 2;\n\n switch (addr)\n\n {\n\n case R_STATUS:\n\n hw_error(\"write to UART STATUS?\\n\");\n\n break;\n\n\n\n case R_CTRL:\n\n if (value & CONTROL_RST_RX) {\n\n s->rx_fifo_pos = 0;\n\n s->rx_fifo_len = 0;\n\n }\n\n s->regs[addr] = value;\n\n break;\n\n\n\n case R_TX:\n\n if (s->chr)\n\n qemu_chr_fe_write(s->chr, &ch, 1);\n\n\n\n s->regs[addr] = value;\n\n\n\n /* hax. */\n\n s->regs[R_STATUS] |= STATUS_IE;\n\n break;\n\n\n\n default:\n\n DUART(printf(\"%s addr=%x v=%x\\n\", __func__, addr, value));\n\n if (addr < ARRAY_SIZE(s->regs))\n\n s->regs[addr] = value;\n\n break;\n\n }\n\n uart_update_status(s);\n\n uart_update_irq(s);\n\n}\n", + "output": "1", + "index": 15255 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr)\n\n{\n\n MemoryRegionSection *section;\n\n\n\n section = phys_page_find(phys_addr >> TARGET_PAGE_BITS);\n\n\n\n return !(memory_region_is_ram(section->mr) ||\n\n memory_region_is_romd(section->mr));\n\n}\n", + "output": "0", + "index": 16606 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qcrypto_tls_creds_x509_sanity_check(QCryptoTLSCredsX509 *creds,\n\n bool isServer,\n\n const char *cacertFile,\n\n const char *certFile,\n\n Error **errp)\n\n{\n\n gnutls_x509_crt_t cert = NULL;\n\n gnutls_x509_crt_t cacerts[MAX_CERTS];\n\n size_t ncacerts = 0;\n\n size_t i;\n\n int ret = -1;\n\n\n\n memset(cacerts, 0, sizeof(cacerts));\n\n if (access(certFile, R_OK) == 0) {\n\n cert = qcrypto_tls_creds_load_cert(creds,\n\n certFile, isServer,\n\n errp);\n\n if (!cert) {\n\n goto cleanup;\n\n }\n\n }\n\n if (access(cacertFile, R_OK) == 0) {\n\n if (qcrypto_tls_creds_load_ca_cert_list(creds,\n\n cacertFile, cacerts,\n\n MAX_CERTS, &ncacerts,\n\n errp) < 0) {\n\n goto cleanup;\n\n }\n\n }\n\n\n\n if (cert &&\n\n qcrypto_tls_creds_check_cert(creds,\n\n cert, certFile, isServer,\n\n false, errp) < 0) {\n\n goto cleanup;\n\n }\n\n\n\n for (i = 0; i < ncacerts; i++) {\n\n if (qcrypto_tls_creds_check_cert(creds,\n\n cacerts[i], cacertFile,\n\n isServer, true, errp) < 0) {\n\n goto cleanup;\n\n }\n\n }\n\n\n\n if (cert && ncacerts &&\n\n qcrypto_tls_creds_check_cert_pair(cert, certFile, cacerts,\n\n ncacerts, cacertFile,\n\n isServer, errp) < 0) {\n\n goto cleanup;\n\n }\n\n\n\n ret = 0;\n\n\n\n cleanup:\n\n if (cert) {\n\n gnutls_x509_crt_deinit(cert);\n\n }\n\n for (i = 0; i < ncacerts; i++) {\n\n gnutls_x509_crt_deinit(cacerts[i]);\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 12150 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_init_isa(MachineState *machine)\n\n{\n\n pci_enabled = false;\n\n has_acpi_build = false;\n\n smbios_defaults = false;\n\n gigabyte_align = false;\n\n smbios_legacy_mode = true;\n\n has_reserved_memory = false;\n\n option_rom_has_mr = true;\n\n rom_file_has_mr = false;\n\n if (!machine->cpu_model) {\n\n machine->cpu_model = \"486\";\n\n }\n\n x86_cpu_change_kvm_default(\"kvm-pv-eoi\", NULL);\n\n enable_compat_apic_id_mode();\n\n pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);\n\n}\n", + "output": "0", + "index": 20509 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t nam_readw (void *opaque, uint32_t addr)\n\n{\n\n PCIAC97LinkState *d = opaque;\n\n AC97LinkState *s = &d->ac97;\n\n uint32_t val = ~0U;\n\n uint32_t index = addr - s->base[0];\n\n s->cas = 0;\n\n val = mixer_load (s, index);\n\n return val;\n\n}\n", + "output": "0", + "index": 1991 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void emulated_push_type(EmulatedState *card, uint32_t type)\n\n{\n\n EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent));\n\n\n\n assert(event);\n\n event->p.gen.type = type;\n\n emulated_push_event(card, event);\n\n}\n", + "output": "1", + "index": 4361 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void IRQ_check(OpenPICState *opp, IRQ_queue_t *q)\n\n{\n\n int next, i;\n\n int priority;\n\n\n\n next = -1;\n\n priority = -1;\n\n\n\n if (!q->pending) {\n\n /* IRQ bitmap is empty */\n\n goto out;\n\n }\n\n\n\n for (i = 0; i < opp->max_irq; i++) {\n\n if (IRQ_testbit(q, i)) {\n\n DPRINTF(\"IRQ_check: irq %d set ipvp_pr=%d pr=%d\\n\",\n\n i, IPVP_PRIORITY(opp->src[i].ipvp), priority);\n\n if (IPVP_PRIORITY(opp->src[i].ipvp) > priority) {\n\n next = i;\n\n priority = IPVP_PRIORITY(opp->src[i].ipvp);\n\n }\n\n }\n\n }\n\n\n\nout:\n\n q->next = next;\n\n q->priority = priority;\n\n}\n", + "output": "1", + "index": 7343 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tcp_write(URLContext *h, const uint8_t *buf, int size)\n\n{\n\n TCPContext *s = h->priv_data;\n\n int ret, size1, fd_max, len;\n\n fd_set wfds;\n\n struct timeval tv;\n\n\n\n size1 = size;\n\n while (size > 0) {\n\n if (url_interrupt_cb())\n\n return AVERROR(EINTR);\n\n fd_max = s->fd;\n\n FD_ZERO(&wfds);\n\n FD_SET(s->fd, &wfds);\n\n tv.tv_sec = 0;\n\n tv.tv_usec = 100 * 1000;\n\n ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);\n\n if (ret > 0 && FD_ISSET(s->fd, &wfds)) {\n\n len = send(s->fd, buf, size, 0);\n\n if (len < 0) {\n\n if (ff_neterrno() != FF_NETERROR(EINTR) &&\n\n ff_neterrno() != FF_NETERROR(EAGAIN))\n\n return ff_neterrno();\n\n continue;\n\n }\n\n size -= len;\n\n buf += len;\n\n } else if (ret < 0) {\n\n if (ff_neterrno() == FF_NETERROR(EINTR))\n\n continue;\n\n return -1;\n\n }\n\n }\n\n return size1 - size;\n\n}\n", + "output": "0", + "index": 20132 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_frame_packing_arrangement(H264Context *h)\n\n{\n\n h->sei_fpa.frame_packing_arrangement_id = get_ue_golomb(&h->gb);\n\n h->sei_fpa.frame_packing_arrangement_cancel_flag = get_bits1(&h->gb);\n\n h->sei_frame_packing_present = !h->sei_fpa.frame_packing_arrangement_cancel_flag;\n\n\n\n if (h->sei_frame_packing_present) {\n\n h->sei_fpa.frame_packing_arrangement_type =\n\n h->frame_packing_arrangement_type = get_bits(&h->gb, 7);\n\n h->sei_fpa.quincunx_sampling_flag =\n\n h->quincunx_subsampling = get_bits1(&h->gb);\n\n h->sei_fpa.content_interpretation_type =\n\n h->content_interpretation_type = get_bits(&h->gb, 6);\n\n\n\n // the following skips: spatial_flipping_flag, frame0_flipped_flag,\n\n // field_views_flag, current_frame_is_frame0_flag,\n\n // frame0_self_contained_flag, frame1_self_contained_flag\n\n skip_bits(&h->gb, 6);\n\n\n\n if (!h->quincunx_subsampling && h->frame_packing_arrangement_type != 5)\n\n skip_bits(&h->gb, 16); // frame[01]_grid_position_[xy]\n\n skip_bits(&h->gb, 8); // frame_packing_arrangement_reserved_byte\n\n h->sei_fpa.frame_packing_arrangement_repetition_period = get_ue_golomb(&h->gb) /* frame_packing_arrangement_repetition_period */;\n\n }\n\n skip_bits1(&h->gb); // frame_packing_arrangement_extension_flag\n\n\n\n if (h->avctx->debug & FF_DEBUG_PICT_INFO)\n\n av_log(h->avctx, AV_LOG_DEBUG, \"SEI FPA %d %d %d %d %d %d\\n\",\n\n h->sei_fpa.frame_packing_arrangement_id,\n\n h->sei_fpa.frame_packing_arrangement_cancel_flag,\n\n h->sei_fpa.frame_packing_arrangement_type,\n\n h->sei_fpa.quincunx_sampling_flag,\n\n h->sei_fpa.content_interpretation_type,\n\n h->sei_fpa.frame_packing_arrangement_repetition_period);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 19201 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int walk_memory_regions(void *priv, walk_memory_regions_fn fn)\n\n{\n\n struct walk_memory_regions_data data;\n\n uintptr_t i;\n\n\n\n data.fn = fn;\n\n data.priv = priv;\n\n data.start = -1ul;\n\n data.prot = 0;\n\n\n\n for (i = 0; i < V_L1_SIZE; i++) {\n\n int rc = walk_memory_regions_1(&data, (abi_ulong)i << V_L1_SHIFT,\n\n V_L1_SHIFT / L2_BITS - 1, l1_map + i);\n\n\n\n if (rc != 0) {\n\n return rc;\n\n }\n\n }\n\n\n\n return walk_memory_regions_end(&data, 0, 0);\n\n}\n", + "output": "0", + "index": 20893 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)\n\n{\n\n DriveInfo *dinfo;\n\n int unit;\n\n\n\n for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {\n\n dinfo = drive_get(IF_SCSI, bus->busnr, unit);\n\n if (dinfo == NULL) {\n\n continue;\n\n }\n\n scsi_bus_legacy_add_drive(bus, dinfo, unit);\n\n }\n\n}\n", + "output": "1", + "index": 26416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)\n\n{\n\n int i, j = 0;\n\n const int mb_block_count = 4 + (1 << s->chroma_format);\n\n\n\n cbp <<= 12-mb_block_count;\n\n for (i = 0; i < mb_block_count; i++) {\n\n if (cbp & (1 << 11))\n\n s->pblocks[i] = &s->block[j++];\n\n else\n\n s->pblocks[i] = NULL;\n\n cbp += cbp;\n\n }\n\n}\n", + "output": "0", + "index": 21349 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int pci_piix3_xen_ide_unplug(DeviceState *dev)\n\n{\n\n PCIIDEState *pci_ide;\n\n DriveInfo *di;\n\n int i;\n\n IDEDevice *idedev;\n\n\n\n pci_ide = PCI_IDE(dev);\n\n\n\n for (i = 0; i < 4; i++) {\n\n di = drive_get_by_index(IF_IDE, i);\n\n if (di != NULL && !di->media_cd) {\n\n BlockBackend *blk = blk_by_legacy_dinfo(di);\n\n DeviceState *ds = blk_get_attached_dev(blk);\n\n\n\n blk_drain(blk);\n\n blk_flush(blk);\n\n\n\n if (ds) {\n\n blk_detach_dev(blk, ds);\n\n }\n\n pci_ide->bus[di->bus].ifs[di->unit].blk = NULL;\n\n if (!(i % 2)) {\n\n idedev = pci_ide->bus[di->bus].master;\n\n } else {\n\n idedev = pci_ide->bus[di->bus].slave;\n\n }\n\n idedev->conf.blk = NULL;\n\n monitor_remove_blk(blk);\n\n blk_unref(blk);\n\n }\n\n }\n\n qdev_reset_all(DEVICE(dev));\n\n return 0;\n\n}\n", + "output": "0", + "index": 7945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fill_buffer(AVIOContext *s)\n\n{\n\n int max_buffer_size = s->max_packet_size ?\n\n s->max_packet_size : IO_BUFFER_SIZE;\n\n uint8_t *dst = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ?\n\n s->buf_end : s->buffer;\n\n int len = s->buffer_size - (dst - s->buffer);\n\n\n\n /* can't fill the buffer without read_packet, just set EOF if appropriate */\n\n if (!s->read_packet && s->buf_ptr >= s->buf_end)\n\n s->eof_reached = 1;\n\n\n\n /* no need to do anything if EOF already reached */\n\n if (s->eof_reached)\n\n return;\n\n\n\n if (s->update_checksum && dst == s->buffer) {\n\n if (s->buf_end > s->checksum_ptr)\n\n s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,\n\n s->buf_end - s->checksum_ptr);\n\n s->checksum_ptr = s->buffer;\n\n }\n\n\n\n /* make buffer smaller in case it ended up large after probing */\n\n if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {\n\n if (dst == s->buffer && s->buf_ptr != dst) {\n\n int ret = ffio_set_buf_size(s, s->orig_buffer_size);\n\n if (ret < 0)\n\n av_log(s, AV_LOG_WARNING, \"Failed to decrease buffer size\\n\");\n\n\n\n s->checksum_ptr = dst = s->buffer;\n\n }\n\n av_assert0(len >= s->orig_buffer_size);\n\n len = s->orig_buffer_size;\n\n }\n\n\n\n if (s->read_packet)\n\n len = s->read_packet(s->opaque, dst, len);\n\n else\n\n len = AVERROR_EOF;\n\n if (len == AVERROR_EOF) {\n\n /* do not modify buffer if EOF reached so that a seek back can\n\n be done without rereading data */\n\n s->eof_reached = 1;\n\n } else if (len < 0) {\n\n s->eof_reached = 1;\n\n s->error= len;\n\n } else {\n\n s->pos += len;\n\n s->buf_ptr = dst;\n\n s->buf_end = dst + len;\n\n s->bytes_read += len;\n\n }\n\n}\n", + "output": "0", + "index": 8730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void dsputil_init_mmi(void)\n\n{\n\n clear_blocks = clear_blocks_mmi;\n\n \n\n put_pixels_tab[1][0] = put_pixels8_mmi;\n\n put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;\n\n \n\n put_pixels_tab[0][0] = put_pixels16_mmi;\n\n put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;\n\n \n\n get_pixels = get_pixels_mmi;\n\n}\n", + "output": "0", + "index": 7879 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(qdict_put_exists_test)\n\n{\n\n int value;\n\n const char *key = \"exists\";\n\n\n\n qdict_put(tests_dict, key, qint_from_int(1));\n\n qdict_put(tests_dict, key, qint_from_int(2));\n\n\n\n value = qdict_get_int(tests_dict, key);\n\n fail_unless(value == 2);\n\n\n\n fail_unless(qdict_size(tests_dict) == 1);\n\n}\n", + "output": "0", + "index": 3435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_gsi(KVMState *s, unsigned int gsi)\n\n{\n\n assert(gsi < s->max_gsi);\n\n\n\n s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32);\n\n}\n", + "output": "0", + "index": 2563 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_exec_nocache(CPUState *cpu, int max_cycles,\n\n TranslationBlock *orig_tb, bool ignore_icount)\n\n{\n\n TranslationBlock *tb;\n\n\n\n /* Should never happen.\n\n We only end up here when an existing TB is too long. */\n\n if (max_cycles > CF_COUNT_MASK)\n\n max_cycles = CF_COUNT_MASK;\n\n\n\n tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags,\n\n max_cycles | CF_NOCACHE\n\n | (ignore_icount ? CF_IGNORE_ICOUNT : 0));\n\n tb->orig_tb = tcg_ctx.tb_ctx.tb_invalidated_flag ? NULL : orig_tb;\n\n cpu->current_tb = tb;\n\n /* execute the generated code */\n\n trace_exec_tb_nocache(tb, tb->pc);\n\n cpu_tb_exec(cpu, tb);\n\n cpu->current_tb = NULL;\n\n tb_phys_invalidate(tb, -1);\n\n tb_free(tb);\n\n}\n", + "output": "0", + "index": 5388 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_io_channel_setup_sync(SocketAddressLegacy *listen_addr,\n\n SocketAddressLegacy *connect_addr,\n\n QIOChannel **src,\n\n QIOChannel **dst)\n\n{\n\n QIOChannelSocket *lioc;\n\n\n\n lioc = qio_channel_socket_new();\n\n qio_channel_socket_listen_sync(lioc, listen_addr, &error_abort);\n\n\n\n if (listen_addr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {\n\n SocketAddressLegacy *laddr = qio_channel_socket_get_local_address(\n\n lioc, &error_abort);\n\n\n\n g_free(connect_addr->u.inet.data->port);\n\n connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);\n\n\n\n qapi_free_SocketAddressLegacy(laddr);\n\n }\n\n\n\n *src = QIO_CHANNEL(qio_channel_socket_new());\n\n qio_channel_socket_connect_sync(\n\n QIO_CHANNEL_SOCKET(*src), connect_addr, &error_abort);\n\n qio_channel_set_delay(*src, false);\n\n\n\n qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN);\n\n *dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort));\n\n g_assert(*dst);\n\n\n\n test_io_channel_set_socket_bufs(*src, *dst);\n\n\n\n object_unref(OBJECT(lioc));\n\n}\n", + "output": "0", + "index": 814 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t mv88w8618_wlan_read(void *opaque, target_phys_addr_t offset,\n\n unsigned size)\n\n{\n\n switch (offset) {\n\n /* Workaround to allow loading the binary-only wlandrv.ko crap\n\n * from the original Freecom firmware. */\n\n case MP_WLAN_MAGIC1:\n\n return ~3;\n\n case MP_WLAN_MAGIC2:\n\n return -1;\n\n\n\n default:\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 23423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_uas_unrealize(USBDevice *dev, Error **errp)\n{\n UASDevice *uas = USB_UAS(dev);\n qemu_bh_delete(uas->status_bh);\n}", + "output": "1", + "index": 27281 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int seqvideo_decode_init(AVCodecContext *avctx)\n\n{\n\n SeqVideoContext *seq = avctx->priv_data;\n\n\n\n seq->avctx = avctx;\n\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n\n\n\n seq->frame.data[0] = NULL;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 760 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cmd_test_unit_ready(IDEState *s, uint8_t *buf)\n\n{\n\n if (bdrv_is_inserted(s->bs)) {\n\n ide_atapi_cmd_ok(s);\n\n } else {\n\n ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);\n\n }\n\n}\n", + "output": "0", + "index": 20064 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "real_parse_asm_rulebook(AVFormatContext *s, AVStream *orig_st,\n\n const char *p)\n\n{\n\n const char *end;\n\n int n_rules, odd = 0;\n\n AVStream *st;\n\n\n\n /**\n\n * The ASMRuleBook contains a list of comma-separated strings per rule,\n\n * and each rule is separated by a ;. The last one also has a ; at the\n\n * end so we can use it as delimiter.\n\n * Every rule occurs twice, once for when the RTSP packet header marker\n\n * is set and once for if it isn't. We only read the first because we\n\n * don't care much (that's what the \"odd\" variable is for).\n\n * Each rule contains a set of one or more statements, optionally\n\n * preceeded by a single condition. If there's a condition, the rule\n\n * starts with a '#'. Multiple conditions are merged between brackets,\n\n * so there are never multiple conditions spread out over separate\n\n * statements. Generally, these conditions are bitrate limits (min/max)\n\n * for multi-bitrate streams.\n\n */\n\n if (*p == '\\\"') p++;\n\n for (n_rules = 0; s->nb_streams < MAX_STREAMS;) {\n\n if (!(end = strchr(p, ';')))\n\n break;\n\n if (!odd && end != p) {\n\n if (n_rules > 0)\n\n st = add_dstream(s, orig_st);\n\n else\n\n st = orig_st;\n\n real_parse_asm_rule(st, p, end);\n\n n_rules++;\n\n }\n\n p = end + 1;\n\n odd ^= 1;\n\n }\n\n}\n", + "output": "0", + "index": 17791 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_deserialize(void **native_out, void *datap,\n\n VisitorFunc visit, Error **errp)\n\n{\n\n QmpSerializeData *d = datap;\n\n QString *output_json;\n\n QObject *obj_orig, *obj;\n\n\n\n obj_orig = qmp_output_get_qobject(d->qov);\n\n output_json = qobject_to_json(obj_orig);\n\n obj = qobject_from_json(qstring_get_str(output_json));\n\n\n\n QDECREF(output_json);\n\n d->qiv = qmp_input_visitor_new(obj, true);\n\n qobject_decref(obj_orig);\n\n qobject_decref(obj);\n\n visit(d->qiv, native_out, errp);\n\n}\n", + "output": "0", + "index": 12653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void handle_mousewheel(SDL_Event *ev)\n\n{\n\n struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);\n\n SDL_MouseWheelEvent *wev = &ev->wheel;\n\n InputButton btn;\n\n\n\n if (wev->y > 0) {\n\n btn = INPUT_BUTTON_WHEEL_UP;\n\n } else if (wev->y < 0) {\n\n btn = INPUT_BUTTON_WHEEL_DOWN;\n\n } else {\n\n return;\n\n }\n\n\n\n qemu_input_queue_btn(scon->dcl.con, btn, true);\n\n qemu_input_event_sync();\n\n qemu_input_queue_btn(scon->dcl.con, btn, false);\n\n qemu_input_event_sync();\n\n}\n", + "output": "0", + "index": 4104 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cow_create(const char *filename, QemuOpts *opts, Error **errp)\n\n{\n\n struct cow_header_v2 cow_header;\n\n struct stat st;\n\n int64_t image_sectors = 0;\n\n char *image_filename = NULL;\n\n Error *local_err = NULL;\n\n int ret;\n\n BlockDriverState *cow_bs;\n\n\n\n /* Read out options */\n\n image_sectors = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / 512;\n\n image_filename = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);\n\n\n\n ret = bdrv_create_file(filename, opts, &local_err);\n\n if (ret < 0) {\n\n error_propagate(errp, local_err);\n\n goto exit;\n\n }\n\n\n\n cow_bs = NULL;\n\n ret = bdrv_open(&cow_bs, filename, NULL, NULL,\n\n BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err);\n\n if (ret < 0) {\n\n error_propagate(errp, local_err);\n\n goto exit;\n\n }\n\n\n\n memset(&cow_header, 0, sizeof(cow_header));\n\n cow_header.magic = cpu_to_be32(COW_MAGIC);\n\n cow_header.version = cpu_to_be32(COW_VERSION);\n\n if (image_filename) {\n\n /* Note: if no file, we put a dummy mtime */\n\n cow_header.mtime = cpu_to_be32(0);\n\n\n\n if (stat(image_filename, &st) != 0) {\n\n goto mtime_fail;\n\n }\n\n cow_header.mtime = cpu_to_be32(st.st_mtime);\n\n mtime_fail:\n\n pstrcpy(cow_header.backing_file, sizeof(cow_header.backing_file),\n\n image_filename);\n\n }\n\n cow_header.sectorsize = cpu_to_be32(512);\n\n cow_header.size = cpu_to_be64(image_sectors * 512);\n\n ret = bdrv_pwrite(cow_bs, 0, &cow_header, sizeof(cow_header));\n\n if (ret < 0) {\n\n goto exit;\n\n }\n\n\n\n /* resize to include at least all the bitmap */\n\n ret = bdrv_truncate(cow_bs,\n\n sizeof(cow_header) + ((image_sectors + 7) >> 3));\n\n if (ret < 0) {\n\n goto exit;\n\n }\n\n\n\nexit:\n\n g_free(image_filename);\n\n bdrv_unref(cow_bs);\n\n return ret;\n\n}\n", + "output": "1", + "index": 3824 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_cleanup_net_client(NetClientState *nc)\n\n{\n\n QTAILQ_REMOVE(&net_clients, nc, next);\n\n\n\n nc->info->cleanup(nc);\n\n}\n", + "output": "1", + "index": 24352 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_exitfn(PCIDevice *pdev)\n\n{\n\n VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);\n\n\n\n vfio_unregister_err_notifier(vdev);\n\n pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);\n\n vfio_disable_interrupts(vdev);\n\n if (vdev->intx.mmap_timer) {\n\n timer_free(vdev->intx.mmap_timer);\n\n }\n\n vfio_teardown_msi(vdev);\n\n vfio_unmap_bars(vdev);\n\n}\n", + "output": "0", + "index": 22408 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void draw_char(AVCodecContext *avctx, int c)\n\n{\n\n AnsiContext *s = avctx->priv_data;\n\n int fg = s->fg;\n\n int bg = s->bg;\n\n\n\n if ((s->attributes & ATTR_BOLD))\n\n fg += 8;\n\n if ((s->attributes & ATTR_BLINK))\n\n bg += 8;\n\n if ((s->attributes & ATTR_REVERSE))\n\n FFSWAP(int, fg, bg);\n\n if ((s->attributes & ATTR_CONCEALED))\n\n fg = bg;\n\n ff_draw_pc_font(s->frame->data[0] + s->y * s->frame->linesize[0] + s->x,\n\n s->frame->linesize[0], s->font, s->font_height, c, fg, bg);\n\n s->x += FONT_WIDTH;\n\n if (s->x >= avctx->width) {\n\n s->x = 0;\n\n hscroll(avctx);\n\n }\n\n}\n", + "output": "0", + "index": 2930 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_op_clear_ieee_excp_and_FTT(void)\n\n{\n\n tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));\n\n}\n", + "output": "1", + "index": 22830 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virgl_resource_attach_backing(VirtIOGPU *g,\n\n struct virtio_gpu_ctrl_command *cmd)\n\n{\n\n struct virtio_gpu_resource_attach_backing att_rb;\n\n struct iovec *res_iovs;\n\n int ret;\n\n\n\n VIRTIO_GPU_FILL_CMD(att_rb);\n\n trace_virtio_gpu_cmd_res_back_attach(att_rb.resource_id);\n\n\n\n ret = virtio_gpu_create_mapping_iov(&att_rb, cmd, NULL, &res_iovs);\n\n if (ret != 0) {\n\n cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;\n\n return;\n\n }\n\n\n\n virgl_renderer_resource_attach_iov(att_rb.resource_id,\n\n res_iovs, att_rb.nr_entries);\n\n}\n", + "output": "1", + "index": 17750 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_bind(struct sockaddr *sa, socklen_t salen, bool *has_proto)\n\n{\n\n int fd;\n\n\n\n fd = socket(sa->sa_family, SOCK_STREAM, 0);\n\n if (fd < 0) {\n\n return -1;\n\n }\n\n\n\n if (bind(fd, sa, salen) < 0) {\n\n close(fd);\n\n if (errno == EADDRNOTAVAIL) {\n\n *has_proto = false;\n\n return 0;\n\n }\n\n return -1;\n\n }\n\n\n\n close(fd);\n\n *has_proto = true;\n\n return 0;\n\n}\n", + "output": "1", + "index": 26357 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, size_t iov_off,\n\n void *buf, size_t size)\n\n{\n\n uint8_t *ptr;\n\n size_t iovec_off, buf_off;\n\n unsigned int i;\n\n\n\n ptr = buf;\n\n iovec_off = 0;\n\n buf_off = 0;\n\n for (i = 0; i < iov_cnt && size; i++) {\n\n if (iov_off < (iovec_off + iov[i].iov_len)) {\n\n size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);\n\n\n\n memcpy(ptr + buf_off, iov[i].iov_base + (iov_off - iovec_off), len);\n\n\n\n buf_off += len;\n\n iov_off += len;\n\n size -= len;\n\n }\n\n iovec_off += iov[i].iov_len;\n\n }\n\n return buf_off;\n\n}\n", + "output": "0", + "index": 26697 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "float64 HELPER(ucf64_addd)(float64 a, float64 b, CPUUniCore32State *env)\n\n{\n\n return float64_add(a, b, &env->ucf64.fp_status);\n\n}\n", + "output": "0", + "index": 15475 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vu_queue_notify(VuDev *dev, VuVirtq *vq)\n\n{\n\n if (unlikely(dev->broken)) {\n\n return;\n\n }\n\n\n\n if (!vring_notify(dev, vq)) {\n\n DPRINT(\"skipped notify...\\n\");\n\n return;\n\n }\n\n\n\n if (eventfd_write(vq->call_fd, 1) < 0) {\n\n vu_panic(dev, \"Error writing eventfd: %s\", strerror(errno));\n\n }\n\n}\n", + "output": "1", + "index": 9425 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)\n\n{\n\n int cssid, ssid, schid, m;\n\n SubchDev *sch;\n\n SCHIB schib;\n\n uint64_t addr;\n\n int ret = -ENODEV;\n\n int cc;\n\n CPUS390XState *env = &cpu->env;\n\n uint8_t ar;\n\n\n\n addr = decode_basedisp_s(env, ipb, &ar);\n\n if (addr & 3) {\n\n program_interrupt(env, PGM_SPECIFICATION, 2);\n\n return;\n\n }\n\n if (s390_cpu_virt_mem_read(cpu, addr, ar, &schib, sizeof(schib))) {\n\n return;\n\n }\n\n if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) ||\n\n !ioinst_schib_valid(&schib)) {\n\n program_interrupt(env, PGM_OPERAND, 2);\n\n return;\n\n }\n\n trace_ioinst_sch_id(\"msch\", cssid, ssid, schid);\n\n sch = css_find_subch(m, cssid, ssid, schid);\n\n if (sch && css_subch_visible(sch)) {\n\n ret = css_do_msch(sch, &schib);\n\n }\n\n switch (ret) {\n\n case -ENODEV:\n\n cc = 3;\n\n break;\n\n case -EBUSY:\n\n cc = 2;\n\n break;\n\n case 0:\n\n cc = 0;\n\n break;\n\n default:\n\n cc = 1;\n\n break;\n\n }\n\n setcc(cpu, cc);\n\n}\n", + "output": "0", + "index": 18931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp)\n\n{\n\n PCMachineState *pcms = PC_MACHINE(obj);\n\n\n\n pcms->nvdimm = value;\n\n}\n", + "output": "0", + "index": 11604 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void slirp_init(int restricted, struct in_addr vnetwork,\n\n struct in_addr vnetmask, struct in_addr vhost,\n\n const char *vhostname, const char *tftp_path,\n\n const char *bootfile, struct in_addr vdhcp_start,\n\n struct in_addr vnameserver)\n\n{\n\n slirp_init_once();\n\n\n\n link_up = 1;\n\n slirp_restrict = restricted;\n\n\n\n if_init();\n\n ip_init();\n\n\n\n /* Initialise mbufs *after* setting the MTU */\n\n m_init();\n\n\n\n vnetwork_addr = vnetwork;\n\n vnetwork_mask = vnetmask;\n\n vhost_addr = vhost;\n\n if (vhostname) {\n\n pstrcpy(slirp_hostname, sizeof(slirp_hostname), vhostname);\n\n }\n\n qemu_free(tftp_prefix);\n\n tftp_prefix = NULL;\n\n if (tftp_path) {\n\n tftp_prefix = qemu_strdup(tftp_path);\n\n }\n\n qemu_free(bootp_filename);\n\n bootp_filename = NULL;\n\n if (bootfile) {\n\n bootp_filename = qemu_strdup(bootfile);\n\n }\n\n vdhcp_startaddr = vdhcp_start;\n\n vnameserver_addr = vnameserver;\n\n\n\n register_savevm(\"slirp\", 0, 1, slirp_state_save, slirp_state_load, NULL);\n\n}\n", + "output": "0", + "index": 23701 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_and_aver_dst_16x16_msa(src - 2,\n\n src - (stride * 2) +\n\n sizeof(uint8_t), stride,\n\n dst, stride);\n\n}\n", + "output": "0", + "index": 9489 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_ocbi(CPUSH4State *env, uint32_t address)\n\n{\n\n memory_content **current = &(env->movcal_backup);\n\n while (*current)\n\n {\n\n\tuint32_t a = (*current)->address;\n\n\tif ((a & ~0x1F) == (address & ~0x1F))\n\n\t{\n\n\t memory_content *next = (*current)->next;\n\n cpu_stl_data(env, a, (*current)->value);\n\n\t \n\n\t if (next == NULL)\n\n\t {\n\n\t\tenv->movcal_backup_tail = current;\n\n\t }\n\n\n\n\t free (*current);\n\n\t *current = next;\n\n\t break;\n\n\t}\n\n }\n\n}\n", + "output": "1", + "index": 23951 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t omap_dpll_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque;\n\n\n\n if (size != 2) {\n\n return omap_badwidth_read16(opaque, addr);\n\n }\n\n\n\n if (addr == 0x00)\t/* CTL_REG */\n\n return s->mode;\n\n\n\n OMAP_BAD_REG(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 13771 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bytes_left(ByteIOContext *bc)\n\n{\n\n return bc->buf_end - bc->buf_ptr;\n\n}\n", + "output": "0", + "index": 8738 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_h264_h_lpf_luma_inter_msa(uint8_t *data, int img_width,\n\n int alpha, int beta, int8_t *tc)\n\n{\n\n uint8_t bs0 = 1;\n\n uint8_t bs1 = 1;\n\n uint8_t bs2 = 1;\n\n uint8_t bs3 = 1;\n\n\n\n if (tc[0] < 0)\n\n bs0 = 0;\n\n if (tc[1] < 0)\n\n bs1 = 0;\n\n if (tc[2] < 0)\n\n bs2 = 0;\n\n if (tc[3] < 0)\n\n bs3 = 0;\n\n\n\n avc_loopfilter_luma_inter_edge_ver_msa(data,\n\n bs0, bs1, bs2, bs3,\n\n tc[0], tc[1], tc[2], tc[3],\n\n alpha, beta, img_width);\n\n}\n", + "output": "0", + "index": 21360 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "command_loop(void)\n\n{\n\n\tint\t\tc, i, j = 0, done = 0;\n\n\tchar\t\t*input;\n\n\tchar\t\t**v;\n\n\tconst cmdinfo_t\t*ct;\n\n\n\n\tfor (i = 0; !done && i < ncmdline; i++) {\n\n\t\tinput = strdup(cmdline[i]);\n\n\t\tif (!input) {\n\n\t\t\tfprintf(stderr,\n\n\t\t\t\t_(\"cannot strdup command '%s': %s\\n\"),\n\n\t\t\t\tcmdline[i], strerror(errno));\n\n\t\t\texit(1);\n\n\t\t}\n\n\t\tv = breakline(input, &c);\n\n\t\tif (c) {\n\n\t\t\tct = find_command(v[0]);\n\n\t\t\tif (ct) {\n\n\t\t\t\tif (ct->flags & CMD_FLAG_GLOBAL)\n\n\t\t\t\t\tdone = command(ct, c, v);\n\n\t\t\t\telse {\n\n\t\t\t\t\tj = 0;\n\n\t\t\t\t\twhile (!done && (j = args_command(j)))\n\n\t\t\t\t\t\tdone = command(ct, c, v);\n\n\t\t\t\t}\n\n\t\t\t} else\n\n\t\t\t\tfprintf(stderr, _(\"command \\\"%s\\\" not found\\n\"),\n\n\t\t\t\t\tv[0]);\n\n\t\t}\n\n\t\tdoneline(input, v);\n\n\t}\n\n\tif (cmdline) {\n\n\t\tfree(cmdline);\n\n\t\treturn;\n\n\t}\n\n\twhile (!done) {\n\n\t\tif ((input = fetchline()) == NULL)\n\n\t\t\tbreak;\n\n\t\tv = breakline(input, &c);\n\n\t\tif (c) {\n\n\t\t\tct = find_command(v[0]);\n\n\t\t\tif (ct)\n\n\t\t\t\tdone = command(ct, c, v);\n\n\t\t\telse\n\n\t\t\t\tfprintf(stderr, _(\"command \\\"%s\\\" not found\\n\"),\n\n\t\t\t\t\tv[0]);\n\n\t\t}\n\n\t\tdoneline(input, v);\n\n\t}\n\n}\n", + "output": "0", + "index": 17673 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type,\n\n void (*func)(QVirtioDevice *d, void *data), void *data)\n\n{\n\n QVirtioPCIForeachData d = { .func = func,\n\n .device_type = device_type,\n\n .user_data = data };\n\n\n\n qpci_device_foreach(bus, PCI_VENDOR_ID_REDHAT_QUMRANET, -1,\n\n qvirtio_pci_foreach_callback, &d);\n\n}\n", + "output": "1", + "index": 10683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req)\n\n{\n\n VirtIODevice *vdev = (VirtIODevice *)s;\n\n int type;\n\n int r = 0;\n\n\n\n if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,\n\n &type, sizeof(type)) < sizeof(type)) {\n\n virtio_scsi_bad_req();\n\n return;\n\n }\n\n\n\n virtio_tswap32s(vdev, &req->req.tmf.type);\n\n if (req->req.tmf.type == VIRTIO_SCSI_T_TMF) {\n\n if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICtrlTMFReq),\n\n sizeof(VirtIOSCSICtrlTMFResp)) < 0) {\n\n virtio_scsi_bad_req();\n\n } else {\n\n r = virtio_scsi_do_tmf(s, req);\n\n }\n\n\n\n } else if (req->req.tmf.type == VIRTIO_SCSI_T_AN_QUERY ||\n\n req->req.tmf.type == VIRTIO_SCSI_T_AN_SUBSCRIBE) {\n\n if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICtrlANReq),\n\n sizeof(VirtIOSCSICtrlANResp)) < 0) {\n\n virtio_scsi_bad_req();\n\n } else {\n\n req->resp.an.event_actual = 0;\n\n req->resp.an.response = VIRTIO_SCSI_S_OK;\n\n }\n\n }\n\n if (r == 0) {\n\n virtio_scsi_complete_req(req);\n\n } else {\n\n assert(r == -EINPROGRESS);\n\n }\n\n}\n", + "output": "0", + "index": 4283 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,\n\n CPUBreakpoint **breakpoint)\n\n{\n\n#if defined(TARGET_HAS_ICE)\n\n CPUBreakpoint *bp;\n\n\n\n bp = g_malloc(sizeof(*bp));\n\n\n\n bp->pc = pc;\n\n bp->flags = flags;\n\n\n\n /* keep all GDB-injected breakpoints in front */\n\n if (flags & BP_GDB) {\n\n QTAILQ_INSERT_HEAD(&cpu->breakpoints, bp, entry);\n\n } else {\n\n QTAILQ_INSERT_TAIL(&cpu->breakpoints, bp, entry);\n\n }\n\n\n\n breakpoint_invalidate(cpu, pc);\n\n\n\n if (breakpoint) {\n\n *breakpoint = bp;\n\n }\n\n return 0;\n\n#else\n\n return -ENOSYS;\n\n#endif\n\n}\n", + "output": "0", + "index": 14573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)\n\n{\n\n if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) {\n\n\tint ret;\n\n\tuint32_t chunk = search_chunk(s,sector_num);\n\n\n\n\tif(chunk>=s->n_chunks)\n\n\t return -1;\n\n\n\n\ts->current_chunk = s->n_chunks;\n\n\tswitch(s->types[chunk]) {\n\n\tcase 0x80000005: { /* zlib compressed */\n\n\t int i;\n\n\n\n\t /* we need to buffer, because only the chunk as whole can be\n\n\t * inflated. */\n\n\t i=0;\n\n\t do {\n\n\t\tret = pread(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i,\n\n s->offsets[chunk] + i);\n\n\t\tif(ret<0 && errno==EINTR)\n\n\t\t ret=0;\n\n\t\ti+=ret;\n\n\t } while(ret>=0 && ret+ilengths[chunk]);\n\n\n\n\t if (ret != s->lengths[chunk])\n\n\t\treturn -1;\n\n\n\n\t s->zstream.next_in = s->compressed_chunk;\n\n\t s->zstream.avail_in = s->lengths[chunk];\n\n\t s->zstream.next_out = s->uncompressed_chunk;\n\n\t s->zstream.avail_out = 512*s->sectorcounts[chunk];\n\n\t ret = inflateReset(&s->zstream);\n\n\t if(ret != Z_OK)\n\n\t\treturn -1;\n\n\t ret = inflate(&s->zstream, Z_FINISH);\n\n\t if(ret != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])\n\n\t\treturn -1;\n\n\t break; }\n\n\tcase 1: /* copy */\n\n\t ret = pread(s->fd, s->uncompressed_chunk, s->lengths[chunk],\n\n s->offsets[chunk]);\n\n\t if (ret != s->lengths[chunk])\n\n\t\treturn -1;\n\n\t break;\n\n\tcase 2: /* zero */\n\n\t memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);\n\n\t break;\n\n\t}\n\n\ts->current_chunk = chunk;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 26944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vfio_container_do_ioctl(AddressSpace *as, int32_t groupid,\n\n int req, void *param)\n\n{\n\n VFIOGroup *group;\n\n VFIOContainer *container;\n\n int ret = -1;\n\n\n\n group = vfio_get_group(groupid, as);\n\n if (!group) {\n\n error_report(\"vfio: group %d not registered\", groupid);\n\n return ret;\n\n }\n\n\n\n container = group->container;\n\n if (group->container) {\n\n ret = ioctl(container->fd, req, param);\n\n if (ret < 0) {\n\n error_report(\"vfio: failed to ioctl %d to container: ret=%d, %s\",\n\n _IOC_NR(req) - VFIO_BASE, ret, strerror(errno));\n\n }\n\n }\n\n\n\n vfio_put_group(group);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 24189 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ram_addr_t find_ram_offset(ram_addr_t size)\n\n{\n\n RAMBlock *block, *next_block;\n\n ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX;\n\n\n\n assert(size != 0); /* it would hand out same offset multiple times */\n\n\n\n if (QTAILQ_EMPTY(&ram_list.blocks))\n\n return 0;\n\n\n\n QTAILQ_FOREACH(block, &ram_list.blocks, next) {\n\n ram_addr_t end, next = RAM_ADDR_MAX;\n\n\n\n end = block->offset + block->length;\n\n\n\n QTAILQ_FOREACH(next_block, &ram_list.blocks, next) {\n\n if (next_block->offset >= end) {\n\n next = MIN(next, next_block->offset);\n\n }\n\n }\n\n if (next - end >= size && next - end < mingap) {\n\n offset = end;\n\n mingap = next - end;\n\n }\n\n }\n\n\n\n if (offset == RAM_ADDR_MAX) {\n\n fprintf(stderr, \"Failed to find gap of requested size: %\" PRIu64 \"\\n\",\n\n (uint64_t)size);\n\n abort();\n\n }\n\n\n\n return offset;\n\n}\n", + "output": "0", + "index": 9670 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_ins(DisasContext *s, TCGMemOp ot)\n\n{\n\n if (s->base.tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_string_movl_A0_EDI(s);\n\n /* Note: we must do this dummy write first to be restartable in\n\n case of page fault. */\n\n tcg_gen_movi_tl(cpu_T0, 0);\n\n gen_op_st_v(s, ot, cpu_T0, cpu_A0);\n\n tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_EDX]);\n\n tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);\n\n gen_helper_in_func(ot, cpu_T0, cpu_tmp2_i32);\n\n gen_op_st_v(s, ot, cpu_T0, cpu_A0);\n\n gen_op_movl_T0_Dshift(ot);\n\n gen_op_add_reg_T0(s->aflag, R_EDI);\n\n gen_bpt_io(s, cpu_tmp2_i32, ot);\n\n if (s->base.tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n }\n\n}\n", + "output": "1", + "index": 3473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_client_write(void *opaque)\n\n{\n\n VncState *vs = opaque;\n\n\n\n vnc_lock_output(vs);\n\n if (vs->output.offset\n\n#ifdef CONFIG_VNC_WS\n\n || vs->ws_output.offset\n\n#endif\n\n ) {\n\n vnc_client_write_locked(opaque);\n\n } else if (vs->csock != -1) {\n\n qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs);\n\n }\n\n vnc_unlock_output(vs);\n\n}\n", + "output": "0", + "index": 23547 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_in_coroutine(void)\n\n{\n\n Coroutine *coroutine;\n\n\n\n g_assert(!qemu_in_coroutine());\n\n\n\n coroutine = qemu_coroutine_create(verify_in_coroutine);\n\n qemu_coroutine_enter(coroutine, NULL);\n\n}\n", + "output": "1", + "index": 8186 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,\n\n ImageInfoSpecific *info_spec)\n\n{\n\n QObject *obj, *data;\n\n Visitor *v = qobject_output_visitor_new(&obj);\n\n\n\n visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);\n\n visit_complete(v, &obj);\n\n assert(qobject_type(obj) == QTYPE_QDICT);\n\n data = qdict_get(qobject_to_qdict(obj), \"data\");\n\n dump_qobject(func_fprintf, f, 1, data);\n\n qobject_decref(obj);\n\n visit_free(v);\n\n}\n", + "output": "0", + "index": 26784 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int x86_cpu_filter_features(X86CPU *cpu)\n\n{\n\n CPUX86State *env = &cpu->env;\n\n FeatureWord w;\n\n int rv = 0;\n\n\n\n for (w = 0; w < FEATURE_WORDS; w++) {\n\n uint32_t host_feat =\n\n x86_cpu_get_supported_feature_word(w, false);\n\n uint32_t requested_features = env->features[w];\n\n env->features[w] &= host_feat;\n\n cpu->filtered_features[w] = requested_features & ~env->features[w];\n\n if (cpu->filtered_features[w]) {\n\n rv = 1;\n\n }\n\n }\n\n\n\n return rv;\n\n}\n", + "output": "0", + "index": 7976 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int sclp_service_call(uint32_t sccb, uint64_t code)\n\n{\n\n int r = 0;\n\n SCCB work_sccb;\n\n\n\n hwaddr sccb_len = sizeof(SCCB);\n\n\n\n /* first some basic checks on program checks */\n\n if (cpu_physical_memory_is_io(sccb)) {\n\n r = -PGM_ADDRESSING;\n\n goto out;\n\n }\n\n if (sccb & ~0x7ffffff8ul) {\n\n r = -PGM_SPECIFICATION;\n\n goto out;\n\n }\n\n\n\n /*\n\n * we want to work on a private copy of the sccb, to prevent guests\n\n * from playing dirty tricks by modifying the memory content after\n\n * the host has checked the values\n\n */\n\n cpu_physical_memory_read(sccb, &work_sccb, sccb_len);\n\n\n\n /* Valid sccb sizes */\n\n if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||\n\n be16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {\n\n r = -PGM_SPECIFICATION;\n\n goto out;\n\n }\n\n\n\n sclp_execute((SCCB *)&work_sccb, code);\n\n\n\n cpu_physical_memory_write(sccb, &work_sccb,\n\n be16_to_cpu(work_sccb.h.length));\n\n\n\n sclp_service_interrupt(sccb);\n\n\n\nout:\n\n return r;\n\n}\n", + "output": "0", + "index": 17654 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,\n\n DCTELEM *col)\n\n{\n\n int a0, a1, a2, a3, b0, b1, b2, b3;\n\n INIT_CLIP;\n\n\n\n IDCT_COLS;\n\n\n\n dest[0] = CLIP((a0 + b0) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a1 + b1) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a2 + b2) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a3 + b3) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a3 - b3) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a2 - b2) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a1 - b1) >> COL_SHIFT);\n\n dest += line_size;\n\n dest[0] = CLIP((a0 - b0) >> COL_SHIFT);\n\n}\n", + "output": "1", + "index": 22321 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys,\n\n const uint8_t* frame, unsigned buf_size)\n\n{\n\n int i;\n\n\n\n int dsf = (frame[3] & 0x80) >> 7;\n\n\n\n int stype = frame[80*5 + 48 + 3] & 0x1f;\n\n\n\n /* 576i50 25Mbps 4:1:1 is a special case */\n\n if (dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) {\n\n return &dv_profiles[2];\n\n }\n\n\n\n if(codec && codec->codec_tag==AV_RL32(\"dvsd\") && codec->width==720 && codec->height==576)\n\n return &dv_profiles[1];\n\n\n\n for (i=0; iframe_size)\n\n return sys;\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 25577 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void create_map(vorbis_context *vc, unsigned floor_number)\n\n{\n\n vorbis_floor *floors = vc->floors;\n\n vorbis_floor0 *vf;\n\n int idx;\n\n int blockflag, n;\n\n int32_t *map;\n\n\n\n for (blockflag = 0; blockflag < 2; ++blockflag) {\n\n n = vc->blocksize[blockflag] / 2;\n\n floors[floor_number].data.t0.map[blockflag] =\n\n av_malloc((n + 1) * sizeof(int32_t)); // n + sentinel\n\n\n\n map = floors[floor_number].data.t0.map[blockflag];\n\n vf = &floors[floor_number].data.t0;\n\n\n\n for (idx = 0; idx < n; ++idx) {\n\n map[idx] = floor(BARK((vf->rate * idx) / (2.0f * n)) *\n\n (vf->bark_map_size / BARK(vf->rate / 2.0f)));\n\n if (vf->bark_map_size-1 < map[idx])\n\n map[idx] = vf->bark_map_size - 1;\n\n }\n\n map[n] = -1;\n\n vf->map_size[blockflag] = n;\n\n }\n\n\n\n for (idx = 0; idx <= n; ++idx) {\n\n av_dlog(NULL, \"floor0 map: map at pos %d is %d\\n\", idx, map[idx]);\n\n }\n\n}\n", + "output": "0", + "index": 15906 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool memory_region_get_may_overlap(Object *obj, Error **errp)\n\n{\n\n MemoryRegion *mr = MEMORY_REGION(obj);\n\n\n\n return mr->may_overlap;\n\n}\n", + "output": "0", + "index": 24441 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_bios_write(void *opaque, uint32_t address, uint32_t data)\n\n{\n\n printf(\"%s: what are we supposed to do with (%08x)?\\n\",\n\n __FUNCTION__, data);\n\n}\n", + "output": "0", + "index": 21438 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int asf_read_ext_content(AVFormatContext *s, const GUIDParseTable *g)\n\n{\n\n ASFContext *asf = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n uint64_t size = avio_rl64(pb);\n\n uint16_t nb_desc = avio_rl16(pb);\n\n int i, ret;\n\n\n\n for (i = 0; i < nb_desc; i++) {\n\n uint16_t name_len, type, val_len;\n\n uint8_t *name = NULL;\n\n\n\n name_len = avio_rl16(pb);\n\n if (!name_len)\n\n return AVERROR_INVALIDDATA;\n\n name = av_malloc(name_len);\n\n if (!name)\n\n return AVERROR(ENOMEM);\n\n avio_get_str16le(pb, name_len, name,\n\n name_len);\n\n type = avio_rl16(pb);\n\n val_len = avio_rl16(pb);\n\n\n\n if ((ret = process_metadata(s, name, name_len, val_len, type, &s->metadata)) < 0)\n\n return ret;\n\n }\n\n\n\n align_position(pb, asf->offset, size);\n\n return 0;\n\n}\n", + "output": "1", + "index": 6543 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel4_mc10_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hz_qrt_4w_msa(src - 2, stride, dst, stride, 4, 0);\n\n}\n", + "output": "0", + "index": 15008 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qio_channel_socket_finalize(Object *obj)\n{\n QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(obj);\n if (ioc->fd != -1) {\n#ifdef WIN32\n WSAEventSelect(ioc->fd, NULL, 0);\n#endif\n closesocket(ioc->fd);\n ioc->fd = -1;", + "output": "1", + "index": 24331 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int load_image_targphys(const char *filename,\n\n target_phys_addr_t addr, uint64_t max_sz)\n\n{\n\n int size;\n\n\n\n size = get_image_size(filename);\n\n if (size > max_sz) {\n\n return -1;\n\n }\n\n if (size > 0) {\n\n rom_add_file_fixed(filename, addr, -1);\n\n }\n\n return size;\n\n}\n", + "output": "0", + "index": 25356 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,\n\n uint32_t iov_off, uint32_t size)\n\n{\n\n size_t iovec_off, buf_off;\n\n unsigned int i;\n\n uint32_t res = 0;\n\n uint32_t seq = 0;\n\n\n\n iovec_off = 0;\n\n buf_off = 0;\n\n for (i = 0; i < iov_cnt && size; i++) {\n\n if (iov_off < (iovec_off + iov[i].iov_len)) {\n\n size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);\n\n void *chunk_buf = iov[i].iov_base + (iov_off - iovec_off);\n\n\n\n res += net_checksum_add_cont(len, chunk_buf, seq);\n\n seq += len;\n\n\n\n buf_off += len;\n\n iov_off += len;\n\n size -= len;\n\n }\n\n iovec_off += iov[i].iov_len;\n\n }\n\n return res;\n\n}\n", + "output": "0", + "index": 27265 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb)\n\n{\n\n CRW *crw;\n\n uint64_t addr;\n\n int cc;\n\n hwaddr len = sizeof(*crw);\n\n CPUS390XState *env = &cpu->env;\n\n\n\n addr = decode_basedisp_s(env, ipb);\n\n if (addr & 3) {\n\n program_interrupt(env, PGM_SPECIFICATION, 2);\n\n return;\n\n }\n\n crw = s390_cpu_physical_memory_map(env, addr, &len, 1);\n\n if (!crw || len != sizeof(*crw)) {\n\n program_interrupt(env, PGM_ADDRESSING, 2);\n\n goto out;\n\n }\n\n cc = css_do_stcrw(crw);\n\n /* 0 - crw stored, 1 - zeroes stored */\n\n setcc(cpu, cc);\n\n\n\nout:\n\n s390_cpu_physical_memory_unmap(env, crw, len, 1);\n\n}\n", + "output": "0", + "index": 9944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void migration_instance_init(Object *obj)\n\n{\n\n MigrationState *ms = MIGRATION_OBJ(obj);\n\n\n\n ms->state = MIGRATION_STATUS_NONE;\n\n ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;\n\n ms->mbps = -1;\n\n ms->parameters.tls_creds = g_strdup(\"\");\n\n ms->parameters.tls_hostname = g_strdup(\"\");\n\n}\n", + "output": "0", + "index": 27082 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockAIOCB *ide_issue_trim(BlockDriverState *bs,\n\n int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\n\n BlockCompletionFunc *cb, void *opaque)\n\n{\n\n TrimAIOCB *iocb;\n\n\n\n iocb = qemu_aio_get(&trim_aiocb_info, bs, cb, opaque);\n\n iocb->bh = qemu_bh_new(ide_trim_bh_cb, iocb);\n\n iocb->ret = 0;\n\n iocb->qiov = qiov;\n\n iocb->i = -1;\n\n iocb->j = 0;\n\n ide_issue_trim_cb(iocb, 0);\n\n return &iocb->common;\n\n}\n", + "output": "0", + "index": 1627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void syscall_init(void)\n{\n IOCTLEntry *ie;\n const argtype *arg_type;\n int size;\n int i;\n#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);\n#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);\n#include \"syscall_types.h\"\n#undef STRUCT\n#undef STRUCT_SPECIAL\n /* Build target_to_host_errno_table[] table from\n * host_to_target_errno_table[]. */\n for (i = 0; i < ERRNO_TABLE_SIZE; i++) {\n target_to_host_errno_table[host_to_target_errno_table[i]] = i;\n }\n /* we patch the ioctl size if necessary. We rely on the fact that\n no ioctl has all the bits at '1' in the size field */\n ie = ioctl_entries;\n while (ie->target_cmd != 0) {\n if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==\n TARGET_IOC_SIZEMASK) {\n arg_type = ie->arg_type;\n if (arg_type[0] != TYPE_PTR) {\n fprintf(stderr, \"cannot patch size for ioctl 0x%x\\n\",\n ie->target_cmd);\n exit(1);\n }\n arg_type++;\n size = thunk_type_size(arg_type, 0);\n ie->target_cmd = (ie->target_cmd &\n ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |\n (size << TARGET_IOC_SIZESHIFT);\n }\n /* automatic consistency check if same arch */\n#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \\\n (defined(__x86_64__) && defined(TARGET_X86_64))\n if (unlikely(ie->target_cmd != ie->host_cmd)) {\n fprintf(stderr, \"ERROR: ioctl(%s): target=0x%x host=0x%x\\n\",\n ie->name, ie->target_cmd, ie->host_cmd);\n }\n#endif\n ie++;\n }\n}", + "output": "1", + "index": 13930 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr,\n\n target_ulong opcode, target_ulong *args)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n target_ulong flags = args[0];\n\n target_ulong pte_index = args[1];\n\n uint8_t *hpte;\n\n int i, ridx, n_entries = 1;\n\n\n\n if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {\n\n return H_PARAMETER;\n\n }\n\n\n\n if (flags & H_READ_4) {\n\n /* Clear the two low order bits */\n\n pte_index &= ~(3ULL);\n\n n_entries = 4;\n\n }\n\n\n\n hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);\n\n\n\n for (i = 0, ridx = 0; i < n_entries; i++) {\n\n args[ridx++] = ldq_p(hpte);\n\n args[ridx++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));\n\n hpte += HASH_PTE_SIZE_64;\n\n }\n\n\n\n return H_SUCCESS;\n\n}\n", + "output": "1", + "index": 27024 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)\n\n{\n\n uint16_t cmd;\n\n int i, sz, offset, code;\n\n unsigned char *dst_end = dst + dst_size;\n\n const unsigned char *src_end = src + src_size;\n\n\n\n while (src < src_end && dst < dst_end) {\n\n code = *src++;\n\n for (i = 0; i < 8 && src < src_end && dst < dst_end; ++i) {\n\n if (code & (1 << i)) {\n\n *dst++ = *src++;\n\n } else {\n\n cmd = AV_RL16(src); src += 2;\n\n offset = cmd >> 4;\n\n sz = (cmd & 0xF) + 2;\n\n /* don't use memcpy/memmove here as the decoding routine (ab)uses */\n\n /* buffer overlappings to repeat bytes in the destination */\n\n sz = FFMIN(sz, dst_end - dst);\n\n while (sz--) {\n\n *dst = *(dst - offset - 1);\n\n ++dst;\n\n }\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 9896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aiff_write_trailer(AVFormatContext *s)\n\n{\n\n AVIOContext *pb = s->pb;\n\n AIFFOutputContext *aiff = s->priv_data;\n\n AVCodecParameters *par = s->streams[0]->codecpar;\n\n\n\n /* Chunks sizes must be even */\n\n int64_t file_size, end_size;\n\n end_size = file_size = avio_tell(pb);\n\n if (file_size & 1) {\n\n avio_w8(pb, 0);\n\n end_size++;\n\n }\n\n\n\n if (s->pb->seekable) {\n\n /* File length */\n\n avio_seek(pb, aiff->form, SEEK_SET);\n\n avio_wb32(pb, file_size - aiff->form - 4);\n\n\n\n /* Number of sample frames */\n\n avio_seek(pb, aiff->frames, SEEK_SET);\n\n avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align);\n\n\n\n /* Sound Data chunk size */\n\n avio_seek(pb, aiff->ssnd, SEEK_SET);\n\n avio_wb32(pb, file_size - aiff->ssnd - 4);\n\n\n\n /* return to the end */\n\n avio_seek(pb, end_size, SEEK_SET);\n\n\n\n avio_flush(pb);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 6656 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int encode_slice_plane(AVCodecContext *avctx, int mb_count,\n\n uint8_t *src, int src_stride, uint8_t *buf, unsigned buf_size,\n\n int *qmat, int chroma)\n\n{\n\n ProresContext* ctx = avctx->priv_data;\n\n FDCTDSPContext *fdsp = &ctx->fdsp;\n\n DECLARE_ALIGNED(16, int16_t, blocks)[DEFAULT_SLICE_MB_WIDTH << 8], *block;\n\n int i, blocks_per_slice;\n\n PutBitContext pb;\n\n\n\n block = blocks;\n\n for (i = 0; i < mb_count; i++) {\n\n fdct_get(fdsp, src, src_stride, block + (0 << 6));\n\n fdct_get(fdsp, src + 8 * src_stride, src_stride, block + ((2 - chroma) << 6));\n\n if (!chroma) {\n\n fdct_get(fdsp, src + 16, src_stride, block + (1 << 6));\n\n fdct_get(fdsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6));\n\n }\n\n\n\n block += (256 >> chroma);\n\n src += (32 >> chroma);\n\n }\n\n\n\n blocks_per_slice = mb_count << (2 - chroma);\n\n init_put_bits(&pb, buf, buf_size << 3);\n\n\n\n encode_dc_coeffs(&pb, blocks, blocks_per_slice, qmat);\n\n encode_ac_coeffs(avctx, &pb, blocks, blocks_per_slice, qmat);\n\n\n\n flush_put_bits(&pb);\n\n return put_bits_ptr(&pb) - pb.buf;\n\n}\n", + "output": "1", + "index": 4421 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ffm_set_write_index(AVFormatContext *s, int64_t pos,\n\n int64_t file_size)\n\n{\n\n FFMContext *ffm = s->priv_data;\n\n ffm->write_index = pos;\n\n ffm->file_size = file_size;\n\n}\n", + "output": "0", + "index": 4790 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_sector_read(IDEState *s)\n{\n int64_t sector_num;\n int n;\n s->status = READY_STAT | SEEK_STAT;\n s->error = 0; /* not needed by IDE spec, but needed by Windows */\n sector_num = ide_get_sector(s);\n n = s->nsector;\n if (n == 0) {\n ide_transfer_stop(s);\n s->status |= BUSY_STAT;\n if (n > s->req_nb_sectors) {\n n = s->req_nb_sectors;\n#if defined(DEBUG_IDE)\n printf(\"sector=%\" PRId64 \"\\n\", sector_num);\n#endif\n s->iov.iov_base = s->io_buffer;\n s->iov.iov_len = n * BDRV_SECTOR_SIZE;\n qemu_iovec_init_external(&s->qiov, &s->iov, 1);\n bdrv_acct_start(s->bs, &s->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);\n s->pio_aiocb = bdrv_aio_readv(s->bs, sector_num, &s->qiov, n,\n ide_sector_read_cb, s);", + "output": "1", + "index": 22010 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_native_list(TestOutputVisitorData *data,\n\n const void *unused,\n\n UserDefNativeListUnionKind kind)\n\n{\n\n UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1);\n\n QObject *obj;\n\n\n\n cvalue->type = kind;\n\n init_native_list(cvalue);\n\n\n\n visit_type_UserDefNativeListUnion(data->ov, NULL, &cvalue, &error_abort);\n\n\n\n obj = visitor_get(data);\n\n check_native_list(obj, cvalue->type);\n\n qapi_free_UserDefNativeListUnion(cvalue);\n\n}\n", + "output": "0", + "index": 12858 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_setup_block(struct subchannel_id schid)\n\n{\n\n struct vq_info_block info;\n\n struct vq_config_block config = {};\n\n\n\n virtio_reset(schid);\n\n\n\n config.index = 0;\n\n if (run_ccw(schid, CCW_CMD_READ_VQ_CONF, &config, sizeof(config))) {\n\n virtio_panic(\"Could not get block device configuration\\n\");\n\n }\n\n vring_init(&block, config.num, (void*)(100 * 1024 * 1024),\n\n KVM_S390_VIRTIO_RING_ALIGN);\n\n\n\n info.queue = (100ULL * 1024ULL* 1024ULL);\n\n info.align = KVM_S390_VIRTIO_RING_ALIGN;\n\n info.index = 0;\n\n info.num = config.num;\n\n block.schid = schid;\n\n\n\n if (!run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info))) {\n\n virtio_set_status(schid, VIRTIO_CONFIG_S_DRIVER_OK);\n\n }\n\n}\n", + "output": "0", + "index": 8000 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes,\n\n VirtIOBlockReq *req)\n\n{\n\n BlockDriverAIOCB *acb;\n\n\n\n /*\n\n * Make sure all outstanding writes are posted to the backing device.\n\n */\n\n if (*num_writes > 0) {\n\n do_multiwrite(req->dev->bs, blkreq, *num_writes);\n\n }\n\n *num_writes = 0;\n\n\n\n acb = bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req);\n\n if (!acb) {\n\n virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);\n\n }\n\n}\n", + "output": "0", + "index": 14892 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; }\n", + "output": "0", + "index": 23249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,\n\n const char *name, size_t size, Error **errp)\n\n{\n\n QmpInputVisitor *qiv = to_qiv(v);\n\n const QObject *qobj = qmp_input_get_object(qiv, name);\n\n\n\n if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {\n\n error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",\n\n \"QDict\");\n\n return;\n\n }\n\n\n\n qmp_input_push(qiv, qobj, errp);\n\n if (error_is_set(errp)) {\n\n return;\n\n }\n\n\n\n if (obj) {\n\n *obj = g_malloc0(size);\n\n }\n\n}\n", + "output": "1", + "index": 25036 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_dma_restart_cb(void *opaque, int running,\n\n RunState state)\n\n{\n\n VirtIOBlock *s = opaque;\n\n\n\n if (!running) {\n\n return;\n\n }\n\n\n\n if (!s->bh) {\n\n s->bh = qemu_bh_new(virtio_blk_dma_restart_bh, s);\n\n qemu_bh_schedule(s->bh);\n\n }\n\n}\n", + "output": "0", + "index": 23923 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmxnet3_fill_stats(VMXNET3State *s)\n\n{\n\n int i;\n\n\n\n if (!s->device_active)\n\n return;\n\n\n\n for (i = 0; i < s->txq_num; i++) {\n\n pci_dma_write(PCI_DEVICE(s),\n\n s->txq_descr[i].tx_stats_pa,\n\n &s->txq_descr[i].txq_stats,\n\n sizeof(s->txq_descr[i].txq_stats));\n\n }\n\n\n\n for (i = 0; i < s->rxq_num; i++) {\n\n pci_dma_write(PCI_DEVICE(s),\n\n s->rxq_descr[i].rx_stats_pa,\n\n &s->rxq_descr[i].rxq_stats,\n\n sizeof(s->rxq_descr[i].rxq_stats));\n\n }\n\n}\n", + "output": "1", + "index": 11163 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n\n{\n\n AVStream *st;\n\n MOVStreamContext *sc;\n\n int ret, entries;\n\n\n\n if (c->fc->nb_streams < 1)\n\n return 0;\n\n st = c->fc->streams[c->fc->nb_streams - 1];\n\n sc = st->priv_data;\n\n\n\n avio_r8(pb); /* version */\n\n avio_rb24(pb); /* flags */\n\n entries = avio_rb32(pb);\n\n\n\n if (entries <= 0) {\n\n av_log(c->fc, AV_LOG_ERROR, \"invalid STSD entries %d\\n\", entries);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n if (sc->extradata) {\n\n av_log(c->fc, AV_LOG_ERROR,\n\n \"Duplicate stsd found in this track.\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n /* Prepare space for hosting multiple extradata. */\n\n sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata));\n\n if (!sc->extradata)\n\n return AVERROR(ENOMEM);\n\n\n\n sc->extradata_size = av_mallocz_array(entries, sizeof(*sc->extradata_size));\n\n if (!sc->extradata_size) {\n\n ret = AVERROR(ENOMEM);\n\n goto fail;\n\n }\n\n\n\n ret = ff_mov_read_stsd_entries(c, pb, entries);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n sc->stsd_count = entries;\n\n\n\n /* Restore back the primary extradata. */\n\n av_freep(&st->codecpar->extradata);\n\n st->codecpar->extradata_size = sc->extradata_size[0];\n\n if (sc->extradata_size[0]) {\n\n st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);\n\n if (!st->codecpar->extradata)\n\n return AVERROR(ENOMEM);\n\n memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);\n\n }\n\n\n\n return mov_finalize_stsd_codec(c, pb, st, sc);\n\nfail:\n\n av_freep(&sc->extradata);\n\n av_freep(&sc->extradata_size);\n\n return ret;\n\n}\n", + "output": "1", + "index": 3087 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int net_init_vhost_user(const NetClientOptions *opts, const char *name,\n\n NetClientState *peer)\n\n{\n\n return net_vhost_user_init(peer, \"vhost_user\", 0, 0, 0);\n\n}\n", + "output": "0", + "index": 18063 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static AioHandler *find_aio_handler(int fd)\n\n{\n\n AioHandler *node;\n\n\n\n LIST_FOREACH(node, &aio_handlers, node) {\n\n if (node->fd == fd)\n\n if (!node->deleted)\n\n return node;\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 17694 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_slirp_smb(const char *exported_dir)\n\n{\n\n if (slirp_smb_export) {\n\n fprintf(stderr, \"-smb given twice\\n\");\n\n exit(1);\n\n }\n\n slirp_smb_export = exported_dir;\n\n if (slirp_inited) {\n\n slirp_smb(exported_dir);\n\n }\n\n}\n", + "output": "0", + "index": 23533 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pc_boot_set(void *opaque, const char *boot_device)\n\n{\n\n return set_boot_dev(opaque, boot_device);\n\n}\n", + "output": "0", + "index": 11266 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t cs_read (void *opaque, target_phys_addr_t addr, unsigned size)\n\n{\n\n CSState *s = opaque;\n\n uint32_t saddr, iaddr, ret;\n\n\n\n saddr = addr;\n\n iaddr = ~0U;\n\n\n\n switch (saddr) {\n\n case Index_Address:\n\n ret = s->regs[saddr] & ~0x80;\n\n break;\n\n\n\n case Index_Data:\n\n if (!(s->dregs[MODE_And_ID] & MODE2))\n\n iaddr = s->regs[Index_Address] & 0x0f;\n\n else\n\n iaddr = s->regs[Index_Address] & 0x1f;\n\n\n\n ret = s->dregs[iaddr];\n\n if (iaddr == Error_Status_And_Initialization) {\n\n /* keep SEAL happy */\n\n if (s->aci_counter) {\n\n ret |= 1 << 5;\n\n s->aci_counter -= 1;\n\n }\n\n }\n\n break;\n\n\n\n default:\n\n ret = s->regs[saddr];\n\n break;\n\n }\n\n dolog (\"read %d:%d -> %d\\n\", saddr, iaddr, ret);\n\n return ret;\n\n}\n", + "output": "0", + "index": 15028 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)\n\n{\n\n uint64_t features;\n\n int r;\n\n if (devfd >= 0) {\n\n hdev->control = devfd;\n\n } else {\n\n hdev->control = open(\"/dev/vhost-net\", O_RDWR);\n\n if (hdev->control < 0) {\n\n return -errno;\n\n }\n\n }\n\n r = ioctl(hdev->control, VHOST_SET_OWNER, NULL);\n\n if (r < 0) {\n\n goto fail;\n\n }\n\n\n\n r = ioctl(hdev->control, VHOST_GET_FEATURES, &features);\n\n if (r < 0) {\n\n goto fail;\n\n }\n\n hdev->features = features;\n\n\n\n hdev->client.set_memory = vhost_client_set_memory;\n\n hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;\n\n hdev->client.migration_log = vhost_client_migration_log;\n\n hdev->client.log_start = NULL;\n\n hdev->client.log_stop = NULL;\n\n hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));\n\n hdev->log = NULL;\n\n hdev->log_size = 0;\n\n hdev->log_enabled = false;\n\n hdev->started = false;\n\n cpu_register_phys_memory_client(&hdev->client);\n\n hdev->force = force;\n\n return 0;\n\nfail:\n\n r = -errno;\n\n close(hdev->control);\n\n return r;\n\n}\n", + "output": "1", + "index": 23291 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){\n\n int i;\n\n\n\n memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop?\n\n\n\n /* mpeg1 */\n\n d->mb_incr= s->mb_incr;\n\n for(i=0; i<3; i++)\n\n d->last_dc[i]= s->last_dc[i];\n\n \n\n /* statistics */\n\n d->mv_bits= s->mv_bits;\n\n d->i_tex_bits= s->i_tex_bits;\n\n d->p_tex_bits= s->p_tex_bits;\n\n d->i_count= s->i_count;\n\n d->p_count= s->p_count;\n\n d->skip_count= s->skip_count;\n\n d->misc_bits= s->misc_bits;\n\n d->last_bits= 0;\n\n\n\n d->mb_skiped= s->mb_skiped;\n\n}\n", + "output": "0", + "index": 19439 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_hrfid(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n#else\n\n /* Restore CPU state */\n\n if (unlikely(ctx->pr || !ctx->hv)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n return;\n\n }\n\n gen_helper_hrfid(cpu_env);\n\n gen_sync_exception(ctx);\n\n#endif\n\n}\n", + "output": "1", + "index": 17754 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_slirp_redir(Monitor *mon, const char *redir_str, const char *redir_opt2)\n\n{\n\n struct slirp_config_str *config;\n\n\n\n if (!slirp_inited) {\n\n if (mon) {\n\n monitor_printf(mon, \"user mode network stack not in use\\n\");\n\n } else {\n\n config = qemu_malloc(sizeof(*config));\n\n config->str = redir_str;\n\n config->next = slirp_redirs;\n\n slirp_redirs = config;\n\n }\n\n return;\n\n }\n\n\n\n if (!strcmp(redir_str, \"remove\")) {\n\n net_slirp_redir_rm(mon, redir_opt2);\n\n return;\n\n }\n\n\n\n slirp_redirection(mon, redir_str);\n\n}\n", + "output": "0", + "index": 27275 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Visitor *visitor_input_test_init(TestInputVisitorData *data,\n\n const char *json_string, ...)\n\n{\n\n Visitor *v;\n\n va_list ap;\n\n\n\n va_start(ap, json_string);\n\n data->obj = qobject_from_jsonv(json_string, &ap);\n\n va_end(ap);\n\n\n\n g_assert(data->obj != NULL);\n\n\n\n data->qiv = qmp_input_visitor_new(data->obj);\n\n g_assert(data->qiv != NULL);\n\n\n\n v = qmp_input_get_visitor(data->qiv);\n\n g_assert(v != NULL);\n\n\n\n return v;\n\n}\n", + "output": "1", + "index": 13392 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_sub(DisasContext *dc, TCGv dest, TCGv srca, TCGv srcb)\n\n{\n\n TCGv res = tcg_temp_new();\n\n TCGv sr_cy = tcg_temp_new();\n\n TCGv sr_ov = tcg_temp_new();\n\n\n\n tcg_gen_sub_tl(res, srca, srcb);\n\n tcg_gen_xor_tl(sr_cy, srca, srcb);\n\n tcg_gen_xor_tl(sr_ov, res, srcb);\n\n tcg_gen_and_tl(sr_ov, sr_ov, sr_cy);\n\n tcg_gen_setcond_tl(TCG_COND_LTU, sr_cy, srca, srcb);\n\n\n\n tcg_gen_mov_tl(dest, res);\n\n tcg_temp_free(res);\n\n\n\n tcg_gen_shri_tl(sr_ov, sr_ov, TARGET_LONG_BITS - 1);\n\n tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_cy, ctz32(SR_CY), 1);\n\n tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_ov, ctz32(SR_OV), 1);\n\n\n\n gen_ove_cyov(dc, sr_ov, sr_cy);\n\n tcg_temp_free(sr_ov);\n\n tcg_temp_free(sr_cy);\n\n}\n", + "output": "1", + "index": 8588 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nvdimm_build_ssdt(GSList *device_list, GArray *table_offsets,\n\n GArray *table_data, GArray *linker)\n\n{\n\n Aml *ssdt, *sb_scope, *dev;\n\n\n\n acpi_add_table(table_offsets, table_data);\n\n\n\n ssdt = init_aml_allocator();\n\n acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));\n\n\n\n sb_scope = aml_scope(\"\\\\_SB\");\n\n\n\n dev = aml_device(\"NVDR\");\n\n\n\n /*\n\n * ACPI 6.0: 9.20 NVDIMM Devices:\n\n *\n\n * The ACPI Name Space device uses _HID of ACPI0012 to identify the root\n\n * NVDIMM interface device. Platform firmware is required to contain one\n\n * such device in _SB scope if NVDIMMs support is exposed by platform to\n\n * OSPM.\n\n * For each NVDIMM present or intended to be supported by platform,\n\n * platform firmware also exposes an ACPI Namespace Device under the\n\n * root device.\n\n */\n\n aml_append(dev, aml_name_decl(\"_HID\", aml_string(\"ACPI0012\")));\n\n\n\n nvdimm_build_common_dsm(dev);\n\n nvdimm_build_device_dsm(dev);\n\n\n\n nvdimm_build_nvdimm_devices(device_list, dev);\n\n\n\n aml_append(sb_scope, dev);\n\n\n\n aml_append(ssdt, sb_scope);\n\n /* copy AML table into ACPI tables blob and patch header there */\n\n g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);\n\n build_header(linker, table_data,\n\n (void *)(table_data->data + table_data->len - ssdt->buf->len),\n\n \"SSDT\", ssdt->buf->len, 1, \"NVDIMM\");\n\n free_aml_allocator();\n\n}\n", + "output": "0", + "index": 12700 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "size_t nbd_wr_sync(int fd, void *buffer, size_t size, bool do_read)\n\n{\n\n size_t offset = 0;\n\n\n\n if (qemu_in_coroutine()) {\n\n if (do_read) {\n\n return qemu_co_recv(fd, buffer, size);\n\n } else {\n\n return qemu_co_send(fd, buffer, size);\n\n }\n\n }\n\n\n\n while (offset < size) {\n\n ssize_t len;\n\n\n\n if (do_read) {\n\n len = qemu_recv(fd, buffer + offset, size - offset, 0);\n\n } else {\n\n len = send(fd, buffer + offset, size - offset, 0);\n\n }\n\n\n\n if (len == -1)\n\n errno = socket_error();\n\n\n\n /* recoverable error */\n\n if (len == -1 && (errno == EAGAIN || errno == EINTR)) {\n\n continue;\n\n }\n\n\n\n /* eof */\n\n if (len == 0) {\n\n break;\n\n }\n\n\n\n /* unrecoverable error */\n\n if (len == -1) {\n\n return 0;\n\n }\n\n\n\n offset += len;\n\n }\n\n\n\n return offset;\n\n}\n", + "output": "0", + "index": 9739 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qbus_initfn(Object *obj)\n\n{\n\n BusState *bus = BUS(obj);\n\n\n\n QTAILQ_INIT(&bus->children);\n\n object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY,\n\n TYPE_HOTPLUG_HANDLER,\n\n (Object **)&bus->hotplug_handler, NULL);\n\n object_property_add_bool(obj, \"realized\",\n\n bus_get_realized, bus_set_realized, NULL);\n\n}\n", + "output": "1", + "index": 26522 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool visit_start_union(Visitor *v, bool data_present, Error **errp)\n\n{\n\n if (v->start_union) {\n\n return v->start_union(v, data_present, errp);\n\n }\n\n return true;\n\n}\n", + "output": "1", + "index": 26426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool msi_is_masked(const PCIDevice *dev, unsigned int vector)\n\n{\n\n uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));\n\n uint32_t mask;\n\n assert(vector < PCI_MSI_VECTORS_MAX);\n\n\n\n if (!(flags & PCI_MSI_FLAGS_MASKBIT)) {\n\n return false;\n\n }\n\n\n\n mask = pci_get_long(dev->config +\n\n msi_mask_off(dev, flags & PCI_MSI_FLAGS_64BIT));\n\n return mask & (1U << vector);\n\n}\n", + "output": "0", + "index": 25706 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_coroutine_thread_cleanup(void *opaque)\n\n{\n\n CoroutineThreadState *s = opaque;\n\n Coroutine *co;\n\n Coroutine *tmp;\n\n\n\n QLIST_FOREACH_SAFE(co, &s->pool, pool_next, tmp) {\n\n g_free(DO_UPCAST(CoroutineUContext, base, co)->stack);\n\n g_free(co);\n\n }\n\n g_free(s);\n\n}\n", + "output": "0", + "index": 8960 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline void gen_load_mem (DisasContext *ctx,\n\n void (*tcg_gen_qemu_load)(TCGv t0, TCGv t1, int flags),\n\n int ra, int rb, int32_t disp16,\n\n int fp, int clear)\n\n{\n\n TCGv addr;\n\n\n\n if (unlikely(ra == 31))\n\n return;\n\n\n\n addr = tcg_temp_new(TCG_TYPE_I64);\n\n if (rb != 31) {\n\n tcg_gen_addi_i64(addr, cpu_ir[rb], disp16);\n\n if (clear)\n\n tcg_gen_andi_i64(addr, addr, ~0x7);\n\n } else {\n\n if (clear)\n\n disp16 &= ~0x7;\n\n tcg_gen_movi_i64(addr, disp16);\n\n }\n\n if (fp)\n\n tcg_gen_qemu_load(cpu_fir[ra], addr, ctx->mem_idx);\n\n else\n\n tcg_gen_qemu_load(cpu_ir[ra], addr, ctx->mem_idx);\n\n tcg_temp_free(addr);\n\n}\n", + "output": "0", + "index": 15182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2)\n\n{\n\n /* ??? Assume only ISA and PCI configurations, and that the PCI-ISA\n\n bridge has been setup properly to always register with ISA. */\n\n isa_register_portio_list(dev, iobase, ide_portio_list, bus, \"ide\");\n\n\n\n if (iobase2) {\n\n isa_register_portio_list(dev, iobase2, ide_portio2_list, bus, \"ide\");\n\n }\n\n}\n", + "output": "1", + "index": 6948 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler)\n\n{\n\n CPUDebugExcpHandler *old_handler = debug_excp_handler;\n\n\n\n debug_excp_handler = handler;\n\n return old_handler;\n\n}\n", + "output": "0", + "index": 1711 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void validate_bootdevices(const char *devices)\n\n{\n\n /* We just do some generic consistency checks */\n\n const char *p;\n\n int bitmap = 0;\n\n\n\n for (p = devices; *p != '\\0'; p++) {\n\n /* Allowed boot devices are:\n\n * a-b: floppy disk drives\n\n * c-f: IDE disk drives\n\n * g-m: machine implementation dependent drives\n\n * n-p: network devices\n\n * It's up to each machine implementation to check if the given boot\n\n * devices match the actual hardware implementation and firmware\n\n * features.\n\n */\n\n if (*p < 'a' || *p > 'p') {\n\n fprintf(stderr, \"Invalid boot device '%c'\\n\", *p);\n\n exit(1);\n\n }\n\n if (bitmap & (1 << (*p - 'a'))) {\n\n fprintf(stderr, \"Boot device '%c' was given twice\\n\", *p);\n\n exit(1);\n\n }\n\n bitmap |= 1 << (*p - 'a');\n\n }\n\n}\n", + "output": "0", + "index": 21876 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)\n\n{\n\n uint32_t *hc = (uint32_t*)buf;\n\n struct kvm_ppc_pvinfo pvinfo;\n\n\n\n if (!kvmppc_get_pvinfo(env, &pvinfo)) {\n\n memcpy(buf, pvinfo.hcall, buf_len);\n\n return 0;\n\n }\n\n\n\n /*\n\n * Fallback to always fail hypercalls regardless of endianness:\n\n *\n\n * tdi 0,r0,72 (becomes b .+8 in wrong endian, nop in good endian)\n\n * li r3, -1\n\n * b .+8 (becomes nop in wrong endian)\n\n * bswap32(li r3, -1)\n\n */\n\n\n\n hc[0] = cpu_to_be32(0x08000048);\n\n hc[1] = cpu_to_be32(0x3860ffff);\n\n hc[2] = cpu_to_be32(0x48000008);\n\n hc[3] = cpu_to_be32(bswap32(0x3860ffff));\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 9188 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_rfe(DisasContext *s, TCGv pc, TCGv cpsr)\n\n{\n\n gen_set_cpsr(cpsr, 0xffffffff);\n\n dead_tmp(cpsr);\n\n store_reg(s, 15, pc);\n\n s->is_jmp = DISAS_UPDATE;\n\n}\n", + "output": "1", + "index": 6315 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "long do_sigreturn(CPUSH4State *regs)\n\n{\n\n struct target_sigframe *frame;\n\n abi_ulong frame_addr;\n\n sigset_t blocked;\n\n target_sigset_t target_set;\n\n target_ulong r0;\n\n int i;\n\n int err = 0;\n\n\n\n#if defined(DEBUG_SIGNAL)\n\n fprintf(stderr, \"do_sigreturn\\n\");\n\n#endif\n\n frame_addr = regs->gregs[15];\n\n if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))\n\n \tgoto badframe;\n\n\n\n err |= __get_user(target_set.sig[0], &frame->sc.oldmask);\n\n for(i = 1; i < TARGET_NSIG_WORDS; i++) {\n\n err |= (__get_user(target_set.sig[i], &frame->extramask[i - 1]));\n\n }\n\n\n\n if (err)\n\n goto badframe;\n\n\n\n target_to_host_sigset_internal(&blocked, &target_set);\n\n sigprocmask(SIG_SETMASK, &blocked, NULL);\n\n\n\n if (restore_sigcontext(regs, &frame->sc, &r0))\n\n goto badframe;\n\n\n\n unlock_user_struct(frame, frame_addr, 0);\n\n return r0;\n\n\n\nbadframe:\n\n unlock_user_struct(frame, frame_addr, 0);\n\n force_sig(TARGET_SIGSEGV);\n\n return 0;\n\n}\n", + "output": "0", + "index": 9960 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void matroska_merge_packets(AVPacket *out, AVPacket *in)\n\n{\n\n out->data = av_realloc(out->data, out->size+in->size);\n\n memcpy(out->data+out->size, in->data, in->size);\n\n out->size += in->size;\n\n av_destruct_packet(in);\n\n av_free(in);\n\n}\n", + "output": "1", + "index": 13542 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Visitor *qobject_input_visitor_new_keyval(QObject *obj)\n\n{\n\n QObjectInputVisitor *v = qobject_input_visitor_base_new(obj);\n\n\n\n v->visitor.type_int64 = qobject_input_type_int64_keyval;\n\n v->visitor.type_uint64 = qobject_input_type_uint64_keyval;\n\n v->visitor.type_bool = qobject_input_type_bool_keyval;\n\n v->visitor.type_str = qobject_input_type_str;\n\n v->visitor.type_number = qobject_input_type_number_keyval;\n\n v->visitor.type_any = qobject_input_type_any;\n\n v->visitor.type_null = qobject_input_type_null;\n\n v->visitor.type_size = qobject_input_type_size_keyval;\n\n\n\n return &v->visitor;\n\n}\n", + "output": "1", + "index": 7590 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features)\n\n{\n\n VirtIOBlock *s = to_virtio_blk(vdev);\n\n\n\n features |= (1 << VIRTIO_BLK_F_SEG_MAX);\n\n features |= (1 << VIRTIO_BLK_F_GEOMETRY);\n\n features |= (1 << VIRTIO_BLK_F_TOPOLOGY);\n\n features |= (1 << VIRTIO_BLK_F_BLK_SIZE);\n\n features |= (1 << VIRTIO_BLK_F_SCSI);\n\n\n\n features |= (1 << VIRTIO_BLK_F_CONFIG_WCE);\n\n if (bdrv_enable_write_cache(s->bs))\n\n features |= (1 << VIRTIO_BLK_F_WCE);\n\n\n\n if (bdrv_is_read_only(s->bs))\n\n features |= 1 << VIRTIO_BLK_F_RO;\n\n\n\n return features;\n\n}\n", + "output": "0", + "index": 18105 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t ldq_phys(target_phys_addr_t addr)\n\n{\n\n return ldq_phys_internal(addr, DEVICE_NATIVE_ENDIAN);\n\n}\n", + "output": "0", + "index": 24602 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_cpu_initfn(Object *obj)\n\n{\n\n CPUState *cs = CPU(obj);\n\n S390CPU *cpu = S390_CPU(obj);\n\n CPUS390XState *env = &cpu->env;\n\n static bool inited;\n\n static int cpu_num = 0;\n\n#if !defined(CONFIG_USER_ONLY)\n\n struct tm tm;\n\n#endif\n\n\n\n cs->env_ptr = env;\n\n cpu_exec_init(env);\n\n#if !defined(CONFIG_USER_ONLY)\n\n qemu_register_reset(s390_cpu_machine_reset_cb, cpu);\n\n qemu_get_timedate(&tm, 0);\n\n env->tod_offset = TOD_UNIX_EPOCH +\n\n (time2tod(mktimegm(&tm)) * 1000000000ULL);\n\n env->tod_basetime = 0;\n\n env->tod_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu);\n\n env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);\n\n s390_cpu_set_state(CPU_STATE_STOPPED, cpu);\n\n#endif\n\n env->cpu_num = cpu_num++;\n\n env->ext_index = -1;\n\n\n\n if (tcg_enabled() && !inited) {\n\n inited = true;\n\n s390x_translate_init();\n\n }\n\n}\n", + "output": "0", + "index": 14717 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const char *full_name(QObjectInputVisitor *qiv, const char *name)\n\n{\n\n StackObject *so;\n\n char buf[32];\n\n\n\n if (qiv->errname) {\n\n g_string_truncate(qiv->errname, 0);\n\n } else {\n\n qiv->errname = g_string_new(\"\");\n\n }\n\n\n\n QSLIST_FOREACH(so , &qiv->stack, node) {\n\n if (qobject_type(so->obj) == QTYPE_QDICT) {\n\n g_string_prepend(qiv->errname, name);\n\n g_string_prepend_c(qiv->errname, '.');\n\n } else {\n\n snprintf(buf, sizeof(buf), \"[%u]\", so->index);\n\n g_string_prepend(qiv->errname, buf);\n\n }\n\n name = so->name;\n\n }\n\n\n\n if (name) {\n\n g_string_prepend(qiv->errname, name);\n\n } else if (qiv->errname->str[0] == '.') {\n\n g_string_erase(qiv->errname, 0, 1);\n\n } else {\n\n return \"\";\n\n }\n\n\n\n return qiv->errname->str;\n\n}\n", + "output": "0", + "index": 16638 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,\n\n MemTxAttrs attrs, uint8_t *buf,\n\n int len, hwaddr addr1, hwaddr l,\n\n MemoryRegion *mr)\n\n{\n\n uint8_t *ptr;\n\n uint64_t val;\n\n MemTxResult result = MEMTX_OK;\n\n bool release_lock = false;\n\n\n\n for (;;) {\n\n if (!memory_access_is_direct(mr, false)) {\n\n /* I/O case */\n\n release_lock |= prepare_mmio_access(mr);\n\n l = memory_access_size(mr, l, addr1);\n\n switch (l) {\n\n case 8:\n\n /* 64 bit read access */\n\n result |= memory_region_dispatch_read(mr, addr1, &val, 8,\n\n attrs);\n\n stq_p(buf, val);\n\n break;\n\n case 4:\n\n /* 32 bit read access */\n\n result |= memory_region_dispatch_read(mr, addr1, &val, 4,\n\n attrs);\n\n stl_p(buf, val);\n\n break;\n\n case 2:\n\n /* 16 bit read access */\n\n result |= memory_region_dispatch_read(mr, addr1, &val, 2,\n\n attrs);\n\n stw_p(buf, val);\n\n break;\n\n case 1:\n\n /* 8 bit read access */\n\n result |= memory_region_dispatch_read(mr, addr1, &val, 1,\n\n attrs);\n\n stb_p(buf, val);\n\n break;\n\n default:\n\n abort();\n\n }\n\n } else {\n\n /* RAM case */\n\n ptr = qemu_map_ram_ptr(mr->ram_block, addr1);\n\n memcpy(buf, ptr, l);\n\n }\n\n\n\n if (release_lock) {\n\n qemu_mutex_unlock_iothread();\n\n release_lock = false;\n\n }\n\n\n\n len -= l;\n\n buf += l;\n\n addr += l;\n\n\n\n if (!len) {\n\n break;\n\n }\n\n\n\n l = len;\n\n mr = address_space_translate(as, addr, &addr1, &l, false);\n\n }\n\n\n\n return result;\n\n}\n", + "output": "0", + "index": 14494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mxf_write_multi_descriptor(AVFormatContext *s)\n\n{\n\n MXFContext *mxf = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n const uint8_t *ul;\n\n int i;\n\n\n\n mxf_write_metadata_key(pb, 0x014400);\n\n PRINT_KEY(s, \"multiple descriptor key\", pb->buf_ptr - 16);\n\n klv_encode_ber_length(pb, 64 + 16 * s->nb_streams);\n\n\n\n mxf_write_local_tag(pb, 16, 0x3C0A);\n\n mxf_write_uuid(pb, MultipleDescriptor, 0);\n\n PRINT_KEY(s, \"multi_desc uid\", pb->buf_ptr - 16);\n\n\n\n // write sample rate\n\n mxf_write_local_tag(pb, 8, 0x3001);\n\n avio_wb32(pb, mxf->time_base.den);\n\n avio_wb32(pb, mxf->time_base.num);\n\n\n\n // write essence container ul\n\n mxf_write_local_tag(pb, 16, 0x3004);\n\n if (mxf->essence_container_count > 1)\n\n ul = multiple_desc_ul;\n\n else {\n\n MXFStreamContext *sc = s->streams[0]->priv_data;\n\n ul = mxf_essence_container_uls[sc->index].container_ul;\n\n }\n\n avio_write(pb, ul, 16);\n\n\n\n // write sub descriptor refs\n\n mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);\n\n mxf_write_refs_count(pb, s->nb_streams);\n\n for (i = 0; i < s->nb_streams; i++)\n\n mxf_write_uuid(pb, SubDescriptor, i);\n\n}\n", + "output": "1", + "index": 13674 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool virtqueue_map_desc(VirtIODevice *vdev, unsigned int *p_num_sg,\n\n hwaddr *addr, struct iovec *iov,\n\n unsigned int max_num_sg, bool is_write,\n\n hwaddr pa, size_t sz)\n\n{\n\n bool ok = false;\n\n unsigned num_sg = *p_num_sg;\n\n assert(num_sg <= max_num_sg);\n\n\n\n if (!sz) {\n\n virtio_error(vdev, \"virtio: zero sized buffers are not allowed\");\n\n goto out;\n\n }\n\n\n\n while (sz) {\n\n hwaddr len = sz;\n\n\n\n if (num_sg == max_num_sg) {\n\n virtio_error(vdev, \"virtio: too many write descriptors in \"\n\n \"indirect table\");\n\n goto out;\n\n }\n\n\n\n iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);\n\n if (!iov[num_sg].iov_base) {\n\n virtio_error(vdev, \"virtio: bogus descriptor or out of resources\");\n\n goto out;\n\n }\n\n\n\n iov[num_sg].iov_len = len;\n\n addr[num_sg] = pa;\n\n\n\n sz -= len;\n\n pa += len;\n\n num_sg++;\n\n }\n\n ok = true;\n\n\n\nout:\n\n *p_num_sg = num_sg;\n\n return ok;\n\n}\n", + "output": "0", + "index": 13597 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mace3_decode_frame(AVCodecContext *avctx,\n\n void *data, int *data_size,\n\n const uint8_t *buf, int buf_size)\n\n{\n\n int16_t *samples = data;\n\n MACEContext *ctx = avctx->priv_data;\n\n int i, j, k;\n\n\n\n for(i = 0; i < avctx->channels; i++) {\n\n int16_t *output = samples + i;\n\n\n\n for (j=0; j < buf_size / 2 / avctx->channels; j++)\n\n for (k=0; k < 2; k++) {\n\n uint8_t pkt = buf[i*2 + j*2*avctx->channels + k];\n\n chomp3(&ctx->chd[i], output, pkt &7, MACEtab1, MACEtab2,\n\n 8, avctx->channels);\n\n output += avctx->channels;\n\n chomp3(&ctx->chd[i], output,(pkt >> 3) &3, MACEtab3, MACEtab4,\n\n 4, avctx->channels);\n\n output += avctx->channels;\n\n chomp3(&ctx->chd[i], output, pkt >> 5 , MACEtab1, MACEtab2,\n\n 8, avctx->channels);\n\n output += avctx->channels;\n\n }\n\n }\n\n\n\n *data_size = 2 * 3 * buf_size;\n\n\n\n return buf_size;\n\n}\n", + "output": "1", + "index": 5598 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void sws_rgb2rgb_init(int flags){\n\n#if (defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)) && defined(CONFIG_GPL)\n\n\tif(flags & SWS_CPU_CAPS_MMX2)\n\n\t\trgb2rgb_init_MMX2();\n\n\telse if(flags & SWS_CPU_CAPS_3DNOW)\n\n\t\trgb2rgb_init_3DNOW();\n\n\telse if(flags & SWS_CPU_CAPS_MMX)\n\n\t\trgb2rgb_init_MMX();\n\n\telse\n\n#endif /* defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX) */\n\n\t\trgb2rgb_init_C();\n\n}\n", + "output": "1", + "index": 11876 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qapi_dealloc_end_list(Visitor *v)\n\n{\n\n QapiDeallocVisitor *qov = to_qov(v);\n\n void *obj = qapi_dealloc_pop(qov);\n\n assert(obj == NULL); /* should've been list head tracker with no payload */\n\n}\n", + "output": "0", + "index": 3744 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_insn_3405(TCGContext *s, AArch64Insn insn, TCGType ext,\n\n TCGReg rd, uint16_t half, unsigned shift)\n\n{\n\n assert((shift & ~0x30) == 0);\n\n tcg_out32(s, insn | ext << 31 | shift << (21 - 4) | half << 5 | rd);\n\n}\n", + "output": "0", + "index": 7560 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static abi_long do_getpeername(int fd, abi_ulong target_addr,\n\n abi_ulong target_addrlen_addr)\n\n{\n\n socklen_t addrlen;\n\n void *addr;\n\n abi_long ret;\n\n\n\n if (get_user_u32(addrlen, target_addrlen_addr))\n\n return -TARGET_EFAULT;\n\n\n\n if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)\n\n return -TARGET_EINVAL;\n\n\n\n addr = alloca(addrlen);\n\n\n\n ret = get_errno(getpeername(fd, addr, &addrlen));\n\n if (!is_error(ret)) {\n\n host_to_target_sockaddr(target_addr, addr, addrlen);\n\n if (put_user_u32(addrlen, target_addrlen_addr))\n\n ret = -TARGET_EFAULT;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 7378 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_tx_pkt_setup_vlan_header(struct NetTxPkt *pkt, uint16_t vlan)\n\n{\n\n bool is_new;\n\n assert(pkt);\n\n\n\n eth_setup_vlan_headers(pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_base,\n\n vlan, &is_new);\n\n\n\n /* update l2hdrlen */\n\n if (is_new) {\n\n pkt->hdr_len += sizeof(struct vlan_header);\n\n pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len +=\n\n sizeof(struct vlan_header);\n\n }\n\n}\n", + "output": "0", + "index": 15489 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_write_decr (DisasContext *ctx, int sprn, int gprn)\n\n{\n\n if (use_icount) {\n\n gen_io_start();\n\n }\n\n gen_helper_store_decr(cpu_env, cpu_gpr[gprn]);\n\n if (use_icount) {\n\n gen_io_end();\n\n gen_stop_exception(ctx);\n\n }\n\n}\n", + "output": "0", + "index": 14113 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline void gen_cmov (TCGCond inv_cond,\n\n int ra, int rb, int rc,\n\n int islit, uint8_t lit, int mask)\n\n{\n\n int l1;\n\n\n\n if (unlikely(rc == 31))\n\n return;\n\n\n\n l1 = gen_new_label();\n\n\n\n if (ra != 31) {\n\n if (mask) {\n\n TCGv tmp = tcg_temp_new(TCG_TYPE_I64);\n\n tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);\n\n tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1);\n\n tcg_temp_free(tmp);\n\n } else\n\n tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, l1);\n\n } else {\n\n /* Very uncommon case - Do not bother to optimize. */\n\n TCGv tmp = tcg_const_i64(0);\n\n tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1);\n\n tcg_temp_free(tmp);\n\n }\n\n\n\n if (islit)\n\n tcg_gen_movi_i64(cpu_ir[rc], lit);\n\n else\n\n tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);\n\n gen_set_label(l1);\n\n}\n", + "output": "0", + "index": 16823 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_drain_recurse(BlockDriverState *bs, bool begin)\n\n{\n\n BdrvChild *child, *tmp;\n\n bool waited;\n\n\n\n /* Ensure any pending metadata writes are submitted to bs->file. */\n\n bdrv_drain_invoke(bs, begin);\n\n\n\n /* Wait for drained requests to finish */\n\n waited = BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0);\n\n\n\n QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {\n\n BlockDriverState *bs = child->bs;\n\n bool in_main_loop =\n\n qemu_get_current_aio_context() == qemu_get_aio_context();\n\n assert(bs->refcnt > 0);\n\n if (in_main_loop) {\n\n /* In case the recursive bdrv_drain_recurse processes a\n\n * block_job_defer_to_main_loop BH and modifies the graph,\n\n * let's hold a reference to bs until we are done.\n\n *\n\n * IOThread doesn't have such a BH, and it is not safe to call\n\n * bdrv_unref without BQL, so skip doing it there.\n\n */\n\n bdrv_ref(bs);\n\n }\n\n waited |= bdrv_drain_recurse(bs, begin);\n\n if (in_main_loop) {\n\n bdrv_unref(bs);\n\n }\n\n }\n\n\n\n return waited;\n\n}\n", + "output": "1", + "index": 396 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_acl_reset(qemu_acl *acl)\n\n{\n\n qemu_acl_entry *entry;\n\n\n\n /* Put back to deny by default, so there is no window\n\n * of \"open access\" while the user re-initializes the\n\n * access control list */\n\n acl->defaultDeny = 1;\n\n TAILQ_FOREACH(entry, &acl->entries, next) {\n\n TAILQ_REMOVE(&acl->entries, entry, next);\n\n free(entry->match);\n\n free(entry);\n\n }\n\n acl->nentries = 0;\n\n}\n", + "output": "0", + "index": 9684 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void timer_mod_ns(QEMUTimer *ts, int64_t expire_time)\n\n{\n\n QEMUTimerList *timer_list = ts->timer_list;\n\n bool rearm;\n\n\n\n qemu_mutex_lock(&timer_list->active_timers_lock);\n\n timer_del_locked(timer_list, ts);\n\n rearm = timer_mod_ns_locked(timer_list, ts, expire_time);\n\n qemu_mutex_unlock(&timer_list->active_timers_lock);\n\n\n\n if (rearm) {\n\n timerlist_rearm(timer_list);\n\n }\n\n}\n", + "output": "0", + "index": 15478 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))\n\n{\n\n unsigned int i;\n\n\n\n for (i = 0; i < TRACE_BUF_LEN; i++) {\n\n TraceRecord record;\n\n\n\n if (!get_trace_record(i, &record)) {\n\n continue;\n\n }\n\n stream_printf(stream, \"Event %\" PRIu64 \" : %\" PRIx64 \" %\" PRIx64\n\n \" %\" PRIx64 \" %\" PRIx64 \" %\" PRIx64 \" %\" PRIx64 \"\\n\",\n\n record.event, record.x1, record.x2,\n\n record.x3, record.x4, record.x5,\n\n record.x6);\n\n }\n\n}\n", + "output": "1", + "index": 4531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void run_dependent_requests(QCowL2Meta *m)\n\n{\n\n QCowAIOCB *req;\n\n QCowAIOCB *next;\n\n\n\n /* Take the request off the list of running requests */\n\n if (m->nb_clusters != 0) {\n\n LIST_REMOVE(m, next_in_flight);\n\n }\n\n\n\n /*\n\n * Restart all dependent requests.\n\n * Can't use LIST_FOREACH here - the next link might not be the same\n\n * any more after the callback (request could depend on a different\n\n * request now)\n\n */\n\n for (req = m->dependent_requests.lh_first; req != NULL; req = next) {\n\n next = req->next_depend.le_next;\n\n qcow_aio_write_cb(req, 0);\n\n }\n\n\n\n /* Empty the list for the next part of the request */\n\n LIST_INIT(&m->dependent_requests);\n\n}\n", + "output": "0", + "index": 19114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp)\n\n{\n\n int ret;\n\n\n\n vdev->msix->pending = g_malloc0(BITS_TO_LONGS(vdev->msix->entries) *\n\n sizeof(unsigned long));\n\n ret = msix_init(&vdev->pdev, vdev->msix->entries,\n\n vdev->bars[vdev->msix->table_bar].region.mem,\n\n vdev->msix->table_bar, vdev->msix->table_offset,\n\n vdev->bars[vdev->msix->pba_bar].region.mem,\n\n vdev->msix->pba_bar, vdev->msix->pba_offset, pos);\n\n if (ret < 0) {\n\n if (ret == -ENOTSUP) {\n\n return 0;\n\n }\n\n error_setg(errp, \"msix_init failed\");\n\n return ret;\n\n }\n\n\n\n /*\n\n * The PCI spec suggests that devices provide additional alignment for\n\n * MSI-X structures and avoid overlapping non-MSI-X related registers.\n\n * For an assigned device, this hopefully means that emulation of MSI-X\n\n * structures does not affect the performance of the device. If devices\n\n * fail to provide that alignment, a significant performance penalty may\n\n * result, for instance Mellanox MT27500 VFs:\n\n * http://www.spinics.net/lists/kvm/msg125881.html\n\n *\n\n * The PBA is simply not that important for such a serious regression and\n\n * most drivers do not appear to look at it. The solution for this is to\n\n * disable the PBA MemoryRegion unless it's being used. We disable it\n\n * here and only enable it if a masked vector fires through QEMU. As the\n\n * vector-use notifier is called, which occurs on unmask, we test whether\n\n * PBA emulation is needed and again disable if not.\n\n */\n\n memory_region_set_enabled(&vdev->pdev.msix_pba_mmio, false);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 5418 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t watch_mem_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_READ);\n\n switch (size) {\n\n case 1: return ldub_phys(addr);\n\n case 2: return lduw_phys(addr);\n\n case 4: return ldl_phys(addr);\n\n default: abort();\n\n }\n\n}\n", + "output": "0", + "index": 10955 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vcard_emul_replay_insertion_events(void)\n{\n VReaderListEntry *current_entry;\n VReaderListEntry *next_entry = NULL;\n VReaderList *list = vreader_get_reader_list();\n for (current_entry = vreader_list_get_first(list); current_entry;\n current_entry = next_entry) {\n VReader *vreader = vreader_list_get_reader(current_entry);\n next_entry = vreader_list_get_next(current_entry);\n vreader_queue_card_event(vreader);\n }\n}", + "output": "1", + "index": 11888 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void RENAME(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0,\n\n const uint16_t *buf1, const uint16_t *ubuf0,\n\n const uint16_t *ubuf1, const uint16_t *vbuf0,\n\n const uint16_t *vbuf1, const uint16_t *abuf0,\n\n const uint16_t *abuf1, uint8_t *dest,\n\n int dstW, int yalpha, int uvalpha, int y)\n\n{\n\n //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(\n\n __asm__ volatile(\n\n \"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\n \"mov %4, %%\"REG_b\" \\n\\t\"\n\n \"push %%\"REG_BP\" \\n\\t\"\n\n YSCALEYUV2RGB(%%REGBP, %5)\n\n \"pxor %%mm7, %%mm7 \\n\\t\"\n\n WRITEBGR24(%%REGb, 8280(%5), %%REGBP)\n\n \"pop %%\"REG_BP\" \\n\\t\"\n\n \"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n\n :: \"c\" (buf0), \"d\" (buf1), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\n \"a\" (&c->redDither)\n\n );\n\n}\n", + "output": "0", + "index": 12629 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_rdma_init_one_block(void *host_addr,\n\n ram_addr_t block_offset, ram_addr_t length, void *opaque)\n\n{\n\n rdma_add_block(opaque, host_addr, block_offset, length);\n\n}\n", + "output": "0", + "index": 26402 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int available_samples(AVFrame *out)\n\n{\n\n int bytes_per_sample = av_get_bytes_per_sample(out->format);\n\n int samples = out->linesize[0] / bytes_per_sample;\n\n\n\n if (av_sample_fmt_is_planar(out->format)) {\n\n return samples;\n\n } else {\n\n int channels = av_get_channel_layout_nb_channels(out->channel_layout);\n\n return samples / channels;\n\n }\n\n}\n", + "output": "1", + "index": 19784 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,\n\n unsigned int index, unsigned int n, bool flush)\n\n{\n\n unsigned int sector_mask = BDRV_SECTOR_SIZE / sizeof(uint64_t) - 1;\n\n unsigned int start, end, i;\n\n QEDTable *new_table;\n\n struct iovec iov;\n\n QEMUIOVector qiov;\n\n size_t len_bytes;\n\n int ret;\n\n\n\n trace_qed_write_table(s, offset, table, index, n);\n\n\n\n /* Calculate indices of the first and one after last elements */\n\n start = index & ~sector_mask;\n\n end = (index + n + sector_mask) & ~sector_mask;\n\n\n\n len_bytes = (end - start) * sizeof(uint64_t);\n\n\n\n new_table = qemu_blockalign(s->bs, len_bytes);\n\n iov = (struct iovec) {\n\n .iov_base = new_table->offsets,\n\n .iov_len = len_bytes,\n\n };\n\n qemu_iovec_init_external(&qiov, &iov, 1);\n\n\n\n /* Byteswap table */\n\n for (i = start; i < end; i++) {\n\n uint64_t le_offset = cpu_to_le64(table->offsets[i]);\n\n new_table->offsets[i - start] = le_offset;\n\n }\n\n\n\n /* Adjust for offset into table */\n\n offset += start * sizeof(uint64_t);\n\n\n\n ret = bdrv_pwritev(s->bs->file, offset, &qiov);\n\n trace_qed_write_table_cb(s, table, flush, ret);\n\n if (ret < 0) {\n\n goto out;\n\n }\n\n\n\n if (flush) {\n\n qed_acquire(s);\n\n ret = bdrv_flush(s->bs);\n\n qed_release(s);\n\n if (ret < 0) {\n\n goto out;\n\n }\n\n }\n\n\n\n ret = 0;\n\nout:\n\n qemu_vfree(new_table);\n\n return ret;\n\n}\n", + "output": "0", + "index": 4606 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_put_xsave(CPUState *env)\n\n{\n\n#ifdef KVM_CAP_XSAVE\n\n int i;\n\n struct kvm_xsave* xsave;\n\n uint16_t cwd, swd, twd, fop;\n\n\n\n if (!kvm_has_xsave())\n\n return kvm_put_fpu(env);\n\n\n\n xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));\n\n memset(xsave, 0, sizeof(struct kvm_xsave));\n\n cwd = swd = twd = fop = 0;\n\n swd = env->fpus & ~(7 << 11);\n\n swd |= (env->fpstt & 7) << 11;\n\n cwd = env->fpuc;\n\n for (i = 0; i < 8; ++i)\n\n twd |= (!env->fptags[i]) << i;\n\n xsave->region[0] = (uint32_t)(swd << 16) + cwd;\n\n xsave->region[1] = (uint32_t)(fop << 16) + twd;\n\n memcpy(&xsave->region[XSAVE_ST_SPACE], env->fpregs,\n\n sizeof env->fpregs);\n\n memcpy(&xsave->region[XSAVE_XMM_SPACE], env->xmm_regs,\n\n sizeof env->xmm_regs);\n\n xsave->region[XSAVE_MXCSR] = env->mxcsr;\n\n *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV] = env->xstate_bv;\n\n memcpy(&xsave->region[XSAVE_YMMH_SPACE], env->ymmh_regs,\n\n sizeof env->ymmh_regs);\n\n return kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);\n\n#else\n\n return kvm_put_fpu(env);\n\n#endif\n\n}\n", + "output": "1", + "index": 2687 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_parse_context(OptionParseContext *octx,\n\n const OptionGroupDef *groups)\n\n{\n\n static const OptionGroupDef global_group = { \"global\" };\n\n const OptionGroupDef *g = groups;\n\n int i;\n\n\n\n memset(octx, 0, sizeof(*octx));\n\n\n\n while (g->name)\n\n g++;\n\n octx->nb_groups = g - groups;\n\n octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups);\n\n if (!octx->groups)\n\n exit(1);\n\n\n\n for (i = 0; i < octx->nb_groups; i++)\n\n octx->groups[i].group_def = &groups[i];\n\n\n\n octx->global_opts.group_def = &global_group;\n\n octx->global_opts.arg = \"\";\n\n\n\n init_opts();\n\n}\n", + "output": "0", + "index": 18094 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,\n\n InputEvent *evt)\n\n{\n\n KBDState *s = (KBDState *)dev;\n\n int qcode, keycode;\n\n\n\n qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key);\n\n if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) {\n\n return;\n\n }\n\n keycode = qcode_to_adb_keycode[qcode];\n\n\n\n if (evt->u.key.data->down == false) { /* if key release event */\n\n keycode = keycode | 0x80; /* create keyboard break code */\n\n }\n\n\n\n adb_kbd_put_keycode(s, keycode);\n\n}\n", + "output": "0", + "index": 18679 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mirror_cow_align(MirrorBlockJob *s, int64_t *offset,\n\n uint64_t *bytes)\n\n{\n\n bool need_cow;\n\n int ret = 0;\n\n int64_t align_offset = *offset;\n\n unsigned int align_bytes = *bytes;\n\n int max_bytes = s->granularity * s->max_iov;\n\n\n\n assert(*bytes < INT_MAX);\n\n need_cow = !test_bit(*offset / s->granularity, s->cow_bitmap);\n\n need_cow |= !test_bit((*offset + *bytes - 1) / s->granularity,\n\n s->cow_bitmap);\n\n if (need_cow) {\n\n bdrv_round_to_clusters(blk_bs(s->target), *offset, *bytes,\n\n &align_offset, &align_bytes);\n\n }\n\n\n\n if (align_bytes > max_bytes) {\n\n align_bytes = max_bytes;\n\n if (need_cow) {\n\n align_bytes = QEMU_ALIGN_DOWN(align_bytes, s->target_cluster_size);\n\n }\n\n }\n\n /* Clipping may result in align_bytes unaligned to chunk boundary, but\n\n * that doesn't matter because it's already the end of source image. */\n\n align_bytes = mirror_clip_bytes(s, align_offset, align_bytes);\n\n\n\n ret = align_offset + align_bytes - (*offset + *bytes);\n\n *offset = align_offset;\n\n *bytes = align_bytes;\n\n assert(ret >= 0);\n\n return ret;\n\n}\n", + "output": "1", + "index": 24016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openpic_load_IRQ_queue(QEMUFile* f, IRQQueue *q)\n\n{\n\n unsigned int i;\n\n\n\n for (i = 0; i < BF_WIDTH(MAX_IRQ); i++)\n\n qemu_get_be32s(f, &q->queue[i]);\n\n\n\n qemu_get_sbe32s(f, &q->next);\n\n qemu_get_sbe32s(f, &q->priority);\n\n}\n", + "output": "0", + "index": 882 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_tx_pkt_update_ip_checksums(struct NetTxPkt *pkt)\n\n{\n\n uint16_t csum;\n\n uint32_t ph_raw_csum;\n\n assert(pkt);\n\n uint8_t gso_type = pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN;\n\n struct ip_header *ip_hdr;\n\n\n\n if (VIRTIO_NET_HDR_GSO_TCPV4 != gso_type &&\n\n VIRTIO_NET_HDR_GSO_UDP != gso_type) {\n\n return;\n\n }\n\n\n\n ip_hdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;\n\n\n\n if (pkt->payload_len + pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len >\n\n ETH_MAX_IP_DGRAM_LEN) {\n\n return;\n\n }\n\n\n\n ip_hdr->ip_len = cpu_to_be16(pkt->payload_len +\n\n pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len);\n\n\n\n /* Calculate IP header checksum */\n\n ip_hdr->ip_sum = 0;\n\n csum = net_raw_checksum((uint8_t *)ip_hdr,\n\n pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len);\n\n ip_hdr->ip_sum = cpu_to_be16(csum);\n\n\n\n /* Calculate IP pseudo header checksum */\n\n ph_raw_csum = eth_calc_pseudo_hdr_csum(ip_hdr, pkt->payload_len);\n\n csum = cpu_to_be16(~net_checksum_finish(ph_raw_csum));\n\n iov_from_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags,\n\n pkt->virt_hdr.csum_offset, &csum, sizeof(csum));\n\n}\n", + "output": "0", + "index": 3662 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)\n\n{\n\n int ret = 0;\n\n\n\n s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT);\n\n if (!s->fdsp)\n\n return AVERROR(ENOMEM);\n\n\n\n // window init\n\n ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);\n\n ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);\n\n ff_init_ff_sine_windows(10);\n\n ff_init_ff_sine_windows(7);\n\n\n\n if (ret = ff_mdct_init(&s->mdct1024, 11, 0, 32768.0))\n\n return ret;\n\n if (ret = ff_mdct_init(&s->mdct128, 8, 0, 32768.0))\n\n return ret;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8369 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_init_drive(IDEState *s, DriveInfo *dinfo,\n\n const char *version, const char *serial)\n\n{\n\n int cylinders, heads, secs;\n\n uint64_t nb_sectors;\n\n\n\n s->bs = dinfo->bdrv;\n\n bdrv_get_geometry(s->bs, &nb_sectors);\n\n bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs);\n\n s->cylinders = cylinders;\n\n s->heads = heads;\n\n s->sectors = secs;\n\n s->nb_sectors = nb_sectors;\n\n /* The SMART values should be preserved across power cycles\n\n but they aren't. */\n\n s->smart_enabled = 1;\n\n s->smart_autosave = 1;\n\n s->smart_errors = 0;\n\n s->smart_selftest_count = 0;\n\n if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {\n\n s->is_cdrom = 1;\n\n bdrv_set_change_cb(s->bs, cdrom_change_cb, s);\n\n }\n\n if (serial && *serial) {\n\n strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));\n\n } else {\n\n snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),\n\n \"QM%05d\", s->drive_serial);\n\n }\n\n if (version) {\n\n pstrcpy(s->version, sizeof(s->version), version);\n\n } else {\n\n pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);\n\n }\n\n ide_reset(s);\n\n}\n", + "output": "0", + "index": 16393 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,\n\n void *opaque)\n\n{\n\n const VMStateSubsection *sub = vmsd->subsections;\n\n\n\n while (sub && sub->needed) {\n\n if (sub->needed(opaque)) {\n\n const VMStateDescription *vmsd = sub->vmsd;\n\n uint8_t len;\n\n\n\n qemu_put_byte(f, QEMU_VM_SUBSECTION);\n\n len = strlen(vmsd->name);\n\n qemu_put_byte(f, len);\n\n qemu_put_buffer(f, (uint8_t *)vmsd->name, len);\n\n qemu_put_be32(f, vmsd->version_id);\n\n assert(!vmsd->subsections);\n\n vmstate_save_state(f, vmsd, opaque);\n\n }\n\n sub++;\n\n }\n\n}\n", + "output": "1", + "index": 5768 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ISADevice *isa_create(const char *name)\n\n{\n\n DeviceState *dev;\n\n\n\n if (!isabus) {\n\n fprintf(stderr, \"Tried to create isa device %s with no isa bus present.\\n\", name);\n\n return NULL;\n\n }\n\n dev = qdev_create(&isabus->qbus, name);\n\n return DO_UPCAST(ISADevice, qdev, dev);\n\n}\n", + "output": "1", + "index": 3411 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void posix_aio_read(void *opaque)\n\n{\n\n PosixAioState *s = opaque;\n\n ssize_t len;\n\n\n\n /* read all bytes from signal pipe */\n\n for (;;) {\n\n char bytes[16];\n\n\n\n len = read(s->rfd, bytes, sizeof(bytes));\n\n if (len == -1 && errno == EINTR)\n\n continue; /* try again */\n\n if (len == sizeof(bytes))\n\n continue; /* more to read */\n\n break;\n\n }\n\n\n\n posix_aio_process_queue(s);\n\n}\n", + "output": "1", + "index": 14256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n RTSPState *rt = s->priv_data;\n\n int ret, len;\n\n uint8_t buf[10 * RTP_MAX_PACKET_LENGTH];\n\n RTSPStream *rtsp_st;\n\n\n\n /* get next frames from the same RTP packet */\n\n if (rt->cur_transport_priv) {\n\n if (rt->transport == RTSP_TRANSPORT_RDT)\n\n ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);\n\n else\n\n ret = rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);\n\n if (ret == 0) {\n\n rt->cur_transport_priv = NULL;\n\n return 0;\n\n } else if (ret == 1) {\n\n return 0;\n\n } else {\n\n rt->cur_transport_priv = NULL;\n\n }\n\n }\n\n\n\n /* read next RTP packet */\n\n redo:\n\n switch(rt->lower_transport) {\n\n default:\n\n#if CONFIG_RTSP_DEMUXER\n\n case RTSP_LOWER_TRANSPORT_TCP:\n\n len = tcp_read_packet(s, &rtsp_st, buf, sizeof(buf));\n\n break;\n\n#endif\n\n case RTSP_LOWER_TRANSPORT_UDP:\n\n case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:\n\n len = udp_read_packet(s, &rtsp_st, buf, sizeof(buf));\n\n if (len >=0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)\n\n rtp_check_and_send_back_rr(rtsp_st->transport_priv, len);\n\n break;\n\n }\n\n if (len < 0)\n\n return len;\n\n if (len == 0)\n\n return AVERROR_EOF;\n\n if (rt->transport == RTSP_TRANSPORT_RDT)\n\n ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, buf, len);\n\n else\n\n ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, buf, len);\n\n if (ret < 0)\n\n goto redo;\n\n if (ret == 1) {\n\n /* more packets may follow, so we save the RTP context */\n\n rt->cur_transport_priv = rtsp_st->transport_priv;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 3637 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int analyze(const uint8_t *buf, int size, int packet_size, int *index)\n\n{\n\n int stat[TS_MAX_PACKET_SIZE];\n\n int i;\n\n int x = 0;\n\n int best_score = 0;\n\n\n\n memset(stat, 0, packet_size * sizeof(int));\n\n\n\n for (x = i = 0; i < size - 3; i++) {\n\n if (buf[i] == 0x47 && !(buf[i + 1] & 0x80) && (buf[i + 3] & 0x30)) {\n\n stat[x]++;\n\n if (stat[x] > best_score) {\n\n best_score = stat[x];\n\n if (index)\n\n *index = x;\n\n }\n\n }\n\n\n\n x++;\n\n if (x == packet_size)\n\n x = 0;\n\n }\n\n\n\n return best_score;\n\n}\n", + "output": "1", + "index": 21051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int expand_rle_row16(SgiState *s, uint16_t *out_buf,\n\n int len, int pixelstride)\n\n{\n\n unsigned short pixel;\n\n unsigned char count;\n\n unsigned short *orig = out_buf;\n\n uint16_t *out_end = out_buf + len;\n\n\n\n while (out_buf < out_end) {\n\n if (bytestream2_get_bytes_left(&s->g) < 2)\n\n return AVERROR_INVALIDDATA;\n\n pixel = bytestream2_get_be16u(&s->g);\n\n if (!(count = (pixel & 0x7f)))\n\n break;\n\n\n\n /* Check for buffer overflow. */\n\n if (pixelstride * (count - 1) >= len) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"Invalid pixel count.\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n if (pixel & 0x80) {\n\n while (count--) {\n\n pixel = bytestream2_get_ne16(&s->g);\n\n AV_WN16A(out_buf, pixel);\n\n out_buf += pixelstride;\n\n }\n\n } else {\n\n pixel = bytestream2_get_ne16(&s->g);\n\n\n\n while (count--) {\n\n AV_WN16A(out_buf, pixel);\n\n out_buf += pixelstride;\n\n }\n\n }\n\n }\n\n return (out_buf - orig) / pixelstride;\n\n}\n", + "output": "0", + "index": 192 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int png_write_row(PNGContext *s, const uint8_t *data, int size)\n\n{\n\n int ret;\n\n\n\n s->zstream.avail_in = size;\n\n s->zstream.next_in = (uint8_t *)data;\n\n while (s->zstream.avail_in > 0) {\n\n ret = deflate(&s->zstream, Z_NO_FLUSH);\n\n if (ret != Z_OK)\n\n return -1;\n\n if (s->zstream.avail_out == 0) {\n\n png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE);\n\n s->zstream.avail_out = IOBUF_SIZE;\n\n s->zstream.next_out = s->buf;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 26981 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n\n{\n\n uint32_t count;\n\n uint32_t i;\n\n\n\n if (atom.size < 8)\n\n return 0;\n\n\n\n avio_skip(pb, 4);\n\n count = avio_rb32(pb);\n\n if (count > UINT_MAX / sizeof(*c->meta_keys)) {\n\n av_log(c->fc, AV_LOG_ERROR,\n\n \"The 'keys' atom with the invalid key count: %d\\n\", count);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n c->meta_keys_count = count + 1;\n\n c->meta_keys = av_mallocz(c->meta_keys_count * sizeof(*c->meta_keys));\n\n if (!c->meta_keys)\n\n return AVERROR(ENOMEM);\n\n\n\n for (i = 1; i <= count; ++i) {\n\n uint32_t key_size = avio_rb32(pb);\n\n uint32_t type = avio_rl32(pb);\n\n if (key_size < 8) {\n\n av_log(c->fc, AV_LOG_ERROR,\n\n \"The key# %d in meta has invalid size: %d\\n\", i, key_size);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n key_size -= 8;\n\n if (type != MKTAG('m','d','t','a')) {\n\n avio_skip(pb, key_size);\n\n }\n\n c->meta_keys[i] = av_mallocz(key_size + 1);\n\n if (!c->meta_keys[i])\n\n return AVERROR(ENOMEM);\n\n avio_read(pb, c->meta_keys[i], key_size);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 9288 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t size)\n\n{\n\n NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);\n\n uint32_t len;\n\n len = htonl(size);\n\n\n\n send_all(s->fd, (const uint8_t *)&len, sizeof(len));\n\n return send_all(s->fd, buf, size);\n\n}\n", + "output": "0", + "index": 23418 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static AVInputFormat *probe_input_format(AVProbeData *pd, int is_opened)\n\n{\n\n AVInputFormat *fmt1, *fmt;\n\n int score, score_max;\n\n\n\n fmt = NULL;\n\n score_max = 0;\n\n for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) {\n\n if (!is_opened && !(fmt1->flags & AVFMT_NOFILE))\n\n continue;\n\n score = 0;\n\n if (fmt1->extensions) {\n\n if (match_ext(pd->filename, fmt1->extensions)) {\n\n score = 50;\n\n }\n\n } else if (fmt1->read_probe) {\n\n score = fmt1->read_probe(pd);\n\n }\n\n if (score > score_max) {\n\n score_max = score;\n\n fmt = fmt1;\n\n }\n\n }\n\n return fmt;\n\n}\n", + "output": "0", + "index": 668 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,\n\n uint64_t start, uint64_t count,\n\n bool finish)\n\n{\n\n hbitmap_deserialize_zeroes(bitmap->bitmap, start, count, finish);\n\n}\n", + "output": "0", + "index": 20239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *scan,\n const uint32_t *quant) {\n int coeff, i, n;\n int8_t ac;\n uint8_t dc = get_bits(gb, 8);\n // block not coded\n if (dc == 255)\n // number of non-zero coefficients\n coeff = get_bits(gb, 6);\n // normally we would only need to clear the (63 - coeff) last values,\n // but since we do not know where they are we just clear the whole block\n memset(block, 0, 64 * sizeof(DCTELEM));\n // 2 bits per coefficient\n while (coeff) {\n ac = get_sbits(gb, 2);\n if (ac == -2)\n break; // continue with more bits\n PUT_COEFF(ac);\n }\n // 4 bits per coefficient\n ALIGN(4);\n if (get_bits_count(gb) + (coeff << 2) >= gb->size_in_bits)\n while (coeff) {\n ac = get_sbits(gb, 4);\n if (ac == -8)\n break; // continue with more bits\n PUT_COEFF(ac);\n }\n // 8 bits per coefficient\n ALIGN(8);\n if (get_bits_count(gb) + (coeff << 3) >= gb->size_in_bits)\n while (coeff) {\n ac = get_sbits(gb, 8);\n PUT_COEFF(ac);\n }\n PUT_COEFF(dc);\n return 1;\n}", + "output": "1", + "index": 12249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,\n\n int64_t pos)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n int64_t total_sectors = bs->total_sectors;\n\n bool zero_beyond_eof = bs->zero_beyond_eof;\n\n int ret;\n\n\n\n BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);\n\n bs->zero_beyond_eof = false;\n\n ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);\n\n bs->zero_beyond_eof = zero_beyond_eof;\n\n\n\n /* bdrv_co_do_writev will have increased the total_sectors value to include\n\n * the VM state - the VM state is however not an actual part of the block\n\n * device, therefore, we need to restore the old value. */\n\n bs->total_sectors = total_sectors;\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 4192 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct omap_dss_s *omap_dss_init(struct omap_target_agent_s *ta,\n\n MemoryRegion *sysmem,\n\n hwaddr l3_base,\n\n qemu_irq irq, qemu_irq drq,\n\n omap_clk fck1, omap_clk fck2, omap_clk ck54m,\n\n omap_clk ick1, omap_clk ick2)\n\n{\n\n struct omap_dss_s *s = (struct omap_dss_s *)\n\n g_malloc0(sizeof(struct omap_dss_s));\n\n\n\n s->irq = irq;\n\n s->drq = drq;\n\n omap_dss_reset(s);\n\n\n\n memory_region_init_io(&s->iomem_diss1, NULL, &omap_diss_ops, s, \"omap.diss1\",\n\n omap_l4_region_size(ta, 0));\n\n memory_region_init_io(&s->iomem_disc1, NULL, &omap_disc_ops, s, \"omap.disc1\",\n\n omap_l4_region_size(ta, 1));\n\n memory_region_init_io(&s->iomem_rfbi1, NULL, &omap_rfbi_ops, s, \"omap.rfbi1\",\n\n omap_l4_region_size(ta, 2));\n\n memory_region_init_io(&s->iomem_venc1, NULL, &omap_venc_ops, s, \"omap.venc1\",\n\n omap_l4_region_size(ta, 3));\n\n memory_region_init_io(&s->iomem_im3, NULL, &omap_im3_ops, s,\n\n \"omap.im3\", 0x1000);\n\n\n\n omap_l4_attach(ta, 0, &s->iomem_diss1);\n\n omap_l4_attach(ta, 1, &s->iomem_disc1);\n\n omap_l4_attach(ta, 2, &s->iomem_rfbi1);\n\n omap_l4_attach(ta, 3, &s->iomem_venc1);\n\n memory_region_add_subregion(sysmem, l3_base, &s->iomem_im3);\n\n\n\n#if 0\n\n s->state = graphic_console_init(omap_update_display,\n\n omap_invalidate_display, omap_screen_dump, s);\n\n#endif\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 8458 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_aio_set_fd_handler(int fd,\n\n IOHandler *io_read,\n\n IOHandler *io_write,\n\n AioFlushHandler *io_flush,\n\n void *opaque)\n\n{\n\n aio_set_fd_handler(qemu_aio_context, fd, io_read, io_write, io_flush,\n\n opaque);\n\n\n\n qemu_set_fd_handler2(fd, NULL, io_read, io_write, opaque);\n\n}\n", + "output": "0", + "index": 11634 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mem_commit(MemoryListener *listener)\n\n{\n\n AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener);\n\n AddressSpaceDispatch *cur = as->dispatch;\n\n AddressSpaceDispatch *next = as->next_dispatch;\n\n\n\n next->nodes = next_map.nodes;\n\n next->sections = next_map.sections;\n\n\n\n phys_page_compact_all(next, next_map.nodes_nb);\n\n\n\n as->dispatch = next;\n\n g_free(cur);\n\n}\n", + "output": "0", + "index": 26400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,\n int num_ports, dma_addr_t localmem_base,\n char *masterbus, uint32_t firstport,\n AddressSpace *as, Error **errp)\n{\n Error *err = NULL;\n int i;\n ohci->as = as;\n if (usb_frame_time == 0) {\n#ifdef OHCI_TIME_WARP\n usb_frame_time = NANOSECONDS_PER_SECOND;\n usb_bit_time = NANOSECONDS_PER_SECOND / (USB_HZ / 1000);\n#else\n usb_frame_time = NANOSECONDS_PER_SECOND / 1000;\n if (NANOSECONDS_PER_SECOND >= USB_HZ) {\n usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ;\n } else {\n usb_bit_time = 1;\n#endif\n trace_usb_ohci_init_time(usb_frame_time, usb_bit_time);\n ohci->num_ports = num_ports;\n if (masterbus) {\n USBPort *ports[OHCI_MAX_PORTS];\n for(i = 0; i < num_ports; i++) {\n ports[i] = &ohci->rhport[i].port;\n usb_register_companion(masterbus, ports, num_ports,\n firstport, ohci, &ohci_port_ops,\n USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL,\n &err);\n if (err) {\n error_propagate(errp, err);\n } else {\n usb_bus_new(&ohci->bus, sizeof(ohci->bus), &ohci_bus_ops, dev);\n for (i = 0; i < num_ports; i++) {\n usb_register_port(&ohci->bus, &ohci->rhport[i].port,\n ohci, i, &ohci_port_ops,\n USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);\n memory_region_init_io(&ohci->mem, OBJECT(dev), &ohci_mem_ops,\n ohci, \"ohci\", 256);\n ohci->localmem_base = localmem_base;\n ohci->name = object_get_typename(OBJECT(dev));\n usb_packet_init(&ohci->usb_packet);\n ohci->async_td = 0;\n ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,\n ohci_frame_boundary, ohci);", + "output": "1", + "index": 27238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int fmod_init_in (HWVoiceIn *hw, audsettings_t *as)\n\n{\n\n int bits16, mode;\n\n FMODVoiceIn *fmd = (FMODVoiceIn *) hw;\n\n audsettings_t obt_as = *as;\n\n\n\n if (conf.broken_adc) {\n\n return -1;\n\n }\n\n\n\n mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0);\n\n fmd->fmod_sample = FSOUND_Sample_Alloc (\n\n FSOUND_FREE, /* index */\n\n conf.nb_samples, /* length */\n\n mode, /* mode */\n\n as->freq, /* freq */\n\n 255, /* volume */\n\n 128, /* pan */\n\n 255 /* priority */\n\n );\n\n\n\n if (!fmd->fmod_sample) {\n\n fmod_logerr2 (\"ADC\", \"Failed to allocate FMOD sample\\n\");\n\n return -1;\n\n }\n\n\n\n /* FMOD always operates on little endian frames? */\n\n obt_as.endianness = 0;\n\n audio_pcm_init_info (&hw->info, &obt_as);\n\n bits16 = (mode & FSOUND_16BITS) != 0;\n\n hw->samples = conf.nb_samples;\n\n return 0;\n\n}\n", + "output": "0", + "index": 4889 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,\n\n int64_t cpu_index, Error **errp)\n\n{\n\n char *output = NULL;\n\n Monitor *old_mon, hmp;\n\n\n\n memset(&hmp, 0, sizeof(hmp));\n\n hmp.outbuf = qstring_new();\n\n hmp.skip_flush = true;\n\n\n\n old_mon = cur_mon;\n\n cur_mon = &hmp;\n\n\n\n if (has_cpu_index) {\n\n int ret = monitor_set_cpu(cpu_index);\n\n if (ret < 0) {\n\n cur_mon = old_mon;\n\n error_set(errp, QERR_INVALID_PARAMETER_VALUE, \"cpu-index\",\n\n \"a CPU number\");\n\n goto out;\n\n }\n\n }\n\n\n\n handle_user_command(&hmp, command_line);\n\n cur_mon = old_mon;\n\n\n\n if (qstring_get_length(hmp.outbuf) > 0) {\n\n output = g_strdup(qstring_get_str(hmp.outbuf));\n\n } else {\n\n output = g_strdup(\"\");\n\n }\n\n\n\nout:\n\n QDECREF(hmp.outbuf);\n\n return output;\n\n}\n", + "output": "0", + "index": 25516 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_handle_interrupt(CPUArchState *env, int mask)\n\n{\n\n CPUState *cpu = ENV_GET_CPU(env);\n\n int old_mask;\n\n\n\n old_mask = env->interrupt_request;\n\n env->interrupt_request |= mask;\n\n\n\n /*\n\n * If called from iothread context, wake the target cpu in\n\n * case its halted.\n\n */\n\n if (!qemu_cpu_is_self(cpu)) {\n\n qemu_cpu_kick(cpu);\n\n return;\n\n }\n\n\n\n if (use_icount) {\n\n env->icount_decr.u16.high = 0xffff;\n\n if (!can_do_io(env)\n\n && (mask & ~old_mask) != 0) {\n\n cpu_abort(env, \"Raised interrupt while not in I/O function\");\n\n }\n\n } else {\n\n cpu_unlink_tb(cpu);\n\n }\n\n}\n", + "output": "1", + "index": 19829 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void icount_adjust_vm(void *opaque)\n\n{\n\n timer_mod(icount_vm_timer,\n\n qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +\n\n NANOSECONDS_PER_SECOND / 10);\n\n icount_adjust();\n\n}\n", + "output": "0", + "index": 21316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "pci_ebus_init1(PCIDevice *s)\n\n{\n\n isa_bus_new(&s->qdev);\n\n\n\n pci_config_set_vendor_id(s->config, PCI_VENDOR_ID_SUN);\n\n pci_config_set_device_id(s->config, PCI_DEVICE_ID_SUN_EBUS);\n\n s->config[0x04] = 0x06; // command = bus master, pci mem\n\n s->config[0x05] = 0x00;\n\n s->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error\n\n s->config[0x07] = 0x03; // status = medium devsel\n\n s->config[0x08] = 0x01; // revision\n\n s->config[0x09] = 0x00; // programming i/f\n\n pci_config_set_class(s->config, PCI_CLASS_BRIDGE_OTHER);\n\n s->config[0x0D] = 0x0a; // latency_timer\n\n\n\n pci_register_bar(s, 0, 0x1000000, PCI_BASE_ADDRESS_SPACE_MEMORY,\n\n ebus_mmio_mapfunc);\n\n pci_register_bar(s, 1, 0x800000, PCI_BASE_ADDRESS_SPACE_MEMORY,\n\n ebus_mmio_mapfunc);\n\n return 0;\n\n}\n", + "output": "0", + "index": 15871 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DeviceState *bdrv_get_attached(BlockDriverState *bs)\n\n{\n\n return bs->peer;\n\n}\n", + "output": "0", + "index": 24084 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){\n\n pixel *src = (pixel*)_src;\n\n int stride = _stride/sizeof(pixel);\n\n const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;\n\n\n\n ((pixel4*)(src+0*stride))[0]=\n\n ((pixel4*)(src+1*stride))[0]=\n\n ((pixel4*)(src+2*stride))[0]=\n\n ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);\n\n}\n", + "output": "1", + "index": 23254 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rac_normalise(RangeCoder *c)\n\n{\n\n for (;;) {\n\n c->range <<= 8;\n\n c->low <<= 8;\n\n if (c->src < c->src_end) {\n\n c->low |= *c->src++;\n\n } else if (!c->low) {\n\n c->got_error = 1;\n\n return;\n\n }\n\n if (c->range >= RAC_BOTTOM)\n\n return;\n\n }\n\n}\n", + "output": "1", + "index": 1417 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QString *qstring_from_substr(const char *str, int start, int end)\n\n{\n\n QString *qstring;\n\n\n\n qstring = g_malloc(sizeof(*qstring));\n\n\n\n qstring->length = end - start + 1;\n\n qstring->capacity = qstring->length;\n\n\n\n qstring->string = g_malloc(qstring->capacity + 1);\n\n memcpy(qstring->string, str + start, qstring->length);\n\n qstring->string[qstring->length] = 0;\n\n\n\n QOBJECT_INIT(qstring, &qstring_type);\n\n\n\n return qstring;\n\n}\n", + "output": "0", + "index": 7754 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int msrle_decode_init(AVCodecContext *avctx)\n\n{\n\n MsrleContext *s = avctx->priv_data;\n\n int i;\n\n\n\n s->avctx = avctx;\n\n\n\n switch (avctx->bits_per_coded_sample) {\n\n case 1:\n\n avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;\n\n break;\n\n case 4:\n\n case 8:\n\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n\n break;\n\n case 24:\n\n avctx->pix_fmt = AV_PIX_FMT_BGR24;\n\n break;\n\n default:\n\n av_log(avctx, AV_LOG_ERROR, \"unsupported bits per sample\\n\");\n\n return -1;\n\n }\n\n\n\n avcodec_get_frame_defaults(&s->frame);\n\n s->frame.data[0] = NULL;\n\n\n\n if (avctx->extradata_size >= AVPALETTE_SIZE)\n\n for (i = 0; i < AVPALETTE_SIZE/4; i++)\n\n s->pal[i] = 0xFF<<24 | AV_RL32(avctx->extradata+4*i);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 6569 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_8w_msa(src + stride - 2,\n\n src - (stride * 2), stride, dst, stride, 8);\n\n}\n", + "output": "0", + "index": 24628 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void idcin_decode_vlcs(IdcinContext *s)\n\n{\n\n hnode_t *hnodes;\n\n long x, y;\n\n int prev;\n\n unsigned char v = 0;\n\n int bit_pos, node_num, dat_pos;\n\n\n\n prev = bit_pos = dat_pos = 0;\n\n for (y = 0; y < (s->frame.linesize[0] * s->avctx->height);\n\n y += s->frame.linesize[0]) {\n\n for (x = y; x < y + s->avctx->width; x++) {\n\n node_num = s->num_huff_nodes[prev];\n\n hnodes = s->huff_nodes[prev];\n\n\n\n while(node_num >= HUF_TOKENS) {\n\n if(!bit_pos) {\n\n if(dat_pos > s->size) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"Huffman decode error.\\n\");\n\n return;\n\n }\n\n bit_pos = 8;\n\n v = s->buf[dat_pos++];\n\n }\n\n\n\n node_num = hnodes[node_num].children[v & 0x01];\n\n v = v >> 1;\n\n bit_pos--;\n\n }\n\n\n\n s->frame.data[0][x] = node_num;\n\n prev = node_num;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 9762 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void setup_frame(int sig, struct target_sigaction *ka,\n\n target_sigset_t *set, CPUAlphaState *env)\n\n{\n\n abi_ulong frame_addr, r26;\n\n struct target_sigframe *frame;\n\n int err = 0;\n\n\n\n frame_addr = get_sigframe(ka, env, sizeof(*frame));\n\n if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {\n\n goto give_sigsegv;\n\n }\n\n\n\n err |= setup_sigcontext(&frame->sc, env, frame_addr, set);\n\n\n\n if (ka->sa_restorer) {\n\n r26 = ka->sa_restorer;\n\n } else {\n\n __put_user(INSN_MOV_R30_R16, &frame->retcode[0]);\n\n __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn,\n\n &frame->retcode[1]);\n\n __put_user(INSN_CALLSYS, &frame->retcode[2]);\n\n /* imb() */\n\n r26 = frame_addr;\n\n }\n\n\n\n unlock_user_struct(frame, frame_addr, 1);\n\n\n\n if (err) {\n\n give_sigsegv:\n\n if (sig == TARGET_SIGSEGV) {\n\n ka->_sa_handler = TARGET_SIG_DFL;\n\n }\n\n force_sig(TARGET_SIGSEGV);\n\n }\n\n\n\n env->ir[IR_RA] = r26;\n\n env->ir[IR_PV] = env->pc = ka->_sa_handler;\n\n env->ir[IR_A0] = sig;\n\n env->ir[IR_A1] = 0;\n\n env->ir[IR_A2] = frame_addr + offsetof(struct target_sigframe, sc);\n\n env->ir[IR_SP] = frame_addr;\n\n}\n", + "output": "0", + "index": 25021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,\n\n int nb_sectors)\n\n{\n\n struct nbd_request request = { .type = NBD_CMD_TRIM };\n\n struct nbd_reply reply;\n\n ssize_t ret;\n\n\n\n if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {\n\n return 0;\n\n }\n\n request.from = sector_num * 512;\n\n request.len = nb_sectors * 512;\n\n\n\n nbd_coroutine_start(client, &request);\n\n ret = nbd_co_send_request(client, &request, NULL, 0);\n\n if (ret < 0) {\n\n reply.error = -ret;\n\n } else {\n\n nbd_co_receive_reply(client, &request, &reply, NULL, 0);\n\n }\n\n nbd_coroutine_end(client, &request);\n\n return -reply.error;\n\n\n\n}\n", + "output": "0", + "index": 27188 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ram_control_load_hook(QEMUFile *f, uint64_t flags)\n\n{\n\n int ret = 0;\n\n\n\n if (f->ops->hook_ram_load) {\n\n ret = f->ops->hook_ram_load(f, f->opaque, flags);\n\n if (ret < 0) {\n\n qemu_file_set_error(f, ret);\n\n }\n\n } else {\n\n qemu_file_set_error(f, ret);\n\n }\n\n}\n", + "output": "0", + "index": 22764 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vnc_update_client(VncState *vs, int has_dirty, bool sync)\n\n{\n\n if (vs->need_update && vs->csock != -1) {\n\n VncDisplay *vd = vs->vd;\n\n VncJob *job;\n\n int y;\n\n int height;\n\n int n = 0;\n\n\n\n if (vs->output.offset && !vs->audio_cap && !vs->force_update)\n\n /* kernel send buffers are full -> drop frames to throttle */\n\n return 0;\n\n\n\n if (!has_dirty && !vs->audio_cap && !vs->force_update)\n\n return 0;\n\n\n\n /*\n\n * Send screen updates to the vnc client using the server\n\n * surface and server dirty map. guest surface updates\n\n * happening in parallel don't disturb us, the next pass will\n\n * send them to the client.\n\n */\n\n job = vnc_job_new(vs);\n\n\n\n height = MIN(pixman_image_get_height(vd->server), vs->client_height);\n\n\n\n y = 0;\n\n for (;;) {\n\n int x, h;\n\n unsigned long x2;\n\n unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,\n\n height * VNC_DIRTY_BPL(vs),\n\n y * VNC_DIRTY_BPL(vs));\n\n if (offset == height * VNC_DIRTY_BPL(vs)) {\n\n /* no more dirty bits */\n\n break;\n\n }\n\n y = offset / VNC_DIRTY_BPL(vs);\n\n x = offset % VNC_DIRTY_BPL(vs);\n\n x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],\n\n VNC_DIRTY_BPL(vs), x);\n\n bitmap_clear(vs->dirty[y], x, x2 - x);\n\n h = find_and_clear_dirty_height(vs, y, x, x2, height);\n\n n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,\n\n (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);\n\n }\n\n\n\n vnc_job_push(job);\n\n vs->force_update = 0;\n\n return n;\n\n }\n\n\n\n if (vs->csock == -1) {\n\n vnc_disconnect_finish(vs);\n\n } else if (sync) {\n\n vnc_jobs_join(vs);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 20101 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pflash_cfi01_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->realize = pflash_cfi01_realize;\n\n dc->props = pflash_cfi01_properties;\n\n dc->vmsd = &vmstate_pflash;\n\n set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);\n\n\n\n\n\n\n}", + "output": "1", + "index": 18760 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void uninit(struct vf_instance *vf)\n\n{\n\n free(vf->priv);\n\n}\n", + "output": "0", + "index": 1272 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpeg_mux_write_packet(AVFormatContext *ctx, int stream_index,\n\n const uint8_t *buf, int size, int64_t pts)\n\n{\n\n MpegMuxContext *s = ctx->priv_data;\n\n AVStream *st = ctx->streams[stream_index];\n\n StreamInfo *stream = st->priv_data;\n\n int len;\n\n \n\n while (size > 0) {\n\n /* set pts */\n\n if (stream->start_pts == -1) {\n\n stream->start_pts = pts;\n\n }\n\n len = s->packet_data_max_size - stream->buffer_ptr;\n\n if (len > size)\n\n len = size;\n\n memcpy(stream->buffer + stream->buffer_ptr, buf, len);\n\n stream->buffer_ptr += len;\n\n buf += len;\n\n size -= len;\n\n while (stream->buffer_ptr >= s->packet_data_max_size) {\n\n /* output the packet */\n\n if (stream->start_pts == -1)\n\n stream->start_pts = pts;\n\n flush_packet(ctx, stream_index, 0);\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 11424 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(rgb24ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_RGB24);\n\n#else\n\n int i;\n\n for (i=0; i>RGB2YUV_SHIFT);\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 25481 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,\n\n int64_t whence, Error **errp)\n\n{\n\n GuestFileHandle *gfh = guest_file_handle_find(handle, errp);\n\n GuestFileSeek *seek_data = NULL;\n\n FILE *fh;\n\n int ret;\n\n\n\n if (!gfh) {\n\n return NULL;\n\n }\n\n\n\n fh = gfh->fh;\n\n ret = fseek(fh, offset, whence);\n\n if (ret == -1) {\n\n error_setg_errno(errp, errno, \"failed to seek file\");\n\n if (errno == ESPIPE) {\n\n /* file is non-seekable, stdio shouldn't be buffering anyways */\n\n gfh->state = RW_STATE_NEW;\n\n }\n\n } else {\n\n seek_data = g_new0(GuestFileSeek, 1);\n\n seek_data->position = ftell(fh);\n\n seek_data->eof = feof(fh);\n\n gfh->state = RW_STATE_NEW;\n\n }\n\n clearerr(fh);\n\n\n\n return seek_data;\n\n}\n", + "output": "0", + "index": 6224 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_pp_fd(int fd)\n\n{\n\n CharDriverState *chr;\n\n ParallelCharDriver *drv;\n\n\n\n if (ioctl(fd, PPCLAIM) < 0) {\n\n close(fd);\n\n return NULL;\n\n }\n\n\n\n drv = g_malloc0(sizeof(ParallelCharDriver));\n\n drv->fd = fd;\n\n drv->mode = IEEE1284_MODE_COMPAT;\n\n\n\n chr = qemu_chr_alloc();\n\n chr->chr_write = null_chr_write;\n\n chr->chr_ioctl = pp_ioctl;\n\n chr->chr_close = pp_close;\n\n chr->opaque = drv;\n\n\n\n return chr;\n\n}\n", + "output": "1", + "index": 17818 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void free_test_data(test_data *data)\n\n{\n\n AcpiSdtTable *temp;\n\n int i;\n\n\n\n g_free(data->rsdt_tables_addr);\n\n\n\n for (i = 0; i < data->tables->len; ++i) {\n\n temp = &g_array_index(data->tables, AcpiSdtTable, i);\n\n g_free(temp->aml);\n\n if (temp->aml_file &&\n\n !temp->tmp_files_retain &&\n\n g_strstr_len(temp->aml_file, -1, \"aml-\")) {\n\n unlink(temp->aml_file);\n\n }\n\n g_free(temp->aml_file);\n\n g_free(temp->asl);\n\n if (temp->asl_file &&\n\n !temp->tmp_files_retain) {\n\n unlink(temp->asl_file);\n\n }\n\n g_free(temp->asl_file);\n\n }\n\n\n\n g_array_free(data->tables, false);\n\n}\n", + "output": "1", + "index": 27225 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nam_writeb (void *opaque, uint32_t addr, uint32_t val)\n\n{\n\n PCIAC97LinkState *d = opaque;\n\n AC97LinkState *s = &d->ac97;\n\n dolog (\"U nam writeb %#x <- %#x\\n\", addr, val);\n\n s->cas = 0;\n\n}\n", + "output": "0", + "index": 23540 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)\n\n{\n\n int i, ret = 1;\n\n char filename[1000];\n\n const char *base[3] = { getenv(\"AVCONV_DATADIR\"),\n\n getenv(\"HOME\"),\n\n AVCONV_DATADIR,\n\n };\n\n\n\n for (i = 0; i < FF_ARRAY_ELEMS(base) && ret; i++) {\n\n if (!base[i])\n\n continue;\n\n if (codec_name) {\n\n snprintf(filename, sizeof(filename), \"%s%s/%s-%s.avpreset\", base[i],\n\n i != 1 ? \"\" : \"/.avconv\", codec_name, preset_name);\n\n ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);\n\n }\n\n if (ret) {\n\n snprintf(filename, sizeof(filename), \"%s%s/%s.avpreset\", base[i],\n\n i != 1 ? \"\" : \"/.avconv\", preset_name);\n\n ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);\n\n }\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 3566 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr,\n\n int rw, int mmu_idx)\n\n{\n\n S390CPU *cpu = S390_CPU(cs);\n\n CPUS390XState *env = &cpu->env;\n\n target_ulong vaddr, raddr;\n\n uint64_t asc;\n\n int prot;\n\n\n\n DPRINTF(\"%s: address 0x%\" VADDR_PRIx \" rw %d mmu_idx %d\\n\",\n\n __func__, orig_vaddr, rw, mmu_idx);\n\n\n\n orig_vaddr &= TARGET_PAGE_MASK;\n\n vaddr = orig_vaddr;\n\n\n\n if (mmu_idx < MMU_REAL_IDX) {\n\n asc = cpu_mmu_idx_to_asc(mmu_idx);\n\n /* 31-Bit mode */\n\n if (!(env->psw.mask & PSW_MASK_64)) {\n\n vaddr &= 0x7fffffff;\n\n }\n\n if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) {\n\n return 1;\n\n }\n\n } else if (mmu_idx == MMU_REAL_IDX) {\n\n if (mmu_translate_real(env, vaddr, rw, &raddr, &prot)) {\n\n return 1;\n\n }\n\n } else {\n\n abort();\n\n }\n\n\n\n /* check out of RAM access */\n\n if (!address_space_access_valid(&address_space_memory, raddr,\n\n TARGET_PAGE_SIZE, rw)) {\n\n DPRINTF(\"%s: raddr %\" PRIx64 \" > ram_size %\" PRIx64 \"\\n\", __func__,\n\n (uint64_t)raddr, (uint64_t)ram_size);\n\n trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);\n\n return 1;\n\n }\n\n\n\n qemu_log_mask(CPU_LOG_MMU, \"%s: set tlb %\" PRIx64 \" -> %\" PRIx64 \" (%x)\\n\",\n\n __func__, (uint64_t)vaddr, (uint64_t)raddr, prot);\n\n\n\n tlb_set_page(cs, orig_vaddr, raddr, prot,\n\n mmu_idx, TARGET_PAGE_SIZE);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17089 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "float av_int2flt(int32_t v){\n\n if(v+v > 0xFF000000U)\n\n return NAN;\n\n return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);\n\n}\n", + "output": "1", + "index": 14683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32 float64_to_uint32( float64 a STATUS_PARAM )\n\n{\n\n int64_t v;\n\n uint32 res;\n\n\n\n v = float64_to_int64(a STATUS_VAR);\n\n if (v < 0) {\n\n res = 0;\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n } else if (v > 0xffffffff) {\n\n res = 0xffffffff;\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n } else {\n\n res = v;\n\n }\n\n return res;\n\n}\n", + "output": "0", + "index": 15544 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_pwrite(BlockDriverState *bs, int64_t offset,\n\n const void *buf, int bytes)\n\n{\n\n QEMUIOVector qiov;\n\n struct iovec iov = {\n\n .iov_base = (void *) buf,\n\n .iov_len = bytes,\n\n };\n\n\n\n if (bytes < 0) {\n\n return -EINVAL;\n\n }\n\n\n\n qemu_iovec_init_external(&qiov, &iov, 1);\n\n return bdrv_pwritev(bs, offset, &qiov);\n\n}\n", + "output": "0", + "index": 181 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int sclp_parse(const char *devname)\n\n{\n\n QemuOptsList *device = qemu_find_opts(\"device\");\n\n static int index = 0;\n\n char label[32];\n\n QemuOpts *dev_opts;\n\n\n\n if (strcmp(devname, \"none\") == 0) {\n\n return 0;\n\n }\n\n if (index == MAX_SCLP_CONSOLES) {\n\n fprintf(stderr, \"qemu: too many sclp consoles\\n\");\n\n exit(1);\n\n }\n\n\n\n assert(arch_type == QEMU_ARCH_S390X);\n\n\n\n dev_opts = qemu_opts_create(device, NULL, 0, NULL);\n\n qemu_opt_set(dev_opts, \"driver\", \"sclpconsole\", &error_abort);\n\n\n\n snprintf(label, sizeof(label), \"sclpcon%d\", index);\n\n sclp_hds[index] = qemu_chr_new(label, devname, NULL);\n\n if (!sclp_hds[index]) {\n\n fprintf(stderr, \"qemu: could not connect sclp console\"\n\n \" to character backend '%s'\\n\", devname);\n\n return -1;\n\n }\n\n qemu_opt_set(dev_opts, \"chardev\", label, &error_abort);\n\n\n\n index++;\n\n return 0;\n\n}\n", + "output": "0", + "index": 5574 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void build_fadt(GArray *table_data, BIOSLinker *linker,\n\n VirtMachineState *vms, unsigned dsdt_tbl_offset)\n\n{\n\n AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));\n\n unsigned dsdt_entry_offset = (char *)&fadt->dsdt - table_data->data;\n\n uint16_t bootflags;\n\n\n\n switch (vms->psci_conduit) {\n\n case QEMU_PSCI_CONDUIT_DISABLED:\n\n bootflags = 0;\n\n break;\n\n case QEMU_PSCI_CONDUIT_HVC:\n\n bootflags = ACPI_FADT_ARM_PSCI_COMPLIANT | ACPI_FADT_ARM_PSCI_USE_HVC;\n\n break;\n\n case QEMU_PSCI_CONDUIT_SMC:\n\n bootflags = ACPI_FADT_ARM_PSCI_COMPLIANT;\n\n break;\n\n default:\n\n g_assert_not_reached();\n\n }\n\n\n\n /* Hardware Reduced = 1 and use PSCI 0.2+ */\n\n fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);\n\n fadt->arm_boot_flags = cpu_to_le16(bootflags);\n\n\n\n /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */\n\n fadt->minor_revision = 0x1;\n\n\n\n /* DSDT address to be filled by Guest linker */\n\n bios_linker_loader_add_pointer(linker,\n\n ACPI_BUILD_TABLE_FILE, dsdt_entry_offset, sizeof(fadt->dsdt),\n\n ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset);\n\n\n\n build_header(linker, table_data,\n\n (void *)fadt, \"FACP\", sizeof(*fadt), 5, NULL, NULL);\n\n}\n", + "output": "0", + "index": 22997 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ide_test_quit(void)\n\n{\n\n\n\n qtest_end();\n\n}", + "output": "1", + "index": 22813 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void remove_migration_state_change_notifier(Notifier *notify)\n\n{\n\n notifier_remove(notify);\n\n}\n", + "output": "1", + "index": 2571 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_tick_set_count(CPUTimer *timer, uint64_t count)\n\n{\n\n uint64_t real_count = count & ~timer->disabled_mask;\n\n uint64_t disabled_bit = count & timer->disabled_mask;\n\n\n\n int64_t vm_clock_offset = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -\n\n cpu_to_timer_ticks(real_count, timer->frequency);\n\n\n\n TIMER_DPRINTF(\"%s set_count count=0x%016lx (%s) p=%p\\n\",\n\n timer->name, real_count,\n\n timer->disabled?\"disabled\":\"enabled\", timer);\n\n\n\n timer->disabled = disabled_bit ? 1 : 0;\n\n timer->clock_offset = vm_clock_offset;\n\n}\n", + "output": "1", + "index": 963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int decode_hrd_parameters(H264Context *h, SPS *sps)\n\n{\n\n int cpb_count, i;\n\n cpb_count = get_ue_golomb_31(&h->gb) + 1;\n\n\n\n if (cpb_count > 32U) {\n\n av_log(h->avctx, AV_LOG_ERROR, \"cpb_count %d invalid\\n\", cpb_count);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n get_bits(&h->gb, 4); /* bit_rate_scale */\n\n get_bits(&h->gb, 4); /* cpb_size_scale */\n\n for (i = 0; i < cpb_count; i++) {\n\n get_ue_golomb_long(&h->gb); /* bit_rate_value_minus1 */\n\n get_ue_golomb_long(&h->gb); /* cpb_size_value_minus1 */\n\n get_bits1(&h->gb); /* cbr_flag */\n\n }\n\n sps->initial_cpb_removal_delay_length = get_bits(&h->gb, 5) + 1;\n\n sps->cpb_removal_delay_length = get_bits(&h->gb, 5) + 1;\n\n sps->dpb_output_delay_length = get_bits(&h->gb, 5) + 1;\n\n sps->time_offset_length = get_bits(&h->gb, 5);\n\n sps->cpb_cnt = cpb_count;\n\n return 0;\n\n}\n", + "output": "0", + "index": 23880 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_setup_io_funcs(BlockDriver *bdrv)\n\n{\n\n /* Block drivers without coroutine functions need emulation */\n\n if (!bdrv->bdrv_co_readv) {\n\n bdrv->bdrv_co_readv = bdrv_co_readv_em;\n\n bdrv->bdrv_co_writev = bdrv_co_writev_em;\n\n\n\n /* bdrv_co_readv_em()/brdv_co_writev_em() work in terms of aio, so if\n\n * the block driver lacks aio we need to emulate that too.\n\n */\n\n if (!bdrv->bdrv_aio_readv) {\n\n /* add AIO emulation layer */\n\n bdrv->bdrv_aio_readv = bdrv_aio_readv_em;\n\n bdrv->bdrv_aio_writev = bdrv_aio_writev_em;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 23483 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fdctrl_handle_drive_specification_command(FDCtrl *fdctrl, int direction)\n\n{\n\n FDrive *cur_drv = get_cur_drv(fdctrl);\n\n\n\n if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x80) {\n\n /* Command parameters done */\n\n if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x40) {\n\n fdctrl->fifo[0] = fdctrl->fifo[1];\n\n fdctrl->fifo[2] = 0;\n\n fdctrl->fifo[3] = 0;\n\n fdctrl_set_fifo(fdctrl, 4);\n\n } else {\n\n fdctrl_reset_fifo(fdctrl);\n\n }\n\n } else if (fdctrl->data_len > 7) {\n\n /* ERROR */\n\n fdctrl->fifo[0] = 0x80 |\n\n (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);\n\n fdctrl_set_fifo(fdctrl, 1);\n\n }\n\n}\n", + "output": "1", + "index": 15242 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int32 float32_to_int32_round_to_zero( float32 a STATUS_PARAM )\n\n{\n\n flag aSign;\n\n int16 aExp, shiftCount;\n\n uint32_t aSig;\n\n int32 z;\n\n a = float32_squash_input_denormal(a STATUS_VAR);\n\n\n\n aSig = extractFloat32Frac( a );\n\n aExp = extractFloat32Exp( a );\n\n aSign = extractFloat32Sign( a );\n\n shiftCount = aExp - 0x9E;\n\n if ( 0 <= shiftCount ) {\n\n if ( float32_val(a) != 0xCF000000 ) {\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF;\n\n }\n\n return (int32_t) 0x80000000;\n\n }\n\n else if ( aExp <= 0x7E ) {\n\n if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact;\n\n return 0;\n\n }\n\n aSig = ( aSig | 0x00800000 )<<8;\n\n z = aSig>>( - shiftCount );\n\n if ( (uint32_t) ( aSig<<( shiftCount & 31 ) ) ) {\n\n STATUS(float_exception_flags) |= float_flag_inexact;\n\n }\n\n if ( aSign ) z = - z;\n\n return z;\n\n\n\n}\n", + "output": "1", + "index": 4372 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_scsi_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);\n\n dc->exit = vhost_scsi_exit;\n\n dc->props = vhost_scsi_properties;\n\n set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);\n\n vdc->init = vhost_scsi_init;\n\n vdc->get_features = vhost_scsi_get_features;\n\n vdc->set_config = vhost_scsi_set_config;\n\n vdc->set_status = vhost_scsi_set_status;\n\n}\n", + "output": "1", + "index": 25082 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int encode_ext_header(Wmv2Context *w){\n\n MpegEncContext * const s= &w->s;\n\n PutBitContext pb;\n\n int code;\n\n\n\n init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);\n\n\n\n put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29\n\n put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));\n\n\n\n put_bits(&pb, 1, w->mspel_bit=1);\n\n put_bits(&pb, 1, w->flag3=1);\n\n put_bits(&pb, 1, w->abt_flag=1);\n\n put_bits(&pb, 1, w->j_type_bit=1);\n\n put_bits(&pb, 1, w->top_left_mv_flag=0);\n\n put_bits(&pb, 1, w->per_mb_rl_bit=1);\n\n put_bits(&pb, 3, code=1);\n\n\n\n flush_put_bits(&pb);\n\n\n\n s->slice_height = s->mb_height / code;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 14416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_dr_connector_class_init(ObjectClass *k, void *data)\n\n{\n\n DeviceClass *dk = DEVICE_CLASS(k);\n\n sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);\n\n\n\n dk->reset = reset;\n\n dk->realize = realize;\n\n dk->unrealize = unrealize;\n\n drck->set_isolation_state = set_isolation_state;\n\n drck->set_indicator_state = set_indicator_state;\n\n drck->set_allocation_state = set_allocation_state;\n\n drck->get_index = get_index;\n\n drck->get_type = get_type;\n\n drck->get_name = get_name;\n\n drck->get_fdt = get_fdt;\n\n drck->set_configured = set_configured;\n\n drck->entity_sense = entity_sense;\n\n drck->attach = attach;\n\n drck->detach = detach;\n\n drck->release_pending = release_pending;\n\n\n\n\n\n}", + "output": "1", + "index": 19616 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp)\n\n{\n\n int64_t value;\n\n if (!error_is_set(errp)) {\n\n if (v->type_uint16) {\n\n v->type_uint16(v, obj, name, errp);\n\n } else {\n\n value = *obj;\n\n v->type_int(v, &value, name, errp);\n\n if (value < 0 || value > UINT16_MAX) {\n\n error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",\n\n \"uint16_t\");\n\n return;\n\n }\n\n *obj = value;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 8177 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int intel_hda_post_load(void *opaque, int version)\n\n{\n\n IntelHDAState* d = opaque;\n\n int i;\n\n\n\n dprint(d, 1, \"%s\\n\", __FUNCTION__);\n\n for (i = 0; i < ARRAY_SIZE(d->st); i++) {\n\n if (d->st[i].ctl & 0x02) {\n\n intel_hda_parse_bdl(d, &d->st[i]);\n\n }\n\n }\n\n intel_hda_update_irq(d);\n\n return 0;\n\n}\n", + "output": "0", + "index": 21482 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dump_ops(const uint16_t *opc_buf)\n\n{\n\n const uint16_t *opc_ptr;\n\n int c;\n\n opc_ptr = opc_buf;\n\n for(;;) {\n\n c = *opc_ptr++;\n\n fprintf(logfile, \"0x%04x: %s\\n\", opc_ptr - opc_buf - 1, op_str[c]);\n\n if (c == INDEX_op_end)\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 12022 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,\n\n int dstWidth, const uint8_t *src1,\n\n const uint8_t *src2, int srcW, int xInc)\n\n{\n\n int i;\n\n unsigned int xpos=0;\n\n for (i=0;i>16;\n\n register unsigned int xalpha=(xpos&0xFFFF)>>9;\n\n dst1[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);\n\n dst2[i]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);\n\n xpos+=xInc;\n\n\n\n\n\n", + "output": "1", + "index": 5451 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\n\n{\n\n MOVQ_BFE(mm6);\n\n __asm__ volatile(\n\n \"lea (%3, %3), %%\"REG_a\" \\n\\t\"\n\n \".p2align 3 \\n\\t\"\n\n \"1: \\n\\t\"\n\n \"movq (%1), %%mm0 \\n\\t\"\n\n \"movq 1(%1), %%mm1 \\n\\t\"\n\n \"movq (%1, %3), %%mm2 \\n\\t\"\n\n \"movq 1(%1, %3), %%mm3 \\n\\t\"\n\n PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)\n\n \"movq %%mm4, (%2) \\n\\t\"\n\n \"movq %%mm5, (%2, %3) \\n\\t\"\n\n \"add %%\"REG_a\", %1 \\n\\t\"\n\n \"add %%\"REG_a\", %2 \\n\\t\"\n\n \"movq (%1), %%mm0 \\n\\t\"\n\n \"movq 1(%1), %%mm1 \\n\\t\"\n\n \"movq (%1, %3), %%mm2 \\n\\t\"\n\n \"movq 1(%1, %3), %%mm3 \\n\\t\"\n\n PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)\n\n \"movq %%mm4, (%2) \\n\\t\"\n\n \"movq %%mm5, (%2, %3) \\n\\t\"\n\n \"add %%\"REG_a\", %1 \\n\\t\"\n\n \"add %%\"REG_a\", %2 \\n\\t\"\n\n \"subl $4, %0 \\n\\t\"\n\n \"jnz 1b \\n\\t\"\n\n :\"+g\"(h), \"+S\"(pixels), \"+D\"(block)\n\n :\"r\"((x86_reg)line_size)\n\n :REG_a, \"memory\");\n\n}\n", + "output": "0", + "index": 9716 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void term_completion(void)\n\n{\n\n int len, i, j, max_width, nb_cols;\n\n char *cmdline;\n\n\n\n nb_completions = 0;\n\n \n\n cmdline = qemu_malloc(term_cmd_buf_index + 1);\n\n if (!cmdline)\n\n return;\n\n memcpy(cmdline, term_cmd_buf, term_cmd_buf_index);\n\n cmdline[term_cmd_buf_index] = '\\0';\n\n find_completion(cmdline);\n\n qemu_free(cmdline);\n\n\n\n /* no completion found */\n\n if (nb_completions <= 0)\n\n return;\n\n if (nb_completions == 1) {\n\n len = strlen(completions[0]);\n\n for(i = completion_index; i < len; i++) {\n\n term_insert_char(completions[0][i]);\n\n }\n\n /* extra space for next argument. XXX: make it more generic */\n\n if (len > 0 && completions[0][len - 1] != '/')\n\n term_insert_char(' ');\n\n } else {\n\n term_printf(\"\\n\");\n\n max_width = 0;\n\n for(i = 0; i < nb_completions; i++) {\n\n len = strlen(completions[i]);\n\n if (len > max_width)\n\n max_width = len;\n\n }\n\n max_width += 2;\n\n if (max_width < 10)\n\n max_width = 10;\n\n else if (max_width > 80)\n\n max_width = 80;\n\n nb_cols = 80 / max_width;\n\n j = 0;\n\n for(i = 0; i < nb_completions; i++) {\n\n term_printf(\"%-*s\", max_width, completions[i]);\n\n if (++j == nb_cols || i == (nb_completions - 1)) {\n\n term_printf(\"\\n\");\n\n j = 0;\n\n }\n\n }\n\n term_show_prompt2();\n\n }\n\n}\n", + "output": "0", + "index": 11270 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_free(void *ptr)\n\n{\n\n free(ptr);\n\n}\n", + "output": "0", + "index": 2897 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_renameat(FsContext *ctx, V9fsPath *olddir,\n\n const char *old_name, V9fsPath *newdir,\n\n const char *new_name)\n\n{\n\n int ret;\n\n V9fsString old_full_name, new_full_name;\n\n\n\n v9fs_string_init(&old_full_name);\n\n v9fs_string_init(&new_full_name);\n\n\n\n v9fs_string_sprintf(&old_full_name, \"%s/%s\", olddir->data, old_name);\n\n v9fs_string_sprintf(&new_full_name, \"%s/%s\", newdir->data, new_name);\n\n\n\n ret = proxy_rename(ctx, old_full_name.data, new_full_name.data);\n\n v9fs_string_free(&old_full_name);\n\n v9fs_string_free(&new_full_name);\n\n return ret;\n\n}\n", + "output": "0", + "index": 23143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_pci_device_unplugged(DeviceState *d)\n\n{\n\n PCIDevice *pci_dev = PCI_DEVICE(d);\n\n VirtIOPCIProxy *proxy = VIRTIO_PCI(d);\n\n\n\n virtio_pci_stop_ioeventfd(proxy);\n\n msix_uninit_exclusive_bar(pci_dev);\n\n}\n", + "output": "1", + "index": 23297 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_tmp105_set_temperature(const char *id, int value)\n\n{\n\n QDict *response;\n\n\n\n response = qmp(\"{ 'execute': 'qom-set', 'arguments': { 'path': '%s', \"\n\n \"'property': 'temperature', 'value': %d } }\", id, value);\n\n g_assert(qdict_haskey(response, \"return\"));\n\n QDECREF(response);\n\n}\n", + "output": "1", + "index": 15765 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void * g_malloc0(size_t size)\n\n{\n\n return g_malloc(size);\n\n}\n", + "output": "1", + "index": 17529 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int svq1_decode_delta_block(MpegEncContext *s, GetBitContext *bitbuf,\n\n uint8_t *current, uint8_t *previous,\n\n int pitch, svq1_pmv *motion, int x, int y)\n\n{\n\n uint32_t block_type;\n\n int result = 0;\n\n\n\n /* get block type */\n\n block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);\n\n\n\n /* reset motion vectors */\n\n if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {\n\n motion[0].x =\n\n motion[0].y =\n\n motion[x / 8 + 2].x =\n\n motion[x / 8 + 2].y =\n\n motion[x / 8 + 3].x =\n\n motion[x / 8 + 3].y = 0;\n\n }\n\n\n\n switch (block_type) {\n\n case SVQ1_BLOCK_SKIP:\n\n svq1_skip_block(current, previous, pitch, x, y);\n\n break;\n\n\n\n case SVQ1_BLOCK_INTER:\n\n result = svq1_motion_inter_block(s, bitbuf, current, previous,\n\n pitch, motion, x, y);\n\n\n\n if (result != 0) {\n\n av_dlog(s->avctx, \"Error in svq1_motion_inter_block %i\\n\", result);\n\n break;\n\n }\n\n result = svq1_decode_block_non_intra(bitbuf, current, pitch);\n\n break;\n\n\n\n case SVQ1_BLOCK_INTER_4V:\n\n result = svq1_motion_inter_4v_block(s, bitbuf, current, previous,\n\n pitch, motion, x, y);\n\n\n\n if (result != 0) {\n\n av_dlog(s->avctx,\n\n \"Error in svq1_motion_inter_4v_block %i\\n\", result);\n\n break;\n\n }\n\n result = svq1_decode_block_non_intra(bitbuf, current, pitch);\n\n break;\n\n\n\n case SVQ1_BLOCK_INTRA:\n\n result = svq1_decode_block_intra(bitbuf, current, pitch);\n\n break;\n\n }\n\n\n\n return result;\n\n}\n", + "output": "0", + "index": 11445 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_schro_queue_init(FFSchroQueue *queue)\n\n{\n\n queue->p_head = queue->p_tail = NULL;\n\n queue->size = 0;\n\n}\n", + "output": "1", + "index": 12561 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,\n\n AVPacket *avpkt)\n\n{\n\n int ret;\n\n HEVCContext *s = avctx->priv_data;\n\n\n\n if (!avpkt->size) {\n\n ret = ff_hevc_output_frame(s, data, 1);\n\n if (ret < 0)\n\n return ret;\n\n\n\n *got_output = ret;\n\n return 0;\n\n }\n\n\n\n s->ref = NULL;\n\n ret = decode_nal_units(s, avpkt->data, avpkt->size);\n\n if (ret < 0)\n\n return ret;\n\n\n\n /* verify the SEI checksum */\n\n if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded &&\n\n avctx->err_recognition & AV_EF_EXPLODE &&\n\n s->is_md5) {\n\n ret = verify_md5(s, s->ref->frame);\n\n if (ret < 0) {\n\n ff_hevc_unref_frame(s, s->ref, ~0);\n\n return ret;\n\n }\n\n }\n\n s->is_md5 = 0;\n\n\n\n if (s->is_decoded) {\n\n av_log(avctx, AV_LOG_DEBUG, \"Decoded frame with POC %d.\\n\", s->poc);\n\n s->is_decoded = 0;\n\n }\n\n\n\n if (s->output_frame->buf[0]) {\n\n av_frame_move_ref(data, s->output_frame);\n\n *got_output = 1;\n\n }\n\n\n\n return avpkt->size;\n\n}\n", + "output": "0", + "index": 24000 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_chr_be_generic_open(CharDriverState *s)\n\n{\n\n if (s->idle_tag == 0) {\n\n s->idle_tag = g_idle_add(qemu_chr_be_generic_open_bh, s);\n\n }\n\n}\n", + "output": "0", + "index": 15613 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct iovec *cap_sg(struct iovec *sg, int cap, int *cnt)\n\n{\n\n int i;\n\n int total = 0;\n\n\n\n for (i = 0; i < *cnt; i++) {\n\n if ((total + sg[i].iov_len) > cap) {\n\n sg[i].iov_len -= ((total + sg[i].iov_len) - cap);\n\n i++;\n\n break;\n\n }\n\n total += sg[i].iov_len;\n\n }\n\n\n\n *cnt = i;\n\n\n\n return sg;\n\n}\n", + "output": "1", + "index": 1679 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const uint8_t *pcx_rle_decode(const uint8_t *src,\n\n const uint8_t *end,\n\n uint8_t *dst,\n\n unsigned int bytes_per_scanline,\n\n int compressed)\n\n{\n\n unsigned int i = 0;\n\n unsigned char run, value;\n\n\n\n if (compressed) {\n\n while (i < bytes_per_scanline && src < end) {\n\n run = 1;\n\n value = *src++;\n\n if (value >= 0xc0 && src < end) {\n\n run = value & 0x3f;\n\n value = *src++;\n\n }\n\n while (i < bytes_per_scanline && run--)\n\n dst[i++] = value;\n\n }\n\n } else {\n\n memcpy(dst, src, bytes_per_scanline);\n\n src += bytes_per_scanline;\n\n }\n\n\n\n return src;\n\n}\n", + "output": "1", + "index": 4140 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int milkymist_vgafb_init(SysBusDevice *dev)\n\n{\n\n MilkymistVgafbState *s = FROM_SYSBUS(typeof(*s), dev);\n\n\n\n memory_region_init_io(&s->regs_region, &vgafb_mmio_ops, s,\n\n \"milkymist-vgafb\", R_MAX * 4);\n\n sysbus_init_mmio(dev, &s->regs_region);\n\n\n\n s->con = graphic_console_init(vgafb_update_display,\n\n vgafb_invalidate_display,\n\n NULL, NULL, s);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21101 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void downmix_3f_2r_to_dolby(float *samples)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < 256; i++) {\n\n samples[i] += (samples[i + 256] - samples[i + 768]);\n\n samples[i + 256] = (samples[i + 512] + samples[i + 1024]);\n\n samples[i + 512] = samples[i + 768] = samples[i + 1024] = 0;\n\n }\n\n}\n", + "output": "0", + "index": 6871 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)\n\n{\n\n int i, csize = 1;\n\n void *src[3];\n\n\n\n for (i = 1; i < 3; i++)\n\n if (tile->codsty[0].transform != tile->codsty[i].transform) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"Transforms mismatch, MCT not supported\\n\");\n\n return;\n\n }\n\n\n\n for (i = 0; i < 3; i++)\n\n if (tile->codsty[0].transform == FF_DWT97)\n\n src[i] = tile->comp[i].f_data;\n\n else\n\n src[i] = tile->comp[i].i_data;\n\n\n\n for (i = 0; i < 2; i++)\n\n csize *= tile->comp[0].coord[i][1] - tile->comp[0].coord[i][0];\n\n\n\n s->dsp.mct_decode[tile->codsty[0].transform](src[0], src[1], src[2], csize);\n\n}\n", + "output": "0", + "index": 757 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_addzeo (void)\n\n{\n\n T1 = T0;\n\n T0 += xer_ca;\n\n if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) {\n\n xer_ov = 0;\n\n } else {\n\n xer_so = 1;\n\n xer_ov = 1;\n\n }\n\n if (likely(T0 >= T1)) {\n\n xer_ca = 0;\n\n } else {\n\n xer_ca = 1;\n\n }\n\n}\n", + "output": "1", + "index": 25654 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info)\n\n{\n\n PcRomPciInfo *info;\n\n if (!guest_info->has_pci_info || !guest_info->fw_cfg) {\n\n return;\n\n }\n\n\n\n info = g_malloc(sizeof *info);\n\n info->w32_min = cpu_to_le64(guest_info->pci_info.w32.begin);\n\n info->w32_max = cpu_to_le64(guest_info->pci_info.w32.end);\n\n info->w64_min = cpu_to_le64(guest_info->pci_info.w64.begin);\n\n info->w64_max = cpu_to_le64(guest_info->pci_info.w64.end);\n\n /* Pass PCI hole info to guest via a side channel.\n\n * Required so guest PCI enumeration does the right thing. */\n\n fw_cfg_add_file(guest_info->fw_cfg, \"etc/pci-info\", info, sizeof *info);\n\n}\n", + "output": "1", + "index": 18475 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "target_ulong spapr_rtas_call(sPAPREnvironment *spapr,\n\n uint32_t token, uint32_t nargs, target_ulong args,\n\n uint32_t nret, target_ulong rets)\n\n{\n\n if ((token >= TOKEN_BASE)\n\n && ((token - TOKEN_BASE) < TOKEN_MAX)) {\n\n struct rtas_call *call = rtas_table + (token - TOKEN_BASE);\n\n\n\n if (call->fn) {\n\n call->fn(spapr, token, nargs, args, nret, rets);\n\n return H_SUCCESS;\n\n }\n\n }\n\n\n\n /* HACK: Some Linux early debug code uses RTAS display-character,\n\n * but assumes the token value is 0xa (which it is on some real\n\n * machines) without looking it up in the device tree. This\n\n * special case makes this work */\n\n if (token == 0xa) {\n\n rtas_display_character(spapr, 0xa, nargs, args, nret, rets);\n\n return H_SUCCESS;\n\n }\n\n\n\n hcall_dprintf(\"Unknown RTAS token 0x%x\\n\", token);\n\n rtas_st(rets, 0, -3);\n\n return H_PARAMETER;\n\n}\n", + "output": "0", + "index": 24759 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int config_props(AVFilterLink *outlink)\n\n{\n\n AVFilterContext *ctx = outlink->src;\n\n AVFilterLink *inlink = outlink->src->inputs[0];\n\n ScaleContext *scale = ctx->priv;\n\n int64_t w, h;\n\n\n\n if (!(w = scale->w))\n\n w = inlink->w;\n\n if (!(h = scale->h))\n\n h = inlink->h;\n\n if (w == -1)\n\n w = av_rescale(h, inlink->w, inlink->h);\n\n if (h == -1)\n\n h = av_rescale(w, inlink->h, inlink->w);\n\n\n\n if (w > INT_MAX || h > INT_MAX ||\n\n (h * inlink->w) > INT_MAX ||\n\n (w * inlink->h) > INT_MAX)\n\n av_log(ctx, AV_LOG_ERROR, \"Rescaled value for width or height is too big.\\n\");\n\n\n\n outlink->w = w;\n\n outlink->h = h;\n\n\n\n /* TODO: make algorithm configurable */\n\n scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format,\n\n outlink->w, outlink->h, outlink->format,\n\n SWS_BILINEAR, NULL, NULL, NULL);\n\n\n\n av_log(ctx, AV_LOG_INFO, \"w:%d h:%d fmt:%s\\n\",\n\n outlink->w, outlink->h, av_pix_fmt_descriptors[outlink->format].name);\n\n\n\n scale->input_is_pal = inlink->format == PIX_FMT_PAL8 ||\n\n inlink->format == PIX_FMT_BGR4_BYTE ||\n\n inlink->format == PIX_FMT_RGB4_BYTE ||\n\n inlink->format == PIX_FMT_BGR8 ||\n\n inlink->format == PIX_FMT_RGB8;\n\n\n\n return !scale->sws;\n\n}\n", + "output": "0", + "index": 188 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_do_read(void *opaque, int ret)\n{\n SCSIDiskReq *r = opaque;\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n uint32_t n;\n if (r->req.aiocb != NULL) {\n r->req.aiocb = NULL;\n bdrv_acct_done(s->qdev.conf.bs, &r->acct);\n if (ret < 0) {\n if (scsi_handle_rw_error(r, -ret)) {\n goto done;\n if (r->req.sg) {\n dma_acct_start(s->qdev.conf.bs, &r->acct, r->req.sg, BDRV_ACCT_READ);\n r->req.resid -= r->req.sg->size;\n r->req.aiocb = dma_bdrv_read(s->qdev.conf.bs, r->req.sg, r->sector,\n scsi_dma_complete, r);\n } else {\n n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);\n bdrv_acct_start(s->qdev.conf.bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);\n r->req.aiocb = bdrv_aio_readv(s->qdev.conf.bs, r->sector, &r->qiov, n,\n scsi_read_complete, r);\ndone:\n if (!r->req.io_canceled) {\n scsi_req_unref(&r->req);", + "output": "1", + "index": 21085 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int setenv(const char *name, const char *value, int overwrite)\n{\n int result = 0;\n if (overwrite || !getenv(name)) {\n size_t length = strlen(name) + strlen(value) + 2;\n char *string = g_malloc(length);\n snprintf(string, length, \"%s=%s\", name, value);\n result = putenv(string);\n }\n return result;\n}", + "output": "1", + "index": 24065 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)\n\n{\n\n int size = 0, ret;\n\n const uint8_t *data;\n\n uint32_t flags;\n\n\n\n data = av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, &size);\n\n if (!data)\n\n return 0;\n\n\n\n if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE)) {\n\n av_log(avctx, AV_LOG_ERROR, \"This decoder does not support parameter \"\n\n \"changes, but PARAM_CHANGE side data was sent to it.\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n if (size < 4)\n\n goto fail;\n\n\n\n flags = bytestream_get_le32(&data);\n\n size -= 4;\n\n\n\n if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {\n\n if (size < 4)\n\n goto fail;\n\n avctx->channels = bytestream_get_le32(&data);\n\n size -= 4;\n\n }\n\n if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {\n\n if (size < 8)\n\n goto fail;\n\n avctx->channel_layout = bytestream_get_le64(&data);\n\n size -= 8;\n\n }\n\n if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {\n\n if (size < 4)\n\n goto fail;\n\n avctx->sample_rate = bytestream_get_le32(&data);\n\n size -= 4;\n\n }\n\n if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {\n\n if (size < 8)\n\n goto fail;\n\n avctx->width = bytestream_get_le32(&data);\n\n avctx->height = bytestream_get_le32(&data);\n\n size -= 8;\n\n ret = ff_set_dimensions(avctx, avctx->width, avctx->height);\n\n if (ret < 0)\n\n return ret;\n\n }\n\n\n\n return 0;\n\nfail:\n\n av_log(avctx, AV_LOG_ERROR, \"PARAM_CHANGE side data too small.\\n\");\n\n return AVERROR_INVALIDDATA;\n\n}\n", + "output": "0", + "index": 19722 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)\n\n{\n\n int ret = 0;\n\n int64_t total_size = 0;\n\n NFSClient *client = g_new0(NFSClient, 1);\n\n QDict *options = NULL;\n\n\n\n client->aio_context = qemu_get_aio_context();\n\n\n\n /* Read out options */\n\n total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),\n\n BDRV_SECTOR_SIZE);\n\n\n\n options = qdict_new();\n\n ret = nfs_parse_uri(url, options, errp);\n\n if (ret < 0) {\n\n goto out;\n\n }\n\n\n\n ret = nfs_client_open(client, options, O_CREAT, errp, 0);\n\n if (ret < 0) {\n\n goto out;\n\n }\n\n ret = nfs_ftruncate(client->context, client->fh, total_size);\n\n nfs_client_close(client);\n\nout:\n\n\n g_free(client);\n\n return ret;\n\n}", + "output": "1", + "index": 24064 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)\n\n{\n\n int ret = -ENOSYS;\n\n#ifdef KVM_CAP_COALESCED_MMIO\n\n KVMState *s = kvm_state;\n\n\n\n if (s->coalesced_mmio) {\n\n struct kvm_coalesced_mmio_zone zone;\n\n\n\n zone.addr = start;\n\n zone.size = size;\n\n\n\n ret = kvm_vm_ioctl(s, KVM_REGISTER_COALESCED_MMIO, &zone);\n\n }\n\n#endif\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 6503 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void stream_start(const char *job_id, BlockDriverState *bs,\n\n BlockDriverState *base, const char *backing_file_str,\n\n int64_t speed, BlockdevOnError on_error,\n\n BlockCompletionFunc *cb, void *opaque, Error **errp)\n\n{\n\n StreamBlockJob *s;\n\n\n\n s = block_job_create(job_id, &stream_job_driver, bs, speed,\n\n cb, opaque, errp);\n\n if (!s) {\n\n return;\n\n }\n\n\n\n s->base = base;\n\n s->backing_file_str = g_strdup(backing_file_str);\n\n\n\n s->on_error = on_error;\n\n s->common.co = qemu_coroutine_create(stream_run);\n\n trace_stream_start(bs, base, s, s->common.co, opaque);\n\n qemu_coroutine_enter(s->common.co, s);\n\n}\n", + "output": "1", + "index": 369 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_tw (int flags)\n\n{\n\n if (!likely(!((Ts0 < Ts1 && (flags & 0x10)) ||\n\n (Ts0 > Ts1 && (flags & 0x08)) ||\n\n (Ts0 == Ts1 && (flags & 0x04)) ||\n\n (T0 < T1 && (flags & 0x02)) ||\n\n (T0 > T1 && (flags & 0x01)))))\n\n do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);\n\n}\n", + "output": "1", + "index": 12911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t omap_id_read(void *opaque, hwaddr addr,\n\n unsigned size)\n\n{\n\n struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;\n\n\n\n if (size != 4) {\n\n return omap_badwidth_read32(opaque, addr);\n\n }\n\n\n\n switch (addr) {\n\n case 0xfffe1800:\t/* DIE_ID_LSB */\n\n return 0xc9581f0e;\n\n case 0xfffe1804:\t/* DIE_ID_MSB */\n\n return 0xa8858bfa;\n\n\n\n case 0xfffe2000:\t/* PRODUCT_ID_LSB */\n\n return 0x00aaaafc;\n\n case 0xfffe2004:\t/* PRODUCT_ID_MSB */\n\n return 0xcafeb574;\n\n\n\n case 0xfffed400:\t/* JTAG_ID_LSB */\n\n switch (s->mpu_model) {\n\n case omap310:\n\n return 0x03310315;\n\n case omap1510:\n\n return 0x03310115;\n\n default:\n\n hw_error(\"%s: bad mpu model\\n\", __FUNCTION__);\n\n }\n\n break;\n\n\n\n case 0xfffed404:\t/* JTAG_ID_MSB */\n\n switch (s->mpu_model) {\n\n case omap310:\n\n return 0xfb57402f;\n\n case omap1510:\n\n return 0xfb47002f;\n\n default:\n\n hw_error(\"%s: bad mpu model\\n\", __FUNCTION__);\n\n }\n\n break;\n\n }\n\n\n\n OMAP_BAD_REG(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 22864 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void wavpack_decode_flush(AVCodecContext *avctx)\n\n{\n\n WavpackContext *s = avctx->priv_data;\n\n int i;\n\n\n\n for (i = 0; i < s->fdec_num; i++)\n\n wv_reset_saved_context(s->fdec[i]);\n\n}\n", + "output": "1", + "index": 12505 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){\n\n int i;\n\n for(i=0; i<16; i++){\n\n if(nnzc[ scan8[i] ] || block[i*16])\n\n ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride);\n\n }\n\n}\n", + "output": "0", + "index": 251 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pte64_check (mmu_ctx_t *ctx,\n\n target_ulong pte0, target_ulong pte1, int h, int rw)\n\n{\n\n return _pte_check(ctx, 1, pte0, pte1, h, rw);\n\n}\n", + "output": "0", + "index": 611 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MigrationState *migrate_init(const MigrationParams *params)\n\n{\n\n MigrationState *s = migrate_get_current();\n\n int64_t bandwidth_limit = s->bandwidth_limit;\n\n bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];\n\n int64_t xbzrle_cache_size = s->xbzrle_cache_size;\n\n int compress_level = s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL];\n\n int compress_thread_count =\n\n s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS];\n\n int decompress_thread_count =\n\n s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS];\n\n int x_cpu_throttle_initial =\n\n s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL];\n\n int x_cpu_throttle_increment =\n\n s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT];\n\n\n\n memcpy(enabled_capabilities, s->enabled_capabilities,\n\n sizeof(enabled_capabilities));\n\n\n\n memset(s, 0, sizeof(*s));\n\n s->params = *params;\n\n memcpy(s->enabled_capabilities, enabled_capabilities,\n\n sizeof(enabled_capabilities));\n\n s->xbzrle_cache_size = xbzrle_cache_size;\n\n\n\n s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level;\n\n s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] =\n\n compress_thread_count;\n\n s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] =\n\n decompress_thread_count;\n\n s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] =\n\n x_cpu_throttle_initial;\n\n s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] =\n\n x_cpu_throttle_increment;\n\n s->bandwidth_limit = bandwidth_limit;\n\n migrate_set_state(s, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);\n\n\n\n QSIMPLEQ_INIT(&s->src_page_requests);\n\n\n\n s->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);\n\n return s;\n\n}\n", + "output": "1", + "index": 13134 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_symlink(FsContext *fs_ctx, const char *oldpath,\n\n V9fsPath *dir_path, const char *name, FsCred *credp)\n\n{\n\n int retval;\n\n V9fsString fullname, target;\n\n\n\n v9fs_string_init(&fullname);\n\n v9fs_string_init(&target);\n\n\n\n v9fs_string_sprintf(&fullname, \"%s/%s\", dir_path->data, name);\n\n v9fs_string_sprintf(&target, \"%s\", oldpath);\n\n\n\n retval = v9fs_request(fs_ctx->private, T_SYMLINK, NULL, \"ssdd\",\n\n &target, &fullname, credp->fc_uid, credp->fc_gid);\n\n v9fs_string_free(&fullname);\n\n v9fs_string_free(&target);\n\n if (retval < 0) {\n\n errno = -retval;\n\n retval = -1;\n\n }\n\n return retval;\n\n}\n", + "output": "0", + "index": 1896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_max_p_order(int max_porder, int n, int order)\n\n{\n\n int porder, max_parts;\n\n\n\n porder = max_porder;\n\n while(porder > 0) {\n\n max_parts = (1 << porder);\n\n if(!(n % max_parts) && (n > max_parts*order)) {\n\n break;\n\n }\n\n porder--;\n\n }\n\n return porder;\n\n}\n", + "output": "0", + "index": 24290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_phb_remove_pci_device(sPAPRDRConnector *drc,\n\n sPAPRPHBState *phb,\n\n PCIDevice *pdev,\n\n Error **errp)\n\n{\n\n sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n\n\n drck->detach(drc, DEVICE(pdev), spapr_phb_remove_pci_device_cb, phb, errp);\n\n}\n", + "output": "0", + "index": 2042 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_sigframe_return_v2(CPUState *env, target_ulong frame_addr,\n struct target_ucontext_v2 *uc)\n{\n sigset_t host_set;\n abi_ulong *regspace;\n target_to_host_sigset(&host_set, &uc->tuc_sigmask);\n sigprocmask(SIG_SETMASK, &host_set, NULL);\n if (restore_sigcontext(env, &uc->tuc_mcontext))\n if (do_sigaltstack(frame_addr + offsetof(struct target_ucontext_v2, tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)\n#if 0\n /* Send SIGTRAP if we're single-stepping */\n if (ptrace_cancel_bpt(current))\n send_sig(SIGTRAP, current, 1);\n#endif\n return 0;", + "output": "1", + "index": 24578 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void option_rom_reset(void *_rrd)\n\n{\n\n RomResetData *rrd = _rrd;\n\n\n\n cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size);\n\n}\n", + "output": "0", + "index": 20813 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t rtl8139_io_readb(void *opaque, uint8_t addr)\n\n{\n\n RTL8139State *s = opaque;\n\n int ret;\n\n\n\n addr &= 0xff;\n\n\n\n switch (addr)\n\n {\n\n case MAC0 ... MAC0+5:\n\n ret = s->phys[addr - MAC0];\n\n break;\n\n case MAC0+6 ... MAC0+7:\n\n ret = 0;\n\n break;\n\n case MAR0 ... MAR0+7:\n\n ret = s->mult[addr - MAR0];\n\n break;\n\n case ChipCmd:\n\n ret = rtl8139_ChipCmd_read(s);\n\n break;\n\n case Cfg9346:\n\n ret = rtl8139_Cfg9346_read(s);\n\n break;\n\n case Config0:\n\n ret = rtl8139_Config0_read(s);\n\n break;\n\n case Config1:\n\n ret = rtl8139_Config1_read(s);\n\n break;\n\n case Config3:\n\n ret = rtl8139_Config3_read(s);\n\n break;\n\n case Config4:\n\n ret = rtl8139_Config4_read(s);\n\n break;\n\n case Config5:\n\n ret = rtl8139_Config5_read(s);\n\n break;\n\n\n\n case MediaStatus:\n\n ret = 0xd0;\n\n DPRINTF(\"MediaStatus read 0x%x\\n\", ret);\n\n break;\n\n\n\n case HltClk:\n\n ret = s->clock_enabled;\n\n DPRINTF(\"HltClk read 0x%x\\n\", ret);\n\n break;\n\n\n\n case PCIRevisionID:\n\n ret = RTL8139_PCI_REVID;\n\n DPRINTF(\"PCI Revision ID read 0x%x\\n\", ret);\n\n break;\n\n\n\n case TxThresh:\n\n ret = s->TxThresh;\n\n DPRINTF(\"C+ TxThresh read(b) val=0x%02x\\n\", ret);\n\n break;\n\n\n\n case 0x43: /* Part of TxConfig register. Windows driver tries to read it */\n\n ret = s->TxConfig >> 24;\n\n DPRINTF(\"RTL8139C TxConfig at 0x43 read(b) val=0x%02x\\n\", ret);\n\n break;\n\n\n\n default:\n\n DPRINTF(\"not implemented read(b) addr=0x%x\\n\", addr);\n\n ret = 0;\n\n break;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 3600 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void adx_decode(ADXContext *c, int16_t *out, const uint8_t *in, int ch)\n\n{\n\n ADXChannelState *prev = &c->prev[ch];\n\n GetBitContext gb;\n\n int scale = AV_RB16(in);\n\n int i;\n\n int s0, s1, s2, d;\n\n\n\n init_get_bits(&gb, in + 2, (18 - 2) * 8);\n\n s1 = prev->s1;\n\n s2 = prev->s2;\n\n for (i = 0; i < 32; i++) {\n\n d = get_sbits(&gb, 4);\n\n s0 = (BASEVOL * d * scale + SCALE1 * s1 - SCALE2 * s2) >> 14;\n\n s2 = s1;\n\n s1 = av_clip_int16(s0);\n\n *out = s1;\n\n out += c->channels;\n\n }\n\n prev->s1 = s1;\n\n prev->s2 = s2;\n\n}\n", + "output": "1", + "index": 13904 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_info_mice(Monitor *mon, QObject **ret_data)\n\n{\n\n QEMUPutMouseEntry *cursor;\n\n QList *mice_list;\n\n int current;\n\n\n\n mice_list = qlist_new();\n\n\n\n if (QTAILQ_EMPTY(&mouse_handlers)) {\n\n goto out;\n\n }\n\n\n\n current = QTAILQ_FIRST(&mouse_handlers)->index;\n\n\n\n QTAILQ_FOREACH(cursor, &mouse_handlers, node) {\n\n QObject *obj;\n\n obj = qobject_from_jsonf(\"{ 'name': %s, 'index': %d, 'current': %i }\",\n\n cursor->qemu_put_mouse_event_name,\n\n cursor->index,\n\n cursor->index == current);\n\n qlist_append_obj(mice_list, obj);\n\n }\n\n\n\nout:\n\n *ret_data = QOBJECT(mice_list);\n\n}\n", + "output": "0", + "index": 8763 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DriveInfo *add_init_drive(const char *optstr)\n\n{\n\n DriveInfo *dinfo;\n\n QemuOpts *opts;\n\n\n\n opts = drive_def(optstr);\n\n if (!opts)\n\n return NULL;\n\n\n\n dinfo = drive_init(opts, current_machine->use_scsi);\n\n if (!dinfo) {\n\n qemu_opts_del(opts);\n\n return NULL;\n\n }\n\n\n\n return dinfo;\n\n}\n", + "output": "0", + "index": 23520 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int set_sps(HEVCContext *s, const HEVCSPS *sps)\n\n{\n\n #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL)\n\n enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;\n\n int ret;\n\n\n\n export_stream_params(s->avctx, &s->ps, sps);\n\n\n\n pic_arrays_free(s);\n\n ret = pic_arrays_init(s, sps);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) {\n\n#if CONFIG_HEVC_DXVA2_HWACCEL\n\n *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n\n#endif\n\n#if CONFIG_HEVC_D3D11VA_HWACCEL\n\n *fmt++ = AV_PIX_FMT_D3D11VA_VLD;\n\n#endif\n\n }\n\n\n\n *fmt++ = sps->pix_fmt;\n\n *fmt = AV_PIX_FMT_NONE;\n\n\n\n ret = ff_get_format(s->avctx, pix_fmts);\n\n if (ret < 0)\n\n goto fail;\n\n s->avctx->pix_fmt = ret;\n\n\n\n ff_hevc_pred_init(&s->hpc, sps->bit_depth);\n\n ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth);\n\n ff_videodsp_init (&s->vdsp, sps->bit_depth);\n\n\n\n if (sps->sao_enabled && !s->avctx->hwaccel) {\n\n av_frame_unref(s->tmp_frame);\n\n ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF);\n\n if (ret < 0)\n\n goto fail;\n\n s->frame = s->tmp_frame;\n\n }\n\n\n\n s->ps.sps = sps;\n\n s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data;\n\n\n\n return 0;\n\n\n\nfail:\n\n pic_arrays_free(s);\n\n s->ps.sps = NULL;\n\n return ret;\n\n}\n", + "output": "1", + "index": 9984 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void generate_coupling_coordinates(AC3DecodeContext * ctx)\n\n{\n\n ac3_audio_block *ab = &ctx->audio_block;\n\n uint8_t exp, mstrcplco;\n\n int16_t mant;\n\n uint32_t cplbndstrc = (1 << ab->ncplsubnd) >> 1;\n\n int ch, bnd, sbnd;\n\n float cplco;\n\n\n\n if (ab->cplcoe)\n\n for (ch = 0; ch < ctx->bsi.nfchans; ch++)\n\n if (ab->cplcoe & (1 << ch)) {\n\n mstrcplco = 3 * ab->mstrcplco[ch];\n\n sbnd = ab->cplbegf;\n\n for (bnd = 0; bnd < ab->ncplbnd; bnd++) {\n\n exp = ab->cplcoexp[ch][bnd];\n\n if (exp == 15)\n\n mant = ab->cplcomant[ch][bnd] <<= 14;\n\n else\n\n mant = (ab->cplcomant[ch][bnd] | 0x10) << 13;\n\n cplco = to_float(exp + mstrcplco, mant);\n\n if (ctx->bsi.acmod == 0x02 && (ab->flags & AC3_AB_PHSFLGINU) && ch == 1\n\n && (ab->phsflg & (1 << bnd)))\n\n cplco = -cplco; /* invert the right channel */\n\n ab->cplco[ch][sbnd++] = cplco;\n\n while (cplbndstrc & ab->cplbndstrc) {\n\n cplbndstrc >>= 1;\n\n ab->cplco[ch][sbnd++] = cplco;\n\n }\n\n cplbndstrc >>= 1;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 23442 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr,\n\n unsigned size)\n\n{\n\n PXA2xxRTCState *s = (PXA2xxRTCState *) opaque;\n\n\n\n switch (addr) {\n\n case RTTR:\n\n return s->rttr;\n\n case RTSR:\n\n return s->rtsr;\n\n case RTAR:\n\n return s->rtar;\n\n case RDAR1:\n\n return s->rdar1;\n\n case RDAR2:\n\n return s->rdar2;\n\n case RYAR1:\n\n return s->ryar1;\n\n case RYAR2:\n\n return s->ryar2;\n\n case SWAR1:\n\n return s->swar1;\n\n case SWAR2:\n\n return s->swar2;\n\n case PIAR:\n\n return s->piar;\n\n case RCNR:\n\n return s->last_rcnr +\n\n ((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /\n\n (1000 * ((s->rttr & 0xffff) + 1));\n\n case RDCR:\n\n return s->last_rdcr +\n\n ((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /\n\n (1000 * ((s->rttr & 0xffff) + 1));\n\n case RYCR:\n\n return s->last_rycr;\n\n case SWCR:\n\n if (s->rtsr & (1 << 12))\n\n return s->last_swcr +\n\n (qemu_clock_get_ms(rtc_clock) - s->last_sw) / 10;\n\n else\n\n return s->last_swcr;\n\n default:\n\n printf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, addr);\n\n break;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 25235 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void scsi_req_cancel_async(SCSIRequest *req, Notifier *notifier)\n\n{\n\n trace_scsi_req_cancel(req->dev->id, req->lun, req->tag);\n\n if (notifier) {\n\n notifier_list_add(&req->cancel_notifiers, notifier);\n\n }\n\n if (req->io_canceled) {\n\n return;\n\n }\n\n scsi_req_ref(req);\n\n scsi_req_dequeue(req);\n\n req->io_canceled = true;\n\n if (req->aiocb) {\n\n bdrv_aio_cancel_async(req->aiocb);\n\n }\n\n}\n", + "output": "0", + "index": 26675 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *g_malloc(size_t size)\n\n{\n\n char * p;\n\n size += 16;\n\n p = bsd_vmalloc(size);\n\n *(size_t *)p = size;\n\n return p + 16;\n\n}\n", + "output": "1", + "index": 18844 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)\n\n{\n\n AVStream *st = s->streams[0];\n\n int tmp, tmp2;\n\n uint64_t pos = url_ftell(s->pb);\n\n unsigned dts;\n\n\n\n dts = get_be32(s->pb);\n\n\n\n tmp = get_be32(s->pb);\n\n dprintf(s, \"frame num %d\\n\", tmp);\n\n\n\n tmp = get_byte(s->pb); // major version\n\n tmp2 = get_byte(s->pb); // minor version\n\n dprintf(s, \"version %d.%d\\n\", tmp, tmp2);\n\n\n\n tmp = get_be16(s->pb); // unknown\n\n dprintf(s, \"unknown %d\\n\", tmp);\n\n\n\n if (tmp > 4) {\n\n tmp = get_be16(s->pb); // unknown\n\n dprintf(s, \"unknown %d\\n\", tmp);\n\n\n\n tmp = get_be16(s->pb); // unknown\n\n dprintf(s, \"unknown %d\\n\", tmp);\n\n\n\n tmp = get_be32(s->pb);\n\n dprintf(s, \"width %d\\n\", tmp);\n\n tmp = get_be32(s->pb);\n\n dprintf(s, \"height %d\\n\", tmp);\n\n\n\n tmp = get_be32(s->pb);\n\n dprintf(s, \"metadata len %d\\n\", tmp);\n\n }\n\n tmp = atom->size - 8 - (url_ftell(s->pb) - pos);\n\n if (tmp < 0)\n\n return -1;\n\n\n\n if (av_get_packet(s->pb, pkt, tmp) != tmp) {\n\n av_log(s, AV_LOG_ERROR, \"error reading video packet\\n\");\n\n return -1;\n\n }\n\n\n\n pkt->stream_index = 0;\n\n pkt->dts = dts;\n\n if (st->codec->time_base.den)\n\n pkt->duration = (uint64_t)st->time_base.den*\n\n st->codec->time_base.num/st->codec->time_base.den;\n\n dprintf(s, \"pkt dts %lld duration %d\\n\", pkt->dts, pkt->duration);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 23384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,\n\n Error **errp)\n\n{\n\n NetClientState *nc;\n\n RxFilterInfoList *filter_list = NULL, *last_entry = NULL;\n\n\n\n QTAILQ_FOREACH(nc, &net_clients, next) {\n\n RxFilterInfoList *entry;\n\n RxFilterInfo *info;\n\n\n\n if (has_name && strcmp(nc->name, name) != 0) {\n\n continue;\n\n }\n\n\n\n /* only query rx-filter information of NIC */\n\n if (nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC) {\n\n if (has_name) {\n\n error_setg(errp, \"net client(%s) isn't a NIC\", name);\n\n break;\n\n }\n\n continue;\n\n }\n\n\n\n if (nc->info->query_rx_filter) {\n\n info = nc->info->query_rx_filter(nc);\n\n entry = g_malloc0(sizeof(*entry));\n\n entry->value = info;\n\n\n\n if (!filter_list) {\n\n filter_list = entry;\n\n } else {\n\n last_entry->next = entry;\n\n }\n\n last_entry = entry;\n\n } else if (has_name) {\n\n error_setg(errp, \"net client(%s) doesn't support\"\n\n \" rx-filter querying\", name);\n\n break;\n\n }\n\n\n\n if (has_name) {\n\n break;\n\n }\n\n }\n\n\n\n if (filter_list == NULL && !error_is_set(errp) && has_name) {\n\n error_setg(errp, \"invalid net client name: %s\", name);\n\n }\n\n\n\n return filter_list;\n\n}\n", + "output": "0", + "index": 10265 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dump_json_image_info_list(ImageInfoList *list)\n\n{\n\n QString *str;\n\n QmpOutputVisitor *ov = qmp_output_visitor_new();\n\n QObject *obj;\n\n visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list,\n\n &error_abort);\n\n obj = qmp_output_get_qobject(ov);\n\n str = qobject_to_json_pretty(obj);\n\n assert(str != NULL);\n\n printf(\"%s\\n\", qstring_get_str(str));\n\n qobject_decref(obj);\n\n qmp_output_visitor_cleanup(ov);\n\n QDECREF(str);\n\n}\n", + "output": "0", + "index": 26683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t wrap_timestamp(AVStream *st, int64_t timestamp)\n\n{\n\n if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&\n\n st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {\n\n if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&\n\n timestamp < st->pts_wrap_reference)\n\n return timestamp + (1ULL<pts_wrap_bits);\n\n else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&\n\n timestamp >= st->pts_wrap_reference)\n\n return timestamp - (1ULL<pts_wrap_bits);\n\n }\n\n return timestamp;\n\n}\n", + "output": "0", + "index": 17009 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,\n\n Error **errp)\n\n{\n\n g_free(*obj);\n\n}\n", + "output": "0", + "index": 20935 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit)\n\n{\n\n int rc;\n\n\n\n struct kvm_device_attr attr = {\n\n .group = KVM_S390_VM_MEM_CTRL,\n\n .attr = KVM_S390_VM_MEM_LIMIT_SIZE,\n\n .addr = (uint64_t) &new_limit,\n\n };\n\n\n\n if (!kvm_s390_supports_mem_limit(s)) {\n\n return 0;\n\n }\n\n\n\n rc = kvm_s390_query_mem_limit(s, hw_limit);\n\n if (rc) {\n\n return rc;\n\n } else if (*hw_limit < new_limit) {\n\n return -E2BIG;\n\n }\n\n\n\n return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);\n\n}\n", + "output": "0", + "index": 1615 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)\n\n{\n\n DeviceState *dev = DEVICE(pci_dev);\n\n VMXNET3State *s = VMXNET3(pci_dev);\n\n\n\n VMW_CBPRN(\"Starting init...\");\n\n\n\n memory_region_init_io(&s->bar0, OBJECT(s), &b0_ops, s,\n\n \"vmxnet3-b0\", VMXNET3_PT_REG_SIZE);\n\n pci_register_bar(pci_dev, VMXNET3_BAR0_IDX,\n\n PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar0);\n\n\n\n memory_region_init_io(&s->bar1, OBJECT(s), &b1_ops, s,\n\n \"vmxnet3-b1\", VMXNET3_VD_REG_SIZE);\n\n pci_register_bar(pci_dev, VMXNET3_BAR1_IDX,\n\n PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar1);\n\n\n\n memory_region_init(&s->msix_bar, OBJECT(s), \"vmxnet3-msix-bar\",\n\n VMXNET3_MSIX_BAR_SIZE);\n\n pci_register_bar(pci_dev, VMXNET3_MSIX_BAR_IDX,\n\n PCI_BASE_ADDRESS_SPACE_MEMORY, &s->msix_bar);\n\n\n\n vmxnet3_reset_interrupt_states(s);\n\n\n\n /* Interrupt pin A */\n\n pci_dev->config[PCI_INTERRUPT_PIN] = 0x01;\n\n\n\n if (!vmxnet3_init_msix(s)) {\n\n VMW_WRPRN(\"Failed to initialize MSI-X, configuration is inconsistent.\");\n\n }\n\n\n\n if (!vmxnet3_init_msi(s)) {\n\n VMW_WRPRN(\"Failed to initialize MSI, configuration is inconsistent.\");\n\n }\n\n\n\n vmxnet3_net_init(s);\n\n\n\n if (pci_is_express(pci_dev)) {\n\n if (pci_bus_is_express(pci_dev->bus)) {\n\n pcie_endpoint_cap_init(pci_dev, VMXNET3_EXP_EP_OFFSET);\n\n }\n\n\n\n pcie_dev_ser_num_init(pci_dev, VMXNET3_DSN_OFFSET,\n\n vmxnet3_device_serial_num(s));\n\n }\n\n\n\n register_savevm(dev, \"vmxnet3-msix\", -1, 1,\n\n vmxnet3_msix_save, vmxnet3_msix_load, s);\n\n}\n", + "output": "1", + "index": 17471 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int msrle_decode_init(AVCodecContext *avctx)\n\n{\n\n MsrleContext *s = avctx->priv_data;\n\n\n\n s->avctx = avctx;\n\n\n\n switch (avctx->bits_per_coded_sample) {\n\n case 4:\n\n case 8:\n\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n\n break;\n\n case 24:\n\n avctx->pix_fmt = AV_PIX_FMT_BGR24;\n\n break;\n\n default:\n\n av_log(avctx, AV_LOG_ERROR, \"unsupported bits per sample\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n s->frame.data[0] = NULL;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8484 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tc6393xb_gpio_handler_update(TC6393xbState *s)\n\n{\n\n uint32_t level, diff;\n\n int bit;\n\n\n\n level = s->gpio_level & s->gpio_dir;\n\n\n\n for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) {\n\n bit = ffs(diff) - 1;\n\n qemu_set_irq(s->handler[bit], (level >> bit) & 1);\n\n }\n\n\n\n s->prev_level = level;\n\n}\n", + "output": "0", + "index": 1504 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)\n\n{\n\n if(st->request_probe>0){\n\n AVProbeData *pd = &st->probe_data;\n\n int end;\n\n av_log(s, AV_LOG_DEBUG, \"probing stream %d pp:%d\\n\", st->index, st->probe_packets);\n\n --st->probe_packets;\n\n\n\n if (pkt) {\n\n pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);\n\n memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);\n\n pd->buf_size += pkt->size;\n\n memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);\n\n } else {\n\n st->probe_packets = 0;\n\n }\n\n\n\n end= s->raw_packet_buffer_remaining_size <= 0\n\n || st->probe_packets<=0;\n\n\n\n if(end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){\n\n int score= set_codec_from_probe_data(s, st, pd);\n\n if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4)\n\n || end){\n\n pd->buf_size=0;\n\n av_freep(&pd->buf);\n\n st->request_probe= -1;\n\n if(st->codec->codec_id != CODEC_ID_NONE){\n\n av_log(s, AV_LOG_DEBUG, \"probed stream %d\\n\", st->index);\n\n }else\n\n av_log(s, AV_LOG_WARNING, \"probed stream %d failed\\n\", st->index);\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 6521 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoull_whitespace(void)\n\n{\n\n const char *str = \" \\t \";\n\n char f = 'X';\n\n const char *endptr = &f;\n\n uint64_t res = 999;\n\n int err;\n\n\n\n err = qemu_strtoull(str, &endptr, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, 0);\n\n g_assert(endptr == str);\n\n}\n", + "output": "1", + "index": 26351 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int write_elf_loads(DumpState *s)\n\n{\n\n hwaddr offset;\n\n MemoryMapping *memory_mapping;\n\n uint32_t phdr_index = 1;\n\n int ret;\n\n uint32_t max_index;\n\n\n\n if (s->have_section) {\n\n max_index = s->sh_info;\n\n } else {\n\n max_index = s->phdr_num;\n\n }\n\n\n\n QTAILQ_FOREACH(memory_mapping, &s->list.head, next) {\n\n offset = get_offset(memory_mapping->phys_addr, s);\n\n if (s->dump_info.d_class == ELFCLASS64) {\n\n ret = write_elf64_load(s, memory_mapping, phdr_index++, offset);\n\n } else {\n\n ret = write_elf32_load(s, memory_mapping, phdr_index++, offset);\n\n }\n\n\n\n if (ret < 0) {\n\n return -1;\n\n }\n\n\n\n if (phdr_index >= max_index) {\n\n break;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 14549 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gem_cleanup(NetClientState *nc)\n\n{\n\n GemState *s = qemu_get_nic_opaque(nc);\n\n\n\n DB_PRINT(\"\\n\");\n\n s->nic = NULL;\n\n}\n", + "output": "0", + "index": 22345 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_fctiwz (void)\n\n{\n\n union {\n\n double d;\n\n uint64_t i;\n\n } p;\n\n\n\n /* XXX: higher bits are not supposed to be significant.\n\n * to make tests easier, return the same as a real PowerPC 750 (aka G3)\n\n */\n\n p.i = float64_to_int32_round_to_zero(FT0, &env->fp_status);\n\n p.i |= 0xFFF80000ULL << 32;\n\n FT0 = p.d;\n\n}\n", + "output": "1", + "index": 20127 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spatial_compose97i_dy_buffered(dwt_compose_t *cs, slice_buffer * sb, int width, int height, int stride_line){\n\n int y = cs->y;\n\n\n\n int mirror0 = mirror(y - 1, height - 1);\n\n int mirror1 = mirror(y + 0, height - 1);\n\n int mirror2 = mirror(y + 1, height - 1);\n\n int mirror3 = mirror(y + 2, height - 1);\n\n int mirror4 = mirror(y + 3, height - 1);\n\n int mirror5 = mirror(y + 4, height - 1);\n\n DWTELEM *b0= cs->b0;\n\n DWTELEM *b1= cs->b1;\n\n DWTELEM *b2= cs->b2;\n\n DWTELEM *b3= cs->b3;\n\n DWTELEM *b4= slice_buffer_get_line(sb, mirror4 * stride_line);\n\n DWTELEM *b5= slice_buffer_get_line(sb, mirror5 * stride_line);\n\n\n\n{START_TIMER\n\n if(y>0 && y+4400){\n\nSTOP_TIMER(\"vertical_compose97i\")}}\n\n\n\n{START_TIMER\n\n if(y-1>= 0) horizontal_compose97i(b0, width);\n\n if(mirror0 <= mirror2) horizontal_compose97i(b1, width);\n\nif(width>400 && mirror0 <= mirror2){\n\nSTOP_TIMER(\"horizontal_compose97i\")}}\n\n\n\n cs->b0=b2;\n\n cs->b1=b3;\n\n cs->b2=b4;\n\n cs->b3=b5;\n\n cs->y += 2;\n\n}\n", + "output": "1", + "index": 22719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_client_co_flush(BlockDriverState *bs)\n\n{\n\n NbdClientSession *client = nbd_get_client_session(bs);\n\n struct nbd_request request = { .type = NBD_CMD_FLUSH };\n\n struct nbd_reply reply;\n\n ssize_t ret;\n\n\n\n if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) {\n\n return 0;\n\n }\n\n\n\n if (client->nbdflags & NBD_FLAG_SEND_FUA) {\n\n request.type |= NBD_CMD_FLAG_FUA;\n\n }\n\n\n\n request.from = 0;\n\n request.len = 0;\n\n\n\n nbd_coroutine_start(client, &request);\n\n ret = nbd_co_send_request(bs, &request, NULL, 0);\n\n if (ret < 0) {\n\n reply.error = -ret;\n\n } else {\n\n nbd_co_receive_reply(client, &request, &reply, NULL, 0);\n\n }\n\n nbd_coroutine_end(client, &request);\n\n return -reply.error;\n\n}\n", + "output": "0", + "index": 19338 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int load_normal_reset(S390CPU *cpu)\n\n{\n\n S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);\n\n\n\n pause_all_vcpus();\n\n cpu_synchronize_all_states();\n\n cpu_reset_all();\n\n\n io_subsystem_reset();\n\n scc->initial_cpu_reset(CPU(cpu));\n\n scc->load_normal(CPU(cpu));\n\n cpu_synchronize_all_post_reset();\n\n resume_all_vcpus();\n\n return 0;\n\n}", + "output": "1", + "index": 22875 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size)\n\n{\n\n put_flush_packet(bc);\n\n nut->last_packet_start= nut->packet_start;\n\n nut->packet_start+= nut->written_packet_size;\n\n nut->packet_size_pos = url_ftell(bc);\n\n nut->written_packet_size = max_size;\n\n\n\n /* packet header */\n\n put_v(bc, nut->written_packet_size); /* forward ptr */\n\n put_v(bc, nut->packet_start - nut->last_packet_start); /* backward ptr */\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17918 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_pci_reset(DeviceState *dev)\n\n{\n\n PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);\n\n VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);\n\n\n\n if (!vdev->reset_works) {\n\n return;\n\n }\n\n\n\n if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {\n\n error_report(\"vfio: Error unable to reset physical device \"\n\n \"(%04x:%02x:%02x.%x): %m\\n\", vdev->host.domain,\n\n vdev->host.bus, vdev->host.slot, vdev->host.function);\n\n }\n\n}\n", + "output": "0", + "index": 23246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *text_console_init(ChardevVC *vc, Error **errp)\n\n{\n\n CharDriverState *chr;\n\n QemuConsole *s;\n\n unsigned width = 0;\n\n unsigned height = 0;\n\n\n\n chr = qemu_chr_alloc();\n\n\n\n if (vc->has_width) {\n\n width = vc->width;\n\n } else if (vc->has_cols) {\n\n width = vc->cols * FONT_WIDTH;\n\n }\n\n\n\n if (vc->has_height) {\n\n height = vc->height;\n\n } else if (vc->has_rows) {\n\n height = vc->rows * FONT_HEIGHT;\n\n }\n\n\n\n trace_console_txt_new(width, height);\n\n if (width == 0 || height == 0) {\n\n s = new_console(NULL, TEXT_CONSOLE, 0);\n\n } else {\n\n s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE, 0);\n\n s->surface = qemu_create_displaysurface(width, height);\n\n }\n\n\n\n if (!s) {\n\n g_free(chr);\n\n error_setg(errp, \"cannot create text console\");\n\n return NULL;\n\n }\n\n\n\n s->chr = chr;\n\n chr->opaque = s;\n\n chr->chr_set_echo = text_console_set_echo;\n\n /* console/chardev init sometimes completes elsewhere in a 2nd\n\n * stage, so defer OPENED events until they are fully initialized\n\n */\n\n chr->explicit_be_open = true;\n\n\n\n if (display_state) {\n\n text_console_do_init(chr, display_state);\n\n }\n\n return chr;\n\n}\n", + "output": "0", + "index": 4552 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_strtoll(const char *nptr, const char **endptr, int base,\n\n int64_t *result)\n\n{\n\n char *p;\n\n int err = 0;\n\n if (!nptr) {\n\n if (endptr) {\n\n *endptr = nptr;\n\n }\n\n err = -EINVAL;\n\n } else {\n\n errno = 0;\n\n *result = strtoll(nptr, &p, base);\n\n err = check_strtox_error(endptr, p, errno);\n\n }\n\n return err;\n\n}\n", + "output": "1", + "index": 24382 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) {\n\n const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);\n\n const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;\n\n const int alpha = alpha_table[index_a];\n\n const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];\n\n if (alpha ==0 || beta == 0) return;\n\n\n\n if( bS[0] < 4 || !intra ) {\n\n int8_t tc[4];\n\n tc[0] = tc0_table[index_a][bS[0]]+1;\n\n tc[1] = tc0_table[index_a][bS[1]]+1;\n\n tc[2] = tc0_table[index_a][bS[2]]+1;\n\n tc[3] = tc0_table[index_a][bS[3]]+1;\n\n h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);\n\n } else {\n\n h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);\n\n }\n\n}\n", + "output": "0", + "index": 22733 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_reset (CPUMIPSState *env)\n{\n memset(env, 0, offsetof(CPUMIPSState, breakpoints));\n tlb_flush(env, 1);\n /* Minimal init */\n#if defined(CONFIG_USER_ONLY)\n env->hflags = MIPS_HFLAG_UM;\n#else\n if (env->hflags & MIPS_HFLAG_BMASK) {\n /* If the exception was raised from a delay slot,\n come back to the jump. */\n env->CP0_ErrorEPC = env->active_tc.PC - 4;\n } else {\n env->CP0_ErrorEPC = env->active_tc.PC;\n env->active_tc.PC = (int32_t)0xBFC00000;\n env->CP0_Wired = 0;\n /* SMP not implemented */\n env->CP0_EBase = 0x80000000;\n env->CP0_Status = (1 << CP0St_BEV) | (1 << CP0St_ERL);\n /* vectored interrupts not implemented, timer on int 7,\n no performance counters. */\n env->CP0_IntCtl = 0xe0000000;\n {\n int i;\n for (i = 0; i < 7; i++) {\n env->CP0_WatchLo[i] = 0;\n env->CP0_WatchHi[i] = 0x80000000;\n env->CP0_WatchLo[7] = 0;\n env->CP0_WatchHi[7] = 0;\n /* Count register increments in debug mode, EJTAG version 1 */\n env->CP0_Debug = (1 << CP0DB_CNT) | (0x1 << CP0DB_VER);\n env->hflags = MIPS_HFLAG_CP0;\n#endif\n env->exception_index = EXCP_NONE;\n cpu_mips_register(env, env->cpu_model);", + "output": "1", + "index": 26498 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs)\n\n{\n\n return closedir(fs->dir);\n\n}\n", + "output": "0", + "index": 25712 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_get_channel_layout_string(char *buf, int buf_size,\n\n int nb_channels, uint64_t channel_layout)\n\n{\n\n int i;\n\n\n\n if (nb_channels <= 0)\n\n nb_channels = av_get_channel_layout_nb_channels(channel_layout);\n\n\n\n for (i = 0; channel_layout_map[i].name; i++)\n\n if (nb_channels == channel_layout_map[i].nb_channels &&\n\n channel_layout == channel_layout_map[i].layout) {\n\n av_strlcpy(buf, channel_layout_map[i].name, buf_size);\n\n return;\n\n }\n\n\n\n snprintf(buf, buf_size, \"%d channels\", nb_channels);\n\n if (channel_layout) {\n\n int i, ch;\n\n av_strlcat(buf, \" (\", buf_size);\n\n for (i = 0, ch = 0; i < 64; i++) {\n\n if ((channel_layout & (1L << i))) {\n\n const char *name = get_channel_name(i);\n\n if (name) {\n\n if (ch > 0)\n\n av_strlcat(buf, \"|\", buf_size);\n\n av_strlcat(buf, name, buf_size);\n\n }\n\n ch++;\n\n }\n\n }\n\n av_strlcat(buf, \")\", buf_size);\n\n }\n\n}\n", + "output": "1", + "index": 5871 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent,\n\n Error **errp)\n\n{\n\n int ret;\n\n int l1_size, i;\n\n\n\n /* read the L1 table */\n\n l1_size = extent->l1_size * sizeof(uint32_t);\n\n extent->l1_table = g_try_malloc(l1_size);\n\n if (l1_size && extent->l1_table == NULL) {\n\n return -ENOMEM;\n\n }\n\n\n\n ret = bdrv_pread(extent->file,\n\n extent->l1_table_offset,\n\n extent->l1_table,\n\n l1_size);\n\n if (ret < 0) {\n\n error_setg_errno(errp, -ret,\n\n \"Could not read l1 table from extent '%s'\",\n\n extent->file->filename);\n\n goto fail_l1;\n\n }\n\n for (i = 0; i < extent->l1_size; i++) {\n\n le32_to_cpus(&extent->l1_table[i]);\n\n }\n\n\n\n if (extent->l1_backup_table_offset) {\n\n extent->l1_backup_table = g_try_malloc(l1_size);\n\n if (l1_size && extent->l1_backup_table == NULL) {\n\n ret = -ENOMEM;\n\n goto fail_l1;\n\n }\n\n ret = bdrv_pread(extent->file,\n\n extent->l1_backup_table_offset,\n\n extent->l1_backup_table,\n\n l1_size);\n\n if (ret < 0) {\n\n error_setg_errno(errp, -ret,\n\n \"Could not read l1 backup table from extent '%s'\",\n\n extent->file->filename);\n\n goto fail_l1b;\n\n }\n\n for (i = 0; i < extent->l1_size; i++) {\n\n le32_to_cpus(&extent->l1_backup_table[i]);\n\n }\n\n }\n\n\n\n extent->l2_cache =\n\n g_new(uint32_t, extent->l2_size * L2_CACHE_SIZE);\n\n return 0;\n\n fail_l1b:\n\n g_free(extent->l1_backup_table);\n\n fail_l1:\n\n g_free(extent->l1_table);\n\n return ret;\n\n}\n", + "output": "1", + "index": 20783 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {\n\n int frame_size_code;\n\n\n\n /* unknown field */\n\n get_bits (bitbuf, 8);\n\n\n\n /* frame type */\n\n s->pict_type = get_bits (bitbuf, 2);\n\n\n\n if (s->pict_type == 3)\n\n return -1;\n\n\n\n if (s->pict_type == SVQ1_FRAME_INTRA) {\n\n\n\n /* unknown fields */\n\n if (s->f_code == 0x50 || s->f_code == 0x60) {\n\n get_bits (bitbuf, 16);\n\n }\n\n\n\n if ((s->f_code ^ 0x10) >= 0x50) {\n\n skip_bits(bitbuf,8*get_bits (bitbuf, 8));\n\n }\n\n\n\n get_bits (bitbuf, 2);\n\n get_bits (bitbuf, 2);\n\n get_bits (bitbuf, 1);\n\n\n\n /* load frame size */\n\n frame_size_code = get_bits (bitbuf, 3);\n\n\n\n if (frame_size_code == 7) {\n\n /* load width, height (12 bits each) */\n\n s->width = get_bits (bitbuf, 12);\n\n s->height = get_bits (bitbuf, 12);\n\n\n\n if (!s->width || !s->height)\n\n return -1;\n\n } else {\n\n /* get width, height from table */\n\n s->width = frame_size_table[frame_size_code].width;\n\n s->height = frame_size_table[frame_size_code].height;\n\n }\n\n }\n\n\n\n /* unknown fields */\n\n if (get_bits (bitbuf, 1) == 1) {\n\n get_bits (bitbuf, 1);\n\n get_bits (bitbuf, 1);\n\n\n\n if (get_bits (bitbuf, 2) != 0)\n\n return -1;\n\n }\n\n\n\n if (get_bits (bitbuf, 1) == 1) {\n\n get_bits (bitbuf, 1);\n\n get_bits (bitbuf, 4);\n\n get_bits (bitbuf, 1);\n\n get_bits (bitbuf, 2);\n\n\n\n while (get_bits (bitbuf, 1) == 1) {\n\n get_bits (bitbuf, 8);\n\n }\n\n }\n\n \n\n return 0;\n\n}\n", + "output": "0", + "index": 9622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)\n\n{\n\n s->scratch_size = SVGA_SCRATCH_SIZE;\n\n s->scratch = qemu_malloc(s->scratch_size * 4);\n\n\n\n vmsvga_reset(s);\n\n\n\n s->fifo_size = SVGA_FIFO_SIZE;\n\n s->fifo_offset = qemu_ram_alloc(s->fifo_size);\n\n s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset);\n\n\n\n vga_common_init(&s->vga, vga_ram_size);\n\n vga_init(&s->vga);\n\n vmstate_register(0, &vmstate_vga_common, &s->vga);\n\n\n\n s->vga.ds = graphic_console_init(vmsvga_update_display,\n\n vmsvga_invalidate_display,\n\n vmsvga_screen_dump,\n\n vmsvga_text_update, s);\n\n\n\n vga_init_vbe(&s->vga);\n\n rom_add_vga(VGABIOS_FILENAME);\n\n}\n", + "output": "1", + "index": 3216 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void machine_set_loadparm(Object *obj, const char *val, Error **errp)\n\n{\n\n S390CcwMachineState *ms = S390_CCW_MACHINE(obj);\n\n int i;\n\n\n\n for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) {\n\n uint8_t c = toupper(val[i]); /* mimic HMC */\n\n\n\n if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') ||\n\n (c == ' ')) {\n\n ms->loadparm[i] = c;\n\n } else {\n\n error_setg(errp, \"LOADPARM: invalid character '%c' (ASCII 0x%02x)\",\n\n c, c);\n\n return;\n\n }\n\n }\n\n\n\n for (; i < sizeof(ms->loadparm); i++) {\n\n ms->loadparm[i] = ' '; /* pad right with spaces */\n\n }\n\n}\n", + "output": "1", + "index": 25420 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)\n\n{\n\n sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);\n\n struct vfio_iommu_spapr_tce_info info = { .argsz = sizeof(info) };\n\n int ret;\n\n sPAPRTCETable *tcet;\n\n uint32_t liobn = svphb->phb.dma_liobn;\n\n\n\n if (svphb->iommugroupid == -1) {\n\n error_setg(errp, \"Wrong IOMMU group ID %d\", svphb->iommugroupid);\n\n return;\n\n }\n\n\n\n ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,\n\n VFIO_CHECK_EXTENSION,\n\n (void *) VFIO_SPAPR_TCE_IOMMU);\n\n if (ret != 1) {\n\n error_setg_errno(errp, -ret,\n\n \"spapr-vfio: SPAPR extension is not supported\");\n\n return;\n\n }\n\n\n\n ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,\n\n VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);\n\n if (ret) {\n\n error_setg_errno(errp, -ret,\n\n \"spapr-vfio: get info from container failed\");\n\n return;\n\n }\n\n\n\n tcet = spapr_tce_new_table(DEVICE(sphb), liobn, info.dma32_window_start,\n\n SPAPR_TCE_PAGE_SHIFT,\n\n info.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT,\n\n true);\n\n if (!tcet) {\n\n error_setg(errp, \"spapr-vfio: failed to create VFIO TCE table\");\n\n return;\n\n }\n\n\n\n /* Register default 32bit DMA window */\n\n memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset,\n\n spapr_tce_get_iommu(tcet));\n\n}\n", + "output": "1", + "index": 10780 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t helper_st_virt_to_phys (uint64_t virtaddr)\n\n{\n\n uint64_t tlb_addr, physaddr;\n\n int index, mmu_idx;\n\n void *retaddr;\n\n\n\n mmu_idx = cpu_mmu_index(env);\n\n index = (virtaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);\n\n redo:\n\n tlb_addr = env->tlb_table[mmu_idx][index].addr_write;\n\n if ((virtaddr & TARGET_PAGE_MASK) ==\n\n (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) {\n\n physaddr = virtaddr + env->tlb_table[mmu_idx][index].addend;\n\n } else {\n\n /* the page is not in the TLB : fill it */\n\n retaddr = GETPC();\n\n tlb_fill(virtaddr, 1, mmu_idx, retaddr);\n\n goto redo;\n\n }\n\n return physaddr;\n\n}\n", + "output": "0", + "index": 565 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void clear_blocks_dcbz32_ppc(DCTELEM *blocks)\n\n{\n\nPOWERPC_TBL_DECLARE(powerpc_clear_blocks_dcbz32, 1);\n\n register int misal = ((unsigned long)blocks & 0x00000010);\n\n register int i = 0;\n\nPOWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1);\n\n#if 1\n\n if (misal) {\n\n ((unsigned long*)blocks)[0] = 0L;\n\n ((unsigned long*)blocks)[1] = 0L;\n\n ((unsigned long*)blocks)[2] = 0L;\n\n ((unsigned long*)blocks)[3] = 0L;\n\n i += 16;\n\n }\n\n for ( ; i < sizeof(DCTELEM)*6*64 ; i += 32) {\n\n asm volatile(\"dcbz %0,%1\" : : \"b\" (blocks), \"r\" (i) : \"memory\");\n\n }\n\n if (misal) {\n\n ((unsigned long*)blocks)[188] = 0L;\n\n ((unsigned long*)blocks)[189] = 0L;\n\n ((unsigned long*)blocks)[190] = 0L;\n\n ((unsigned long*)blocks)[191] = 0L;\n\n i += 16;\n\n }\n\n#else\n\n memset(blocks, 0, sizeof(DCTELEM)*6*64);\n\n#endif\n\nPOWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1);\n\n}\n", + "output": "0", + "index": 3787 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int dnxhd_decode_init_thread_copy(AVCodecContext *avctx)\n\n{\n\n DNXHDContext *ctx = avctx->priv_data;\n\n\n\n\n // make sure VLC tables will be loaded when cid is parsed\n\n ctx->cid = -1;\n\n\n\n ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext));\n\n if (!ctx->rows)\n\n return AVERROR(ENOMEM);\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 5422 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static hwaddr get_offset(hwaddr phys_addr,\n\n DumpState *s)\n\n{\n\n RAMBlock *block;\n\n hwaddr offset = s->memory_offset;\n\n int64_t size_in_block, start;\n\n\n\n if (s->has_filter) {\n\n if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {\n\n return -1;\n\n }\n\n }\n\n\n\n QTAILQ_FOREACH(block, &ram_list.blocks, next) {\n\n if (s->has_filter) {\n\n if (block->offset >= s->begin + s->length ||\n\n block->offset + block->length <= s->begin) {\n\n /* This block is out of the range */\n\n continue;\n\n }\n\n\n\n if (s->begin <= block->offset) {\n\n start = block->offset;\n\n } else {\n\n start = s->begin;\n\n }\n\n\n\n size_in_block = block->length - (start - block->offset);\n\n if (s->begin + s->length < block->offset + block->length) {\n\n size_in_block -= block->offset + block->length -\n\n (s->begin + s->length);\n\n }\n\n } else {\n\n start = block->offset;\n\n size_in_block = block->length;\n\n }\n\n\n\n if (phys_addr >= start && phys_addr < start + size_in_block) {\n\n return phys_addr - start + offset;\n\n }\n\n\n\n offset += size_in_block;\n\n }\n\n\n\n return -1;\n\n}\n", + "output": "0", + "index": 2902 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int test_vector_dmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,\n\n const double *v1, const double *src0, double scale)\n\n{\n\n LOCAL_ALIGNED(32, double, cdst, [LEN]);\n\n LOCAL_ALIGNED(32, double, odst, [LEN]);\n\n int ret;\n\n\n\n memcpy(cdst, v1, LEN * sizeof(*v1));\n\n memcpy(odst, v1, LEN * sizeof(*v1));\n\n\n\n cdsp->vector_dmac_scalar(cdst, src0, scale, LEN);\n\n fdsp->vector_dmac_scalar(odst, src0, scale, LEN);\n\n\n\n if (ret = compare_doubles(cdst, odst, LEN, ARBITRARY_DMAC_SCALAR_CONST))\n\n av_log(NULL, AV_LOG_ERROR, \"vector_dmac_scalar failed\\n\");\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 9103 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)\n\n{\n\n QEDCheck check = {\n\n .s = s,\n\n .result = result,\n\n .nclusters = qed_bytes_to_clusters(s, s->file_size),\n\n .request = { .l2_table = NULL },\n\n .fix = fix,\n\n };\n\n int ret;\n\n\n\n check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *\n\n sizeof(check.used_clusters[0]));\n\n if (check.nclusters && check.used_clusters == NULL) {\n\n return -ENOMEM;\n\n }\n\n\n\n check.result->bfi.total_clusters =\n\n (s->header.image_size + s->header.cluster_size - 1) /\n\n s->header.cluster_size;\n\n ret = qed_check_l1_table(&check, s->l1_table);\n\n if (ret == 0) {\n\n /* Only check for leaks if entire image was scanned successfully */\n\n qed_check_for_leaks(&check);\n\n\n\n if (fix) {\n\n qed_check_mark_clean(s, result);\n\n }\n\n }\n\n\n\n g_free(check.used_clusters);\n\n return ret;\n\n}\n", + "output": "1", + "index": 24667 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_string(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n char *res = NULL, *value = (char *) \"Q E M U\";\n\n Visitor *v;\n\n\n\n v = visitor_input_test_init(data, \"%s\", value);\n\n\n\n visit_type_str(v, NULL, &res, &error_abort);\n\n g_assert_cmpstr(res, ==, value);\n\n\n\n g_free(res);\n\n}\n", + "output": "0", + "index": 26874 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mm_decode_pal(MmContext *s)\n\n{\n\n int i;\n\n\n\n bytestream2_skip(&s->gb, 4);\n\n for (i = 0; i < 128; i++) {\n\n s->palette[i] = 0xFF << 24 | bytestream2_get_be24(&s->gb);\n\n s->palette[i+128] = s->palette[i]<<2;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 6718 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_boot_set(const char *boot_order, Error **errp)\n\n{\n\n Error *local_err = NULL;\n\n\n\n if (!boot_set_handler) {\n\n error_setg(errp, \"no function defined to set boot device list for\"\n\n \" this architecture\");\n\n return;\n\n }\n\n\n\n validate_bootdevices(boot_order, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n if (boot_set_handler(boot_set_opaque, boot_order)) {\n\n error_setg(errp, \"setting boot device list failed\");\n\n return;\n\n }\n\n}\n", + "output": "0", + "index": 22180 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel)\n\n{\n\n BusChild *kid, *next;\n\n PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel);\n\n\n\n /* Execute any pending removes during reset */\n\n while (s->acpi_pcihp_pci_status[bsel].down) {\n\n acpi_pcihp_eject_slot(s, bsel, s->acpi_pcihp_pci_status[bsel].down);\n\n }\n\n\n\n s->acpi_pcihp_pci_status[bsel].hotplug_enable = ~0;\n\n s->acpi_pcihp_pci_status[bsel].device_present = 0;\n\n\n\n if (!bus) {\n\n return;\n\n }\n\n QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {\n\n DeviceState *qdev = kid->child;\n\n PCIDevice *pdev = PCI_DEVICE(qdev);\n\n int slot = PCI_SLOT(pdev->devfn);\n\n\n\n if (acpi_pcihp_pc_no_hotplug(s, pdev)) {\n\n s->acpi_pcihp_pci_status[bsel].hotplug_enable &= ~(1U << slot);\n\n }\n\n\n\n s->acpi_pcihp_pci_status[bsel].device_present |= (1U << slot);\n\n }\n\n}\n", + "output": "0", + "index": 1567 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "unsigned int qemu_get_be16(QEMUFile *f)\n\n{\n\n unsigned int v;\n\n v = qemu_get_byte(f) << 8;\n\n v |= qemu_get_byte(f);\n\n return v;\n\n}\n", + "output": "1", + "index": 10466 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ioapic_class_init(ObjectClass *klass, void *data)\n\n{\n\n IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass);\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n k->realize = ioapic_realize;\n\n\n * If APIC is in kernel, we need to update the kernel cache after\n\n * migration, otherwise first 24 gsi routes will be invalid.\n\n\n k->post_load = ioapic_update_kvm_routes;\n\n dc->reset = ioapic_reset_common;\n\n dc->props = ioapic_properties;\n\n\n\n\n\n\n}", + "output": "1", + "index": 20269 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)\n\n{\n\n int num;\n\n if (!s->config || !s->enable)\n\n return 0;\n\n num = CMD(next_cmd) - CMD(stop);\n\n if (num < 0)\n\n num += CMD(max) - CMD(min);\n\n return num >> 2;\n\n}\n", + "output": "0", + "index": 9057 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_exts(int ot, TCGv reg)\n\n{\n\n switch(ot) {\n\n case OT_BYTE:\n\n tcg_gen_ext8s_tl(reg, reg);\n\n break;\n\n case OT_WORD:\n\n tcg_gen_ext16s_tl(reg, reg);\n\n break;\n\n case OT_LONG:\n\n tcg_gen_ext32s_tl(reg, reg);\n\n break;\n\n default:\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 20299 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void clear_blocks_dcbz128_ppc(DCTELEM *blocks)\n\n{\n\nPOWERPC_TBL_DECLARE(powerpc_clear_blocks_dcbz128, 1);\n\n register int misal = ((unsigned long)blocks & 0x0000007f);\n\n register int i = 0;\n\nPOWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz128, 1);\n\n#if 1\n\n if (misal) {\n\n // we could probably also optimize this case,\n\n // but there's not much point as the machines\n\n // aren't available yet (2003-06-26)\n\n memset(blocks, 0, sizeof(DCTELEM)*6*64);\n\n }\n\n else\n\n for ( ; i < sizeof(DCTELEM)*6*64 ; i += 128) {\n\n\tasm volatile(\"dcbzl %0,%1\" : : \"b\" (blocks), \"r\" (i) : \"memory\");\n\n }\n\n#else\n\n memset(blocks, 0, sizeof(DCTELEM)*6*64);\n\n#endif\n\nPOWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz128, 1);\n\n}\n", + "output": "0", + "index": 21688 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *qdist_pr(const struct qdist *dist, size_t n_bins, uint32_t opt)\n\n{\n\n const char *border = opt & QDIST_PR_BORDER ? \"|\" : \"\";\n\n char *llabel, *rlabel;\n\n char *hgram;\n\n GString *s;\n\n\n\n if (dist->n == 0) {\n\n return NULL;\n\n }\n\n\n\n s = g_string_new(\"\");\n\n\n\n llabel = qdist_pr_label(dist, n_bins, opt, true);\n\n rlabel = qdist_pr_label(dist, n_bins, opt, false);\n\n hgram = qdist_pr_plain(dist, n_bins);\n\n g_string_append_printf(s, \"%s%s%s%s%s\",\n\n llabel, border, hgram, border, rlabel);\n\n g_free(llabel);\n\n g_free(rlabel);\n\n g_free(hgram);\n\n\n\n return g_string_free(s, FALSE);\n\n}\n", + "output": "1", + "index": 426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ohci_bus_stop(OHCIState *ohci)\n\n{\n\n trace_usb_ohci_stop(ohci->name);\n\n if (ohci->eof_timer) {\n\n timer_del(ohci->eof_timer);\n\n timer_free(ohci->eof_timer);\n\n }\n\n ohci->eof_timer = NULL;\n\n}\n", + "output": "1", + "index": 11091 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "VirtIOSCSIReq *virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq)\n\n{\n\n VirtIOSCSIReq *req;\n\n VirtIOSCSICommon *vs = (VirtIOSCSICommon *)s;\n\n const size_t zero_skip = offsetof(VirtIOSCSIReq, vring);\n\n\n\n req = g_malloc(sizeof(*req) + vs->cdb_size);\n\n req->vq = vq;\n\n req->dev = s;\n\n qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);\n\n qemu_iovec_init(&req->resp_iov, 1);\n\n memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);\n\n return req;\n\n}\n", + "output": "0", + "index": 23927 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pm_write_config(PCIDevice *d,\n\n uint32_t address, uint32_t val, int len)\n\n{\n\n DPRINTF(\"pm_write_config address 0x%x val 0x%x len 0x%x \\n\",\n\n address, val, len);\n\n pci_default_write_config(d, address, val, len);\n\n}\n", + "output": "0", + "index": 20442 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_acelp_weighted_filter(\n\n int16_t *out,\n\n const int16_t* in,\n\n const int16_t *weight_pow,\n\n int filter_length)\n\n{\n\n int n;\n\n for(n=0; n> 15; /* (3.12) = (0.15) * (3.12) with rounding */\n\n}\n", + "output": "0", + "index": 22946 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_POWER_maskg (void)\n\n{\n\n uint32_t ret;\n\n\n\n if ((uint32_t)T0 == (uint32_t)(T1 + 1)) {\n\n ret = -1;\n\n } else {\n\n ret = (((uint32_t)(-1)) >> ((uint32_t)T0)) ^\n\n (((uint32_t)(-1) >> ((uint32_t)T1)) >> 1);\n\n if ((uint32_t)T0 > (uint32_t)T1)\n\n ret = ~ret;\n\n }\n\n T0 = ret;\n\n}\n", + "output": "1", + "index": 686 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_read_tbu(DisasContext *ctx, int gprn, int sprn)\n\n{\n\n if (ctx->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_helper_load_tbu(cpu_gpr[gprn], cpu_env);\n\n if (ctx->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n gen_stop_exception(ctx);\n\n }\n\n}\n", + "output": "1", + "index": 18484 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n int ret, size;\n\n\n\n size= RAW_SAMPLES*s->streams[0]->codec->block_align;\n\n if (size <= 0)\n\n return AVERROR(EINVAL);\n\n\n\n ret= av_get_packet(s->pb, pkt, size);\n\n\n\n pkt->flags &= ~AV_PKT_FLAG_CORRUPT;\n\n pkt->stream_index = 0;\n\n if (ret < 0)\n\n return ret;\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 24372 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void get_sel_entry(IPMIBmcSim *ibs,\n\n uint8_t *cmd, unsigned int cmd_len,\n\n uint8_t *rsp, unsigned int *rsp_len,\n\n unsigned int max_rsp_len)\n\n{\n\n unsigned int val;\n\n\n\n IPMI_CHECK_CMD_LEN(8);\n\n if (cmd[6]) {\n\n IPMI_CHECK_RESERVATION(2, ibs->sel.reservation);\n\n }\n\n if (ibs->sel.next_free == 0) {\n\n rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;\n\n return;\n\n }\n\n if (cmd[6] > 15) {\n\n rsp[2] = IPMI_CC_INVALID_DATA_FIELD;\n\n return;\n\n }\n\n if (cmd[7] == 0xff) {\n\n cmd[7] = 16;\n\n } else if ((cmd[7] + cmd[6]) > 16) {\n\n rsp[2] = IPMI_CC_INVALID_DATA_FIELD;\n\n return;\n\n } else {\n\n cmd[7] += cmd[6];\n\n }\n\n\n\n val = cmd[4] | (cmd[5] << 8);\n\n if (val == 0xffff) {\n\n val = ibs->sel.next_free - 1;\n\n } else if (val >= ibs->sel.next_free) {\n\n rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;\n\n return;\n\n }\n\n if ((val + 1) == ibs->sel.next_free) {\n\n IPMI_ADD_RSP_DATA(0xff);\n\n IPMI_ADD_RSP_DATA(0xff);\n\n } else {\n\n IPMI_ADD_RSP_DATA((val + 1) & 0xff);\n\n IPMI_ADD_RSP_DATA(((val + 1) >> 8) & 0xff);\n\n }\n\n for (; cmd[6] < cmd[7]; cmd[6]++) {\n\n IPMI_ADD_RSP_DATA(ibs->sel.sel[val][cmd[6]]);\n\n }\n\n}\n", + "output": "1", + "index": 11213 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static AVStream * init_stream(AVFormatContext *s)\n\n{\n\n BinDemuxContext *bin = s->priv_data;\n\n AVStream *st = avformat_new_stream(s, NULL);\n\n if (!st)\n\n return NULL;\n\n st->codec->codec_tag = 0;\n\n st->codec->codec_type = AVMEDIA_TYPE_VIDEO;\n\n\n\n if (!bin->width) {\n\n st->codec->width = (80<<3);\n\n st->codec->height = (25<<4);\n\n }\n\n\n\n avpriv_set_pts_info(st, 60, bin->framerate.den, bin->framerate.num);\n\n\n\n /* simulate tty display speed */\n\n bin->chars_per_frame = FFMAX(av_q2d(st->time_base) * bin->chars_per_frame, 1);\n\n\n\n return st;\n\n}\n", + "output": "1", + "index": 767 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,\n\n int cpuid, void *opaque)\n\n{\n\n struct arm_note note;\n\n CPUARMState *env = &ARM_CPU(cs)->env;\n\n DumpState *s = opaque;\n\n int ret, i;\n\n\n\n arm_note_init(¬e, s, \"CORE\", 5, NT_PRSTATUS, sizeof(note.prstatus));\n\n\n\n note.prstatus.pr_pid = cpu_to_dump32(s, cpuid);\n\n\n\n for (i = 0; i < 16; ++i) {\n\n note.prstatus.pr_reg.regs[i] = cpu_to_dump32(s, env->regs[i]);\n\n }\n\n note.prstatus.pr_reg.regs[16] = cpu_to_dump32(s, cpsr_read(env));\n\n\n\n ret = f(¬e, ARM_PRSTATUS_NOTE_SIZE, s);\n\n if (ret < 0) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15485 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vfio_add_capabilities(VFIOPCIDevice *vdev)\n\n{\n\n PCIDevice *pdev = &vdev->pdev;\n\n int ret;\n\n\n\n if (!(pdev->config[PCI_STATUS] & PCI_STATUS_CAP_LIST) ||\n\n !pdev->config[PCI_CAPABILITY_LIST]) {\n\n return 0; /* Nothing to add */\n\n }\n\n\n\n ret = vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST]);\n\n if (ret) {\n\n return ret;\n\n }\n\n\n\n /* on PCI bus, it doesn't make sense to expose extended capabilities. */\n\n if (!pci_is_express(pdev) ||\n\n !pci_bus_is_express(pdev->bus) ||\n\n !pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) {\n\n return 0;\n\n }\n\n\n\n return vfio_add_ext_cap(vdev);\n\n}\n", + "output": "0", + "index": 15447 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_request_exit(void *opaque, int irq, int level)\n\n{\n\n CPUState *cpu = current_cpu;\n\n\n\n if (cpu && level) {\n\n cpu_exit(cpu);\n\n }\n\n}\n", + "output": "0", + "index": 3642 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxb_dev_exitfn(PCIDevice *pci_dev)\n\n{\n\n PXBDev *pxb = PXB_DEV(pci_dev);\n\n\n\n pxb_dev_list = g_list_remove(pxb_dev_list, pxb);\n\n}\n", + "output": "0", + "index": 12770 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_int32_equal(QEMUFile *f, void *pv, size_t size,\n\n VMStateField *field)\n\n{\n\n int32_t *v = pv;\n\n int32_t v2;\n\n qemu_get_sbe32s(f, &v2);\n\n\n\n if (*v == v2) {\n\n return 0;\n\n\n error_report(\"%\" PRIx32 \" != %\" PRIx32, *v, v2);\n\n\n\n\n return -EINVAL;\n", + "output": "1", + "index": 16427 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void send_qmp_error_event(BlockDriverState *bs,\n\n BlockErrorAction action,\n\n bool is_read, int error)\n\n{\n\n IoOperationType optype;\n\n\n\n optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;\n\n qapi_event_send_block_io_error(bdrv_get_device_name(bs), optype, action,\n\n bdrv_iostatus_is_enabled(bs),\n\n error == ENOSPC, strerror(error),\n\n &error_abort);\n\n}\n", + "output": "0", + "index": 27015 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,\n\n int *header_len, AVDictionary **m, int framing_bit)\n\n{\n\n const char *vendor = bitexact ? \"ffmpeg\" : LIBAVFORMAT_IDENT;\n\n int size;\n\n uint8_t *p, *p0;\n\n\n\n ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);\n\n\n\n size = offset + ff_vorbiscomment_length(*m, vendor) + framing_bit;\n\n p = av_mallocz(size);\n\n if (!p)\n\n return NULL;\n\n p0 = p;\n\n\n\n p += offset;\n\n ff_vorbiscomment_write(&p, m, vendor);\n\n if (framing_bit)\n\n bytestream_put_byte(&p, 1);\n\n\n\n *header_len = size;\n\n return p0;\n\n}\n", + "output": "0", + "index": 3406 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)\n\n{\n\n int64_t value;\n\n if (!error_is_set(errp)) {\n\n if (v->type_uint64) {\n\n v->type_uint64(v, obj, name, errp);\n\n } else {\n\n value = *obj;\n\n v->type_int(v, &value, name, errp);\n\n *obj = value;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 5424 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool ranges_can_merge(Range *range1, Range *range2)\n\n{\n\n return !(range1->end < range2->begin || range2->end < range1->begin);\n\n}\n", + "output": "1", + "index": 20604 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SDState *sd_init(BlockBackend *blk, bool is_spi)\n\n{\n\n SDState *sd;\n\n\n\n if (blk && blk_is_read_only(blk)) {\n\n fprintf(stderr, \"sd_init: Cannot use read-only drive\\n\");\n\n return NULL;\n\n }\n\n\n\n sd = (SDState *) g_malloc0(sizeof(SDState));\n\n sd->buf = blk_blockalign(blk, 512);\n\n sd->spi = is_spi;\n\n sd->enable = true;\n\n sd_reset(sd, blk);\n\n if (sd->blk) {\n\n blk_attach_dev_nofail(sd->blk, sd);\n\n blk_set_dev_ops(sd->blk, &sd_block_ops, sd);\n\n }\n\n vmstate_register(NULL, -1, &sd_vmstate, sd);\n\n return sd;\n\n}\n", + "output": "0", + "index": 15041 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ioapic_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val,\n\n unsigned int size)\n\n{\n\n IOAPICCommonState *s = opaque;\n\n int index;\n\n\n\n switch (addr & 0xff) {\n\n case IOAPIC_IOREGSEL:\n\n s->ioregsel = val;\n\n break;\n\n case IOAPIC_IOWIN:\n\n if (size != 4) {\n\n break;\n\n }\n\n DPRINTF(\"write: %08x = %08\" PRIx64 \"\\n\", s->ioregsel, val);\n\n switch (s->ioregsel) {\n\n case IOAPIC_REG_ID:\n\n s->id = (val >> IOAPIC_ID_SHIFT) & IOAPIC_ID_MASK;\n\n break;\n\n case IOAPIC_REG_VER:\n\n case IOAPIC_REG_ARB:\n\n break;\n\n default:\n\n index = (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1;\n\n if (index >= 0 && index < IOAPIC_NUM_PINS) {\n\n if (s->ioregsel & 1) {\n\n s->ioredtbl[index] &= 0xffffffff;\n\n s->ioredtbl[index] |= (uint64_t)val << 32;\n\n } else {\n\n s->ioredtbl[index] &= ~0xffffffffULL;\n\n s->ioredtbl[index] |= val;\n\n }\n\n ioapic_service(s);\n\n }\n\n }\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 15350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_spr_power5p_lpar(CPUPPCState *env)\n\n{\n\n#if !defined(CONFIG_USER_ONLY)\n\n /* Logical partitionning */\n\n spr_register_kvm(env, SPR_LPCR, \"LPCR\",\n\n\n &spr_read_generic, &spr_write_lpcr,\n\n KVM_REG_PPC_LPCR, LPCR_LPES0 | LPCR_LPES1);\n\n\n\n\n\n#endif\n\n}", + "output": "1", + "index": 12059 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t eepro100_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n EEPRO100State *s = opaque;\n\n\n\n switch (size) {\n\n case 1: return eepro100_read1(s, addr);\n\n case 2: return eepro100_read2(s, addr);\n\n case 4: return eepro100_read4(s, addr);\n\n default: abort();\n\n }\n\n}\n", + "output": "0", + "index": 13155 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_physical (CPUState *env, mmu_ctx_t *ctx,\n\n target_ulong eaddr, int rw)\n\n{\n\n int in_plb, ret;\n\n\n\n ctx->raddr = eaddr;\n\n ctx->prot = PAGE_READ;\n\n ret = 0;\n\n switch (env->mmu_model) {\n\n case POWERPC_MMU_32B:\n\n case POWERPC_MMU_SOFT_6xx:\n\n case POWERPC_MMU_SOFT_74xx:\n\n case POWERPC_MMU_SOFT_4xx:\n\n case POWERPC_MMU_REAL_4xx:\n\n case POWERPC_MMU_BOOKE:\n\n ctx->prot |= PAGE_WRITE;\n\n break;\n\n#if defined(TARGET_PPC64)\n\n case POWERPC_MMU_64B:\n\n /* Real address are 60 bits long */\n\n ctx->raddr &= 0x0FFFFFFFFFFFFFFFULL;\n\n ctx->prot |= PAGE_WRITE;\n\n break;\n\n#endif\n\n case POWERPC_MMU_SOFT_4xx_Z:\n\n if (unlikely(msr_pe != 0)) {\n\n /* 403 family add some particular protections,\n\n * using PBL/PBU registers for accesses with no translation.\n\n */\n\n in_plb =\n\n /* Check PLB validity */\n\n (env->pb[0] < env->pb[1] &&\n\n /* and address in plb area */\n\n eaddr >= env->pb[0] && eaddr < env->pb[1]) ||\n\n (env->pb[2] < env->pb[3] &&\n\n eaddr >= env->pb[2] && eaddr < env->pb[3]) ? 1 : 0;\n\n if (in_plb ^ msr_px) {\n\n /* Access in protected area */\n\n if (rw == 1) {\n\n /* Access is not allowed */\n\n ret = -2;\n\n }\n\n } else {\n\n /* Read-write access is allowed */\n\n ctx->prot |= PAGE_WRITE;\n\n }\n\n }\n\n break;\n\n case POWERPC_MMU_BOOKE_FSL:\n\n /* XXX: TODO */\n\n cpu_abort(env, \"BookE FSL MMU model not implemented\\n\");\n\n break;\n\n default:\n\n cpu_abort(env, \"Unknown or invalid MMU model\\n\");\n\n return -1;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 8634 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_log_stop(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n int r;\n\n\n\n r = kvm_dirty_pages_log_change(section->offset_within_address_space,\n\n int128_get64(section->size), false);\n\n if (r < 0) {\n\n abort();\n\n }\n\n}\n", + "output": "0", + "index": 14707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_serial_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);\n\n\n\n k->init = virtio_serial_init_pci;\n\n k->exit = virtio_serial_exit_pci;\n\n k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;\n\n k->device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE;\n\n k->revision = VIRTIO_PCI_ABI_VERSION;\n\n k->class_id = PCI_CLASS_COMMUNICATION_OTHER;\n\n dc->alias = \"virtio-serial\";\n\n dc->reset = virtio_pci_reset;\n\n dc->props = virtio_serial_properties;\n\n}\n", + "output": "0", + "index": 14117 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm,\n\n unsigned facs, unsigned dsdt,\n\n const char *oem_id, const char *oem_table_id)\n\n{\n\n AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt));\n\n\n\n fadt->firmware_ctrl = cpu_to_le32(facs);\n\n /* FACS address to be filled by Guest linker */\n\n bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,\n\n ACPI_BUILD_TABLE_FILE,\n\n &fadt->firmware_ctrl,\n\n sizeof fadt->firmware_ctrl);\n\n\n\n fadt->dsdt = cpu_to_le32(dsdt);\n\n /* DSDT address to be filled by Guest linker */\n\n bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,\n\n ACPI_BUILD_TABLE_FILE,\n\n &fadt->dsdt,\n\n sizeof fadt->dsdt);\n\n\n\n fadt_setup(fadt, pm);\n\n\n\n build_header(linker, table_data,\n\n (void *)fadt, \"FACP\", sizeof(*fadt), 1, oem_id, oem_table_id);\n\n}\n", + "output": "0", + "index": 8933 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int css_do_xsch(SubchDev *sch)\n\n{\n\n SCSW *s = &sch->curr_status.scsw;\n\n PMCW *p = &sch->curr_status.pmcw;\n\n int ret;\n\n\n\n if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) {\n\n ret = -ENODEV;\n\n goto out;\n\n }\n\n\n\n if (!(s->ctrl & SCSW_CTRL_MASK_FCTL) ||\n\n ((s->ctrl & SCSW_CTRL_MASK_FCTL) != SCSW_FCTL_START_FUNC) ||\n\n (!(s->ctrl &\n\n (SCSW_ACTL_RESUME_PEND | SCSW_ACTL_START_PEND | SCSW_ACTL_SUSP))) ||\n\n (s->ctrl & SCSW_ACTL_SUBCH_ACTIVE)) {\n\n ret = -EINPROGRESS;\n\n goto out;\n\n }\n\n\n\n if (s->ctrl & SCSW_CTRL_MASK_STCTL) {\n\n ret = -EBUSY;\n\n goto out;\n\n }\n\n\n\n /* Cancel the current operation. */\n\n s->ctrl &= ~(SCSW_FCTL_START_FUNC |\n\n SCSW_ACTL_RESUME_PEND |\n\n SCSW_ACTL_START_PEND |\n\n SCSW_ACTL_SUSP);\n\n sch->channel_prog = 0x0;\n\n sch->last_cmd_valid = false;\n\n s->dstat = 0;\n\n s->cstat = 0;\n\n ret = 0;\n\n\n\nout:\n\n return ret;\n\n}\n", + "output": "0", + "index": 17651 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_set_options_string(void *ctx, const char *opts,\n\n const char *key_val_sep, const char *pairs_sep)\n\n{\n\n int ret, count = 0;\n\n\n\n\n\n while (*opts) {\n\n if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0)\n\n return ret;\n\n count++;\n\n\n\n if (*opts)\n\n opts++;\n\n }\n\n\n\n return count;\n\n}", + "output": "1", + "index": 2576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int buf_put_buffer(void *opaque, const uint8_t *buf,\n\n int64_t pos, int size)\n\n{\n\n QEMUBuffer *s = opaque;\n\n\n\n return qsb_write_at(s->qsb, buf, pos, size);\n\n}\n", + "output": "1", + "index": 13996 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_exitfn(PCIDevice *pdev)\n\n{\n\n VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);\n\n VFIOGroup *group = vdev->vbasedev.group;\n\n\n\n vfio_unregister_err_notifier(vdev);\n\n pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);\n\n vfio_disable_interrupts(vdev);\n\n if (vdev->intx.mmap_timer) {\n\n timer_free(vdev->intx.mmap_timer);\n\n }\n\n vfio_teardown_msi(vdev);\n\n vfio_unmap_bars(vdev);\n\n g_free(vdev->emulated_config_bits);\n\n g_free(vdev->rom);\n\n vfio_put_device(vdev);\n\n vfio_put_group(group);\n\n}\n", + "output": "1", + "index": 23253 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fd_coroutine_enter(void *opaque)\n\n{\n\n FDYieldUntilData *data = opaque;\n\n qemu_set_fd_handler(data->fd, NULL, NULL, NULL);\n\n qemu_coroutine_enter(data->co, NULL);\n\n}\n", + "output": "1", + "index": 7893 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void fd_start_incoming_migration(const char *infd, Error **errp)\n\n{\n\n int fd;\n\n QEMUFile *f;\n\n\n\n DPRINTF(\"Attempting to start an incoming migration via fd\\n\");\n\n\n\n fd = strtol(infd, NULL, 0);\n\n f = qemu_fdopen(fd, \"rb\");\n\n if(f == NULL) {\n\n error_setg_errno(errp, errno, \"failed to open the source descriptor\");\n\n return;\n\n }\n\n\n\n qemu_set_fd_handler2(fd, NULL, fd_accept_incoming_migration, NULL, f);\n\n}\n", + "output": "1", + "index": 19992 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_net_has_buffers(VirtIONet *n, int bufsize)\n\n{\n\n if (virtio_queue_empty(n->rx_vq) ||\n\n (n->mergeable_rx_bufs &&\n\n !virtqueue_avail_bytes(n->rx_vq, bufsize, 0))) {\n\n virtio_queue_set_notification(n->rx_vq, 1);\n\n return 0;\n\n }\n\n\n\n virtio_queue_set_notification(n->rx_vq, 0);\n\n return 1;\n\n}\n", + "output": "1", + "index": 26516 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf, int size)\n\n{\n\n GetBitContext gb;\n\n\n\n init_get_bits(&gb, buf, size * 8);\n\n adts->objecttype = get_bits(&gb, 5) - 1;\n\n adts->sample_rate_index = get_bits(&gb, 4);\n\n adts->channel_conf = get_bits(&gb, 4);\n\n\n\n if (adts->objecttype > 3) {\n\n av_log(s, AV_LOG_ERROR, \"MPEG-4 AOT %d is not allowed in ADTS\\n\", adts->objecttype);\n\n return -1;\n\n }\n\n if (adts->sample_rate_index == 15) {\n\n av_log(s, AV_LOG_ERROR, \"Escape sample rate index illegal in ADTS\\n\");\n\n return -1;\n\n }\n\n if (adts->channel_conf == 0) {\n\n ff_log_missing_feature(s, \"PCE based channel configuration\", 0);\n\n return -1;\n\n }\n\n\n\n adts->write_adts = 1;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void jpeg2000_flush(Jpeg2000DecoderContext *s)\n\n{\n\n if (*s->buf == 0xff)\n\n s->buf++;\n\n s->bit_index = 8;\n\n s->buf++;\n\n}\n", + "output": "1", + "index": 19813 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_POWER_srea (void)\n\n{\n\n T1 &= 0x1FUL;\n\n env->spr[SPR_MQ] = T0 >> T1;\n\n T0 = Ts0 >> T1;\n\n RETURN();\n\n}\n", + "output": "1", + "index": 6428 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t esp_pci_io_read(void *opaque, target_phys_addr_t addr,\n\n unsigned int size)\n\n{\n\n PCIESPState *pci = opaque;\n\n uint32_t ret;\n\n\n\n if (addr < 0x40) {\n\n /* SCSI core reg */\n\n ret = esp_reg_read(&pci->esp, addr >> 2);\n\n } else if (addr < 0x60) {\n\n /* PCI DMA CCB */\n\n ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2);\n\n } else if (addr == 0x70) {\n\n /* DMA SCSI Bus and control */\n\n trace_esp_pci_sbac_read(pci->sbac);\n\n ret = pci->sbac;\n\n } else {\n\n /* Invalid region */\n\n trace_esp_pci_error_invalid_read((int)addr);\n\n ret = 0;\n\n }\n\n\n\n /* give only requested data */\n\n ret >>= (addr & 3) * 8;\n\n ret &= ~(~(uint64_t)0 << (8 * size));\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 4487 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vmxnet3_dump_tx_descr(struct Vmxnet3_TxDesc *descr)\n\n{\n\n VMW_PKPRN(\"TX DESCR: \"\n\n \"addr %\" PRIx64 \", len: %d, gen: %d, rsvd: %d, \"\n\n \"dtype: %d, ext1: %d, msscof: %d, hlen: %d, om: %d, \"\n\n \"eop: %d, cq: %d, ext2: %d, ti: %d, tci: %d\",\n\n le64_to_cpu(descr->addr), descr->len, descr->gen, descr->rsvd,\n\n descr->dtype, descr->ext1, descr->msscof, descr->hlen, descr->om,\n\n descr->eop, descr->cq, descr->ext2, descr->ti, descr->tci);\n\n}\n", + "output": "1", + "index": 21334 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int irq_cpu_hotplug_init(SCLPEvent *event)\n\n{\n\n irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);\n\n return 0;\n\n}\n", + "output": "1", + "index": 18289 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void float_to_int16_stride_altivec(int16_t *dst, const float *src,\n\n long len, int stride)\n\n{\n\n int i, j;\n\n vector signed short d, s;\n\n\n\n for (i = 0; i < len - 7; i += 8) {\n\n d = float_to_int16_one_altivec(src + i);\n\n for (j = 0; j < 8; j++) {\n\n s = vec_splat(d, j);\n\n vec_ste(s, 0, dst);\n\n dst += stride;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 9517 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_device_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *k = DEVICE_CLASS(klass);\n\n set_bit(DEVICE_CATEGORY_STORAGE, k->categories);\n\n k->bus_type = TYPE_SCSI_BUS;\n\n k->init = scsi_qdev_init;\n\n k->unplug = scsi_qdev_unplug;\n\n k->exit = scsi_qdev_exit;\n\n k->props = scsi_props;\n\n}\n", + "output": "0", + "index": 17675 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static always_inline void gen_op_neg (DisasContext *ctx, TCGv ret, TCGv arg1, int ov_check)\n\n{\n\n int l1, l2;\n\n\n\n l1 = gen_new_label();\n\n l2 = gen_new_label();\n\n#if defined(TARGET_PPC64)\n\n if (ctx->sf_mode) {\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, arg1, INT64_MIN, l1);\n\n } else {\n\n TCGv t0 = tcg_temp_new(TCG_TYPE_TL);\n\n\ttcg_gen_ext32s_tl(t0, arg1);\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, t0, INT32_MIN, l1);\n\n }\n\n#else\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, arg1, INT32_MIN, l1);\n\n#endif\n\n tcg_gen_neg_tl(ret, arg1);\n\n if (ov_check) {\n\n tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV));\n\n }\n\n tcg_gen_br(l2);\n\n gen_set_label(l1);\n\n tcg_gen_mov_tl(ret, arg1);\n\n if (ov_check) {\n\n tcg_gen_ori_tl(cpu_xer, cpu_xer, (1 << XER_OV) | (1 << XER_SO));\n\n }\n\n gen_set_label(l2);\n\n if (unlikely(Rc(ctx->opcode) != 0))\n\n gen_set_Rc0(ctx, ret);\n\n}\n", + "output": "1", + "index": 24032 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_float64(QEMUFile *f, void *pv, size_t size)\n\n{\n\n float64 *v = pv;\n\n\n\n *v = make_float64(qemu_get_be64(f));\n\n return 0;\n\n}\n", + "output": "1", + "index": 25503 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_parent_open(BlockDriverState *bs, const char * filename)\n\n{\n\n BDRVVmdkState *s = bs->opaque;\n\n char *p_name; \n\n char desc[DESC_SIZE];\n\n char parent_img_name[1024];\n\n\n\n /* the descriptor offset = 0x200 */\n\n if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)\n\n return -1;\n\n\n\n if ((p_name = strstr(desc,\"parentFileNameHint\")) != 0) {\n\n char *end_name;\n\n struct stat file_buf;\n\n\n\n p_name += sizeof(\"parentFileNameHint\") + 1;\n\n if ((end_name = strchr(p_name,'\\\"')) == 0)\n\n return -1;\n\n \n\n strncpy(s->hd->backing_file, p_name, end_name - p_name);\n\n if (stat(s->hd->backing_file, &file_buf) != 0) {\n\n path_combine(parent_img_name, sizeof(parent_img_name),\n\n filename, s->hd->backing_file);\n\n } else {\n\n strcpy(parent_img_name, s->hd->backing_file);\n\n }\n\n\n\n s->hd->backing_hd = bdrv_new(\"\");\n\n if (!s->hd->backing_hd) {\n\n failure:\n\n bdrv_close(s->hd);\n\n return -1;\n\n }\n\n if (bdrv_open(s->hd->backing_hd, parent_img_name, 0) < 0)\n\n goto failure;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 17947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)\n\n{\n\n int compno;\n\n int x;\n\n int y;\n\n int width;\n\n int height;\n\n int *image_line;\n\n int frame_index;\n\n const int numcomps = image->numcomps;\n\n uint16_t *frame_ptr;\n\n\n\n for (compno = 0; compno < numcomps; ++compno) {\n\n if (image->comps[compno].w > frame->linesize[compno]) {\n\n av_log(avctx, AV_LOG_ERROR, \"Error: frame's linesize is too small for the image\\n\");\n\n return 0;\n\n }\n\n }\n\n\n\n for (compno = 0; compno < numcomps; ++compno) {\n\n width = avctx->width / image->comps[compno].dx;\n\n height = avctx->height / image->comps[compno].dy;\n\n frame_ptr = (uint16_t *)frame->data[compno];\n\n for (y = 0; y < height; ++y) {\n\n image_line = image->comps[compno].data + y * image->comps[compno].w;\n\n frame_index = y * (frame->linesize[compno] / 2);\n\n for (x = 0; x < width; ++x)\n\n image_line[x] = frame_ptr[frame_index++];\n\n for (; x < image->comps[compno].w; ++x) {\n\n image_line[x] = image_line[x - 1];\n\n }\n\n }\n\n for (; y < image->comps[compno].h; ++y) {\n\n image_line = image->comps[compno].data + y * image->comps[compno].w;\n\n for (x = 0; x < image->comps[compno].w; ++x) {\n\n image_line[x] = image_line[x - image->comps[compno].w];\n\n }\n\n }\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 27157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rdma_get_buffer(void *opaque, uint8_t *buf,\n\n int64_t pos, int size)\n\n{\n\n QEMUFileRDMA *r = opaque;\n\n RDMAContext *rdma = r->rdma;\n\n RDMAControlHeader head;\n\n int ret = 0;\n\n\n\n CHECK_ERROR_STATE();\n\n\n\n /*\n\n * First, we hold on to the last SEND message we\n\n * were given and dish out the bytes until we run\n\n * out of bytes.\n\n */\n\n r->len = qemu_rdma_fill(r->rdma, buf, size, 0);\n\n if (r->len) {\n\n return r->len;\n\n }\n\n\n\n /*\n\n * Once we run out, we block and wait for another\n\n * SEND message to arrive.\n\n */\n\n ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FILE);\n\n\n\n if (ret < 0) {\n\n rdma->error_state = ret;\n\n return ret;\n\n }\n\n\n\n /*\n\n * SEND was received with new bytes, now try again.\n\n */\n\n return qemu_rdma_fill(r->rdma, buf, size, 0);\n\n}\n", + "output": "1", + "index": 8336 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void object_set_link_property(Object *obj, Visitor *v, void *opaque,\n\n const char *name, Error **errp)\n\n{\n\n Object **child = opaque;\n\n bool ambiguous = false;\n\n const char *type;\n\n char *path;\n\n\n\n type = object_property_get_type(obj, name, NULL);\n\n\n\n visit_type_str(v, &path, name, errp);\n\n\n\n if (*child) {\n\n object_unref(*child);\n\n }\n\n\n\n if (strcmp(path, \"\") != 0) {\n\n Object *target;\n\n\n\n target = object_resolve_path(path, &ambiguous);\n\n if (target) {\n\n gchar *target_type;\n\n\n\n target_type = g_strdup(&type[5]);\n\n target_type[strlen(target_type) - 2] = 0;\n\n\n\n if (object_dynamic_cast(target, target_type)) {\n\n object_ref(target);\n\n *child = target;\n\n } else {\n\n error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type);\n\n }\n\n\n\n g_free(target_type);\n\n } else {\n\n error_set(errp, QERR_DEVICE_NOT_FOUND, path);\n\n }\n\n } else {\n\n *child = NULL;\n\n }\n\n\n\n g_free(path);\n\n}\n", + "output": "1", + "index": 22832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_write(BlockDriverState *bs, int64_t sector_num,\n\n const uint8_t *buf, int nb_sectors)\n\n{\n\n BDRVVmdkState *s = bs->opaque;\n\n VmdkExtent *extent = NULL;\n\n int n;\n\n int64_t index_in_cluster;\n\n uint64_t cluster_offset;\n\n VmdkMetaData m_data;\n\n\n\n if (sector_num > bs->total_sectors) {\n\n fprintf(stderr,\n\n \"(VMDK) Wrong offset: sector_num=0x%\" PRIx64\n\n \" total_sectors=0x%\" PRIx64 \"\\n\",\n\n sector_num, bs->total_sectors);\n\n return -1;\n\n }\n\n\n\n while (nb_sectors > 0) {\n\n extent = find_extent(s, sector_num, extent);\n\n if (!extent) {\n\n return -EIO;\n\n }\n\n cluster_offset = get_cluster_offset(\n\n bs,\n\n extent,\n\n &m_data,\n\n sector_num << 9, 1);\n\n if (!cluster_offset) {\n\n return -1;\n\n }\n\n index_in_cluster = sector_num % extent->cluster_sectors;\n\n n = extent->cluster_sectors - index_in_cluster;\n\n if (n > nb_sectors) {\n\n n = nb_sectors;\n\n }\n\n\n\n if (bdrv_pwrite(bs->file,\n\n cluster_offset + index_in_cluster * 512,\n\n buf, n * 512)\n\n != n * 512) {\n\n return -1;\n\n }\n\n if (m_data.valid) {\n\n /* update L2 tables */\n\n if (vmdk_L2update(extent, &m_data) == -1) {\n\n return -1;\n\n }\n\n }\n\n nb_sectors -= n;\n\n sector_num += n;\n\n buf += n * 512;\n\n\n\n // update CID on the first write every time the virtual disk is opened\n\n if (!s->cid_updated) {\n\n vmdk_write_cid(bs, time(NULL));\n\n s->cid_updated = true;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(stfl)(CPUS390XState *env)\n\n{\n\n uint64_t words[MAX_STFL_WORDS];\n\n LowCore *lowcore;\n\n\n\n lowcore = cpu_map_lowcore(env);\n\n do_stfle(env, words);\n\n lowcore->stfl_fac_list = cpu_to_be32(words[0] >> 32);\n\n cpu_unmap_lowcore(lowcore);\n\n}\n", + "output": "0", + "index": 5824 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg *args,\n\n TCGArg dst, TCGArg src)\n\n{\n\n if (temps_are_copies(dst, src)) {\n\n tcg_op_remove(s, op);\n\n return;\n\n }\n\n\n\n if (temp_is_const(src)) {\n\n tcg_opt_gen_movi(s, op, args, dst, temps[src].val);\n\n return;\n\n }\n\n\n\n TCGOpcode new_op = op_to_mov(op->opc);\n\n tcg_target_ulong mask;\n\n\n\n op->opc = new_op;\n\n\n\n reset_temp(dst);\n\n mask = temps[src].mask;\n\n if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_mov_i32) {\n\n /* High bits of the destination are now garbage. */\n\n mask |= ~0xffffffffull;\n\n }\n\n temps[dst].mask = mask;\n\n\n\n assert(!temp_is_const(src));\n\n\n\n if (s->temps[src].type == s->temps[dst].type) {\n\n temps[dst].next_copy = temps[src].next_copy;\n\n temps[dst].prev_copy = src;\n\n temps[temps[dst].next_copy].prev_copy = dst;\n\n temps[src].next_copy = dst;\n\n temps[dst].is_const = false;\n\n }\n\n\n\n args[0] = dst;\n\n args[1] = src;\n\n}\n", + "output": "0", + "index": 19492 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_win_path(const char *filename)\n\n{\n\n CharDriverState *chr;\n\n WinCharState *s;\n\n\n\n chr = qemu_chr_alloc();\n\n s = g_malloc0(sizeof(WinCharState));\n\n chr->opaque = s;\n\n chr->chr_write = win_chr_write;\n\n chr->chr_close = win_chr_close;\n\n\n\n if (win_chr_init(chr, filename) < 0) {\n\n g_free(s);\n\n g_free(chr);\n\n return NULL;\n\n }\n\n return chr;\n\n}\n", + "output": "1", + "index": 24118 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t qpci_spapr_io_readw(QPCIBus *bus, void *addr)\n\n{\n\n QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);\n\n uint64_t port = (uintptr_t)addr;\n\n uint16_t v;\n\n if (port < s->pio.size) {\n\n v = readw(s->pio_cpu_base + port);\n\n } else {\n\n v = readw(s->mmio_cpu_base + port);\n\n }\n\n return bswap16(v);\n\n}\n", + "output": "0", + "index": 24054 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QObject *qmp_output_pop(QmpOutputVisitor *qov, void *qapi)\n\n{\n\n QStackEntry *e = QSLIST_FIRST(&qov->stack);\n\n QObject *value;\n\n\n\n assert(e);\n\n assert(e->qapi == qapi);\n\n QSLIST_REMOVE_HEAD(&qov->stack, node);\n\n value = e->value;\n\n assert(value);\n\n g_free(e);\n\n return value;\n\n}\n", + "output": "0", + "index": 19142 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t reloc_pc24_val(tcg_insn_unit *pc, tcg_insn_unit *target)\n\n{\n\n ptrdiff_t disp = tcg_ptr_byte_diff(target, pc);\n\n assert(in_range_b(disp));\n\n return disp & 0x3fffffc;\n\n}\n", + "output": "0", + "index": 15959 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers)\n\n{\n\n unsigned int i;\n\n for (i = 0; i < n_buffers; i++) {\n\n if (buffers[i]) {\n\n vaDestroyBuffer(display, buffers[i]);\n\n buffers[i] = 0;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 13624 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void op_dmfc0_ebase (void)\n\n{\n\n T0 = env->CP0_EBase;\n\n RETURN();\n\n}\n", + "output": "0", + "index": 25170 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNCC(ff_h264_add_pixels4)(uint8_t *_dst, int16_t *_src, int stride)\n\n{\n\n int i;\n\n pixel *dst = (pixel *) _dst;\n\n dctcoef *src = (dctcoef *) _src;\n\n stride /= sizeof(pixel);\n\n\n\n for (i = 0; i < 4; i++) {\n\n dst[0] += src[0];\n\n dst[1] += src[1];\n\n dst[2] += src[2];\n\n dst[3] += src[3];\n\n\n\n dst += stride;\n\n src += 4;\n\n }\n\n\n\n memset(_src, 0, sizeof(dctcoef) * 16);\n\n}\n", + "output": "1", + "index": 26427 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)\n\n{\n\n int i;\n\n uint8_t *row;\n\n\n\n row = ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * ds_get_bytes_per_pixel(vs->ds);\n\n for (i = 0; i < h; i++) {\n\n vs->write_pixels(vs, row, w * ds_get_bytes_per_pixel(vs->ds));\n\n row += ds_get_linesize(vs->ds);\n\n }\n\n}\n", + "output": "1", + "index": 18945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_output_free(Visitor *v)\n\n{\n\n QmpOutputVisitor *qov = to_qov(v);\n\n QStackEntry *e;\n\n\n\n while (!QSLIST_EMPTY(&qov->stack)) {\n\n e = QSLIST_FIRST(&qov->stack);\n\n QSLIST_REMOVE_HEAD(&qov->stack, node);\n\n g_free(e);\n\n }\n\n\n\n qobject_decref(qov->root);\n\n g_free(qov);\n\n}\n", + "output": "0", + "index": 7365 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_long monitor_get_psr (const struct MonitorDef *md, int val)\n\n{\n\n CPUState *env = mon_get_cpu();\n\n if (!env)\n\n return 0;\n\n return GET_PSR(env);\n\n}\n", + "output": "1", + "index": 18078 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void error_propagate(Error **dst_errp, Error *local_err)\n\n{\n\n if (local_err && dst_errp == &error_abort) {\n\n error_report_err(local_err);\n\n abort();\n\n } else if (dst_errp && !*dst_errp) {\n\n *dst_errp = local_err;\n\n } else if (local_err) {\n\n error_free(local_err);\n\n }\n\n}\n", + "output": "1", + "index": 22047 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs,\n\n BdrvDirtyBitmap *bitmap, int64_t sector,\n\n int nb_sectors)\n\n{\n\n uint64_t i;\n\n int sectors_per_bit = 1 << hbitmap_granularity(bitmap->meta);\n\n\n\n /* To optimize: we can make hbitmap to internally check the range in a\n\n * coarse level, or at least do it word by word. */\n\n for (i = sector; i < sector + nb_sectors; i += sectors_per_bit) {\n\n if (hbitmap_get(bitmap->meta, i)) {\n\n return true;\n\n }\n\n }\n\n return false;\n\n}\n", + "output": "0", + "index": 14586 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_send_key(const char *string)\n\n{\n\n char keybuf[16], *q;\n\n uint8_t keycodes[16];\n\n const char *p;\n\n int nb_keycodes, keycode, i;\n\n\n\n nb_keycodes = 0;\n\n p = string;\n\n while (*p != '\\0') {\n\n q = keybuf;\n\n while (*p != '\\0' && *p != '-') {\n\n if ((q - keybuf) < sizeof(keybuf) - 1) {\n\n *q++ = *p;\n\n }\n\n p++;\n\n }\n\n *q = '\\0';\n\n keycode = get_keycode(keybuf);\n\n if (keycode < 0) {\n\n term_printf(\"unknown key: '%s'\\n\", keybuf);\n\n return;\n\n }\n\n keycodes[nb_keycodes++] = keycode;\n\n if (*p == '\\0')\n\n break;\n\n p++;\n\n }\n\n /* key down events */\n\n for(i = 0; i < nb_keycodes; i++) {\n\n keycode = keycodes[i];\n\n if (keycode & 0x80)\n\n kbd_put_keycode(0xe0);\n\n kbd_put_keycode(keycode & 0x7f);\n\n }\n\n /* key up events */\n\n for(i = nb_keycodes - 1; i >= 0; i--) {\n\n keycode = keycodes[i];\n\n if (keycode & 0x80)\n\n kbd_put_keycode(0xe0);\n\n kbd_put_keycode(keycode | 0x80);\n\n }\n\n}\n", + "output": "1", + "index": 5191 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_has_zero_init_1(BlockDriverState *bs)\n\n{\n\n return 1;\n\n}\n", + "output": "0", + "index": 2292 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section)\n\n{\n\n KVMState *s = kvm_state;\n\n unsigned long size, allocated_size = 0;\n\n KVMDirtyLog d;\n\n KVMSlot *mem;\n\n int ret = 0;\n\n hwaddr start_addr = section->offset_within_address_space;\n\n hwaddr end_addr = start_addr + int128_get64(section->size);\n\n\n\n d.dirty_bitmap = NULL;\n\n while (start_addr < end_addr) {\n\n mem = kvm_lookup_overlapping_slot(s, start_addr, end_addr);\n\n if (mem == NULL) {\n\n break;\n\n }\n\n\n\n /* XXX bad kernel interface alert\n\n * For dirty bitmap, kernel allocates array of size aligned to\n\n * bits-per-long. But for case when the kernel is 64bits and\n\n * the userspace is 32bits, userspace can't align to the same\n\n * bits-per-long, since sizeof(long) is different between kernel\n\n * and user space. This way, userspace will provide buffer which\n\n * may be 4 bytes less than the kernel will use, resulting in\n\n * userspace memory corruption (which is not detectable by valgrind\n\n * too, in most cases).\n\n * So for now, let's align to 64 instead of HOST_LONG_BITS here, in\n\n * a hope that sizeof(long) wont become >8 any time soon.\n\n */\n\n size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS),\n\n /*HOST_LONG_BITS*/ 64) / 8;\n\n if (!d.dirty_bitmap) {\n\n d.dirty_bitmap = g_malloc(size);\n\n } else if (size > allocated_size) {\n\n d.dirty_bitmap = g_realloc(d.dirty_bitmap, size);\n\n }\n\n allocated_size = size;\n\n memset(d.dirty_bitmap, 0, allocated_size);\n\n\n\n d.slot = mem->slot;\n\n\n\n if (kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) == -1) {\n\n DPRINTF(\"ioctl failed %d\\n\", errno);\n\n ret = -1;\n\n break;\n\n }\n\n\n\n kvm_get_dirty_pages_log_range(section, d.dirty_bitmap);\n\n start_addr = mem->start_addr + mem->memory_size;\n\n }\n\n g_free(d.dirty_bitmap);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 8627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge)\n\n{\n\n return bridge->i2c_bus;\n\n}\n", + "output": "1", + "index": 26919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xen_pt_word_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,\n\n uint16_t *value, uint16_t valid_mask)\n\n{\n\n XenPTRegInfo *reg = cfg_entry->reg;\n\n uint16_t valid_emu_mask = 0;\n\n\n\n /* emulate word register */\n\n valid_emu_mask = reg->emu_mask & valid_mask;\n\n *value = XEN_PT_MERGE_VALUE(*value, cfg_entry->data, ~valid_emu_mask);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_virtio_net_can_receive(VirtIONet *n, int bufsize)\n\n{\n\n if (!virtio_queue_ready(n->rx_vq) ||\n\n !(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK))\n\n return 0;\n\n\n\n if (virtio_queue_empty(n->rx_vq) ||\n\n (n->mergeable_rx_bufs &&\n\n !virtqueue_avail_bytes(n->rx_vq, bufsize, 0))) {\n\n virtio_queue_set_notification(n->rx_vq, 1);\n\n return 0;\n\n }\n\n\n\n virtio_queue_set_notification(n->rx_vq, 0);\n\n return 1;\n\n}\n", + "output": "0", + "index": 15796 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_crypto_initfn(Object *obj)\n\n{\n\n VirtIOCryptoPCI *dev = VIRTIO_CRYPTO_PCI(obj);\n\n\n\n virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),\n\n TYPE_VIRTIO_CRYPTO);\n\n object_property_add_alias(obj, \"cryptodev\", OBJECT(&dev->vdev),\n\n \"cryptodev\", &error_abort);\n\n}\n", + "output": "0", + "index": 23510 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args,\n\n const int *const_args)\n\n{\n\n tcg_out_cmp2(s, args, const_args);\n\n tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, args[5]);\n\n}\n", + "output": "0", + "index": 18228 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_xhci_exit(PCIDevice *dev)\n\n{\n\n int i;\n\n XHCIState *xhci = XHCI(dev);\n\n\n\n trace_usb_xhci_exit();\n\n\n\n for (i = 0; i < xhci->numslots; i++) {\n\n xhci_disable_slot(xhci, i + 1);\n\n }\n\n\n\n if (xhci->mfwrap_timer) {\n\n timer_del(xhci->mfwrap_timer);\n\n timer_free(xhci->mfwrap_timer);\n\n xhci->mfwrap_timer = NULL;\n\n }\n\n\n\n memory_region_del_subregion(&xhci->mem, &xhci->mem_cap);\n\n memory_region_del_subregion(&xhci->mem, &xhci->mem_oper);\n\n memory_region_del_subregion(&xhci->mem, &xhci->mem_runtime);\n\n memory_region_del_subregion(&xhci->mem, &xhci->mem_doorbell);\n\n\n\n for (i = 0; i < xhci->numports; i++) {\n\n XHCIPort *port = &xhci->ports[i];\n\n memory_region_del_subregion(&xhci->mem, &port->mem);\n\n }\n\n\n\n /* destroy msix memory region */\n\n if (dev->msix_table && dev->msix_pba\n\n && dev->msix_entry_used) {\n\n memory_region_del_subregion(&xhci->mem, &dev->msix_table_mmio);\n\n memory_region_del_subregion(&xhci->mem, &dev->msix_pba_mmio);\n\n }\n\n\n\n usb_bus_release(&xhci->bus);\n\n}\n", + "output": "1", + "index": 22619 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qxl_exit_vga_mode(PCIQXLDevice *d)\n\n{\n\n if (d->mode != QXL_MODE_VGA) {\n\n return;\n\n }\n\n trace_qxl_exit_vga_mode(d->id);\n\n\n qxl_destroy_primary(d, QXL_SYNC);\n\n}", + "output": "1", + "index": 8871 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void configure_alarms(char const *opt)\n\n{\n\n int i;\n\n int cur = 0;\n\n int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;\n\n char *arg;\n\n char *name;\n\n\n\n if (!strcmp(opt, \"help\")) {\n\n show_available_alarms();\n\n exit(0);\n\n }\n\n\n\n arg = strdup(opt);\n\n\n\n /* Reorder the array */\n\n name = strtok(arg, \",\");\n\n while (name) {\n\n struct qemu_alarm_timer tmp;\n\n\n\n for (i = 0; i < count; i++) {\n\n if (!strcmp(alarm_timers[i].name, name))\n\n break;\n\n }\n\n\n\n if (i == count) {\n\n fprintf(stderr, \"Unknown clock %s\\n\", name);\n\n goto next;\n\n }\n\n\n\n if (i < cur)\n\n /* Ignore */\n\n goto next;\n\n\n\n\t/* Swap */\n\n tmp = alarm_timers[i];\n\n alarm_timers[i] = alarm_timers[cur];\n\n alarm_timers[cur] = tmp;\n\n\n\n cur++;\n\nnext:\n\n name = strtok(NULL, \",\");\n\n }\n\n\n\n free(arg);\n\n\n\n if (cur) {\n\n\t/* Disable remaining timers */\n\n for (i = cur; i < count; i++)\n\n alarm_timers[i].name = NULL;\n\n }\n\n\n\n /* debug */\n\n show_available_alarms();\n\n}\n", + "output": "0", + "index": 10243 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void free_drive(DeviceState *dev, Property *prop)\n\n{\n\n DriveInfo **ptr = qdev_get_prop_ptr(dev, prop);\n\n\n\n if (*ptr) {\n\n blockdev_auto_del((*ptr)->bdrv);\n\n }\n\n}\n", + "output": "0", + "index": 26964 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QBool *qbool_from_bool(bool value)\n\n{\n\n QBool *qb;\n\n\n\n qb = g_malloc(sizeof(*qb));\n\n qb->value = value;\n\n QOBJECT_INIT(qb, &qbool_type);\n\n\n\n return qb;\n\n}\n", + "output": "0", + "index": 8134 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_opendir(FsContext *ctx,\n\n V9fsPath *fs_path, V9fsFidOpenState *fs)\n\n{\n\n int serrno, fd;\n\n\n\n fs->dir = NULL;\n\n fd = v9fs_request(ctx->private, T_OPEN, NULL, \"sd\", fs_path, O_DIRECTORY);\n\n if (fd < 0) {\n\n errno = -fd;\n\n return -1;\n\n }\n\n fs->dir = fdopendir(fd);\n\n if (!fs->dir) {\n\n serrno = errno;\n\n close(fd);\n\n errno = serrno;\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 801 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sigp_restart(CPUState *cs, run_on_cpu_data arg)\n\n{\n\n S390CPU *cpu = S390_CPU(cs);\n\n SigpInfo *si = arg.host_ptr;\n\n struct kvm_s390_irq irq = {\n\n .type = KVM_S390_RESTART,\n\n };\n\n\n\n switch (s390_cpu_get_state(cpu)) {\n\n case CPU_STATE_STOPPED:\n\n /* the restart irq has to be delivered prior to any other pending irq */\n\n cpu_synchronize_state(cs);\n\n do_restart_interrupt(&cpu->env);\n\n s390_cpu_set_state(CPU_STATE_OPERATING, cpu);\n\n break;\n\n case CPU_STATE_OPERATING:\n\n kvm_s390_vcpu_interrupt(cpu, &irq);\n\n break;\n\n }\n\n si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;\n\n}\n", + "output": "0", + "index": 25290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,\n\n const uint8_t *buf, int nb_sectors)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n if (!drv)\n\n return -ENOMEDIUM;\n\n if (!drv->bdrv_write_compressed)\n\n return -ENOTSUP;\n\n if (bdrv_check_request(bs, sector_num, nb_sectors))\n\n return -EIO;\n\n\n\n if (bs->dirty_tracking) {\n\n set_dirty_bitmap(bs, sector_num, nb_sectors, 1);\n\n }\n\n\n\n return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);\n\n}\n", + "output": "1", + "index": 13665 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,\n\n uint32_t fid, uint64_t faddr, uint32_t e)\n\n{\n\n SeiContainer *sei_cont = g_malloc0(sizeof(SeiContainer));\n\n S390pciState *s = S390_PCI_HOST_BRIDGE(\n\n object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));\n\n\n\n if (!s) {\n\n return;\n\n }\n\n\n\n sei_cont->fh = fh;\n\n sei_cont->fid = fid;\n\n sei_cont->cc = cc;\n\n sei_cont->pec = pec;\n\n sei_cont->faddr = faddr;\n\n sei_cont->e = e;\n\n\n\n QTAILQ_INSERT_TAIL(&s->pending_sei, sei_cont, link);\n\n css_generate_css_crws(0);\n\n}\n", + "output": "1", + "index": 23947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_htab_fd(sPAPRMachineState *spapr)\n\n{\n\n if (spapr->htab_fd >= 0) {\n\n return spapr->htab_fd;\n\n }\n\n\n\n spapr->htab_fd = kvmppc_get_htab_fd(false);\n\n if (spapr->htab_fd < 0) {\n\n error_report(\"Unable to open fd for reading hash table from KVM: %s\",\n\n strerror(errno));\n\n }\n\n\n\n return spapr->htab_fd;\n\n}\n", + "output": "1", + "index": 19434 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_dsputil_init_alpha(DSPContext *c, AVCodecContext *avctx)\n\n{\n\n const int high_bit_depth = avctx->bits_per_raw_sample > 8;\n\n\n\n /* amask clears all bits that correspond to present features. */\n\n if (amask(AMASK_MVI) == 0) {\n\n c->put_pixels_clamped = put_pixels_clamped_mvi_asm;\n\n c->add_pixels_clamped = add_pixels_clamped_mvi_asm;\n\n\n\n if (!high_bit_depth)\n\n c->get_pixels = get_pixels_mvi;\n\n c->diff_pixels = diff_pixels_mvi;\n\n c->sad[0] = pix_abs16x16_mvi_asm;\n\n c->sad[1] = pix_abs8x8_mvi;\n\n c->pix_abs[0][0] = pix_abs16x16_mvi_asm;\n\n c->pix_abs[1][0] = pix_abs8x8_mvi;\n\n c->pix_abs[0][1] = pix_abs16x16_x2_mvi;\n\n c->pix_abs[0][2] = pix_abs16x16_y2_mvi;\n\n c->pix_abs[0][3] = pix_abs16x16_xy2_mvi;\n\n }\n\n\n\n put_pixels_clamped_axp_p = c->put_pixels_clamped;\n\n add_pixels_clamped_axp_p = c->add_pixels_clamped;\n\n\n\n if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&\n\n (avctx->idct_algo == FF_IDCT_AUTO ||\n\n avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) {\n\n c->idct_put = ff_simple_idct_put_axp;\n\n c->idct_add = ff_simple_idct_add_axp;\n\n c->idct = ff_simple_idct_axp;\n\n }\n\n}\n", + "output": "1", + "index": 21610 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "target_ulong helper_load_slb_esid(CPUPPCState *env, target_ulong rb)\n\n{\n\n target_ulong rt;\n\n\n\n if (ppc_load_slb_esid(env, rb, &rt) < 0) {\n\n helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,\n\n POWERPC_EXCP_INVAL);\n\n }\n\n return rt;\n\n}\n", + "output": "1", + "index": 19970 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v4l2_read_packet(AVFormatContext *s1, AVPacket *pkt)\n\n{\n\n#if FF_API_CODED_FRAME\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n struct video_data *s = s1->priv_data;\n\n AVFrame *frame = s1->streams[0]->codec->coded_frame;\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n int res;\n\n\n\n av_init_packet(pkt);\n\n if ((res = mmap_read_frame(s1, pkt)) < 0) {\n\n return res;\n\n }\n\n\n\n#if FF_API_CODED_FRAME\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n if (frame && s->interlaced) {\n\n frame->interlaced_frame = 1;\n\n frame->top_field_first = s->top_field_first;\n\n }\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n return pkt->size;\n\n}\n", + "output": "0", + "index": 4873 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm)\n\n{\n\n fadt->model = 1;\n\n fadt->reserved1 = 0;\n\n fadt->sci_int = cpu_to_le16(pm->sci_int);\n\n fadt->smi_cmd = cpu_to_le32(ACPI_PORT_SMI_CMD);\n\n fadt->acpi_enable = pm->acpi_enable_cmd;\n\n fadt->acpi_disable = pm->acpi_disable_cmd;\n\n /* EVT, CNT, TMR offset matches hw/acpi/core.c */\n\n fadt->pm1a_evt_blk = cpu_to_le32(pm->io_base);\n\n fadt->pm1a_cnt_blk = cpu_to_le32(pm->io_base + 0x04);\n\n fadt->pm_tmr_blk = cpu_to_le32(pm->io_base + 0x08);\n\n fadt->gpe0_blk = cpu_to_le32(pm->gpe0_blk);\n\n /* EVT, CNT, TMR length matches hw/acpi/core.c */\n\n fadt->pm1_evt_len = 4;\n\n fadt->pm1_cnt_len = 2;\n\n fadt->pm_tmr_len = 4;\n\n fadt->gpe0_blk_len = pm->gpe0_blk_len;\n\n fadt->plvl2_lat = cpu_to_le16(0xfff); /* C2 state not supported */\n\n fadt->plvl3_lat = cpu_to_le16(0xfff); /* C3 state not supported */\n\n fadt->flags = cpu_to_le32((1 << ACPI_FADT_F_WBINVD) |\n\n (1 << ACPI_FADT_F_PROC_C1) |\n\n (1 << ACPI_FADT_F_SLP_BUTTON) |\n\n (1 << ACPI_FADT_F_RTC_S4));\n\n fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_USE_PLATFORM_CLOCK);\n\n /* APIC destination mode (\"Flat Logical\") has an upper limit of 8 CPUs\n\n * For more than 8 CPUs, \"Clustered Logical\" mode has to be used\n\n */\n\n if (max_cpus > 8) {\n\n fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL);\n\n }\n\n fadt->century = RTC_CENTURY;\n\n}\n", + "output": "0", + "index": 12026 + } +] \ No newline at end of file