diff --git "a/devign/alpaca/devign_0-512_validate.json" "b/devign/alpaca/devign_0-512_validate.json" new file mode 100644--- /dev/null +++ "b/devign/alpaca/devign_0-512_validate.json" @@ -0,0 +1,11534 @@ +[ + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "build_fadt(GArray *table_data, GArray *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 table_data, &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 table_data, &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": 19477 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dbdma_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n int channel = addr >> DBDMA_CHANNEL_SHIFT;\n\n DBDMAState *s = opaque;\n\n DBDMA_channel *ch = &s->channels[channel];\n\n int reg = (addr - (channel << DBDMA_CHANNEL_SHIFT)) >> 2;\n\n\n\n DBDMA_DPRINTF(\"writel 0x\" TARGET_FMT_plx \" <= 0x%08x\\n\", addr, value);\n\n DBDMA_DPRINTF(\"channel 0x%x reg 0x%x\\n\",\n\n (uint32_t)addr >> DBDMA_CHANNEL_SHIFT, reg);\n\n\n\n /* cmdptr cannot be modified if channel is RUN or ACTIVE */\n\n\n\n if (reg == DBDMA_CMDPTR_LO &&\n\n (ch->regs[DBDMA_STATUS] & (RUN | ACTIVE)))\n\n\treturn;\n\n\n\n ch->regs[reg] = value;\n\n\n\n switch(reg) {\n\n case DBDMA_CONTROL:\n\n dbdma_control_write(ch);\n\n break;\n\n case DBDMA_CMDPTR_LO:\n\n /* 16-byte aligned */\n\n ch->regs[DBDMA_CMDPTR_LO] &= ~0xf;\n\n dbdma_cmdptr_load(ch);\n\n break;\n\n case DBDMA_STATUS:\n\n case DBDMA_INTR_SEL:\n\n case DBDMA_BRANCH_SEL:\n\n case DBDMA_WAIT_SEL:\n\n /* nothing to do */\n\n break;\n\n case DBDMA_XFER_MODE:\n\n case DBDMA_CMDPTR_HI:\n\n case DBDMA_DATA2PTR_HI:\n\n case DBDMA_DATA2PTR_LO:\n\n case DBDMA_ADDRESS_HI:\n\n case DBDMA_BRANCH_ADDR_HI:\n\n case DBDMA_RES1:\n\n case DBDMA_RES2:\n\n case DBDMA_RES3:\n\n case DBDMA_RES4:\n\n /* unused */\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 10069 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool bdrv_requests_pending(BlockDriverState *bs)\n\n{\n\n BdrvChild *child;\n\n BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL;\n\n\n\n if (!QLIST_EMPTY(&bs->tracked_requests)) {\n\n return true;\n\n }\n\n if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) {\n\n return true;\n\n }\n\n if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) {\n\n return true;\n\n }\n\n\n\n QLIST_FOREACH(child, &bs->children, next) {\n\n if (bdrv_requests_pending(child->bs)) {\n\n return true;\n\n }\n\n }\n\n\n\n return false;\n\n}\n", + "output": "0", + "index": 19470 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void timerlistgroup_init(QEMUTimerListGroup *tlg,\n\n QEMUTimerListNotifyCB *cb, void *opaque)\n\n{\n\n QEMUClockType type;\n\n for (type = 0; type < QEMU_CLOCK_MAX; type++) {\n\n tlg->tl[type] = timerlist_new(type, cb, opaque);\n\n }\n\n}\n", + "output": "0", + "index": 20250 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)\n\n{\n\n int ret;\n\n AVExpr *old = NULL;\n\n\n\n if (*pexpr)\n\n old = *pexpr;\n\n ret = av_expr_parse(pexpr, expr, var_names,\n\n NULL, NULL, NULL, NULL, 0, log_ctx);\n\n if (ret < 0) {\n\n av_log(log_ctx, AV_LOG_ERROR,\n\n \"Error when evaluating the expression '%s'\\n\", expr);\n\n *pexpr = old;\n\n return ret;\n\n }\n\n\n\n av_expr_free(old);\n\n return 0;\n\n}\n", + "output": "0", + "index": 12933 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)\n\n{\n\n int cpu_flags = av_get_cpu_flags();\n\n\n\n cavsdsp_init_mmx(c, avctx);\n\n#if HAVE_AMD3DNOW_INLINE\n\n if (INLINE_AMD3DNOW(cpu_flags))\n\n cavsdsp_init_3dnow(c, avctx);\n\n#endif /* HAVE_AMD3DNOW_INLINE */\n\n#if HAVE_MMXEXT_INLINE\n\n if (INLINE_MMXEXT(cpu_flags)) {\n\n DSPFUNC(put, 0, 16, mmxext);\n\n DSPFUNC(put, 1, 8, mmxext);\n\n DSPFUNC(avg, 0, 16, mmxext);\n\n DSPFUNC(avg, 1, 8, mmxext);\n\n }\n\n#endif\n\n#if HAVE_MMX_EXTERNAL\n\n if (EXTERNAL_MMXEXT(cpu_flags)) {\n\n c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;\n\n c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;\n\n }\n\n#endif\n\n#if HAVE_SSE2_EXTERNAL\n\n if (EXTERNAL_SSE2(cpu_flags)) {\n\n c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;\n\n c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 18092 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_input_optional(Visitor *v, const char *name, bool *present)\n\n{\n\n QmpInputVisitor *qiv = to_qiv(v);\n\n QObject *qobj = qmp_input_get_object(qiv, name, false, NULL);\n\n\n\n if (!qobj) {\n\n *present = false;\n\n return;\n\n }\n\n\n\n *present = true;\n\n}\n", + "output": "0", + "index": 9702 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int isa_vga_mm_init(hwaddr vram_base,\n\n hwaddr ctrl_base, int it_shift,\n\n MemoryRegion *address_space)\n\n{\n\n ISAVGAMMState *s;\n\n\n\n s = g_malloc0(sizeof(*s));\n\n\n\n s->vga.vram_size_mb = VGA_RAM_SIZE >> 20;\n\n vga_common_init(&s->vga);\n\n vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space);\n\n\n\n s->vga.con = graphic_console_init(s->vga.update, s->vga.invalidate,\n\n s->vga.screen_dump, s->vga.text_update,\n\n s);\n\n\n\n vga_init_vbe(&s->vga, address_space);\n\n return 0;\n\n}\n", + "output": "0", + "index": 3021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n\n{\n\n AVStream *st;\n\n MOVStreamContext *sc;\n\n unsigned int i, entries;\n\n int64_t duration=0;\n\n int64_t total_sample_count=0;\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 av_dlog(c->fc, \"track[%i].stts.entries = %i\\n\",\n\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\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\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 av_dlog(c->fc, \"sample_count=%d, sample_duration=%d\\n\",\n\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": "1", + "index": 2664 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void get_offset_range(hwaddr phys_addr,\n\n ram_addr_t mapping_length,\n\n DumpState *s,\n\n hwaddr *p_offset,\n\n hwaddr *p_filesz)\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 /* When the memory is not stored into vmcore, offset will be -1 */\n\n *p_offset = -1;\n\n *p_filesz = 0;\n\n\n\n if (s->has_filter) {\n\n if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {\n\n return;\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 *p_offset = phys_addr - start + offset;\n\n\n\n /* The offset range mapped from the vmcore file must not spill over\n\n * the RAMBlock, clamp it. The rest of the mapping will be\n\n * zero-filled in memory at load time; see\n\n * .\n\n */\n\n *p_filesz = phys_addr + mapping_length <= start + size_in_block ?\n\n mapping_length :\n\n size_in_block - (phys_addr - start);\n\n return;\n\n }\n\n\n\n offset += size_in_block;\n\n }\n\n}\n", + "output": "1", + "index": 6162 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_ioreq_pio(ioreq_t *req)\n\n{\n\n int i;\n\n\n\n if (req->dir == IOREQ_READ) {\n\n if (!req->data_is_ptr) {\n\n req->data = do_inp(req->addr, req->size);\n\n } else {\n\n uint32_t tmp;\n\n\n\n for (i = 0; i < req->count; i++) {\n\n tmp = do_inp(req->addr, req->size);\n\n write_phys_req_item(req->data, req, i, &tmp);\n\n }\n\n }\n\n } else if (req->dir == IOREQ_WRITE) {\n\n if (!req->data_is_ptr) {\n\n do_outp(req->addr, req->size, req->data);\n\n } else {\n\n for (i = 0; i < req->count; i++) {\n\n uint32_t tmp = 0;\n\n\n\n read_phys_req_item(req->data, req, i, &tmp);\n\n do_outp(req->addr, req->size, tmp);\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 498 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_noinline void emulated_edge_mc_sse(uint8_t *buf, const uint8_t *src,\n\n ptrdiff_t buf_stride,\n\n ptrdiff_t src_stride,\n\n int block_w, int block_h,\n\n int src_x, int src_y, int w, int h)\n\n{\n\n emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h,\n\n src_x, src_y, w, h, vfixtbl_sse, &ff_emu_edge_vvar_sse,\n\n hfixtbl_mmxext, &ff_emu_edge_hvar_mmxext);\n\n}\n", + "output": "0", + "index": 11468 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int sol_probe(AVProbeData *p)\n\n{\n\n /* check file header */\n\n uint16_t magic;\n\n if (p->buf_size <= 14)\n\n return 0;\n\n magic=le2me_16(*((uint16_t*)p->buf));\n\n if ((magic == 0x0B8D || magic == 0x0C0D || magic == 0x0C8D) &&\n\n p->buf[2] == 'S' && p->buf[3] == 'O' &&\n\n p->buf[4] == 'L' && p->buf[5] == 0)\n\n return AVPROBE_SCORE_MAX;\n\n else\n\n return 0;\n\n}\n", + "output": "0", + "index": 18064 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int asink_init(AVFilterContext *ctx, void *opaque)\n\n{\n\n BufferSinkContext *buf = ctx->priv;\n\n AVABufferSinkParams *params = opaque;\n\n\n\n if (params && params->sample_fmts) {\n\n buf->sample_fmts = ff_copy_int_list(params->sample_fmts);\n\n if (!buf->sample_fmts)\n\n return AVERROR(ENOMEM);\n\n }\n\n if (params && params->sample_rates) {\n\n buf->sample_rates = ff_copy_int_list(params->sample_rates);\n\n if (!buf->sample_rates)\n\n return AVERROR(ENOMEM);\n\n }\n\n if (params && (params->channel_layouts || params->channel_counts)) {\n\n if (params->all_channel_counts) {\n\n av_log(ctx, AV_LOG_ERROR,\n\n \"Conflicting all_channel_counts and list in parameters\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n buf->channel_layouts = concat_channels_lists(params->channel_layouts,\n\n params->channel_counts);\n\n if (!buf->channel_layouts)\n\n return AVERROR(ENOMEM);\n\n }\n\n if (params)\n\n buf->all_channel_counts = params->all_channel_counts;\n\n return common_init(ctx);\n\n}\n", + "output": "0", + "index": 11895 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_native_list_int8(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_S8);\n\n}\n", + "output": "0", + "index": 16781 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void elcr_ioport_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t val, unsigned size)\n\n{\n\n PICCommonState *s = opaque;\n\n s->elcr = val & s->elcr_mask;\n\n}\n", + "output": "0", + "index": 169 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ehci_state_executing(EHCIQueue *q)\n\n{\n\n EHCIPacket *p = QTAILQ_FIRST(&q->packets);\n\n int again = 0;\n\n\n\n assert(p != NULL);\n\n assert(p->qtdaddr == q->qtdaddr);\n\n\n\n ehci_execute_complete(q);\n\n if (p->usb_status == USB_RET_ASYNC) {\n\n goto out;\n\n }\n\n if (p->usb_status == USB_RET_PROCERR) {\n\n again = -1;\n\n goto out;\n\n }\n\n\n\n // 4.10.3\n\n if (!q->async) {\n\n int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);\n\n transactCtr--;\n\n set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);\n\n // 4.10.3, bottom of page 82, should exit this state when transaction\n\n // counter decrements to 0\n\n }\n\n\n\n /* 4.10.5 */\n\n if (p->usb_status == USB_RET_NAK) {\n\n ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);\n\n } else {\n\n ehci_set_state(q->ehci, q->async, EST_WRITEBACK);\n\n }\n\n\n\n again = 1;\n\n\n\nout:\n\n ehci_flush_qh(q);\n\n return again;\n\n}\n", + "output": "0", + "index": 5197 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pal_init (CPUState *env)\n\n{\n\n}\n", + "output": "0", + "index": 24756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void raw_lock_medium(BlockDriverState *bs, bool locked)\n\n{\n\n bdrv_lock_medium(bs->file->bs, locked);\n\n}\n", + "output": "0", + "index": 23531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int omap_validate_emiff_addr(struct omap_mpu_state_s *s,\n\n target_phys_addr_t addr)\n\n{\n\n return addr >= OMAP_EMIFF_BASE && addr < OMAP_EMIFF_BASE + s->sdram_size;\n\n}\n", + "output": "0", + "index": 19281 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nvdec_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)\n\n{\n\n VP8Context *h = avctx->priv_data;\n\n\n\n NVDECContext *ctx = avctx->internal->hwaccel_priv_data;\n\n CUVIDPICPARAMS *pp = &ctx->pic_params;\n\n FrameDecodeData *fdd;\n\n NVDECFrame *cf;\n\n AVFrame *cur_frame = h->framep[VP56_FRAME_CURRENT]->tf.f;\n\n\n\n int ret;\n\n\n\n ret = ff_nvdec_start_frame(avctx, cur_frame);\n\n if (ret < 0)\n\n return ret;\n\n\n\n fdd = (FrameDecodeData*)cur_frame->private_ref->data;\n\n cf = (NVDECFrame*)fdd->hwaccel_priv;\n\n\n\n *pp = (CUVIDPICPARAMS) {\n\n .PicWidthInMbs = (cur_frame->width + 15) / 16,\n\n .FrameHeightInMbs = (cur_frame->height + 15) / 16,\n\n .CurrPicIdx = cf->idx,\n\n\n\n .CodecSpecific.vp8 = {\n\n .width = cur_frame->width,\n\n .height = cur_frame->height,\n\n\n\n .first_partition_size = h->header_partition_size,\n\n\n\n .LastRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_PREVIOUS]),\n\n .GoldenRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN]),\n\n .AltRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN2]),\n\n /*\n\n * Explicit braces for anonymous inners to work around limitations\n\n * in ancient versions of gcc.\n\n */\n\n {\n\n {\n\n .frame_type = !h->keyframe,\n\n .version = h->profile,\n\n .show_frame = !h->invisible,\n\n .update_mb_segmentation_data = h->segmentation.enabled ?\n\n h->segmentation.update_feature_data :\n\n 0,\n\n }\n\n }\n\n }\n\n };\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 7569 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void phys_sections_clear(PhysPageMap *map)\n\n{\n\n while (map->sections_nb > 0) {\n\n MemoryRegionSection *section = &map->sections[--map->sections_nb];\n\n phys_section_destroy(section->mr);\n\n }\n\n g_free(map->sections);\n\n g_free(map->nodes);\n\n}\n", + "output": "0", + "index": 16316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gif_fill_rect(AVFrame *picture, uint32_t color, int l, int t, int w, int h)\n\n{\n\n const int linesize = picture->linesize[0] / sizeof(uint32_t);\n\n const uint32_t *py = (uint32_t *)picture->data[0] + t * linesize;\n\n const uint32_t *pr, *pb = py + (t + h) * linesize;\n\n uint32_t *px;\n\n\n\n for (; py < pb; py += linesize) {\n\n px = (uint32_t *)py + l;\n\n pr = px + w;\n\n\n\n for (; px < pr; px++)\n\n *px = color;\n\n }\n\n}\n", + "output": "1", + "index": 13901 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)\n\n{\n\n s->chr_read(s->handler_opaque, buf, len);\n\n}\n", + "output": "1", + "index": 841 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rv40_v_loop_filter_strength(uint8_t *src, int stride,\n\n int beta, int beta2, int edge,\n\n int *p1, int *q1)\n\n{\n\n return rv40_loop_filter_strength(src, 1, stride, beta, beta2, edge, p1, q1);\n\n}\n", + "output": "1", + "index": 19789 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target)\n\n{\n\n ptrdiff_t offset = target - code_ptr;\n\n assert(offset == sextract64(offset, 0, 26));\n\n /* read instruction, mask away previous PC_REL26 parameter contents,\n\n set the proper offset, then write back the instruction. */\n\n *code_ptr = deposit32(*code_ptr, 0, 26, offset);\n\n}\n", + "output": "0", + "index": 8756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int audio_validate_settings (audsettings_t *as)\n\n{\n\n int invalid;\n\n\n\n invalid = as->nchannels != 1 && as->nchannels != 2;\n\n invalid |= as->endianness != 0 && as->endianness != 1;\n\n\n\n switch (as->fmt) {\n\n case AUD_FMT_S8:\n\n case AUD_FMT_U8:\n\n case AUD_FMT_S16:\n\n case AUD_FMT_U16:\n\n case AUD_FMT_S32:\n\n case AUD_FMT_U32:\n\n break;\n\n default:\n\n invalid = 1;\n\n break;\n\n }\n\n\n\n invalid |= as->freq <= 0;\n\n return invalid ? -1 : 0;\n\n}\n", + "output": "0", + "index": 18121 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,\n\n int evt, int len)\n\n{\n\n uint8_t *packet, mask;\n\n int mask_byte;\n\n\n\n if (len > 255) {\n\n fprintf(stderr, \"%s: HCI event params too long (%ib)\\n\",\n\n __FUNCTION__, len);\n\n exit(-1);\n\n }\n\n\n\n mask_byte = (evt - 1) >> 3;\n\n mask = 1 << ((evt - 1) & 3);\n\n if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte])\n\n return NULL;\n\n\n\n packet = hci->evt_packet(hci->opaque);\n\n packet[0] = evt;\n\n packet[1] = len;\n\n\n\n return &packet[2];\n\n}\n", + "output": "0", + "index": 3651 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,\n\n int w, int h, int stride, int color)\n\n{\n\n int x, y, fr, f;\n\n\n\n sx = av_clip(sx, 0, w - 1);\n\n sy = av_clip(sy, 0, h - 1);\n\n ex = av_clip(ex, 0, w - 1);\n\n ey = av_clip(ey, 0, h - 1);\n\n\n\n buf[sy * stride + sx] += color;\n\n\n\n if (FFABS(ex - sx) > FFABS(ey - sy)) {\n\n if (sx > ex) {\n\n FFSWAP(int, sx, ex);\n\n FFSWAP(int, sy, ey);\n\n }\n\n buf += sx + sy * stride;\n\n ex -= sx;\n\n f = ((ey - sy) << 16) / ex;\n\n for (x = 0; x = ex; x++) {\n\n y = (x * f) >> 16;\n\n fr = (x * f) & 0xFFFF;\n\n buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;\n\n buf[(y + 1) * stride + x] += (color * fr ) >> 16;\n\n }\n\n } else {\n\n if (sy > ey) {\n\n FFSWAP(int, sx, ex);\n\n FFSWAP(int, sy, ey);\n\n }\n\n buf += sx + sy * stride;\n\n ey -= sy;\n\n if (ey)\n\n f = ((ex - sx) << 16) / ey;\n\n else\n\n f = 0;\n\n for (y = 0; y = ey; y++) {\n\n x = (y * f) >> 16;\n\n fr = (y * f) & 0xFFFF;\n\n buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;\n\n buf[y * stride + x + 1] += (color * fr ) >> 16;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 4919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,\n\n int nb_sectors, BdrvRequestFlags flags)\n\n{\n\n return bdrv_rw_co(bs, sector_num, NULL, nb_sectors, true,\n\n BDRV_REQ_ZERO_WRITE | flags);\n\n}\n", + "output": "0", + "index": 14957 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gxf_write_padding(ByteIOContext *pb, offset_t to_pad)\n\n{\n\n while (to_pad--) {\n\n put_byte(pb, 0);\n\n }\n\n}\n", + "output": "0", + "index": 25914 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static sPAPRDREntitySense logical_entity_sense(sPAPRDRConnector *drc)\n\n{\n\n if (drc->dev\n\n && (drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE)) {\n\n return SPAPR_DR_ENTITY_SENSE_PRESENT;\n\n } else {\n\n return SPAPR_DR_ENTITY_SENSE_UNUSABLE;\n\n }\n\n}\n", + "output": "0", + "index": 8668 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tb_invalidate_page_range(target_ulong start, target_ulong end)\n\n{\n\n /* XXX: cannot enable it yet because it yields to MMU exception\n\n where NIP != read address on PowerPC */\n\n#if 0\n\n target_ulong phys_addr;\n\n phys_addr = get_phys_addr_code(env, start);\n\n tb_invalidate_phys_page_range(phys_addr, phys_addr + end - start, 0);\n\n#endif\n\n}\n", + "output": "0", + "index": 25918 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)\n\n{\n\n char buffer[PATH_MAX];\n\n char *path = fs_path->data;\n\n\n\n return statfs(rpath(s, path, buffer), stbuf);\n\n}\n", + "output": "0", + "index": 26576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int make_cdt24_entry(int p1, int p2, int16_t *cdt)\n\n{\n\n int r, b;\n\n\n\n b = cdt[p2];\n\n r = cdt[p1]<<16;\n\n return (b+r) << 1;\n\n}\n", + "output": "1", + "index": 17341 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)\n\n{\n\n /* This always zero-extends and writes to a full 128 bit wide vector */\n\n TCGv_i64 tmplo = tcg_temp_new_i64();\n\n TCGv_i64 tmphi;\n\n\n\n if (size < 4) {\n\n TCGMemOp memop = MO_TE + size;\n\n tmphi = tcg_const_i64(0);\n\n tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop);\n\n } else {\n\n TCGv_i64 tcg_hiaddr;\n\n tmphi = tcg_temp_new_i64();\n\n tcg_hiaddr = tcg_temp_new_i64();\n\n\n\n tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), MO_TEQ);\n\n tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);\n\n tcg_gen_qemu_ld_i64(tmphi, tcg_hiaddr, get_mem_index(s), MO_TEQ);\n\n tcg_temp_free_i64(tcg_hiaddr);\n\n }\n\n\n\n tcg_gen_st_i64(tmplo, cpu_env, fp_reg_offset(destidx, MO_64));\n\n tcg_gen_st_i64(tmphi, cpu_env, fp_reg_hi_offset(destidx));\n\n\n\n tcg_temp_free_i64(tmplo);\n\n tcg_temp_free_i64(tmphi);\n\n}\n", + "output": "0", + "index": 1257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avpriv_exif_decode_ifd(AVCodecContext *avctx, GetByteContext *gbytes, int le,\n\n int depth, AVDictionary **metadata)\n\n{\n\n int i, ret;\n\n int entries;\n\n\n\n entries = ff_tget_short(gbytes, le);\n\n\n\n if (bytestream2_get_bytes_left(gbytes) < entries * 12) {\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n for (i = 0; i < entries; i++) {\n\n if ((ret = exif_decode_tag(avctx, gbytes, le, depth, metadata)) < 0) {\n\n return ret;\n\n }\n\n }\n\n\n\n // return next IDF offset or 0x000000000 or a value < 0 for failure\n\n return ff_tget_long(gbytes, le);\n\n}\n", + "output": "0", + "index": 15174 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_info_kqemu(Monitor *mon)\n\n{\n\n#ifdef CONFIG_KQEMU\n\n CPUState *env;\n\n int val;\n\n val = 0;\n\n env = mon_get_cpu();\n\n if (!env) {\n\n monitor_printf(mon, \"No cpu initialized yet\");\n\n return;\n\n }\n\n val = env->kqemu_enabled;\n\n monitor_printf(mon, \"kqemu support: \");\n\n switch(val) {\n\n default:\n\n case 0:\n\n monitor_printf(mon, \"disabled\\n\");\n\n break;\n\n case 1:\n\n monitor_printf(mon, \"enabled for user code\\n\");\n\n break;\n\n case 2:\n\n monitor_printf(mon, \"enabled for user and kernel code\\n\");\n\n break;\n\n }\n\n#else\n\n monitor_printf(mon, \"kqemu support: not compiled\\n\");\n\n#endif\n\n}\n", + "output": "0", + "index": 20990 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_tcmi_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\n\n if (size != 4) {\n\n return omap_badwidth_write32(opaque, addr, value);\n\n }\n\n\n\n switch (addr) {\n\n case 0x00:\t/* IMIF_PRIO */\n\n case 0x04:\t/* EMIFS_PRIO */\n\n case 0x08:\t/* EMIFF_PRIO */\n\n case 0x10:\t/* EMIFS_CS0_CONFIG */\n\n case 0x14:\t/* EMIFS_CS1_CONFIG */\n\n case 0x18:\t/* EMIFS_CS2_CONFIG */\n\n case 0x1c:\t/* EMIFS_CS3_CONFIG */\n\n case 0x20:\t/* EMIFF_SDRAM_CONFIG */\n\n case 0x24:\t/* EMIFF_MRS */\n\n case 0x28:\t/* TIMEOUT1 */\n\n case 0x2c:\t/* TIMEOUT2 */\n\n case 0x30:\t/* TIMEOUT3 */\n\n case 0x3c:\t/* EMIFF_SDRAM_CONFIG_2 */\n\n case 0x40:\t/* EMIFS_CFG_DYN_WAIT */\n\n s->tcmi_regs[addr >> 2] = value;\n\n break;\n\n case 0x0c:\t/* EMIFS_CONFIG */\n\n s->tcmi_regs[addr >> 2] = (value & 0xf) | (1 << 4);\n\n break;\n\n\n\n default:\n\n OMAP_BAD_REG(addr);\n\n }\n\n}\n", + "output": "0", + "index": 12331 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PPC_OP(cmpli)\n\n{\n\n if (T0 < PARAM(1)) {\n\n T0 = 0x08;\n\n } else if (T0 > PARAM(1)) {\n\n T0 = 0x04;\n\n } else {\n\n T0 = 0x02;\n\n }\n\n RETURN();\n\n}\n", + "output": "1", + "index": 19712 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint32_t efsctsf(uint32_t val)\n\n{\n\n CPU_FloatU u;\n\n float32 tmp;\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 tmp = uint64_to_float32(1ULL << 32, &env->vec_status);\n\n u.f = float32_mul(u.f, tmp, &env->vec_status);\n\n\n\n return float32_to_int32(u.f, &env->vec_status);\n\n}\n", + "output": "0", + "index": 15839 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "sosendto(struct socket *so, struct mbuf *m)\n\n{\n\n\tSlirp *slirp = so->slirp;\n\n\tint ret;\n\n\tstruct sockaddr_in addr;\n\n\n\n\tDEBUG_CALL(\"sosendto\");\n\n\tDEBUG_ARG(\"so = %p\", so);\n\n\tDEBUG_ARG(\"m = %p\", m);\n\n\n\n addr.sin_family = AF_INET;\n\n\tif ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==\n\n\t slirp->vnetwork_addr.s_addr) {\n\n\t /* It's an alias */\n\n\t if (so->so_faddr.s_addr == slirp->vnameserver_addr.s_addr) {\n\n\t if (get_dns_addr(&addr.sin_addr) < 0)\n\n\t addr.sin_addr = loopback_addr;\n\n\t } else {\n\n\t addr.sin_addr = loopback_addr;\n\n\t }\n\n\t} else\n\n\t addr.sin_addr = so->so_faddr;\n\n\taddr.sin_port = so->so_fport;\n\n\n\n\tDEBUG_MISC((dfd, \" sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\\n\", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));\n\n\n\n\t/* Don't care what port we get */\n\n\tret = sendto(so->s, m->m_data, m->m_len, 0,\n\n\t\t (struct sockaddr *)&addr, sizeof (struct sockaddr));\n\n\tif (ret < 0)\n\n\t\treturn -1;\n\n\n\n\t/*\n\n\t * Kill the socket if there's no reply in 4 minutes,\n\n\t * but only if it's an expirable socket\n\n\t */\n\n\tif (so->so_expire)\n\n\t\tso->so_expire = curtime + SO_EXPIRE;\n\n\tso->so_state &= SS_PERSISTENT_MASK;\n\n\tso->so_state |= SS_ISFCONNECTED; /* So that it gets select()ed */\n\n\treturn 0;\n\n}\n", + "output": "0", + "index": 4847 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_synth_direntry(V9fsSynthNode *node,\n\n struct dirent *entry, off_t off)\n\n{\n\n strcpy(entry->d_name, node->name);\n\n entry->d_ino = node->attr->inode;\n\n entry->d_off = off + 1;\n\n}\n", + "output": "0", + "index": 14390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qcrypto_init(Error **errp)\n\n{\n\n int ret;\n\n ret = gnutls_global_init();\n\n if (ret < 0) {\n\n error_setg(errp,\n\n \"Unable to initialize GNUTLS library: %s\",\n\n gnutls_strerror(ret));\n\n return -1;\n\n }\n\n#ifdef DEBUG_GNUTLS\n\n gnutls_global_set_log_level(10);\n\n gnutls_global_set_log_function(qcrypto_gnutls_log);\n\n#endif\n\n\n\n#ifdef CONFIG_GNUTLS_GCRYPT\n\n if (!gcry_check_version(GCRYPT_VERSION)) {\n\n error_setg(errp, \"Unable to initialize gcrypt\");\n\n return -1;\n\n }\n\n#ifdef QCRYPTO_INIT_GCRYPT_THREADS\n\n gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl);\n\n#endif /* QCRYPTO_INIT_GCRYPT_THREADS */\n\n gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);\n\n#endif\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 99 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_uncompressed_sgi(unsigned char* out_buf, uint8_t* out_end,\n\n const uint8_t *in_buf, const uint8_t *in_end, SgiState* s)\n\n{\n\n int x, y, z;\n\n const uint8_t *ptr;\n\n unsigned int offset = s->height * s->width * s->bytes_per_channel;\n\n\n\n /* Test buffer size. */\n\n if (offset * s->depth > in_end - in_buf) {\n\n return -1;\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 for (x = s->width; x > 0; x--) {\n\n ptr = in_buf += s->bytes_per_channel;\n\n for(z = 0; z < s->depth; z ++) {\n\n memcpy(out_end, ptr, s->bytes_per_channel);\n\n out_end += s->bytes_per_channel;\n\n ptr += offset;\n\n }\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 2676 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mmf_probe(AVProbeData *p)\n\n{\n\n /* check file header */\n\n if (p->buf_size <= 32)\n\n return 0;\n\n if (p->buf[0] == 'M' && p->buf[1] == 'M' &&\n\n p->buf[2] == 'M' && p->buf[3] == 'D' &&\n\n p->buf[8] == 'C' && p->buf[9] == 'N' &&\n\n p->buf[10] == 'T' && p->buf[11] == 'I')\n\n return AVPROBE_SCORE_MAX;\n\n else\n\n return 0;\n\n}\n", + "output": "0", + "index": 238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_kvm_init_cpu_signals(CPUState *env)\n\n{\n\n int r;\n\n sigset_t set;\n\n struct sigaction sigact;\n\n\n\n memset(&sigact, 0, sizeof(sigact));\n\n sigact.sa_handler = dummy_signal;\n\n sigaction(SIG_IPI, &sigact, NULL);\n\n\n\n#ifdef CONFIG_IOTHREAD\n\n pthread_sigmask(SIG_BLOCK, NULL, &set);\n\n sigdelset(&set, SIG_IPI);\n\n sigdelset(&set, SIGBUS);\n\n r = kvm_set_signal_mask(env, &set);\n\n if (r) {\n\n fprintf(stderr, \"kvm_set_signal_mask: %s\\n\", strerror(-r));\n\n exit(1);\n\n }\n\n#else\n\n sigemptyset(&set);\n\n sigaddset(&set, SIG_IPI);\n\n sigaddset(&set, SIGIO);\n\n sigaddset(&set, SIGALRM);\n\n pthread_sigmask(SIG_BLOCK, &set, NULL);\n\n\n\n pthread_sigmask(SIG_BLOCK, NULL, &set);\n\n sigdelset(&set, SIGIO);\n\n sigdelset(&set, SIGALRM);\n\n#endif\n\n sigdelset(&set, SIG_IPI);\n\n sigdelset(&set, SIGBUS);\n\n r = kvm_set_signal_mask(env, &set);\n\n if (r) {\n\n fprintf(stderr, \"kvm_set_signal_mask: %s\\n\", strerror(-r));\n\n exit(1);\n\n }\n\n}\n", + "output": "1", + "index": 20312 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid, int stream_type)\n\n{\n\n MpegTSFilter *tss;\n\n PESContext *pes;\n\n\n\n /* if no pid found, then add a pid context */\n\n pes = av_mallocz(sizeof(PESContext));\n\n if (!pes)\n\n return 0;\n\n pes->ts = ts;\n\n pes->stream = ts->stream;\n\n pes->pid = pid;\n\n pes->pcr_pid = pcr_pid;\n\n pes->stream_type = stream_type;\n\n pes->state = MPEGTS_SKIP;\n\n pes->pts = AV_NOPTS_VALUE;\n\n pes->dts = AV_NOPTS_VALUE;\n\n tss = mpegts_open_pes_filter(ts, pid, mpegts_push_data, pes);\n\n if (!tss) {\n\n av_free(pes);\n\n return 0;\n\n }\n\n return pes;\n\n}\n", + "output": "0", + "index": 23425 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "long do_rt_sigreturn(CPUM68KState *env)\n\n{\n\n struct target_rt_sigframe *frame;\n\n abi_ulong frame_addr = env->aregs[7] - 4;\n\n target_sigset_t target_set;\n\n sigset_t set;\n\n\n\n trace_user_do_rt_sigreturn(env, frame_addr);\n\n if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))\n\n goto badframe;\n\n\n\n target_to_host_sigset_internal(&set, &target_set);\n\n set_sigmask(&set);\n\n\n\n /* restore registers */\n\n\n\n if (target_rt_restore_ucontext(env, &frame->uc))\n\n goto badframe;\n\n\n\n if (do_sigaltstack(frame_addr +\n\n offsetof(struct target_rt_sigframe, uc.tuc_stack),\n\n 0, get_sp_from_cpustate(env)) == -EFAULT)\n\n goto badframe;\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);\n\n return 0;\n\n}\n", + "output": "1", + "index": 24893 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int buf_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)\n\n{\n\n QEMUBuffer *s = opaque;\n\n ssize_t len = qsb_get_length(s->qsb) - pos;\n\n\n\n if (len <= 0) {\n\n return 0;\n\n }\n\n\n\n if (len > size) {\n\n len = size;\n\n }\n\n return qsb_get_buffer(s->qsb, pos, len, buf);\n\n}\n", + "output": "1", + "index": 12550 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dequantization_float(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 float *datap = &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] = (float)(t1->data[j][i]) * band->f_stepsize;\n\n }\n\n}\n", + "output": "1", + "index": 12082 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_user_cleanup(NetClientState *nc)\n\n{\n\n VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);\n\n\n\n vhost_user_stop(s);\n\n qemu_purge_queued_packets(nc);\n\n}\n", + "output": "0", + "index": 16857 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_breakpoint_remove_all(CPUState *env, int mask)\n\n{\n\n#if defined(TARGET_HAS_ICE)\n\n CPUBreakpoint *bp, *next;\n\n\n\n TAILQ_FOREACH_SAFE(bp, &env->breakpoints, entry, next) {\n\n if (bp->flags & mask)\n\n cpu_breakpoint_remove_by_ref(env, bp);\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 26155 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "assigned_dev_msix_mmio_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n AssignedDevice *adev = opaque;\n\n uint64_t val;\n\n\n\n memcpy(&val, (void *)((uint8_t *)adev->msix_table + addr), size);\n\n\n\n return val;\n\n}\n", + "output": "0", + "index": 5643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rndis_query_response(USBNetState *s,\n\n rndis_query_msg_type *buf, unsigned int length)\n\n{\n\n rndis_query_cmplt_type *resp;\n\n /* oid_supported_list is the largest data reply */\n\n uint8_t infobuf[sizeof(oid_supported_list)];\n\n uint32_t bufoffs, buflen;\n\n int infobuflen;\n\n unsigned int resplen;\n\n\n\n bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;\n\n buflen = le32_to_cpu(buf->InformationBufferLength);\n\n if (bufoffs + buflen > length)\n\n return USB_RET_STALL;\n\n\n\n infobuflen = ndis_query(s, le32_to_cpu(buf->OID),\n\n bufoffs + (uint8_t *) buf, buflen, infobuf,\n\n sizeof(infobuf));\n\n resplen = sizeof(rndis_query_cmplt_type) +\n\n ((infobuflen < 0) ? 0 : infobuflen);\n\n resp = rndis_queue_response(s, resplen);\n\n if (!resp)\n\n return USB_RET_STALL;\n\n\n\n resp->MessageType = cpu_to_le32(RNDIS_QUERY_CMPLT);\n\n resp->RequestID = buf->RequestID; /* Still LE in msg buffer */\n\n resp->MessageLength = cpu_to_le32(resplen);\n\n\n\n if (infobuflen < 0) {\n\n /* OID not supported */\n\n resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);\n\n resp->InformationBufferLength = cpu_to_le32(0);\n\n resp->InformationBufferOffset = cpu_to_le32(0);\n\n return 0;\n\n }\n\n\n\n resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);\n\n resp->InformationBufferOffset =\n\n cpu_to_le32(infobuflen ? sizeof(rndis_query_cmplt_type) - 8 : 0);\n\n resp->InformationBufferLength = cpu_to_le32(infobuflen);\n\n memcpy(resp + 1, infobuf, infobuflen);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 17607 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int do_balloon(Monitor *mon, const QDict *params,\n\n\t MonitorCompletion cb, void *opaque)\n\n{\n\n int ret;\n\n\n\n if (kvm_enabled() && !kvm_has_sync_mmu()) {\n\n qerror_report(QERR_KVM_MISSING_CAP, \"synchronous MMU\", \"balloon\");\n\n return -1;\n\n }\n\n\n\n ret = qemu_balloon(qdict_get_int(params, \"value\"));\n\n if (ret == 0) {\n\n qerror_report(QERR_DEVICE_NOT_ACTIVE, \"balloon\");\n\n return -1;\n\n }\n\n\n\n cb(opaque, NULL);\n\n return 0;\n\n}\n", + "output": "0", + "index": 4925 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void aio_set_fd_handler(AioContext *ctx,\n\n int fd,\n\n bool is_external,\n\n IOHandler *io_read,\n\n IOHandler *io_write,\n\n void *opaque)\n\n{\n\n AioHandler *node;\n\n bool is_new = false;\n\n\n\n node = find_aio_handler(ctx, fd);\n\n\n\n /* Are we deleting the fd handler? */\n\n if (!io_read && !io_write) {\n\n if (node) {\n\n g_source_remove_poll(&ctx->source, &node->pfd);\n\n\n\n /* If the lock is held, just mark the node as deleted */\n\n if (ctx->walking_handlers) {\n\n node->deleted = 1;\n\n node->pfd.revents = 0;\n\n } else {\n\n /* Otherwise, delete it for real. We can't just mark it as\n\n * deleted because deleted nodes are only cleaned up after\n\n * releasing the walking_handlers lock.\n\n */\n\n QLIST_REMOVE(node, node);\n\n g_free(node);\n\n }\n\n }\n\n } else {\n\n if (node == NULL) {\n\n /* Alloc and insert if it's not already there */\n\n node = g_new0(AioHandler, 1);\n\n node->pfd.fd = fd;\n\n QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);\n\n\n\n g_source_add_poll(&ctx->source, &node->pfd);\n\n is_new = true;\n\n }\n\n /* Update handler with latest information */\n\n node->io_read = io_read;\n\n node->io_write = io_write;\n\n node->opaque = opaque;\n\n node->is_external = is_external;\n\n\n\n node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);\n\n node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0);\n\n }\n\n\n\n aio_epoll_update(ctx, node, is_new);\n\n aio_notify(ctx);\n\n}\n", + "output": "1", + "index": 967 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)\n\n{\n\n VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev);\n\n DeviceState *vdev = DEVICE(&dev->vdev);\n\n\n\n qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));\n\n if (qdev_init(vdev) < 0) {\n\n return -1;\n\n }\n\n\n\n object_property_set_link(OBJECT(dev),\n\n OBJECT(dev->vdev.conf.default_backend), \"rng\",\n\n NULL);\n\n\n\n return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));\n\n}\n", + "output": "1", + "index": 8903 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dma_complete(DMAAIOCB *dbs, int ret)\n\n{\n\n trace_dma_complete(dbs, ret, dbs->common.cb);\n\n\n\n dma_bdrv_unmap(dbs);\n\n if (dbs->common.cb) {\n\n dbs->common.cb(dbs->common.opaque, ret);\n\n }\n\n qemu_iovec_destroy(&dbs->iov);\n\n if (dbs->bh) {\n\n qemu_bh_delete(dbs->bh);\n\n dbs->bh = NULL;\n\n }\n\n qemu_aio_unref(dbs);\n\n}\n", + "output": "0", + "index": 2183 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t buffered_get_rate_limit(void *opaque)\n\n{\n\n QEMUFileBuffered *s = opaque;\n\n \n\n return s->xfer_limit;\n\n}\n", + "output": "0", + "index": 14237 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void netmap_update_fd_handler(NetmapState *s)\n\n{\n\n qemu_set_fd_handler2(s->me.fd,\n\n s->read_poll ? netmap_can_send : NULL,\n\n s->read_poll ? netmap_send : NULL,\n\n s->write_poll ? netmap_writable : NULL,\n\n s);\n\n}\n", + "output": "0", + "index": 8667 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,\n\n uint64_t *cur_bytes)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n QCowL2Meta *old_alloc;\n\n uint64_t bytes = *cur_bytes;\n\n\n\n QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {\n\n\n\n uint64_t start = guest_offset;\n\n uint64_t end = start + bytes;\n\n uint64_t old_start = l2meta_cow_start(old_alloc);\n\n uint64_t old_end = l2meta_cow_end(old_alloc);\n\n\n\n if (end <= old_start || start >= old_end) {\n\n /* No intersection */\n\n } else {\n\n if (start < old_start) {\n\n /* Stop at the start of a running allocation */\n\n bytes = old_start - start;\n\n } else {\n\n bytes = 0;\n\n }\n\n\n\n if (bytes == 0) {\n\n /* Wait for the dependency to complete. We need to recheck\n\n * the free/allocated clusters when we continue. */\n\n qemu_co_mutex_unlock(&s->lock);\n\n qemu_co_queue_wait(&old_alloc->dependent_requests);\n\n qemu_co_mutex_lock(&s->lock);\n\n return -EAGAIN;\n\n }\n\n }\n\n }\n\n\n\n /* Make sure that existing clusters and new allocations are only used up to\n\n * the next dependency if we shortened the request above */\n\n *cur_bytes = bytes;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 9180 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr,\n\n int count, int copy)\n\n{\n\n struct target_iovec *target_vec;\n\n abi_ulong base;\n\n int i;\n\n\n\n target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);\n\n if (!target_vec)\n\n return -TARGET_EFAULT;\n\n for(i = 0;i < count; i++) {\n\n base = tswapl(target_vec[i].iov_base);\n\n unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0);\n\n }\n\n unlock_user (target_vec, target_addr, 0);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 26398 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_bootdevices(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 dependant 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 return bitmap;\n\n}\n", + "output": "0", + "index": 808 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,\n\n AVFilterInOut **open_inputs,\n\n AVFilterInOut **open_outputs, AVClass *log_ctx)\n\n{\n\n int ret, pad = 0;\n\n\n\n while (**buf == '[') {\n\n char *name = parse_link_name(buf, log_ctx);\n\n AVFilterInOut *match;\n\n\n\n AVFilterInOut *input = *curr_inputs;\n\n\n\n\n\n\n\n *curr_inputs = (*curr_inputs)->next;\n\n\n\n if (!name)\n\n\n\n\n /* First check if the label is not in the open_inputs list */\n\n match = extract_inout(name, open_inputs);\n\n\n\n if (match) {\n\n if ((ret = link_filter(input->filter_ctx, input->pad_idx,\n\n match->filter_ctx, match->pad_idx, log_ctx)) < 0)\n\n return ret;\n\n av_free(match->name);\n\n av_free(name);\n\n av_free(match);\n\n av_free(input);\n\n } else {\n\n /* Not in the list, so add the first input as a open_output */\n\n input->name = name;\n\n insert_inout(open_outputs, input);\n\n\n *buf += strspn(*buf, WHITESPACES);\n\n pad++;\n\n\n\n\n return pad;\n", + "output": "1", + "index": 21081 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gic_do_cpu_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n GICState **backref = (GICState **)opaque;\n\n GICState *s = *backref;\n\n int id = (backref - s->backref);\n\n gic_cpu_write(s, id, addr, value);\n\n}\n", + "output": "0", + "index": 20257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t omap_clkm_read(void *opaque, target_phys_addr_t 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 != 2) {\n\n return omap_badwidth_read16(opaque, addr);\n\n }\n\n\n\n switch (addr) {\n\n case 0x00:\t/* ARM_CKCTL */\n\n return s->clkm.arm_ckctl;\n\n\n\n case 0x04:\t/* ARM_IDLECT1 */\n\n return s->clkm.arm_idlect1;\n\n\n\n case 0x08:\t/* ARM_IDLECT2 */\n\n return s->clkm.arm_idlect2;\n\n\n\n case 0x0c:\t/* ARM_EWUPCT */\n\n return s->clkm.arm_ewupct;\n\n\n\n case 0x10:\t/* ARM_RSTCT1 */\n\n return s->clkm.arm_rstct1;\n\n\n\n case 0x14:\t/* ARM_RSTCT2 */\n\n return s->clkm.arm_rstct2;\n\n\n\n case 0x18:\t/* ARM_SYSST */\n\n return (s->clkm.clocking_scheme << 11) | s->clkm.cold_start;\n\n\n\n case 0x1c:\t/* ARM_CKOUT1 */\n\n return s->clkm.arm_ckout1;\n\n\n\n case 0x20:\t/* ARM_CKOUT2 */\n\n break;\n\n }\n\n\n\n OMAP_BAD_REG(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 8840 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)\n\n{\n\n AVStream *st = c->fc->streams[c->fc->nb_streams-1];\n\n int little_endian = get_be16(pb);\n\n\n\n dprintf(c->fc, \"enda %d\\n\", little_endian);\n\n if (little_endian == 1) {\n\n switch (st->codec->codec_id) {\n\n case CODEC_ID_PCM_S24BE:\n\n st->codec->codec_id = CODEC_ID_PCM_S24LE;\n\n break;\n\n case CODEC_ID_PCM_S32BE:\n\n st->codec->codec_id = CODEC_ID_PCM_S32LE;\n\n break;\n\n case CODEC_ID_PCM_F32BE:\n\n st->codec->codec_id = CODEC_ID_PCM_F32LE;\n\n break;\n\n case CODEC_ID_PCM_F64BE:\n\n st->codec->codec_id = CODEC_ID_PCM_F64LE;\n\n break;\n\n default:\n\n break;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 22295 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_sem_timedwait(QemuSemaphore *sem, int ms)\n\n{\n\n int rc;\n\n struct timespec ts;\n\n\n\n#if defined(__APPLE__) || defined(__NetBSD__)\n\n compute_abs_deadline(&ts, ms);\n\n pthread_mutex_lock(&sem->lock);\n\n --sem->count;\n\n while (sem->count < 0) {\n\n rc = pthread_cond_timedwait(&sem->cond, &sem->lock, &ts);\n\n if (rc == ETIMEDOUT) {\n\n\n break;\n\n }\n\n if (rc != 0) {\n\n error_exit(rc, __func__);\n\n }\n\n }\n\n pthread_mutex_unlock(&sem->lock);\n\n return (rc == ETIMEDOUT ? -1 : 0);\n\n#else\n\n if (ms <= 0) {\n\n /* This is cheaper than sem_timedwait. */\n\n do {\n\n rc = sem_trywait(&sem->sem);\n\n } while (rc == -1 && errno == EINTR);\n\n if (rc == -1 && errno == EAGAIN) {\n\n return -1;\n\n }\n\n } else {\n\n compute_abs_deadline(&ts, ms);\n\n do {\n\n rc = sem_timedwait(&sem->sem, &ts);\n\n } while (rc == -1 && errno == EINTR);\n\n if (rc == -1 && errno == ETIMEDOUT) {\n\n return -1;\n\n }\n\n }\n\n if (rc < 0) {\n\n error_exit(errno, __func__);\n\n }\n\n return 0;\n\n#endif\n\n}", + "output": "1", + "index": 9078 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,\n\n hwaddr data_addr, uint32_t data_width,\n\n hwaddr dma_addr, AddressSpace *dma_as)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *sbd;\n\n FWCfgState *s;\n\n bool dma_requested = dma_addr && dma_as;\n\n\n\n dev = qdev_create(NULL, TYPE_FW_CFG_MEM);\n\n qdev_prop_set_uint32(dev, \"data_width\", data_width);\n\n if (!dma_requested) {\n\n qdev_prop_set_bit(dev, \"dma_enabled\", false);\n\n }\n\n\n\n fw_cfg_init1(dev);\n\n\n\n sbd = SYS_BUS_DEVICE(dev);\n\n sysbus_mmio_map(sbd, 0, ctl_addr);\n\n sysbus_mmio_map(sbd, 1, data_addr);\n\n\n\n s = FW_CFG(dev);\n\n\n\n if (s->dma_enabled) {\n\n s->dma_as = dma_as;\n\n s->dma_addr = 0;\n\n sysbus_mmio_map(sbd, 2, dma_addr);\n\n }\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 6559 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcx_stip_writel(void *opaque, hwaddr addr,\n\n uint64_t val, unsigned size)\n\n{\n\n TCXState *s = opaque;\n\n int i;\n\n uint32_t col;\n\n\n\n if (!(addr & 4)) {\n\n s->tmpblit = val;\n\n } else {\n\n addr = (addr >> 3) & 0xfffff;\n\n col = cpu_to_be32(s->tmpblit);\n\n if (s->depth == 24) {\n\n for (i = 0; i < 32; i++) {\n\n if (val & 0x80000000) {\n\n s->vram[addr + i] = s->tmpblit;\n\n s->vram24[addr + i] = col;\n\n }\n\n val <<= 1;\n\n }\n\n } else {\n\n for (i = 0; i < 32; i++) {\n\n if (val & 0x80000000) {\n\n s->vram[addr + i] = s->tmpblit;\n\n }\n\n val <<= 1;\n\n }\n\n }\n\n memory_region_set_dirty(&s->vram_mem, addr, 32);\n\n }\n\n}\n", + "output": "0", + "index": 17016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ram_save_complete(QEMUFile *f, void *opaque)\n\n{\n\n rcu_read_lock();\n\n\n\n if (!migration_in_postcopy(migrate_get_current())) {\n\n migration_bitmap_sync();\n\n }\n\n\n\n ram_control_before_iterate(f, RAM_CONTROL_FINISH);\n\n\n\n /* try transferring iterative blocks of memory */\n\n\n\n /* flush all remaining blocks regardless of rate limiting */\n\n while (true) {\n\n int pages;\n\n\n\n pages = ram_find_and_save_block(f, true, &bytes_transferred);\n\n /* no more blocks to sent */\n\n if (pages == 0) {\n\n break;\n\n }\n\n }\n\n\n\n flush_compressed_data(f);\n\n ram_control_after_iterate(f, RAM_CONTROL_FINISH);\n\n\n\n rcu_read_unlock();\n\n\n\n qemu_put_be64(f, RAM_SAVE_FLAG_EOS);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 26968 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size)\n\n{\n\n VLANClientState *vc;\n\n\n\n for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {\n\n if (vc != sender && !vc->link_down) {\n\n vc->receive(vc->opaque, buf, size);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 26904 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "enum AVCodecID ff_guess_image2_codec(const char *filename)\n\n{\n\n return av_str2id(img_tags, filename);\n\n}\n", + "output": "0", + "index": 15908 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static hwaddr ppc_hash32_htab_lookup(PowerPCCPU *cpu,\n\n target_ulong sr, target_ulong eaddr,\n\n ppc_hash_pte32_t *pte)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n hwaddr pteg_off, pte_offset;\n\n hwaddr hash;\n\n uint32_t vsid, pgidx, ptem;\n\n\n\n vsid = sr & SR32_VSID;\n\n pgidx = (eaddr & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;\n\n hash = vsid ^ pgidx;\n\n ptem = (vsid << 7) | (pgidx >> 10);\n\n\n\n /* Page address translation */\n\n qemu_log_mask(CPU_LOG_MMU, \"htab_base \" TARGET_FMT_plx\n\n \" htab_mask \" TARGET_FMT_plx\n\n \" hash \" TARGET_FMT_plx \"\\n\",\n\n env->htab_base, env->htab_mask, hash);\n\n\n\n /* Primary PTEG lookup */\n\n qemu_log_mask(CPU_LOG_MMU, \"0 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\n \" vsid=%\" PRIx32 \" ptem=%\" PRIx32\n\n \" hash=\" TARGET_FMT_plx \"\\n\",\n\n env->htab_base, env->htab_mask, vsid, ptem, hash);\n\n pteg_off = get_pteg_offset32(cpu, hash);\n\n pte_offset = ppc_hash32_pteg_search(cpu, pteg_off, 0, ptem, pte);\n\n if (pte_offset == -1) {\n\n /* Secondary PTEG lookup */\n\n qemu_log_mask(CPU_LOG_MMU, \"1 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\n \" vsid=%\" PRIx32 \" api=%\" PRIx32\n\n \" hash=\" TARGET_FMT_plx \"\\n\", env->htab_base,\n\n env->htab_mask, vsid, ptem, ~hash);\n\n pteg_off = get_pteg_offset32(cpu, ~hash);\n\n pte_offset = ppc_hash32_pteg_search(cpu, pteg_off, 1, ptem, pte);\n\n }\n\n\n\n return pte_offset;\n\n}\n", + "output": "0", + "index": 7337 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)\n\n{\n\n if (cid != ctx->cid) {\n\n int index;\n\n\n\n if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {\n\n av_log(ctx->avctx, AV_LOG_ERROR, \"unsupported cid %d\\n\", cid);\n\n return AVERROR(ENOSYS);\n\n }\n\n if (ff_dnxhd_cid_table[index].bit_depth != ctx->bit_depth) {\n\n av_log(ctx->avctx, AV_LOG_ERROR, \"bit depth mismatches %d %d\\n\", ff_dnxhd_cid_table[index].bit_depth, ctx->bit_depth);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n ctx->cid_table = &ff_dnxhd_cid_table[index];\n\n av_log(ctx->avctx, AV_LOG_VERBOSE, \"Profile cid %d.\\n\", cid);\n\n\n\n ff_free_vlc(&ctx->ac_vlc);\n\n ff_free_vlc(&ctx->dc_vlc);\n\n ff_free_vlc(&ctx->run_vlc);\n\n\n\n init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,\n\n ctx->cid_table->ac_bits, 1, 1,\n\n ctx->cid_table->ac_codes, 2, 2, 0);\n\n init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->bit_depth + 4,\n\n ctx->cid_table->dc_bits, 1, 1,\n\n ctx->cid_table->dc_codes, 1, 1, 0);\n\n init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,\n\n ctx->cid_table->run_bits, 1, 1,\n\n ctx->cid_table->run_codes, 2, 2, 0);\n\n\n\n ctx->cid = cid;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 22089 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_codec_data(ByteIOContext *pb, AVStream *vst,\n\n AVStream *ast, int myth) {\n\n frametype_t frametype;\n\n if (!vst && !myth)\n\n return 1; // no codec data needed\n\n while (!url_feof(pb)) {\n\n int size, subtype;\n\n frametype = get_byte(pb);\n\n switch (frametype) {\n\n case NUV_EXTRADATA:\n\n subtype = get_byte(pb);\n\n url_fskip(pb, 6);\n\n size = PKTSIZE(get_le32(pb));\n\n if (subtype == 'R') {\n\n vst->codec->extradata_size = size;\n\n vst->codec->extradata = av_malloc(size);\n\n get_buffer(pb, vst->codec->extradata, size);\n\n size = 0;\n\n if (!myth)\n\n return 1;\n\n }\n\n break;\n\n case NUV_MYTHEXT:\n\n url_fskip(pb, 7);\n\n size = PKTSIZE(get_le32(pb));\n\n if (size != 128 * 4)\n\n break;\n\n get_le32(pb); // version\n\n if (vst) {\n\n vst->codec->codec_tag = get_le32(pb);\n\n vst->codec->codec_id =\n\n codec_get_id(codec_bmp_tags, vst->codec->codec_tag);\n\n } else\n\n url_fskip(pb, 4);\n\n\n\n if (ast) {\n\n ast->codec->codec_tag = get_le32(pb);\n\n ast->codec->sample_rate = get_le32(pb);\n\n ast->codec->bits_per_sample = get_le32(pb);\n\n ast->codec->channels = get_le32(pb);\n\n ast->codec->codec_id =\n\n wav_codec_get_id(ast->codec->codec_tag,\n\n ast->codec->bits_per_sample);\n\n } else\n\n url_fskip(pb, 4 * 4);\n\n\n\n size -= 6 * 4;\n\n url_fskip(pb, size);\n\n return 1;\n\n case NUV_SEEKP:\n\n size = 11;\n\n break;\n\n default:\n\n url_fskip(pb, 7);\n\n size = PKTSIZE(get_le32(pb));\n\n break;\n\n }\n\n url_fskip(pb, size);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 6215 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "virtio_crypto_check_cryptodev_is_used(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": "1", + "index": 21970 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "GAChannel *ga_channel_new(GAChannelMethod method, const gchar *path,\n\n GAChannelCallback cb, gpointer opaque)\n\n{\n\n GAChannel *c = g_malloc0(sizeof(GAChannel));\n\n SECURITY_ATTRIBUTES sec_attrs;\n\n\n\n if (!ga_channel_open(c, method, path)) {\n\n g_critical(\"error opening channel\");\n\n g_free(c);\n\n return NULL;\n\n }\n\n\n\n c->cb = cb;\n\n c->user_data = opaque;\n\n\n\n sec_attrs.nLength = sizeof(SECURITY_ATTRIBUTES);\n\n sec_attrs.lpSecurityDescriptor = NULL;\n\n sec_attrs.bInheritHandle = false;\n\n\n\n c->rstate.buf_size = QGA_READ_COUNT_DEFAULT;\n\n c->rstate.buf = g_malloc(QGA_READ_COUNT_DEFAULT);\n\n c->rstate.ov.hEvent = CreateEvent(&sec_attrs, FALSE, FALSE, NULL);\n\n\n\n c->source = ga_channel_create_watch(c);\n\n g_source_attach(c->source, NULL);\n\n return c;\n\n}\n", + "output": "1", + "index": 3880 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,\n\n unsigned long vga_ram_offset, 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 vga_reset(s);\n\n\n\n s->vram_ptr = vga_ram_base;\n\n s->vram_offset = vga_ram_offset;\n\n s->vram_size = vga_ram_size;\n\n s->ds = ds;\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 memset(&s->retrace_info, 0, sizeof (s->retrace_info));\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 8971 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int omap2_intc_init(SysBusDevice *sbd)\n\n{\n\n DeviceState *dev = DEVICE(sbd);\n\n struct omap_intr_handler_s *s = OMAP_INTC(dev);\n\n\n\n if (!s->iclk) {\n\n hw_error(\"omap2-intc: iclk not connected\\n\");\n\n }\n\n if (!s->fclk) {\n\n hw_error(\"omap2-intc: fclk not connected\\n\");\n\n }\n\n s->level_only = 1;\n\n s->nbanks = 3;\n\n sysbus_init_irq(sbd, &s->parent_intr[0]);\n\n sysbus_init_irq(sbd, &s->parent_intr[1]);\n\n qdev_init_gpio_in(dev, omap_set_intr_noedge, s->nbanks * 32);\n\n memory_region_init_io(&s->mmio, OBJECT(s), &omap2_inth_mem_ops, s,\n\n \"omap2-intc\", 0x1000);\n\n sysbus_init_mmio(sbd, &s->mmio);\n\n return 0;\n\n}\n", + "output": "1", + "index": 19742 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int net_slirp_init(VLANState *vlan, const char *model, const char *name)\n\n{\n\n if (!slirp_inited) {\n\n slirp_inited = 1;\n\n slirp_init(slirp_restrict, slirp_ip);\n\n }\n\n slirp_vc = qemu_new_vlan_client(vlan, model, name,\n\n slirp_receive, NULL, NULL, NULL);\n\n slirp_vc->info_str[0] = '\\0';\n\n return 0;\n\n}\n", + "output": "0", + "index": 13580 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void raw_refresh_limits(BlockDriverState *bs, Error **errp)\n\n{\n\n BDRVRawState *s = bs->opaque;\n\n struct stat st;\n\n\n\n if (!fstat(s->fd, &st)) {\n\n if (S_ISBLK(st.st_mode)) {\n\n int ret = hdev_get_max_transfer_length(s->fd);\n\n if (ret >= 0) {\n\n bs->bl.max_transfer_length = ret;\n\n }\n\n }\n\n }\n\n\n\n raw_probe_alignment(bs, s->fd, errp);\n\n bs->bl.min_mem_alignment = s->buf_align;\n\n bs->bl.opt_mem_alignment = MAX(s->buf_align, getpagesize());\n\n}\n", + "output": "0", + "index": 7426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int wav_read_header(AVFormatContext *s,\n\n AVFormatParameters *ap)\n\n{\n\n int size;\n\n unsigned int tag;\n\n ByteIOContext *pb = s->pb;\n\n AVStream *st;\n\n WAVContext *wav = s->priv_data;\n\n\n\n /* check RIFF header */\n\n tag = get_le32(pb);\n\n\n\n if (tag != MKTAG('R', 'I', 'F', 'F'))\n\n return -1;\n\n get_le32(pb); /* file size */\n\n tag = get_le32(pb);\n\n if (tag != MKTAG('W', 'A', 'V', 'E'))\n\n return -1;\n\n\n\n /* parse fmt header */\n\n size = find_tag(pb, MKTAG('f', 'm', 't', ' '));\n\n if (size < 0)\n\n return -1;\n\n st = av_new_stream(s, 0);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n get_wav_header(pb, st->codec, size);\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_tag(pb, MKTAG('d', 'a', 't', 'a'));\n\n if (size < 0)\n\n return -1;\n\n wav->data_end= url_ftell(pb) + size;\n\n return 0;\n\n}\n", + "output": "1", + "index": 8202 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n MP3Context *mp3 = s->priv_data;\n\n\n\n if (pkt && pkt->data && pkt->size >= 4) {\n\n MPADecodeHeader c;\n\n int av_unused base;\n\n\n\n avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));\n\n\n\n if (!mp3->initial_bitrate)\n\n mp3->initial_bitrate = c.bit_rate;\n\n if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))\n\n mp3->has_variable_bitrate = 1;\n\n\n\n#ifdef FILTER_VBR_HEADERS\n\n /* filter out XING and INFO headers. */\n\n base = 4 + xing_offtbl[c.lsf == 1][c.nb_channels == 1];\n\n\n\n if (base + 4 <= pkt->size) {\n\n uint32_t v = AV_RB32(pkt->data + base);\n\n\n\n if (MKBETAG('X','i','n','g') == v || MKBETAG('I','n','f','o') == v)\n\n return 0;\n\n }\n\n\n\n /* filter out VBRI headers. */\n\n base = 4 + 32;\n\n\n\n if (base + 4 <= pkt->size && MKBETAG('V','B','R','I') == AV_RB32(pkt->data + base))\n\n return 0;\n\n#endif\n\n\n\n if (mp3->xing_offset)\n\n mp3_xing_add_frame(mp3, pkt);\n\n }\n\n\n\n return ff_raw_write_packet(s, pkt);\n\n}\n", + "output": "0", + "index": 27230 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_wrpstate(CPUSPARCState *env, target_ulong new_state)\n\n{\n\n cpu_change_pstate(env, new_state & 0xf3f);\n\n\n\n#if !defined(CONFIG_USER_ONLY)\n\n if (cpu_interrupts_enabled(env)) {\n\n\n cpu_check_irqs(env);\n\n\n }\n\n#endif\n\n}", + "output": "1", + "index": 4373 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)\n\n{\n\n JNIEnv *env = NULL;\n\n FFAMediaCodec *codec = NULL;\n\n jstring mime_type = NULL;\n\n\n\n codec = av_mallocz(sizeof(FFAMediaCodec));\n\n if (!codec) {\n\n return NULL;\n\n }\n\n codec->class = &amediacodec_class;\n\n\n\n env = ff_jni_get_env(codec);\n\n if (!env) {\n\n av_freep(&codec);\n\n return NULL;\n\n }\n\n\n\n if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {\n\n goto fail;\n\n }\n\n\n\n mime_type = ff_jni_utf_chars_to_jstring(env, mime, codec);\n\n if (!mime_type) {\n\n goto fail;\n\n }\n\n\n\n codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_decoder_by_type_id, mime_type);\n\n if (ff_jni_exception_check(env, 1, codec) < 0) {\n\n goto fail;\n\n }\n\n\n\n codec->object = (*env)->NewGlobalRef(env, codec->object);\n\n if (!codec->object) {\n\n goto fail;\n\n }\n\n\n\n if (codec_init_static_fields(codec) < 0) {\n\n goto fail;\n\n }\n\n\n\n if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {\n\n codec->has_get_i_o_buffer = 1;\n\n }\n\n\n\n return codec;\n\nfail:\n\n ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);\n\n\n\n if (mime_type) {\n\n (*env)->DeleteLocalRef(env, mime_type);\n\n }\n\n\n\n av_freep(&codec);\n\n\n\n return NULL;\n\n}\n", + "output": "1", + "index": 6696 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_tablet_class_initfn(ObjectClass *klass, void *data)\n\n{\n\n USBDeviceClass *uc = USB_DEVICE_CLASS(klass);\n\n\n\n uc->init = usb_tablet_initfn;\n\n uc->product_desc = \"QEMU USB Tablet\";\n\n uc->usb_desc = &desc_tablet;\n\n uc->handle_packet = usb_generic_handle_packet;\n\n uc->handle_reset = usb_hid_handle_reset;\n\n uc->handle_control = usb_hid_handle_control;\n\n uc->handle_data = usb_hid_handle_data;\n\n uc->handle_destroy = usb_hid_handle_destroy;\n\n}\n", + "output": "0", + "index": 25814 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint8_t lag_calc_zero_run(int8_t x)\n\n{\n\n return (x << 1) ^ (x >> 7);\n\n}\n", + "output": "1", + "index": 2423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)\n\n{\n\n uint8_t read_mark;\n\n uint32_t read_section_id;\n\n\n\n if (skip_section_footers) {\n\n /* No footer to check */\n\n return true;\n\n }\n\n\n\n read_mark = qemu_get_byte(f);\n\n\n\n if (read_mark != QEMU_VM_SECTION_FOOTER) {\n\n error_report(\"Missing section footer for %s\", se->idstr);\n\n return false;\n\n }\n\n\n\n read_section_id = qemu_get_be32(f);\n\n if (read_section_id != se->section_id) {\n\n error_report(\"Mismatched section id in footer for %s -\"\n\n \" read 0x%x expected 0x%x\",\n\n se->idstr, read_section_id, se->section_id);\n\n return false;\n\n }\n\n\n\n /* All good */\n\n return true;\n\n}\n", + "output": "0", + "index": 21732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t ram_bytes_total(void)\n\n{\n\n return last_ram_offset;\n\n}\n", + "output": "0", + "index": 2995 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ppc_hash64_pte_prot(PowerPCCPU *cpu,\n\n ppc_slb_t *slb, ppc_hash_pte64_t pte)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n unsigned pp, key;\n\n /* Some pp bit combinations have undefined behaviour, so default\n\n * to no access in those cases */\n\n int prot = 0;\n\n\n\n key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP)\n\n : (slb->vsid & SLB_VSID_KS));\n\n pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61);\n\n\n\n if (key == 0) {\n\n switch (pp) {\n\n case 0x0:\n\n case 0x1:\n\n case 0x2:\n\n prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;\n\n break;\n\n\n\n case 0x3:\n\n case 0x6:\n\n prot = PAGE_READ | PAGE_EXEC;\n\n break;\n\n }\n\n } else {\n\n switch (pp) {\n\n case 0x0:\n\n case 0x6:\n\n break;\n\n\n\n case 0x1:\n\n case 0x3:\n\n prot = PAGE_READ | PAGE_EXEC;\n\n break;\n\n\n\n case 0x2:\n\n prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;\n\n break;\n\n }\n\n }\n\n\n\n /* No execute if either noexec or guarded bits set */\n\n if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G)\n\n || (slb->vsid & SLB_VSID_N)) {\n\n prot |= PAGE_EXEC;\n\n }\n\n\n\n return prot;\n\n}\n", + "output": "1", + "index": 715 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) {\n\n const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);\n\n int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;\n\n int alpha = alpha_table[index_a];\n\n 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*bsi]];\n\n tc[1] = tc0_table[index_a][bS[1*bsi]];\n\n tc[2] = tc0_table[index_a][bS[2*bsi]];\n\n tc[3] = tc0_table[index_a][bS[3*bsi]];\n\n h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);\n\n } else {\n\n h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);\n\n }\n\n}\n", + "output": "0", + "index": 7849 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base,\n\n qemu_irq *irqs)\n\n{\n\n int i;\n\n int iomemtype;\n\n pxa2xx_timer_info *s;\n\n\n\n s = (pxa2xx_timer_info *) qemu_mallocz(sizeof(pxa2xx_timer_info));\n\n s->base = base;\n\n s->irq_enabled = 0;\n\n s->oldclock = 0;\n\n s->clock = 0;\n\n s->lastload = qemu_get_clock(vm_clock);\n\n s->reset3 = 0;\n\n\n\n for (i = 0; i < 4; i ++) {\n\n s->timer[i].value = 0;\n\n s->timer[i].irq = irqs[i];\n\n s->timer[i].info = s;\n\n s->timer[i].num = i;\n\n s->timer[i].level = 0;\n\n s->timer[i].qtimer = qemu_new_timer(vm_clock,\n\n pxa2xx_timer_tick, &s->timer[i]);\n\n }\n\n\n\n iomemtype = cpu_register_io_memory(0, pxa2xx_timer_readfn,\n\n pxa2xx_timer_writefn, s);\n\n cpu_register_physical_memory(base, 0x00000fff, iomemtype);\n\n\n\n register_savevm(\"pxa2xx_timer\", 0, 0,\n\n pxa2xx_timer_save, pxa2xx_timer_load, s);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 26305 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_mfsr(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);\n\n#else\n\n TCGv t0;\n\n if (unlikely(ctx->pr)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);\n\n return;\n\n }\n\n t0 = tcg_const_tl(SR(ctx->opcode));\n\n gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);\n\n tcg_temp_free(t0);\n\n#endif\n\n}\n", + "output": "1", + "index": 19990 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)\n\n{\n\n BinkContext * const c = avctx->priv_data;\n\n GetBitContext gb;\n\n int plane, plane_idx, ret;\n\n int bits_count = pkt->size << 3;\n\n\n\n if (c->version > 'b') {\n\n if(c->pic->data[0])\n\n avctx->release_buffer(avctx, c->pic);\n\n\n\n if ((ret = ff_get_buffer(avctx, c->pic)) < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"get_buffer() failed\\n\");\n\n return ret;\n\n }\n\n } else {\n\n if ((ret = avctx->reget_buffer(avctx, c->pic)) < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"reget_buffer() failed\\n\");\n\n return ret;\n\n }\n\n }\n\n\n\n init_get_bits(&gb, pkt->data, bits_count);\n\n if (c->has_alpha) {\n\n if (c->version >= 'i')\n\n skip_bits_long(&gb, 32);\n\n if ((ret = bink_decode_plane(c, &gb, 3, 0)) < 0)\n\n return ret;\n\n }\n\n if (c->version >= 'i')\n\n skip_bits_long(&gb, 32);\n\n\n\n for (plane = 0; plane < 3; plane++) {\n\n plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);\n\n\n\n if (c->version > 'b') {\n\n if ((ret = bink_decode_plane(c, &gb, plane_idx, !!plane)) < 0)\n\n return ret;\n\n } else {\n\n if ((ret = binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane)) < 0)\n\n return ret;\n\n }\n\n if (get_bits_count(&gb) >= bits_count)\n\n break;\n\n }\n\n emms_c();\n\n\n\n *got_frame = 1;\n\n *(AVFrame*)data = *c->pic;\n\n\n\n if (c->version > 'b')\n\n FFSWAP(AVFrame*, c->pic, c->last);\n\n\n\n /* always report that the buffer was completely consumed */\n\n return pkt->size;\n\n}\n", + "output": "0", + "index": 11022 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_pci_generate_error_event(uint16_t pec, uint32_t fh,\n\n uint32_t fid, uint64_t faddr,\n\n uint32_t e)\n\n{\n\n s390_pci_generate_event(1, pec, fh, fid, faddr, e);\n\n}\n", + "output": "0", + "index": 21214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_network_init(void)\n\n{\n\n#if HAVE_WINSOCK2_H\n\n WSADATA wsaData;\n\n#endif\n\n\n\n if (!ff_network_inited_globally)\n\n av_log(NULL, AV_LOG_WARNING, \"Using network protocols without global \"\n\n \"network initialization. Please use \"\n\n \"avformat_network_init(), this will \"\n\n \"become mandatory later.\\n\");\n\n#if HAVE_WINSOCK2_H\n\n if (WSAStartup(MAKEWORD(1,1), &wsaData))\n\n return 0;\n\n#endif\n\n return 1;\n\n}\n", + "output": "0", + "index": 8801 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int compensate_volume(AVFilterContext *ctx)\n\n{\n\n struct SOFAlizerContext *s = ctx->priv;\n\n float compensate;\n\n float energy = 0;\n\n float *ir;\n\n int m;\n\n\n\n if (s->sofa.ncid) {\n\n /* find IR at front center position in the SOFA file (IR closest to 0\u00b0,0\u00b0,1m) */\n\n struct NCSofa *sofa = &s->sofa;\n\n m = find_m(s, 0, 0, 1);\n\n /* get energy of that IR and compensate volume */\n\n ir = sofa->data_ir + 2 * m * sofa->n_samples;\n\n if (sofa->n_samples & 31) {\n\n energy = avpriv_scalarproduct_float_c(ir, ir, sofa->n_samples);\n\n } else {\n\n energy = s->fdsp->scalarproduct_float(ir, ir, sofa->n_samples);\n\n }\n\n compensate = 256 / (sofa->n_samples * sqrt(energy));\n\n av_log(ctx, AV_LOG_DEBUG, \"Compensate-factor: %f\\n\", compensate);\n\n ir = sofa->data_ir;\n\n /* apply volume compensation to IRs */\n\n s->fdsp->vector_fmul_scalar(ir, ir, compensate, sofa->n_samples * sofa->m_dim * 2);\n\n emms_c();\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 19424 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rc4030_dma_tt_write(void *opaque, hwaddr addr, uint64_t data,\n\n unsigned int size)\n\n{\n\n rc4030State *s = opaque;\n\n\n\n /* write memory */\n\n memcpy(memory_region_get_ram_ptr(&s->dma_tt) + addr, &data, size);\n\n\n\n /* update dma address space (only if frame field has been written) */\n\n if (addr % sizeof(dma_pagetable_entry) == 0) {\n\n int index = addr / sizeof(dma_pagetable_entry);\n\n memory_region_transaction_begin();\n\n rc4030_dma_as_update_one(s, index, (uint32_t)data);\n\n memory_region_transaction_commit();\n\n }\n\n}\n", + "output": "1", + "index": 8231 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_unregister_device(DeviceState *dev)\n\n{\n\n PCIDevice *pci_dev = PCI_DEVICE(dev);\n\n PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);\n\n\n\n pci_unregister_io_regions(pci_dev);\n\n pci_del_option_rom(pci_dev);\n\n\n\n if (pc->exit) {\n\n pc->exit(pci_dev);\n\n }\n\n\n\n do_pci_unregister_device(pci_dev);\n\n return 0;\n\n}\n", + "output": "1", + "index": 19778 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_device_init(SCSIDevice *s)\n\n{\n\n SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);\n\n if (sc->init) {\n\n return sc->init(s);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 7017 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int shall_we_drop(AVFormatContext *s)\n\n{\n\n struct dshow_ctx *ctx = s->priv_data;\n\n static const uint8_t dropscore[] = {62, 75, 87, 100};\n\n const int ndropscores = FF_ARRAY_ELEMS(dropscore);\n\n unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;\n\n\n\n if(dropscore[++ctx->video_frame_num%ndropscores] <= buffer_fullness) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"real-time buffer %d%% full! frame dropped!\\n\", buffer_fullness);\n\n return 1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 9506 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs,\n\n int64_t sector_num,\n\n QEMUIOVector *qiov,\n\n int nb_sectors,\n\n BlockDriverCompletionFunc *cb,\n\n void *opaque, int write)\n\n{\n\n RBDAIOCB *acb;\n\n RADOSCB *rcb;\n\n rbd_completion_t c;\n\n int64_t off, size;\n\n char *buf;\n\n\n\n BDRVRBDState *s = bs->opaque;\n\n\n\n acb = qemu_aio_get(&rbd_aio_pool, bs, cb, opaque);\n\n acb->write = write;\n\n acb->qiov = qiov;\n\n acb->bounce = qemu_blockalign(bs, qiov->size);\n\n acb->ret = 0;\n\n acb->error = 0;\n\n acb->s = s;\n\n acb->cancelled = 0;\n\n acb->bh = NULL;\n\n\n\n if (write) {\n\n qemu_iovec_to_buffer(acb->qiov, acb->bounce);\n\n }\n\n\n\n buf = acb->bounce;\n\n\n\n off = sector_num * BDRV_SECTOR_SIZE;\n\n size = nb_sectors * BDRV_SECTOR_SIZE;\n\n\n\n s->qemu_aio_count++; /* All the RADOSCB */\n\n\n\n rcb = qemu_malloc(sizeof(RADOSCB));\n\n rcb->done = 0;\n\n rcb->acb = acb;\n\n rcb->buf = buf;\n\n rcb->s = acb->s;\n\n rcb->size = size;\n\n\n\n if (write) {\n\n rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);\n\n rbd_aio_write(s->image, off, size, buf, c);\n\n } else {\n\n rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);\n\n rbd_aio_read(s->image, off, size, buf, c);\n\n }\n\n\n\n return &acb->common;\n\n}\n", + "output": "1", + "index": 9280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,\n\n tcg_target_long value)\n\n{\n\n AArch64Insn insn;\n\n\n\n if (type == TCG_TYPE_I32) {\n\n value = (uint32_t)value;\n\n }\n\n\n\n /* count trailing zeros in 16 bit steps, mapping 64 to 0. Emit the\n\n first MOVZ with the half-word immediate skipping the zeros, with a shift\n\n (LSL) equal to this number. Then all next instructions use MOVKs.\n\n Zero the processed half-word in the value, continue until empty.\n\n We build the final result 16bits at a time with up to 4 instructions,\n\n but do not emit instructions for 16bit zero holes. */\n\n insn = I3405_MOVZ;\n\n do {\n\n unsigned shift = ctz64(value) & (63 & -16);\n\n tcg_out_insn_3405(s, insn, shift >= 32, rd, value >> shift, shift);\n\n value &= ~(0xffffUL << shift);\n\n insn = I3405_MOVK;\n\n } while (value);\n\n}\n", + "output": "0", + "index": 23180 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_opt_set_pixel_fmt(void *obj, const char *name, enum AVPixelFormat fmt, int search_flags)\n\n{\n\n return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_PIXEL_FMT, \"pixel\", AV_PIX_FMT_NB-1);\n\n}\n", + "output": "0", + "index": 13503 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,\n\n unsigned size)\n\n{\n\n mv88w8618_eth_state *s = opaque;\n\n\n\n switch (offset) {\n\n case MP_ETH_SMIR:\n\n if (s->smir & MP_ETH_SMIR_OPCODE) {\n\n switch (s->smir & MP_ETH_SMIR_ADDR) {\n\n case MP_ETH_PHY1_BMSR:\n\n return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |\n\n MP_ETH_SMIR_RDVALID;\n\n case MP_ETH_PHY1_PHYSID1:\n\n return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;\n\n case MP_ETH_PHY1_PHYSID2:\n\n return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;\n\n default:\n\n return MP_ETH_SMIR_RDVALID;\n\n }\n\n }\n\n return 0;\n\n\n\n case MP_ETH_ICR:\n\n return s->icr;\n\n\n\n case MP_ETH_IMR:\n\n return s->imr;\n\n\n\n case MP_ETH_FRDP0 ... MP_ETH_FRDP3:\n\n return s->frx_queue[(offset - MP_ETH_FRDP0)/4];\n\n\n\n case MP_ETH_CRDP0 ... MP_ETH_CRDP3:\n\n return s->rx_queue[(offset - MP_ETH_CRDP0)/4];\n\n\n\n case MP_ETH_CTDP0 ... MP_ETH_CTDP3:\n\n return s->tx_queue[(offset - MP_ETH_CTDP0)/4];\n\n\n\n default:\n\n return 0;\n\n }\n\n}\n", + "output": "1", + "index": 25334 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void memory_region_register_iommu_notifier(MemoryRegion *mr, Notifier *n)\n\n{\n\n if (mr->iommu_ops->notify_started &&\n\n QLIST_EMPTY(&mr->iommu_notify.notifiers)) {\n\n mr->iommu_ops->notify_started(mr);\n\n }\n\n notifier_list_add(&mr->iommu_notify, n);\n\n}\n", + "output": "0", + "index": 12748 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)\n\n{\n\n FILE *f;\n\n uint32_t size = qdict_get_int(qdict, \"size\");\n\n const char *filename = qdict_get_str(qdict, \"filename\");\n\n target_long addr = qdict_get_int(qdict, \"val\");\n\n uint32_t l;\n\n CPUState *env;\n\n uint8_t buf[1024];\n\n\n\n env = mon_get_cpu();\n\n if (!env)\n\n return;\n\n\n\n f = fopen(filename, \"wb\");\n\n if (!f) {\n\n monitor_printf(mon, \"could not open '%s'\\n\", filename);\n\n return;\n\n }\n\n while (size != 0) {\n\n l = sizeof(buf);\n\n if (l > size)\n\n l = size;\n\n cpu_memory_rw_debug(env, addr, buf, l, 0);\n\n fwrite(buf, 1, l, f);\n\n addr += l;\n\n size -= l;\n\n }\n\n fclose(f);\n\n}\n", + "output": "1", + "index": 9450 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QObject *qmp_dispatch(QObject *request)\n\n{\n\n Error *err = NULL;\n\n QObject *ret;\n\n QDict *rsp;\n\n\n\n ret = do_qmp_dispatch(request, &err);\n\n\n\n rsp = qdict_new();\n\n if (err) {\n\n qdict_put_obj(rsp, \"error\", error_get_qobject(err));\n\n error_free(err);\n\n } else if (ret) {\n\n qdict_put_obj(rsp, \"return\", ret);\n\n } else {\n\n QDECREF(rsp);\n\n return NULL;\n\n }\n\n\n\n return QOBJECT(rsp);\n\n}\n", + "output": "1", + "index": 25388 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,\n\n size_t iov_off, int fillc, size_t size)\n\n{\n\n size_t iovec_off, buf_off;\n\n unsigned int i;\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\n\n memset(iov[i].iov_base + (iov_off - iovec_off), fillc, 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": 476 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int teletext_close_decoder(AVCodecContext *avctx)\n\n{\n\n TeletextContext *ctx = avctx->priv_data;\n\n\n\n av_dlog(avctx, \"lines_total=%u\\n\", ctx->lines_processed);\n\n while (ctx->nb_pages)\n\n subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);\n\n av_freep(&ctx->pages);\n\n\n\n vbi_dvb_demux_delete(ctx->dx);\n\n vbi_decoder_delete(ctx->vbi);\n\n ctx->dx = NULL;\n\n ctx->vbi = NULL;\n\n ctx->pts = AV_NOPTS_VALUE;\n\n return 0;\n\n}\n", + "output": "1", + "index": 1315 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_qdev_exit(DeviceState *qdev)\n\n{\n\n SCSIDevice *dev = SCSI_DEVICE(qdev);\n\n\n\n if (dev->vmsentry) {\n\n qemu_del_vm_change_state_handler(dev->vmsentry);\n\n }\n\n scsi_device_destroy(dev);\n\n return 0;\n\n}\n", + "output": "0", + "index": 26069 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,\n\n AcpiCpuHotplug *gpe_cpu, uint16_t base)\n\n{\n\n CPUState *cpu;\n\n\n\n CPU_FOREACH(cpu) {\n\n acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort);\n\n }\n\n memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops,\n\n gpe_cpu, \"acpi-cpu-hotplug\", ACPI_GPE_PROC_LEN);\n\n memory_region_add_subregion(parent, base, &gpe_cpu->io);\n\n gpe_cpu->device = owner;\n\n}\n", + "output": "0", + "index": 16504 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_acpi_power_state(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 IPMI_CHECK_CMD_LEN(4);\n\n ibs->acpi_power_state[0] = cmd[2];\n\n ibs->acpi_power_state[1] = cmd[3];\n\n}\n", + "output": "1", + "index": 27280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong compute_tlbie_rb(target_ulong v, target_ulong r,\n\n target_ulong pte_index)\n\n{\n\n target_ulong rb, va_low;\n\n\n\n rb = (v & ~0x7fULL) << 16; /* AVA field */\n\n va_low = pte_index >> 3;\n\n if (v & HPTE64_V_SECONDARY) {\n\n va_low = ~va_low;\n\n }\n\n /* xor vsid from AVA */\n\n if (!(v & HPTE64_V_1TB_SEG)) {\n\n va_low ^= v >> 12;\n\n } else {\n\n va_low ^= v >> 24;\n\n }\n\n va_low &= 0x7ff;\n\n if (v & HPTE64_V_LARGE) {\n\n rb |= 1; /* L field */\n\n#if 0 /* Disable that P7 specific bit for now */\n\n if (r & 0xff000) {\n\n /* non-16MB large page, must be 64k */\n\n /* (masks depend on page size) */\n\n rb |= 0x1000; /* page encoding in LP field */\n\n rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */\n\n rb |= (va_low & 0xfe); /* AVAL field */\n\n }\n\n#endif\n\n } else {\n\n /* 4kB page */\n\n rb |= (va_low & 0x7ff) << 12; /* remaining 11b of AVA */\n\n }\n\n rb |= (v >> 54) & 0x300; /* B field */\n\n return rb;\n\n}\n", + "output": "1", + "index": 9008 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_hd_initfn(SCSIDevice *dev)\n\n{\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);\n\n s->qdev.blocksize = s->qdev.conf.logical_block_size;\n\n s->qdev.type = TYPE_DISK;\n\n if (!s->product) {\n\n s->product = g_strdup(\"QEMU HARDDISK\");\n\n }\n\n return scsi_initfn(&s->qdev);\n\n}\n", + "output": "0", + "index": 24039 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t omap_mpui_read(void *opaque, target_phys_addr_t 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 0x00:\t/* CTRL */\n\n return s->mpui_ctrl;\n\n case 0x04:\t/* DEBUG_ADDR */\n\n return 0x01ffffff;\n\n case 0x08:\t/* DEBUG_DATA */\n\n return 0xffffffff;\n\n case 0x0c:\t/* DEBUG_FLAG */\n\n return 0x00000800;\n\n case 0x10:\t/* STATUS */\n\n return 0x00000000;\n\n\n\n /* Not in OMAP310 */\n\n case 0x14:\t/* DSP_STATUS */\n\n case 0x18:\t/* DSP_BOOT_CONFIG */\n\n return 0x00000000;\n\n case 0x1c:\t/* DSP_MPUI_CONFIG */\n\n return 0x0000ffff;\n\n }\n\n\n\n OMAP_BAD_REG(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 15353 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void adb_kbd_reset(DeviceState *dev)\n\n{\n\n ADBDevice *d = ADB_DEVICE(dev);\n\n KBDState *s = ADB_KEYBOARD(dev);\n\n\n\n d->handler = 1;\n\n d->devaddr = ADB_DEVID_KEYBOARD;\n\n memset(s->data, 0, sizeof(s->data));\n\n s->rptr = 0;\n\n s->wptr = 0;\n\n s->count = 0;\n\n}\n", + "output": "1", + "index": 24068 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(qstring_destroy_test)\n\n{\n\n QString *qstring = qstring_from_str(\"destroy test\");\n\n QDECREF(qstring);\n\n}\n", + "output": "0", + "index": 10527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int arm946_prbs_read(CPUARMState *env, const ARMCPRegInfo *ri,\n\n uint64_t *value)\n\n{\n\n if (ri->crm > 8) {\n\n return EXCP_UDEF;\n\n }\n\n *value = env->cp15.c6_region[ri->crm];\n\n return 0;\n\n}\n", + "output": "1", + "index": 18469 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_bdlt(uint8_t *frame, int width, int height,\n\n const uint8_t *src, const uint8_t *src_end)\n\n{\n\n const uint8_t *frame_end = frame + width * height;\n\n uint8_t *line_ptr;\n\n int count, lines, segments;\n\n\n\n count = bytestream_get_le16(&src);\n\n if (count >= height || width * count < 0)\n\n return -1;\n\n frame += width * count;\n\n lines = bytestream_get_le16(&src);\n\n if (frame + lines * width > frame_end || src >= src_end)\n\n return -1;\n\n\n\n while (lines--) {\n\n line_ptr = frame;\n\n frame += width;\n\n segments = *src++;\n\n while (segments--) {\n\n if (src_end - src < 3)\n\n return -1;\n\n line_ptr += *src++;\n\n if (line_ptr >= frame)\n\n return -1;\n\n count = (int8_t)*src++;\n\n if (count >= 0) {\n\n if (line_ptr + count > frame || src_end - src < count)\n\n return -1;\n\n bytestream_get_buffer(&src, line_ptr, count);\n\n } else {\n\n count = -count;\n\n if (line_ptr + count > frame || src >= src_end)\n\n return -1;\n\n memset(line_ptr, *src++, count);\n\n }\n\n line_ptr += count;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 21331 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p)\n\n{\n\n int rc;\n\n\n\n trace_usb_host_set_config(s->bus_num, s->addr, config);\n\n\n\n usb_host_release_interfaces(s);\n\n usb_host_detach_kernel(s);\n\n rc = libusb_set_configuration(s->dh, config);\n\n if (rc != 0) {\n\n usb_host_libusb_error(\"libusb_set_configuration\", rc);\n\n p->status = USB_RET_STALL;\n\n if (rc == LIBUSB_ERROR_NO_DEVICE) {\n\n usb_host_nodev(s);\n\n }\n\n return;\n\n }\n\n p->status = usb_host_claim_interfaces(s, config);\n\n if (p->status != USB_RET_SUCCESS) {\n\n return;\n\n }\n\n usb_host_ep_update(s);\n\n}\n", + "output": "0", + "index": 25213 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_range_off(int *off, int *y_rng, int *uv_rng,\n\n enum AVColorRange rng, int depth)\n\n{\n\n switch (rng) {\n\n case AVCOL_RANGE_MPEG:\n\n *off = 16 << (depth - 8);\n\n *y_rng = 219 << (depth - 8);\n\n *uv_rng = 224 << (depth - 8);\n\n break;\n\n case AVCOL_RANGE_JPEG:\n\n *off = 0;\n\n *y_rng = *uv_rng = (256 << (depth - 8)) - 1;\n\n break;\n\n default:\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21755 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t dummy_section(MemoryRegion *mr)\n\n{\n\n MemoryRegionSection section = {\n\n .mr = mr,\n\n .offset_within_address_space = 0,\n\n .offset_within_region = 0,\n\n .size = int128_2_64(),\n\n };\n\n\n\n return phys_section_add(§ion);\n\n}\n", + "output": "0", + "index": 8623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int check_ap(CPUARMState *env, int ap, int domain_prot,\n\n int access_type, int is_user)\n\n{\n\n int prot_ro;\n\n\n\n if (domain_prot == 3) {\n\n return PAGE_READ | PAGE_WRITE;\n\n }\n\n\n\n if (access_type == 1)\n\n prot_ro = 0;\n\n else\n\n prot_ro = PAGE_READ;\n\n\n\n switch (ap) {\n\n case 0:\n\n if (access_type == 1)\n\n return 0;\n\n switch ((env->cp15.c1_sys >> 8) & 3) {\n\n case 1:\n\n return is_user ? 0 : PAGE_READ;\n\n case 2:\n\n return PAGE_READ;\n\n default:\n\n return 0;\n\n }\n\n case 1:\n\n return is_user ? 0 : PAGE_READ | PAGE_WRITE;\n\n case 2:\n\n if (is_user)\n\n return prot_ro;\n\n else\n\n return PAGE_READ | PAGE_WRITE;\n\n case 3:\n\n return PAGE_READ | PAGE_WRITE;\n\n case 4: /* Reserved. */\n\n return 0;\n\n case 5:\n\n return is_user ? 0 : prot_ro;\n\n case 6:\n\n return prot_ro;\n\n case 7:\n\n if (!arm_feature (env, ARM_FEATURE_V6K))\n\n return 0;\n\n return prot_ro;\n\n default:\n\n abort();\n\n }\n\n}\n", + "output": "0", + "index": 25160 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p,\n\n uint8_t ep)\n\n{\n\n AsyncURB *aurb = async_alloc(dev, p);\n\n struct usb_redir_bulk_packet_header bulk_packet;\n\n\n\n DPRINTF(\"bulk-out ep %02X len %zd id %u\\n\", ep,\n\n p->iov.size, aurb->packet_id);\n\n\n\n bulk_packet.endpoint = ep;\n\n bulk_packet.length = p->iov.size;\n\n bulk_packet.stream_id = 0;\n\n aurb->bulk_packet = bulk_packet;\n\n\n\n if (ep & USB_DIR_IN) {\n\n usbredirparser_send_bulk_packet(dev->parser, aurb->packet_id,\n\n &bulk_packet, NULL, 0);\n\n } else {\n\n uint8_t buf[p->iov.size];\n\n usb_packet_copy(p, buf, p->iov.size);\n\n usbredir_log_data(dev, \"bulk data out:\", buf, p->iov.size);\n\n usbredirparser_send_bulk_packet(dev->parser, aurb->packet_id,\n\n &bulk_packet, buf, p->iov.size);\n\n }\n\n usbredirparser_do_write(dev->parser);\n\n return USB_RET_ASYNC;\n\n}\n", + "output": "0", + "index": 26713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd)\n\n{\n\n qemu_mutex_init(&ssd->lock);\n\n QTAILQ_INIT(&ssd->updates);\n\n ssd->mouse_x = -1;\n\n ssd->mouse_y = -1;\n\n if (ssd->num_surfaces == 0) {\n\n ssd->num_surfaces = 1024;\n\n }\n\n ssd->bufsize = (16 * 1024 * 1024);\n\n ssd->buf = g_malloc(ssd->bufsize);\n\n}\n", + "output": "1", + "index": 11939 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int au_read_header(AVFormatContext *s)\n\n{\n\n int size;\n\n unsigned int tag;\n\n AVIOContext *pb = s->pb;\n\n unsigned int id, channels, rate;\n\n enum AVCodecID codec;\n\n AVStream *st;\n\n\n\n /* check \".snd\" header */\n\n tag = avio_rl32(pb);\n\n if (tag != MKTAG('.', 's', 'n', 'd'))\n\n return -1;\n\n size = avio_rb32(pb); /* header size */\n\n avio_rb32(pb); /* data size */\n\n\n\n id = avio_rb32(pb);\n\n rate = avio_rb32(pb);\n\n channels = avio_rb32(pb);\n\n\n\n codec = ff_codec_get_id(codec_au_tags, id);\n\n\n\n if (!av_get_bits_per_sample(codec)) {\n\n av_log_ask_for_sample(s, \"could not determine bits per sample\\n\");\n\n return AVERROR_PATCHWELCOME;\n\n }\n\n\n\n if (channels == 0 || channels > 64) {\n\n av_log(s, AV_LOG_ERROR, \"Invalid number of channels %d\\n\", channels);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n if (size >= 24) {\n\n /* skip unused data */\n\n avio_skip(pb, size - 24);\n\n }\n\n\n\n /* now we are ready: build format streams */\n\n st = avformat_new_stream(s, NULL);\n\n if (!st)\n\n return -1;\n\n st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n\n st->codec->codec_tag = id;\n\n st->codec->codec_id = codec;\n\n st->codec->channels = channels;\n\n st->codec->sample_rate = rate;\n\n avpriv_set_pts_info(st, 64, 1, rate);\n\n return 0;\n\n}\n", + "output": "0", + "index": 26853 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)\n\n{\n\n vhost_log_chunk_t *log;\n\n uint64_t log_base;\n\n int r;\n\n if (size) {\n\n log = g_malloc0(size * sizeof *log);\n\n } else {\n\n log = NULL;\n\n }\n\n log_base = (uint64_t)(unsigned long)log;\n\n r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);\n\n assert(r >= 0);\n\n vhost_client_sync_dirty_bitmap(&dev->client, 0,\n\n (target_phys_addr_t)~0x0ull);\n\n if (dev->log) {\n\n g_free(dev->log);\n\n }\n\n dev->log = log;\n\n dev->log_size = size;\n\n}\n", + "output": "1", + "index": 11818 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_evmwumiaa(DisasContext *ctx)\n\n{\n\n TCGv_i64 acc;\n\n TCGv_i64 tmp;\n\n\n\n if (unlikely(!ctx->spe_enabled)) {\n\n gen_exception(ctx, POWERPC_EXCP_APU);\n\n return;\n\n }\n\n\n\n gen_evmwumi(ctx); /* rD := rA * rB */\n\n\n\n acc = tcg_temp_new_i64();\n\n tmp = tcg_temp_new_i64();\n\n\n\n /* tmp := rD */\n\n gen_load_gpr64(tmp, rD(ctx->opcode));\n\n\n\n /* Load acc */\n\n tcg_gen_ld_i64(acc, cpu_env, offsetof(CPUState, spe_acc));\n\n\n\n /* acc := tmp + acc */\n\n tcg_gen_add_i64(acc, acc, tmp);\n\n\n\n /* Store acc */\n\n tcg_gen_st_i64(acc, cpu_env, offsetof(CPUState, spe_acc));\n\n\n\n /* rD := acc */\n\n gen_store_gpr64(rD(ctx->opcode), acc);\n\n\n\n tcg_temp_free_i64(acc);\n\n tcg_temp_free_i64(tmp);\n\n}\n", + "output": "0", + "index": 14847 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int thp_probe(AVProbeData *p)\n\n{\n\n /* check file header */\n\n if (AV_RL32(p->buf) == MKTAG('T', 'H', 'P', '\\0'))\n\n return AVPROBE_SCORE_MAX;\n\n else\n\n return 0;\n\n}\n", + "output": "1", + "index": 19773 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int mirror(int v, int m){\n\n if (v<0) return -v;\n\n else if(v>m) return 2*m-v;\n\n else return v;\n\n}\n", + "output": "1", + "index": 4769 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_chr_open_win(QemuOpts *opts, CharDriverState **_chr)\n\n{\n\n const char *filename = qemu_opt_get(opts, \"path\");\n\n CharDriverState *chr;\n\n WinCharState *s;\n\n\n\n chr = g_malloc0(sizeof(CharDriverState));\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 -EIO;\n\n }\n\n qemu_chr_generic_open(chr);\n\n\n\n *_chr = chr;\n\n return 0;\n\n}\n", + "output": "1", + "index": 19810 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_gp_timer_clk_setup(struct omap_gp_timer_s *timer)\n\n{\n\n omap_clk_adduser(timer->clk,\n\n qemu_allocate_irqs(omap_gp_timer_clk_update, timer, 1)[0]);\n\n timer->rate = omap_clk_getrate(timer->clk);\n\n}\n", + "output": "1", + "index": 12197 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_addco (void)\n\n{\n\n do_addco();\n\n RETURN();\n\n}\n", + "output": "1", + "index": 26930 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int floppy_probe_device(const char *filename)\n\n{\n\n int fd, ret;\n\n int prio = 0;\n\n struct floppy_struct fdparam;\n\n struct stat st;\n\n\n\n if (strstart(filename, \"/dev/fd\", NULL) &&\n\n !strstart(filename, \"/dev/fdset/\", NULL)) {\n\n prio = 50;\n\n }\n\n\n\n fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);\n\n if (fd < 0) {\n\n goto out;\n\n }\n\n ret = fstat(fd, &st);\n\n if (ret == -1 || !S_ISBLK(st.st_mode)) {\n\n goto outc;\n\n }\n\n\n\n /* Attempt to detect via a floppy specific ioctl */\n\n ret = ioctl(fd, FDGETPRM, &fdparam);\n\n if (ret >= 0)\n\n prio = 100;\n\n\n\noutc:\n\n qemu_close(fd);\n\nout:\n\n return prio;\n\n}\n", + "output": "1", + "index": 444 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t do_mac_read(lan9118_state *s, int reg)\n\n{\n\n switch (reg) {\n\n case MAC_CR:\n\n return s->mac_cr;\n\n case MAC_ADDRH:\n\n return s->conf.macaddr.a[4] | (s->conf.macaddr.a[5] << 8);\n\n case MAC_ADDRL:\n\n return s->conf.macaddr.a[0] | (s->conf.macaddr.a[1] << 8)\n\n | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24);\n\n case MAC_HASHH:\n\n return s->mac_hashh;\n\n break;\n\n case MAC_HASHL:\n\n return s->mac_hashl;\n\n break;\n\n case MAC_MII_ACC:\n\n return s->mac_mii_acc;\n\n case MAC_MII_DATA:\n\n return s->mac_mii_data;\n\n case MAC_FLOW:\n\n return s->mac_flow;\n\n default:\n\n hw_error(\"lan9118: Unimplemented MAC register read: %d\\n\",\n\n s->mac_cmd & 0xf);\n\n }\n\n}\n", + "output": "0", + "index": 4108 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)\n\n{\n\n int cpu_flags = av_get_cpu_flags();\n\n\n\n if (INLINE_MMX(cpu_flags))\n\n hpeldsp_init_mmx(c, flags);\n\n\n\n if (EXTERNAL_AMD3DNOW(cpu_flags))\n\n hpeldsp_init_3dnow(c, flags);\n\n\n\n if (EXTERNAL_MMXEXT(cpu_flags))\n\n hpeldsp_init_mmxext(c, flags);\n\n\n\n if (EXTERNAL_SSE2_FAST(cpu_flags))\n\n hpeldsp_init_sse2_fast(c, flags);\n\n\n\n if (CONFIG_VP3_DECODER)\n\n ff_hpeldsp_vp3_init_x86(c, cpu_flags, flags);\n\n}\n", + "output": "0", + "index": 18166 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ehci_state_writeback(EHCIQueue *q)\n\n{\n\n EHCIPacket *p = QTAILQ_FIRST(&q->packets);\n\n int again = 0;\n\n\n\n /* Write back the QTD from the QH area */\n\n assert(p != NULL);\n\n assert(p->qtdaddr == q->qtdaddr);\n\n\n\n ehci_trace_qtd(q, NLPTR_GET(p->qtdaddr), (EHCIqtd *) &q->qh.next_qtd);\n\n put_dwords(q->ehci, NLPTR_GET(p->qtdaddr), (uint32_t *) &q->qh.next_qtd,\n\n sizeof(EHCIqtd) >> 2);\n\n ehci_free_packet(p);\n\n\n\n /*\n\n * EHCI specs say go horizontal here.\n\n *\n\n * We can also advance the queue here for performance reasons. We\n\n * need to take care to only take that shortcut in case we've\n\n * processed the qtd just written back without errors, i.e. halt\n\n * bit is clear.\n\n */\n\n if (q->qh.token & QTD_TOKEN_HALT) {\n\n ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);\n\n again = 1;\n\n } else {\n\n ehci_set_state(q->ehci, q->async, EST_ADVANCEQUEUE);\n\n again = 1;\n\n }\n\n return again;\n\n}\n", + "output": "1", + "index": 4731 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_close(BlockDriverState *bs)\n\n{\n\n BdrvAioNotifier *ban, *ban_next;\n\n\n\n if (bs->job) {\n\n block_job_cancel_sync(bs->job);\n\n }\n\n\n\n /* Disable I/O limits and drain all pending throttled requests */\n\n if (bs->io_limits_enabled) {\n\n bdrv_io_limits_disable(bs);\n\n }\n\n\n\n bdrv_drain(bs); /* complete I/O */\n\n bdrv_flush(bs);\n\n bdrv_drain(bs); /* in case flush left pending I/O */\n\n notifier_list_notify(&bs->close_notifiers, bs);\n\n\n\n if (bs->drv) {\n\n BdrvChild *child, *next;\n\n\n\n bs->drv->bdrv_close(bs);\n\n bs->drv = NULL;\n\n\n\n bdrv_set_backing_hd(bs, NULL);\n\n\n\n if (bs->file != NULL) {\n\n bdrv_unref_child(bs, bs->file);\n\n bs->file = NULL;\n\n }\n\n\n\n QLIST_FOREACH_SAFE(child, &bs->children, next, next) {\n\n /* TODO Remove bdrv_unref() from drivers' close function and use\n\n * bdrv_unref_child() here */\n\n if (child->bs->inherits_from == bs) {\n\n child->bs->inherits_from = NULL;\n\n }\n\n bdrv_detach_child(child);\n\n }\n\n\n\n g_free(bs->opaque);\n\n bs->opaque = NULL;\n\n bs->copy_on_read = 0;\n\n bs->backing_file[0] = '\\0';\n\n bs->backing_format[0] = '\\0';\n\n bs->total_sectors = 0;\n\n bs->encrypted = 0;\n\n bs->valid_key = 0;\n\n bs->sg = 0;\n\n bs->zero_beyond_eof = false;\n\n QDECREF(bs->options);\n\n bs->options = NULL;\n\n QDECREF(bs->full_open_options);\n\n bs->full_open_options = NULL;\n\n }\n\n\n\n if (bs->blk) {\n\n blk_dev_change_media_cb(bs->blk, false);\n\n }\n\n\n\n QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_next) {\n\n g_free(ban);\n\n }\n\n QLIST_INIT(&bs->aio_notifiers);\n\n}\n", + "output": "0", + "index": 24195 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int opt_new_stream(const char *opt, const char *arg)\n\n{\n\n AVFormatContext *oc;\n\n if (nb_output_files <= 0) {\n\n fprintf(stderr, \"At least one output file must be specified\\n\");\n\n ffmpeg_exit(1);\n\n }\n\n oc = output_files[nb_output_files - 1];\n\n\n\n if (!strcmp(opt, \"newvideo\" )) new_video_stream (oc);\n\n else if (!strcmp(opt, \"newaudio\" )) new_audio_stream (oc);\n\n else if (!strcmp(opt, \"newsubtitle\")) new_subtitle_stream(oc);\n\n else av_assert0(0);\n\n return 0;\n\n}\n", + "output": "1", + "index": 713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1)\n\n{\n\n int cssid, ssid, schid, m;\n\n SubchDev *sch;\n\n int ret = -ENODEV;\n\n int cc;\n\n\n\n if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {\n\n program_interrupt(&cpu->env, PGM_OPERAND, 2);\n\n return;\n\n }\n\n trace_ioinst_sch_id(\"csch\", 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_csch(sch);\n\n }\n\n if (ret == -ENODEV) {\n\n cc = 3;\n\n } else {\n\n cc = 0;\n\n }\n\n setcc(cpu, cc);\n\n}\n", + "output": "0", + "index": 7940 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "type_init(pflash_cfi01_register_types)\n\n\n\npflash_t *pflash_cfi01_register(hwaddr base,\n\n DeviceState *qdev, const char *name,\n\n hwaddr size,\n\n BlockDriverState *bs,\n\n uint32_t sector_len, int nb_blocs,\n\n int bank_width, uint16_t id0, uint16_t id1,\n\n uint16_t id2, uint16_t id3, int be)\n\n{\n\n DeviceState *dev = qdev_create(NULL, TYPE_CFI_PFLASH01);\n\n\n\n if (bs && qdev_prop_set_drive(dev, \"drive\", bs)) {\n\n abort();\n\n }\n\n qdev_prop_set_uint32(dev, \"num-blocks\", nb_blocs);\n\n qdev_prop_set_uint64(dev, \"sector-length\", sector_len);\n\n qdev_prop_set_uint8(dev, \"width\", bank_width);\n\n qdev_prop_set_uint8(dev, \"big-endian\", !!be);\n\n qdev_prop_set_uint16(dev, \"id0\", id0);\n\n qdev_prop_set_uint16(dev, \"id1\", id1);\n\n qdev_prop_set_uint16(dev, \"id2\", id2);\n\n qdev_prop_set_uint16(dev, \"id3\", id3);\n\n qdev_prop_set_string(dev, \"name\", name);\n\n qdev_init_nofail(dev);\n\n\n\n sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);\n\n return CFI_PFLASH01(dev);\n\n}\n", + "output": "0", + "index": 20437 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qapi_copy_SocketAddress(SocketAddress **p_dest,\n\n SocketAddress *src)\n\n{\n\n QmpOutputVisitor *qov;\n\n Visitor *ov, *iv;\n\n QObject *obj;\n\n\n\n *p_dest = NULL;\n\n\n\n qov = qmp_output_visitor_new();\n\n ov = qmp_output_get_visitor(qov);\n\n visit_type_SocketAddress(ov, NULL, &src, &error_abort);\n\n obj = qmp_output_get_qobject(qov);\n\n visit_free(ov);\n\n if (!obj) {\n\n return;\n\n }\n\n\n\n iv = qmp_input_visitor_new(obj, true);\n\n visit_type_SocketAddress(iv, NULL, p_dest, &error_abort);\n\n visit_free(iv);\n\n qobject_decref(obj);\n\n}\n", + "output": "0", + "index": 11910 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width)\n\n{\n\n\tint i;\n\n\tfor(i=0; i>5)&0x3F;\n\n\t\tint b= (d>>11)&0x1F;\n\n\n\n\t\tdst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16;\n\n\t}\n\n}\n", + "output": "1", + "index": 13473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int no_init_out (HWVoiceOut *hw, struct audsettings *as)\n\n{\n\n audio_pcm_init_info (&hw->info, as);\n\n hw->samples = 1024;\n\n return 0;\n\n}\n", + "output": "1", + "index": 3377 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int msix_is_masked(PCIDevice *dev, int vector)\n\n{\n\n unsigned offset =\n\n vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;\n\n return dev->msix_function_masked ||\n\n\t dev->msix_table_page[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;\n\n}\n", + "output": "1", + "index": 19021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mxf_write_system_item(AVFormatContext *s)\n\n{\n\n MXFContext *mxf = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n unsigned frame;\n\n uint32_t time_code;\n\n\n\n frame = mxf->last_indexed_edit_unit + mxf->edit_units_count;\n\n\n\n // write system metadata pack\n\n avio_write(pb, system_metadata_pack_key, 16);\n\n klv_encode_ber4_length(pb, 57);\n\n avio_w8(pb, 0x5c); // UL, user date/time stamp, picture and sound item present\n\n avio_w8(pb, 0x04); // content package rate\n\n avio_w8(pb, 0x00); // content package type\n\n avio_wb16(pb, 0x00); // channel handle\n\n avio_wb16(pb, mxf->tc.start + frame); // continuity count\n\n if (mxf->essence_container_count > 1)\n\n avio_write(pb, multiple_desc_ul, 16);\n\n else {\n\n MXFStreamContext *sc = s->streams[0]->priv_data;\n\n avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);\n\n }\n\n avio_w8(pb, 0);\n\n avio_wb64(pb, 0);\n\n avio_wb64(pb, 0); // creation date/time stamp\n\n\n\n avio_w8(pb, 0x81); // SMPTE 12M time code\n\n time_code = av_timecode_get_smpte_from_framenum(&mxf->tc, frame);\n\n avio_wb32(pb, time_code);\n\n avio_wb32(pb, 0); // binary group data\n\n avio_wb64(pb, 0);\n\n\n\n // write system metadata package set\n\n avio_write(pb, system_metadata_package_set_key, 16);\n\n klv_encode_ber4_length(pb, 35);\n\n avio_w8(pb, 0x83); // UMID\n\n avio_wb16(pb, 0x20);\n\n mxf_write_umid(s, 1);\n\n}\n", + "output": "1", + "index": 24809 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len)\n\n{\n\n OpenPICState *opp = opaque;\n\n uint32_t retval;\n\n int idx;\n\n\n\n DPRINTF(\"%s: addr %#\" HWADDR_PRIx \"\\n\", __func__, addr);\n\n retval = 0xFFFFFFFF;\n\n if (addr & 0xF) {\n\n return retval;\n\n }\n\n addr = addr & 0xFFF0;\n\n idx = addr >> 5;\n\n if (addr & 0x10) {\n\n /* EXDE / IFEDE / IEEDE */\n\n retval = read_IRQreg_idr(opp, idx);\n\n } else {\n\n /* EXVP / IFEVP / IEEVP */\n\n retval = read_IRQreg_ivpr(opp, idx);\n\n }\n\n DPRINTF(\"%s: => 0x%08x\\n\", __func__, retval);\n\n\n\n return retval;\n\n}\n", + "output": "0", + "index": 14241 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_interrupt(CPUArchState *env, int mask)\n\n{\n\n CPUState *cpu = ENV_GET_CPU(env);\n\n\n\n env->interrupt_request |= mask;\n\n cpu_unlink_tb(cpu);\n\n}\n", + "output": "1", + "index": 1048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_tsw1(GetByteContext *gb, uint8_t *frame, int width, int height)\n\n{\n\n const uint8_t *frame_start = frame;\n\n const uint8_t *frame_end = frame + width * height;\n\n int mask = 0x10000, bitbuf = 0;\n\n int v, count, segments;\n\n unsigned offset;\n\n\n\n segments = bytestream2_get_le32(gb);\n\n offset = bytestream2_get_le32(gb);\n\n if (segments == 0 && offset == frame_end - frame)\n\n return 0; // skip frame\n\n if (frame_end - frame <= offset)\n\n return AVERROR_INVALIDDATA;\n\n frame += offset;\n\n while (segments--) {\n\n if (bytestream2_get_bytes_left(gb) < 2)\n\n return AVERROR_INVALIDDATA;\n\n if (mask == 0x10000) {\n\n bitbuf = bytestream2_get_le16u(gb);\n\n mask = 1;\n\n }\n\n if (frame_end - frame < 2)\n\n return AVERROR_INVALIDDATA;\n\n if (bitbuf & mask) {\n\n v = bytestream2_get_le16(gb);\n\n offset = (v & 0x1FFF) << 1;\n\n count = ((v >> 13) + 2) << 1;\n\n if (frame - frame_start < offset || frame_end - frame < count)\n\n return AVERROR_INVALIDDATA;\n\n av_memcpy_backptr(frame, offset, count);\n\n frame += count;\n\n } else {\n\n *frame++ = bytestream2_get_byte(gb);\n\n *frame++ = bytestream2_get_byte(gb);\n\n }\n\n mask <<= 1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18406 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *sigwait_compat(void *opaque)\n\n{\n\n struct sigfd_compat_info *info = opaque;\n\n int err;\n\n sigset_t all;\n\n\n\n sigfillset(&all);\n\n sigprocmask(SIG_BLOCK, &all, NULL);\n\n\n\n do {\n\n siginfo_t siginfo;\n\n\n\n err = sigwaitinfo(&info->mask, &siginfo);\n\n if (err == -1 && errno == EINTR) {\n\n err = 0;\n\n continue;\n\n }\n\n\n\n if (err > 0) {\n\n char buffer[128];\n\n size_t offset = 0;\n\n\n\n memcpy(buffer, &err, sizeof(err));\n\n while (offset < sizeof(buffer)) {\n\n ssize_t len;\n\n\n\n len = write(info->fd, buffer + offset,\n\n sizeof(buffer) - offset);\n\n if (len == -1 && errno == EINTR)\n\n continue;\n\n\n\n if (len <= 0) {\n\n err = -1;\n\n break;\n\n }\n\n\n\n offset += len;\n\n }\n\n }\n\n } while (err >= 0);\n\n\n\n return NULL;\n\n}\n", + "output": "1", + "index": 4147 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t ich_elrsr_read(CPUARMState *env, const ARMCPRegInfo *ri)\n\n{\n\n GICv3CPUState *cs = icc_cs_from_env(env);\n\n uint64_t value = 0;\n\n int i;\n\n\n\n for (i = 0; i < cs->num_list_regs; i++) {\n\n uint64_t lr = cs->ich_lr_el2[i];\n\n\n\n if ((lr & ICH_LR_EL2_STATE_MASK) == 0 &&\n\n ((lr & ICH_LR_EL2_HW) == 1 || (lr & ICH_LR_EL2_EOI) == 0)) {\n\n value |= (1 << i);\n\n }\n\n }\n\n\n\n trace_gicv3_ich_elrsr_read(gicv3_redist_affid(cs), value);\n\n return value;\n\n}\n", + "output": "1", + "index": 27161 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qcow_close(BlockDriverState *bs)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n\n\n g_free(s->l1_table);\n\n g_free(s->l2_cache);\n\n g_free(s->cluster_cache);\n\n g_free(s->cluster_data);\n\n\n\n migrate_del_blocker(s->migration_blocker);\n\n error_free(s->migration_blocker);\n\n}\n", + "output": "1", + "index": 23312 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BOOTPClient *get_new_addr(struct in_addr *paddr)\n\n{\n\n BOOTPClient *bc;\n\n int i;\n\n\n\n for(i = 0; i < NB_ADDR; i++) {\n\n if (!bootp_clients[i].allocated)\n\n goto found;\n\n }\n\n return NULL;\n\n found:\n\n bc = &bootp_clients[i];\n\n bc->allocated = 1;\n\n paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));\n\n return bc;\n\n}\n", + "output": "0", + "index": 12679 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static coroutine_fn int cloop_co_read(BlockDriverState *bs, int64_t sector_num,\n\n uint8_t *buf, int nb_sectors)\n\n{\n\n int ret;\n\n BDRVCloopState *s = bs->opaque;\n\n qemu_co_mutex_lock(&s->lock);\n\n ret = cloop_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": 6299 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)\n\n{\n\n int flags, in = -1, out = -1;\n\n\n\n flags = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY;\n\n out = qmp_chardev_open_file_source(file->out, flags, errp);\n\n if (error_is_set(errp)) {\n\n return NULL;\n\n }\n\n\n\n if (file->has_in) {\n\n flags = O_RDONLY;\n\n in = qmp_chardev_open_file_source(file->in, flags, errp);\n\n if (error_is_set(errp)) {\n\n qemu_close(out);\n\n return NULL;\n\n }\n\n }\n\n\n\n return qemu_chr_open_fd(in, out);\n\n}\n", + "output": "1", + "index": 14179 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void make_dirty(uint8_t device)\n\n{\n\n QPCIDevice *dev;\n\n QPCIBar bmdma_bar, ide_bar;\n\n uint8_t status;\n\n size_t len = 512;\n\n uintptr_t guest_buf;\n\n void* buf;\n\n\n\n dev = get_pci_device(&bmdma_bar, &ide_bar);\n\n\n\n guest_buf = guest_alloc(guest_malloc, len);\n\n buf = g_malloc(len);\n\n memset(buf, rand() % 255 + 1, len);\n\n g_assert(guest_buf);\n\n g_assert(buf);\n\n\n\n memwrite(guest_buf, buf, len);\n\n\n\n PrdtEntry prdt[] = {\n\n {\n\n .addr = cpu_to_le32(guest_buf),\n\n .size = cpu_to_le32(len | PRDT_EOT),\n\n },\n\n };\n\n\n\n status = send_dma_request(CMD_WRITE_DMA, 1, 1, prdt,\n\n ARRAY_SIZE(prdt), NULL);\n\n g_assert_cmphex(status, ==, BM_STS_INTR);\n\n assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);\n\n\n\n g_free(buf);\n\n\n}", + "output": "1", + "index": 3284 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_cpu_exec(void)\n\n{\n\n int ret = 0;\n\n\n\n if (next_cpu == NULL)\n\n next_cpu = first_cpu;\n\n for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {\n\n CPUState *env = cur_cpu = next_cpu;\n\n\n\n if (timer_alarm_pending) {\n\n timer_alarm_pending = 0;\n\n break;\n\n }\n\n if (cpu_can_run(env))\n\n ret = qemu_cpu_exec(env);\n\n else if (env->stop)\n\n break;\n\n\n\n if (ret == EXCP_DEBUG) {\n\n gdb_set_stop_cpu(env);\n\n debug_requested = 1;\n\n break;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 12118 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void musicpal_misc_write(void *opaque, target_phys_addr_t offset,\n\n uint64_t value, unsigned size)\n\n{\n\n}\n", + "output": "0", + "index": 21868 + }, + { + "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 AddressSpaceDispatch *d = address_space_memory.dispatch;\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(d, 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 invalidate_and_set_dirty(addr1, l);\n\n qemu_put_ram_ptr(ptr);\n\n }\n\n len -= l;\n\n buf += l;\n\n addr += l;\n\n }\n\n}\n", + "output": "0", + "index": 302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void select_vgahw (const char *p)\n{\n const char *opts;\n vga_interface_type = VGA_NONE;\n if (strstart(p, \"std\", &opts)) {\n if (vga_available()) {\n vga_interface_type = VGA_STD;\n fprintf(stderr, \"Error: standard VGA not available\\n\");\n exit(0);\n } else if (strstart(p, \"cirrus\", &opts)) {\n if (cirrus_vga_available()) {\n vga_interface_type = VGA_CIRRUS;\n fprintf(stderr, \"Error: Cirrus VGA not available\\n\");\n exit(0);\n } else if (strstart(p, \"vmware\", &opts)) {\n if (vmware_vga_available()) {\n vga_interface_type = VGA_VMWARE;\n fprintf(stderr, \"Error: VMWare SVGA not available\\n\");\n exit(0);\n } else if (strstart(p, \"xenfb\", &opts)) {\n vga_interface_type = VGA_XENFB;\n } else if (strstart(p, \"qxl\", &opts)) {\n vga_interface_type = VGA_QXL;\n } else if (!strstart(p, \"none\", &opts)) {\n invalid_vga:\n fprintf(stderr, \"Unknown vga type: %s\\n\", p);\n exit(1);\n const char *nextopt;\n if (strstart(opts, \",retrace=\", &nextopt)) {\n if (strstart(opts, \"dumb\", &nextopt))\n vga_retrace_method = VGA_RETRACE_DUMB;\n else if (strstart(opts, \"precise\", &nextopt))\n vga_retrace_method = VGA_RETRACE_PRECISE;\n else goto invalid_vga;\n } else goto invalid_vga;", + "output": "1", + "index": 1597 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)\n\n{\n\n AVFrame *tmp;\n\n int ret;\n\n\n\n av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);\n\n\n\n if (!frame->data[0])\n\n return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);\n\n\n\n if (av_frame_is_writable(frame)) {\n\n frame->pkt_pts = avctx->internal->pkt ? avctx->internal->pkt->pts : AV_NOPTS_VALUE;\n\n frame->reordered_opaque = avctx->reordered_opaque;\n\n return 0;\n\n }\n\n\n\n tmp = av_frame_alloc();\n\n if (!tmp)\n\n return AVERROR(ENOMEM);\n\n\n\n av_frame_move_ref(tmp, frame);\n\n\n\n ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);\n\n if (ret < 0) {\n\n av_frame_free(&tmp);\n\n return ret;\n\n }\n\n\n\n av_frame_copy(frame, tmp);\n\n av_frame_free(&tmp);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 26112 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)\n\n{\n\n uint32_t *copy;\n\n\n\n copy = g_malloc(sizeof(value));\n\n *copy = cpu_to_le32(value);\n\n fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));\n\n}\n", + "output": "1", + "index": 23954 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void readline_show_prompt(ReadLineState *rs)\n\n{\n\n monitor_printf(rs->mon, \"%s\", rs->prompt);\n\n monitor_flush(rs->mon);\n\n rs->last_cmd_buf_index = 0;\n\n rs->last_cmd_buf_size = 0;\n\n rs->esc_state = IS_NORM;\n\n}\n", + "output": "0", + "index": 12663 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mptsas_scsi_uninit(PCIDevice *dev)\n\n{\n\n MPTSASState *s = MPT_SAS(dev);\n\n\n\n qemu_bh_delete(s->request_bh);\n\n if (s->msi_in_use) {\n\n msi_uninit(dev);\n\n }\n\n}\n", + "output": "0", + "index": 1698 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pulse_get_output_timestamp(AVFormatContext *h, int stream, int64_t *dts, int64_t *wall)\n\n{\n\n PulseData *s = h->priv_data;\n\n pa_usec_t latency;\n\n int neg;\n\n pa_threaded_mainloop_lock(s->mainloop);\n\n pa_stream_get_latency(s->stream, &latency, &neg);\n\n pa_threaded_mainloop_unlock(s->mainloop);\n\n *wall = av_gettime();\n\n *dts = s->timestamp - (neg ? -latency : latency);\n\n}\n", + "output": "0", + "index": 5619 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){\n\n uint64_t state=0;\n\n \n\n if(pos >= 0)\n\n url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream isnt seekable, but that shouldnt matter, as in this case we simply start where we are currently\n\n\n\n while(bytes_left(bc)){\n\n state= (state<<8) | get_byte(bc);\n\n if((state>>56) != 'N')\n\n continue;\n\n switch(state){\n\n case MAIN_STARTCODE:\n\n case STREAM_STARTCODE:\n\n case KEYFRAME_STARTCODE:\n\n case INFO_STARTCODE:\n\n case INDEX_STARTCODE:\n\n return state;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 24146 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len,\n\n char *dst, int dstlen)\n\n{\n\n char *p = dst;\n\n char *end = dst+dstlen-1;\n\n int i;\n\n\n\n for (i = 0; i < len; i++) {\n\n uint8_t t, c = avio_r8(pb);\n\n if (c < 0x80 && p < end)\n\n *p++ = c;\n\n else\n\n PUT_UTF8(mac_to_unicode[c-0x80], t, if (p < end) *p++ = t;);\n\n }\n\n *p = 0;\n\n return p - dst;\n\n}\n", + "output": "1", + "index": 18821 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)\n\n{\n\n VirtIOS390Bus *bus;\n\n int dev_len;\n\n\n\n bus = DO_UPCAST(VirtIOS390Bus, bus, dev->qdev.parent_bus);\n\n dev->vdev = vdev;\n\n dev->dev_offs = bus->dev_offs;\n\n dev->feat_len = sizeof(uint32_t); /* always keep 32 bits features */\n\n\n\n dev_len = VIRTIO_DEV_OFFS_CONFIG;\n\n dev_len += s390_virtio_device_num_vq(dev) * VIRTIO_VQCONFIG_LEN;\n\n dev_len += dev->feat_len * 2;\n\n dev_len += virtio_bus_get_vdev_config_len(&dev->bus);\n\n\n\n bus->dev_offs += dev_len;\n\n\n\n dev->host_features = virtio_bus_get_vdev_features(&dev->bus,\n\n dev->host_features);\n\n s390_virtio_device_sync(dev);\n\n s390_virtio_reset_idx(dev);\n\n if (dev->qdev.hotplugged) {\n\n S390CPU *cpu = s390_cpu_addr2state(0);\n\n s390_virtio_irq(cpu, VIRTIO_PARAM_DEV_ADD, dev->dev_offs);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21723 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb, uintptr_t ra)\n\n{\n\n CRW crw;\n\n uint64_t addr;\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 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);\n\n return;\n\n }\n\n\n\n cc = css_do_stcrw(&crw);\n\n /* 0 - crw stored, 1 - zeroes stored */\n\n\n\n if (s390_cpu_virt_mem_write(cpu, addr, ar, &crw, sizeof(crw)) == 0) {\n\n setcc(cpu, cc);\n\n } else if (cc == 0) {\n\n /* Write failed: requeue CRW since STCRW is a suppressing instruction */\n\n css_undo_stcrw(&crw);\n\n }\n\n}\n", + "output": "0", + "index": 16247 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_instruction(S390CPU *cpu, struct kvm_run *run)\n\n{\n\n unsigned int ipa0 = (run->s390_sieic.ipa & 0xff00);\n\n uint8_t ipa1 = run->s390_sieic.ipa & 0x00ff;\n\n int r = -1;\n\n\n\n DPRINTF(\"handle_instruction 0x%x 0x%x\\n\",\n\n run->s390_sieic.ipa, run->s390_sieic.ipb);\n\n switch (ipa0) {\n\n case IPA0_B2:\n\n r = handle_b2(cpu, run, ipa1);\n\n break;\n\n case IPA0_B9:\n\n r = handle_b9(cpu, run, ipa1);\n\n break;\n\n case IPA0_EB:\n\n r = handle_eb(cpu, run, run->s390_sieic.ipb & 0xff);\n\n break;\n\n case IPA0_E3:\n\n r = handle_e3(cpu, run, run->s390_sieic.ipb & 0xff);\n\n break;\n\n case IPA0_DIAG:\n\n r = handle_diag(cpu, run, run->s390_sieic.ipb);\n\n break;\n\n case IPA0_SIGP:\n\n r = handle_sigp(cpu, ipa1, run->s390_sieic.ipb);\n\n break;\n\n }\n\n\n\n if (r < 0) {\n\n r = 0;\n\n kvm_s390_program_interrupt(cpu, PGM_OPERATION);\n\n }\n\n\n\n return r;\n\n}\n", + "output": "0", + "index": 2548 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size)\n\n{\n\n uint32_t scratch = 0;\n\n const uint8_t *buf_end = buf + buf_size;\n\n\n\n\n\n for (; buf < buf_end - 3; buf += 4)\n\n scratch ^= *((const uint32_t*)buf);\n\n\n\n scratch = xor_32_to_8(scratch);\n\n\n\n for (; buf < buf_end; buf++)\n\n\n\n\n return scratch;\n\n}", + "output": "1", + "index": 5327 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int setfsugid(int uid, int gid)\n\n{\n\n /*\n\n * We still need DAC_OVERRIDE because we don't change\n\n * supplementary group ids, and hence may be subjected DAC rules\n\n */\n\n cap_value_t cap_list[] = {\n\n CAP_DAC_OVERRIDE,\n\n };\n\n\n\n setfsgid(gid);\n\n setfsuid(uid);\n\n\n\n if (uid != 0 || gid != 0) {\n\n return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 16271 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,\n\n uint32_t length)\n\n{\n\n int v, i;\n\n\n\n if (s->color_type == PNG_COLOR_TYPE_PALETTE) {\n\n if (length > 256 || !(s->state & PNG_PLTE))\n\n return AVERROR_INVALIDDATA;\n\n\n\n for (i = 0; i < length; i++) {\n\n v = bytestream2_get_byte(&s->gb);\n\n s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);\n\n }\n\n } else if (s->color_type == PNG_COLOR_TYPE_GRAY || s->color_type == PNG_COLOR_TYPE_RGB) {\n\n if ((s->color_type == PNG_COLOR_TYPE_GRAY && length != 2) ||\n\n (s->color_type == PNG_COLOR_TYPE_RGB && length != 6))\n\n return AVERROR_INVALIDDATA;\n\n\n\n for (i = 0; i < length / 2; i++) {\n\n /* only use the least significant bits */\n\n v = av_mod_uintp2(bytestream2_get_be16(&s->gb), s->bit_depth);\n\n\n\n if (s->bit_depth > 8)\n\n AV_WB16(&s->transparent_color_be[2 * i], v);\n\n else\n\n s->transparent_color_be[i] = v;\n\n }\n\n } else {\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n bytestream2_skip(&s->gb, 4); /* crc */\n\n s->has_trns = 1;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 23309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_write_pass1_stats(MpegEncContext *s)\n\n{\n\n snprintf(s->avctx->stats_out, 256,\n\n \"in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d \"\n\n \"fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\\n\",\n\n s->current_picture_ptr->f.display_picture_number,\n\n s->current_picture_ptr->f.coded_picture_number,\n\n s->pict_type,\n\n s->current_picture.f.quality,\n\n s->i_tex_bits,\n\n s->p_tex_bits,\n\n s->mv_bits,\n\n s->misc_bits,\n\n s->f_code,\n\n s->b_code,\n\n s->current_picture.mc_mb_var_sum,\n\n s->current_picture.mb_var_sum,\n\n s->i_count, s->skip_count,\n\n s->header_bits);\n\n}\n", + "output": "1", + "index": 22608 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tee_write_trailer(AVFormatContext *avf)\n\n{\n\n TeeContext *tee = avf->priv_data;\n\n AVFormatContext *avf2;\n\n int ret_all = 0, ret;\n\n unsigned i;\n\n\n\n for (i = 0; i < tee->nb_slaves; i++) {\n\n avf2 = tee->slaves[i].avf;\n\n if ((ret = av_write_trailer(avf2)) < 0)\n\n if (!ret_all)\n\n ret_all = ret;\n\n if (!(avf2->oformat->flags & AVFMT_NOFILE))\n\n ff_format_io_close(avf2, &avf2->pb);\n\n }\n\n close_slaves(avf);\n\n return ret_all;\n\n}\n", + "output": "1", + "index": 5495 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_recording_time(OutputStream *ost)\n\n{\n\n OutputFile *of = output_files[ost->file_index];\n\n\n\n if (of->recording_time != INT64_MAX &&\n\n av_compare_ts(ost->sync_opts - ost->first_pts, ost->st->codec->time_base, of->recording_time,\n\n AV_TIME_BASE_Q) >= 0) {\n\n ost->is_past_recording_time = 1;\n\n return 0;\n\n }\n\n return 1;\n\n}\n", + "output": "0", + "index": 3112 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_dpy_update(DisplayChangeListener *dcl,\n\n int x, int y, int w, int h)\n\n{\n\n VncDisplay *vd = container_of(dcl, VncDisplay, dcl);\n\n struct VncSurface *s = &vd->guest;\n\n int width = surface_width(vd->ds);\n\n int height = surface_height(vd->ds);\n\n\n\n /* this is needed this to ensure we updated all affected\n\n * blocks if x % VNC_DIRTY_PIXELS_PER_BIT != 0 */\n\n w += (x % VNC_DIRTY_PIXELS_PER_BIT);\n\n x -= (x % VNC_DIRTY_PIXELS_PER_BIT);\n\n\n\n x = MIN(x, width);\n\n y = MIN(y, height);\n\n w = MIN(x + w, width) - x;\n\n h = MIN(y + h, height);\n\n\n\n for (; y < h; y++) {\n\n bitmap_set(s->dirty[y], x / VNC_DIRTY_PIXELS_PER_BIT,\n\n DIV_ROUND_UP(w, VNC_DIRTY_PIXELS_PER_BIT));\n\n }\n\n}\n", + "output": "1", + "index": 21226 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)\n\n{\n\n Flash *s = M25P80(ss);\n\n uint32_t r = 0;\n\n\n\n switch (s->state) {\n\n\n\n case STATE_PAGE_PROGRAM:\n\n DB_PRINT_L(1, \"page program cur_addr=%#\" PRIx64 \" data=%\" PRIx8 \"\\n\",\n\n s->cur_addr, (uint8_t)tx);\n\n flash_write8(s, s->cur_addr, (uint8_t)tx);\n\n s->cur_addr++;\n\n break;\n\n\n\n case STATE_READ:\n\n r = s->storage[s->cur_addr];\n\n DB_PRINT_L(1, \"READ 0x%\" PRIx64 \"=%\" PRIx8 \"\\n\", s->cur_addr,\n\n (uint8_t)r);\n\n s->cur_addr = (s->cur_addr + 1) % s->size;\n\n break;\n\n\n\n case STATE_COLLECTING_DATA:\n\n case STATE_COLLECTING_VAR_LEN_DATA:\n\n s->data[s->len] = (uint8_t)tx;\n\n s->len++;\n\n\n\n if (s->len == s->needed_bytes) {\n\n complete_collecting_data(s);\n\n }\n\n break;\n\n\n\n case STATE_READING_DATA:\n\n r = s->data[s->pos];\n\n s->pos++;\n\n if (s->pos == s->len) {\n\n s->pos = 0;\n\n s->state = STATE_IDLE;\n\n }\n\n break;\n\n\n\n default:\n\n case STATE_IDLE:\n\n decode_new_cmd(s, (uint8_t)tx);\n\n break;\n\n }\n\n\n\n return r;\n\n}\n", + "output": "1", + "index": 20465 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void format_line(void *ptr, int level, const char *fmt, va_list vl,\n\n char part[3][512], int part_size, int *print_prefix, int type[2])\n\n{\n\n AVClass* avc = ptr ? *(AVClass **) ptr : NULL;\n\n part[0][0] = part[1][0] = part[2][0] = 0;\n\n if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;\n\n if (*print_prefix && avc) {\n\n if (avc->parent_log_context_offset) {\n\n AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +\n\n avc->parent_log_context_offset);\n\n if (parent && *parent) {\n\n snprintf(part[0], part_size, \"[%s @ %p] \",\n\n (*parent)->item_name(parent), parent);\n\n if(type) type[0] = get_category(((uint8_t *) ptr) + avc->parent_log_context_offset);\n\n }\n\n }\n\n snprintf(part[1], part_size, \"[%s @ %p] \",\n\n avc->item_name(ptr), ptr);\n\n if(type) type[1] = get_category(ptr);\n\n }\n\n\n\n vsnprintf(part[2], part_size, fmt, vl);\n\n\n\n *print_prefix = strlen(part[2]) && part[2][strlen(part[2]) - 1] == '\\n';\n\n}\n", + "output": "1", + "index": 828 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *thread_func(void *p)\n\n{\n\n struct thread_info *info = p;\n\n\n\n rcu_register_thread();\n\n\n\n atomic_inc(&n_ready_threads);\n\n while (!atomic_mb_read(&test_start)) {\n\n cpu_relax();\n\n }\n\n\n\n rcu_read_lock();\n\n while (!atomic_read(&test_stop)) {\n\n info->r = xorshift64star(info->r);\n\n info->func(info);\n\n }\n\n rcu_read_unlock();\n\n\n\n rcu_unregister_thread();\n\n return NULL;\n\n}\n", + "output": "0", + "index": 26873 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockBackend *img_open(const char *id, const char *filename,\n\n const char *fmt, int flags,\n\n bool require_io, bool quiet)\n\n{\n\n BlockBackend *blk;\n\n BlockDriverState *bs;\n\n char password[256];\n\n Error *local_err = NULL;\n\n QDict *options = NULL;\n\n\n\n if (fmt) {\n\n options = qdict_new();\n\n qdict_put(options, \"driver\", qstring_from_str(fmt));\n\n }\n\n\n\n blk = blk_new_open(id, filename, NULL, options, flags, &local_err);\n\n if (!blk) {\n\n error_report(\"Could not open '%s': %s\", filename,\n\n error_get_pretty(local_err));\n\n error_free(local_err);\n\n goto fail;\n\n }\n\n\n\n bs = blk_bs(blk);\n\n if (bdrv_is_encrypted(bs) && require_io) {\n\n qprintf(quiet, \"Disk image '%s' is encrypted.\\n\", filename);\n\n if (read_password(password, sizeof(password)) < 0) {\n\n error_report(\"No password given\");\n\n goto fail;\n\n }\n\n if (bdrv_set_key(bs, password) < 0) {\n\n error_report(\"invalid password\");\n\n goto fail;\n\n }\n\n }\n\n return blk;\n\nfail:\n\n blk_unref(blk);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 12866 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(vararg_string)\n\n{\n\n int i;\n\n struct {\n\n const char *decoded;\n\n } test_cases[] = {\n\n { \"hello world\" },\n\n { \"the quick brown fox jumped over the fence\" },\n\n {}\n\n };\n\n\n\n for (i = 0; test_cases[i].decoded; i++) {\n\n QObject *obj;\n\n QString *str;\n\n\n\n obj = qobject_from_jsonf(\"%s\", test_cases[i].decoded);\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": 3298 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence)\n\n{\n\n int64_t offset1;\n\n int64_t pos;\n\n int force = whence & AVSEEK_FORCE;\n\n whence &= ~AVSEEK_FORCE;\n\n\n\n if(!s)\n\n return AVERROR(EINVAL);\n\n\n\n pos = s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));\n\n\n\n if (whence != SEEK_CUR && whence != SEEK_SET)\n\n return AVERROR(EINVAL);\n\n\n\n if (whence == SEEK_CUR) {\n\n offset1 = pos + (s->buf_ptr - s->buffer);\n\n if (offset == 0)\n\n return offset1;\n\n offset += offset1;\n\n }\n\n offset1 = offset - pos;\n\n if (!s->must_flush &&\n\n offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {\n\n /* can do the seek inside the buffer */\n\n s->buf_ptr = s->buffer + offset1;\n\n } else if(s->is_streamed && !s->write_flag && offset1 >= 0 &&\n\n (whence != SEEK_END || force)) {\n\n while(s->pos < offset && !s->eof_reached)\n\n fill_buffer(s);\n\n if (s->eof_reached)\n\n return AVERROR_EOF;\n\n s->buf_ptr = s->buf_end + offset - s->pos;\n\n } else {\n\n int64_t res = AVERROR(EPIPE);\n\n\n\n#if CONFIG_MUXERS || CONFIG_NETWORK\n\n if (s->write_flag) {\n\n flush_buffer(s);\n\n s->must_flush = 1;\n\n }\n\n#endif /* CONFIG_MUXERS || CONFIG_NETWORK */\n\n if (!s->seek || (res = s->seek(s->opaque, offset, SEEK_SET)) < 0)\n\n return res;\n\n if (!s->write_flag)\n\n s->buf_end = s->buffer;\n\n s->buf_ptr = s->buffer;\n\n s->pos = offset;\n\n }\n\n s->eof_reached = 0;\n\n return offset;\n\n}\n", + "output": "0", + "index": 997 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vty_receive(void *opaque, const uint8_t *buf, int size)\n\n{\n\n VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)opaque;\n\n int i;\n\n\n\n if ((dev->in == dev->out) && size) {\n\n /* toggle line to simulate edge interrupt */\n\n qemu_irq_pulse(dev->sdev.qirq);\n\n }\n\n for (i = 0; i < size; i++) {\n\n assert((dev->in - dev->out) < VTERM_BUFSIZE);\n\n dev->buf[dev->in++ % VTERM_BUFSIZE] = buf[i];\n\n }\n\n}\n", + "output": "0", + "index": 10373 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void raise_irq_cpu_hotplug(void)\n\n{\n\n qemu_irq_raise(irq_cpu_hotplug);\n\n}\n", + "output": "1", + "index": 23962 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_slbie(CPUPPCState *env, target_ulong addr)\n\n{\n\n PowerPCCPU *cpu = ppc_env_get_cpu(env);\n\n ppc_slb_t *slb;\n\n\n\n slb = slb_lookup(cpu, addr);\n\n if (!slb) {\n\n return;\n\n }\n\n\n\n if (slb->esid & SLB_ESID_V) {\n\n slb->esid &= ~SLB_ESID_V;\n\n\n\n /* XXX: given the fact that segment size is 256 MB or 1TB,\n\n * and we still don't have a tlb_flush_mask(env, n, mask)\n\n * in QEMU, we just invalidate all TLBs\n\n */\n\n tlb_flush(CPU(cpu), 1);\n\n }\n\n}\n", + "output": "1", + "index": 33 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QError *qobject_to_qerror(const QObject *obj)\n\n{\n\n if (qobject_type(obj) != QTYPE_QERROR) {\n\n return NULL;\n\n }\n\n\n\n return container_of(obj, QError, base);\n\n}\n", + "output": "0", + "index": 7401 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_dpy_setdata(DisplayChangeListener *dcl,\n\n DisplayState *ds)\n\n{\n\n VncDisplay *vd = ds->opaque;\n\n\n\n qemu_pixman_image_unref(vd->guest.fb);\n\n vd->guest.fb = pixman_image_ref(ds->surface->image);\n\n vd->guest.format = ds->surface->format;\n\n vnc_dpy_update(dcl, ds, 0, 0, ds_get_width(ds), ds_get_height(ds));\n\n}\n", + "output": "1", + "index": 6678 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xen_pt_bar_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,\n\n uint32_t *value, uint32_t valid_mask)\n\n{\n\n XenPTRegInfo *reg = cfg_entry->reg;\n\n uint32_t valid_emu_mask = 0;\n\n uint32_t bar_emu_mask = 0;\n\n int index;\n\n\n\n /* get BAR index */\n\n index = xen_pt_bar_offset_to_index(reg->offset);\n\n if (index < 0 || index >= PCI_NUM_REGIONS - 1) {\n\n XEN_PT_ERR(&s->dev, \"Internal error: Invalid BAR index [%d].\\n\", index);\n\n return -1;\n\n }\n\n\n\n /* use fixed-up value from kernel sysfs */\n\n *value = base_address_with_flags(&s->real_device.io_regions[index]);\n\n\n\n /* set emulate mask depend on BAR flag */\n\n switch (s->bases[index].bar_flag) {\n\n case XEN_PT_BAR_FLAG_MEM:\n\n bar_emu_mask = XEN_PT_BAR_MEM_EMU_MASK;\n\n break;\n\n case XEN_PT_BAR_FLAG_IO:\n\n bar_emu_mask = XEN_PT_BAR_IO_EMU_MASK;\n\n break;\n\n case XEN_PT_BAR_FLAG_UPPER:\n\n bar_emu_mask = XEN_PT_BAR_ALLF;\n\n break;\n\n default:\n\n break;\n\n }\n\n\n\n /* emulate BAR */\n\n valid_emu_mask = bar_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": 20986 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_co_request(BlockDriverState *bs,\n\n NBDRequest *request,\n\n QEMUIOVector *qiov)\n\n{\n\n NBDClientSession *client = nbd_get_client_session(bs);\n\n int ret;\n\n\n\n if (qiov) {\n\n assert(request->type == NBD_CMD_WRITE || request->type == NBD_CMD_READ);\n\n assert(request->len == iov_size(qiov->iov, qiov->niov));\n\n } else {\n\n assert(request->type != NBD_CMD_WRITE && request->type != NBD_CMD_READ);\n\n }\n\n ret = nbd_co_send_request(bs, request,\n\n request->type == NBD_CMD_WRITE ? qiov : NULL);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n return nbd_co_receive_reply(client, request->handle,\n\n request->type == NBD_CMD_READ ? qiov : NULL);\n\n}\n", + "output": "1", + "index": 9087 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tap_set_sndbuf(TAPState *s, const char *sndbuf_str)\n\n{\n\n int sndbuf = TAP_DEFAULT_SNDBUF;\n\n\n\n if (sndbuf_str) {\n\n sndbuf = atoi(sndbuf_str);\n\n }\n\n\n\n if (!sndbuf) {\n\n sndbuf = INT_MAX;\n\n }\n\n\n\n if (ioctl(s->fd, TUNSETSNDBUF, &sndbuf) == -1 && sndbuf_str) {\n\n qemu_error(\"TUNSETSNDBUF ioctl failed: %s\\n\", strerror(errno));\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 12024 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)\n\n{\n\n V9fsVirtioState *v = (V9fsVirtioState *)vdev;\n\n V9fsState *s = &v->state;\n\n V9fsPDU *pdu;\n\n ssize_t len;\n\n\n\n while ((pdu = pdu_alloc(s))) {\n\n struct {\n\n uint32_t size_le;\n\n uint8_t id;\n\n uint16_t tag_le;\n\n } QEMU_PACKED out;\n\n VirtQueueElement *elem = &v->elems[pdu->idx];\n\n\n\n len = virtqueue_pop(vq, elem);\n\n if (!len) {\n\n pdu_free(pdu);\n\n break;\n\n }\n\n\n\n BUG_ON(elem->out_num == 0 || elem->in_num == 0);\n\n QEMU_BUILD_BUG_ON(sizeof out != 7);\n\n\n\n len = iov_to_buf(elem->out_sg, elem->out_num, 0,\n\n &out, sizeof out);\n\n BUG_ON(len != sizeof out);\n\n\n\n pdu->size = le32_to_cpu(out.size_le);\n\n\n\n pdu->id = out.id;\n\n pdu->tag = le16_to_cpu(out.tag_le);\n\n\n\n qemu_co_queue_init(&pdu->complete);\n\n pdu_submit(pdu);\n\n }\n\n}\n", + "output": "0", + "index": 25522 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *region,\n\n int index, const char *name)\n\n{\n\n struct vfio_region_info *info;\n\n int ret;\n\n\n\n ret = vfio_get_region_info(vbasedev, index, &info);\n\n if (ret) {\n\n return ret;\n\n }\n\n\n\n region->vbasedev = vbasedev;\n\n region->flags = info->flags;\n\n region->size = info->size;\n\n region->fd_offset = info->offset;\n\n region->nr = index;\n\n\n\n if (region->size) {\n\n region->mem = g_new0(MemoryRegion, 1);\n\n memory_region_init_io(region->mem, obj, &vfio_region_ops,\n\n region, name, region->size);\n\n\n\n if (!vbasedev->no_mmap &&\n\n region->flags & VFIO_REGION_INFO_FLAG_MMAP &&\n\n !(region->size & ~qemu_real_host_page_mask)) {\n\n\n\n ret = vfio_setup_region_sparse_mmaps(region, info);\n\n\n\n if (ret) {\n\n region->nr_mmaps = 1;\n\n region->mmaps = g_new0(VFIOMmap, region->nr_mmaps);\n\n region->mmaps[0].offset = 0;\n\n region->mmaps[0].size = region->size;\n\n }\n\n }\n\n }\n\n\n\n g_free(info);\n\n\n\n trace_vfio_region_setup(vbasedev->name, index, name,\n\n region->flags, region->fd_offset, region->size);\n\n return 0;\n\n}\n", + "output": "0", + "index": 27002 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)\n\n{\n\n void *linker_data = bios_linker_loader_cleanup(tables->linker);\n\n if (mfre) {\n\n g_free(linker_data);\n\n }\n\n g_array_free(tables->rsdp, mfre);\n\n g_array_free(tables->table_data, mfre);\n\n g_array_free(tables->tcpalog, mfre);\n\n}\n", + "output": "1", + "index": 12163 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool qemu_log_in_addr_range(uint64_t addr)\n\n{\n\n if (debug_regions) {\n\n int i = 0;\n\n for (i = 0; i < debug_regions->len; i++) {\n\n Range *range = &g_array_index(debug_regions, Range, i);\n\n if (addr >= range->begin && addr <= range->end - 1) {\n\n return true;\n\n }\n\n }\n\n return false;\n\n } else {\n\n return true;\n\n }\n\n}\n", + "output": "0", + "index": 7927 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dxva2_vc1_start_frame(AVCodecContext *avctx,\n\n av_unused const uint8_t *buffer,\n\n av_unused uint32_t size)\n\n{\n\n const VC1Context *v = avctx->priv_data;\n\n AVDXVAContext *ctx = avctx->hwaccel_context;\n\n struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;\n\n\n\n if (!DXVA_CONTEXT_VALID(avctx, ctx))\n\n return -1;\n\n assert(ctx_pic);\n\n\n\n fill_picture_parameters(avctx, ctx, v, &ctx_pic->pp);\n\n\n\n ctx_pic->bitstream_size = 0;\n\n ctx_pic->bitstream = NULL;\n\n return 0;\n\n}\n", + "output": "0", + "index": 10441 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t gic_dist_readl(void *opaque, target_phys_addr_t offset)\n\n{\n\n uint32_t val;\n\n val = gic_dist_readw(opaque, offset);\n\n val |= gic_dist_readw(opaque, offset + 2) << 16;\n\n return val;\n\n}\n", + "output": "0", + "index": 3314 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "alloc_parameter_set(H264Context *h, void **vec, const unsigned int id, const unsigned int max,\n\n const size_t size, const char *name)\n\n{\n\n if(id>=max) {\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"%s_id (%d) out of range\\n\", name, id);\n\n return NULL;\n\n }\n\n\n\n if(!vec[id]) {\n\n vec[id] = av_mallocz(size);\n\n if(vec[id] == NULL)\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"cannot allocate memory for %s\\n\", name);\n\n }\n\n return vec[id];\n\n}\n", + "output": "0", + "index": 22395 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,\n\n target_phys_addr_t base, qemu_irq uart_irq, CharDriverState *uart_chr)\n\n{\n\n MaltaFPGAState *s;\n\n\n\n s = (MaltaFPGAState *)g_malloc0(sizeof(MaltaFPGAState));\n\n\n\n memory_region_init_io(&s->iomem, &malta_fpga_ops, s,\n\n \"malta-fpga\", 0x100000);\n\n memory_region_init_alias(&s->iomem_lo, \"malta-fpga\",\n\n &s->iomem, 0, 0x900);\n\n memory_region_init_alias(&s->iomem_hi, \"malta-fpga\",\n\n &s->iomem, 0xa00, 0x10000-0xa00);\n\n\n\n memory_region_add_subregion(address_space, base, &s->iomem_lo);\n\n memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi);\n\n\n\n s->display = qemu_chr_new(\"fpga\", \"vc:320x200\", malta_fpga_led_init);\n\n\n\n s->uart = serial_mm_init(address_space, base + 0x900, 3, uart_irq,\n\n 230400, uart_chr, DEVICE_NATIVE_ENDIAN);\n\n\n\n malta_fpga_reset(s);\n\n qemu_register_reset(malta_fpga_reset, s);\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 10929 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int add_hfyu_left_prediction_int16_c(uint16_t *dst, const uint16_t *src, unsigned mask, int w, int acc){\n\n int i;\n\n\n\n for(i=0; idata);\n\n return true;\n\n }\n\n\n\n return false;\n\n}\n", + "output": "0", + "index": 8620 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)\n\n{\n\n Object *pci_host;\n\n QObject *o;\n\n\n\n pci_host = acpi_get_i386_pci_host();\n\n g_assert(pci_host);\n\n\n\n o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_BASE, NULL);\n\n if (!o) {\n\n return false;\n\n }\n\n mcfg->mcfg_base = qnum_get_int(qobject_to_qnum(o));\n\n qobject_decref(o);\n\n\n\n o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);\n\n assert(o);\n\n mcfg->mcfg_size = qnum_get_int(qobject_to_qnum(o));\n\n qobject_decref(o);\n\n return true;\n\n}\n", + "output": "1", + "index": 9611 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dhcp_decode(const struct bootp_t *bp, int *pmsg_type,\n\n 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->s_addr = htonl(0L);\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\n } else {\n\n p++;\n\n if (p >= p_end)\n\n\n len = *p++;\n\n\n\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\n case RFC2132_REQ_ADDR:\n\n if (len >= 4) {\n\n memcpy(&(preq_addr->s_addr), p, 4);\n\n\n\n default:\n\n\n\n p += len;\n\n\n\n if (*pmsg_type == DHCPREQUEST && preq_addr->s_addr == htonl(0L) &&\n\n bp->bp_ciaddr.s_addr) {\n\n memcpy(&(preq_addr->s_addr), &bp->bp_ciaddr, 4);\n\n", + "output": "1", + "index": 21020 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int print_drive(DeviceState *dev, Property *prop, char *dest, size_t len)\n\n{\n\n DriveInfo **ptr = qdev_get_prop_ptr(dev, prop);\n\n return snprintf(dest, len, \"%s\", (*ptr) ? (*ptr)->id : \"\");\n\n}\n", + "output": "0", + "index": 18667 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "set_phy_ctrl(E1000State *s, int index, uint16_t val)\n\n{\n\n if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {\n\n qemu_get_queue(s->nic)->link_down = true;\n\n e1000_link_down(s);\n\n s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;\n\n DBGOUT(PHY, \"Start link auto negotiation\\n\");\n\n qemu_mod_timer(s->autoneg_timer, qemu_get_clock_ms(vm_clock) + 500);\n\n }\n\n}\n", + "output": "1", + "index": 9016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,\n\n MemHotplugState *state)\n\n{\n\n MachineState *machine = MACHINE(qdev_get_machine());\n\n\n\n state->dev_count = machine->ram_slots;\n\n if (!state->dev_count) {\n\n return;\n\n }\n\n\n\n state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);\n\n memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state,\n\n \"acpi-mem-hotplug\", ACPI_MEMORY_HOTPLUG_IO_LEN);\n\n memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io);\n\n}\n", + "output": "0", + "index": 869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sub2video_update(InputStream *ist, AVSubtitle *sub)\n\n{\n\n AVFrame *frame = ist->sub2video.frame;\n\n int8_t *dst;\n\n int dst_linesize;\n\n int num_rects, i;\n\n int64_t pts, end_pts;\n\n\n\n if (!frame)\n\n return;\n\n if (sub) {\n\n pts = av_rescale_q(sub->pts + sub->start_display_time * 1000LL,\n\n AV_TIME_BASE_Q, ist->st->time_base);\n\n end_pts = av_rescale_q(sub->pts + sub->end_display_time * 1000LL,\n\n AV_TIME_BASE_Q, ist->st->time_base);\n\n num_rects = sub->num_rects;\n\n } else {\n\n pts = ist->sub2video.end_pts;\n\n end_pts = INT64_MAX;\n\n num_rects = 0;\n\n }\n\n if (sub2video_get_blank_frame(ist) < 0) {\n\n av_log(ist->dec_ctx, AV_LOG_ERROR,\n\n \"Impossible to get a blank canvas.\\n\");\n\n return;\n\n }\n\n dst = frame->data [0];\n\n dst_linesize = frame->linesize[0];\n\n for (i = 0; i < num_rects; i++)\n\n sub2video_copy_rect(dst, dst_linesize, frame->width, frame->height, sub->rects[i]);\n\n sub2video_push_ref(ist, pts);\n\n ist->sub2video.end_pts = end_pts;\n\n}\n", + "output": "0", + "index": 21843 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value)\n\n{\n\n uintptr_t addr = (uintptr_t)data;\n\n\n\n if (addr < QPCI_PIO_LIMIT) {\n\n dev->bus->pio_writel(dev->bus, addr, value);\n\n } else {\n\n value = cpu_to_le32(value);\n\n dev->bus->memwrite(dev->bus, addr, &value, sizeof(value));\n\n }\n\n}\n", + "output": "1", + "index": 2386 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void tb_alloc_page(TranslationBlock *tb,\n\n unsigned int n, tb_page_addr_t page_addr)\n\n{\n\n PageDesc *p;\n\n#ifndef CONFIG_USER_ONLY\n\n bool page_already_protected;\n\n#endif\n\n\n\n assert_memory_lock();\n\n\n\n tb->page_addr[n] = page_addr;\n\n p = page_find_alloc(page_addr >> TARGET_PAGE_BITS, 1);\n\n tb->page_next[n] = p->first_tb;\n\n#ifndef CONFIG_USER_ONLY\n\n page_already_protected = p->first_tb != NULL;\n\n#endif\n\n p->first_tb = (TranslationBlock *)((uintptr_t)tb | n);\n\n invalidate_page_bitmap(p);\n\n\n\n#if defined(CONFIG_USER_ONLY)\n\n if (p->flags & PAGE_WRITE) {\n\n target_ulong addr;\n\n PageDesc *p2;\n\n int prot;\n\n\n\n /* force the host page as non writable (writes will have a\n\n page fault + mprotect overhead) */\n\n page_addr &= qemu_host_page_mask;\n\n prot = 0;\n\n for (addr = page_addr; addr < page_addr + qemu_host_page_size;\n\n addr += TARGET_PAGE_SIZE) {\n\n\n\n p2 = page_find(addr >> TARGET_PAGE_BITS);\n\n if (!p2) {\n\n continue;\n\n }\n\n prot |= p2->flags;\n\n p2->flags &= ~PAGE_WRITE;\n\n }\n\n mprotect(g2h(page_addr), qemu_host_page_size,\n\n (prot & PAGE_BITS) & ~PAGE_WRITE);\n\n#ifdef DEBUG_TB_INVALIDATE\n\n printf(\"protecting code page: 0x\" TARGET_FMT_lx \"\\n\",\n\n page_addr);\n\n#endif\n\n }\n\n#else\n\n /* if some code is already present, then the pages are already\n\n protected. So we handle the case where only the first TB is\n\n allocated in a physical page */\n\n if (!page_already_protected) {\n\n tlb_protect_code(page_addr);\n\n }\n\n#endif\n\n}\n", + "output": "1", + "index": 5848 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int object_create(QemuOpts *opts, void *opaque)\n\n{\n\n const char *type = qemu_opt_get(opts, \"qom-type\");\n\n const char *id = qemu_opts_id(opts);\n\n Object *obj;\n\n\n\n g_assert(type != NULL);\n\n\n\n if (id == NULL) {\n\n qerror_report(QERR_MISSING_PARAMETER, \"id\");\n\n return -1;\n\n }\n\n\n\n obj = object_new(type);\n\n if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {\n\n return -1;\n\n }\n\n\n\n object_property_add_child(container_get(object_get_root(), \"/objects\"),\n\n id, obj, NULL);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 26413 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void buffer_append(Buffer *buffer, const void *data, size_t len)\n\n{\n\n memcpy(buffer->buffer + buffer->offset, data, len);\n\n buffer->offset += len;\n\n}\n", + "output": "1", + "index": 6273 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_migrate(const char *uri, bool has_blk, bool blk,\n\n bool has_inc, bool inc, bool has_detach, bool detach,\n\n Error **errp)\n\n{\n\n Error *local_err = NULL;\n\n MigrationState *s = migrate_get_current();\n\n MigrationParams params;\n\n const char *p;\n\n\n\n params.blk = has_blk && blk;\n\n params.shared = has_inc && inc;\n\n\n\n if (migration_is_setup_or_active(s->state) ||\n\n s->state == MIGRATION_STATUS_CANCELLING) {\n\n error_setg(errp, QERR_MIGRATION_ACTIVE);\n\n return;\n\n }\n\n if (runstate_check(RUN_STATE_INMIGRATE)) {\n\n error_setg(errp, \"Guest is waiting for an incoming migration\");\n\n return;\n\n }\n\n\n\n if (qemu_savevm_state_blocked(errp)) {\n\n return;\n\n }\n\n\n\n if (migration_blockers) {\n\n *errp = error_copy(migration_blockers->data);\n\n return;\n\n }\n\n\n\n s = migrate_init(¶ms);\n\n\n\n if (strstart(uri, \"tcp:\", &p)) {\n\n tcp_start_outgoing_migration(s, p, &local_err);\n\n#ifdef CONFIG_RDMA\n\n } else if (strstart(uri, \"rdma:\", &p)) {\n\n rdma_start_outgoing_migration(s, p, &local_err);\n\n#endif\n\n#if !defined(WIN32)\n\n } else if (strstart(uri, \"exec:\", &p)) {\n\n exec_start_outgoing_migration(s, p, &local_err);\n\n } else if (strstart(uri, \"unix:\", &p)) {\n\n unix_start_outgoing_migration(s, p, &local_err);\n\n } else if (strstart(uri, \"fd:\", &p)) {\n\n fd_start_outgoing_migration(s, p, &local_err);\n\n#endif\n\n } else {\n\n error_setg(errp, QERR_INVALID_PARAMETER_VALUE, \"uri\",\n\n \"a valid migration protocol\");\n\n migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,\n\n MIGRATION_STATUS_FAILED);\n\n return;\n\n }\n\n\n\n if (local_err) {\n\n migrate_fd_error(s);\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n}\n", + "output": "1", + "index": 20426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void input_type_enum(Visitor *v, int *obj, const char *strings[],\n\n const char *kind, const char *name,\n\n Error **errp)\n\n{\n\n int64_t value = 0;\n\n char *enum_str;\n\n\n\n assert(strings);\n\n\n\n visit_type_str(v, &enum_str, name, errp);\n\n if (error_is_set(errp)) {\n\n return;\n\n }\n\n\n\n while (strings[value] != NULL) {\n\n if (strcmp(strings[value], enum_str) == 0) {\n\n break;\n\n }\n\n value++;\n\n }\n\n\n\n if (strings[value] == NULL) {\n\n error_set(errp, QERR_INVALID_PARAMETER, enum_str);\n\n g_free(enum_str);\n\n return;\n\n }\n\n\n\n g_free(enum_str);\n\n *obj = value;\n\n}\n", + "output": "1", + "index": 17814 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool gen_wsr_ccount(DisasContext *dc, uint32_t sr, TCGv_i32 v)\n\n{\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_start();\n\n }\n\n gen_helper_wsr_ccount(cpu_env, v);\n\n if (dc->tb->cflags & CF_USE_ICOUNT) {\n\n gen_io_end();\n\n gen_jumpi_check_loop_end(dc, 0);\n\n return true;\n\n }\n\n return false;\n\n}\n", + "output": "1", + "index": 17764 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "cac_new_pki_applet(int i, const unsigned char *cert,\n\n int cert_len, VCardKey *key)\n\n{\n\n VCardAppletPrivate *applet_private = NULL;\n\n VCardApplet *applet = NULL;\n\n unsigned char pki_aid[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };\n\n int pki_aid_len = sizeof(pki_aid);\n\n\n\n pki_aid[pki_aid_len-1] = i;\n\n\n\n applet_private = cac_new_pki_applet_private(cert, cert_len, key);\n\n if (applet_private == NULL) {\n\n goto failure;\n\n }\n\n applet = vcard_new_applet(cac_applet_pki_process_apdu, cac_applet_pki_reset,\n\n pki_aid, pki_aid_len);\n\n if (applet == NULL) {\n\n goto failure;\n\n }\n\n vcard_set_applet_private(applet, applet_private,\n\n cac_delete_pki_applet_private);\n\n applet_private = NULL;\n\n\n\n return applet;\n\n\n\nfailure:\n\n if (applet_private != NULL) {\n\n cac_delete_pki_applet_private(applet_private);\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 19100 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n __asm__ volatile(\n\n \"mov %0, %%\"REG_a\" \\n\\t\"\n\n \"1: \\n\\t\"\n\n \"movq (%1, %%\"REG_a\",2), %%mm0 \\n\\t\"\n\n \"movq 8(%1, %%\"REG_a\",2), %%mm1 \\n\\t\"\n\n \"psrlw $8, %%mm0 \\n\\t\"\n\n \"psrlw $8, %%mm1 \\n\\t\"\n\n \"packuswb %%mm1, %%mm0 \\n\\t\"\n\n \"movq %%mm0, (%2, %%\"REG_a\") \\n\\t\"\n\n \"add $8, %%\"REG_a\" \\n\\t\"\n\n \" js 1b \\n\\t\"\n\n : : \"g\" ((x86_reg)-width), \"r\" (src+width*2), \"r\" (dst+width)\n\n : \"%\"REG_a\n\n );\n\n#else\n\n int i;\n\n for (i=0; invram;\n\n hwaddr offset, buffer, len;\n\n int alen;\n\n void *membuf;\n\n\n\n if ((nargs != 3) || (nret != 2)) {\n\n rtas_st(rets, 0, -3);\n\n return;\n\n }\n\n\n\n if (!nvram) {\n\n rtas_st(rets, 0, -1);\n\n rtas_st(rets, 1, 0);\n\n return;\n\n }\n\n\n\n offset = rtas_ld(args, 0);\n\n buffer = rtas_ld(args, 1);\n\n len = rtas_ld(args, 2);\n\n\n\n if (((offset + len) < offset)\n\n || ((offset + len) > nvram->size)) {\n\n rtas_st(rets, 0, -3);\n\n rtas_st(rets, 1, 0);\n\n return;\n\n }\n\n\n\n membuf = cpu_physical_memory_map(buffer, &len, 1);\n\n if (nvram->drive) {\n\n alen = bdrv_pread(nvram->drive, offset, membuf, len);\n\n } else {\n\n assert(nvram->buf);\n\n\n\n memcpy(membuf, nvram->buf + offset, len);\n\n alen = len;\n\n }\n\n cpu_physical_memory_unmap(membuf, len, 1, len);\n\n\n\n rtas_st(rets, 0, (alen < len) ? -1 : 0);\n\n rtas_st(rets, 1, (alen < 0) ? 0 : alen);\n\n}\n", + "output": "0", + "index": 12623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openpic_save(QEMUFile* f, void *opaque)\n\n{\n\n OpenPICState *opp = (OpenPICState *)opaque;\n\n unsigned int i;\n\n\n\n qemu_put_be32s(f, &opp->glbc);\n\n qemu_put_be32s(f, &opp->veni);\n\n qemu_put_be32s(f, &opp->pint);\n\n qemu_put_be32s(f, &opp->spve);\n\n qemu_put_be32s(f, &opp->tifr);\n\n\n\n for (i = 0; i < opp->max_irq; i++) {\n\n qemu_put_be32s(f, &opp->src[i].ipvp);\n\n qemu_put_be32s(f, &opp->src[i].ide);\n\n qemu_put_sbe32s(f, &opp->src[i].last_cpu);\n\n qemu_put_sbe32s(f, &opp->src[i].pending);\n\n }\n\n\n\n qemu_put_be32s(f, &opp->nb_cpus);\n\n\n\n for (i = 0; i < opp->nb_cpus; i++) {\n\n qemu_put_be32s(f, &opp->dst[i].pctp);\n\n qemu_put_be32s(f, &opp->dst[i].pcsr);\n\n openpic_save_IRQ_queue(f, &opp->dst[i].raised);\n\n openpic_save_IRQ_queue(f, &opp->dst[i].servicing);\n\n }\n\n\n\n for (i = 0; i < MAX_TMR; i++) {\n\n qemu_put_be32s(f, &opp->timers[i].ticc);\n\n qemu_put_be32s(f, &opp->timers[i].tibc);\n\n }\n\n}\n", + "output": "0", + "index": 8675 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool qemu_clock_use_for_deadline(QEMUClockType type)\n\n{\n\n return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));\n\n}\n", + "output": "0", + "index": 20819 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)\n\n{\n\n char *str = NULL;\n\n int size;\n\n uint16_t str_size;\n\n\n\n if (c->itunes_metadata) {\n\n int data_size = get_be32(pb);\n\n int tag = get_le32(pb);\n\n if (tag == MKTAG('d','a','t','a')) {\n\n get_be32(pb); // type\n\n get_be32(pb); // unknown\n\n str_size = data_size - 16;\n\n } else return 0;\n\n } else {\n\n str_size = get_be16(pb); // string length\n\n get_be16(pb); // language\n\n }\n\n switch (atom.type) {\n\n case MKTAG(0xa9,'n','a','m'):\n\n str = c->fc->title; size = sizeof(c->fc->title); break;\n\n case MKTAG(0xa9,'A','R','T'):\n\n case MKTAG(0xa9,'w','r','t'):\n\n str = c->fc->author; size = sizeof(c->fc->author); break;\n\n case MKTAG(0xa9,'c','p','y'):\n\n str = c->fc->copyright; size = sizeof(c->fc->copyright); break;\n\n case MKTAG(0xa9,'c','m','t'):\n\n case MKTAG(0xa9,'i','n','f'):\n\n str = c->fc->comment; size = sizeof(c->fc->comment); break;\n\n case MKTAG(0xa9,'a','l','b'):\n\n str = c->fc->album; size = sizeof(c->fc->album); break;\n\n }\n\n if (!str)\n\n return 0;\n\n get_buffer(pb, str, FFMIN(size, str_size));\n\n dprintf(c->fc, \"%.4s %s\\n\", (char*)&atom.type, str);\n\n return 0;\n\n}\n", + "output": "0", + "index": 21828 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void arith2_normalise(ArithCoder *c)\n\n{\n\n while ((c->high >> 15) - (c->low >> 15) < 2) {\n\n if ((c->low ^ c->high) & 0x10000) {\n\n c->high ^= 0x8000;\n\n c->value ^= 0x8000;\n\n c->low ^= 0x8000;\n\n }\n\n c->high = c->high << 8 & 0xFFFFFF | 0xFF;\n\n c->value = c->value << 8 & 0xFFFFFF | bytestream2_get_byte(c->gbc.gB);\n\n c->low = c->low << 8 & 0xFFFFFF;\n\n }\n\n}\n", + "output": "1", + "index": 20845 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SocketAddressLegacy *socket_remote_address(int fd, Error **errp)\n\n{\n\n struct sockaddr_storage ss;\n\n socklen_t sslen = sizeof(ss);\n\n\n\n if (getpeername(fd, (struct sockaddr *)&ss, &sslen) < 0) {\n\n error_setg_errno(errp, errno, \"%s\",\n\n \"Unable to query remote socket address\");\n\n return NULL;\n\n }\n\n\n\n return socket_sockaddr_to_address(&ss, sslen, errp);\n\n}\n", + "output": "0", + "index": 16248 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void breakpoint_handler(CPUX86State *env)\n\n{\n\n CPUBreakpoint *bp;\n\n\n\n if (env->watchpoint_hit) {\n\n if (env->watchpoint_hit->flags & BP_CPU) {\n\n env->watchpoint_hit = NULL;\n\n if (check_hw_breakpoints(env, 0))\n\n raise_exception(env, EXCP01_DB);\n\n else\n\n cpu_resume_from_signal(env, NULL);\n\n }\n\n } else {\n\n QTAILQ_FOREACH(bp, &env->breakpoints, entry)\n\n if (bp->pc == env->eip) {\n\n if (bp->flags & BP_CPU) {\n\n check_hw_breakpoints(env, 1);\n\n raise_exception(env, EXCP01_DB);\n\n }\n\n break;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 22622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void raw_fd_pool_put(RawAIOCB *acb)\n\n{\n\n BDRVRawState *s = acb->common.bs->opaque;\n\n int i;\n\n\n\n for (i = 0; i < RAW_FD_POOL_SIZE; i++) {\n\n if (s->fd_pool[i] == acb->fd) {\n\n close(s->fd_pool[i]);\n\n s->fd_pool[i] = -1;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 22268 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_rfmci(CPUPPCState *env)\n\n{\n\n do_rfi(env, env->spr[SPR_BOOKE_MCSRR0], SPR_BOOKE_MCSRR1,\n\n ~((target_ulong)0x3FFF0000), 0);\n\n}\n", + "output": "1", + "index": 5546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hmp_delvm(Monitor *mon, const QDict *qdict)\n\n{\n\n BlockDriverState *bs;\n\n Error *err;\n\n const char *name = qdict_get_str(qdict, \"name\");\n\n\n\n if (!find_vmstate_bs()) {\n\n monitor_printf(mon, \"No block device supports snapshots\\n\");\n\n return;\n\n }\n\n\n\n if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {\n\n monitor_printf(mon,\n\n \"Error while deleting snapshot on device '%s': %s\\n\",\n\n bdrv_get_device_name(bs), error_get_pretty(err));\n\n error_free(err);\n\n }\n\n}\n", + "output": "0", + "index": 26491 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ram_save_cleanup(void *opaque)\n\n{\n\n RAMState **rsp = opaque;\n\n RAMBlock *block;\n\n\n\n /* caller have hold iothread lock or is in a bh, so there is\n\n * no writing race against this migration_bitmap\n\n */\n\n memory_global_dirty_log_stop();\n\n\n\n QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {\n\n g_free(block->bmap);\n\n block->bmap = NULL;\n\n g_free(block->unsentmap);\n\n block->unsentmap = NULL;\n\n }\n\n\n\n XBZRLE_cache_lock();\n\n if (XBZRLE.cache) {\n\n cache_fini(XBZRLE.cache);\n\n g_free(XBZRLE.encoded_buf);\n\n g_free(XBZRLE.current_buf);\n\n g_free(XBZRLE.zero_target_page);\n\n XBZRLE.cache = NULL;\n\n XBZRLE.encoded_buf = NULL;\n\n XBZRLE.current_buf = NULL;\n\n XBZRLE.zero_target_page = NULL;\n\n }\n\n XBZRLE_cache_unlock();\n\n compress_threads_save_cleanup();\n\n ram_state_cleanup(rsp);\n\n}\n", + "output": "1", + "index": 25462 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cin_probe(AVProbeData *p)\n\n{\n\n if (p->buf_size < 18)\n\n return 0;\n\n\n\n /* header starts with this special marker */\n\n if (AV_RL32(&p->buf[0]) != 0x55AA0000)\n\n return 0;\n\n\n\n /* for accuracy, check some header field values */\n\n if (AV_RL32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)\n\n return 0;\n\n\n\n return AVPROBE_SCORE_MAX;\n\n}\n", + "output": "0", + "index": 21944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int queue_attached_pictures(AVFormatContext *s)\n\n{\n\n int i;\n\n for (i = 0; i < s->nb_streams; i++)\n\n if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&\n\n s->streams[i]->discard < AVDISCARD_ALL) {\n\n AVPacket copy = s->streams[i]->attached_pic;\n\n copy.buf = av_buffer_ref(copy.buf);\n\n if (!copy.buf)\n\n return AVERROR(ENOMEM);\n\n\n\n add_to_pktbuf(&s->internal->raw_packet_buffer, ©,\n\n &s->internal->raw_packet_buffer_end);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 14988 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n __asm__ volatile(\n\n \"movq \"MANGLE(bm01010101)\", %%mm4 \\n\\t\"\n\n \"mov %0, %%\"REG_a\" \\n\\t\"\n\n \"1: \\n\\t\"\n\n \"movq (%1, %%\"REG_a\",2), %%mm0 \\n\\t\"\n\n \"movq 8(%1, %%\"REG_a\",2), %%mm1 \\n\\t\"\n\n \"movq (%2, %%\"REG_a\",2), %%mm2 \\n\\t\"\n\n \"movq 8(%2, %%\"REG_a\",2), %%mm3 \\n\\t\"\n\n \"pand %%mm4, %%mm0 \\n\\t\"\n\n \"pand %%mm4, %%mm1 \\n\\t\"\n\n \"pand %%mm4, %%mm2 \\n\\t\"\n\n \"pand %%mm4, %%mm3 \\n\\t\"\n\n \"packuswb %%mm1, %%mm0 \\n\\t\"\n\n \"packuswb %%mm3, %%mm2 \\n\\t\"\n\n \"movq %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\n \"movq %%mm2, (%4, %%\"REG_a\") \\n\\t\"\n\n \"add $8, %%\"REG_a\" \\n\\t\"\n\n \" js 1b \\n\\t\"\n\n : : \"g\" ((x86_reg)-width), \"r\" (src1+width*2), \"r\" (src2+width*2), \"r\" (dstU+width), \"r\" (dstV+width)\n\n : \"%\"REG_a\n\n );\n\n#else\n\n int i;\n\n for (i=0; icleanup_bh);\n\n s->cleanup_bh = NULL;\n\n\n\n if (s->file) {\n\n trace_migrate_fd_cleanup();\n\n qemu_mutex_unlock_iothread();\n\n qemu_thread_join(&s->thread);\n\n qemu_mutex_lock_iothread();\n\n\n\n qemu_fclose(s->file);\n\n s->file = NULL;\n\n }\n\n\n\n assert(s->state != MIG_STATE_ACTIVE);\n\n\n\n if (s->state != MIG_STATE_COMPLETED) {\n\n qemu_savevm_state_cancel();\n\n if (s->state == MIG_STATE_CANCELLING) {\n\n migrate_set_state(s, MIG_STATE_CANCELLING, MIG_STATE_CANCELLED);\n\n }\n\n }\n\n\n\n notifier_list_notify(&migration_state_notifiers, s);\n\n}\n", + "output": "1", + "index": 18826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int flashsv_decode_init(AVCodecContext *avctx)\n\n{\n\n FlashSVContext *s = avctx->priv_data;\n\n int zret; // Zlib return code\n\n\n\n s->avctx = avctx;\n\n s->zstream.zalloc = Z_NULL;\n\n s->zstream.zfree = Z_NULL;\n\n s->zstream.opaque = Z_NULL;\n\n zret = inflateInit(&s->zstream);\n\n if (zret != Z_OK) {\n\n av_log(avctx, AV_LOG_ERROR, \"Inflate init error: %d\\n\", zret);\n\n return 1;\n\n }\n\n avctx->pix_fmt = AV_PIX_FMT_BGR24;\n\n s->frame.data[0] = NULL;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13673 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int find_best(struct vf_instance *vf){\n\n int is_format_okay = vf->next->query_format(vf->next, IMGFMT_YV12);\n\n if ((is_format_okay & VFCAP_CSP_SUPPORTED_BY_HW) || (is_format_okay & VFCAP_CSP_SUPPORTED))\n\n return IMGFMT_YV12;\n\n else\n\n return 0;\n\n}\n", + "output": "1", + "index": 25066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_submit_many(void)\n\n{\n\n WorkerTestData data[100];\n\n int i;\n\n\n\n /* Start more work items than there will be threads. */\n\n for (i = 0; i < 100; i++) {\n\n data[i].n = 0;\n\n data[i].ret = -EINPROGRESS;\n\n thread_pool_submit_aio(worker_cb, &data[i], done_cb, &data[i]);\n\n }\n\n\n\n active = 100;\n\n while (active > 0) {\n\n qemu_aio_wait();\n\n }\n\n for (i = 0; i < 100; i++) {\n\n g_assert_cmpint(data[i].n, ==, 1);\n\n g_assert_cmpint(data[i].ret, ==, 0);\n\n }\n\n}\n", + "output": "0", + "index": 15056 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)\n\n{\n\n struct kvm_signal_mask *sigmask;\n\n int r;\n\n\n\n if (!sigset)\n\n return kvm_vcpu_ioctl(env, KVM_SET_SIGNAL_MASK, NULL);\n\n\n\n sigmask = qemu_malloc(sizeof(*sigmask) + sizeof(*sigset));\n\n\n\n sigmask->len = 8;\n\n memcpy(sigmask->sigset, sigset, sizeof(*sigset));\n\n r = kvm_vcpu_ioctl(env, KVM_SET_SIGNAL_MASK, sigmask);\n\n free(sigmask);\n\n\n\n return r;\n\n}\n", + "output": "0", + "index": 22094 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void block_job_cancel(BlockJob *job)\n\n{\n\n job->cancelled = true;\n\n block_job_resume(job);\n\n}\n", + "output": "0", + "index": 6869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int roq_probe(AVProbeData *p)\n\n{\n\n if (p->buf_size < 6)\n\n return 0;\n\n\n\n if ((AV_RL16(&p->buf[0]) != RoQ_MAGIC_NUMBER) ||\n\n (AV_RL32(&p->buf[2]) != 0xFFFFFFFF))\n\n return 0;\n\n\n\n return AVPROBE_SCORE_MAX;\n\n}\n", + "output": "0", + "index": 6707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "opts_next_list(Visitor *v, GenericList **list, size_t size)\n\n{\n\n OptsVisitor *ov = to_ov(v);\n\n GenericList **link;\n\n\n\n switch (ov->list_mode) {\n\n case LM_STARTED:\n\n ov->list_mode = LM_IN_PROGRESS;\n\n link = list;\n\n break;\n\n\n\n case LM_SIGNED_INTERVAL:\n\n case LM_UNSIGNED_INTERVAL:\n\n link = &(*list)->next;\n\n\n\n if (ov->list_mode == LM_SIGNED_INTERVAL) {\n\n if (ov->range_next.s < ov->range_limit.s) {\n\n ++ov->range_next.s;\n\n break;\n\n }\n\n } else if (ov->range_next.u < ov->range_limit.u) {\n\n ++ov->range_next.u;\n\n break;\n\n }\n\n ov->list_mode = LM_IN_PROGRESS;\n\n /* range has been completed, fall through in order to pop option */\n\n\n\n case LM_IN_PROGRESS: {\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 break;\n\n }\n\n\n\n default:\n\n abort();\n\n }\n\n\n\n *link = g_malloc0(size);\n\n return *link;\n\n}\n", + "output": "0", + "index": 23162 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_mce_inj_srao_memscrub(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 | 0xc0,\n\n .mcg_status = MCG_STATUS_MCIP | MCG_STATUS_RIPV,\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": 26167 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qdev_prop_set_globals_for_type(DeviceState *dev,\n\n const char *typename)\n\n{\n\n GlobalProperty *prop;\n\n\n\n QTAILQ_FOREACH(prop, &global_props, next) {\n\n Error *err = NULL;\n\n\n\n if (strcmp(typename, prop->driver) != 0) {\n\n continue;\n\n }\n\n prop->used = true;\n\n object_property_parse(OBJECT(dev), prop->value, prop->property, &err);\n\n if (err != NULL) {\n\n assert(prop->user_provided);\n\n error_reportf_err(err, \"Warning: global %s.%s=%s ignored: \",\n\n prop->driver, prop->property, prop->value);\n\n return;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 4143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rdma_alloc_qp(RDMAContext *rdma)\n\n{\n\n struct ibv_qp_init_attr attr = { 0 };\n\n int ret;\n\n\n\n attr.cap.max_send_wr = RDMA_SIGNALED_SEND_MAX;\n\n attr.cap.max_recv_wr = 3;\n\n attr.cap.max_send_sge = 1;\n\n attr.cap.max_recv_sge = 1;\n\n attr.send_cq = rdma->cq;\n\n attr.recv_cq = rdma->cq;\n\n attr.qp_type = IBV_QPT_RC;\n\n\n\n ret = rdma_create_qp(rdma->cm_id, rdma->pd, &attr);\n\n if (ret) {\n\n return -1;\n\n }\n\n\n\n rdma->qp = rdma->cm_id->qp;\n\n return 0;\n\n}\n", + "output": "1", + "index": 22237 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t ide_data_readw(void *opaque, uint32_t addr)\n\n{\n\n IDEBus *bus = opaque;\n\n IDEState *s = idebus_active_if(bus);\n\n uint8_t *p;\n\n int ret;\n\n\n\n /* PIO data access allowed only when DRQ bit is set. The result of a read\n\n * during PIO in is indeterminate, return 0 and don't move forward. */\n\n if (!(s->status & DRQ_STAT) || !ide_is_pio_out(s)) {\n\n return 0;\n\n }\n\n\n\n p = s->data_ptr;\n\n if (p + 2 > s->data_end) {\n\n return 0;\n\n }\n\n\n\n ret = cpu_to_le16(*(uint16_t *)p);\n\n p += 2;\n\n s->data_ptr = p;\n\n if (p >= s->data_end)\n\n s->end_transfer_func(s);\n\n return ret;\n\n}\n", + "output": "1", + "index": 17551 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_thread_create(QemuThread *thread,\n\n void *(*start_routine)(void *),\n\n void *arg, int mode)\n\n{\n\n HANDLE hThread;\n\n\n\n assert(mode == QEMU_THREAD_DETACHED);\n\n\n\n struct QemuThreadData *data;\n\n qemu_thread_init();\n\n data = g_malloc(sizeof *data);\n\n data->thread = thread;\n\n data->start_routine = start_routine;\n\n data->arg = arg;\n\n\n\n hThread = (HANDLE) _beginthreadex(NULL, 0, win32_start_routine,\n\n data, 0, NULL);\n\n if (!hThread) {\n\n error_exit(GetLastError(), __func__);\n\n }\n\n CloseHandle(hThread);\n\n}\n", + "output": "1", + "index": 9002 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, mkv_track *tracks, int num_tracks)\n\n{\n\n ebml_master cues_element;\n\n int64_t currentpos;\n\n int i, j;\n\n\n\n currentpos = avio_tell(pb);\n\n cues_element = start_ebml_master(pb, MATROSKA_ID_CUES, 0);\n\n\n\n for (i = 0; i < cues->num_entries; i++) {\n\n ebml_master cuepoint, track_positions;\n\n mkv_cuepoint *entry = &cues->entries[i];\n\n uint64_t pts = entry->pts;\n\n\n\n cuepoint = start_ebml_master(pb, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(num_tracks));\n\n put_ebml_uint(pb, MATROSKA_ID_CUETIME, pts);\n\n\n\n // put all the entries from different tracks that have the exact same\n\n // timestamp into the same CuePoint\n\n for (j = 0; j < num_tracks; j++)\n\n tracks[j].has_cue = 0;\n\n for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {\n\n if (tracks[entry[j].tracknum].has_cue)\n\n continue;\n\n tracks[entry[j].tracknum].has_cue = 1;\n\n track_positions = start_ebml_master(pb, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);\n\n put_ebml_uint(pb, MATROSKA_ID_CUETRACK , entry[j].tracknum );\n\n put_ebml_uint(pb, MATROSKA_ID_CUECLUSTERPOSITION, entry[j].cluster_pos);\n\n end_ebml_master(pb, track_positions);\n\n }\n\n i += j - 1;\n\n end_ebml_master(pb, cuepoint);\n\n }\n\n end_ebml_master(pb, cues_element);\n\n\n\n return currentpos;\n\n}\n", + "output": "0", + "index": 8198 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_scsi_exit(VirtIODevice *vdev)\n\n{\n\n\n\n virtio_cleanup(vdev);\n\n}", + "output": "1", + "index": 17498 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cow_close(BlockDriverState *bs)\n\n{\n\n}\n", + "output": "0", + "index": 9872 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int filter_frame(AVFilterLink *link, AVFrame *frame)\n\n{\n\n AVFilterContext *ctx = link->dst;\n\n AudioFIRContext *s = ctx->priv;\n\n AVFilterLink *outlink = ctx->outputs[0];\n\n int ret = 0;\n\n\n\n av_audio_fifo_write(s->fifo[0], (void **)frame->extended_data,\n\n frame->nb_samples);\n\n if (s->pts == AV_NOPTS_VALUE)\n\n s->pts = frame->pts;\n\n\n\n av_frame_free(&frame);\n\n\n\n if (!s->have_coeffs && s->eof_coeffs) {\n\n ret = convert_coeffs(ctx);\n\n if (ret < 0)\n\n return ret;\n\n }\n\n\n\n if (s->have_coeffs) {\n\n while (av_audio_fifo_size(s->fifo[0]) >= s->part_size) {\n\n ret = fir_frame(s, outlink);\n\n if (ret < 0)\n\n break;\n\n }\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 24430 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const AVOption *av_opt_next(void *obj, const AVOption *last)\n\n{\n\n AVClass *class = *(AVClass**)obj;\n\n if (!last && class->option && class->option[0].name)\n\n return class->option;\n\n if (last && last[1].name)\n\n return ++last;\n\n return NULL;\n\n}\n", + "output": "0", + "index": 25463 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *json_escape_str(const char *s)\n\n{\n\n static const char json_escape[] = {'\"', '\\\\', '\\b', '\\f', '\\n', '\\r', '\\t', 0};\n\n static const char json_subst[] = {'\"', '\\\\', 'b', 'f', 'n', 'r', 't', 0};\n\n char *ret, *p;\n\n int i, len = 0;\n\n\n\n // compute the length of the escaped string\n\n for (i = 0; s[i]; i++) {\n\n if (strchr(json_escape, s[i])) len += 2; // simple escape\n\n else if ((unsigned char)s[i] < 32) len += 6; // handle non-printable chars\n\n else len += 1; // char copy\n\n }\n\n\n\n p = ret = av_malloc(len + 1);\n\n if (!p)\n\n return NULL;\n\n for (i = 0; s[i]; i++) {\n\n char *q = strchr(json_escape, s[i]);\n\n if (q) {\n\n *p++ = '\\\\';\n\n *p++ = json_subst[q - json_escape];\n\n } else if ((unsigned char)s[i] < 32) {\n\n snprintf(p, 7, \"\\\\u00%02x\", s[i] & 0xff);\n\n p += 6;\n\n } else {\n\n *p++ = s[i];\n\n }\n\n }\n\n *p = 0;\n\n return ret;\n\n}\n", + "output": "1", + "index": 15216 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_token_in(USBDevice *s, USBPacket *p)\n\n{\n\n int request, value, index;\n\n int ret = 0;\n\n\n\n if (p->devep != 0)\n\n return s->info->handle_data(s, p);\n\n\n\n request = (s->setup_buf[0] << 8) | s->setup_buf[1];\n\n value = (s->setup_buf[3] << 8) | s->setup_buf[2];\n\n index = (s->setup_buf[5] << 8) | s->setup_buf[4];\n\n \n\n switch(s->setup_state) {\n\n case SETUP_STATE_ACK:\n\n if (!(s->setup_buf[0] & USB_DIR_IN)) {\n\n ret = s->info->handle_control(s, p, request, value, index,\n\n s->setup_len, s->data_buf);\n\n if (ret == USB_RET_ASYNC) {\n\n return USB_RET_ASYNC;\n\n }\n\n s->setup_state = SETUP_STATE_IDLE;\n\n if (ret > 0)\n\n return 0;\n\n return ret;\n\n }\n\n\n\n /* return 0 byte */\n\n return 0;\n\n\n\n case SETUP_STATE_DATA:\n\n if (s->setup_buf[0] & USB_DIR_IN) {\n\n int len = s->setup_len - s->setup_index;\n\n if (len > p->len)\n\n len = p->len;\n\n memcpy(p->data, s->data_buf + s->setup_index, len);\n\n s->setup_index += len;\n\n if (s->setup_index >= s->setup_len)\n\n s->setup_state = SETUP_STATE_ACK;\n\n return len;\n\n }\n\n\n\n s->setup_state = SETUP_STATE_IDLE;\n\n return USB_RET_STALL;\n\n\n\n default:\n\n return USB_RET_STALL;\n\n }\n\n}\n", + "output": "1", + "index": 20834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_mutex_unlock_iothread(void)\n\n{\n\n qemu_mutex_unlock(&qemu_global_mutex);\n\n}\n", + "output": "1", + "index": 3705 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start,\n\n uintptr_t length)\n\n{\n\n uintptr_t addr;\n\n\n\n if (tlb_is_dirty_ram(tlb_entry)) {\n\n addr = (tlb_entry->addr_write & TARGET_PAGE_MASK) + tlb_entry->addend;\n\n if ((addr - start) < length) {\n\n tlb_entry->addr_write |= TLB_NOTDIRTY;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 12606 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void slavio_misc_init(target_phys_addr_t base,\n\n target_phys_addr_t aux1_base,\n\n target_phys_addr_t aux2_base, qemu_irq irq,\n\n qemu_irq fdc_tc)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n\n\n dev = qdev_create(NULL, \"slavio_misc\");\n\n qdev_init(dev);\n\n s = sysbus_from_qdev(dev);\n\n if (base) {\n\n /* 8 bit registers */\n\n /* Slavio control */\n\n sysbus_mmio_map(s, 0, base + MISC_CFG);\n\n /* Diagnostics */\n\n sysbus_mmio_map(s, 1, base + MISC_DIAG);\n\n /* Modem control */\n\n sysbus_mmio_map(s, 2, base + MISC_MDM);\n\n /* 16 bit registers */\n\n /* ss600mp diag LEDs */\n\n sysbus_mmio_map(s, 3, base + MISC_LEDS);\n\n /* 32 bit registers */\n\n /* System control */\n\n sysbus_mmio_map(s, 4, base + MISC_SYS);\n\n }\n\n if (aux1_base) {\n\n /* AUX 1 (Misc System Functions) */\n\n sysbus_mmio_map(s, 5, aux1_base);\n\n }\n\n if (aux2_base) {\n\n /* AUX 2 (Software Powerdown Control) */\n\n sysbus_mmio_map(s, 6, aux2_base);\n\n }\n\n sysbus_connect_irq(s, 0, irq);\n\n sysbus_connect_irq(s, 1, fdc_tc);\n\n qemu_system_powerdown = qdev_get_gpio_in(dev, 0);\n\n}\n", + "output": "1", + "index": 26090 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count)\n\n{\n\n Coroutine *co;\n\n DiscardCo rwco = {\n\n .bs = bs,\n\n .offset = offset,\n\n .count = count,\n\n .ret = NOT_DONE,\n\n };\n\n\n\n if (qemu_in_coroutine()) {\n\n /* Fast-path if already in coroutine context */\n\n bdrv_pdiscard_co_entry(&rwco);\n\n } else {\n\n AioContext *aio_context = bdrv_get_aio_context(bs);\n\n\n\n co = qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco);\n\n qemu_coroutine_enter(co);\n\n while (rwco.ret == NOT_DONE) {\n\n aio_poll(aio_context, true);\n\n }\n\n }\n\n\n\n return rwco.ret;\n\n}\n", + "output": "0", + "index": 23751 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int dec_move_mr(DisasContext *dc)\n\n{\n\n\tint memsize = memsize_zz(dc);\n\n\tint insn_len;\n\n\tDIS(fprintf (logfile, \"move.%c [$r%u%s, $r%u\\n\",\n\n\t\t memsize_char(memsize),\n\n\t\t dc->op1, dc->postinc ? \"+]\" : \"]\",\n\n\t\t dc->op2));\n\n\n\n\tif (memsize == 4) {\n\n\t\tinsn_len = dec_prep_move_m(dc, 0, 4, cpu_R[dc->op2]);\n\n\t\tcris_cc_mask(dc, CC_MASK_NZ);\n\n\t\tcris_update_cc_op(dc, CC_OP_MOVE, 4);\n\n\t\tcris_update_cc_x(dc);\n\n\t\tcris_update_result(dc, cpu_R[dc->op2]);\n\n\t}\n\n\telse {\n\n\t\tTCGv t0;\n\n\n\n\t\tt0 = tcg_temp_new(TCG_TYPE_TL);\n\n\t\tinsn_len = dec_prep_move_m(dc, 0, memsize, t0);\n\n\t\tcris_cc_mask(dc, CC_MASK_NZ);\n\n\t\tcris_alu(dc, CC_OP_MOVE,\n\n\t\t\t cpu_R[dc->op2], cpu_R[dc->op2], t0, memsize);\n\n\t\ttcg_temp_free(t0);\n\n\t}\n\n\tdo_postinc(dc, memsize);\n\n\treturn insn_len;\n\n}\n", + "output": "0", + "index": 3834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void checkasm_check_h264pred(void)\n\n{\n\n static const struct {\n\n void (*func)(H264PredContext*, uint8_t*, uint8_t*, int, int, int);\n\n const char *name;\n\n } tests[] = {\n\n { check_pred4x4, \"pred4x4\" },\n\n { check_pred8x8, \"pred8x8\" },\n\n { check_pred16x16, \"pred16x16\" },\n\n { check_pred8x8l, \"pred8x8l\" },\n\n };\n\n\n\n DECLARE_ALIGNED(16, uint8_t, buf0)[BUF_SIZE];\n\n DECLARE_ALIGNED(16, uint8_t, buf1)[BUF_SIZE];\n\n H264PredContext h;\n\n int test, codec, chroma_format, bit_depth;\n\n\n\n for (test = 0; test < FF_ARRAY_ELEMS(tests); test++) {\n\n for (codec = 0; codec < 4; codec++) {\n\n int codec_id = codec_ids[codec];\n\n for (bit_depth = 8; bit_depth <= (codec_id == AV_CODEC_ID_H264 ? 10 : 8); bit_depth++)\n\n for (chroma_format = 1; chroma_format <= (codec_id == AV_CODEC_ID_H264 ? 2 : 1); chroma_format++) {\n\n ff_h264_pred_init(&h, codec_id, bit_depth, chroma_format);\n\n tests[test].func(&h, buf0, buf1, codec, chroma_format, bit_depth);\n\n }\n\n }\n\n report(\"%s\", tests[test].name);\n\n }\n\n}\n", + "output": "0", + "index": 11526 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void close_slaves(AVFormatContext *avf)\n\n{\n\n TeeContext *tee = avf->priv_data;\n\n AVFormatContext *avf2;\n\n unsigned i, j;\n\n\n\n for (i = 0; i < tee->nb_slaves; i++) {\n\n avf2 = tee->slaves[i].avf;\n\n\n\n for (j = 0; j < avf2->nb_streams; j++) {\n\n AVBitStreamFilterContext *bsf_next, *bsf = tee->slaves[i].bsfs[j];\n\n while (bsf) {\n\n bsf_next = bsf->next;\n\n av_bitstream_filter_close(bsf);\n\n bsf = bsf_next;\n\n }\n\n }\n\n av_freep(&tee->slaves[i].stream_map);\n\n\n\n\n avio_close(avf2->pb);\n\n avf2->pb = NULL;\n\n avformat_free_context(avf2);\n\n tee->slaves[i].avf = NULL;\n\n }\n\n}", + "output": "1", + "index": 7390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_client_set_memory(struct CPUPhysMemoryClient *client,\n\n\t\t\t\t target_phys_addr_t start_addr,\n\n\t\t\t\t ram_addr_t size,\n\n\t\t\t\t ram_addr_t phys_offset)\n\n{\n\n\tkvm_set_phys_mem(start_addr, size, phys_offset);\n\n}\n", + "output": "0", + "index": 7211 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct omap_uart_s *omap_uart_init(hwaddr base,\n\n qemu_irq irq, omap_clk fclk, omap_clk iclk,\n\n qemu_irq txdma, qemu_irq rxdma,\n\n const char *label, CharDriverState *chr)\n\n{\n\n struct omap_uart_s *s = (struct omap_uart_s *)\n\n g_malloc0(sizeof(struct omap_uart_s));\n\n\n\n s->base = base;\n\n s->fclk = fclk;\n\n s->irq = irq;\n\n s->serial = serial_mm_init(get_system_memory(), base, 2, irq,\n\n omap_clk_getrate(fclk)/16,\n\n chr ?: qemu_chr_new(label, \"null\", NULL),\n\n DEVICE_NATIVE_ENDIAN);\n\n return s;\n\n}\n", + "output": "1", + "index": 11235 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)\n\n{\n\n if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {\n\n char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];\n\n\n\n strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));\n\n strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));\n\n strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));\n\n strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));\n\n\n\n trace_colo_compare_ip_info(ppkt->size, pri_ip_src,\n\n pri_ip_dst, spkt->size,\n\n sec_ip_src, sec_ip_dst);\n\n }\n\n\n\n offset = ppkt->vnet_hdr_len + offset;\n\n\n\n if (ppkt->size == spkt->size) {\n\n return memcmp(ppkt->data + offset,\n\n spkt->data + offset,\n\n spkt->size - offset);\n\n } else {\n\n trace_colo_compare_main(\"Net packet size are not the same\");\n\n return -1;\n\n }\n\n}\n", + "output": "1", + "index": 7640 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoull_full_max(void)\n\n{\n\n char *str = g_strdup_printf(\"%lld\", ULLONG_MAX);\n\n uint64_t res = 999;\n\n int err;\n\n\n\n err = qemu_strtoull(str, NULL, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, ULLONG_MAX);\n\n g_free(str);\n\n}\n", + "output": "0", + "index": 12473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_devtree_setprop_cell(void *fdt, const char *node_path,\n\n const char *property, uint32_t val)\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_cell(fdt, offset, property, val);\n\n}\n", + "output": "1", + "index": 3240 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_inactivate_all(void)\n\n{\n\n BlockDriverState *bs = NULL;\n\n BdrvNextIterator it;\n\n int ret = 0;\n\n int pass;\n\n\n\n for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {\n\n aio_context_acquire(bdrv_get_aio_context(bs));\n\n }\n\n\n\n /* We do two passes of inactivation. The first pass calls to drivers'\n\n * .bdrv_inactivate callbacks recursively so all cache is flushed to disk;\n\n * the second pass sets the BDRV_O_INACTIVE flag so that no further write\n\n * is allowed. */\n\n for (pass = 0; pass < 2; pass++) {\n\n for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {\n\n ret = bdrv_inactivate_recurse(bs, pass);\n\n if (ret < 0) {\n\n\n goto out;\n\n }\n\n }\n\n }\n\n\n\nout:\n\n for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {\n\n aio_context_release(bdrv_get_aio_context(bs));\n\n }\n\n\n\n return ret;\n\n}", + "output": "1", + "index": 6001 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rbd_set_conf(rados_t cluster, const char *conf,\n\n bool only_read_conf_file,\n\n Error **errp)\n\n{\n\n char *p, *buf;\n\n char *name;\n\n char *value;\n\n Error *local_err = NULL;\n\n int ret = 0;\n\n\n\n buf = g_strdup(conf);\n\n p = buf;\n\n\n\n while (p) {\n\n name = qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p,\n\n '=', \"conf option name\", &p, &local_err);\n\n if (local_err) {\n\n break;\n\n }\n\n qemu_rbd_unescape(name);\n\n\n\n if (!p) {\n\n error_setg(errp, \"conf option %s has no value\", name);\n\n ret = -EINVAL;\n\n break;\n\n }\n\n\n\n value = qemu_rbd_next_tok(RBD_MAX_CONF_VAL_SIZE, p,\n\n ':', \"conf option value\", &p, &local_err);\n\n if (local_err) {\n\n break;\n\n }\n\n qemu_rbd_unescape(value);\n\n\n\n if (strcmp(name, \"conf\") == 0) {\n\n /* read the conf file alone, so it doesn't override more\n\n specific settings for a particular device */\n\n if (only_read_conf_file) {\n\n ret = rados_conf_read_file(cluster, value);\n\n if (ret < 0) {\n\n error_setg_errno(errp, -ret, \"error reading conf file %s\",\n\n value);\n\n break;\n\n }\n\n }\n\n } else if (strcmp(name, \"id\") == 0) {\n\n /* ignore, this is parsed by qemu_rbd_parse_clientname() */\n\n } else if (!only_read_conf_file) {\n\n ret = rados_conf_set(cluster, name, value);\n\n if (ret < 0) {\n\n error_setg_errno(errp, -ret, \"invalid conf option %s\", name);\n\n ret = -EINVAL;\n\n break;\n\n }\n\n }\n\n }\n\n\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n ret = -EINVAL;\n\n }\n\n g_free(buf);\n\n return ret;\n\n}\n", + "output": "0", + "index": 12765 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline av_flatten void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)\n\n{\n\n int i, d;\n\n for( i = 0; i < 4; i++ ) {\n\n if( tc0[i] < 0 ) {\n\n pix += 4*ystride;\n\n continue;\n\n }\n\n for( d = 0; d < 4; d++ ) {\n\n const int p0 = pix[-1*xstride];\n\n const int p1 = pix[-2*xstride];\n\n const int p2 = pix[-3*xstride];\n\n const int q0 = pix[0];\n\n const int q1 = pix[1*xstride];\n\n const int q2 = pix[2*xstride];\n\n\n\n if( FFABS( p0 - q0 ) < alpha &&\n\n FFABS( p1 - p0 ) < beta &&\n\n FFABS( q1 - q0 ) < beta ) {\n\n\n\n int tc = tc0[i];\n\n int i_delta;\n\n\n\n if( FFABS( p2 - p0 ) < beta ) {\n\n if(tc0[i])\n\n pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] );\n\n tc++;\n\n }\n\n if( FFABS( q2 - q0 ) < beta ) {\n\n if(tc0[i])\n\n pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] );\n\n tc++;\n\n }\n\n\n\n i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );\n\n pix[-xstride] = av_clip_uint8( p0 + i_delta ); /* p0' */\n\n pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */\n\n }\n\n pix += ystride;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 22950 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static SocketAddress *tcp_build_address(const char *host_port, Error **errp)\n\n{\n\n InetSocketAddress *iaddr = g_new(InetSocketAddress, 1);\n\n SocketAddress *saddr;\n\n\n\n if (inet_parse(iaddr, host_port, errp)) {\n\n qapi_free_InetSocketAddress(iaddr);\n\n return NULL;\n\n }\n\n\n\n saddr = g_new0(SocketAddress, 1);\n\n saddr->type = SOCKET_ADDRESS_KIND_INET;\n\n saddr->u.inet.data = iaddr;\n\n\n\n return saddr;\n\n}\n", + "output": "0", + "index": 23066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)\n\n{\n\n int ret, i;\n\n int tp_index = 0;\n\n\n\n s->bit_index = 8;\n\n if (tile->poc.nb_poc) {\n\n for (i=0; ipoc.nb_poc; i++) {\n\n Jpeg2000POCEntry *e = &tile->poc.poc[i];\n\n ret = jpeg2000_decode_packets_po_iteration(s, tile,\n\n e->RSpoc, e->CSpoc,\n\n e->LYEpoc, e->REpoc, e->CEpoc,\n\n e->Ppoc, &tp_index\n\n );\n\n if (ret < 0)\n\n return ret;\n\n }\n\n } else {\n\n ret = jpeg2000_decode_packets_po_iteration(s, tile,\n\n 0, 0,\n\n tile->codsty[0].nlayers,\n\n 33,\n\n s->ncomponents,\n\n tile->codsty[0].prog_order,\n\n &tp_index\n\n );\n\n }\n\n /* EOC marker reached */\n\n bytestream2_skip(&s->g, 2);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 5737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_l4_io_writeh(void *opaque, target_phys_addr_t addr,\n\n uint32_t value)\n\n{\n\n unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;\n\n\n\n return omap_l4_io_writeh_fn[i](omap_l4_io_opaque[i], addr, value);\n\n}\n", + "output": "0", + "index": 18163 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_lods(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_op_mov_reg_T0(ot, R_EAX);\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 } else\n\n#endif\n\n if (s->aflag) {\n\n gen_op_addl_ESI_T0();\n\n } else {\n\n gen_op_addw_ESI_T0();\n\n }\n\n}\n", + "output": "0", + "index": 9737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_init_vcpu(CPUState *env)\n\n{\n\n KVMState *s = kvm_state;\n\n long mmap_size;\n\n int ret;\n\n\n\n DPRINTF(\"kvm_init_vcpu\\n\");\n\n\n\n ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);\n\n if (ret < 0) {\n\n DPRINTF(\"kvm_create_vcpu failed\\n\");\n\n goto err;\n\n }\n\n\n\n env->kvm_fd = ret;\n\n env->kvm_state = s;\n\n\n\n mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);\n\n if (mmap_size < 0) {\n\n DPRINTF(\"KVM_GET_VCPU_MMAP_SIZE failed\\n\");\n\n goto err;\n\n }\n\n\n\n env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,\n\n env->kvm_fd, 0);\n\n if (env->kvm_run == MAP_FAILED) {\n\n ret = -errno;\n\n DPRINTF(\"mmap'ing vcpu state failed\\n\");\n\n goto err;\n\n }\n\n\n\n#ifdef KVM_CAP_COALESCED_MMIO\n\n if (s->coalesced_mmio && !s->coalesced_mmio_ring)\n\n s->coalesced_mmio_ring = (void *) env->kvm_run +\n\n\t\ts->coalesced_mmio * PAGE_SIZE;\n\n#endif\n\n\n\n ret = kvm_arch_init_vcpu(env);\n\n if (ret == 0) {\n\n qemu_register_reset(kvm_reset_vcpu, env);\n\n kvm_arch_reset_vcpu(env);\n\n }\n\nerr:\n\n return ret;\n\n}\n", + "output": "0", + "index": 10945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf)\n\n{\n\n CPU_DoubleU farg;\n\n int isneg;\n\n int ret;\n\n farg.ll = arg;\n\n isneg = float64_is_neg(farg.d);\n\n if (unlikely(float64_is_nan(farg.d))) {\n\n if (float64_is_signaling_nan(farg.d)) {\n\n /* Signaling NaN: flags are undefined */\n\n ret = 0x00;\n\n } else {\n\n /* Quiet NaN */\n\n ret = 0x11;\n\n }\n\n } else if (unlikely(float64_is_infinity(farg.d))) {\n\n /* +/- infinity */\n\n if (isneg)\n\n ret = 0x09;\n\n else\n\n ret = 0x05;\n\n } else {\n\n if (float64_is_zero(farg.d)) {\n\n /* +/- zero */\n\n if (isneg)\n\n ret = 0x12;\n\n else\n\n ret = 0x02;\n\n } else {\n\n if (isden(farg.d)) {\n\n /* Denormalized numbers */\n\n ret = 0x10;\n\n } else {\n\n /* Normalized numbers */\n\n ret = 0x00;\n\n }\n\n if (isneg) {\n\n ret |= 0x08;\n\n } else {\n\n ret |= 0x04;\n\n }\n\n }\n\n }\n\n if (set_fprf) {\n\n /* We update FPSCR_FPRF */\n\n env->fpscr &= ~(0x1F << FPSCR_FPRF);\n\n env->fpscr |= ret << FPSCR_FPRF;\n\n }\n\n /* We just need fpcc to update Rc1 */\n\n return ret & 0xF;\n\n}\n", + "output": "0", + "index": 19274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_add_data_offset(DisasContext *s, unsigned int insn,\n\n TCGv var)\n\n{\n\n int val, rm, shift, shiftop;\n\n TCGv offset;\n\n\n\n if (!(insn & (1 << 25))) {\n\n /* immediate */\n\n val = insn & 0xfff;\n\n if (!(insn & (1 << 23)))\n\n val = -val;\n\n if (val != 0)\n\n tcg_gen_addi_i32(var, var, val);\n\n } else {\n\n /* shift/register */\n\n rm = (insn) & 0xf;\n\n shift = (insn >> 7) & 0x1f;\n\n shiftop = (insn >> 5) & 3;\n\n offset = load_reg(s, rm);\n\n gen_arm_shift_im(offset, shiftop, shift, 0);\n\n if (!(insn & (1 << 23)))\n\n tcg_gen_sub_i32(var, var, offset);\n\n else\n\n tcg_gen_add_i32(var, var, offset);\n\n dead_tmp(offset);\n\n }\n\n}\n", + "output": "1", + "index": 20478 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t nbd_receive_request(QIOChannel *ioc, NBDRequest *request)\n\n{\n\n uint8_t buf[NBD_REQUEST_SIZE];\n\n uint32_t magic;\n\n ssize_t ret;\n\n\n\n ret = read_sync(ioc, buf, sizeof(buf), NULL);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n /* Request\n\n [ 0 .. 3] magic (NBD_REQUEST_MAGIC)\n\n [ 4 .. 5] flags (NBD_CMD_FLAG_FUA, ...)\n\n [ 6 .. 7] type (NBD_CMD_READ, ...)\n\n [ 8 .. 15] handle\n\n [16 .. 23] from\n\n [24 .. 27] len\n\n */\n\n\n\n magic = ldl_be_p(buf);\n\n request->flags = lduw_be_p(buf + 4);\n\n request->type = lduw_be_p(buf + 6);\n\n request->handle = ldq_be_p(buf + 8);\n\n request->from = ldq_be_p(buf + 16);\n\n request->len = ldl_be_p(buf + 24);\n\n\n\n TRACE(\"Got request: { magic = 0x%\" PRIx32 \", .flags = %\" PRIx16\n\n \", .type = %\" PRIx16 \", from = %\" PRIu64 \", len = %\" PRIu32 \" }\",\n\n magic, request->flags, request->type, request->from, request->len);\n\n\n\n if (magic != NBD_REQUEST_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": 7442 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_i_block(FourXContext *f, int16_t *block)\n\n{\n\n int code, i, j, level, val;\n\n\n\n if (get_bits_left(&f->gb) < 2){\n\n av_log(f->avctx, AV_LOG_ERROR, \"%d bits left before decode_i_block()\\n\", get_bits_left(&f->gb));\n\n return -1;\n\n }\n\n\n\n /* DC coef */\n\n val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);\n\n if (val >> 4)\n\n av_log(f->avctx, AV_LOG_ERROR, \"error dc run != 0\\n\");\n\n\n\n if (val)\n\n val = get_xbits(&f->gb, val);\n\n\n\n val = val * dequant_table[0] + f->last_dc;\n\n f->last_dc = block[0] = val;\n\n /* AC coefs */\n\n i = 1;\n\n for (;;) {\n\n code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);\n\n\n\n /* EOB */\n\n if (code == 0)\n\n break;\n\n if (code == 0xf0) {\n\n i += 16;\n\n } else {\n\n level = get_xbits(&f->gb, code & 0xf);\n\n i += code >> 4;\n\n if (i >= 64) {\n\n av_log(f->avctx, AV_LOG_ERROR, \"run %d oveflow\\n\", i);\n\n return 0;\n\n }\n\n\n\n j = ff_zigzag_direct[i];\n\n block[j] = level * dequant_table[j];\n\n i++;\n\n if (i >= 64)\n\n break;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11425 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong h_resize_hpt_commit(PowerPCCPU *cpu,\n\n sPAPRMachineState *spapr,\n\n target_ulong opcode,\n\n target_ulong *args)\n\n{\n\n target_ulong flags = args[0];\n\n target_ulong shift = args[1];\n\n sPAPRPendingHPT *pending = spapr->pending_hpt;\n\n int rc;\n\n size_t newsize;\n\n\n\n if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {\n\n return H_AUTHORITY;\n\n }\n\n\n\n trace_spapr_h_resize_hpt_commit(flags, shift);\n\n\n\n rc = kvmppc_resize_hpt_commit(cpu, flags, shift);\n\n if (rc != -ENOSYS) {\n\n return resize_hpt_convert_rc(rc);\n\n }\n\n\n\n if (flags != 0) {\n\n return H_PARAMETER;\n\n }\n\n\n\n if (!pending || (pending->shift != shift)) {\n\n /* no matching prepare */\n\n return H_CLOSED;\n\n }\n\n\n\n if (!pending->complete) {\n\n /* prepare has not completed */\n\n return H_BUSY;\n\n }\n\n\n\n /* Shouldn't have got past PREPARE without an HPT */\n\n g_assert(spapr->htab_shift);\n\n\n\n newsize = 1ULL << pending->shift;\n\n rc = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr),\n\n pending->hpt, newsize);\n\n if (rc == H_SUCCESS) {\n\n qemu_vfree(spapr->htab);\n\n spapr->htab = pending->hpt;\n\n spapr->htab_shift = pending->shift;\n\n\n\n if (kvm_enabled()) {\n\n /* For KVM PR, update the HPT pointer */\n\n target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab\n\n | (spapr->htab_shift - 18);\n\n kvmppc_update_sdr1(sdr1);\n\n }\n\n\n\n pending->hpt = NULL; /* so it's not free()d */\n\n }\n\n\n\n /* Clean up */\n\n spapr->pending_hpt = NULL;\n\n free_pending_hpt(pending);\n\n\n\n return rc;\n\n}\n", + "output": "0", + "index": 27012 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_resize(VncState *vs)\n\n{\n\n DisplayState *ds = vs->ds;\n\n\n\n int size_changed;\n\n\n\n vs->old_data = qemu_realloc(vs->old_data, ds_get_linesize(ds) * ds_get_height(ds));\n\n\n\n if (vs->old_data == NULL) {\n\n fprintf(stderr, \"vnc: memory allocation failed\\n\");\n\n exit(1);\n\n }\n\n\n\n if (ds_get_bytes_per_pixel(ds) != vs->serverds.pf.bytes_per_pixel)\n\n console_color_init(ds);\n\n vnc_colordepth(vs);\n\n size_changed = ds_get_width(ds) != vs->serverds.width ||\n\n ds_get_height(ds) != vs->serverds.height;\n\n vs->serverds = *(ds->surface);\n\n if (size_changed) {\n\n if (vs->csock != -1 && vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {\n\n vnc_write_u8(vs, 0); /* msg id */\n\n vnc_write_u8(vs, 0);\n\n vnc_write_u16(vs, 1); /* number of rects */\n\n vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),\n\n VNC_ENCODING_DESKTOPRESIZE);\n\n vnc_flush(vs);\n\n }\n\n }\n\n\n\n memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));\n\n memset(vs->old_data, 42, ds_get_linesize(vs->ds) * ds_get_height(vs->ds));\n\n}\n", + "output": "1", + "index": 5977 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t omap2_gpio_module_readp(void *opaque, target_phys_addr_t addr)\n\n{\n\n return omap2_gpio_module_readp(opaque, addr) >> ((addr & 3) << 3);\n\n}\n", + "output": "1", + "index": 5116 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_s390_notify(DeviceState *d, uint16_t vector)\n\n{\n\n VirtIOS390Device *dev = to_virtio_s390_device_fast(d);\n\n uint64_t token = s390_virtio_device_vq_token(dev, vector);\n\n S390CPU *cpu = s390_cpu_addr2state(0);\n\n\n\n s390_virtio_irq(cpu, 0, token);\n\n}\n", + "output": "0", + "index": 17717 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block)\n\n{\n\n uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n dest[0] = cm[(block[0] + 4)>>3];\n\n}\n", + "output": "1", + "index": 26849 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pcx_palette(const uint8_t **src, uint32_t *dst, unsigned int pallen) {\n\n unsigned int i;\n\n\n\n for (i=0; iicount_decr.u16.low + cpu->icount_extra);\n\n }\n\n return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount);\n\n}\n", + "output": "0", + "index": 10932 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_cmd_xfer_mode(SCSICommand *cmd)\n\n{\n\n if (!cmd->xfer) {\n\n cmd->mode = SCSI_XFER_NONE;\n\n return;\n\n }\n\n switch (cmd->buf[0]) {\n\n case WRITE_6:\n\n case WRITE_10:\n\n case WRITE_VERIFY_10:\n\n case WRITE_12:\n\n case WRITE_VERIFY_12:\n\n case WRITE_16:\n\n case WRITE_VERIFY_16:\n\n case COPY:\n\n case COPY_VERIFY:\n\n case COMPARE:\n\n case CHANGE_DEFINITION:\n\n case LOG_SELECT:\n\n case MODE_SELECT:\n\n case MODE_SELECT_10:\n\n case SEND_DIAGNOSTIC:\n\n case WRITE_BUFFER:\n\n case FORMAT_UNIT:\n\n case REASSIGN_BLOCKS:\n\n case SEARCH_EQUAL:\n\n case SEARCH_HIGH:\n\n case SEARCH_LOW:\n\n case UPDATE_BLOCK:\n\n case WRITE_LONG_10:\n\n case WRITE_SAME_10:\n\n case WRITE_SAME_16:\n\n case UNMAP:\n\n case SEARCH_HIGH_12:\n\n case SEARCH_EQUAL_12:\n\n case SEARCH_LOW_12:\n\n case MEDIUM_SCAN:\n\n case SEND_VOLUME_TAG:\n\n case SEND_CUE_SHEET:\n\n case SEND_DVD_STRUCTURE:\n\n case PERSISTENT_RESERVE_OUT:\n\n case MAINTENANCE_OUT:\n\n\n cmd->mode = SCSI_XFER_TO_DEV;\n\n break;\n\n default:\n\n cmd->mode = SCSI_XFER_FROM_DEV;\n\n break;\n\n }\n\n}", + "output": "1", + "index": 14012 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)\n\n{\n\n return guest_fsfreeze_state.status;\n\n}\n", + "output": "0", + "index": 15354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void qemu_assert(int cond, const char *msg)\n\n{\n\n if (!cond) {\n\n fprintf (stderr, \"badness: %s\\n\", msg);\n\n abort();\n\n }\n\n}\n", + "output": "1", + "index": 2239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bonito_pcihost_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);\n\n\n\n k->init = bonito_pcihost_initfn;\n\n dc->no_user = 1;\n\n}\n", + "output": "1", + "index": 4874 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_block_size_shift(BDRVSheepdogState *s, QemuOpts *opt)\n\n{\n\n struct SheepdogInode *inode = &s->inode;\n\n uint64_t object_size;\n\n int obj_order;\n\n\n\n object_size = qemu_opt_get_size_del(opt, BLOCK_OPT_OBJECT_SIZE, 0);\n\n if (object_size) {\n\n if ((object_size - 1) & object_size) { /* not a power of 2? */\n\n return -EINVAL;\n\n }\n\n obj_order = ffs(object_size) - 1;\n\n if (obj_order < 20 || obj_order > 31) {\n\n return -EINVAL;\n\n }\n\n inode->block_size_shift = (uint8_t)obj_order;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 10067 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "VIOsPAPRDevice *vty_lookup(sPAPRMachineState *spapr, target_ulong reg)\n{\n VIOsPAPRDevice *sdev;\n sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);\n if (!sdev && reg == 0) {\n /* Hack for kernel early debug, which always specifies reg==0.\n * We search all VIO devices, and grab the vty with the lowest\n * reg. This attempts to mimic existing PowerVM behaviour\n * (early debug does work there, despite having no vty with\n * reg==0. */\n return spapr_vty_get_default(spapr->vio_bus);\n return sdev;", + "output": "1", + "index": 9172 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *desc_get_buf(DescInfo *info, bool read_only)\n\n{\n\n PCIDevice *dev = PCI_DEVICE(info->ring->r);\n\n size_t size = read_only ? le16_to_cpu(info->desc.tlv_size) :\n\n le16_to_cpu(info->desc.buf_size);\n\n\n\n if (size > info->buf_size) {\n\n info->buf = g_realloc(info->buf, size);\n\n info->buf_size = size;\n\n }\n\n\n\n if (!info->buf) {\n\n return NULL;\n\n }\n\n\n\n if (pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size)) {\n\n return NULL;\n\n }\n\n\n\n return info->buf;\n\n}\n", + "output": "0", + "index": 502 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr)\n\n{\n\n uintptr_t ra = GETPC();\n\n CPUState *cs = CPU(s390_env_get_cpu(env));\n\n int i;\n\n\n\n real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK;\n\n\n\n /* Check low-address protection */\n\n if ((env->cregs[0] & CR0_LOWPROT) && real_addr < 0x2000) {\n\n cpu_restore_state(cs, ra);\n\n program_interrupt(env, PGM_PROTECTION, 4);\n\n return 1;\n\n }\n\n\n\n for (i = 0; i < TARGET_PAGE_SIZE; i += 8) {\n\n cpu_stq_real_ra(env, real_addr + i, 0, ra);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 1496 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int filter_frame(AVFilterLink *inlink, AVFrame *frame)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n AudioEchoContext *s = ctx->priv;\n\n AVFrame *out_frame;\n\n\n\n if (av_frame_is_writable(frame)) {\n\n out_frame = frame;\n\n } else {\n\n out_frame = ff_get_audio_buffer(inlink, frame->nb_samples);\n\n if (!out_frame)\n\n return AVERROR(ENOMEM);\n\n av_frame_copy_props(out_frame, frame);\n\n }\n\n\n\n s->echo_samples(s, s->delayptrs, frame->extended_data, out_frame->extended_data,\n\n frame->nb_samples, inlink->channels);\n\n\n\n s->next_pts = frame->pts + av_rescale_q(frame->nb_samples, (AVRational){1, inlink->sample_rate}, inlink->time_base);\n\n\n\n if (frame != out_frame)\n\n av_frame_free(&frame);\n\n\n\n return ff_filter_frame(ctx->outputs[0], out_frame);\n\n}\n", + "output": "1", + "index": 9597 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_hotplug_set_signalled(uint32_t drc_index)\n\n{\n\n sPAPRDRConnector *drc = spapr_drc_by_index(drc_index);\n\n sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n drck->set_signalled(drc);\n\n}\n", + "output": "0", + "index": 14580 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int swf_write_video(AVFormatContext *s, \n\n AVCodecContext *enc, const uint8_t *buf, int size)\n\n{\n\n ByteIOContext *pb = &s->pb;\n\n static int tag_id = 0;\n\n\n\n if (enc->frame_number > 1) {\n\n /* remove the shape */\n\n put_swf_tag(s, TAG_REMOVEOBJECT);\n\n put_le16(pb, SHAPE_ID); /* shape ID */\n\n put_le16(pb, 1); /* depth */\n\n put_swf_end_tag(s);\n\n \n\n /* free the bitmap */\n\n put_swf_tag(s, TAG_FREECHARACTER);\n\n put_le16(pb, BITMAP_ID);\n\n put_swf_end_tag(s);\n\n }\n\n\n\n put_swf_tag(s, TAG_JPEG2 | TAG_LONG);\n\n\n\n put_le16(pb, tag_id); /* ID of the image */\n\n\n\n /* a dummy jpeg header seems to be required */\n\n put_byte(pb, 0xff); \n\n put_byte(pb, 0xd8);\n\n put_byte(pb, 0xff);\n\n put_byte(pb, 0xd9);\n\n /* write the jpeg image */\n\n put_buffer(pb, buf, size);\n\n\n\n put_swf_end_tag(s);\n\n\n\n /* draw the shape */\n\n\n\n put_swf_tag(s, TAG_PLACEOBJECT);\n\n put_le16(pb, SHAPE_ID); /* shape ID */\n\n put_le16(pb, 1); /* depth */\n\n put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);\n\n put_swf_end_tag(s);\n\n \n\n /* output the frame */\n\n put_swf_tag(s, TAG_SHOWFRAME);\n\n put_swf_end_tag(s);\n\n \n\n put_flush_packet(&s->pb);\n\n return 0;\n\n}\n", + "output": "1", + "index": 4730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)\n\n{\n\n BufferSinkContext *buf = ctx->priv;\n\n AVBufferSinkParams *params = opaque;\n\n\n\n if (params && params->pixel_fmts) {\n\n const int *pixel_fmts = params->pixel_fmts;\n\n\n\n buf->pixel_fmts = ff_copy_int_list(pixel_fmts);\n\n if (!buf->pixel_fmts)\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n return common_init(ctx);\n\n}\n", + "output": "0", + "index": 24056 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name)\n\n{\n\n cl_int status;\n\n int i, ret = 0;\n\n LOCK_OPENCL;\n\n if (strlen(kernel_name) + 1 > AV_OPENCL_MAX_KERNEL_NAME_SIZE) {\n\n av_log(&openclutils, AV_LOG_ERROR, \"Created kernel name %s is too long\\n\", kernel_name);\n\n ret = AVERROR(EINVAL);\n\n goto end;\n\n }\n\n if (!env->kernel) {\n\n if (gpu_env.kernel_count >= MAX_KERNEL_NUM) {\n\n av_log(&openclutils, AV_LOG_ERROR,\n\n \"Could not create kernel with name '%s', maximum number of kernels %d already reached\\n\",\n\n kernel_name, MAX_KERNEL_NUM);\n\n ret = AVERROR(EINVAL);\n\n goto end;\n\n }\n\n for (i = 0; i < gpu_env.program_count; i++) {\n\n env->kernel = clCreateKernel(gpu_env.programs[i], kernel_name, &status);\n\n if (status == CL_SUCCESS)\n\n break;\n\n }\n\n if (status != CL_SUCCESS) {\n\n av_log(&openclutils, AV_LOG_ERROR, \"Could not create OpenCL kernel: %s\\n\", opencl_errstr(status));\n\n ret = AVERROR_EXTERNAL;\n\n goto end;\n\n }\n\n gpu_env.kernel_count++;\n\n env->command_queue = gpu_env.command_queue;\n\n av_strlcpy(env->kernel_name, kernel_name, sizeof(env->kernel_name));\n\n }\n\nend:\n\n UNLOCK_OPENCL;\n\n return ret;\n\n}\n", + "output": "0", + "index": 22090 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_log_default_callback(void *avcl, int level, const char *fmt, va_list vl)\n\n{\n\n static int print_prefix = 1;\n\n static int count;\n\n static char prev[1024];\n\n char line[1024];\n\n static int is_atty;\n\n AVClass* avc = avcl ? *(AVClass **) avcl : NULL;\n\n int tint = av_clip(level >> 8, 0, 256);\n\n\n\n level &= 0xff;\n\n\n\n if (level > av_log_level)\n\n return;\n\n line[0] = 0;\n\n if (print_prefix && avc) {\n\n if (avc->parent_log_context_offset) {\n\n AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +\n\n avc->parent_log_context_offset);\n\n if (parent && *parent) {\n\n snprintf(line, sizeof(line), \"[%s @ %p] \",\n\n (*parent)->item_name(parent), parent);\n\n }\n\n }\n\n snprintf(line + strlen(line), sizeof(line) - strlen(line), \"[%s @ %p] \",\n\n avc->item_name(avcl), avcl);\n\n }\n\n\n\n vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);\n\n\n\n print_prefix = strlen(line) && line[strlen(line) - 1] == '\\n';\n\n\n\n#if HAVE_ISATTY\n\n if (!is_atty)\n\n is_atty = isatty(2) ? 1 : -1;\n\n#endif\n\n\n\n if (print_prefix && (flags & AV_LOG_SKIP_REPEATED) &&\n\n !strncmp(line, prev, sizeof line)) {\n\n count++;\n\n if (is_atty == 1)\n\n fprintf(stderr, \" Last message repeated %d times\\r\", count);\n\n return;\n\n }\n\n if (count > 0) {\n\n fprintf(stderr, \" Last message repeated %d times\\n\", count);\n\n count = 0;\n\n }\n\n colored_fputs(av_clip(level >> 3, 0, 6), tint, line);\n\n av_strlcpy(prev, line, sizeof line);\n\n}\n", + "output": "1", + "index": 26994 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mmubooke_create_initial_mapping(CPUPPCState *env)\n\n{\n\n struct boot_info *bi = env->load_info;\n\n ppcmas_tlb_t *tlb = booke206_get_tlbm(env, 1, 0, 0);\n\n hwaddr size, dt_end;\n\n int ps;\n\n\n\n /* Our initial TLB entry needs to cover everything from 0 to\n\n the device tree top */\n\n dt_end = bi->dt_base + bi->dt_size;\n\n ps = booke206_page_size_to_tlb(dt_end) + 1;\n\n if (ps & 1) {\n\n /* e500v2 can only do even TLB size bits */\n\n ps++;\n\n }\n\n size = (ps << MAS1_TSIZE_SHIFT);\n\n tlb->mas1 = MAS1_VALID | size;\n\n tlb->mas2 = 0;\n\n tlb->mas7_3 = 0;\n\n tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;\n\n\n\n env->tlb_dirty = true;\n\n}\n", + "output": "0", + "index": 14725 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool cmd_read_dma(IDEState *s, uint8_t cmd)\n\n{\n\n bool lba48 = (cmd == WIN_READDMA_EXT);\n\n\n\n if (!s->bs) {\n\n ide_abort_command(s);\n\n return true;\n\n }\n\n\n\n ide_cmd_lba48_transform(s, lba48);\n\n ide_sector_start_dma(s, IDE_DMA_READ);\n\n\n\n return false;\n\n}\n", + "output": "0", + "index": 10255 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)\n\n{\n\n int cb_x, cb_y, left, right, top, bottom;\n\n DiracArith c;\n\n GetBitContext gb;\n\n int cb_width = s->codeblock[b->level + (b->orientation != subband_ll)].width;\n\n int cb_height = s->codeblock[b->level + (b->orientation != subband_ll)].height;\n\n int blockcnt_one = (cb_width + cb_height) == 2;\n\n\n\n if (!b->length)\n\n return;\n\n\n\n init_get_bits8(&gb, b->coeff_data, b->length);\n\n\n\n if (is_arith)\n\n ff_dirac_init_arith_decoder(&c, &gb, b->length);\n\n\n\n top = 0;\n\n for (cb_y = 0; cb_y < cb_height; cb_y++) {\n\n bottom = (b->height * (cb_y+1)) / cb_height;\n\n left = 0;\n\n for (cb_x = 0; cb_x < cb_width; cb_x++) {\n\n right = (b->width * (cb_x+1)) / cb_width;\n\n codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith);\n\n left = right;\n\n }\n\n top = bottom;\n\n }\n\n\n\n if (b->orientation == subband_ll && s->num_refs == 0)\n\n intra_dc_prediction(b);\n\n}\n", + "output": "1", + "index": 13972 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_set_cpu_flags_mask(int mask)\n\n{\n\n checked = 0;\n\n flags = av_get_cpu_flags() & mask;\n\n checked = 1;\n\n}\n", + "output": "0", + "index": 9394 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)\n\n{\n\n AVStream *st = s->streams[stream_index];\n\n int64_t seconds;\n\n MXFContext* mxf = s->priv_data;\n\n int64_t seekpos;\n\n int ret;\n\n MXFIndexTable *t;\n\n\n\n if (mxf->nb_index_tables <= 0) {\n\n if (!s->bit_rate)\n\n return AVERROR_INVALIDDATA;\n\n if (sample_time < 0)\n\n sample_time = 0;\n\n seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);\n\n\n\n if ((ret = avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET)) < 0)\n\n return ret;\n\n ff_update_cur_dts(s, st, sample_time);\n\n mxf->current_edit_unit = sample_time;\n\n } else {\n\n t = &mxf->index_tables[0];\n\n\n\n /* clamp above zero, else ff_index_search_timestamp() returns negative\n\n * this also means we allow seeking before the start */\n\n sample_time = FFMAX(sample_time, 0);\n\n\n\n if (t->fake_index) {\n\n /* behave as if we have a proper index */\n\n if ((sample_time = ff_index_search_timestamp(t->fake_index, t->nb_ptses, sample_time, flags)) < 0)\n\n return sample_time;\n\n } else {\n\n /* no IndexEntryArray (one or more CBR segments)\n\n * make sure we don't seek past the end */\n\n sample_time = FFMIN(sample_time, st->duration - 1);\n\n }\n\n\n\n if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, 1)) << 0)\n\n return ret;\n\n\n\n ff_update_cur_dts(s, st, sample_time);\n\n mxf->current_edit_unit = sample_time;\n\n avio_seek(s->pb, seekpos, SEEK_SET);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 26568 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_addr_t end_addr)\n\n{\n\n KVMState *s = kvm_state;\n\n KVMDirtyLog d;\n\n KVMSlot *mem = kvm_lookup_slot(s, start_addr);\n\n unsigned long alloc_size;\n\n ram_addr_t addr;\n\n target_phys_addr_t phys_addr = start_addr;\n\n\n\n dprintf(\"sync addr: %llx into %lx\\n\", start_addr, mem->phys_offset);\n\n if (mem == NULL) {\n\n fprintf(stderr, \"BUG: %s: invalid parameters\\n\", __func__);\n\n return;\n\n }\n\n\n\n alloc_size = mem->memory_size >> TARGET_PAGE_BITS / sizeof(d.dirty_bitmap);\n\n d.dirty_bitmap = qemu_mallocz(alloc_size);\n\n\n\n d.slot = mem->slot;\n\n dprintf(\"slot %d, phys_addr %llx, uaddr: %llx\\n\",\n\n d.slot, mem->start_addr, mem->phys_offset);\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 goto out;\n\n }\n\n\n\n phys_addr = start_addr;\n\n for (addr = mem->phys_offset; phys_addr < end_addr; phys_addr+= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {\n\n unsigned long *bitmap = (unsigned long *)d.dirty_bitmap;\n\n unsigned nr = (phys_addr - start_addr) >> TARGET_PAGE_BITS;\n\n unsigned word = nr / (sizeof(*bitmap) * 8);\n\n unsigned bit = nr % (sizeof(*bitmap) * 8);\n\n if ((bitmap[word] >> bit) & 1)\n\n cpu_physical_memory_set_dirty(addr);\n\n }\n\nout:\n\n qemu_free(d.dirty_bitmap);\n\n}\n", + "output": "1", + "index": 8115 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf, \n\n int size)\n\n{\n\n AVStream *st;\n\n int64_t pts_mask;\n\n int ret, frame_size;\n\n\n\n st = s->streams[stream_index];\n\n pts_mask = (1LL << s->pts_wrap_bits) - 1;\n\n ret = s->oformat->write_packet(s, stream_index, buf, size, \n\n st->pts.val & pts_mask);\n\n if (ret < 0)\n\n return ret;\n\n\n\n /* update pts */\n\n switch (st->codec.codec_type) {\n\n case CODEC_TYPE_AUDIO:\n\n frame_size = get_audio_frame_size(&st->codec, size);\n\n\n\n /* note, we skip the initial 0-size packets as they are most likely equal to the encoder delay,\n\n but it would be better if we had the real timestamps from the encoder */\n\n// av_log(s, AV_LOG_DEBUG, \"%d %lld %lld\\n\", size, st->pts.num, st->pts.val);\n\n if (frame_size >= 0 && (size || st->pts.num!=st->pts.den>>1 || st->pts.val)) {\n\n av_frac_add(&st->pts, \n\n (int64_t)s->pts_den * frame_size);\n\n }\n\n break;\n\n case CODEC_TYPE_VIDEO:\n\n av_frac_add(&st->pts, \n\n (int64_t)s->pts_den * st->codec.frame_rate_base);\n\n break;\n\n default:\n\n break;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 12461 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tcg_match_cmpi(TCGType type, tcg_target_long val)\n\n{\n\n if (facilities & FACILITY_EXT_IMM) {\n\n /* The COMPARE IMMEDIATE instruction is available. */\n\n if (type == TCG_TYPE_I32) {\n\n /* We have a 32-bit immediate and can compare against anything. */\n\n return 1;\n\n } else {\n\n /* ??? We have no insight here into whether the comparison is\n\n signed or unsigned. The COMPARE IMMEDIATE insn uses a 32-bit\n\n signed immediate, and the COMPARE LOGICAL IMMEDIATE insn uses\n\n a 32-bit unsigned immediate. If we were to use the (semi)\n\n obvious \"val == (int32_t)val\" we would be enabling unsigned\n\n comparisons vs very large numbers. The only solution is to\n\n take the intersection of the ranges. */\n\n /* ??? Another possible solution is to simply lie and allow all\n\n constants here and force the out-of-range values into a temp\n\n register in tgen_cmp when we have knowledge of the actual\n\n comparison code in use. */\n\n return val >= 0 && val <= 0x7fffffff;\n\n }\n\n } else {\n\n /* Only the LOAD AND TEST instruction is available. */\n\n return val == 0;\n\n }\n\n}\n", + "output": "0", + "index": 67 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(qdict_get_try_str_test)\n\n{\n\n const char *p;\n\n const char *key = \"key\";\n\n const char *str = \"string\";\n\n\n\n qdict_put(tests_dict, key, qstring_from_str(str));\n\n\n\n p = qdict_get_try_str(tests_dict, key);\n\n fail_unless(p != NULL);\n\n fail_unless(strcmp(p, str) == 0);\n\n}\n", + "output": "0", + "index": 14710 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_neon_widen(TCGv_i64 dest, TCGv src, int size, int u)\n\n{\n\n if (u) {\n\n switch (size) {\n\n case 0: gen_helper_neon_widen_u8(dest, src); break;\n\n case 1: gen_helper_neon_widen_u16(dest, src); break;\n\n case 2: tcg_gen_extu_i32_i64(dest, src); break;\n\n default: abort();\n\n }\n\n } else {\n\n switch (size) {\n\n case 0: gen_helper_neon_widen_s8(dest, src); break;\n\n case 1: gen_helper_neon_widen_s16(dest, src); break;\n\n case 2: tcg_gen_ext_i32_i64(dest, src); break;\n\n default: abort();\n\n }\n\n }\n\n dead_tmp(src);\n\n}\n", + "output": "1", + "index": 26500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int print_device_sinks(AVOutputFormat *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_OUTPUT_DEVICE(fmt->priv_class->category))\n\n return AVERROR(EINVAL);\n\n\n\n printf(\"Audo-detected sinks for %s:\\n\", fmt->name);\n\n if (!fmt->get_device_list) {\n\n ret = AVERROR(ENOSYS);\n\n printf(\"Cannot list sinks. Not implemented.\\n\");\n\n goto fail;\n\n }\n\n\n\n if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) {\n\n printf(\"Cannot open device: %s.\\n\", fmt->name);\n\n goto fail;\n\n }\n\n av_dict_copy(&tmp_opts, opts, 0);\n\n av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);\n\n\n\n if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {\n\n printf(\"Cannot list sinks.\\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_free_context(dev);\n\n return ret;\n\n}\n", + "output": "1", + "index": 10413 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int jpeg2000_read_bitstream_packets(Jpeg2000DecoderContext *s)\n\n{\n\n int ret = 0;\n\n int tileno;\n\n\n\n for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) {\n\n Jpeg2000Tile *tile = s->tile + tileno;\n\n\n\n if (ret = init_tile(s, tileno))\n\n return ret;\n\n\n\n s->g = tile->tile_part[0].tpg;\n\n if (ret = jpeg2000_decode_packets(s, tile))\n\n return ret;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21838 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_nop_hint(DisasContext *s, int val)\n\n{\n\n switch (val) {\n\n case 1: /* yield */\n\n if (!parallel_cpus) {\n\n gen_set_pc_im(s, s->pc);\n\n s->base.is_jmp = DISAS_YIELD;\n\n }\n\n break;\n\n case 3: /* wfi */\n\n gen_set_pc_im(s, s->pc);\n\n s->base.is_jmp = DISAS_WFI;\n\n break;\n\n case 2: /* wfe */\n\n if (!parallel_cpus) {\n\n gen_set_pc_im(s, s->pc);\n\n s->base.is_jmp = DISAS_WFE;\n\n }\n\n break;\n\n case 4: /* sev */\n\n case 5: /* sevl */\n\n /* TODO: Implement SEV, SEVL and WFE. May help SMP performance. */\n\n default: /* nop */\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 14396 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vnc_client_io_error(VncState *vs, int ret, int last_errno)\n\n{\n\n if (ret == 0 || ret == -1) {\n\n if (ret == -1) {\n\n switch (last_errno) {\n\n case EINTR:\n\n case EAGAIN:\n\n#ifdef _WIN32\n\n case WSAEWOULDBLOCK:\n\n#endif\n\n return 0;\n\n default:\n\n break;\n\n }\n\n }\n\n\n\n\tVNC_DEBUG(\"Closing down client sock %d %d\\n\", ret, ret < 0 ? last_errno : 0);\n\n\tqemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);\n\n\tclosesocket(vs->csock);\n\n qemu_del_timer(vs->timer);\n\n qemu_free_timer(vs->timer);\n\n if (vs->input.buffer) qemu_free(vs->input.buffer);\n\n if (vs->output.buffer) qemu_free(vs->output.buffer);\n\n#ifdef CONFIG_VNC_TLS\n\n\tif (vs->tls_session) {\n\n\t gnutls_deinit(vs->tls_session);\n\n\t vs->tls_session = NULL;\n\n\t}\n\n#endif /* CONFIG_VNC_TLS */\n\n audio_del(vs);\n\n\n\n VncState *p, *parent = NULL;\n\n for (p = vs->vd->clients; p != NULL; p = p->next) {\n\n if (p == vs) {\n\n if (parent)\n\n parent->next = p->next;\n\n else\n\n vs->vd->clients = p->next;\n\n break;\n\n }\n\n parent = p;\n\n }\n\n if (!vs->vd->clients)\n\n dcl->idle = 1;\n\n\n\n qemu_free(vs->old_data);\n\n qemu_free(vs);\n\n \n\n\treturn 0;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 23421 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static UserDefNested *nested_struct_create(void)\n\n{\n\n UserDefNested *udnp = g_malloc0(sizeof(*udnp));\n\n udnp->string0 = strdup(\"test_string0\");\n\n udnp->dict1.string1 = strdup(\"test_string1\");\n\n udnp->dict1.dict2.userdef1 = g_malloc0(sizeof(UserDefOne));\n\n udnp->dict1.dict2.userdef1->base = g_new0(UserDefZero, 1);\n\n udnp->dict1.dict2.userdef1->base->integer = 42;\n\n udnp->dict1.dict2.userdef1->string = strdup(\"test_string\");\n\n udnp->dict1.dict2.string2 = strdup(\"test_string2\");\n\n udnp->dict1.has_dict3 = true;\n\n udnp->dict1.dict3.userdef2 = g_malloc0(sizeof(UserDefOne));\n\n udnp->dict1.dict3.userdef2->base = g_new0(UserDefZero, 1);\n\n udnp->dict1.dict3.userdef2->base->integer = 43;\n\n udnp->dict1.dict3.userdef2->string = strdup(\"test_string\");\n\n udnp->dict1.dict3.string3 = strdup(\"test_string3\");\n\n return udnp;\n\n}\n", + "output": "0", + "index": 876 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *show_parts(void *arg)\n\n{\n\n char *device = arg;\n\n int nbd;\n\n\n\n /* linux just needs an open() to trigger\n\n * the partition table update\n\n * but remember to load the module with max_part != 0 :\n\n * modprobe nbd max_part=63\n\n */\n\n nbd = open(device, O_RDWR);\n\n if (nbd != -1) {\n\n close(nbd);\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 14919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_unlinkat(FsContext *ctx, V9fsPath *dir,\n\n const char *name, int flags)\n\n{\n\n int ret;\n\n V9fsString fullname;\n\n char buffer[PATH_MAX];\n\n\n\n v9fs_string_init(&fullname);\n\n\n\n v9fs_string_sprintf(&fullname, \"%s/%s\", dir->data, name);\n\n if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n\n if (flags == AT_REMOVEDIR) {\n\n /*\n\n * If directory remove .virtfs_metadata contained in the\n\n * directory\n\n */\n\n snprintf(buffer, ARRAY_SIZE(buffer), \"%s/%s/%s\", ctx->fs_root,\n\n fullname.data, VIRTFS_META_DIR);\n\n ret = remove(buffer);\n\n if (ret < 0 && errno != ENOENT) {\n\n /*\n\n * We didn't had the .virtfs_metadata file. May be file created\n\n * in non-mapped mode ?. Ignore ENOENT.\n\n */\n\n goto err_out;\n\n }\n\n }\n\n /*\n\n * Now remove the name from parent directory\n\n * .virtfs_metadata directory.\n\n */\n\n ret = remove(local_mapped_attr_path(ctx, fullname.data, buffer));\n\n if (ret < 0 && errno != ENOENT) {\n\n /*\n\n * We didn't had the .virtfs_metadata file. May be file created\n\n * in non-mapped mode ?. Ignore ENOENT.\n\n */\n\n goto err_out;\n\n }\n\n }\n\n /* Remove the name finally */\n\n ret = remove(rpath(ctx, fullname.data, buffer));\n\n\n\nerr_out:\n\n v9fs_string_free(&fullname);\n\n return ret;\n\n}\n", + "output": "0", + "index": 18222 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status,\n\n void *command_data, void *opaque)\n\n{\n\n struct IscsiTask *itask = opaque;\n\n struct scsi_readcapacity10 *rc10;\n\n struct scsi_task *task = command_data;\n\n\n\n if (status != 0) {\n\n error_report(\"iSCSI: Failed to read capacity of iSCSI lun. %s\",\n\n iscsi_get_error(iscsi));\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 rc10 = scsi_datain_unmarshall(task);\n\n if (rc10 == NULL) {\n\n error_report(\"iSCSI: Failed to unmarshall readcapacity10 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->block_size = rc10->block_size;\n\n if (rc10->lba == 0) {\n\n /* blank disk loaded */\n\n itask->iscsilun->num_blocks = 0;\n\n } else {\n\n itask->iscsilun->num_blocks = rc10->lba + 1;\n\n }\n\n itask->bs->total_sectors = itask->iscsilun->num_blocks *\n\n itask->iscsilun->block_size / BDRV_SECTOR_SIZE ;\n\n\n\n itask->status = 0;\n\n itask->complete = 1;\n\n scsi_free_scsi_task(task);\n\n}\n", + "output": "1", + "index": 8897 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dnxhd_decode_dct_block_10_444(const DNXHDContext *ctx,\n\n RowContext *row, int n)\n\n{\n\n dnxhd_decode_dct_block(ctx, row, n, 6, 32, 6);\n\n}\n", + "output": "1", + "index": 20047 + }, + { + "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 = bdrv_get_error_action(req->dev->bs, 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(bdrv_get_stats(s->bs), &req->acct);\n\n virtio_blk_free_request(req);\n\n }\n\n\n\n bdrv_error_action(s->bs, action, is_read, error);\n\n return action != BLOCK_ERROR_ACTION_IGNORE;\n\n}\n", + "output": "0", + "index": 12477 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_identify(void)\n\n{\n\n AHCIQState *ahci;\n\n\n\n ahci = ahci_boot_and_enable();\n\n ahci_test_identify(ahci);\n\n ahci_shutdown(ahci);\n\n}\n", + "output": "0", + "index": 23087 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unplug_nic(PCIBus *b, PCIDevice *d)\n\n{\n\n if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==\n\n PCI_CLASS_NETWORK_ETHERNET) {\n\n qdev_unplug(&(d->qdev), NULL);\n\n }\n\n}\n", + "output": "0", + "index": 7964 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usage(void)\n\n{\n\n printf(\"Escape an input string, adopting the av_get_token() escaping logic\\n\");\n\n printf(\"usage: ffescape [OPTIONS]\\n\");\n\n printf(\"\\n\"\n\n \"Options:\\n\"\n\n \"-e echo each input line on output\\n\"\n\n \"-h print this help\\n\"\n\n \"-i INFILE set INFILE as input file, stdin if omitted\\n\"\n\n \"-l LEVEL set the number of escaping levels, 1 if omitted\\n\"\n\n \"-m ESCAPE_MODE select escape mode between 'full', 'lazy', 'quote', default is 'lazy'\\n\"\n\n \"-o OUTFILE set OUTFILE as output file, stdout if omitted\\n\"\n\n \"-p PROMPT set output prompt, is '=> ' by default\\n\"\n\n \"-s SPECIAL_CHARS set the list of special characters\\n\");\n\n}\n", + "output": "0", + "index": 2391 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static size_t qemu_rdma_fill(RDMAContext *rdma, uint8_t *buf,\n\n int size, int idx)\n\n{\n\n size_t len = 0;\n\n\n\n if (rdma->wr_data[idx].control_len) {\n\n DDDPRINTF(\"RDMA %\" PRId64 \" of %d bytes already in buffer\\n\",\n\n rdma->wr_data[idx].control_len, size);\n\n\n\n len = MIN(size, rdma->wr_data[idx].control_len);\n\n memcpy(buf, rdma->wr_data[idx].control_curr, len);\n\n rdma->wr_data[idx].control_curr += len;\n\n rdma->wr_data[idx].control_len -= len;\n\n }\n\n\n\n return len;\n\n}\n", + "output": "1", + "index": 4428 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_lpg_tick(void *opaque)\n\n{\n\n struct omap_lpg_s *s = opaque;\n\n\n\n if (s->cycle)\n\n timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->period - s->on);\n\n else\n\n timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->on);\n\n\n\n s->cycle = !s->cycle;\n\n printf(\"%s: LED is %s\\n\", __FUNCTION__, s->cycle ? \"on\" : \"off\");\n\n}\n", + "output": "0", + "index": 25209 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n __asm__ volatile(\n\n \"movq \"MANGLE(bm01010101)\", %%mm4 \\n\\t\"\n\n \"mov %0, %%\"REG_a\" \\n\\t\"\n\n \"1: \\n\\t\"\n\n \"movq (%1, %%\"REG_a\",4), %%mm0 \\n\\t\"\n\n \"movq 8(%1, %%\"REG_a\",4), %%mm1 \\n\\t\"\n\n \"pand %%mm4, %%mm0 \\n\\t\"\n\n \"pand %%mm4, %%mm1 \\n\\t\"\n\n \"packuswb %%mm1, %%mm0 \\n\\t\"\n\n \"movq %%mm0, %%mm1 \\n\\t\"\n\n \"psrlw $8, %%mm0 \\n\\t\"\n\n \"pand %%mm4, %%mm1 \\n\\t\"\n\n \"packuswb %%mm0, %%mm0 \\n\\t\"\n\n \"packuswb %%mm1, %%mm1 \\n\\t\"\n\n \"movd %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\n \"movd %%mm1, (%2, %%\"REG_a\") \\n\\t\"\n\n \"add $4, %%\"REG_a\" \\n\\t\"\n\n \" js 1b \\n\\t\"\n\n : : \"g\" ((x86_reg)-width), \"r\" (src1+width*4), \"r\" (dstU+width), \"r\" (dstV+width)\n\n : \"%\"REG_a\n\n );\n\n#else\n\n int i;\n\n for (i=0; istate;\n\n uint8_t *pci_conf;\n\n\n\n#if 0\n\n printf(\"sizeof(RMD)=%d, sizeof(TMD)=%d\\n\",\n\n sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));\n\n#endif\n\n\n\n pci_conf = pci_dev->config;\n\n\n\n pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD);\n\n pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE);\n\n pci_set_word(pci_conf + PCI_STATUS,\n\n PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM);\n\n pci_conf[PCI_REVISION_ID] = 0x10;\n\n pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);\n\n\n\n pci_set_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID, 0x0);\n\n pci_set_word(pci_conf + PCI_SUBSYSTEM_ID, 0x0);\n\n\n\n pci_conf[PCI_INTERRUPT_PIN] = 1; // interrupt pin 0\n\n pci_conf[PCI_MIN_GNT] = 0x06;\n\n pci_conf[PCI_MAX_LAT] = 0xff;\n\n\n\n /* Handler for memory-mapped I/O */\n\n s->mmio_index =\n\n cpu_register_io_memory(pcnet_mmio_read, pcnet_mmio_write, &d->state,\n\n DEVICE_NATIVE_ENDIAN);\n\n\n\n pci_register_bar(pci_dev, 0, PCNET_IOPORT_SIZE,\n\n PCI_BASE_ADDRESS_SPACE_IO, pcnet_ioport_map);\n\n\n\n pci_register_bar_simple(pci_dev, 1, PCNET_PNPMMIO_SIZE, 0, s->mmio_index);\n\n\n\n s->irq = pci_dev->irq[0];\n\n s->phys_mem_read = pci_physical_memory_read;\n\n s->phys_mem_write = pci_physical_memory_write;\n\n\n\n if (!pci_dev->qdev.hotplugged) {\n\n static int loaded = 0;\n\n if (!loaded) {\n\n rom_add_option(\"pxe-pcnet.rom\", -1);\n\n loaded = 1;\n\n }\n\n }\n\n\n\n return pcnet_common_init(&pci_dev->qdev, s, &net_pci_pcnet_info);\n\n}\n", + "output": "0", + "index": 16400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tcp_wait_fd(int fd, int write)\n\n{\n\n int ev = write ? POLLOUT : POLLIN;\n\n struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };\n\n int ret;\n\n\n\n ret = poll(&p, 1, 100);\n\n return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);\n\n}\n", + "output": "0", + "index": 23732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_conditional_jump(DisasContext * ctx,\n\n\t\t\t\t target_ulong ift, target_ulong ifnott)\n\n{\n\n int l1;\n\n TCGv sr;\n\n\n\n l1 = gen_new_label();\n\n sr = tcg_temp_new();\n\n tcg_gen_andi_i32(sr, cpu_sr, SR_T);\n\n tcg_gen_brcondi_i32(TCG_COND_NE, sr, 0, l1);\n\n gen_goto_tb(ctx, 0, ifnott);\n\n gen_set_label(l1);\n\n gen_goto_tb(ctx, 1, ift);\n\n}\n", + "output": "0", + "index": 23409 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void float64_maddsub_update_excp(CPUPPCState *env, float64 arg1,\n\n float64 arg2, float64 arg3,\n\n unsigned int madd_flags)\n\n{\n\n if (unlikely((float64_is_infinity(arg1) && float64_is_zero(arg2)) ||\n\n (float64_is_zero(arg1) && float64_is_infinity(arg2)))) {\n\n /* Multiplication of zero by infinity */\n\n arg1 = float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1);\n\n } else if (unlikely(float64_is_signaling_nan(arg1, &env->fp_status) ||\n\n float64_is_signaling_nan(arg2, &env->fp_status) ||\n\n float64_is_signaling_nan(arg3, &env->fp_status))) {\n\n /* sNaN operation */\n\n float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);\n\n } else if ((float64_is_infinity(arg1) || float64_is_infinity(arg2)) &&\n\n float64_is_infinity(arg3)) {\n\n uint8_t aSign, bSign, cSign;\n\n\n\n aSign = float64_is_neg(arg1);\n\n bSign = float64_is_neg(arg2);\n\n cSign = float64_is_neg(arg3);\n\n if (madd_flags & float_muladd_negate_c) {\n\n cSign ^= 1;\n\n }\n\n if (aSign ^ bSign ^ cSign) {\n\n float_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI, 1);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 4916 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n if (!drv) {\n\n return -ENOMEDIUM;\n\n }\n\n if (drv->bdrv_get_allocated_file_size) {\n\n return drv->bdrv_get_allocated_file_size(bs);\n\n }\n\n if (bs->file) {\n\n return bdrv_get_allocated_file_size(bs->file);\n\n }\n\n return -ENOTSUP;\n\n}\n", + "output": "0", + "index": 14582 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_clock_unregister_reset_notifier(QEMUClockType type,\n\n Notifier *notifier)\n\n{\n\n notifier_remove(notifier);\n\n}\n", + "output": "0", + "index": 26889 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,\n\n void *value, size_t vsize)\n\n{\n\n ssize_t size = 0;\n\n char buffer[PATH_MAX];\n\n void *ovalue = value;\n\n XattrOperations *xops;\n\n char *orig_value, *orig_value_start;\n\n ssize_t xattr_len, parsed_len = 0, attr_len;\n\n\n\n /* Get the actual len */\n\n xattr_len = llistxattr(rpath(ctx, path, buffer), value, 0);\n\n if (xattr_len <= 0) {\n\n return xattr_len;\n\n }\n\n\n\n /* Now fetch the xattr and find the actual size */\n\n orig_value = g_malloc(xattr_len);\n\n xattr_len = llistxattr(rpath(ctx, path, buffer), orig_value, xattr_len);\n\n\n\n /* store the orig pointer */\n\n orig_value_start = orig_value;\n\n while (xattr_len > parsed_len) {\n\n xops = get_xattr_operations(ctx->xops, orig_value);\n\n if (!xops) {\n\n goto next_entry;\n\n }\n\n\n\n if (!value) {\n\n size += xops->listxattr(ctx, path, orig_value, value, vsize);\n\n } else {\n\n size = xops->listxattr(ctx, path, orig_value, value, vsize);\n\n if (size < 0) {\n\n goto err_out;\n\n }\n\n value += size;\n\n vsize -= size;\n\n }\n\nnext_entry:\n\n /* Got the next entry */\n\n attr_len = strlen(orig_value) + 1;\n\n parsed_len += attr_len;\n\n orig_value += attr_len;\n\n }\n\n if (value) {\n\n size = value - ovalue;\n\n }\n\n\n\nerr_out:\n\n g_free(orig_value_start);\n\n return size;\n\n}\n", + "output": "0", + "index": 7457 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void float_to_int16_3dnow(int16_t *dst, const float *src, int len){\n\n // not bit-exact: pf2id uses different rounding than C and SSE\n\n int i;\n\n for(i=0; iintra4x4_pred_mode);\n\n av_freep(&h->chroma_pred_mode_table);\n\n av_freep(&h->cbp_table);\n\n av_freep(&h->mvd_table[0]);\n\n av_freep(&h->mvd_table[1]);\n\n av_freep(&h->direct_table);\n\n av_freep(&h->non_zero_count);\n\n av_freep(&h->slice_table_base);\n\n h->slice_table= NULL;\n\n av_freep(&h->list_counts);\n\n\n\n av_freep(&h->mb2b_xy);\n\n av_freep(&h->mb2br_xy);\n\n\n\n for(i = 0; i < MAX_THREADS; i++) {\n\n hx = h->thread_context[i];\n\n if(!hx) continue;\n\n av_freep(&hx->top_borders[1]);\n\n av_freep(&hx->top_borders[0]);\n\n av_freep(&hx->s.obmc_scratchpad);\n\n av_freep(&hx->rbsp_buffer[1]);\n\n av_freep(&hx->rbsp_buffer[0]);\n\n hx->rbsp_buffer_size[0] = 0;\n\n hx->rbsp_buffer_size[1] = 0;\n\n if (i) av_freep(&h->thread_context[i]);\n\n }\n\n}\n", + "output": "1", + "index": 21747 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_handle_export_name(NBDClient *client, uint32_t length)\n\n{\n\n int rc = -EINVAL, csock = client->sock;\n\n char name[256];\n\n\n\n /* Client sends:\n\n [20 .. xx] export name (length bytes)\n\n */\n\n TRACE(\"Checking length\");\n\n if (length > 255) {\n\n LOG(\"Bad length received\");\n\n goto fail;\n\n }\n\n if (read_sync(csock, name, length) != length) {\n\n LOG(\"read failed\");\n\n goto fail;\n\n }\n\n name[length] = '\\0';\n\n\n\n client->exp = nbd_export_find(name);\n\n if (!client->exp) {\n\n LOG(\"export not found\");\n\n goto fail;\n\n }\n\n\n\n QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);\n\n nbd_export_get(client->exp);\n\n rc = 0;\n\nfail:\n\n return rc;\n\n}\n", + "output": "0", + "index": 26119 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)\n\n{\n\n int ret;\n\n\n\n ret = ff_framesync_dualinput_get(fs, f0, f1);\n\n if (ret < 0)\n\n return ret;\n\n ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);\n\n if (ret < 0) {\n\n av_frame_free(f0);\n\n av_frame_free(f1);\n\n return ret;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 9920 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int MP3lame_encode_init(AVCodecContext *avctx)\n\n{\n\n Mp3AudioContext *s = avctx->priv_data;\n\n\n\n if (avctx->channels > 2)\n\n return -1;\n\n\n\n s->stereo = avctx->channels > 1 ? 1 : 0;\n\n\n\n if ((s->gfp = lame_init()) == NULL)\n\n goto err;\n\n lame_set_in_samplerate(s->gfp, avctx->sample_rate);\n\n lame_set_out_samplerate(s->gfp, avctx->sample_rate);\n\n lame_set_num_channels(s->gfp, avctx->channels);\n\n if(avctx->compression_level == FF_COMPRESSION_DEFAULT) {\n\n lame_set_quality(s->gfp, 5);\n\n } else {\n\n lame_set_quality(s->gfp, avctx->compression_level);\n\n }\n\n lame_set_mode(s->gfp, s->stereo ? JOINT_STEREO : MONO);\n\n lame_set_brate(s->gfp, avctx->bit_rate/1000);\n\n if(avctx->flags & CODEC_FLAG_QSCALE) {\n\n lame_set_brate(s->gfp, 0);\n\n lame_set_VBR(s->gfp, vbr_default);\n\n lame_set_VBR_quality(s->gfp, avctx->global_quality/(float)FF_QP2LAMBDA);\n\n }\n\n lame_set_bWriteVbrTag(s->gfp,0);\n\n lame_set_disable_reservoir(s->gfp, avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR ? 0 : 1);\n\n if (lame_init_params(s->gfp) < 0)\n\n goto err_close;\n\n\n\n avctx->frame_size = lame_get_framesize(s->gfp);\n\n\n\n avctx->coded_frame= avcodec_alloc_frame();\n\n avctx->coded_frame->key_frame= 1;\n\n\n\n return 0;\n\n\n\nerr_close:\n\n lame_close(s->gfp);\n\nerr:\n\n return -1;\n\n}\n", + "output": "1", + "index": 18756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_ppc_store_decr (CPUState *env, uint32_t value)\n\n{\n\n /* TO FIX */\n\n}\n", + "output": "0", + "index": 11122 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int smbios_entry_add(const char *t)\n\n{\n\n char buf[1024];\n\n\n\n if (get_param_value(buf, sizeof(buf), \"file\", t)) {\n\n struct smbios_structure_header *header;\n\n struct smbios_table *table;\n\n int size = get_image_size(buf);\n\n\n\n if (size < sizeof(struct smbios_structure_header)) {\n\n fprintf(stderr, \"Cannot read smbios file %s\", buf);\n\n exit(1);\n\n }\n\n\n\n if (!smbios_entries) {\n\n smbios_entries_len = sizeof(uint16_t);\n\n smbios_entries = qemu_mallocz(smbios_entries_len);\n\n }\n\n\n\n smbios_entries = qemu_realloc(smbios_entries, smbios_entries_len +\n\n sizeof(*table) + size);\n\n table = (struct smbios_table *)(smbios_entries + smbios_entries_len);\n\n table->header.type = SMBIOS_TABLE_ENTRY;\n\n table->header.length = cpu_to_le16(sizeof(*table) + size);\n\n\n\n if (load_image(buf, table->data) != size) {\n\n fprintf(stderr, \"Failed to load smbios file %s\", buf);\n\n exit(1);\n\n }\n\n\n\n header = (struct smbios_structure_header *)(table->data);\n\n smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY);\n\n\n\n smbios_entries_len += sizeof(*table) + size;\n\n (*(uint16_t *)smbios_entries) =\n\n cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);\n\n return 0;\n\n }\n\n\n\n if (get_param_value(buf, sizeof(buf), \"type\", t)) {\n\n unsigned long type = strtoul(buf, NULL, 0);\n\n switch (type) {\n\n case 0:\n\n smbios_build_type_0_fields(t);\n\n return 0;\n\n case 1:\n\n smbios_build_type_1_fields(t);\n\n return 0;\n\n default:\n\n fprintf(stderr, \"Don't know how to build fields for SMBIOS type \"\n\n \"%ld\\n\", type);\n\n exit(1);\n\n }\n\n }\n\n\n\n fprintf(stderr, \"smbios: must specify type= or file=\\n\");\n\n return -1;\n\n}\n", + "output": "0", + "index": 2883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xen_init_pv(MachineState *machine)\n\n{\n\n DriveInfo *dinfo;\n\n int i;\n\n\n\n /* Initialize backend core & drivers */\n\n if (xen_be_init() != 0) {\n\n fprintf(stderr, \"%s: xen backend core setup failed\\n\", __FUNCTION__);\n\n exit(1);\n\n }\n\n\n\n switch (xen_mode) {\n\n case XEN_ATTACH:\n\n /* nothing to do, xend handles everything */\n\n break;\n\n#ifdef CONFIG_XEN_PV_DOMAIN_BUILD\n\n case XEN_CREATE: {\n\n const char *kernel_filename = machine->kernel_filename;\n\n const char *kernel_cmdline = machine->kernel_cmdline;\n\n const char *initrd_filename = machine->initrd_filename;\n\n if (xen_domain_build_pv(kernel_filename, initrd_filename,\n\n kernel_cmdline) < 0) {\n\n fprintf(stderr, \"xen pv domain creation failed\\n\");\n\n exit(1);\n\n }\n\n break;\n\n }\n\n#endif\n\n case XEN_EMULATE:\n\n fprintf(stderr, \"xen emulation not implemented (yet)\\n\");\n\n exit(1);\n\n break;\n\n default:\n\n fprintf(stderr, \"unhandled xen_mode %d\\n\", xen_mode);\n\n exit(1);\n\n break;\n\n }\n\n\n\n xen_be_register_common();\n\n xen_be_register(\"vfb\", &xen_framebuffer_ops);\n\n xen_be_register(\"qnic\", &xen_netdev_ops);\n\n\n\n /* configure framebuffer */\n\n if (xenfb_enabled) {\n\n xen_config_dev_vfb(0, \"vnc\");\n\n xen_config_dev_vkbd(0);\n\n }\n\n\n\n /* configure disks */\n\n for (i = 0; i < 16; i++) {\n\n dinfo = drive_get(IF_XEN, 0, i);\n\n if (!dinfo)\n\n continue;\n\n xen_config_dev_blk(dinfo);\n\n }\n\n\n\n /* configure nics */\n\n for (i = 0; i < nb_nics; i++) {\n\n if (!nd_table[i].model || 0 != strcmp(nd_table[i].model, \"xen\"))\n\n continue;\n\n xen_config_dev_nic(nd_table + i);\n\n }\n\n\n\n /* config cleanup hook */\n\n atexit(xen_config_cleanup);\n\n\n\n /* setup framebuffer */\n\n xen_init_display(xen_domid);\n\n}\n", + "output": "0", + "index": 16876 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_opencl_buffer_write_image(cl_mem dst_cl_buf, size_t cl_buffer_size, int dst_cl_offset,\n\n uint8_t **src_data, int *plane_size, int plane_num)\n\n{\n\n int i, buffer_size = 0;\n\n uint8_t *temp;\n\n cl_int status;\n\n void *mapped;\n\n if ((unsigned int)plane_num > 8) {\n\n return AVERROR(EINVAL);\n\n }\n\n for (i = 0;i < plane_num;i++) {\n\n buffer_size += plane_size[i];\n\n }\n\n if (buffer_size > cl_buffer_size) {\n\n av_log(&openclutils, AV_LOG_ERROR, \"Cannot write image to OpenCL buffer: buffer too small\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n mapped = clEnqueueMapBuffer(gpu_env.command_queue, dst_cl_buf,\n\n CL_TRUE,CL_MAP_WRITE, 0, buffer_size + dst_cl_offset,\n\n 0, NULL, NULL, &status);\n\n if (status != CL_SUCCESS) {\n\n av_log(&openclutils, AV_LOG_ERROR, \"Could not map OpenCL buffer: %s\\n\", opencl_errstr(status));\n\n return AVERROR_EXTERNAL;\n\n }\n\n temp = mapped;\n\n temp += dst_cl_offset;\n\n for (i = 0; i < plane_num; i++) {\n\n memcpy(temp, src_data[i], plane_size[i]);\n\n temp += plane_size[i];\n\n }\n\n status = clEnqueueUnmapMemObject(gpu_env.command_queue, dst_cl_buf, mapped, 0, NULL, NULL);\n\n if (status != CL_SUCCESS) {\n\n av_log(&openclutils, AV_LOG_ERROR, \"Could not unmap OpenCL buffer: %s\\n\", opencl_errstr(status));\n\n return AVERROR_EXTERNAL;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 14622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtsp_cmd_describe(HTTPContext *c, const char *url)\n\n{\n\n FFStream *stream;\n\n char path1[1024];\n\n const char *path;\n\n uint8_t *content;\n\n int content_length, len;\n\n struct sockaddr_in my_addr;\n\n\n\n /* find which url is asked */\n\n url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);\n\n path = path1;\n\n if (*path == '/')\n\n path++;\n\n\n\n for(stream = first_stream; stream != NULL; stream = stream->next) {\n\n if (!stream->is_feed && !strcmp(stream->fmt->name, \"rtp\") &&\n\n !strcmp(path, stream->filename)) {\n\n goto found;\n\n }\n\n }\n\n /* no stream found */\n\n rtsp_reply_error(c, RTSP_STATUS_SERVICE); /* XXX: right error ? */\n\n return;\n\n\n\n found:\n\n /* prepare the media description in sdp format */\n\n\n\n /* get the host IP */\n\n len = sizeof(my_addr);\n\n getsockname(c->fd, (struct sockaddr *)&my_addr, &len);\n\n content_length = prepare_sdp_description(stream, &content, my_addr.sin_addr);\n\n if (content_length < 0) {\n\n rtsp_reply_error(c, RTSP_STATUS_INTERNAL);\n\n return;\n\n }\n\n rtsp_reply_header(c, RTSP_STATUS_OK);\n\n url_fprintf(c->pb, \"Content-Type: application/sdp\\r\\n\");\n\n url_fprintf(c->pb, \"Content-Length: %d\\r\\n\", content_length);\n\n url_fprintf(c->pb, \"\\r\\n\");\n\n put_buffer(c->pb, content, content_length);\n\n}\n", + "output": "1", + "index": 8333 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int div_round (int dividend, int divisor)\n\n{\n\n if (dividend > 0)\n\n\treturn (dividend + (divisor>>1)) / divisor;\n\n else\n\n\treturn -((-dividend + (divisor>>1)) / divisor);\n\n}\n", + "output": "1", + "index": 8769 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *bdrv_get_encrypted_filename(BlockDriverState *bs)\n\n{\n\n if (bs->backing_hd && bs->backing_hd->encrypted)\n\n return bs->backing_file;\n\n else if (bs->encrypted)\n\n return bs->filename;\n\n else\n\n return NULL;\n\n}\n", + "output": "0", + "index": 11908 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void mv_pred_direct(AVSContext *h, cavs_vector *pmv_fw,\n\n cavs_vector *col_mv)\n\n{\n\n cavs_vector *pmv_bw = pmv_fw + MV_BWD_OFFS;\n\n int den = h->direct_den[col_mv->ref];\n\n int m = FF_SIGNBIT(col_mv->x);\n\n\n\n pmv_fw->dist = h->dist[1];\n\n pmv_bw->dist = h->dist[0];\n\n pmv_fw->ref = 1;\n\n pmv_bw->ref = 0;\n\n /* scale the co-located motion vector according to its temporal span */\n\n pmv_fw->x = (((den + (den * col_mv->x * pmv_fw->dist ^ m) - m - 1) >> 14) ^ m) - m;\n\n pmv_bw->x = m - (((den + (den * col_mv->x * pmv_bw->dist ^ m) - m - 1) >> 14) ^ m);\n\n m = FF_SIGNBIT(col_mv->y);\n\n pmv_fw->y = (((den + (den * col_mv->y * pmv_fw->dist ^ m) - m - 1) >> 14) ^ m) - m;\n\n pmv_bw->y = m - (((den + (den * col_mv->y * pmv_bw->dist ^ m) - m - 1) >> 14) ^ m);\n\n}\n", + "output": "1", + "index": 9528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_drain_recurse(BlockDriverState *bs)\n\n{\n\n BdrvChild *child;\n\n\n\n if (bs->drv && bs->drv->bdrv_drain) {\n\n bs->drv->bdrv_drain(bs);\n\n }\n\n QLIST_FOREACH(child, &bs->children, next) {\n\n bdrv_drain_recurse(child->bs);\n\n }\n\n}\n", + "output": "0", + "index": 21313 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_uint64_equal(QEMUFile *f, void *pv, size_t size)\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\n return -EINVAL;\n\n}\n", + "output": "1", + "index": 10803 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PPC_OP(cmpi)\n\n{\n\n if (Ts0 < SPARAM(1)) {\n\n T0 = 0x08;\n\n } else if (Ts0 > SPARAM(1)) {\n\n T0 = 0x04;\n\n } else {\n\n T0 = 0x02;\n\n }\n\n RETURN();\n\n}\n", + "output": "1", + "index": 2781 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,\n\n void *callback_opaque, uint8_t *data, size_t len)\n\n{\n\n int arch = !!(key & FW_CFG_ARCH_LOCAL);\n\n\n\n if (!(key & FW_CFG_WRITE_CHANNEL))\n\n return 0;\n\n\n\n key &= FW_CFG_ENTRY_MASK;\n\n\n\n if (key >= FW_CFG_MAX_ENTRY || len > 65535)\n\n return 0;\n\n\n\n s->entries[arch][key].data = data;\n\n s->entries[arch][key].len = len;\n\n s->entries[arch][key].callback_opaque = callback_opaque;\n\n s->entries[arch][key].callback = callback;\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 19621 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)\n\n{\n\n int ret;\n\n\n\n dst->owner = src->owner;\n\n\n\n ret = av_frame_ref(dst->f, src->f);\n\n if (ret < 0)\n\n return ret;\n\n\n\n av_assert0(!dst->progress);\n\n\n\n if (src->progress &&\n\n !(dst->progress = av_buffer_ref(src->progress))) {\n\n ff_thread_release_buffer(dst->owner, dst);\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 21797 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void wdt_ib700_realize(DeviceState *dev, Error **errp)\n\n{\n\n IB700State *s = IB700(dev);\n\n PortioList *port_list = g_new(PortioList, 1);\n\n\n\n ib700_debug(\"watchdog init\\n\");\n\n\n\n s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ib700_timer_expired, s);\n\n\n\n portio_list_init(port_list, OBJECT(s), wdt_portio_list, s, \"ib700\");\n\n portio_list_add(port_list, isa_address_space_io(&s->parent_obj), 0);\n\n}\n", + "output": "1", + "index": 17287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp)\n\n{\n\n OptsVisitor *ov = to_ov(v);\n\n const QemuOpt *opt;\n\n int64_t val;\n\n\n\n opt = lookup_scalar(ov, name, errp);\n\n if (!opt) {\n\n return;\n\n }\n\n\n\n val = qemu_strtosz(opt->str ? opt->str : \"\", NULL);\n\n if (val < 0) {\n\n error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,\n\n \"a size value representible as a non-negative int64\");\n\n return;\n\n }\n\n\n\n *obj = val;\n\n processed(ov, name);\n\n}\n", + "output": "0", + "index": 293 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int onenand_load_spare(OneNANDState *s, int sec, int secn,\n\n void *dest)\n\n{\n\n uint8_t buf[512];\n\n\n\n if (s->bdrv_cur) {\n\n if (bdrv_read(s->bdrv_cur, s->secs_cur + (sec >> 5), buf, 1) < 0)\n\n return 1;\n\n memcpy(dest, buf + ((sec & 31) << 4), secn << 4);\n\n } else if (sec + secn > s->secs_cur)\n\n return 1;\n\n else\n\n memcpy(dest, s->current + (s->secs_cur << 9) + (sec << 4), secn << 4);\n\n \n\n return 0;\n\n}\n", + "output": "0", + "index": 19479 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "GACommandState *ga_command_state_new(void)\n\n{\n\n GACommandState *cs = g_malloc0(sizeof(GACommandState));\n\n cs->groups = NULL;\n\n return cs;\n\n}\n", + "output": "1", + "index": 19786 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_bar_quirk_teardown(VFIODevice *vdev, int nr)\n\n{\n\n VFIOBAR *bar = &vdev->bars[nr];\n\n\n\n while (!QLIST_EMPTY(&bar->quirks)) {\n\n VFIOQuirk *quirk = QLIST_FIRST(&bar->quirks);\n\n memory_region_del_subregion(&bar->mem, &quirk->mem);\n\n\n QLIST_REMOVE(quirk, next);\n\n g_free(quirk);\n\n }\n\n}", + "output": "1", + "index": 23812 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_write_compressed(BlockBackend *blk, char *buf, int64_t offset,\n\n int64_t count, int64_t *total)\n\n{\n\n int ret;\n\n\n\n if (count >> 9 > INT_MAX) {\n\n return -ERANGE;\n\n }\n\n\n\n ret = blk_write_compressed(blk, offset >> 9, (uint8_t *)buf, count >> 9);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n *total = count;\n\n return 1;\n\n}\n", + "output": "0", + "index": 16016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_fd_register(int fd)\n\n{\n\n WSAEventSelect(fd, qemu_event_handle, FD_READ | FD_ACCEPT | FD_CLOSE |\n\n FD_CONNECT | FD_WRITE | FD_OOB);\n\n}\n", + "output": "0", + "index": 25975 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ffm_write_write_index(int fd, int64_t pos)\n\n{\n\n uint8_t buf[8];\n\n int i;\n\n\n\n for(i=0;i<8;i++)\n\n buf[i] = (pos >> (56 - i * 8)) & 0xff;\n\n lseek(fd, 8, SEEK_SET);\n\n if (write(fd, buf, 8) != 8)\n\n return AVERROR(EIO);\n\n return 8;\n\n}\n", + "output": "0", + "index": 20754 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int use_gdb_syscalls(void)\n\n{\n\n if (gdb_syscall_mode == GDB_SYS_UNKNOWN) {\n\n gdb_syscall_mode = (gdb_syscall_state ? GDB_SYS_ENABLED\n\n : GDB_SYS_DISABLED);\n\n }\n\n return gdb_syscall_mode == GDB_SYS_ENABLED;\n\n}\n", + "output": "0", + "index": 6301 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)\n\n{\n\n DisasContext *dc = container_of(dcbase, DisasContext, base);\n\n\n\n dc->insn_start_idx = tcg_op_buf_count();\n\n tcg_gen_insn_start(dc->pc, 0, 0);\n\n}\n", + "output": "1", + "index": 15158 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void q35_host_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);\n\n\n\n hc->root_bus_path = q35_host_root_bus_path;\n\n dc->realize = q35_host_realize;\n\n dc->props = mch_props;\n\n /* Reason: needs to be wired up by pc_q35_init */\n\n dc->user_creatable = false;\n\n set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);\n\n dc->fw_name = \"pci\";\n\n}\n", + "output": "1", + "index": 6346 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int debugcon_parse(const char *devname)\n\n{\n\n QemuOpts *opts;\n\n\n\n if (!qemu_chr_new(\"debugcon\", devname, NULL)) {\n\n exit(1);\n\n }\n\n opts = qemu_opts_create(qemu_find_opts(\"device\"), \"debugcon\", 1, NULL);\n\n if (!opts) {\n\n fprintf(stderr, \"qemu: already have a debugcon device\\n\");\n\n exit(1);\n\n }\n\n qemu_opt_set(opts, \"driver\", \"isa-debugcon\", &error_abort);\n\n qemu_opt_set(opts, \"chardev\", \"debugcon\", &error_abort);\n\n return 0;\n\n}\n", + "output": "0", + "index": 1112 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hb_synthesis(AMRWBContext *ctx, int subframe, float *samples,\n\n const float *exc, const float *isf, const float *isf_past)\n\n{\n\n float hb_lpc[LP_ORDER_16k];\n\n enum Mode mode = ctx->fr_cur_mode;\n\n\n\n if (mode == MODE_6k60) {\n\n float e_isf[LP_ORDER_16k]; // ISF vector for extrapolation\n\n double e_isp[LP_ORDER_16k];\n\n\n\n ff_weighted_vector_sumf(e_isf, isf_past, isf, isfp_inter[subframe],\n\n 1.0 - isfp_inter[subframe], LP_ORDER);\n\n\n\n extrapolate_isf(e_isf, e_isf);\n\n\n\n e_isf[LP_ORDER_16k - 1] *= 2.0;\n\n ff_acelp_lsf2lspd(e_isp, e_isf, LP_ORDER_16k);\n\n ff_amrwb_lsp2lpc(e_isp, hb_lpc, LP_ORDER_16k);\n\n\n\n lpc_weighting(hb_lpc, hb_lpc, 0.9, LP_ORDER_16k);\n\n } else {\n\n lpc_weighting(hb_lpc, ctx->lp_coef[subframe], 0.6, LP_ORDER);\n\n }\n\n\n\n ff_celp_lp_synthesis_filterf(samples, hb_lpc, exc, AMRWB_SFR_SIZE_16k,\n\n (mode == MODE_6k60) ? LP_ORDER_16k : LP_ORDER);\n\n}\n", + "output": "0", + "index": 6409 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_iovec_concat_iov(QEMUIOVector *dst,\n struct iovec *src_iov, unsigned int src_cnt,\n size_t soffset, size_t sbytes)\n{\n int i;\n size_t done;\n assert(dst->nalloc != -1);\n for (i = 0, done = 0; done < sbytes && i < src_cnt; i++) {\n if (soffset < src_iov[i].iov_len) {\n size_t len = MIN(src_iov[i].iov_len - soffset, sbytes - done);\n qemu_iovec_add(dst, src_iov[i].iov_base + soffset, len);\n done += len;\n soffset = 0;\n } else {\n soffset -= src_iov[i].iov_len;\n assert(soffset == 0); /* offset beyond end of src */", + "output": "1", + "index": 18440 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_sraq(DisasContext *ctx)\n\n{\n\n int l1 = gen_new_label();\n\n int l2 = gen_new_label();\n\n TCGv t0 = tcg_temp_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_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);\n\n tcg_gen_sar_tl(t1, cpu_gpr[rS(ctx->opcode)], t2);\n\n tcg_gen_subfi_tl(t2, 32, t2);\n\n tcg_gen_shl_tl(t2, cpu_gpr[rS(ctx->opcode)], t2);\n\n tcg_gen_or_tl(t0, t0, t2);\n\n gen_store_spr(SPR_MQ, t0);\n\n tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l1);\n\n tcg_gen_mov_tl(t2, cpu_gpr[rS(ctx->opcode)]);\n\n tcg_gen_sari_tl(t1, cpu_gpr[rS(ctx->opcode)], 31);\n\n gen_set_label(l1);\n\n tcg_temp_free(t0);\n\n tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t1);\n\n tcg_gen_movi_tl(cpu_ca, 0);\n\n tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);\n\n tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l2);\n\n tcg_gen_movi_tl(cpu_ca, 1);\n\n gen_set_label(l2);\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": 315 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int ape_decode_close(AVCodecContext * avctx)\n\n{\n\n APEContext *s = avctx->priv_data;\n\n int i;\n\n\n\n for (i = 0; i < APE_FILTER_LEVELS; i++)\n\n av_freep(&s->filterbuf[i]);\n\n\n\n av_freep(&s->data);\n\n return 0;\n\n}\n", + "output": "1", + "index": 12953 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SPARCCPU *sparc64_cpu_devinit(const char *cpu_model,\n\n const char *default_cpu_model, uint64_t prom_addr)\n\n{\n\n SPARCCPU *cpu;\n\n CPUSPARCState *env;\n\n ResetData *reset_info;\n\n\n\n uint32_t tick_frequency = 100 * 1000000;\n\n uint32_t stick_frequency = 100 * 1000000;\n\n uint32_t hstick_frequency = 100 * 1000000;\n\n\n\n if (cpu_model == NULL) {\n\n cpu_model = default_cpu_model;\n\n }\n\n cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));\n\n if (cpu == NULL) {\n\n fprintf(stderr, \"Unable to find Sparc CPU definition\\n\");\n\n exit(1);\n\n }\n\n env = &cpu->env;\n\n\n\n env->tick = cpu_timer_create(\"tick\", cpu, tick_irq,\n\n tick_frequency, TICK_INT_DIS,\n\n TICK_NPT_MASK);\n\n\n\n env->stick = cpu_timer_create(\"stick\", cpu, stick_irq,\n\n stick_frequency, TICK_INT_DIS,\n\n TICK_NPT_MASK);\n\n\n\n env->hstick = cpu_timer_create(\"hstick\", cpu, hstick_irq,\n\n hstick_frequency, TICK_INT_DIS,\n\n TICK_NPT_MASK);\n\n\n\n reset_info = g_malloc0(sizeof(ResetData));\n\n reset_info->cpu = cpu;\n\n reset_info->prom_addr = prom_addr;\n\n qemu_register_reset(main_cpu_reset, reset_info);\n\n\n\n return cpu;\n\n}\n", + "output": "1", + "index": 19045 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int dec_addi_acr(DisasContext *dc)\n\n{\n\n\tTCGv t0;\n\n\tDIS(fprintf (logfile, \"addi.%c $r%u, $r%u, $acr\\n\",\n\n\t\t memsize_char(memsize_zz(dc)), dc->op2, dc->op1));\n\n\tcris_cc_mask(dc, 0);\n\n\tt0 = tcg_temp_new(TCG_TYPE_TL);\n\n\ttcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize));\n\n\ttcg_gen_add_tl(cpu_R[R_ACR], cpu_R[dc->op1], t0);\n\n\n\n\treturn 2;\n\n}\n", + "output": "1", + "index": 5499 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void t_gen_cris_dstep(TCGv d, TCGv a, TCGv b)\n\n{\n\n int l1;\n\n\n\n l1 = gen_new_label();\n\n\n\n /*\n\n * d <<= 1\n\n * if (d >= s)\n\n * d -= s;\n\n */\n\n tcg_gen_shli_tl(d, a, 1);\n\n tcg_gen_brcond_tl(TCG_COND_LTU, d, b, l1);\n\n tcg_gen_sub_tl(d, d, b);\n\n gen_set_label(l1);\n\n}\n", + "output": "0", + "index": 3299 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,\n\n SocketAddressLegacy *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(SocketAddressLegacy, 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": 12372 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mp_user_removexattr(FsContext *ctx,\n\n const char *path, const char *name)\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 lremovexattr(rpath(ctx, path, buffer), name);\n\n}\n", + "output": "0", + "index": 20396 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int flags)\n\n{\n\n PerThreadContext *p = avctx->thread_opaque;\n\n int err;\n\n\n\n f->owner = avctx;\n\n\n\n ff_init_buffer_info(avctx, f->f);\n\n\n\n if (!(avctx->active_thread_type & FF_THREAD_FRAME))\n\n return ff_get_buffer(avctx, f->f, flags);\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 if (avctx->internal->allocate_progress) {\n\n int *progress;\n\n f->progress = av_buffer_alloc(2 * sizeof(int));\n\n if (!f->progress) {\n\n return AVERROR(ENOMEM);\n\n }\n\n progress = (int*)f->progress->data;\n\n\n\n progress[0] = progress[1] = -1;\n\n }\n\n\n\n pthread_mutex_lock(&p->parent->buffer_mutex);\n\n\n\n if (avctx->thread_safe_callbacks || (\n\n#if FF_API_GET_BUFFER\n\n !avctx->get_buffer &&\n\n#endif\n\n avctx->get_buffer2 == avcodec_default_get_buffer2)) {\n\n err = ff_get_buffer(avctx, f->f, flags);\n\n } else {\n\n pthread_mutex_lock(&p->progress_mutex);\n\n p->requested_frame = f->f;\n\n p->requested_flags = flags;\n\n p->state = STATE_GET_BUFFER;\n\n pthread_cond_broadcast(&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 if (err)\n\n av_buffer_unref(&f->progress);\n\n\n\n pthread_mutex_unlock(&p->parent->buffer_mutex);\n\n\n\n return err;\n\n}\n", + "output": "0", + "index": 11996 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int avs_decode_init(AVCodecContext * avctx)\n\n{\n\n AvsContext *s = avctx->priv_data;\n\n\n\n s->frame = av_frame_alloc();\n\n if (!s->frame)\n\n return AVERROR(ENOMEM);\n\n\n\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n\n ff_set_dimensions(avctx, 318, 198);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 10309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void print_sdp(void)\n\n{\n\n char sdp[16384];\n\n int i;\n\n AVFormatContext **avc = av_malloc(sizeof(*avc) * nb_output_files);\n\n\n\n if (!avc)\n\n exit_program(1);\n\n for (i = 0; i < nb_output_files; i++)\n\n avc[i] = output_files[i]->ctx;\n\n\n\n av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp));\n\n printf(\"SDP:\\n%s\\n\", sdp);\n\n fflush(stdout);\n\n av_freep(&avc);\n\n}\n", + "output": "0", + "index": 14802 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct pxa2xx_pcmcia_s *pxa2xx_pcmcia_init(target_phys_addr_t base)\n\n{\n\n int iomemtype;\n\n struct pxa2xx_pcmcia_s *s;\n\n\n\n s = (struct pxa2xx_pcmcia_s *)\n\n qemu_mallocz(sizeof(struct pxa2xx_pcmcia_s));\n\n\n\n /* Socket I/O Memory Space */\n\n s->io_base = base | 0x00000000;\n\n iomemtype = cpu_register_io_memory(0, pxa2xx_pcmcia_io_readfn,\n\n pxa2xx_pcmcia_io_writefn, s);\n\n cpu_register_physical_memory(s->io_base, 0x03ffffff, iomemtype);\n\n\n\n /* Then next 64 MB is reserved */\n\n\n\n /* Socket Attribute Memory Space */\n\n s->attr_base = base | 0x08000000;\n\n iomemtype = cpu_register_io_memory(0, pxa2xx_pcmcia_attr_readfn,\n\n pxa2xx_pcmcia_attr_writefn, s);\n\n cpu_register_physical_memory(s->attr_base, 0x03ffffff, iomemtype);\n\n\n\n /* Socket Common Memory Space */\n\n s->common_base = base | 0x0c000000;\n\n iomemtype = cpu_register_io_memory(0, pxa2xx_pcmcia_common_readfn,\n\n pxa2xx_pcmcia_common_writefn, s);\n\n cpu_register_physical_memory(s->common_base, 0x03ffffff, iomemtype);\n\n\n\n if (base == 0x30000000)\n\n s->slot.slot_string = \"PXA PC Card Socket 1\";\n\n else\n\n s->slot.slot_string = \"PXA PC Card Socket 0\";\n\n s->slot.irq = qemu_allocate_irqs(pxa2xx_pcmcia_set_irq, s, 1)[0];\n\n pcmcia_socket_register(&s->slot);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 26362 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *rcu_q_updater(void *arg)\n\n{\n\n int j, target_el;\n\n long long n_updates_local = 0;\n\n long long n_removed_local = 0;\n\n struct list_element *el, *prev_el;\n\n\n\n *(struct rcu_reader_data **)arg = &rcu_reader;\n\n atomic_inc(&nthreadsrunning);\n\n while (goflag == GOFLAG_INIT) {\n\n g_usleep(1000);\n\n }\n\n\n\n while (goflag == GOFLAG_RUN) {\n\n target_el = select_random_el(RCU_Q_LEN);\n\n j = 0;\n\n /* FOREACH_RCU could work here but let's use both macros */\n\n QLIST_FOREACH_SAFE_RCU(prev_el, &Q_list_head, entry, el) {\n\n j++;\n\n if (target_el == j) {\n\n QLIST_REMOVE_RCU(prev_el, entry);\n\n /* may be more than one updater in the future */\n\n call_rcu1(&prev_el->rcu, reclaim_list_el);\n\n n_removed_local++;\n\n break;\n\n }\n\n }\n\n if (goflag == GOFLAG_STOP) {\n\n break;\n\n }\n\n target_el = select_random_el(RCU_Q_LEN);\n\n j = 0;\n\n QLIST_FOREACH_RCU(el, &Q_list_head, entry) {\n\n j++;\n\n if (target_el == j) {\n\n prev_el = g_new(struct list_element, 1);\n\n atomic_add(&n_nodes, 1);\n\n prev_el->val = atomic_read(&n_nodes);\n\n QLIST_INSERT_BEFORE_RCU(el, prev_el, entry);\n\n break;\n\n }\n\n }\n\n\n\n n_updates_local += 2;\n\n synchronize_rcu();\n\n }\n\n synchronize_rcu();\n\n atomic_add(&n_updates, n_updates_local);\n\n atomic_add(&n_nodes_removed, n_removed_local);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 1605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void lfe_downsample(DCAEncContext *c, const int32_t *input)\n\n{\n\n /* FIXME: make 128x LFE downsampling possible */\n\n const int lfech = lfe_index[c->channel_config];\n\n int i, j, lfes;\n\n int32_t hist[512];\n\n int32_t accum;\n\n int hist_start = 0;\n\n\n\n for (i = 0; i < 512; i++)\n\n hist[i] = c->history[i][c->channels - 1];\n\n\n\n for (lfes = 0; lfes < DCA_LFE_SAMPLES; lfes++) {\n\n /* Calculate the convolution */\n\n accum = 0;\n\n\n\n for (i = hist_start, j = 0; i < 512; i++, j++)\n\n accum += mul32(hist[i], lfe_fir_64i[j]);\n\n for (i = 0; i < hist_start; i++, j++)\n\n accum += mul32(hist[i], lfe_fir_64i[j]);\n\n\n\n c->downsampled_lfe[lfes] = accum;\n\n\n\n /* Copy in 64 new samples from input */\n\n for (i = 0; i < 64; i++)\n\n hist[i + hist_start] = input[(lfes * 64 + i) * c->channels + lfech];\n\n\n\n hist_start = (hist_start + 64) & 511;\n\n }\n\n}\n", + "output": "0", + "index": 21712 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int page_unprotect(target_ulong address, uintptr_t pc)\n\n{\n\n unsigned int prot;\n\n bool current_tb_invalidated;\n\n PageDesc *p;\n\n target_ulong host_start, host_end, addr;\n\n\n\n /* Technically this isn't safe inside a signal handler. However we\n\n know this only ever happens in a synchronous SEGV handler, so in\n\n practice it seems to be ok. */\n\n mmap_lock();\n\n\n\n p = page_find(address >> TARGET_PAGE_BITS);\n\n if (!p) {\n\n mmap_unlock();\n\n return 0;\n\n }\n\n\n\n /* if the page was really writable, then we change its\n\n protection back to writable */\n\n if ((p->flags & PAGE_WRITE_ORG) && !(p->flags & PAGE_WRITE)) {\n\n host_start = address & qemu_host_page_mask;\n\n host_end = host_start + qemu_host_page_size;\n\n\n\n prot = 0;\n\n current_tb_invalidated = false;\n\n for (addr = host_start ; addr < host_end ; addr += TARGET_PAGE_SIZE) {\n\n p = page_find(addr >> TARGET_PAGE_BITS);\n\n p->flags |= PAGE_WRITE;\n\n prot |= p->flags;\n\n\n\n /* and since the content will be modified, we must invalidate\n\n the corresponding translated code. */\n\n current_tb_invalidated |= tb_invalidate_phys_page(addr, pc);\n\n#ifdef CONFIG_USER_ONLY\n\n if (DEBUG_TB_CHECK_GATE) {\n\n tb_invalidate_check(addr);\n\n }\n\n#endif\n\n }\n\n mprotect((void *)g2h(host_start), qemu_host_page_size,\n\n prot & PAGE_BITS);\n\n\n\n mmap_unlock();\n\n /* If current TB was invalidated return to main loop */\n\n return current_tb_invalidated ? 2 : 1;\n\n }\n\n mmap_unlock();\n\n return 0;\n\n}\n", + "output": "1", + "index": 1384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void dsputil_init_armv4l(void)\n\n{\n\n// ff_idct = j_rev_dct_ARM;\n\n}\n", + "output": "0", + "index": 15122 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_stream_index(AVFormatContext *s)\n\n{\n\n int i;\n\n AVStream *st;\n\n\n\n if (s->nb_streams <= 0)\n\n return -1;\n\n for(i = 0; i < s->nb_streams; i++) {\n\n st = s->streams[i];\n\n if (st->codec.codec_type == CODEC_TYPE_VIDEO) {\n\n return i;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 253 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t pxb_bus_numa_node(PCIBus *bus)\n\n{\n\n PXBDev *pxb = PXB_DEV(bus->parent_dev);\n\n\n\n return pxb->numa_node;\n\n}\n", + "output": "0", + "index": 23449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int blkdebug_debug_resume(BlockDriverState *bs, const char *tag)\n\n{\n\n BDRVBlkdebugState *s = bs->opaque;\n\n BlkdebugSuspendedReq *r;\n\n\n\n QLIST_FOREACH(r, &s->suspended_reqs, next) {\n\n if (!strcmp(r->tag, tag)) {\n\n qemu_coroutine_enter(r->co, NULL);\n\n return 0;\n\n }\n\n }\n\n return -ENOENT;\n\n}\n", + "output": "1", + "index": 25556 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_write(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 (!bs->drv)\n\n return -ENOMEDIUM;\n\n if (bs->read_only)\n\n return -EACCES;\n\n if (bdrv_check_request(bs, sector_num, nb_sectors))\n\n return -EIO;\n\n\n\n return drv->bdrv_write(bs, sector_num, buf, nb_sectors);\n\n}\n", + "output": "1", + "index": 5411 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool pte32_match(target_ulong pte0, target_ulong pte1,\n\n bool secondary, target_ulong ptem)\n\n{\n\n return (pte0 & HPTE32_V_VALID)\n\n && (secondary == !!(pte0 & HPTE32_V_SECONDARY))\n\n && HPTE32_V_COMPARE(pte0, ptem);\n\n}\n", + "output": "0", + "index": 3432 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_lcall_real_T0_T1(int shift, int next_eip)\n\n{\n\n int new_cs, new_eip;\n\n uint32_t esp, esp_mask;\n\n uint8_t *ssp;\n\n\n\n new_cs = T0;\n\n new_eip = T1;\n\n esp = env->regs[R_ESP];\n\n esp_mask = 0xffffffff;\n\n if (!(env->segs[R_SS].flags & DESC_B_MASK))\n\n esp_mask = 0xffff;\n\n ssp = env->segs[R_SS].base;\n\n if (shift) {\n\n esp -= 4;\n\n stl(ssp + (esp & esp_mask), env->segs[R_CS].selector);\n\n esp -= 4;\n\n stl(ssp + (esp & esp_mask), next_eip);\n\n } else {\n\n esp -= 2;\n\n stw(ssp + (esp & esp_mask), env->segs[R_CS].selector);\n\n esp -= 2;\n\n stw(ssp + (esp & esp_mask), next_eip);\n\n }\n\n\n\n if (!(env->segs[R_SS].flags & DESC_B_MASK))\n\n env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);\n\n else\n\n env->regs[R_ESP] = esp;\n\n env->eip = new_eip;\n\n env->segs[R_CS].selector = new_cs;\n\n env->segs[R_CS].base = (uint8_t *)(new_cs << 4);\n\n}\n", + "output": "0", + "index": 14832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)\n\n{\n\n PerThreadContext *p = avctx->internal->thread_ctx;\n\n FrameThreadContext *fctx;\n\n AVFrame *dst, *tmp;\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) ||\n\n avctx->thread_safe_callbacks ||\n\n (\n\n#if FF_API_GET_BUFFER\n\n !avctx->get_buffer &&\n\n#endif\n\n avctx->get_buffer2 == avcodec_default_get_buffer2);\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n\n\n if (!f->f->data[0])\n\n return;\n\n\n\n if (avctx->debug & FF_DEBUG_BUFFERS)\n\n av_log(avctx, AV_LOG_DEBUG, \"thread_release_buffer called on pic %p\\n\", f);\n\n\n\n av_buffer_unref(&f->progress);\n\n f->owner = NULL;\n\n\n\n if (can_direct_free) {\n\n av_frame_unref(f->f);\n\n return;\n\n }\n\n\n\n fctx = p->parent;\n\n pthread_mutex_lock(&fctx->buffer_mutex);\n\n\n\n if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers))\n\n goto fail;\n\n tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated,\n\n (p->num_released_buffers + 1) *\n\n sizeof(*p->released_buffers));\n\n if (!tmp)\n\n goto fail;\n\n p->released_buffers = tmp;\n\n\n\n dst = &p->released_buffers[p->num_released_buffers];\n\n av_frame_move_ref(dst, f->f);\n\n\n\n p->num_released_buffers++;\n\n\n\nfail:\n\n pthread_mutex_unlock(&fctx->buffer_mutex);\n\n}\n", + "output": "0", + "index": 16784 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void uhci_fill_queue(UHCIState *s, UHCI_TD *td)\n\n{\n\n uint32_t int_mask = 0;\n\n uint32_t plink = td->link;\n\n uint32_t token = uhci_queue_token(td);\n\n UHCI_TD ptd;\n\n int ret;\n\n\n\n while (is_valid(plink)) {\n\n pci_dma_read(&s->dev, plink & ~0xf, &ptd, sizeof(ptd));\n\n le32_to_cpus(&ptd.link);\n\n le32_to_cpus(&ptd.ctrl);\n\n le32_to_cpus(&ptd.token);\n\n le32_to_cpus(&ptd.buffer);\n\n if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {\n\n break;\n\n }\n\n if (uhci_queue_token(&ptd) != token) {\n\n break;\n\n }\n\n trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);\n\n ret = uhci_handle_td(s, plink, &ptd, &int_mask, true);\n\n if (ret == TD_RESULT_ASYNC_CONT) {\n\n break;\n\n }\n\n assert(ret == TD_RESULT_ASYNC_START);\n\n assert(int_mask == 0);\n\n if (ptd.ctrl & TD_CTRL_SPD) {\n\n break;\n\n }\n\n plink = ptd.link;\n\n }\n\n}\n", + "output": "0", + "index": 26788 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr)\n\n{\n\n uint64_t val;\n\n\n\n spapr_tce_dma_read(dev, taddr, &val, sizeof(val));\n\n return tswap64(val);\n\n}\n", + "output": "1", + "index": 16706 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_pm1_cnt_reset(ACPIREGS *ar)\n\n{\n\n ar->pm1.cnt.cnt = 0;\n\n if (ar->pm1.cnt.cmos_s3) {\n\n qemu_irq_lower(ar->pm1.cnt.cmos_s3);\n\n }\n\n}\n", + "output": "0", + "index": 6389 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_flac_compute_autocorr(const int32_t *data, int len, int lag,\n\n double *autoc)\n\n{\n\n int i, j;\n\n double tmp[len + lag + 1];\n\n double *data1= tmp + lag;\n\n\n\n apply_welch_window(data, len, data1);\n\n\n\n for(j=0; jnext;\n\n if (stream->stream_type == STREAM_TYPE_LIVE &&\n\n !stream->feed) {\n\n /* the stream comes from a file */\n\n /* try to open the file */\n\n /* open stream */\n\n stream->ap_in = av_mallocz(sizeof(AVFormatParameters));\n\n if (!strcmp(stream->fmt->name, \"rtp\")) {\n\n /* specific case : if transport stream output to RTP,\n\n we use a raw transport stream reader */\n\n stream->ap_in->mpeg2ts_raw = 1;\n\n stream->ap_in->mpeg2ts_compute_pcr = 1;\n\n }\n\n\n\n if (av_open_input_file(&infile, stream->feed_filename,\n\n stream->ifmt, 0, stream->ap_in) < 0) {\n\n http_log(\"%s not found\", stream->feed_filename);\n\n /* remove stream (no need to spend more time on it) */\n\n fail:\n\n remove_stream(stream);\n\n } else {\n\n /* find all the AVStreams inside and reference them in\n\n 'stream' */\n\n if (av_find_stream_info(infile) < 0) {\n\n http_log(\"Could not find codec parameters from '%s'\",\n\n stream->feed_filename);\n\n av_close_input_file(infile);\n\n goto fail;\n\n }\n\n extract_mpeg4_header(infile);\n\n\n\n for(i=0;inb_streams;i++)\n\n add_av_stream1(stream, infile->streams[i]->codec);\n\n\n\n av_close_input_file(infile);\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 26929 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,\n\n uint64_t offset, uint64_t len)\n\n{\n\n RDMALocalBlock *block =\n\n &(rdma->local_ram_blocks.block[rdma->current_index]);\n\n uint8_t *host_addr = block->local_host_addr + (offset - block->offset);\n\n uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk);\n\n\n\n if (rdma->current_length == 0) {\n\n return 0;\n\n }\n\n\n\n /*\n\n * Only merge into chunk sequentially.\n\n */\n\n if (offset != (rdma->current_addr + rdma->current_length)) {\n\n return 0;\n\n }\n\n\n\n if (rdma->current_index < 0) {\n\n return 0;\n\n }\n\n\n\n if (offset < block->offset) {\n\n return 0;\n\n }\n\n\n\n if ((offset + len) > (block->offset + block->length)) {\n\n return 0;\n\n }\n\n\n\n if (rdma->current_chunk < 0) {\n\n return 0;\n\n }\n\n\n\n if ((host_addr + len) > chunk_end) {\n\n return 0;\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "0", + "index": 13067 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,\n\n int64_t sector_num,\n\n QEMUIOVector *iov,\n\n int nb_sectors,\n\n BlockDriverCompletionFunc *cb,\n\n void *opaque,\n\n int is_write)\n\n\n\n{\n\n VectorTranslationState *s = qemu_mallocz(sizeof(*s));\n\n BlockDriverAIOCB *aiocb = qemu_aio_get(bs, cb, opaque);\n\n\n\n s->this_aiocb = aiocb;\n\n s->iov = iov;\n\n s->bounce = qemu_memalign(512, nb_sectors * 512);\n\n s->is_write = is_write;\n\n if (is_write) {\n\n qemu_iovec_to_buffer(s->iov, s->bounce);\n\n s->aiocb = bdrv_aio_write(bs, sector_num, s->bounce, nb_sectors,\n\n bdrv_aio_rw_vector_cb, s);\n\n } else {\n\n s->aiocb = bdrv_aio_read(bs, sector_num, s->bounce, nb_sectors,\n\n bdrv_aio_rw_vector_cb, s);\n\n }\n\n return aiocb;\n\n}\n", + "output": "0", + "index": 11912 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)\n\n{\n\n DeviceState *qdev = DEVICE(vdev);\n\n BusState *qbus = BUS(qdev_get_parent_bus(qdev));\n\n VirtioBusState *bus = VIRTIO_BUS(qbus);\n\n VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);\n\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n\n\n\n DPRINTF(\"%s: plug device.\\n\", qbus->name);\n\n\n\n if (klass->device_plugged != NULL) {\n\n klass->device_plugged(qbus->parent, errp);\n\n }\n\n\n\n /* Get the features of the plugged device. */\n\n assert(vdc->get_features != NULL);\n\n vdev->host_features = vdc->get_features(vdev, vdev->host_features,\n\n errp);\n\n if (klass->post_plugged != NULL) {\n\n klass->post_plugged(qbus->parent, errp);\n\n }\n\n}\n", + "output": "0", + "index": 20363 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool ftrace_init(void)\n\n{\n\n char mount_point[PATH_MAX];\n\n char path[PATH_MAX];\n\n int debugfs_found;\n\n int trace_fd = -1;\n\n\n\n debugfs_found = find_mount(mount_point, \"debugfs\");\n\n if (debugfs_found) {\n\n snprintf(path, PATH_MAX, \"%s/tracing/tracing_on\", mount_point);\n\n trace_fd = open(path, O_WRONLY);\n\n if (trace_fd < 0) {\n\n if (errno == EACCES) {\n\n trace_marker_fd = open(\"/dev/null\", O_WRONLY);\n\n if (trace_marker_fd != -1) {\n\n return true;\n\n }\n\n }\n\n perror(\"Could not open ftrace 'tracing_on' file\");\n\n return false;\n\n } else {\n\n if (write(trace_fd, \"1\", 1) < 0) {\n\n perror(\"Could not write to 'tracing_on' file\");\n\n close(trace_fd);\n\n return false;\n\n }\n\n close(trace_fd);\n\n }\n\n snprintf(path, PATH_MAX, \"%s/tracing/trace_marker\", mount_point);\n\n trace_marker_fd = open(path, O_WRONLY);\n\n if (trace_marker_fd < 0) {\n\n perror(\"Could not open ftrace 'trace_marker' file\");\n\n return false;\n\n }\n\n } else {\n\n fprintf(stderr, \"debugfs is not mounted\\n\");\n\n return false;\n\n }\n\n\n\n return true;\n\n}\n", + "output": "1", + "index": 24351 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,\n\n VirtQueue *vq)\n\n{\n\n VirtIOSCSI *s = VIRTIO_SCSI(vdev);\n\n\n\n assert(s->ctx && s->dataplane_started);\n\n return virtio_scsi_handle_ctrl_vq(s, vq);\n\n}\n", + "output": "1", + "index": 2368 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_addo (void)\n\n{\n\n T2 = T0;\n\n T0 += T1;\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": 11731 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,\n\n int nb_sectors)\n\n{\n\n int max_discard;\n\n\n\n if (!bs->drv) {\n\n return -ENOMEDIUM;\n\n } else if (bdrv_check_request(bs, sector_num, nb_sectors)) {\n\n return -EIO;\n\n } else if (bs->read_only) {\n\n return -EROFS;\n\n }\n\n\n\n bdrv_reset_dirty(bs, sector_num, nb_sectors);\n\n\n\n /* Do nothing if disabled. */\n\n if (!(bs->open_flags & BDRV_O_UNMAP)) {\n\n return 0;\n\n }\n\n\n\n if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) {\n\n return 0;\n\n }\n\n\n\n max_discard = bs->bl.max_discard ? bs->bl.max_discard : MAX_DISCARD_DEFAULT;\n\n while (nb_sectors > 0) {\n\n int ret;\n\n int num = nb_sectors;\n\n\n\n /* align request */\n\n if (bs->bl.discard_alignment &&\n\n num >= bs->bl.discard_alignment &&\n\n sector_num % bs->bl.discard_alignment) {\n\n if (num > bs->bl.discard_alignment) {\n\n num = bs->bl.discard_alignment;\n\n }\n\n num -= sector_num % bs->bl.discard_alignment;\n\n }\n\n\n\n /* limit request size */\n\n if (num > max_discard) {\n\n num = max_discard;\n\n }\n\n\n\n if (bs->drv->bdrv_co_discard) {\n\n ret = bs->drv->bdrv_co_discard(bs, sector_num, num);\n\n } else {\n\n BlockDriverAIOCB *acb;\n\n CoroutineIOCompletion co = {\n\n .coroutine = qemu_coroutine_self(),\n\n };\n\n\n\n acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors,\n\n bdrv_co_io_em_complete, &co);\n\n if (acb == NULL) {\n\n return -EIO;\n\n } else {\n\n qemu_coroutine_yield();\n\n ret = co.ret;\n\n }\n\n }\n\n if (ret) {\n\n return ret;\n\n }\n\n\n\n sector_num += num;\n\n nb_sectors -= num;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 17030 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,\n\n int width, int height,\n\n int lumStride, int chromStride, int srcStride)\n\n{\n\n int y;\n\n const int chromWidth = FF_CEIL_RSHIFT(width, 1);\n\n\n\n for (y=0; yopaque;\n\n NFSRPC task;\n\n char *buf = NULL;\n\n\n\n nfs_co_init_task(client, &task);\n\n\n\n buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE);\n\n if (nb_sectors && buf == NULL) {\n\n return -ENOMEM;\n\n }\n\n\n\n qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);\n\n\n\n if (nfs_pwrite_async(client->context, client->fh,\n\n sector_num * BDRV_SECTOR_SIZE,\n\n nb_sectors * BDRV_SECTOR_SIZE,\n\n buf, nfs_co_generic_cb, &task) != 0) {\n\n g_free(buf);\n\n return -ENOMEM;\n\n }\n\n\n\n while (!task.complete) {\n\n nfs_set_events(client);\n\n qemu_coroutine_yield();\n\n }\n\n\n\n g_free(buf);\n\n\n\n if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {\n\n return task.ret < 0 ? task.ret : -EIO;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vnc_display_disable_login(DisplayState *ds)\n\n{\n\n VncDisplay *vs = vnc_display;\n\n\n\n if (!vs) {\n\n return -1;\n\n }\n\n\n\n if (vs->password) {\n\n g_free(vs->password);\n\n }\n\n\n\n vs->password = NULL;\n\n if (vs->auth == VNC_AUTH_NONE) {\n\n vs->auth = VNC_AUTH_VNC;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 12711 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(oc);\n\n PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);\n\n\n\n dc->fw_name = \"PowerPC,POWER8\";\n\n dc->desc = \"POWER8\";\n\n pcc->pvr = CPU_POWERPC_POWER8_BASE;\n\n pcc->pvr_mask = CPU_POWERPC_POWER8_MASK;\n\n pcc->init_proc = init_proc_POWER7;\n\n pcc->check_pow = check_pow_nocheck;\n\n pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB |\n\n PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |\n\n PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |\n\n PPC_FLOAT_STFIWX |\n\n\n PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |\n\n PPC_MEM_SYNC | PPC_MEM_EIEIO |\n\n PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |\n\n PPC_64B | PPC_ALTIVEC |\n\n PPC_SEGMENT_64B | PPC_SLBI |\n\n PPC_POPCNTB | PPC_POPCNTWD;\n\n pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |\n\n PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |\n\n PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206;\n\n pcc->msr_mask = 0x800000000284FF36ULL;\n\n pcc->mmu_model = POWERPC_MMU_2_06;\n\n#if defined(CONFIG_SOFTMMU)\n\n pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;\n\n#endif\n\n pcc->excp_model = POWERPC_EXCP_POWER7;\n\n pcc->bus_model = PPC_FLAGS_INPUT_POWER7;\n\n pcc->bfd_mach = bfd_mach_ppc64;\n\n pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |\n\n POWERPC_FLAG_BE | POWERPC_FLAG_PMM |\n\n POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |\n\n POWERPC_FLAG_VSX;\n\n pcc->l1_dcache_size = 0x8000;\n\n pcc->l1_icache_size = 0x8000;\n\n}", + "output": "1", + "index": 9457 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt)\n\n{\n\n SRTContext *srt = avf->priv_data;\n\n int write_ts = avf->streams[0]->codec->codec_id != AV_CODEC_ID_SRT;\n\n\n\n srt->index++;\n\n if (write_ts) {\n\n int64_t s = pkt->pts, e, d = pkt->duration;\n\n\n\n if (d <= 0)\n\n /* For backward compatibility, fallback to convergence_duration. */\n\n d = pkt->convergence_duration;\n\n if (s == AV_NOPTS_VALUE || d < 0) {\n\n av_log(avf, AV_LOG_ERROR, \"Insufficient timestamps.\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n e = s + d;\n\n avio_printf(avf->pb, \"%d\\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\\n\",\n\n srt->index,\n\n (int)(s / 3600000), (int)(s / 60000) % 60,\n\n (int)(s / 1000) % 60, (int)(s % 1000),\n\n (int)(e / 3600000), (int)(e / 60000) % 60,\n\n (int)(e / 1000) % 60, (int)(e % 1000));\n\n }\n\n avio_write(avf->pb, pkt->data, pkt->size);\n\n if (write_ts)\n\n avio_write(avf->pb, \"\\n\\n\", 2);\n\n avio_flush(avf->pb);\n\n return 0;\n\n}\n", + "output": "1", + "index": 27198 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PCIBus *pci_pmac_u3_init(qemu_irq *pic,\n\n MemoryRegion *address_space_mem,\n\n MemoryRegion *address_space_io)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n PCIHostState *h;\n\n UNINState *d;\n\n\n\n /* Uninorth AGP bus */\n\n\n\n dev = qdev_create(NULL, TYPE_U3_AGP_HOST_BRIDGE);\n\n qdev_init_nofail(dev);\n\n s = SYS_BUS_DEVICE(dev);\n\n h = PCI_HOST_BRIDGE(dev);\n\n d = U3_AGP_HOST_BRIDGE(dev);\n\n\n\n memory_region_init(&d->pci_mmio, OBJECT(d), \"pci-mmio\", 0x100000000ULL);\n\n memory_region_init_alias(&d->pci_hole, OBJECT(d), \"pci-hole\", &d->pci_mmio,\n\n 0x80000000ULL, 0x70000000ULL);\n\n memory_region_add_subregion(address_space_mem, 0x80000000ULL,\n\n &d->pci_hole);\n\n\n\n h->bus = pci_register_bus(dev, \"pci\",\n\n pci_unin_set_irq, pci_unin_map_irq,\n\n pic,\n\n &d->pci_mmio,\n\n address_space_io,\n\n PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);\n\n\n\n sysbus_mmio_map(s, 0, 0xf0800000);\n\n sysbus_mmio_map(s, 1, 0xf0c00000);\n\n\n\n pci_create_simple(h->bus, 11 << 3, \"u3-agp\");\n\n\n\n return h->bus;\n\n}\n", + "output": "0", + "index": 1366 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoull_full_max(void)\n\n{\n\n const char *str = g_strdup_printf(\"%lld\", ULLONG_MAX);\n\n uint64_t res = 999;\n\n int err;\n\n\n\n err = qemu_strtoull(str, NULL, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, ULLONG_MAX);\n\n}\n", + "output": "1", + "index": 5935 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int asym_quant(int c, int e, int qbits)\n\n{\n\n int m;\n\n\n\n c = (((c << e) >> (24 - qbits)) + 1) >> 1;\n\n m = (1 << (qbits-1));\n\n if (c >= m)\n\n c = m - 1;\n\n av_assert2(c >= -m);\n\n return c;\n\n}\n", + "output": "1", + "index": 17736 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int voc_probe(AVProbeData *p)\n\n{\n\n int version, check;\n\n\n\n if (p->buf_size < 26)\n\n return 0;\n\n if (memcmp(p->buf, voc_magic, sizeof(voc_magic) - 1))\n\n return 0;\n\n version = p->buf[22] | (p->buf[23] << 8);\n\n check = p->buf[24] | (p->buf[25] << 8);\n\n if (~version + 0x1234 != check)\n\n return 10;\n\n\n\n return AVPROBE_SCORE_MAX;\n\n}\n", + "output": "0", + "index": 22379 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void block_job_enter(BlockJob *job)\n\n{\n\n if (!block_job_started(job)) {\n\n return;\n\n }\n\n if (job->deferred_to_main_loop) {\n\n return;\n\n }\n\n\n\n if (!job->busy) {\n\n bdrv_coroutine_enter(blk_bs(job->blk), job->co);\n\n }\n\n}\n", + "output": "1", + "index": 356 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void enter_migration_coroutine(void *opaque)\n\n{\n\n Coroutine *co = opaque;\n\n qemu_coroutine_enter(co, NULL);\n\n}\n", + "output": "1", + "index": 12086 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_mouse_class_initfn(ObjectClass *klass, void *data)\n\n{\n\n USBDeviceClass *uc = USB_DEVICE_CLASS(klass);\n\n\n\n uc->init = usb_mouse_initfn;\n\n uc->product_desc = \"QEMU USB Mouse\";\n\n uc->usb_desc = &desc_mouse;\n\n uc->handle_packet = usb_generic_handle_packet;\n\n uc->handle_reset = usb_hid_handle_reset;\n\n uc->handle_control = usb_hid_handle_control;\n\n uc->handle_data = usb_hid_handle_data;\n\n uc->handle_destroy = usb_hid_handle_destroy;\n\n}\n", + "output": "0", + "index": 6187 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int configure_accelerator(void)\n\n{\n\n const char *p = NULL;\n\n char buf[10];\n\n int i, ret;\n\n bool accel_initalised = 0;\n\n bool init_failed = 0;\n\n\n\n QemuOptsList *list = qemu_find_opts(\"machine\");\n\n if (!QTAILQ_EMPTY(&list->head)) {\n\n p = qemu_opt_get(QTAILQ_FIRST(&list->head), \"accel\");\n\n }\n\n\n\n if (p == NULL) {\n\n /* Use the default \"accelerator\", tcg */\n\n p = \"tcg\";\n\n }\n\n\n\n while (!accel_initalised && *p != '\\0') {\n\n if (*p == ':') {\n\n p++;\n\n }\n\n p = get_opt_name(buf, sizeof (buf), p, ':');\n\n for (i = 0; i < ARRAY_SIZE(accel_list); i++) {\n\n if (strcmp(accel_list[i].opt_name, buf) == 0) {\n\n ret = accel_list[i].init();\n\n if (ret < 0) {\n\n init_failed = 1;\n\n if (!accel_list[i].available()) {\n\n printf(\"%s not supported for this target\\n\",\n\n accel_list[i].name);\n\n } else {\n\n fprintf(stderr, \"failed to initialize %s: %s\\n\",\n\n accel_list[i].name,\n\n strerror(-ret));\n\n }\n\n } else {\n\n accel_initalised = 1;\n\n *(accel_list[i].allowed) = 1;\n\n }\n\n break;\n\n }\n\n }\n\n if (i == ARRAY_SIZE(accel_list)) {\n\n fprintf(stderr, \"\\\"%s\\\" accelerator does not exist.\\n\", buf);\n\n }\n\n }\n\n\n\n if (!accel_initalised) {\n\n fprintf(stderr, \"No accelerator found!\\n\");\n\n exit(1);\n\n }\n\n\n\n if (init_failed) {\n\n fprintf(stderr, \"Back to %s accelerator.\\n\", accel_list[i].name);\n\n }\n\n\n\n return !accel_initalised;\n\n}\n", + "output": "0", + "index": 1104 + }, + { + "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 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[0x09] = 0x00; // programming i/f\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": "1", + "index": 6442 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int uncouple_channels(AC3DecodeContext * ctx)\n\n{\n\n ac3_audio_block *ab = &ctx->audio_block;\n\n int ch, sbnd, bin;\n\n int index;\n\n float (*samples)[256];\n\n int16_t mantissa;\n\n\n\n samples = (float (*)[256])((ctx->bsi.flags & AC3_BSI_LFEON) ? (ctx->samples + 256) : (ctx->samples));\n\n\n\n /* uncouple channels */\n\n for (ch = 0; ch < ctx->bsi.nfchans; ch++)\n\n if (ab->chincpl & (1 << ch))\n\n for (sbnd = ab->cplbegf; sbnd < 3 + ab->cplendf; sbnd++)\n\n for (bin = 0; bin < 12; bin++) {\n\n index = sbnd * 12 + bin + 37;\n\n samples[ch][index] = ab->cplcoeffs[index] * ab->cplco[ch][sbnd] * ab->chcoeffs[ch];\n\n }\n\n\n\n /* generate dither if required */\n\n for (ch = 0; ch < ctx->bsi.nfchans; ch++)\n\n if ((ab->chincpl & (1 << ch)) && (ab->dithflag & (1 << ch)))\n\n for (index = 0; index < ab->endmant[ch]; index++)\n\n if (!ab->bap[ch][index]) {\n\n mantissa = dither_int16(&ctx->state);\n\n samples[ch][index] = to_float(ab->dexps[ch][index], mantissa) * ab->chcoeffs[ch];\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11858 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvmppc_get_htab_fd(bool write)\n\n{\n\n struct kvm_get_htab_fd s = {\n\n .flags = write ? KVM_GET_HTAB_WRITE : 0,\n\n .start_index = 0,\n\n };\n\n\n\n if (!cap_htab_fd) {\n\n fprintf(stderr, \"KVM version doesn't support saving the hash table\\n\");\n\n return -1;\n\n }\n\n\n\n return kvm_vm_ioctl(kvm_state, KVM_PPC_GET_HTAB_FD, &s);\n\n}\n", + "output": "1", + "index": 25419 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_cpu_class_init(ObjectClass *oc, void *data)\n\n{\n\n S390CPUClass *scc = S390_CPU_CLASS(oc);\n\n CPUClass *cc = CPU_CLASS(scc);\n\n DeviceClass *dc = DEVICE_CLASS(oc);\n\n\n\n scc->parent_realize = dc->realize;\n\n dc->realize = s390_cpu_realizefn;\n\n\n\n scc->parent_reset = cc->reset;\n\n cc->reset = s390_cpu_reset;\n\n\n\n cc->do_interrupt = s390_cpu_do_interrupt;\n\n cc->dump_state = s390_cpu_dump_state;\n\n cc->set_pc = s390_cpu_set_pc;\n\n cc->gdb_read_register = s390_cpu_gdb_read_register;\n\n cc->gdb_write_register = s390_cpu_gdb_write_register;\n\n#ifndef CONFIG_USER_ONLY\n\n cc->get_phys_page_debug = s390_cpu_get_phys_page_debug;\n\n\n\n#endif\n\n dc->vmsd = &vmstate_s390_cpu;\n\n cc->gdb_num_core_regs = S390_NUM_REGS;\n\n}", + "output": "1", + "index": 13485 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,\n\n uint32_t *ext_features,\n\n uint32_t *ext2_features,\n\n uint32_t *ext3_features,\n\n uint32_t *kvm_features)\n\n{\n\n int i;\n\n int found = 0;\n\n\n\n for ( i = 0 ; i < 32 ; i++ )\n\n if (feature_name[i] && !strcmp (flagname, feature_name[i])) {\n\n *features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ )\n\n if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {\n\n *ext_features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ )\n\n if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {\n\n *ext2_features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ )\n\n if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {\n\n *ext3_features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ )\n\n if (kvm_feature_name[i] && !strcmp (flagname, kvm_feature_name[i])) {\n\n *kvm_features |= 1 << i;\n\n found = 1;\n\n }\n\n\n\n if (!found) {\n\n fprintf(stderr, \"CPU feature %s not found\\n\", flagname);\n\n }\n\n}\n", + "output": "0", + "index": 7333 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sbr_hf_g_filt_c(int (*Y)[2], const int (*X_high)[40][2],\n\n const SoftFloat *g_filt, int m_max, intptr_t ixh)\n\n{\n\n int m;\n\n int64_t accu;\n\n\n\n for (m = 0; m < m_max; m++) {\n\n int64_t r = 1LL << (22-g_filt[m].exp);\n\n accu = (int64_t)X_high[m][ixh][0] * ((g_filt[m].mant + 0x40)>>7);\n\n Y[m][0] = (int)((accu + r) >> (23-g_filt[m].exp));\n\n\n\n accu = (int64_t)X_high[m][ixh][1] * ((g_filt[m].mant + 0x40)>>7);\n\n Y[m][1] = (int)((accu + r) >> (23-g_filt[m].exp));\n\n }\n\n}\n", + "output": "1", + "index": 5790 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_serialize(void *native_in, void **datap,\n\n VisitorFunc visit, Error **errp)\n\n{\n\n QmpSerializeData *d = g_malloc0(sizeof(*d));\n\n\n\n d->qov = qmp_output_visitor_new(&d->obj);\n\n visit(d->qov, &native_in, errp);\n\n *datap = d;\n\n}\n", + "output": "0", + "index": 329 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void replay_save_instructions(void)\n{\n if (replay_file && replay_mode == REPLAY_MODE_RECORD) {\n replay_mutex_lock();\n int diff = (int)(replay_get_current_step() - replay_state.current_step);\n if (diff > 0) {\n replay_put_event(EVENT_INSTRUCTION);\n replay_put_dword(diff);\n replay_state.current_step += diff;\n }\n replay_mutex_unlock();\n }\n}", + "output": "1", + "index": 2453 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static MemoryRegionSection address_space_do_translate(AddressSpace *as,\n\n hwaddr addr,\n\n hwaddr *xlat,\n\n hwaddr *plen,\n\n bool is_write,\n\n bool is_mmio)\n\n{\n\n IOMMUTLBEntry iotlb;\n\n MemoryRegionSection *section;\n\n MemoryRegion *mr;\n\n\n\n for (;;) {\n\n AddressSpaceDispatch *d = atomic_rcu_read(&as->dispatch);\n\n section = address_space_translate_internal(d, addr, &addr, plen, is_mmio);\n\n mr = section->mr;\n\n\n\n if (!mr->iommu_ops) {\n\n break;\n\n }\n\n\n\n iotlb = mr->iommu_ops->translate(mr, addr, is_write);\n\n addr = ((iotlb.translated_addr & ~iotlb.addr_mask)\n\n | (addr & iotlb.addr_mask));\n\n *plen = MIN(*plen, (addr | iotlb.addr_mask) - addr + 1);\n\n if (!(iotlb.perm & (1 << is_write))) {\n\n goto translate_fail;\n\n }\n\n\n\n as = iotlb.target_as;\n\n }\n\n\n\n *xlat = addr;\n\n\n\n return *section;\n\n\n\ntranslate_fail:\n\n return (MemoryRegionSection) { .mr = &io_mem_unassigned };\n\n}\n", + "output": "0", + "index": 11969 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rv34_idct_dc_add_c(uint8_t *dst, int stride, int dc)\n\n{\n\n const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n int i, j;\n\n\n\n cm += (13*13*dc + 0x200) >> 10;\n\n\n\n for (i = 0; i < 4; i++)\n\n {\n\n for (j = 0; j < 4; j++)\n\n dst[j] = cm[ dst[j] ];\n\n\n\n dst += stride;\n\n }\n\n}\n", + "output": "1", + "index": 2357 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_init_state(VncState *vs)\n\n{\n\n vs->initialized = true;\n\n VncDisplay *vd = vs->vd;\n\n bool first_client = QTAILQ_EMPTY(&vd->clients);\n\n\n\n vs->last_x = -1;\n\n vs->last_y = -1;\n\n\n\n vs->as.freq = 44100;\n\n vs->as.nchannels = 2;\n\n vs->as.fmt = AUD_FMT_S16;\n\n vs->as.endianness = 0;\n\n\n\n qemu_mutex_init(&vs->output_mutex);\n\n vs->bh = qemu_bh_new(vnc_jobs_bh, vs);\n\n\n\n QTAILQ_INSERT_TAIL(&vd->clients, vs, next);\n\n if (first_client) {\n\n vnc_update_server_surface(vd);\n\n }\n\n\n\n graphic_hw_update(vd->dcl.con);\n\n\n\n vnc_write(vs, \"RFB 003.008\\n\", 12);\n\n vnc_flush(vs);\n\n vnc_read_when(vs, protocol_version, 12);\n\n reset_keys(vs);\n\n if (vs->vd->lock_key_sync)\n\n vs->led = qemu_add_led_event_handler(kbd_leds, vs);\n\n\n\n vs->mouse_mode_notifier.notify = check_pointer_type_change;\n\n qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);\n\n}\n", + "output": "0", + "index": 20745 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t megasas_mmio_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n MegasasState *s = opaque;\n\n uint32_t retval = 0;\n\n\n\n switch (addr) {\n\n case MFI_IDB:\n\n retval = 0;\n\n break;\n\n case MFI_OMSG0:\n\n case MFI_OSP0:\n\n retval = (megasas_use_msix(s) ? MFI_FWSTATE_MSIX_SUPPORTED : 0) |\n\n (s->fw_state & MFI_FWSTATE_MASK) |\n\n ((s->fw_sge & 0xff) << 16) |\n\n (s->fw_cmds & 0xFFFF);\n\n break;\n\n case MFI_OSTS:\n\n if (megasas_intr_enabled(s) && s->doorbell) {\n\n retval = MFI_1078_RM | 1;\n\n }\n\n break;\n\n case MFI_OMSK:\n\n retval = s->intr_mask;\n\n break;\n\n case MFI_ODCR0:\n\n retval = s->doorbell;\n\n break;\n\n default:\n\n trace_megasas_mmio_invalid_readl(addr);\n\n break;\n\n }\n\n trace_megasas_mmio_readl(addr, retval);\n\n return retval;\n\n}\n", + "output": "0", + "index": 25233 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint16_t cpu_inw(CPUState *env, pio_addr_t addr)\n\n{\n\n uint16_t val;\n\n val = ioport_read(1, addr);\n\n LOG_IOPORT(\"inw : %04\"FMT_pioaddr\" %04\"PRIx16\"\\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": 11413 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void store_booke_tsr (CPUState *env, target_ulong val)\n\n{\n\n LOG_TB(\"%s: val \" TARGET_FMT_lx \"\\n\", __func__, val);\n\n env->spr[SPR_40x_TSR] &= ~(val & 0xFC000000);\n\n if (val & 0x80000000)\n\n ppc_set_irq(env, PPC_INTERRUPT_PIT, 0);\n\n}\n", + "output": "0", + "index": 23823 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)\n\n{\n\n DynBuffer *d = opaque;\n\n int new_size, new_allocated_size;\n\n\n\n /* reallocate buffer if needed */\n\n new_size = d->pos + buf_size;\n\n new_allocated_size = d->allocated_size;\n\n if(new_size < d->pos || new_size > INT_MAX/2)\n\n return -1;\n\n while (new_size > new_allocated_size) {\n\n if (!new_allocated_size)\n\n new_allocated_size = new_size;\n\n else\n\n new_allocated_size += new_allocated_size / 2 + 1;\n\n }\n\n\n\n if (new_allocated_size > d->allocated_size) {\n\n d->buffer = av_realloc(d->buffer, new_allocated_size);\n\n if(d->buffer == NULL)\n\n return -1234;\n\n d->allocated_size = new_allocated_size;\n\n }\n\n memcpy(d->buffer + d->pos, buf, buf_size);\n\n d->pos = new_size;\n\n if (d->pos > d->size)\n\n d->size = d->pos;\n\n return buf_size;\n\n}\n", + "output": "1", + "index": 3283 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_out_enum_errors(TestOutputVisitorData *data,\n\n const void *unused)\n\n{\n\n EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };\n\n Error *err;\n\n\n\n for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {\n\n err = NULL;\n\n visit_type_EnumOne(data->ov, \"unused\", &bad_values[i], &err);\n\n g_assert(err);\n\n error_free(err);\n\n visitor_reset(data);\n\n }\n\n}\n", + "output": "0", + "index": 20791 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qdev_init(DeviceState *dev)\n\n{\n\n int rc;\n\n\n\n assert(dev->state == DEV_STATE_CREATED);\n\n rc = dev->info->init(dev, dev->info);\n\n if (rc < 0) {\n\n qdev_free(dev);\n\n return rc;\n\n }\n\n qemu_register_reset(qdev_reset, dev);\n\n if (dev->info->vmsd) {\n\n vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,\n\n dev->instance_id_alias,\n\n dev->alias_required_for_version);\n\n }\n\n dev->state = DEV_STATE_INITIALIZED;\n\n return 0;\n\n}\n", + "output": "0", + "index": 24722 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void icp_control_init(uint32_t base)\n\n{\n\n int iomemtype;\n\n icp_control_state *s;\n\n\n\n s = (icp_control_state *)qemu_mallocz(sizeof(icp_control_state));\n\n iomemtype = cpu_register_io_memory(0, icp_control_readfn,\n\n icp_control_writefn, s);\n\n cpu_register_physical_memory(base, 0x007fffff, iomemtype);\n\n s->base = base;\n\n /* ??? Save/restore. */\n\n}\n", + "output": "1", + "index": 17474 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qed_aio_next_io(QEDAIOCB *acb)\n\n{\n\n BDRVQEDState *s = acb_to_s(acb);\n\n uint64_t offset;\n\n size_t len;\n\n int ret;\n\n\n\n trace_qed_aio_next_io(s, acb, 0, acb->cur_pos + acb->cur_qiov.size);\n\n\n\n if (acb->backing_qiov) {\n\n qemu_iovec_destroy(acb->backing_qiov);\n\n g_free(acb->backing_qiov);\n\n acb->backing_qiov = NULL;\n\n }\n\n\n\n acb->qiov_offset += acb->cur_qiov.size;\n\n acb->cur_pos += acb->cur_qiov.size;\n\n qemu_iovec_reset(&acb->cur_qiov);\n\n\n\n /* Complete request */\n\n if (acb->cur_pos >= acb->end_pos) {\n\n qed_aio_complete(acb, 0);\n\n return;\n\n }\n\n\n\n /* Find next cluster and start I/O */\n\n len = acb->end_pos - acb->cur_pos;\n\n ret = qed_find_cluster(s, &acb->request, acb->cur_pos, &len, &offset);\n\n if (ret < 0) {\n\n qed_aio_complete(acb, ret);\n\n return;\n\n }\n\n\n\n if (acb->flags & QED_AIOCB_WRITE) {\n\n ret = qed_aio_write_data(acb, ret, offset, len);\n\n } else {\n\n ret = qed_aio_read_data(acb, ret, offset, len);\n\n }\n\n\n\n if (ret < 0) {\n\n if (ret != -EINPROGRESS) {\n\n qed_aio_complete(acb, ret);\n\n }\n\n return;\n\n }\n\n qed_aio_next_io(acb);\n\n}\n", + "output": "0", + "index": 27090 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_phb_reset(DeviceState *qdev)\n\n{\n\n SysBusDevice *s = SYS_BUS_DEVICE(qdev);\n\n sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s);\n\n\n\n /* Reset the IOMMU state */\n\n spapr_tce_reset(sphb->tcet);\n\n}\n", + "output": "0", + "index": 4131 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_balloon_save(QEMUFile *f, void *opaque)\n\n{\n\n VirtIOBalloon *s = opaque;\n\n\n\n virtio_save(&s->vdev, f);\n\n\n\n qemu_put_be32(f, s->num_pages);\n\n qemu_put_be32(f, s->actual);\n\n qemu_put_buffer(f, (uint8_t *)&s->stats_vq_elem, sizeof(VirtQueueElement));\n\n qemu_put_buffer(f, (uint8_t *)&s->stats_vq_offset, sizeof(size_t));\n\n qemu_put_buffer(f, (uint8_t *)&s->stats_callback, sizeof(MonitorCompletion));\n\n qemu_put_buffer(f, (uint8_t *)&s->stats_opaque_callback_data, sizeof(void));\n\n}\n", + "output": "1", + "index": 12595 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void laio_cancel(BlockDriverAIOCB *blockacb)\n\n{\n\n struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb;\n\n struct io_event event;\n\n int ret;\n\n\n\n if (laiocb->ret != -EINPROGRESS)\n\n return;\n\n\n\n /*\n\n * Note that as of Linux 2.6.31 neither the block device code nor any\n\n * filesystem implements cancellation of AIO request.\n\n * Thus the polling loop below is the normal code path.\n\n */\n\n ret = io_cancel(laiocb->ctx->ctx, &laiocb->iocb, &event);\n\n if (ret == 0) {\n\n laiocb->ret = -ECANCELED;\n\n return;\n\n }\n\n\n\n /*\n\n * We have to wait for the iocb to finish.\n\n *\n\n * The only way to get the iocb status update is by polling the io context.\n\n * We might be able to do this slightly more optimal by removing the\n\n * O_NONBLOCK flag.\n\n */\n\n while (laiocb->ret == -EINPROGRESS) {\n\n qemu_laio_completion_cb(&laiocb->ctx->e);\n\n }\n\n}\n", + "output": "1", + "index": 16715 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtas_get_time_of_day(PowerPCCPU *cpu, 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 struct tm tm;\n\n\n\n if (nret != 8) {\n\n rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);\n\n return;\n\n }\n\n\n\n qemu_get_timedate(&tm, spapr->rtc_offset);\n\n\n\n rtas_st(rets, 0, RTAS_OUT_SUCCESS);\n\n rtas_st(rets, 1, tm.tm_year + 1900);\n\n rtas_st(rets, 2, tm.tm_mon + 1);\n\n rtas_st(rets, 3, tm.tm_mday);\n\n rtas_st(rets, 4, tm.tm_hour);\n\n rtas_st(rets, 5, tm.tm_min);\n\n rtas_st(rets, 6, tm.tm_sec);\n\n rtas_st(rets, 7, 0); /* we don't do nanoseconds */\n\n}\n", + "output": "1", + "index": 10104 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug)\n\n{\n\n struct qemu_laio_state *s = aio_ctx;\n\n\n\n assert(s->io_q.plugged > 0 || !unplug);\n\n\n\n if (unplug && --s->io_q.plugged > 0) {\n\n return;\n\n }\n\n\n\n if (!s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {\n\n ioq_submit(s);\n\n }\n\n}\n", + "output": "0", + "index": 16153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void i440fx_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 = i440fx_initfn;\n\n k->config_write = i440fx_write_config;\n\n k->vendor_id = PCI_VENDOR_ID_INTEL;\n\n k->device_id = PCI_DEVICE_ID_INTEL_82441;\n\n k->revision = 0x02;\n\n k->class_id = PCI_CLASS_BRIDGE_HOST;\n\n dc->desc = \"Host bridge\";\n\n dc->no_user = 1;\n\n dc->vmsd = &vmstate_i440fx;\n\n}\n", + "output": "1", + "index": 133 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int fill_note_info(struct elf_note_info *info,\n\n long signr, const CPUState *env)\n\n{\n\n#define NUMNOTES 3\n\n CPUState *cpu = NULL;\n\n TaskState *ts = (TaskState *)env->opaque;\n\n int i;\n\n\n\n (void) memset(info, 0, sizeof (*info));\n\n\n\n TAILQ_INIT(&info->thread_list);\n\n\n\n info->notes = qemu_mallocz(NUMNOTES * sizeof (struct memelfnote));\n\n if (info->notes == NULL)\n\n return (-ENOMEM);\n\n info->prstatus = qemu_mallocz(sizeof (*info->prstatus));\n\n if (info->prstatus == NULL)\n\n return (-ENOMEM);\n\n info->psinfo = qemu_mallocz(sizeof (*info->psinfo));\n\n if (info->prstatus == NULL)\n\n return (-ENOMEM);\n\n\n\n /*\n\n * First fill in status (and registers) of current thread\n\n * including process info & aux vector.\n\n */\n\n fill_prstatus(info->prstatus, ts, signr);\n\n elf_core_copy_regs(&info->prstatus->pr_reg, env);\n\n fill_note(&info->notes[0], \"CORE\", NT_PRSTATUS,\n\n sizeof (*info->prstatus), info->prstatus);\n\n fill_psinfo(info->psinfo, ts);\n\n fill_note(&info->notes[1], \"CORE\", NT_PRPSINFO,\n\n sizeof (*info->psinfo), info->psinfo);\n\n fill_auxv_note(&info->notes[2], ts);\n\n info->numnote = 3;\n\n\n\n info->notes_size = 0;\n\n for (i = 0; i < info->numnote; i++)\n\n info->notes_size += note_size(&info->notes[i]);\n\n\n\n /* read and fill status of all threads */\n\n cpu_list_lock();\n\n for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {\n\n if (cpu == thread_env)\n\n continue;\n\n fill_thread_info(info, cpu);\n\n }\n\n cpu_list_unlock();\n\n\n\n return (0);\n\n}\n", + "output": "0", + "index": 17247 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unset_dirty_tracking(void)\n\n{\n\n BlkMigDevState *bmds;\n\n\n\n QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {\n\n bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap);\n\n }\n\n}\n", + "output": "1", + "index": 11212 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void escaped_string(void)\n\n{\n\n int i;\n\n struct {\n\n const char *encoded;\n\n const char *decoded;\n\n int skip;\n\n } test_cases[] = {\n\n { \"\\\"\\\\b\\\"\", \"\\b\" },\n\n { \"\\\"\\\\f\\\"\", \"\\f\" },\n\n { \"\\\"\\\\n\\\"\", \"\\n\" },\n\n { \"\\\"\\\\r\\\"\", \"\\r\" },\n\n { \"\\\"\\\\t\\\"\", \"\\t\" },\n\n { \"\\\"/\\\"\", \"/\" },\n\n { \"\\\"\\\\/\\\"\", \"/\", .skip = 1 },\n\n { \"\\\"\\\\\\\\\\\"\", \"\\\\\" },\n\n { \"\\\"\\\\\\\"\\\"\", \"\\\"\" },\n\n { \"\\\"hello world \\\\\\\"embedded string\\\\\\\"\\\"\",\n\n \"hello world \\\"embedded string\\\"\" },\n\n { \"\\\"hello world\\\\nwith new line\\\"\", \"hello world\\nwith new line\" },\n\n { \"\\\"single byte utf-8 \\\\u0020\\\"\", \"single byte utf-8 \", .skip = 1 },\n\n { \"\\\"double byte utf-8 \\\\u00A2\\\"\", \"double byte utf-8 \\xc2\\xa2\" },\n\n { \"\\\"triple byte utf-8 \\\\u20AC\\\"\", \"triple byte utf-8 \\xe2\\x82\\xac\" },\n\n { \"'\\\\b'\", \"\\b\", .skip = 1 },\n\n { \"'\\\\f'\", \"\\f\", .skip = 1 },\n\n { \"'\\\\n'\", \"\\n\", .skip = 1 },\n\n { \"'\\\\r'\", \"\\r\", .skip = 1 },\n\n { \"'\\\\t'\", \"\\t\", .skip = 1 },\n\n { \"'\\\\/'\", \"/\", .skip = 1 },\n\n { \"'\\\\\\\\'\", \"\\\\\", .skip = 1 },\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 str = qobject_to_qstring(obj);\n\n g_assert(str);\n\n g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].decoded);\n\n\n\n if (test_cases[i].skip == 0) {\n\n str = qobject_to_json(obj);\n\n g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].encoded);\n\n qobject_decref(obj);\n\n }\n\n\n\n QDECREF(str);\n\n }\n\n}\n", + "output": "1", + "index": 7683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *av_malloc(size_t size)\n\n{\n\n void *ptr = NULL;\n\n#if CONFIG_MEMALIGN_HACK\n\n long diff;\n\n#endif\n\n\n\n /* let's disallow possible ambiguous cases */\n\n if(size > (INT_MAX-32) )\n\n return NULL;\n\n\n\n#if CONFIG_MEMALIGN_HACK\n\n ptr = malloc(size+32);\n\n if(!ptr)\n\n return ptr;\n\n diff= ((-(long)ptr - 1)&31) + 1;\n\n ptr = (char*)ptr + diff;\n\n ((char*)ptr)[-1]= diff;\n\n#elif HAVE_POSIX_MEMALIGN\n\n if (posix_memalign(&ptr,32,size))\n\n ptr = NULL;\n\n#elif HAVE_MEMALIGN\n\n ptr = memalign(32,size);\n\n /* Why 64?\n\n Indeed, we should align it:\n\n on 4 for 386\n\n on 16 for 486\n\n on 32 for 586, PPro - K6-III\n\n on 64 for K7 (maybe for P3 too).\n\n Because L1 and L2 caches are aligned on those values.\n\n But I don't want to code such logic here!\n\n */\n\n /* Why 32?\n\n For AVX ASM. SSE / NEON needs only 16.\n\n Why not larger? Because I did not see a difference in benchmarks ...\n\n */\n\n /* benchmarks with P3\n\n memalign(64)+1 3071,3051,3032\n\n memalign(64)+2 3051,3032,3041\n\n memalign(64)+4 2911,2896,2915\n\n memalign(64)+8 2545,2554,2550\n\n memalign(64)+16 2543,2572,2563\n\n memalign(64)+32 2546,2545,2571\n\n memalign(64)+64 2570,2533,2558\n\n\n\n BTW, malloc seems to do 8-byte alignment by default here.\n\n */\n\n#else\n\n ptr = malloc(size);\n\n#endif\n\n return ptr;\n\n}\n", + "output": "1", + "index": 23196 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int omap_intc_init(SysBusDevice *sbd)\n\n{\n\n DeviceState *dev = DEVICE(sbd);\n\n struct omap_intr_handler_s *s = OMAP_INTC(dev);\n\n\n\n if (!s->iclk) {\n\n hw_error(\"omap-intc: clk not connected\\n\");\n\n }\n\n s->nbanks = 1;\n\n sysbus_init_irq(sbd, &s->parent_intr[0]);\n\n sysbus_init_irq(sbd, &s->parent_intr[1]);\n\n qdev_init_gpio_in(dev, omap_set_intr, s->nbanks * 32);\n\n memory_region_init_io(&s->mmio, OBJECT(s), &omap_inth_mem_ops, s,\n\n \"omap-intc\", s->size);\n\n sysbus_init_mmio(sbd, &s->mmio);\n\n return 0;\n\n}\n", + "output": "1", + "index": 1643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ftp_connect_data_connection(URLContext *h)\n\n{\n\n int err;\n\n char buf[CONTROL_BUFFER_SIZE], opts_format[20];\n\n AVDictionary *opts = NULL;\n\n FTPContext *s = h->priv_data;\n\n\n\n if (!s->conn_data) {\n\n /* Enter passive mode */\n\n if ((err = ftp_passive_mode(s)) < 0) {\n\n av_dlog(h, \"Set passive mode failed\\n\");\n\n return err;\n\n }\n\n /* Open data connection */\n\n ff_url_join(buf, sizeof(buf), \"tcp\", NULL, s->hostname, s->server_data_port, NULL);\n\n if (s->rw_timeout != -1) {\n\n snprintf(opts_format, sizeof(opts_format), \"%d\", s->rw_timeout);\n\n av_dict_set(&opts, \"timeout\", opts_format, 0);\n\n } /* if option is not given, don't pass it and let tcp use its own default */\n\n err = ffurl_open(&s->conn_data, buf, AVIO_FLAG_READ_WRITE,\n\n &h->interrupt_callback, &opts);\n\n av_dict_free(&opts);\n\n if (err < 0)\n\n return err;\n\n\n\n if (s->position)\n\n if ((err = ftp_restart(s, s->position)) < 0)\n\n return err;\n\n }\n\n s->state = READY;\n\n return 0;\n\n}\n", + "output": "0", + "index": 19569 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AioContext *aio_context_new(void)\n\n{\n\n AioContext *ctx;\n\n ctx = (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioContext));\n\n ctx->pollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));\n\n ctx->thread_pool = NULL;\n\n qemu_mutex_init(&ctx->bh_lock);\n\n rfifolock_init(&ctx->lock, aio_rfifolock_cb, ctx);\n\n event_notifier_init(&ctx->notifier, false);\n\n aio_set_event_notifier(ctx, &ctx->notifier, \n\n (EventNotifierHandler *)\n\n event_notifier_test_and_clear);\n\n timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx);\n\n\n\n return ctx;\n\n}\n", + "output": "1", + "index": 7512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "build_gtdt(GArray *table_data, GArray *linker)\n\n{\n\n int gtdt_start = table_data->len;\n\n AcpiGenericTimerTable *gtdt;\n\n\n\n gtdt = acpi_data_push(table_data, sizeof *gtdt);\n\n /* The interrupt values are the same with the device tree when adding 16 */\n\n gtdt->secure_el1_interrupt = ARCH_TIMER_S_EL1_IRQ + 16;\n\n gtdt->secure_el1_flags = ACPI_EDGE_SENSITIVE;\n\n\n\n gtdt->non_secure_el1_interrupt = ARCH_TIMER_NS_EL1_IRQ + 16;\n\n gtdt->non_secure_el1_flags = ACPI_EDGE_SENSITIVE;\n\n\n\n gtdt->virtual_timer_interrupt = ARCH_TIMER_VIRT_IRQ + 16;\n\n gtdt->virtual_timer_flags = ACPI_EDGE_SENSITIVE;\n\n\n\n gtdt->non_secure_el2_interrupt = ARCH_TIMER_NS_EL2_IRQ + 16;\n\n gtdt->non_secure_el2_flags = ACPI_EDGE_SENSITIVE;\n\n\n\n build_header(linker, table_data,\n\n (void *)(table_data->data + gtdt_start), \"GTDT\",\n\n table_data->len - gtdt_start, 2, NULL);\n\n}\n", + "output": "0", + "index": 4219 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pcnet_aprom_writeb(void *opaque, uint32_t addr, uint32_t val)\n\n{\n\n PCNetState *s = opaque;\n\n#ifdef PCNET_DEBUG\n\n printf(\"pcnet_aprom_writeb addr=0x%08x val=0x%02x\\n\", addr, val);\n\n#endif\n\n /* Check APROMWE bit to enable write access */\n\n if (pcnet_bcr_readw(s,2) & 0x100)\n\n s->prom[addr & 15] = val;\n\n}\n", + "output": "0", + "index": 9677 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kalman_smoothen(WMAVoiceContext *s, int pitch,\n\n const float *in, float *out, int size)\n\n{\n\n int n;\n\n float optimal_gain = 0, dot;\n\n const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)],\n\n *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)],\n\n *best_hist_ptr;\n\n\n\n /* find best fitting point in history */\n\n do {\n\n dot = ff_scalarproduct_float_c(in, ptr, size);\n\n if (dot > optimal_gain) {\n\n optimal_gain = dot;\n\n best_hist_ptr = ptr;\n\n }\n\n } while (--ptr >= end);\n\n\n\n if (optimal_gain <= 0)\n\n return -1;\n\n dot = ff_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);\n\n if (dot <= 0) // would be 1.0\n\n return -1;\n\n\n\n if (optimal_gain <= dot) {\n\n dot = dot / (dot + 0.6 * optimal_gain); // 0.625-1.000\n\n } else\n\n dot = 0.625;\n\n\n\n /* actual smoothing */\n\n for (n = 0; n < size; n++)\n\n out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 7894 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void compare_pri_rs_finalize(SocketReadState *pri_rs)\n\n{\n\n CompareState *s = container_of(pri_rs, CompareState, pri_rs);\n\n\n\n if (packet_enqueue(s, PRIMARY_IN)) {\n\n trace_colo_compare_main(\"primary: unsupported packet in\");\n\n compare_chr_send(s,\n\n pri_rs->buf,\n\n pri_rs->packet_len,\n\n pri_rs->vnet_hdr_len);\n\n } else {\n\n /* compare connection */\n\n g_queue_foreach(&s->conn_list, colo_compare_connection, s);\n\n }\n\n}\n", + "output": "0", + "index": 23238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData *aiocb)\n\n{\n\n int ret = -EOPNOTSUPP;\n\n BDRVRawState *s = aiocb->bs->opaque;\n\n\n\n if (s->has_write_zeroes == 0) {\n\n return -ENOTSUP;\n\n }\n\n\n\n if (aiocb->aio_type & QEMU_AIO_BLKDEV) {\n\n#ifdef BLKZEROOUT\n\n do {\n\n uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };\n\n if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {\n\n return 0;\n\n }\n\n } while (errno == EINTR);\n\n\n\n ret = -errno;\n\n#endif\n\n } else {\n\n#ifdef CONFIG_XFS\n\n if (s->is_xfs) {\n\n return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes);\n\n }\n\n#endif\n\n }\n\n\n\n ret = translate_err(ret);\n\n if (ret == -ENOTSUP) {\n\n s->has_write_zeroes = false;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 27252 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int htab_save_setup(QEMUFile *f, void *opaque)\n\n{\n\n sPAPRMachineState *spapr = opaque;\n\n\n\n /* \"Iteration\" header */\n\n qemu_put_be32(f, spapr->htab_shift);\n\n\n\n if (spapr->htab) {\n\n spapr->htab_save_index = 0;\n\n spapr->htab_first_pass = true;\n\n } else {\n\n assert(kvm_enabled());\n\n\n\n spapr->htab_fd = kvmppc_get_htab_fd(false);\n\n spapr->htab_fd_stale = false;\n\n if (spapr->htab_fd < 0) {\n\n fprintf(stderr, \"Unable to open fd for reading hash table from KVM: %s\\n\",\n\n strerror(errno));\n\n return -1;\n\n }\n\n }\n\n\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 20366 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virt_class_init(ObjectClass *oc, void *data)\n\n{\n\n MachineClass *mc = MACHINE_CLASS(oc);\n\n\n\n mc->desc = \"ARM Virtual Machine\",\n\n mc->init = machvirt_init;\n\n mc->max_cpus = 8;\n\n mc->has_dynamic_sysbus = true;\n\n mc->block_default_type = IF_VIRTIO;\n\n mc->no_cdrom = 1;\n\n}\n", + "output": "0", + "index": 16584 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t uart_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n LM32UartState *s = opaque;\n\n uint32_t r = 0;\n\n\n\n addr >>= 2;\n\n switch (addr) {\n\n case R_RXTX:\n\n r = s->regs[R_RXTX];\n\n s->regs[R_LSR] &= ~LSR_DR;\n\n uart_update_irq(s);\n\n break;\n\n case R_IIR:\n\n case R_LSR:\n\n case R_MSR:\n\n r = s->regs[addr];\n\n break;\n\n case R_IER:\n\n case R_LCR:\n\n case R_MCR:\n\n case R_DIV:\n\n error_report(\"lm32_uart: read access to write only register 0x\"\n\n TARGET_FMT_plx, addr << 2);\n\n break;\n\n default:\n\n error_report(\"lm32_uart: read access to unknown register 0x\"\n\n TARGET_FMT_plx, addr << 2);\n\n break;\n\n }\n\n\n\n trace_lm32_uart_memory_read(addr << 2, r);\n\n return r;\n\n}\n", + "output": "0", + "index": 6855 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void portio_list_add(PortioList *piolist,\n\n MemoryRegion *address_space,\n\n uint32_t start)\n\n{\n\n const MemoryRegionPortio *pio, *pio_start = piolist->ports;\n\n unsigned int off_low, off_high, off_last, count;\n\n\n\n piolist->address_space = address_space;\n\n\n\n /* Handle the first entry specially. */\n\n off_last = off_low = pio_start->offset;\n\n off_high = off_low + pio_start->len;\n\n count = 1;\n\n\n\n for (pio = pio_start + 1; pio->size != 0; pio++, count++) {\n\n /* All entries must be sorted by offset. */\n\n assert(pio->offset >= off_last);\n\n off_last = pio->offset;\n\n\n\n /* If we see a hole, break the region. */\n\n if (off_last > off_high) {\n\n portio_list_add_1(piolist, pio_start, count, start, off_low,\n\n off_high);\n\n /* ... and start collecting anew. */\n\n pio_start = pio;\n\n off_low = off_last;\n\n off_high = off_low + pio->len;\n\n count = 0;\n\n } else if (off_last + pio->len > off_high) {\n\n off_high = off_last + pio->len;\n\n }\n\n }\n\n\n\n /* There will always be an open sub-list. */\n\n portio_list_add_1(piolist, pio_start, count, start, off_low, off_high);\n\n}\n", + "output": "0", + "index": 24178 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)\n\n{\n\n int len, 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 if (code & 0x80) {\n\n len = code - 0x7F;\n\n memset(dst, *src++, FFMIN(len, dst_end - dst));\n\n } else {\n\n len = code + 1;\n\n memcpy(dst, src, FFMIN(len, dst_end - dst));\n\n src += len;\n\n }\n\n dst += len;\n\n }\n\n}\n", + "output": "1", + "index": 922 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)\n\n{\n\n int n, n4, i;\n\n double alpha, theta;\n\n int tstep;\n\n\n\n memset(s, 0, sizeof(*s));\n\n n = 1 << nbits;\n\n s->mdct_bits = nbits;\n\n s->mdct_size = n;\n\n n4 = n >> 2;\n\n s->permutation = FF_MDCT_PERM_NONE;\n\n\n\n if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)\n\n goto fail;\n\n\n\n s->tcos = av_malloc(n/2 * sizeof(FFTSample));\n\n if (!s->tcos)\n\n goto fail;\n\n\n\n switch (s->permutation) {\n\n case FF_MDCT_PERM_NONE:\n\n s->tsin = s->tcos + n4;\n\n tstep = 1;\n\n break;\n\n case FF_MDCT_PERM_INTERLEAVE:\n\n s->tsin = s->tcos + 1;\n\n tstep = 2;\n\n break;\n\n default:\n\n goto fail;\n\n }\n\n\n\n theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);\n\n scale = sqrt(fabs(scale));\n\n for(i=0;itcos[i*tstep] = -cos(alpha) * scale;\n\n s->tsin[i*tstep] = -sin(alpha) * scale;\n\n }\n\n return 0;\n\n fail:\n\n ff_mdct_end(s);\n\n return -1;\n\n}\n", + "output": "0", + "index": 13079 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)\n\n{\n\n CompandContext *s = ctx->priv;\n\n AVFilterLink *inlink = ctx->inputs[0];\n\n const int channels = inlink->channels;\n\n const int nb_samples = frame->nb_samples;\n\n AVFrame *out_frame;\n\n int chan, i;\n\n\n\n if (av_frame_is_writable(frame)) {\n\n out_frame = frame;\n\n } else {\n\n out_frame = ff_get_audio_buffer(inlink, nb_samples);\n\n if (!out_frame)\n\n return AVERROR(ENOMEM);\n\n av_frame_copy_props(out_frame, frame);\n\n }\n\n\n\n for (chan = 0; chan < channels; chan++) {\n\n const double *src = (double *)frame->extended_data[chan];\n\n double *dst = (double *)out_frame->extended_data[chan];\n\n ChanParam *cp = &s->channels[chan];\n\n\n\n for (i = 0; i < nb_samples; i++) {\n\n update_volume(cp, fabs(src[i]));\n\n\n\n dst[i] = av_clipd(src[i] * get_volume(s, cp->volume), -1, 1);\n\n }\n\n }\n\n\n\n if (frame != out_frame)\n\n av_frame_free(&frame);\n\n\n\n return ff_filter_frame(ctx->outputs[0], out_frame);\n\n}\n", + "output": "1", + "index": 970 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nvram_writel (void *opaque, target_phys_addr_t addr, uint32_t value)\n\n{\n\n M48t59State *NVRAM = opaque;\n\n\n\n m48t59_write(NVRAM, addr, (value >> 24) & 0xff);\n\n m48t59_write(NVRAM, addr + 1, (value >> 16) & 0xff);\n\n m48t59_write(NVRAM, addr + 2, (value >> 8) & 0xff);\n\n m48t59_write(NVRAM, addr + 3, value & 0xff);\n\n}\n", + "output": "0", + "index": 10188 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void blk_dev_change_media_cb(BlockBackend *blk, bool load)\n\n{\n\n if (blk->dev_ops && blk->dev_ops->change_media_cb) {\n\n bool tray_was_closed = !blk_dev_is_tray_open(blk);\n\n\n\n blk->dev_ops->change_media_cb(blk->dev_opaque, load);\n\n if (tray_was_closed) {\n\n /* tray open */\n\n qapi_event_send_device_tray_moved(blk_name(blk),\n\n true, &error_abort);\n\n }\n\n if (load) {\n\n /* tray close */\n\n qapi_event_send_device_tray_moved(blk_name(blk),\n\n false, &error_abort);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 10482 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Visitor *validate_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 v = validate_test_init_internal(data, json_string, &ap);\n\n va_end(ap);\n\n return v;\n\n}\n", + "output": "0", + "index": 8764 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max)\n\n{\n\n uint8_t key[6];\n\n int idx = qdict_size(palette);\n\n bool present;\n\n\n\n tight_palette_rgb2buf(rgb, bpp, key);\n\n present = qdict_haskey(palette, (char *)key);\n\n if (idx >= max && !present) {\n\n return 0;\n\n }\n\n if (!present) {\n\n qdict_put(palette, (char *)key, qint_from_int(idx));\n\n }\n\n return qdict_size(palette);\n\n}\n", + "output": "0", + "index": 9947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry,\n\n int nb_clusters, enum qcow2_discard_type type)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n\n\n switch (qcow2_get_cluster_type(l2_entry)) {\n\n case QCOW2_CLUSTER_COMPRESSED:\n\n {\n\n int nb_csectors;\n\n nb_csectors = ((l2_entry >> s->csize_shift) &\n\n s->csize_mask) + 1;\n\n qcow2_free_clusters(bs,\n\n (l2_entry & s->cluster_offset_mask) & ~511,\n\n nb_csectors * 512, type);\n\n }\n\n break;\n\n case QCOW2_CLUSTER_NORMAL:\n\n case QCOW2_CLUSTER_ZERO:\n\n if (l2_entry & L2E_OFFSET_MASK) {\n\n if (offset_into_cluster(s, l2_entry & L2E_OFFSET_MASK)) {\n\n qcow2_signal_corruption(bs, false, -1, -1,\n\n \"Cannot free unaligned cluster %#llx\",\n\n l2_entry & L2E_OFFSET_MASK);\n\n } else {\n\n qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK,\n\n nb_clusters << s->cluster_bits, type);\n\n }\n\n }\n\n break;\n\n case QCOW2_CLUSTER_UNALLOCATED:\n\n break;\n\n default:\n\n abort();\n\n }\n\n}\n", + "output": "0", + "index": 4627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int walk_memory_regions_1(struct walk_memory_regions_data *data,\n\n abi_ulong base, int level, void **lp)\n\n{\n\n abi_ulong pa;\n\n int i, rc;\n\n\n\n if (*lp == NULL) {\n\n return walk_memory_regions_end(data, base, 0);\n\n }\n\n\n\n if (level == 0) {\n\n PageDesc *pd = *lp;\n\n\n\n for (i = 0; i < L2_SIZE; ++i) {\n\n int prot = pd[i].flags;\n\n\n\n pa = base | (i << TARGET_PAGE_BITS);\n\n if (prot != data->prot) {\n\n rc = walk_memory_regions_end(data, pa, prot);\n\n if (rc != 0) {\n\n return rc;\n\n }\n\n }\n\n }\n\n } else {\n\n void **pp = *lp;\n\n\n\n for (i = 0; i < L2_SIZE; ++i) {\n\n pa = base | ((abi_ulong)i <<\n\n (TARGET_PAGE_BITS + L2_BITS * level));\n\n rc = walk_memory_regions_1(data, pa, level - 1, pp + i);\n\n if (rc != 0) {\n\n return rc;\n\n }\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_debug_gnutls_log(int level, const char* str) {\n\n VNC_DEBUG(\"%d %s\", level, str);\n\n}\n", + "output": "0", + "index": 11315 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void migration_bitmap_sync(void)\n\n{\n\n uint64_t num_dirty_pages_init = ram_list.dirty_pages;\n\n\n\n trace_migration_bitmap_sync_start();\n\n memory_global_sync_dirty_bitmap(get_system_memory());\n\n trace_migration_bitmap_sync_end(ram_list.dirty_pages\n\n - num_dirty_pages_init);\n\n}\n", + "output": "0", + "index": 4189 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int y41p_decode_frame(AVCodecContext *avctx, void *data,\n\n int *got_frame, AVPacket *avpkt)\n\n{\n\n AVFrame *pic = data;\n\n uint8_t *src = avpkt->data;\n\n uint8_t *y, *u, *v;\n\n int i, j, ret;\n\n\n\n if (avpkt->size < 3LL * avctx->height * avctx->width / 2) {\n\n av_log(avctx, AV_LOG_ERROR, \"Insufficient input data.\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)\n\n return ret;\n\n\n\n pic->key_frame = 1;\n\n pic->pict_type = AV_PICTURE_TYPE_I;\n\n\n\n for (i = avctx->height - 1; i >= 0 ; i--) {\n\n y = &pic->data[0][i * pic->linesize[0]];\n\n u = &pic->data[1][i * pic->linesize[1]];\n\n v = &pic->data[2][i * pic->linesize[2]];\n\n for (j = 0; j < avctx->width; j += 8) {\n\n *(u++) = *src++;\n\n *(y++) = *src++;\n\n *(v++) = *src++;\n\n *(y++) = *src++;\n\n\n\n *(u++) = *src++;\n\n *(y++) = *src++;\n\n *(v++) = *src++;\n\n *(y++) = *src++;\n\n\n\n *(y++) = *src++;\n\n *(y++) = *src++;\n\n *(y++) = *src++;\n\n *(y++) = *src++;\n\n }\n\n }\n\n\n\n *got_frame = 1;\n\n\n\n return avpkt->size;\n\n}\n", + "output": "1", + "index": 8446 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qio_channel_websock_source_check(GSource *source)\n\n{\n\n QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)source;\n\n GIOCondition cond = 0;\n\n\n\n if (wsource->wioc->rawinput.offset) {\n\n cond |= G_IO_IN;\n\n }\n\n if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {\n\n cond |= G_IO_OUT;\n\n }\n\n\n\n return cond & wsource->condition;\n\n}\n", + "output": "1", + "index": 4088 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_client_init(BlockDriverState *bs,\n\n QIOChannelSocket *sioc,\n\n const char *export,\n\n QCryptoTLSCreds *tlscreds,\n\n const char *hostname,\n\n Error **errp)\n\n{\n\n NbdClientSession *client = nbd_get_client_session(bs);\n\n int ret;\n\n\n\n /* NBD handshake */\n\n logout(\"session init %s\\n\", export);\n\n qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL);\n\n\n\n ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), export,\n\n &client->nbdflags,\n\n tlscreds, hostname,\n\n &client->ioc,\n\n &client->size, errp);\n\n if (ret < 0) {\n\n logout(\"Failed to negotiate with the NBD server\\n\");\n\n return ret;\n\n }\n\n if (client->nbdflags & NBD_FLAG_SEND_FUA) {\n\n bs->supported_write_flags = BDRV_REQ_FUA;\n\n }\n\n\n\n qemu_co_mutex_init(&client->send_mutex);\n\n qemu_co_mutex_init(&client->free_sema);\n\n client->sioc = sioc;\n\n object_ref(OBJECT(client->sioc));\n\n\n\n if (!client->ioc) {\n\n client->ioc = QIO_CHANNEL(sioc);\n\n object_ref(OBJECT(client->ioc));\n\n }\n\n\n\n /* Now that we're connected, set the socket to be non-blocking and\n\n * kick the reply mechanism. */\n\n qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);\n\n\n\n nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));\n\n\n\n logout(\"Established connection with NBD server\\n\");\n\n return 0;\n\n}\n", + "output": "1", + "index": 13910 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "vu_queue_fill(VuDev *dev, VuVirtq *vq,\n\n const VuVirtqElement *elem,\n\n unsigned int len, unsigned int idx)\n\n{\n\n struct vring_used_elem uelem;\n\n\n\n if (unlikely(dev->broken)) {\n\n return;\n\n }\n\n\n\n vu_log_queue_fill(dev, vq, elem, len);\n\n\n\n idx = (idx + vq->used_idx) % vq->vring.num;\n\n\n\n uelem.id = elem->index;\n\n uelem.len = len;\n\n vring_used_write(dev, vq, &uelem, idx);\n\n}\n", + "output": "1", + "index": 8114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avg_width8_msa(src, stride, dst, stride, 8);\n\n}\n", + "output": "0", + "index": 1812 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_desc_attach(USBDevice *dev)\n\n{\n\n const USBDesc *desc = usb_device_get_usb_desc(dev);\n\n\n\n assert(desc != NULL);\n\n if (desc->super && (dev->port->speedmask & USB_SPEED_MASK_SUPER)) {\n\n dev->speed = USB_SPEED_SUPER;\n\n } else if (desc->high && (dev->port->speedmask & USB_SPEED_MASK_HIGH)) {\n\n dev->speed = USB_SPEED_HIGH;\n\n } else if (desc->full && (dev->port->speedmask & USB_SPEED_MASK_FULL)) {\n\n dev->speed = USB_SPEED_FULL;\n\n } else {\n\n return;\n\n }\n\n usb_desc_setdefaults(dev);\n\n}\n", + "output": "0", + "index": 14964 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nfs_co_generic_bh_cb(void *opaque)\n\n{\n\n NFSRPC *task = opaque;\n\n task->complete = 1;\n\n qemu_bh_delete(task->bh);\n\n qemu_coroutine_enter(task->co, NULL);\n\n}\n", + "output": "1", + "index": 5976 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ide_qdev_init(DeviceState *qdev)\n\n{\n\n IDEDevice *dev = IDE_DEVICE(qdev);\n\n IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev);\n\n IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);\n\n\n\n if (!dev->conf.bs) {\n\n error_report(\"No drive specified\");\n\n goto err;\n\n }\n\n if (dev->unit == -1) {\n\n dev->unit = bus->master ? 1 : 0;\n\n }\n\n\n\n if (dev->unit >= bus->max_units) {\n\n error_report(\"Can't create IDE unit %d, bus supports only %d units\",\n\n dev->unit, bus->max_units);\n\n goto err;\n\n }\n\n\n\n switch (dev->unit) {\n\n case 0:\n\n if (bus->master) {\n\n error_report(\"IDE unit %d is in use\", dev->unit);\n\n goto err;\n\n }\n\n bus->master = dev;\n\n break;\n\n case 1:\n\n if (bus->slave) {\n\n error_report(\"IDE unit %d is in use\", dev->unit);\n\n goto err;\n\n }\n\n bus->slave = dev;\n\n break;\n\n default:\n\n error_report(\"Invalid IDE unit %d\", dev->unit);\n\n goto err;\n\n }\n\n return dc->init(dev);\n\n\n\nerr:\n\n return -1;\n\n}\n", + "output": "0", + "index": 3929 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int win_chr_pipe_init(CharDriverState *chr, const char *filename,\n\n Error **errp)\n\n{\n\n WinCharState *s = chr->opaque;\n\n OVERLAPPED ov;\n\n int ret;\n\n DWORD size;\n\n char openname[CHR_MAX_FILENAME_SIZE];\n\n\n\n s->fpipe = TRUE;\n\n\n\n s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);\n\n if (!s->hsend) {\n\n error_setg(errp, \"Failed CreateEvent\");\n\n goto fail;\n\n }\n\n s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);\n\n if (!s->hrecv) {\n\n error_setg(errp, \"Failed CreateEvent\");\n\n goto fail;\n\n }\n\n\n\n snprintf(openname, sizeof(openname), \"\\\\\\\\.\\\\pipe\\\\%s\", filename);\n\n s->hcom = CreateNamedPipe(openname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,\n\n PIPE_TYPE_BYTE | PIPE_READMODE_BYTE |\n\n PIPE_WAIT,\n\n MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);\n\n if (s->hcom == INVALID_HANDLE_VALUE) {\n\n error_setg(errp, \"Failed CreateNamedPipe (%lu)\", GetLastError());\n\n s->hcom = NULL;\n\n goto fail;\n\n }\n\n\n\n ZeroMemory(&ov, sizeof(ov));\n\n ov.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);\n\n ret = ConnectNamedPipe(s->hcom, &ov);\n\n if (ret) {\n\n error_setg(errp, \"Failed ConnectNamedPipe\");\n\n goto fail;\n\n }\n\n\n\n ret = GetOverlappedResult(s->hcom, &ov, &size, TRUE);\n\n if (!ret) {\n\n error_setg(errp, \"Failed GetOverlappedResult\");\n\n if (ov.hEvent) {\n\n CloseHandle(ov.hEvent);\n\n ov.hEvent = NULL;\n\n }\n\n goto fail;\n\n }\n\n\n\n if (ov.hEvent) {\n\n CloseHandle(ov.hEvent);\n\n ov.hEvent = NULL;\n\n }\n\n qemu_add_polling_cb(win_chr_pipe_poll, chr);\n\n return 0;\n\n\n\n fail:\n\n win_chr_close(chr);\n\n return -1;\n\n}\n", + "output": "0", + "index": 5563 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,\n\n BdrvCheckMode fix, uint16_t **refcount_table,\n\n int64_t *nb_clusters)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int64_t i;\n\n QCowSnapshot *sn;\n\n int ret;\n\n\n\n *refcount_table = g_try_new0(uint16_t, *nb_clusters);\n\n if (*nb_clusters && *refcount_table == NULL) {\n\n res->check_errors++;\n\n return -ENOMEM;\n\n }\n\n\n\n /* header */\n\n ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters,\n\n 0, s->cluster_size);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n /* current L1 table */\n\n ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters,\n\n s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n /* snapshots */\n\n for (i = 0; i < s->nb_snapshots; i++) {\n\n sn = s->snapshots + i;\n\n ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters,\n\n sn->l1_table_offset, sn->l1_size, 0);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n }\n\n ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters,\n\n s->snapshots_offset, s->snapshots_size);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n /* refcount data */\n\n ret = inc_refcounts(bs, res, *refcount_table, *nb_clusters,\n\n s->refcount_table_offset,\n\n s->refcount_table_size * sizeof(uint64_t));\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n return check_refblocks(bs, res, fix, refcount_table, nb_clusters);\n\n}\n", + "output": "0", + "index": 56 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void adaptive_gain_control(float *out, const float *in,\n\n const float *speech_synth,\n\n int size, float alpha, float *gain_mem)\n\n{\n\n int i;\n\n float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor;\n\n float mem = *gain_mem;\n\n\n\n for (i = 0; i < size; i++) {\n\n speech_energy += fabsf(speech_synth[i]);\n\n postfilter_energy += fabsf(in[i]);\n\n }\n\n gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;\n\n\n\n for (i = 0; i < size; i++) {\n\n mem = alpha * mem + gain_scale_factor;\n\n out[i] = in[i] * mem;\n\n }\n\n\n\n *gain_mem = mem;\n\n}\n", + "output": "1", + "index": 1592 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void core_region_nop(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n cpu_register_physical_memory_log(section, section->readonly);\n\n}\n", + "output": "0", + "index": 5041 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 0);\n\n}\n", + "output": "0", + "index": 17169 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_desc_create_serial(USBDevice *dev)\n\n{\n\n DeviceState *hcd = dev->qdev.parent_bus->parent;\n\n const USBDesc *desc = usb_device_get_usb_desc(dev);\n\n int index = desc->id.iSerialNumber;\n\n char serial[64];\n\n char *path;\n\n int dst;\n\n\n\n if (dev->serial) {\n\n /* 'serial' usb bus property has priority if present */\n\n usb_desc_set_string(dev, index, dev->serial);\n\n return;\n\n }\n\n\n\n assert(index != 0 && desc->str[index] != NULL);\n\n dst = snprintf(serial, sizeof(serial), \"%s\", desc->str[index]);\n\n path = qdev_get_dev_path(hcd);\n\n if (path) {\n\n dst += snprintf(serial+dst, sizeof(serial)-dst, \"-%s\", path);\n\n }\n\n dst += snprintf(serial+dst, sizeof(serial)-dst, \"-%s\", dev->port->path);\n\n usb_desc_set_string(dev, index, serial);\n\n\n}", + "output": "1", + "index": 6342 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs,\n\n int64_t sector_num, int nb_sectors, int *pnum)\n\n{\n\n BDRVVmdkState *s = bs->opaque;\n\n int64_t index_in_cluster, n, ret;\n\n uint64_t offset;\n\n VmdkExtent *extent;\n\n\n\n extent = find_extent(s, sector_num, NULL);\n\n if (!extent) {\n\n return 0;\n\n }\n\n qemu_co_mutex_lock(&s->lock);\n\n ret = get_cluster_offset(bs, extent, NULL,\n\n sector_num * 512, false, &offset,\n\n 0, 0);\n\n qemu_co_mutex_unlock(&s->lock);\n\n\n\n switch (ret) {\n\n case VMDK_ERROR:\n\n ret = -EIO;\n\n break;\n\n case VMDK_UNALLOC:\n\n ret = 0;\n\n break;\n\n case VMDK_ZEROED:\n\n ret = BDRV_BLOCK_ZERO;\n\n break;\n\n case VMDK_OK:\n\n ret = BDRV_BLOCK_DATA;\n\n if (extent->file == bs->file && !extent->compressed) {\n\n ret |= BDRV_BLOCK_OFFSET_VALID | offset;\n\n }\n\n\n\n break;\n\n }\n\n\n\n index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);\n\n n = extent->cluster_sectors - index_in_cluster;\n\n if (n > nb_sectors) {\n\n n = nb_sectors;\n\n }\n\n *pnum = n;\n\n return ret;\n\n}\n", + "output": "0", + "index": 22175 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t phys_section_add(MemoryRegionSection *section)\n\n{\n\n /* The physical section number is ORed with a page-aligned\n\n * pointer to produce the iotlb entries. Thus it should\n\n * never overflow into the page-aligned value.\n\n */\n\n assert(next_map.sections_nb < TARGET_PAGE_SIZE);\n\n\n\n if (next_map.sections_nb == next_map.sections_nb_alloc) {\n\n next_map.sections_nb_alloc = MAX(next_map.sections_nb_alloc * 2,\n\n 16);\n\n next_map.sections = g_renew(MemoryRegionSection, next_map.sections,\n\n next_map.sections_nb_alloc);\n\n }\n\n next_map.sections[next_map.sections_nb] = *section;\n\n memory_region_ref(section->mr);\n\n return next_map.sections_nb++;\n\n}\n", + "output": "0", + "index": 18221 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)\n\n{\n\n int dom, bus;\n\n unsigned slot;\n\n\n\n if (!devaddr) {\n\n *devfnp = -1;\n\n return pci_find_bus(0);\n\n }\n\n\n\n if (pci_parse_devaddr(devaddr, &dom, &bus, &slot) < 0) {\n\n return NULL;\n\n }\n\n\n\n *devfnp = slot << 3;\n\n return pci_find_bus(bus);\n\n}\n", + "output": "0", + "index": 12114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int has_altivec(void)\n\n{\n\n#ifdef __AMIGAOS4__\n\n ULONG result = 0;\n\n extern struct ExecIFace *IExec;\n\n\n\n IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);\n\n if (result == VECTORTYPE_ALTIVEC) return 1;\n\n return 0;\n\n#else /* __AMIGAOS4__ */\n\n\n\n#ifdef SYS_DARWIN\n\n int sels[2] = {CTL_HW, HW_VECTORUNIT};\n\n int has_vu = 0;\n\n size_t len = sizeof(has_vu);\n\n int err;\n\n\n\n err = sysctl(sels, 2, &has_vu, &len, NULL, 0);\n\n\n\n if (err == 0) return (has_vu != 0);\n\n#else /* SYS_DARWIN */\n\n/* no Darwin, do it the brute-force way */\n\n/* this is borrowed from the libmpeg2 library */\n\n {\n\n signal (SIGILL, sigill_handler);\n\n if (sigsetjmp (jmpbuf, 1)) {\n\n signal (SIGILL, SIG_DFL);\n\n } else {\n\n canjump = 1;\n\n\n\n asm volatile (\"mtspr 256, %0\\n\\t\"\n\n \"vand %%v0, %%v0, %%v0\"\n\n :\n\n : \"r\" (-1));\n\n\n\n signal (SIGILL, SIG_DFL);\n\n return 1;\n\n }\n\n }\n\n#endif /* SYS_DARWIN */\n\n return 0;\n\n#endif /* __AMIGAOS4__ */\n\n}\n", + "output": "0", + "index": 27231 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_generate_sliding_window_mmcos(H264Context *h) {\n\n MpegEncContext * const s = &h->s;\n\n assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);\n\n\n\n h->mmco_index= 0;\n\n if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&\n\n !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) {\n\n h->mmco[0].opcode= MMCO_SHORT2UNUSED;\n\n h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;\n\n h->mmco_index= 1;\n\n if (FIELD_PICTURE) {\n\n h->mmco[0].short_pic_num *= 2;\n\n h->mmco[1].opcode= MMCO_SHORT2UNUSED;\n\n h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1;\n\n h->mmco_index= 2;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 2428 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rsd_probe(AVProbeData *p)\n\n{\n\n if (!memcmp(p->buf, \"RSD\", 3) &&\n\n p->buf[3] - '0' >= 2 && p->buf[3] - '0' <= 6)\n\n return AVPROBE_SCORE_EXTENSION;\n\n return 0;\n\n}\n", + "output": "1", + "index": 16973 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void blk_mig_cleanup(void)\n\n{\n\n BlkMigDevState *bmds;\n\n BlkMigBlock *blk;\n\n\n\n bdrv_drain_all();\n\n\n\n unset_dirty_tracking();\n\n\n\n blk_mig_lock();\n\n while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {\n\n QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);\n\n bdrv_op_unblock_all(bmds->bs, bmds->blocker);\n\n error_free(bmds->blocker);\n\n bdrv_unref(bmds->bs);\n\n g_free(bmds->aio_bitmap);\n\n g_free(bmds);\n\n }\n\n\n\n while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {\n\n QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);\n\n g_free(blk->buf);\n\n g_free(blk);\n\n }\n\n blk_mig_unlock();\n\n}\n", + "output": "1", + "index": 11720 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size)\n\n{\n\n USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;\n\n struct rndis_packet_msg_type *msg;\n\n\n\n if (is_rndis(s)) {\n\n msg = (struct rndis_packet_msg_type *) s->in_buf;\n\n if (!s->rndis_state == RNDIS_DATA_INITIALIZED)\n\n return -1;\n\n if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))\n\n return -1;\n\n\n\n memset(msg, 0, sizeof(struct rndis_packet_msg_type));\n\n msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);\n\n msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));\n\n msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);\n\n msg->DataLength = cpu_to_le32(size);\n\n /* msg->OOBDataOffset;\n\n * msg->OOBDataLength;\n\n * msg->NumOOBDataElements;\n\n * msg->PerPacketInfoOffset;\n\n * msg->PerPacketInfoLength;\n\n * msg->VcHandle;\n\n * msg->Reserved;\n\n */\n\n memcpy(msg + 1, buf, size);\n\n s->in_len = size + sizeof(struct rndis_packet_msg_type);\n\n } else {\n\n if (size > sizeof(s->in_buf))\n\n return -1;\n\n memcpy(s->in_buf, buf, size);\n\n s->in_len = size;\n\n }\n\n s->in_ptr = 0;\n\n return size;\n\n}\n", + "output": "1", + "index": 27078 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_sbrdsp_init_x86(SBRDSPContext *s)\n\n{\n\n if (HAVE_YASM) {\n\n int mm_flags = av_get_cpu_flags();\n\n\n\n if (mm_flags & AV_CPU_FLAG_SSE) {\n\n s->sum_square = ff_sbr_sum_square_sse;\n\n s->hf_g_filt = ff_sbr_hf_g_filt_sse;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 835 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoul_full_max(void)\n\n{\n\n char *str = g_strdup_printf(\"%lu\", ULONG_MAX);\n\n unsigned long res = 999;\n\n int err;\n\n\n\n err = qemu_strtoul(str, NULL, 0, &res);\n\n\n\n g_assert_cmpint(err, ==, 0);\n\n g_assert_cmpint(res, ==, ULONG_MAX);\n\n g_free(str);\n\n}\n", + "output": "0", + "index": 12766 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int device_open(AVFormatContext *ctx)\n\n{\n\n struct v4l2_capability cap;\n\n int fd;\n\n#if CONFIG_LIBV4L2\n\n int fd_libv4l;\n\n#endif\n\n int res, err;\n\n int flags = O_RDWR;\n\n\n\n if (ctx->flags & AVFMT_FLAG_NONBLOCK) {\n\n flags |= O_NONBLOCK;\n\n }\n\n\n\n fd = v4l2_open(ctx->filename, flags, 0);\n\n if (fd < 0) {\n\n err = errno;\n\n\n\n av_log(ctx, AV_LOG_ERROR, \"Cannot open video device %s : %s\\n\",\n\n ctx->filename, strerror(err));\n\n\n\n return AVERROR(err);\n\n }\n\n#if CONFIG_LIBV4L2\n\n fd_libv4l = v4l2_fd_open(fd, 0);\n\n if (fd < 0) {\n\n err = AVERROR(errno);\n\n av_log(ctx, AV_LOG_ERROR, \"Cannot open video device with libv4l neither %s : %s\\n\",\n\n ctx->filename, strerror(errno));\n\n return err;\n\n }\n\n fd = fd_libv4l;\n\n#endif\n\n\n\n res = v4l2_ioctl(fd, VIDIOC_QUERYCAP, &cap);\n\n if (res < 0) {\n\n err = errno;\n\n av_log(ctx, AV_LOG_ERROR, \"ioctl(VIDIOC_QUERYCAP): %s\\n\",\n\n strerror(err));\n\n\n\n goto fail;\n\n }\n\n\n\n av_log(ctx, AV_LOG_VERBOSE, \"[%d]Capabilities: %x\\n\",\n\n fd, cap.capabilities);\n\n\n\n if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {\n\n av_log(ctx, AV_LOG_ERROR, \"Not a video capture device.\\n\");\n\n err = ENODEV;\n\n\n\n goto fail;\n\n }\n\n\n\n if (!(cap.capabilities & V4L2_CAP_STREAMING)) {\n\n av_log(ctx, AV_LOG_ERROR,\n\n \"The device does not support the streaming I/O method.\\n\");\n\n err = ENOSYS;\n\n\n\n goto fail;\n\n }\n\n\n\n return fd;\n\n\n\nfail:\n\n v4l2_close(fd);\n\n return AVERROR(err);\n\n}\n", + "output": "1", + "index": 3541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)\n\n{\n\n\tint i;\n\n assert(src1 == src2);\n\n\tfor(i=0; i>8;\n\n\t\tdstV[i]= p>>16;\n\n\t}\n\n}\n", + "output": "1", + "index": 25684 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix)\n\n{\n\n AVIOContext *pb = s->pb;\n\n AVIContext *avi = s->priv_data;\n\n AVIStream *avist = s->streams[stream_index]->priv_data;\n\n int64_t pos;\n\n int au_byterate, au_ssize, au_scale;\n\n\n\n avio_flush(pb);\n\n pos = avio_tell(pb);\n\n\n\n /* Updating one entry in the AVI OpenDML master index */\n\n avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);\n\n ffio_wfourcc(pb, \"indx\"); /* enabling this entry */\n\n avio_skip(pb, 8);\n\n avio_wl32(pb, avi->riff_id); /* nEntriesInUse */\n\n avio_skip(pb, 16 * avi->riff_id);\n\n avio_wl64(pb, ix); /* qwOffset */\n\n avio_wl32(pb, pos - ix); /* dwSize */\n\n ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);\n\n if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {\n\n uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);\n\n if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {\n\n avpriv_request_sample(s, \"OpenDML index duration for audio packets with partial frames\");\n\n avist->sample_requested = 1;\n\n }\n\n avio_wl32(pb, audio_segm_size / au_ssize); /* dwDuration (sample count) */\n\n } else\n\n avio_wl32(pb, avist->indexes.entry); /* dwDuration (packet count) */\n\n\n\n avio_seek(pb, pos, SEEK_SET);\n\n}\n", + "output": "0", + "index": 10445 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],\n\n int qsel, int is_chroma, int is_hqa)\n\n{\n\n const int32_t *q;\n\n int val, pos = 1;\n\n\n\n memset(block, 0, 64 * sizeof(*block));\n\n\n\n if (!is_hqa) {\n\n block[0] = get_sbits(gb, 9) << 6;\n\n q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];\n\n } else {\n\n q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];\n\n block[0] = get_sbits(gb, 9) << 6;\n\n }\n\n\n\n for (;;) {\n\n val = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2);\n\n pos += ff_hq_ac_skips[val];\n\n if (pos >= 64)\n\n break;\n\n block[ff_zigzag_direct[pos]] = (ff_hq_ac_syms[val] * q[pos]) >> 12;\n\n pos++;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 6640 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void flush_queued_work(CPUState *env)\n\n{\n\n struct qemu_work_item *wi;\n\n\n\n if (!env->queued_work_first)\n\n return;\n\n\n\n while ((wi = env->queued_work_first)) {\n\n env->queued_work_first = wi->next;\n\n wi->func(wi->data);\n\n wi->done = true;\n\n }\n\n env->queued_work_last = NULL;\n\n qemu_cond_broadcast(&qemu_work_cond);\n\n}\n", + "output": "0", + "index": 9805 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_hba_spec(void)\n\n{\n\n AHCIQState *ahci;\n\n\n\n ahci = ahci_boot();\n\n ahci_pci_enable(ahci);\n\n ahci_test_hba_spec(ahci);\n\n ahci_shutdown(ahci);\n\n}\n", + "output": "0", + "index": 14922 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)\n{\n ConcatContext *cat = avf->priv_data;\n int ret;\n int64_t delta;\n while (1) {\n if ((ret = av_read_frame(cat->avf, pkt)) != AVERROR_EOF ||\n (ret = open_next_file(avf)) < 0)\n break;\n }\n delta = av_rescale_q(cat->cur_file->start_time - cat->avf->start_time,\n AV_TIME_BASE_Q,\n cat->avf->streams[pkt->stream_index]->time_base);\n if (pkt->pts != AV_NOPTS_VALUE)\n pkt->pts += delta;\n if (pkt->dts != AV_NOPTS_VALUE)\n pkt->dts += delta;\n}", + "output": "1", + "index": 10784 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold void init_mdct_win(TwinContext *tctx)\n\n{\n\n int i,j;\n\n const ModeTab *mtab = tctx->mtab;\n\n int size_s = mtab->size / mtab->fmode[FT_SHORT].sub;\n\n int size_m = mtab->size / mtab->fmode[FT_MEDIUM].sub;\n\n int channels = tctx->avctx->channels;\n\n float norm = channels == 1 ? 2. : 1.;\n\n\n\n for (i = 0; i < 3; i++) {\n\n int bsize = tctx->mtab->size/tctx->mtab->fmode[i].sub;\n\n ff_mdct_init(&tctx->mdct_ctx[i], av_log2(bsize) + 1, 1,\n\n -sqrt(norm/bsize) / (1<<15));\n\n }\n\n\n\n tctx->tmp_buf = av_malloc(mtab->size * sizeof(*tctx->tmp_buf));\n\n\n\n tctx->spectrum = av_malloc(2*mtab->size*channels*sizeof(float));\n\n tctx->curr_frame = av_malloc(2*mtab->size*channels*sizeof(float));\n\n tctx->prev_frame = av_malloc(2*mtab->size*channels*sizeof(float));\n\n\n\n for (i = 0; i < 3; i++) {\n\n int m = 4*mtab->size/mtab->fmode[i].sub;\n\n double freq = 2*M_PI/m;\n\n tctx->cos_tabs[i] = av_malloc((m/4)*sizeof(*tctx->cos_tabs));\n\n\n\n for (j = 0; j <= m/8; j++)\n\n tctx->cos_tabs[i][j] = cos((2*j + 1)*freq);\n\n for (j = 1; j < m/8; j++)\n\n tctx->cos_tabs[i][m/4-j] = tctx->cos_tabs[i][j];\n\n }\n\n\n\n\n\n ff_init_ff_sine_windows(av_log2(size_m));\n\n ff_init_ff_sine_windows(av_log2(size_s/2));\n\n ff_init_ff_sine_windows(av_log2(mtab->size));\n\n}\n", + "output": "1", + "index": 17446 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ExitStatus gen_mtpr(DisasContext *ctx, TCGv vb, int regno)\n\n{\n\n TCGv tmp;\n\n int data;\n\n\n\n switch (regno) {\n\n case 255:\n\n /* TBIA */\n\n gen_helper_tbia(cpu_env);\n\n break;\n\n\n\n case 254:\n\n /* TBIS */\n\n gen_helper_tbis(cpu_env, vb);\n\n break;\n\n\n\n case 253:\n\n /* WAIT */\n\n tmp = tcg_const_i64(1);\n\n tcg_gen_st32_i64(tmp, cpu_env, -offsetof(AlphaCPU, env) +\n\n offsetof(CPUState, halted));\n\n return gen_excp(ctx, EXCP_HALTED, 0);\n\n\n\n case 252:\n\n /* HALT */\n\n gen_helper_halt(vb);\n\n return EXIT_PC_STALE;\n\n\n\n case 251:\n\n /* ALARM */\n\n gen_helper_set_alarm(cpu_env, vb);\n\n break;\n\n\n\n case 7:\n\n /* PALBR */\n\n tcg_gen_st_i64(vb, cpu_env, offsetof(CPUAlphaState, palbr));\n\n /* Changing the PAL base register implies un-chaining all of the TBs\n\n that ended with a CALL_PAL. Since the base register usually only\n\n changes during boot, flushing everything works well. */\n\n gen_helper_tb_flush(cpu_env);\n\n return EXIT_PC_STALE;\n\n\n\n case 32 ... 39:\n\n /* Accessing the \"non-shadow\" general registers. */\n\n regno = regno == 39 ? 25 : regno - 32 + 8;\n\n tcg_gen_mov_i64(cpu_std_ir[regno], vb);\n\n break;\n\n\n\n case 0: /* PS */\n\n st_flag_byte(vb, ENV_FLAG_PS_SHIFT);\n\n break;\n\n case 1: /* FEN */\n\n st_flag_byte(vb, ENV_FLAG_FEN_SHIFT);\n\n break;\n\n\n\n default:\n\n /* The basic registers are data only, and unknown registers\n\n are read-zero, write-ignore. */\n\n data = cpu_pr_data(regno);\n\n if (data != 0) {\n\n if (data & PR_LONG) {\n\n tcg_gen_st32_i64(vb, cpu_env, data & ~PR_LONG);\n\n } else {\n\n tcg_gen_st_i64(vb, cpu_env, data);\n\n }\n\n }\n\n break;\n\n }\n\n\n\n return NO_EXIT;\n\n}\n", + "output": "1", + "index": 2360 + }, + { + "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 bs->growable = 1;\n\n *pbs = bs;\n\n return 0;\n\n}\n", + "output": "0", + "index": 8672 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void swri_resample_dsp_x86_init(ResampleContext *c)\n\n{\n\n int av_unused mm_flags = av_get_cpu_flags();\n\n\n\n switch(c->format){\n\n case AV_SAMPLE_FMT_S16P:\n\n if (ARCH_X86_32 && EXTERNAL_MMXEXT(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext\n\n : ff_resample_common_int16_mmxext;\n\n }\n\n if (EXTERNAL_SSE2(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2\n\n : ff_resample_common_int16_sse2;\n\n }\n\n if (EXTERNAL_XOP(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_int16_xop\n\n : ff_resample_common_int16_xop;\n\n }\n\n break;\n\n case AV_SAMPLE_FMT_FLTP:\n\n if (EXTERNAL_SSE(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_float_sse\n\n : ff_resample_common_float_sse;\n\n }\n\n if (EXTERNAL_AVX(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_float_avx\n\n : ff_resample_common_float_avx;\n\n }\n\n if (EXTERNAL_FMA3(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_float_fma3\n\n : ff_resample_common_float_fma3;\n\n }\n\n if (EXTERNAL_FMA4(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_float_fma4\n\n : ff_resample_common_float_fma4;\n\n }\n\n break;\n\n case AV_SAMPLE_FMT_DBLP:\n\n if (EXTERNAL_SSE2(mm_flags)) {\n\n c->dsp.resample = c->linear ? ff_resample_linear_double_sse2\n\n : ff_resample_common_double_sse2;\n\n }\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 22394 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_mclms(WmallDecodeCtx *s)\n\n{\n\n s->mclms_order = (get_bits(&s->gb, 4) + 1) * 2;\n\n s->mclms_scaling = get_bits(&s->gb, 4);\n\n if(get_bits1(&s->gb)) {\n\n\t// mclms_send_coef\n\n\tint i;\n\n\tint send_coef_bits;\n\n\tint cbits = av_log2(s->mclms_scaling + 1);\n\n\tassert(cbits == my_log2(s->mclms_scaling + 1));\n\n\tif(1 << cbits < s->mclms_scaling + 1)\n\n\t cbits++;\n\n\n\n\tsend_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;\n\n\n\n\tfor(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) {\n\n\t s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);\n\n\t}\n\n\n\n\tfor(i = 0; i < s->num_channels; i++) {\n\n\t int c;\n\n\t for(c = 0; c < i; c++) {\n\n\t\ts->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);\n\n\t }\n\n\t}\n\n }\n\n}\n", + "output": "1", + "index": 3722 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmport_class_initfn(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->realize = vmport_realizefn;\n\n dc->no_user = 1;\n\n}\n", + "output": "1", + "index": 8476 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ppc_hash64_set_external_hpt(PowerPCCPU *cpu, void *hpt, int shift,\n\n Error **errp)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n Error *local_err = NULL;\n\n\n\n cpu_synchronize_state(CPU(cpu));\n\n\n\n env->external_htab = hpt;\n\n ppc_hash64_set_sdr1(cpu, (target_ulong)(uintptr_t)hpt | (shift - 18),\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 /* Not strictly necessary, but makes it clearer that an external\n\n * htab is in use when debugging */\n\n env->htab_base = -1;\n\n\n\n if (kvm_enabled()) {\n\n if (kvmppc_put_books_sregs(cpu) < 0) {\n\n error_setg(errp, \"Unable to update SDR1 in KVM\");\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 7383 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *socket_address_to_string(struct SocketAddress *addr, Error **errp)\n\n{\n\n char *buf;\n\n InetSocketAddress *inet;\n\n\n\n switch (addr->type) {\n\n case SOCKET_ADDRESS_KIND_INET:\n\n inet = addr->u.inet.data;\n\n if (strchr(inet->host, ':') == NULL) {\n\n buf = g_strdup_printf(\"%s:%s\", inet->host, inet->port);\n\n } else {\n\n buf = g_strdup_printf(\"[%s]:%s\", inet->host, inet->port);\n\n }\n\n break;\n\n\n\n case SOCKET_ADDRESS_KIND_UNIX:\n\n buf = g_strdup(addr->u.q_unix.data->path);\n\n break;\n\n\n\n case SOCKET_ADDRESS_KIND_FD:\n\n buf = g_strdup(addr->u.fd.data->str);\n\n break;\n\n\n\n case SOCKET_ADDRESS_KIND_VSOCK:\n\n buf = g_strdup_printf(\"%s:%s\",\n\n addr->u.vsock.data->cid,\n\n addr->u.vsock.data->port);\n\n break;\n\n\n\n default:\n\n abort();\n\n }\n\n return buf;\n\n}\n", + "output": "0", + "index": 22760 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat)\n\n{\n\n memset(stbuf, 0, sizeof(*stbuf));\n\n stbuf->st_dev = prstat->st_dev;\n\n stbuf->st_ino = prstat->st_ino;\n\n stbuf->st_nlink = prstat->st_nlink;\n\n stbuf->st_mode = prstat->st_mode;\n\n stbuf->st_uid = prstat->st_uid;\n\n stbuf->st_gid = prstat->st_gid;\n\n stbuf->st_rdev = prstat->st_rdev;\n\n stbuf->st_size = prstat->st_size;\n\n stbuf->st_blksize = prstat->st_blksize;\n\n stbuf->st_blocks = prstat->st_blocks;\n\n stbuf->st_atim.tv_sec = prstat->st_atim_sec;\n\n stbuf->st_atim.tv_nsec = prstat->st_atim_nsec;\n\n stbuf->st_mtime = prstat->st_mtim_sec;\n\n stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec;\n\n stbuf->st_ctime = prstat->st_ctim_sec;\n\n stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec;\n\n}\n", + "output": "0", + "index": 4904 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qcrypto_cipher_encrypt(QCryptoCipher *cipher,\n const void *in,\n void *out,\n size_t len,\n Error **errp)\n{\n QCryptoCipherBuiltin *ctxt = cipher->opaque;\n return ctxt->encrypt(cipher, in, out, len, errp);", + "output": "1", + "index": 18848 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int show_format(WriterContext *w, AVFormatContext *fmt_ctx)\n\n{\n\n char val_str[128];\n\n int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;\n\n int ret = 0;\n\n\n\n writer_print_section_header(w, SECTION_ID_FORMAT);\n\n print_str(\"filename\", fmt_ctx->filename);\n\n print_int(\"nb_streams\", fmt_ctx->nb_streams);\n\n print_int(\"nb_programs\", fmt_ctx->nb_programs);\n\n print_str(\"format_name\", fmt_ctx->iformat->name);\n\n if (!do_bitexact) {\n\n if (fmt_ctx->iformat->long_name) print_str (\"format_long_name\", fmt_ctx->iformat->long_name);\n\n else print_str_opt(\"format_long_name\", \"unknown\");\n\n }\n\n print_time(\"start_time\", fmt_ctx->start_time, &AV_TIME_BASE_Q);\n\n print_time(\"duration\", fmt_ctx->duration, &AV_TIME_BASE_Q);\n\n if (size >= 0) print_val (\"size\", size, unit_byte_str);\n\n else print_str_opt(\"size\", \"N/A\");\n\n if (fmt_ctx->bit_rate > 0) print_val (\"bit_rate\", fmt_ctx->bit_rate, unit_bit_per_second_str);\n\n else print_str_opt(\"bit_rate\", \"N/A\");\n\n print_int(\"probe_score\", av_format_get_probe_score(fmt_ctx));\n\n ret = show_tags(w, fmt_ctx->metadata, SECTION_ID_FORMAT_TAGS);\n\n\n\n writer_print_section_footer(w);\n\n fflush(stdout);\n\n return ret;\n\n}\n", + "output": "0", + "index": 9689 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ehci_state_writeback(EHCIQueue *q, int async)\n\n{\n\n int again = 0;\n\n\n\n /* Write back the QTD from the QH area */\n\n ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), (EHCIqtd*) &q->qh.next_qtd);\n\n put_dwords(NLPTR_GET(q->qtdaddr),(uint32_t *) &q->qh.next_qtd,\n\n sizeof(EHCIqtd) >> 2);\n\n\n\n /*\n\n * EHCI specs say go horizontal here.\n\n *\n\n * We can also advance the queue here for performance reasons. We\n\n * need to take care to only take that shortcut in case we've\n\n * processed the qtd just written back without errors, i.e. halt\n\n * bit is clear.\n\n */\n\n if (q->qh.token & QTD_TOKEN_HALT) {\n\n ehci_set_state(q->ehci, async, EST_HORIZONTALQH);\n\n again = 1;\n\n } else {\n\n ehci_set_state(q->ehci, async, EST_ADVANCEQUEUE);\n\n again = 1;\n\n }\n\n return again;\n\n}\n", + "output": "0", + "index": 13770 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int mov_stsc_index_valid(int index, int count)\n\n{\n\n return index + 1 < count;\n\n}\n", + "output": "1", + "index": 20765 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_wakeup(USBEndpoint *ep, unsigned int stream)\n\n{\n\n USBDevice *dev = ep->dev;\n\n USBBus *bus = usb_bus_from_device(dev);\n\n\n\n\n\n\n\n\n\n\n\n if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) {\n\n dev->port->ops->wakeup(dev->port);\n\n\n if (bus->ops->wakeup_endpoint) {\n\n bus->ops->wakeup_endpoint(bus, ep, stream);\n\n", + "output": "1", + "index": 8324 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int css_do_hsch(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_STCTL) == SCSW_STCTL_STATUS_PEND) ||\n\n (s->ctrl & (SCSW_STCTL_PRIMARY |\n\n SCSW_STCTL_SECONDARY |\n\n SCSW_STCTL_ALERT))) {\n\n ret = -EINPROGRESS;\n\n goto out;\n\n }\n\n\n\n if (s->ctrl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) {\n\n ret = -EBUSY;\n\n goto out;\n\n }\n\n\n\n /* Trigger the halt function. */\n\n s->ctrl |= SCSW_FCTL_HALT_FUNC;\n\n s->ctrl &= ~SCSW_FCTL_START_FUNC;\n\n if (((s->ctrl & SCSW_CTRL_MASK_ACTL) ==\n\n (SCSW_ACTL_SUBCH_ACTIVE | SCSW_ACTL_DEVICE_ACTIVE)) &&\n\n ((s->ctrl & SCSW_CTRL_MASK_STCTL) == SCSW_STCTL_INTERMEDIATE)) {\n\n s->ctrl &= ~SCSW_STCTL_STATUS_PEND;\n\n }\n\n s->ctrl |= SCSW_ACTL_HALT_PEND;\n\n\n\n do_subchannel_work(sch, NULL);\n\n ret = 0;\n\n\n\nout:\n\n return ret;\n\n}\n", + "output": "0", + "index": 7931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static hwaddr ppc_hash64_pte_raddr(ppc_slb_t *slb, ppc_hash_pte64_t pte,\n\n target_ulong eaddr)\n\n{\n\n hwaddr mask;\n\n int target_page_bits;\n\n hwaddr rpn = pte.pte1 & HPTE64_R_RPN;\n\n /*\n\n * We support 4K, 64K and 16M now\n\n */\n\n target_page_bits = ppc_hash64_page_shift(slb);\n\n mask = (1ULL << target_page_bits) - 1;\n\n return (rpn & ~mask) | (eaddr & mask);\n\n}\n", + "output": "1", + "index": 10151 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_pread(BlockDriverState *bs, int64_t offset,\n\n void *buf1, int count1)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n\n\n if (!drv)\n\n return -ENOMEDIUM;\n\n if (!drv->bdrv_pread)\n\n return bdrv_pread_em(bs, offset, buf1, count1);\n\n\n\n return drv->bdrv_pread(bs, offset, buf1, count1);\n\n}", + "output": "1", + "index": 19594 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int ape_decode_value_3900(APEContext *ctx, APERice *rice)\n\n{\n\n unsigned int x, overflow;\n\n int tmpk;\n\n\n\n overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970);\n\n\n\n if (overflow == (MODEL_ELEMENTS - 1)) {\n\n tmpk = range_decode_bits(ctx, 5);\n\n overflow = 0;\n\n } else\n\n tmpk = (rice->k < 1) ? 0 : rice->k - 1;\n\n\n\n if (tmpk <= 16 || ctx->fileversion < 3910) {\n\n if (tmpk > 23) {\n\n av_log(ctx->avctx, AV_LOG_ERROR, \"Too many bits: %d\\n\", tmpk);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n x = range_decode_bits(ctx, tmpk);\n\n } else if (tmpk <= 32) {\n\n x = range_decode_bits(ctx, 16);\n\n x |= (range_decode_bits(ctx, tmpk - 16) << 16);\n\n } else {\n\n av_log(ctx->avctx, AV_LOG_ERROR, \"Too many bits: %d\\n\", tmpk);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n x += overflow << tmpk;\n\n\n\n update_rice(rice, x);\n\n\n\n /* Convert to signed */\n\n if (x & 1)\n\n return (x >> 1) + 1;\n\n else\n\n return -(x >> 1);\n\n}\n", + "output": "1", + "index": 3324 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcp_chr_close(CharDriverState *chr)\n\n{\n\n TCPCharDriver *s = chr->opaque;\n\n if (s->fd >= 0) {\n\n if (s->tag) {\n\n g_source_remove(s->tag);\n\n s->tag = 0;\n\n }\n\n if (s->chan) {\n\n g_io_channel_unref(s->chan);\n\n }\n\n closesocket(s->fd);\n\n }\n\n if (s->listen_fd >= 0) {\n\n if (s->listen_tag) {\n\n g_source_remove(s->listen_tag);\n\n s->listen_tag = 0;\n\n }\n\n if (s->listen_chan) {\n\n g_io_channel_unref(s->listen_chan);\n\n }\n\n closesocket(s->listen_fd);\n\n }\n\n g_free(s);\n\n qemu_chr_be_event(chr, CHR_EVENT_CLOSED);\n\n}\n", + "output": "1", + "index": 18390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vm_stop(int reason)\n\n{\n\n QemuThread me;\n\n qemu_thread_self(&me);\n\n\n\n if (!qemu_thread_equal(&me, &io_thread)) {\n\n qemu_system_vmstop_request(reason);\n\n /*\n\n * FIXME: should not return to device code in case\n\n * vm_stop() has been requested.\n\n */\n\n cpu_stop_current();\n\n return;\n\n }\n\n do_vm_stop(reason);\n\n}\n", + "output": "0", + "index": 9274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_int_overflow(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n int64_t res = 0;\n\n Error *err = NULL;\n\n Visitor *v;\n\n\n\n /* this will overflow a Qint/int64, so should be deserialized into\n\n * a QFloat/double field instead, leading to an error if we pass it\n\n * to visit_type_int. confirm this.\n\n */\n\n v = visitor_input_test_init(data, \"%f\", DBL_MAX);\n\n\n\n visit_type_int(v, &res, NULL, &err);\n\n g_assert(err);\n\n error_free(err);\n\n}\n", + "output": "1", + "index": 15602 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,\n\n ram_addr_t memory, ram_addr_t region_offset)\n\n{\n\n int idx, eidx;\n\n\n\n if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE)\n\n return -1;\n\n idx = SUBPAGE_IDX(start);\n\n eidx = SUBPAGE_IDX(end);\n\n#if defined(DEBUG_SUBPAGE)\n\n printf(\"%s: %p start %08x end %08x idx %08x eidx %08x mem %ld\\n\", __func__,\n\n mmio, start, end, idx, eidx, memory);\n\n#endif\n\n\n\n memory = (memory >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);\n\n for (; idx <= eidx; idx++) {\n\n mmio->sub_io_index[idx] = memory;\n\n mmio->region_offset[idx] = region_offset;\n\n }\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 10349 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spatial_decompose97i(DWTELEM *buffer, int width, int height, int stride){\n\n int y;\n\n DWTELEM *b0= buffer + mirror(-4-1, height-1)*stride;\n\n DWTELEM *b1= buffer + mirror(-4 , height-1)*stride;\n\n DWTELEM *b2= buffer + mirror(-4+1, height-1)*stride;\n\n DWTELEM *b3= buffer + mirror(-4+2, height-1)*stride;\n\n\n\n for(y=-4; y400){\n\nSTOP_TIMER(\"horizontal_decompose97i\")\n\n}}\n\n\n\n{START_TIMER\n\n if(b3 <= b5) vertical_decompose97iH0(b3, b4, b5, width);\n\n if(b2 <= b4) vertical_decompose97iL0(b2, b3, b4, width);\n\n if(b1 <= b3) vertical_decompose97iH1(b1, b2, b3, width);\n\n if(b0 <= b2) vertical_decompose97iL1(b0, b1, b2, width);\n\n\n\nif(width>400){\n\nSTOP_TIMER(\"vertical_decompose97i\")\n\n}}\n\n\n\n b0=b2;\n\n b1=b3;\n\n b2=b4;\n\n b3=b5;\n\n }\n\n}\n", + "output": "1", + "index": 6175 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr)\n\n{\n\n int hpt_shift;\n\n\n\n if ((spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED)\n\n || (spapr->cas_reboot\n\n && !spapr_ovec_test(spapr->ov5_cas, OV5_HPT_RESIZE))) {\n\n hpt_shift = spapr_hpt_shift_for_ramsize(MACHINE(spapr)->maxram_size);\n\n } else {\n\n hpt_shift = spapr_hpt_shift_for_ramsize(MACHINE(spapr)->ram_size);\n\n }\n\n spapr_reallocate_hpt(spapr, hpt_shift, &error_fatal);\n\n\n\n if (spapr->vrma_adjust) {\n\n spapr->rma_size = kvmppc_rma_size(spapr_node0_size(MACHINE(spapr)),\n\n spapr->htab_shift);\n\n }\n\n /* We're setting up a hash table, so that means we're not radix */\n\n spapr->patb_entry = 0;\n\n}\n", + "output": "0", + "index": 3352 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rle_unpack(unsigned char *src, unsigned char *dest, int len)\n\n{\n\n unsigned char *ps;\n\n unsigned char *pd;\n\n int i, l;\n\n\n\n ps = src;\n\n pd = dest;\n\n if (len & 1)\n\n *pd++ = *ps++;\n\n\n\n len >>= 1;\n\n i = 0;\n\n do {\n\n l = *ps++;\n\n if (l & 0x80) {\n\n l = (l & 0x7F) * 2;\n\n memcpy(pd, ps, l);\n\n ps += l;\n\n pd += l;\n\n } else {\n\n for (i = 0; i < l; i++) {\n\n *pd++ = ps[0];\n\n *pd++ = ps[1];\n\n }\n\n ps += 2;\n\n }\n\n i += l;\n\n } while (i < len);\n\n\n\n return (ps - src);\n\n}\n", + "output": "0", + "index": 14488 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_type_int32(Visitor *v, int32_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_int32) {\n\n v->type_int32(v, obj, name, errp);\n\n } else {\n\n value = *obj;\n\n v->type_int(v, &value, name, errp);\n\n if (value < INT32_MIN || value > INT32_MAX) {\n\n error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",\n\n \"int32_t\");\n\n return;\n\n }\n\n *obj = value;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 6268 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int fft_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int ln)\n\n{\n\n int i, n, n2;\n\n float alpha;\n\n\n\n n = 1 << ln;\n\n n2 = n >> 1;\n\n\n\n FF_ALLOC_OR_GOTO(avctx, mdct->costab, n2 * sizeof(*mdct->costab), fft_alloc_fail);\n\n FF_ALLOC_OR_GOTO(avctx, mdct->sintab, n2 * sizeof(*mdct->sintab), fft_alloc_fail);\n\n\n\n for (i = 0; i < n2; i++) {\n\n alpha = 2.0 * M_PI * i / n;\n\n mdct->costab[i] = FIX15(cos(alpha));\n\n mdct->sintab[i] = FIX15(sin(alpha));\n\n }\n\n\n\n return 0;\n\nfft_alloc_fail:\n\n mdct_end(mdct);\n\n return AVERROR(ENOMEM);\n\n}\n", + "output": "0", + "index": 26730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtce_init(VIOsPAPRDevice *dev)\n\n{\n\n size_t size = (dev->rtce_window_size >> SPAPR_VIO_TCE_PAGE_SHIFT)\n\n * sizeof(VIOsPAPR_RTCE);\n\n\n\n if (size) {\n\n dev->rtce_table = kvmppc_create_spapr_tce(dev->reg,\n\n dev->rtce_window_size,\n\n &dev->kvmtce_fd);\n\n\n\n if (!dev->rtce_table) {\n\n dev->rtce_table = g_malloc0(size);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 16758 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qint_destroy_obj(QObject *obj)\n\n{\n\n assert(obj != NULL);\n\n g_free(qobject_to_qint(obj));\n\n}\n", + "output": "0", + "index": 23590 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void net_dump_cleanup(VLANClientState *vc)\n\n{\n\n DumpState *s = vc->opaque;\n\n\n\n close(s->fd);\n\n qemu_free(s);\n\n}\n", + "output": "1", + "index": 11753 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int coroutine_fn qemu_co_recvv(int sockfd, struct iovec *iov,\n\n int len, int iov_offset)\n\n{\n\n int total = 0;\n\n int ret;\n\n while (len) {\n\n ret = qemu_recvv(sockfd, iov, len, iov_offset + total);\n\n if (ret < 0) {\n\n if (errno == EAGAIN) {\n\n qemu_coroutine_yield();\n\n continue;\n\n }\n\n if (total == 0) {\n\n total = -1;\n\n }\n\n break;\n\n }\n\n if (ret == 0) {\n\n break;\n\n }\n\n total += ret, len -= ret;\n\n }\n\n\n\n return total;\n\n}\n", + "output": "1", + "index": 3413 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void memory_region_notify_one(IOMMUNotifier *notifier,\n\n IOMMUTLBEntry *entry)\n\n{\n\n IOMMUNotifierFlag request_flags;\n\n\n\n /*\n\n * Skip the notification if the notification does not overlap\n\n * with registered range.\n\n */\n\n if (notifier->start > entry->iova + entry->addr_mask + 1 ||\n\n notifier->end < entry->iova) {\n\n return;\n\n }\n\n\n\n if (entry->perm & IOMMU_RW) {\n\n request_flags = IOMMU_NOTIFIER_MAP;\n\n } else {\n\n request_flags = IOMMU_NOTIFIER_UNMAP;\n\n }\n\n\n\n if (notifier->notifier_flags & request_flags) {\n\n notifier->notify(notifier, entry);\n\n }\n\n}\n", + "output": "1", + "index": 8449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void t_gen_mov_TN_preg(TCGv tn, int r)\n\n{\n\n if (r < 0 || r > 15) {\n\n fprintf(stderr, \"wrong register read $p%d\\n\", r);\n\n }\n\n if (r == PR_BZ || r == PR_WZ || r == PR_DZ) {\n\n tcg_gen_mov_tl(tn, tcg_const_tl(0));\n\n } else if (r == PR_VR) {\n\n tcg_gen_mov_tl(tn, tcg_const_tl(32));\n\n } else {\n\n tcg_gen_mov_tl(tn, cpu_PR[r]);\n\n }\n\n}\n", + "output": "1", + "index": 17605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DISAS_INSN(cas2l)\n\n{\n\n uint16_t ext1, ext2;\n\n TCGv addr1, addr2, regs;\n\n\n\n /* cas2 Dc1:Dc2,Du1:Du2,(Rn1):(Rn2) */\n\n\n\n ext1 = read_im16(env, s);\n\n\n\n if (ext1 & 0x8000) {\n\n /* Address Register */\n\n addr1 = AREG(ext1, 12);\n\n } else {\n\n /* Data Register */\n\n addr1 = DREG(ext1, 12);\n\n }\n\n\n\n ext2 = read_im16(env, s);\n\n if (ext2 & 0x8000) {\n\n /* Address Register */\n\n addr2 = AREG(ext2, 12);\n\n } else {\n\n /* Data Register */\n\n addr2 = DREG(ext2, 12);\n\n }\n\n\n\n /* if (R1) == Dc1 && (R2) == Dc2 then\n\n * (R1) = Du1\n\n * (R2) = Du2\n\n * else\n\n * Dc1 = (R1)\n\n * Dc2 = (R2)\n\n */\n\n\n\n regs = tcg_const_i32(REG(ext2, 6) |\n\n (REG(ext1, 6) << 3) |\n\n (REG(ext2, 0) << 6) |\n\n (REG(ext1, 0) << 9));\n\n gen_helper_cas2l(cpu_env, regs, addr1, addr2);\n\n tcg_temp_free(regs);\n\n\n\n /* Note that cas2l also assigned to env->cc_op. */\n\n s->cc_op = CC_OP_CMPL;\n\n s->cc_op_synced = 1;\n\n}\n", + "output": "0", + "index": 2795 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t isa_mmio_readw(void *opaque, target_phys_addr_t addr)\n\n{\n\n return cpu_inw(addr & IOPORTS_MASK);\n\n}\n", + "output": "0", + "index": 11001 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qxl_dirty_surfaces(PCIQXLDevice *qxl)\n\n{\n\n uintptr_t vram_start;\n\n int i;\n\n\n\n if (qxl->mode != QXL_MODE_NATIVE && qxl->mode != QXL_MODE_COMPAT) {\n\n return;\n\n }\n\n\n\n /* dirty the primary surface */\n\n qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,\n\n qxl->shadow_rom.surface0_area_size);\n\n\n\n vram_start = (uintptr_t)memory_region_get_ram_ptr(&qxl->vram_bar);\n\n\n\n /* dirty the off-screen surfaces */\n\n for (i = 0; i < qxl->ssd.num_surfaces; i++) {\n\n QXLSurfaceCmd *cmd;\n\n intptr_t surface_offset;\n\n int surface_size;\n\n\n\n if (qxl->guest_surfaces.cmds[i] == 0) {\n\n continue;\n\n }\n\n\n\n cmd = qxl_phys2virt(qxl, qxl->guest_surfaces.cmds[i],\n\n MEMSLOT_GROUP_GUEST);\n\n assert(cmd);\n\n assert(cmd->type == QXL_SURFACE_CMD_CREATE);\n\n surface_offset = (intptr_t)qxl_phys2virt(qxl,\n\n cmd->u.surface_create.data,\n\n MEMSLOT_GROUP_GUEST);\n\n assert(surface_offset);\n\n surface_offset -= vram_start;\n\n surface_size = cmd->u.surface_create.height *\n\n abs(cmd->u.surface_create.stride);\n\n trace_qxl_surfaces_dirty(qxl->id, i, (int)surface_offset, surface_size);\n\n qxl_set_dirty(&qxl->vram_bar, surface_offset, surface_size);\n\n }\n\n}\n", + "output": "0", + "index": 6845 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kqemu_set_notdirty(CPUState *env, ram_addr_t ram_addr)\n\n{\n\n LOG_INT(\"kqemu_set_notdirty: addr=%08lx\\n\", \n\n (unsigned long)ram_addr);\n\n /* we only track transitions to dirty state */\n\n if (phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] != 0xff)\n\n return;\n\n if (nb_ram_pages_to_update >= KQEMU_MAX_RAM_PAGES_TO_UPDATE)\n\n nb_ram_pages_to_update = KQEMU_RAM_PAGES_UPDATE_ALL;\n\n else\n\n ram_pages_to_update[nb_ram_pages_to_update++] = ram_addr;\n\n}\n", + "output": "0", + "index": 1064 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ss5_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 if (cpu_model == NULL)\n\n cpu_model = \"Fujitsu MB86904\";\n\n sun4m_common_init(ram_size, boot_device, ds, kernel_filename,\n\n kernel_cmdline, initrd_filename, cpu_model,\n\n 0);\n\n}\n", + "output": "0", + "index": 21519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CPUArchState *cpu_copy(CPUArchState *env)\n\n{\n\n CPUState *cpu = ENV_GET_CPU(env);\n\n CPUArchState *new_env = cpu_init(cpu_model);\n\n CPUState *new_cpu = ENV_GET_CPU(new_env);\n\n#if defined(TARGET_HAS_ICE)\n\n CPUBreakpoint *bp;\n\n CPUWatchpoint *wp;\n\n#endif\n\n\n\n /* Reset non arch specific state */\n\n cpu_reset(new_cpu);\n\n\n\n memcpy(new_env, env, sizeof(CPUArchState));\n\n\n\n /* Clone all break/watchpoints.\n\n Note: Once we support ptrace with hw-debug register access, make sure\n\n BP_CPU break/watchpoints are handled correctly on clone. */\n\n QTAILQ_INIT(&cpu->breakpoints);\n\n QTAILQ_INIT(&cpu->watchpoints);\n\n#if defined(TARGET_HAS_ICE)\n\n QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {\n\n cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);\n\n }\n\n QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {\n\n cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);\n\n }\n\n#endif\n\n\n\n return new_env;\n\n}\n", + "output": "0", + "index": 2729 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t v9fs_synth_lgetxattr(FsContext *ctx, V9fsPath *path,\n\n const char *name, void *value, size_t size)\n\n{\n\n errno = ENOTSUP;\n\n return -1;\n\n}\n", + "output": "0", + "index": 1217 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void op_mtc0_ebase (void)\n\n{\n\n /* vectored interrupts not implemented */\n\n /* Multi-CPU not implemented */\n\n env->CP0_EBase = (int32_t)0x80000000 | (T0 & 0x3FFFF000);\n\n RETURN();\n\n}\n", + "output": "0", + "index": 24695 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void musicpal_lcd_write(void *opaque, target_phys_addr_t offset,\n\n uint64_t value, unsigned size)\n\n{\n\n musicpal_lcd_state *s = opaque;\n\n\n\n switch (offset) {\n\n case MP_LCD_IRQCTRL:\n\n s->irqctrl = value;\n\n break;\n\n\n\n case MP_LCD_SPICTRL:\n\n if (value == MP_LCD_SPI_DATA || value == MP_LCD_SPI_CMD) {\n\n s->mode = value;\n\n } else {\n\n s->mode = MP_LCD_SPI_INVALID;\n\n }\n\n break;\n\n\n\n case MP_LCD_INST:\n\n if (value >= MP_LCD_INST_SETPAGE0 && value <= MP_LCD_INST_SETPAGE7) {\n\n s->page = value - MP_LCD_INST_SETPAGE0;\n\n s->page_off = 0;\n\n }\n\n break;\n\n\n\n case MP_LCD_DATA:\n\n if (s->mode == MP_LCD_SPI_CMD) {\n\n if (value >= MP_LCD_INST_SETPAGE0 &&\n\n value <= MP_LCD_INST_SETPAGE7) {\n\n s->page = value - MP_LCD_INST_SETPAGE0;\n\n s->page_off = 0;\n\n }\n\n } else if (s->mode == MP_LCD_SPI_DATA) {\n\n s->video_ram[s->page*128 + s->page_off] = value;\n\n s->page_off = (s->page_off + 1) & 127;\n\n }\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 16862 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,\n\n const char *name, V9fsSynthNode **result)\n\n{\n\n int ret;\n\n V9fsSynthNode *node, *tmp;\n\n\n\n if (!v9fs_synth_fs) {\n\n return EAGAIN;\n\n }\n\n if (!name || (strlen(name) >= NAME_MAX)) {\n\n return EINVAL;\n\n }\n\n if (!parent) {\n\n parent = &v9fs_synth_root;\n\n }\n\n qemu_mutex_lock(&v9fs_synth_mutex);\n\n QLIST_FOREACH(tmp, &parent->child, sibling) {\n\n if (!strcmp(tmp->name, name)) {\n\n ret = EEXIST;\n\n goto err_out;\n\n }\n\n }\n\n /* Add the name */\n\n node = v9fs_add_dir_node(parent, mode, name, NULL, v9fs_synth_node_count++);\n\n v9fs_add_dir_node(node, parent->attr->mode, \"..\",\n\n parent->attr, parent->attr->inode);\n\n v9fs_add_dir_node(node, node->attr->mode, \".\",\n\n node->attr, node->attr->inode);\n\n *result = node;\n\n ret = 0;\n\nerr_out:\n\n qemu_mutex_unlock(&v9fs_synth_mutex);\n\n return ret;\n\n}\n", + "output": "0", + "index": 900 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_info(Monitor *mon, QObject **ret_data)\n\n{\n\n QList *bs_list;\n\n BlockDriverState *bs;\n\n\n\n bs_list = qlist_new();\n\n\n\n QTAILQ_FOREACH(bs, &bdrv_states, list) {\n\n QObject *bs_obj;\n\n\n\n bs_obj = qobject_from_jsonf(\"{ 'device': %s, 'type': 'unknown', \"\n\n \"'removable': %i, 'locked': %i }\",\n\n bs->device_name, bs->removable,\n\n bdrv_dev_is_medium_locked(bs));\n\n\n\n if (bs->drv) {\n\n QObject *obj;\n\n QDict *bs_dict = qobject_to_qdict(bs_obj);\n\n\n\n obj = qobject_from_jsonf(\"{ 'file': %s, 'ro': %i, 'drv': %s, \"\n\n \"'encrypted': %i }\",\n\n bs->filename, bs->read_only,\n\n bs->drv->format_name,\n\n bdrv_is_encrypted(bs));\n\n if (bs->backing_file[0] != '\\0') {\n\n QDict *qdict = qobject_to_qdict(obj);\n\n qdict_put(qdict, \"backing_file\",\n\n qstring_from_str(bs->backing_file));\n\n }\n\n\n\n qdict_put_obj(bs_dict, \"inserted\", obj);\n\n }\n\n qlist_append_obj(bs_list, bs_obj);\n\n }\n\n\n\n *ret_data = QOBJECT(bs_list);\n\n}\n", + "output": "0", + "index": 9256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)\n\n{\n\n if (kvm_enabled()) {\n\n kvm_s390_virtio_irq(cpu, config_change, token);\n\n } else {\n\n cpu_inject_ext(cpu, VIRTIO_EXT_CODE, config_change, token);\n\n }\n\n}\n", + "output": "0", + "index": 23455 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_arch_init(MachineState *ms, KVMState *s)\n\n{\n\n MachineClass *mc = MACHINE_GET_CLASS(ms);\n\n\n\n mc->default_cpu_type = S390_CPU_TYPE_NAME(\"host\");\n\n cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);\n\n cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);\n\n cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);\n\n cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);\n\n\n\n if (!kvm_check_extension(s, KVM_CAP_S390_GMAP)\n\n || !kvm_check_extension(s, KVM_CAP_S390_COW)) {\n\n phys_mem_set_alloc(legacy_s390_alloc);\n\n }\n\n\n\n kvm_vm_enable_cap(s, KVM_CAP_S390_USER_SIGP, 0);\n\n kvm_vm_enable_cap(s, KVM_CAP_S390_VECTOR_REGISTERS, 0);\n\n kvm_vm_enable_cap(s, KVM_CAP_S390_USER_STSI, 0);\n\n if (ri_allowed()) {\n\n if (kvm_vm_enable_cap(s, KVM_CAP_S390_RI, 0) == 0) {\n\n cap_ri = 1;\n\n }\n\n }\n\n if (gs_allowed()) {\n\n if (kvm_vm_enable_cap(s, KVM_CAP_S390_GS, 0) == 0) {\n\n cap_gs = 1;\n\n }\n\n }\n\n\n\n /*\n\n * The migration interface for ais was introduced with kernel 4.13\n\n * but the capability itself had been active since 4.12. As migration\n\n * support is considered necessary let's disable ais in the 2.10\n\n * machine.\n\n */\n\n /* kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); */\n\n\n\n qemu_mutex_init(&qemu_sigp_mutex);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8682 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov,\n\n AVFormatContext *s)\n\n{\n\n int i;\n\n offset_t pos = url_ftell(pb);\n\n put_be32(pb, 0); /* size placeholder*/\n\n put_tag(pb, \"moov\");\n\n mov->timescale = globalTimescale;\n\n\n\n for (i=0; itracks[i].entry <= 0) continue;\n\n\n\n if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {\n\n mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den;\n\n mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num;\n\n } else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {\n\n mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate;\n\n mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size;\n\n }\n\n\n\n mov->tracks[i].trackDuration =\n\n (int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;\n\n mov->tracks[i].time = mov->time;\n\n mov->tracks[i].trackID = i+1;\n\n }\n\n\n\n mov_write_mvhd_tag(pb, mov);\n\n //mov_write_iods_tag(pb, mov);\n\n for (i=0; itracks[i].entry > 0) {\n\n mov_write_trak_tag(pb, &(mov->tracks[i]));\n\n }\n\n }\n\n\n\n if (mov->mode == MODE_PSP)\n\n mov_write_uuidusmt_tag(pb, s);\n\n else\n\n mov_write_udta_tag(pb, mov, s);\n\n\n\n return updateSize(pb, pos);\n\n}\n", + "output": "0", + "index": 18941 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_type_enum(Visitor *v, int *obj, const char *strings[],\n\n const char *kind, const char *name, Error **errp)\n\n{\n\n if (!error_is_set(errp)) {\n\n v->type_enum(v, obj, strings, kind, name, errp);\n\n }\n\n}\n", + "output": "1", + "index": 25719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)\n\n{\n\n if (ret && !monitor_has_error(mon)) {\n\n /*\n\n * If it returns failure, it must have passed on error.\n\n *\n\n * Action: Report an internal error to the client if in QMP.\n\n */\n\n if (monitor_ctrl_mode(mon)) {\n\n qerror_report(QERR_UNDEFINED_ERROR);\n\n }\n\n MON_DEBUG(\"command '%s' returned failure but did not pass an error\\n\",\n\n cmd->name);\n\n }\n\n\n\n#ifdef CONFIG_DEBUG_MONITOR\n\n if (!ret && monitor_has_error(mon)) {\n\n /*\n\n * If it returns success, it must not have passed an error.\n\n *\n\n * Action: Report the passed error to the client.\n\n */\n\n MON_DEBUG(\"command '%s' returned success but passed an error\\n\",\n\n cmd->name);\n\n }\n\n\n\n if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, \"info\") != 0) {\n\n /*\n\n * Handlers should not call Monitor print functions.\n\n *\n\n * Action: Ignore them in QMP.\n\n *\n\n * (XXX: we don't check any 'info' or 'query' command here\n\n * because the user print function _is_ called by do_info(), hence\n\n * we will trigger this check. This problem will go away when we\n\n * make 'query' commands real and kill do_info())\n\n */\n\n MON_DEBUG(\"command '%s' called print functions %d time(s)\\n\",\n\n cmd->name, mon_print_count_get(mon));\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 21493 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_subtitle_out(AVFormatContext *s,\n\n AVOutputStream *ost,\n\n AVInputStream *ist,\n\n AVSubtitle *sub,\n\n int64_t pts)\n\n{\n\n static uint8_t *subtitle_out = NULL;\n\n int subtitle_out_max_size = 65536;\n\n int subtitle_out_size, nb, i;\n\n AVCodecContext *enc;\n\n AVPacket pkt;\n\n\n\n if (pts == AV_NOPTS_VALUE) {\n\n fprintf(stderr, \"Subtitle packets must have a pts\\n\");\n\n if (exit_on_error)\n\n\n return;\n\n\n\n\n enc = ost->st->codec;\n\n\n\n if (!subtitle_out) {\n\n subtitle_out = av_malloc(subtitle_out_max_size);\n\n\n\n\n /* Note: DVB subtitle need one packet to draw them and one other\n\n packet to clear them */\n\n /* XXX: signal it in the codec context ? */\n\n if (enc->codec_id == CODEC_ID_DVB_SUBTITLE)\n\n nb = 2;\n\n else\n\n nb = 1;\n\n\n\n for(i = 0; i < nb; i++) {\n\n sub->pts = av_rescale_q(pts, ist->st->time_base, AV_TIME_BASE_Q);\n\n subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,\n\n subtitle_out_max_size, sub);\n\n\n\n\n\n\n\n av_init_packet(&pkt);\n\n pkt.stream_index = ost->index;\n\n pkt.data = subtitle_out;\n\n pkt.size = subtitle_out_size;\n\n pkt.pts = av_rescale_q(pts, ist->st->time_base, ost->st->time_base);\n\n if (enc->codec_id == CODEC_ID_DVB_SUBTITLE) {\n\n /* XXX: the pts correction is handled here. Maybe handling\n\n it in the codec would be better */\n\n if (i == 0)\n\n pkt.pts += 90 * sub->start_display_time;\n\n else\n\n pkt.pts += 90 * sub->end_display_time;\n\n\n write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);\n\n", + "output": "1", + "index": 10605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_read_primer_pack(MXFContext *mxf)\n\n{\n\n ByteIOContext *pb = mxf->fc->pb;\n\n int item_num = get_be32(pb);\n\n int item_len = get_be32(pb);\n\n\n\n if (item_len != 18) {\n\n av_log(mxf->fc, AV_LOG_ERROR, \"unsupported primer pack item length\\n\");\n\n return -1;\n\n }\n\n if (item_num > UINT_MAX / item_len)\n\n return -1;\n\n mxf->local_tags_count = item_num;\n\n mxf->local_tags = av_malloc(item_num*item_len);\n\n if (!mxf->local_tags)\n\n return -1;\n\n get_buffer(pb, mxf->local_tags, item_num*item_len);\n\n return 0;\n\n}\n", + "output": "1", + "index": 14045 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t helper_frsqrte (uint64_t arg)\n\n{\n\n CPU_DoubleU fone, farg;\n\n fone.ll = 0x3FF0000000000000ULL; /* 1.0 */\n\n farg.ll = arg;\n\n\n\n if (unlikely(float64_is_signaling_nan(farg.d))) {\n\n /* sNaN reciprocal square root */\n\n farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);\n\n } else 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(POWERPC_EXCP_FP_VXSQRT);\n\n } else if (likely(isnormal(farg.d))) {\n\n farg.d = float64_sqrt(farg.d, &env->fp_status);\n\n farg.d = float32_div(fone.d, farg.d, &env->fp_status);\n\n } else {\n\n if (farg.ll == 0x8000000000000000ULL) {\n\n farg.ll = 0xFFF0000000000000ULL;\n\n } else if (farg.ll == 0x0000000000000000ULL) {\n\n farg.ll = 0x7FF0000000000000ULL;\n\n } else if (float64_is_nan(farg.d)) {\n\n farg.ll |= 0x000FFFFFFFFFFFFFULL;\n\n } else if (float64_is_neg(farg.d)) {\n\n farg.ll = 0x7FF8000000000000ULL;\n\n } else {\n\n farg.ll = 0x0000000000000000ULL;\n\n }\n\n }\n\n return farg.ll;\n\n}\n", + "output": "0", + "index": 18250 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void libschroedinger_handle_first_access_unit(AVCodecContext *avctx)\n\n{\n\n SchroDecoderParams *p_schro_params = avctx->priv_data;\n\n SchroDecoder *decoder = p_schro_params->decoder;\n\n\n\n p_schro_params->format = schro_decoder_get_video_format(decoder);\n\n\n\n /* Tell FFmpeg about sequence details. */\n\n if (av_image_check_size(p_schro_params->format->width,\n\n p_schro_params->format->height, 0, avctx) < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"invalid dimensions (%dx%d)\\n\",\n\n p_schro_params->format->width, p_schro_params->format->height);\n\n avctx->height = avctx->width = 0;\n\n return;\n\n }\n\n avctx->height = p_schro_params->format->height;\n\n avctx->width = p_schro_params->format->width;\n\n avctx->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format);\n\n\n\n if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,\n\n &p_schro_params->frame_format) == -1) {\n\n av_log(avctx, AV_LOG_ERROR,\n\n \"This codec currently only supports planar YUV 4:2:0, 4:2:2 \"\n\n \"and 4:4:4 formats.\\n\");\n\n return;\n\n }\n\n\n\n avctx->framerate.num = p_schro_params->format->frame_rate_numerator;\n\n avctx->framerate.den = p_schro_params->format->frame_rate_denominator;\n\n}\n", + "output": "1", + "index": 9140 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)\n\n{\n\n AVFilterContext *ret;\n\n\n\n if (!filter)\n\n return NULL;\n\n\n\n ret = av_mallocz(sizeof(AVFilterContext));\n\n if (!ret)\n\n return NULL;\n\n\n\n ret->av_class = &avfilter_class;\n\n ret->filter = filter;\n\n ret->name = inst_name ? av_strdup(inst_name) : NULL;\n\n if (filter->priv_size) {\n\n ret->priv = av_mallocz(filter->priv_size);\n\n if (!ret->priv)\n\n goto err;\n\n }\n\n\n\n if (filter->priv_class) {\n\n *(const AVClass**)ret->priv = filter->priv_class;\n\n av_opt_set_defaults(ret->priv);\n\n }\n\n\n\n ret->nb_inputs = pad_count(filter->inputs);\n\n if (ret->nb_inputs ) {\n\n ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs);\n\n if (!ret->input_pads)\n\n goto err;\n\n memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->nb_inputs);\n\n ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->nb_inputs);\n\n if (!ret->inputs)\n\n goto err;\n\n }\n\n\n\n ret->nb_outputs = pad_count(filter->outputs);\n\n if (ret->nb_outputs) {\n\n ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_outputs);\n\n if (!ret->output_pads)\n\n goto err;\n\n memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->nb_outputs);\n\n ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->nb_outputs);\n\n if (!ret->outputs)\n\n goto err;\n\n }\n\n#if FF_API_FOO_COUNT\n\n ret->output_count = ret->nb_outputs;\n\n ret->input_count = ret->nb_inputs;\n\n#endif\n\n\n\n return ret;\n\n\n\nerr:\n\n av_freep(&ret->inputs);\n\n av_freep(&ret->input_pads);\n\n ret->nb_inputs = 0;\n\n av_freep(&ret->outputs);\n\n av_freep(&ret->output_pads);\n\n ret->nb_outputs = 0;\n\n av_freep(&ret->priv);\n\n av_free(ret);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 12100 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockDriverAIOCB *bdrv_aio_readv(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, 0);\n}", + "output": "1", + "index": 7627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vhost_user_cleanup(struct vhost_dev *dev)\n\n{\n\n struct vhost_user *u;\n\n\n\n assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);\n\n\n\n u = dev->opaque;\n\n if (u->slave_fd >= 0) {\n\n\n close(u->slave_fd);\n\n u->slave_fd = -1;\n\n }\n\n g_free(u);\n\n dev->opaque = 0;\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 1653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)\n\n{\n\n OpenRISCCPU *cpu = (OpenRISCCPU *)opaque;\n\n CPUState *cs = CPU(cpu);\n\n uint32_t irq_bit = 1 << irq;\n\n\n\n if (irq > 31 || irq < 0) {\n\n return;\n\n }\n\n\n\n if (level) {\n\n cpu->env.picsr |= irq_bit;\n\n } else {\n\n cpu->env.picsr &= ~irq_bit;\n\n }\n\n\n\n if (cpu->env.picsr & cpu->env.picmr) {\n\n cpu_interrupt(cs, CPU_INTERRUPT_HARD);\n\n } else {\n\n cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);\n\n cpu->env.picsr = 0;\n\n }\n\n}\n", + "output": "1", + "index": 25896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nic_cleanup(NetClientState *nc)\n\n{\n\n dp8393xState *s = qemu_get_nic_opaque(nc);\n\n\n\n memory_region_del_subregion(s->address_space, &s->mmio);\n\n memory_region_destroy(&s->mmio);\n\n\n\n timer_del(s->watchdog);\n\n timer_free(s->watchdog);\n\n\n\n g_free(s);\n\n}\n", + "output": "0", + "index": 16519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps,\n\n int is_nalff, int nal_length_size, void *logctx)\n\n{\n\n int i;\n\n int ret = 0;\n\n H2645Packet pkt = { 0 };\n\n\n\n ret = ff_h2645_packet_split(&pkt, buf, buf_size, logctx, is_nalff, nal_length_size, AV_CODEC_ID_HEVC, 1);\n\n if (ret < 0) {\n\n goto done;\n\n }\n\n\n\n for (i = 0; i < pkt.nb_nals; i++) {\n\n H2645NAL *nal = &pkt.nals[i];\n\n\n\n /* ignore everything except parameter sets and VCL NALUs */\n\n switch (nal->type) {\n\n case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break;\n\n case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break;\n\n case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break;\n\n default:\n\n av_log(logctx, AV_LOG_VERBOSE, \"Ignoring NAL type %d in extradata\\n\", nal->type);\n\n break;\n\n }\n\n }\n\n\n\ndone:\n\n ff_h2645_packet_uninit(&pkt);\n\n return ret;\n\n}\n", + "output": "1", + "index": 22225 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline void iadst4_1d(const dctcoef *in, ptrdiff_t stride,\n\n dctcoef *out, int pass)\n\n{\n\n int t0, t1, t2, t3;\n\n\n\n t0 = 5283 * IN(0) + 15212 * IN(2) + 9929 * IN(3);\n\n t1 = 9929 * IN(0) - 5283 * IN(2) - 15212 * IN(3);\n\n t2 = 13377 * (IN(0) - IN(2) + IN(3));\n\n t3 = 13377 * IN(1);\n\n\n\n out[0] = (t0 + t3 + (1 << 13)) >> 14;\n\n out[1] = (t1 + t3 + (1 << 13)) >> 14;\n\n out[2] = (t2 + (1 << 13)) >> 14;\n\n out[3] = (t0 + t1 - t3 + (1 << 13)) >> 14;\n\n}\n", + "output": "1", + "index": 16290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "unsigned int codec_get_tag(const CodecTag *tags, int id)\n\n{\n\n while (tags->id != 0) {\n\n if (tags->id == id)\n\n return tags->tag;\n\n tags++;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 9492 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_q35_init_1_6(QEMUMachineInitArgs *args)\n\n{\n\n has_pci_info = false;\n\n\n pc_q35_init(args);\n\n}", + "output": "1", + "index": 731 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,\n\n void *opaque, int absolute,\n\n const char *name)\n\n{\n\n QEMUPutMouseEntry *s;\n\n\n\n s = g_malloc0(sizeof(QEMUPutMouseEntry));\n\n\n\n s->qemu_put_mouse_event = func;\n\n s->qemu_put_mouse_event_opaque = opaque;\n\n s->qemu_put_mouse_event_absolute = absolute;\n\n\n\n s->h.name = name;\n\n s->h.mask = INPUT_EVENT_MASK_BTN |\n\n (absolute ? INPUT_EVENT_MASK_ABS : INPUT_EVENT_MASK_REL);\n\n s->h.event = legacy_mouse_event;\n\n s->h.sync = legacy_mouse_sync;\n\n s->s = qemu_input_handler_register((DeviceState *)s,\n\n &s->h);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 19993 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void blend_image_rgba_pm(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y)\n\n{\n\n blend_image_packed_rgb(ctx, dst, src, 1, x, y, 1);\n\n}\n", + "output": "0", + "index": 2432 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *nbd_client_thread(void *arg)\n\n{\n\n int fd = *(int *)arg;\n\n off_t size;\n\n size_t blocksize;\n\n uint32_t nbdflags;\n\n int sock;\n\n int ret;\n\n pthread_t show_parts_thread;\n\n\n\n do {\n\n sock = unix_socket_outgoing(sockpath);\n\n if (sock == -1) {\n\n goto out;\n\n }\n\n } while (sock == -1);\n\n\n\n ret = nbd_receive_negotiate(sock, NULL, &nbdflags,\n\n &size, &blocksize);\n\n if (ret == -1) {\n\n goto out;\n\n }\n\n\n\n ret = nbd_init(fd, sock, nbdflags, size, blocksize);\n\n if (ret == -1) {\n\n goto out;\n\n }\n\n\n\n /* update partition table */\n\n pthread_create(&show_parts_thread, NULL, show_parts, NULL);\n\n\n\n if (verbose) {\n\n fprintf(stderr, \"NBD device %s is now connected to %s\\n\",\n\n device, srcpath);\n\n } else {\n\n /* Close stderr so that the qemu-nbd process exits. */\n\n dup2(STDOUT_FILENO, STDERR_FILENO);\n\n }\n\n\n\n ret = nbd_client(fd);\n\n if (ret) {\n\n goto out;\n\n }\n\n close(fd);\n\n kill(getpid(), SIGTERM);\n\n return (void *) EXIT_SUCCESS;\n\n\n\nout:\n\n kill(getpid(), SIGTERM);\n\n return (void *) EXIT_FAILURE;\n\n}\n", + "output": "0", + "index": 8986 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int float32_le( float32 a, float32 b STATUS_PARAM )\n\n{\n\n flag aSign, bSign;\n\n\n\n if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )\n\n || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )\n\n ) {\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n return 0;\n\n }\n\n aSign = extractFloat32Sign( a );\n\n bSign = extractFloat32Sign( b );\n\n if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );\n\n return ( a == b ) || ( aSign ^ ( a < b ) );\n\n\n\n}\n", + "output": "0", + "index": 26022 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void visitor_output_setup_internal(TestOutputVisitorData *data,\n\n bool human)\n\n{\n\n data->human = human;\n\n data->sov = string_output_visitor_new(human);\n\n g_assert(data->sov);\n\n data->ov = string_output_get_visitor(data->sov);\n\n g_assert(data->ov);\n\n}\n", + "output": "0", + "index": 17596 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void stb_phys(target_phys_addr_t addr, uint32_t val)\n\n{\n\n uint8_t v = val;\n\n cpu_physical_memory_write(addr, &v, 1);\n\n}\n", + "output": "0", + "index": 19498 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void write_IRQreg (openpic_t *opp, int n_IRQ,\n\n uint32_t reg, uint32_t val)\n\n{\n\n uint32_t tmp;\n\n\n\n switch (reg) {\n\n case IRQ_IPVP:\n\n /* NOTE: not fully accurate for special IRQs, but simple and\n\n sufficient */\n\n /* ACTIVITY bit is read-only */\n\n opp->src[n_IRQ].ipvp =\n\n (opp->src[n_IRQ].ipvp & 0x40000000) |\n\n (val & 0x800F00FF);\n\n openpic_update_irq(opp, n_IRQ);\n\n DPRINTF(\"Set IPVP %d to 0x%08x -> 0x%08x\\n\",\n\n n_IRQ, val, opp->src[n_IRQ].ipvp);\n\n break;\n\n case IRQ_IDE:\n\n tmp = val & 0xC0000000;\n\n tmp |= val & ((1 << MAX_CPU) - 1);\n\n opp->src[n_IRQ].ide = tmp;\n\n DPRINTF(\"Set IDE %d to 0x%08x\\n\", n_IRQ, opp->src[n_IRQ].ide);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 26511 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_busid_cmd(ESPState *s, uint8_t *buf, uint8_t busid)\n\n{\n\n int32_t datalen;\n\n int lun;\n\n\n\n DPRINTF(\"do_busid_cmd: busid 0x%x\\n\", busid);\n\n lun = busid & 7;\n\n s->current_req = scsi_req_new(s->current_dev, 0, lun, NULL);\n\n datalen = scsi_req_enqueue(s->current_req, buf);\n\n s->ti_size = datalen;\n\n if (datalen != 0) {\n\n s->rregs[ESP_RSTAT] = STAT_TC;\n\n s->dma_left = 0;\n\n s->dma_counter = 0;\n\n if (datalen > 0) {\n\n s->rregs[ESP_RSTAT] |= STAT_DI;\n\n } else {\n\n s->rregs[ESP_RSTAT] |= STAT_DO;\n\n }\n\n scsi_req_continue(s->current_req);\n\n }\n\n s->rregs[ESP_RINTR] = INTR_BS | INTR_FC;\n\n s->rregs[ESP_RSEQ] = SEQ_CD;\n\n esp_raise_irq(s);\n\n}\n", + "output": "0", + "index": 51 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void audio_print_settings (audsettings_t *as)\n\n{\n\n dolog (\"frequency=%d nchannels=%d fmt=\", as->freq, as->nchannels);\n\n\n\n switch (as->fmt) {\n\n case AUD_FMT_S8:\n\n AUD_log (NULL, \"S8\");\n\n break;\n\n case AUD_FMT_U8:\n\n AUD_log (NULL, \"U8\");\n\n break;\n\n case AUD_FMT_S16:\n\n AUD_log (NULL, \"S16\");\n\n break;\n\n case AUD_FMT_U16:\n\n AUD_log (NULL, \"U16\");\n\n break;\n\n case AUD_FMT_S32:\n\n AUD_log (NULL, \"S32\");\n\n break;\n\n case AUD_FMT_U32:\n\n AUD_log (NULL, \"U32\");\n\n break;\n\n default:\n\n AUD_log (NULL, \"invalid(%d)\", as->fmt);\n\n break;\n\n }\n\n\n\n AUD_log (NULL, \" endianness=\");\n\n switch (as->endianness) {\n\n case 0:\n\n AUD_log (NULL, \"little\");\n\n break;\n\n case 1:\n\n AUD_log (NULL, \"big\");\n\n break;\n\n default:\n\n AUD_log (NULL, \"invalid\");\n\n break;\n\n }\n\n AUD_log (NULL, \"\\n\");\n\n}\n", + "output": "0", + "index": 24035 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void __attribute__((constructor)) coroutine_pool_init(void)\n\n{\n\n qemu_mutex_init(&pool_lock);\n\n}\n", + "output": "0", + "index": 18868 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t intel_hda_mmio_readb(void *opaque, target_phys_addr_t addr)\n\n{\n\n IntelHDAState *d = opaque;\n\n const IntelHDAReg *reg = intel_hda_reg_find(d, addr);\n\n\n\n return intel_hda_reg_read(d, reg, 0xff);\n\n}\n", + "output": "0", + "index": 18232 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qemu_acl *qemu_acl_init(const char *aclname)\n\n{\n\n qemu_acl *acl;\n\n\n\n acl = qemu_acl_find(aclname);\n\n if (acl)\n\n return acl;\n\n\n\n acl = qemu_malloc(sizeof(*acl));\n\n acl->aclname = qemu_strdup(aclname);\n\n /* Deny by default, so there is no window of \"open\n\n * access\" between QEMU starting, and the user setting\n\n * up ACLs in the monitor */\n\n acl->defaultDeny = 1;\n\n\n\n acl->nentries = 0;\n\n TAILQ_INIT(&acl->entries);\n\n\n\n acls = qemu_realloc(acls, sizeof(*acls) * (nacls +1));\n\n acls[nacls] = acl;\n\n nacls++;\n\n\n\n return acl;\n\n}\n", + "output": "0", + "index": 8656 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int recode_subtitle(AVCodecContext *avctx,\n\n AVPacket *outpkt, const AVPacket *inpkt)\n\n{\n\n#if CONFIG_ICONV\n\n iconv_t cd = (iconv_t)-1;\n\n int ret = 0;\n\n char *inb, *outb;\n\n size_t inl, outl;\n\n AVPacket tmp;\n\n#endif\n\n\n\n if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_PRE_DECODER)\n\n return 0;\n\n\n\n#if CONFIG_ICONV\n\n cd = iconv_open(\"UTF-8\", avctx->sub_charenc);\n\n av_assert0(cd != (iconv_t)-1);\n\n\n\n inb = inpkt->data;\n\n inl = inpkt->size;\n\n\n\n if (inl >= INT_MAX / UTF8_MAX_BYTES - FF_INPUT_BUFFER_PADDING_SIZE) {\n\n av_log(avctx, AV_LOG_ERROR, \"Subtitles packet is too big for recoding\\n\");\n\n ret = AVERROR(ENOMEM);\n\n goto end;\n\n }\n\n\n\n ret = av_new_packet(&tmp, inl * UTF8_MAX_BYTES);\n\n if (ret < 0)\n\n goto end;\n\n outpkt->buf = tmp.buf;\n\n outpkt->data = tmp.data;\n\n outpkt->size = tmp.size;\n\n outb = outpkt->data;\n\n outl = outpkt->size;\n\n\n\n if (iconv(cd, &inb, &inl, &outb, &outl) == (size_t)-1 ||\n\n iconv(cd, NULL, NULL, &outb, &outl) == (size_t)-1 ||\n\n outl >= outpkt->size || inl != 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Unable to recode subtitle event \\\"%s\\\" \"\n\n \"from %s to UTF-8\\n\", inpkt->data, avctx->sub_charenc);\n\n av_free_packet(&tmp);\n\n ret = AVERROR(errno);\n\n goto end;\n\n }\n\n outpkt->size -= outl;\n\n outpkt->data[outpkt->size - 1] = '\\0';\n\n\n\nend:\n\n if (cd != (iconv_t)-1)\n\n iconv_close(cd);\n\n return ret;\n\n#else\n\n av_assert0(!\"requesting subtitles recoding without iconv\");\n\n#endif\n\n}\n", + "output": "1", + "index": 22917 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c)\n\n{\n\n const char *proto = avio_find_protocol_name(s->filename);\n\n int http_base_proto = !av_strcasecmp(proto, \"http\") || !av_strcasecmp(proto, \"https\");\n\n\n\n if (c->method) {\n\n av_dict_set(options, \"method\", c->method, 0);\n\n } else if (proto && http_base_proto) {\n\n av_log(c, AV_LOG_WARNING, \"No HTTP method set, hls muxer defaulting to method PUT.\\n\");\n\n av_dict_set(options, \"method\", \"PUT\", 0);\n\n }\n\n}\n", + "output": "0", + "index": 16575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFrame *ff_framequeue_take(FFFrameQueue *fq)\n\n{\n\n FFFrameBucket *b;\n\n\n\n check_consistency(fq);\n\n av_assert1(fq->queued);\n\n b = bucket(fq, 0);\n\n fq->queued--;\n\n fq->tail++;\n\n fq->tail &= fq->allocated - 1;\n\n fq->total_frames_tail++;\n\n fq->total_samples_tail += b->frame->nb_samples;\n\n\n check_consistency(fq);\n\n return b->frame;\n\n}", + "output": "1", + "index": 23357 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static USBDevice *usb_msd_init(const char *filename)\n\n{\n\n static int nr=0;\n\n char id[8];\n\n QemuOpts *opts;\n\n DriveInfo *dinfo;\n\n USBDevice *dev;\n\n int fatal_error;\n\n const char *p1;\n\n char fmt[32];\n\n\n\n /* parse -usbdevice disk: syntax into drive opts */\n\n snprintf(id, sizeof(id), \"usb%d\", nr++);\n\n opts = qemu_opts_create(&qemu_drive_opts, id, 0);\n\n\n\n p1 = strchr(filename, ':');\n\n if (p1++) {\n\n const char *p2;\n\n\n\n if (strstart(filename, \"format=\", &p2)) {\n\n int len = MIN(p1 - p2, sizeof(fmt));\n\n pstrcpy(fmt, len, p2);\n\n qemu_opt_set(opts, \"format\", fmt);\n\n } else if (*filename != ':') {\n\n printf(\"unrecognized USB mass-storage option %s\\n\", filename);\n\n\n\n filename = p1;\n\n\n if (!*filename) {\n\n printf(\"block device specification needed\\n\");\n\n\n\n qemu_opt_set(opts, \"file\", filename);\n\n qemu_opt_set(opts, \"if\", \"none\");\n\n\n\n /* create host drive */\n\n dinfo = drive_init(opts, NULL, &fatal_error);\n\n if (!dinfo) {\n\n qemu_opts_del(opts);\n\n\n\n\n\n /* create guest device */\n\n dev = usb_create(NULL /* FIXME */, \"usb-storage\");\n\n\n\n\n qdev_prop_set_drive(&dev->qdev, \"drive\", dinfo);\n\n if (qdev_init(&dev->qdev) < 0)\n\n\n\n\n return dev;\n", + "output": "1", + "index": 18820 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nvdec_vc1_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": 3430 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tlb_fill(target_ulong addr, int is_write, int is_user, void *retaddr)\n\n{\n\n TranslationBlock *tb;\n\n int ret;\n\n unsigned long pc;\n\n CPUX86State *saved_env;\n\n\n\n /* XXX: hack to restore env in all cases, even if not called from\n\n generated code */\n\n saved_env = env;\n\n env = cpu_single_env;\n\n\n\n ret = cpu_x86_handle_mmu_fault(env, addr, is_write, is_user, 1);\n\n if (ret) {\n\n if (retaddr) {\n\n /* now we have a real cpu fault */\n\n pc = (unsigned long)retaddr;\n\n tb = tb_find_pc(pc);\n\n if (tb) {\n\n /* the PC is inside the translated code. It means that we have\n\n a virtual CPU fault */\n\n cpu_restore_state(tb, env, pc, NULL);\n\n }\n\n }\n\n if (retaddr)\n\n raise_exception_err(EXCP0E_PAGE, env->error_code);\n\n else\n\n raise_exception_err_norestore(EXCP0E_PAGE, env->error_code);\n\n }\n\n env = saved_env;\n\n}\n", + "output": "0", + "index": 20831 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_ldl_raw(uint64_t t0, uint64_t t1)\n\n{\n\n ldl_raw(t1, t0);\n\n}\n", + "output": "0", + "index": 4454 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bmdma_addr_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t data, unsigned width)\n\n{\n\n BMDMAState *bm = opaque;\n\n int shift = addr * 8;\n\n uint32_t mask = (1ULL << (width * 8)) - 1;\n\n\n\n#ifdef DEBUG_IDE\n\n printf(\"%s: 0x%08x\\n\", __func__, (unsigned)data);\n\n#endif\n\n bm->addr &= ~(mask << shift);\n\n bm->addr |= ((data & mask) << shift) & ~3;\n\n}\n", + "output": "0", + "index": 24597 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ahci_init_d2h(AHCIDevice *ad)\n\n{\n\n IDEState *ide_state = &ad->port.ifs[0];\n\n AHCIPortRegs *pr = &ad->port_regs;\n\n\n\n if (ad->init_d2h_sent) {\n\n return;\n\n }\n\n\n\n if (ahci_write_fis_d2h(ad)) {\n\n ad->init_d2h_sent = true;\n\n /* We're emulating receiving the first Reg H2D Fis from the device;\n\n * Update the SIG register, but otherwise proceed as normal. */\n\n pr->sig = (ide_state->hcyl << 24) |\n\n (ide_state->lcyl << 16) |\n\n (ide_state->sector << 8) |\n\n (ide_state->nsector & 0xFF);\n\n }\n\n}\n", + "output": "1", + "index": 3697 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool timer_expired_ns(QEMUTimer *timer_head, int64_t current_time)\n\n{\n\n return timer_head && (timer_head->expire_time <= current_time);\n\n}\n", + "output": "0", + "index": 10523 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr)\n\n{\n\n uintptr_t ra = GETPC();\n\n uint64_t hi, lo;\n\n\n\n if (parallel_cpus) {\n\n#ifndef CONFIG_ATOMIC128\n\n cpu_loop_exit_atomic(ENV_GET_CPU(env), ra);\n\n#else\n\n int mem_idx = cpu_mmu_index(env, false);\n\n TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx);\n\n Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra);\n\n hi = int128_gethi(v);\n\n lo = int128_getlo(v);\n\n#endif\n\n } else {\n\n check_alignment(env, addr, 16, ra);\n\n\n\n hi = cpu_ldq_data_ra(env, addr + 0, ra);\n\n lo = cpu_ldq_data_ra(env, addr + 8, ra);\n\n }\n\n\n\n env->retxl = lo;\n\n return hi;\n\n}\n", + "output": "0", + "index": 7038 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pdu_submit(V9fsPDU *pdu)\n\n{\n\n Coroutine *co;\n\n CoroutineEntry *handler;\n\n V9fsState *s = pdu->s;\n\n\n\n if (pdu->id >= ARRAY_SIZE(pdu_co_handlers) ||\n\n (pdu_co_handlers[pdu->id] == NULL)) {\n\n handler = v9fs_op_not_supp;\n\n } else {\n\n handler = pdu_co_handlers[pdu->id];\n\n }\n\n\n\n if (is_ro_export(&s->ctx) && !is_read_only_op(pdu)) {\n\n handler = v9fs_fs_ro;\n\n }\n\n co = qemu_coroutine_create(handler);\n\n qemu_coroutine_enter(co, pdu);\n\n}\n", + "output": "1", + "index": 2151 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_dma_cancel(BMDMAState *bm)\n\n{\n\n if (bm->status & BM_STATUS_DMAING) {\n\n bm->status &= ~BM_STATUS_DMAING;\n\n /* cancel DMA request */\n\n bm->unit = -1;\n\n bm->dma_cb = NULL;\n\n if (bm->aiocb) {\n\n#ifdef DEBUG_AIO\n\n printf(\"aio_cancel\\n\");\n\n#endif\n\n bdrv_aio_cancel(bm->aiocb);\n\n bm->aiocb = NULL;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 14271 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)\n\n{\n\n return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);\n\n}\n", + "output": "0", + "index": 3231 + }, + { + "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 const AVCodec *codec = avctx->codec;\n\n\n\n pthread_mutex_lock(&p->mutex);\n\n while (1) {\n\n while (p->state == STATE_INPUT_READY && !fctx->die)\n\n pthread_cond_wait(&p->input_cond, &p->mutex);\n\n\n\n if (fctx->die) break;\n\n\n\n if (!codec->update_thread_context && (avctx->thread_safe_callbacks || (\n\n#if FF_API_GET_BUFFER\n\n !avctx->get_buffer &&\n\n#endif\n\n avctx->get_buffer2 == avcodec_default_get_buffer2)))\n\n ff_thread_finish_setup(avctx);\n\n\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 /* many decoders assign whole AVFrames, thus overwriting extended_data;\n\n * make sure it's set correctly */\n\n p->frame.extended_data = p->frame.data;\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#if 0 //BUFREF-FIXME\n\n for (i = 0; i < MAX_BUFFERS; i++)\n\n if (p->progress_used[i] && (p->got_frame || p->result<0 || avctx->codec_id != AV_CODEC_ID_H264)) {\n\n p->progress[i][0] = INT_MAX;\n\n p->progress[i][1] = INT_MAX;\n\n }\n\n#endif\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 return NULL;\n\n}\n", + "output": "0", + "index": 17516 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline abi_long host_to_target_timespec(abi_ulong target_addr,\n\n struct timespec *host_ts)\n\n{\n\n struct target_timespec *target_ts;\n\n\n\n if (!lock_user_struct(VERIFY_WRITE, target_ts, target_addr, 0))\n\n return -TARGET_EFAULT;\n\n target_ts->tv_sec = tswapal(host_ts->tv_sec);\n\n target_ts->tv_nsec = tswapal(host_ts->tv_nsec);\n\n unlock_user_struct(target_ts, target_addr, 1);\n\n return 0;\n\n}\n", + "output": "1", + "index": 15217 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int socket_open_listen(struct sockaddr_in *my_addr)\n\n{\n\n int server_fd, tmp;\n\n\n\n server_fd = socket(AF_INET,SOCK_STREAM,0);\n\n if (server_fd < 0) {\n\n perror (\"socket\");\n\n return -1;\n\n }\n\n\n\n tmp = 1;\n\n setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));\n\n\n\n\n if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {\n\n char bindmsg[32];\n\n snprintf(bindmsg, sizeof(bindmsg), \"bind(port %d)\", ntohs(my_addr->sin_port));\n\n perror (bindmsg);\n\n closesocket(server_fd);\n\n return -1;\n\n }\n\n\n\n if (listen (server_fd, 5) < 0) {\n\n perror (\"listen\");\n\n closesocket(server_fd);\n\n return -1;\n\n }\n\n ff_socket_nonblock(server_fd, 1);\n\n\n\n return server_fd;\n\n}", + "output": "1", + "index": 5159 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int print_uint16(DeviceState *dev, Property *prop, char *dest, size_t len)\n\n{\n\n uint16_t *ptr = qdev_get_prop_ptr(dev, prop);\n\n return snprintf(dest, len, \"%\" PRIu16, *ptr);\n\n}\n", + "output": "1", + "index": 18622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *bsd_vmalloc(size_t size)\n\n{\n\n void *p;\n\n mmap_lock();\n\n /* Use map and mark the pages as used. */\n\n p = mmap(NULL, size, PROT_READ | PROT_WRITE,\n\n MAP_PRIVATE | MAP_ANON, -1, 0);\n\n\n\n if (h2g_valid(p)) {\n\n /* Allocated region overlaps guest address space.\n\n This may recurse. */\n\n abi_ulong addr = h2g(p);\n\n page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),\n\n PAGE_RESERVED);\n\n }\n\n\n\n mmap_unlock();\n\n return p;\n\n}\n", + "output": "1", + "index": 27075 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(invalid_array_comma)\n\n{\n\n QObject *obj = qobject_from_json(\"[32,}\");\n\n fail_unless(obj == NULL);\n\n}\n", + "output": "0", + "index": 7225 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv val)\n\n{\n\n TCGv tmp;\n\n tmp = new_tmp();\n\n tcg_gen_trunc_i64_i32(tmp, val);\n\n store_reg(s, rlow, tmp);\n\n tmp = new_tmp();\n\n tcg_gen_shri_i64(val, val, 32);\n\n tcg_gen_trunc_i64_i32(tmp, val);\n\n store_reg(s, rhigh, tmp);\n\n}\n", + "output": "0", + "index": 24164 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void m5208_timer_write(void *opaque, target_phys_addr_t offset,\n\n uint64_t value, unsigned size)\n\n{\n\n m5208_timer_state *s = (m5208_timer_state *)opaque;\n\n int prescale;\n\n int limit;\n\n switch (offset) {\n\n case 0:\n\n /* The PIF bit is set-to-clear. */\n\n if (value & PCSR_PIF) {\n\n s->pcsr &= ~PCSR_PIF;\n\n value &= ~PCSR_PIF;\n\n }\n\n /* Avoid frobbing the timer if we're just twiddling IRQ bits. */\n\n if (((s->pcsr ^ value) & ~PCSR_PIE) == 0) {\n\n s->pcsr = value;\n\n m5208_timer_update(s);\n\n return;\n\n }\n\n\n\n if (s->pcsr & PCSR_EN)\n\n ptimer_stop(s->timer);\n\n\n\n s->pcsr = value;\n\n\n\n prescale = 1 << ((s->pcsr & PCSR_PRE_MASK) >> PCSR_PRE_SHIFT);\n\n ptimer_set_freq(s->timer, (SYS_FREQ / 2) / prescale);\n\n if (s->pcsr & PCSR_RLD)\n\n limit = s->pmr;\n\n else\n\n limit = 0xffff;\n\n ptimer_set_limit(s->timer, limit, 0);\n\n\n\n if (s->pcsr & PCSR_EN)\n\n ptimer_run(s->timer, 0);\n\n break;\n\n case 2:\n\n s->pmr = value;\n\n s->pcsr &= ~PCSR_PIF;\n\n if ((s->pcsr & PCSR_RLD) == 0) {\n\n if (s->pcsr & PCSR_OVW)\n\n ptimer_set_count(s->timer, value);\n\n } else {\n\n ptimer_set_limit(s->timer, value, s->pcsr & PCSR_OVW);\n\n }\n\n break;\n\n case 4:\n\n break;\n\n default:\n\n hw_error(\"m5208_timer_write: Bad offset 0x%x\\n\", (int)offset);\n\n break;\n\n }\n\n m5208_timer_update(s);\n\n}\n", + "output": "0", + "index": 21745 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static RawAIOCB *raw_aio_setup(BlockDriverState *bs, int64_t sector_num,\n\n QEMUIOVector *qiov, int nb_sectors,\n\n BlockDriverCompletionFunc *cb, void *opaque)\n\n{\n\n BDRVRawState *s = bs->opaque;\n\n RawAIOCB *acb;\n\n\n\n if (fd_open(bs) < 0)\n\n return NULL;\n\n\n\n acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque);\n\n if (!acb)\n\n return NULL;\n\n acb->aiocb.aio_fildes = s->fd;\n\n acb->aiocb.ev_signo = SIGUSR2;\n\n acb->aiocb.aio_iov = qiov->iov;\n\n acb->aiocb.aio_niov = qiov->niov;\n\n acb->aiocb.aio_nbytes = nb_sectors * 512;\n\n acb->aiocb.aio_offset = sector_num * 512;\n\n acb->aiocb.aio_flags = 0;\n\n\n\n /*\n\n * If O_DIRECT is used the buffer needs to be aligned on a sector\n\n * boundary. Tell the low level code to ensure that in case it's\n\n * not done yet.\n\n */\n\n if (s->aligned_buf)\n\n acb->aiocb.aio_flags |= QEMU_AIO_SECTOR_ALIGNED;\n\n\n\n acb->next = posix_aio_state->first_aio;\n\n posix_aio_state->first_aio = acb;\n\n return acb;\n\n}\n", + "output": "0", + "index": 15914 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_blk_migration_it(void *opaque, BlockDriverState *bs)\n\n{\n\n BlkMigDevState *bmds;\n\n int64_t sectors;\n\n\n\n if (!bdrv_is_read_only(bs)) {\n\n sectors = bdrv_nb_sectors(bs);\n\n if (sectors <= 0) {\n\n return;\n\n }\n\n\n\n bmds = g_malloc0(sizeof(BlkMigDevState));\n\n bmds->bs = bs;\n\n bmds->bulk_completed = 0;\n\n bmds->total_sectors = sectors;\n\n bmds->completed_sectors = 0;\n\n bmds->shared_base = block_mig_state.shared_base;\n\n alloc_aio_bitmap(bmds);\n\n error_setg(&bmds->blocker, \"block device is in use by migration\");\n\n bdrv_op_block_all(bs, bmds->blocker);\n\n bdrv_ref(bs);\n\n\n\n block_mig_state.total_sector_sum += sectors;\n\n\n\n if (bmds->shared_base) {\n\n DPRINTF(\"Start migration for %s with shared base image\\n\",\n\n bs->device_name);\n\n } else {\n\n DPRINTF(\"Start full migration for %s\\n\", bs->device_name);\n\n }\n\n\n\n QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry);\n\n }\n\n}\n", + "output": "1", + "index": 8512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n SegmentContext *seg = s->priv_data;\n\n AVFormatContext *oc = seg->avf;\n\n AVStream *st = s->streams[pkt->stream_index];\n\n int64_t end_pts = seg->recording_time * seg->number;\n\n int ret, can_split = 1;\n\n\n\n if (!oc)\n\n return AVERROR(EINVAL);\n\n\n\n if (seg->has_video) {\n\n can_split = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\n\n pkt->flags & AV_PKT_FLAG_KEY;\n\n }\n\n\n\n if (can_split && av_compare_ts(pkt->pts, st->time_base, end_pts,\n\n AV_TIME_BASE_Q) >= 0) {\n\n av_log(s, AV_LOG_DEBUG, \"Next segment starts at %d %\"PRId64\"\\n\",\n\n pkt->stream_index, pkt->pts);\n\n\n\n ret = segment_end(oc, seg->individual_header_trailer);\n\n\n\n if (!ret)\n\n ret = segment_start(s, seg->individual_header_trailer);\n\n\n\n if (ret)\n\n goto fail;\n\n\n\n oc = seg->avf;\n\n\n\n if (seg->list) {\n\n if (seg->list_type == LIST_HLS) {\n\n if ((ret = segment_hls_window(s, 0)) < 0)\n\n goto fail;\n\n } else {\n\n avio_printf(seg->pb, \"%s\\n\", oc->filename);\n\n avio_flush(seg->pb);\n\n if (seg->size && !(seg->number % seg->size)) {\n\n avio_closep(&seg->pb);\n\n if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,\n\n &s->interrupt_callback, NULL)) < 0)\n\n goto fail;\n\n }\n\n }\n\n }\n\n }\n\n\n\n ret = ff_write_chained(oc, pkt->stream_index, pkt, s);\n\n\n\nfail:\n\n if (ret < 0)\n\n seg_free_context(seg);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 23209 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gd_update(DisplayChangeListener *dcl,\n\n DisplayState *ds, int x, int y, int w, int h)\n\n{\n\n GtkDisplayState *s = ds->opaque;\n\n int x1, x2, y1, y2;\n\n int mx, my;\n\n int fbw, fbh;\n\n int ww, wh;\n\n\n\n DPRINTF(\"update(x=%d, y=%d, w=%d, h=%d)\\n\", x, y, w, h);\n\n\n\n x1 = floor(x * s->scale_x);\n\n y1 = floor(y * s->scale_y);\n\n\n\n x2 = ceil(x * s->scale_x + w * s->scale_x);\n\n y2 = ceil(y * s->scale_y + h * s->scale_y);\n\n\n\n fbw = ds_get_width(s->ds) * s->scale_x;\n\n fbh = ds_get_height(s->ds) * s->scale_y;\n\n\n\n gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh);\n\n\n\n mx = my = 0;\n\n if (ww > fbw) {\n\n mx = (ww - fbw) / 2;\n\n }\n\n if (wh > fbh) {\n\n my = (wh - fbh) / 2;\n\n }\n\n\n\n gtk_widget_queue_draw_area(s->drawing_area, mx + x1, my + y1, (x2 - x1), (y2 - y1));\n\n}\n", + "output": "1", + "index": 22575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_aio_cancel_async(BlockAIOCB *acb)\n\n{\n\n if (acb->aiocb_info->cancel_async) {\n\n acb->aiocb_info->cancel_async(acb);\n\n }\n\n}\n", + "output": "0", + "index": 9743 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sclp_execute(SCCB *sccb, uint64_t code)\n\n{\n\n S390SCLPDevice *sdev = get_event_facility();\n\n\n\n switch (code & SCLP_CMD_CODE_MASK) {\n\n case SCLP_CMDW_READ_SCP_INFO:\n\n case SCLP_CMDW_READ_SCP_INFO_FORCED:\n\n read_SCP_info(sccb);\n\n break;\n\n case SCLP_CMDW_READ_CPU_INFO:\n\n sclp_read_cpu_info(sccb);\n\n break;\n\n default:\n\n sdev->sclp_command_handler(sdev->ef, sccb, code);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 12319 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static PayloadContext *h264_new_extradata(void)\n\n{\n\n PayloadContext *data =\n\n av_mallocz(sizeof(PayloadContext) +\n\n FF_INPUT_BUFFER_PADDING_SIZE);\n\n\n\n if (data) {\n\n data->cookie = MAGIC_COOKIE;\n\n }\n\n\n\n return data;\n\n}\n", + "output": "0", + "index": 2160 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_synth_opendir(FsContext *ctx,\n\n V9fsPath *fs_path, V9fsFidOpenState *fs)\n\n{\n\n V9fsSynthOpenState *synth_open;\n\n V9fsSynthNode *node = *(V9fsSynthNode **)fs_path->data;\n\n\n\n synth_open = g_malloc(sizeof(*synth_open));\n\n synth_open->node = node;\n\n node->open_count++;\n\n fs->private = synth_open;\n\n return 0;\n\n}\n", + "output": "0", + "index": 25548 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))\n\n{\n\n unsigned int i;\n\n\n\n for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {\n\n (*cpu_fprintf)(f, \"Sparc %16s IU \" TARGET_FMT_lx \" FPU %08x MMU %08x NWINS %d \",\n\n sparc_defs[i].name,\n\n sparc_defs[i].iu_version,\n\n sparc_defs[i].fpu_version,\n\n sparc_defs[i].mmu_version,\n\n sparc_defs[i].nwindows);\n\n print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES &\n\n ~sparc_defs[i].features, \"-\");\n\n print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES &\n\n sparc_defs[i].features, \"+\");\n\n (*cpu_fprintf)(f, \"\\n\");\n\n }\n\n (*cpu_fprintf)(f, \"Default CPU feature flags (use '-' to remove): \");\n\n print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES, NULL);\n\n (*cpu_fprintf)(f, \"\\n\");\n\n (*cpu_fprintf)(f, \"Available CPU feature flags (use '+' to add): \");\n\n print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES, NULL);\n\n (*cpu_fprintf)(f, \"\\n\");\n\n (*cpu_fprintf)(f, \"Numerical features (use '=' to set): iu_version \"\n\n \"fpu_version mmu_version nwindows\\n\");\n\n}\n", + "output": "0", + "index": 25171 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_tlb_update(uint32_t T0)\n\n{\n\n#if !defined(CONFIG_USER_ONLY)\n\n\tuint32_t vaddr;\n\n\tuint32_t srs = env->pregs[PR_SRS];\n\n\n\n\tif (srs != 1 && srs != 2)\n\n\t\treturn;\n\n\n\n\tvaddr = cris_mmu_tlb_latest_update(env, T0);\n\n\tD(printf(\"flush old_vaddr=%x vaddr=%x T0=%x\\n\", vaddr, \n\n\t\t env->sregs[SFR_R_MM_CAUSE] & TARGET_PAGE_MASK, T0));\n\n\ttlb_flush_page(env, vaddr);\n\n#endif\n\n}\n", + "output": "0", + "index": 3256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_source_notify(void)\n\n{\n\n while (g_main_context_iteration(NULL, false));\n\n aio_notify(ctx);\n\n g_assert(g_main_context_iteration(NULL, true));\n\n g_assert(!g_main_context_iteration(NULL, false));\n\n}\n", + "output": "1", + "index": 25244 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void port92_init(ISADevice *dev, qemu_irq *a20_out)\n\n{\n\n Port92State *s = PORT92(dev);\n\n\n\n s->a20_out = a20_out;\n\n}\n", + "output": "0", + "index": 11669 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int avi_write_idx1(AVFormatContext *s)\n\n{\n\n AVIOContext *pb = s->pb;\n\n AVIContext *avi = s->priv_data;\n\n int64_t idx_chunk;\n\n int i;\n\n char tag[5];\n\n\n\n if (pb->seekable) {\n\n AVIStream *avist;\n\n AVIIentry *ie = 0, *tie;\n\n int empty, stream_id = -1;\n\n\n\n idx_chunk = ff_start_tag(pb, \"idx1\");\n\n for (i = 0; i < s->nb_streams; i++) {\n\n avist = s->streams[i]->priv_data;\n\n avist->entry = 0;\n\n }\n\n\n\n do {\n\n empty = 1;\n\n for (i = 0; i < s->nb_streams; i++) {\n\n avist = s->streams[i]->priv_data;\n\n if (avist->indexes.entry <= avist->entry)\n\n continue;\n\n\n\n tie = avi_get_ientry(&avist->indexes, avist->entry);\n\n if (empty || tie->pos < ie->pos) {\n\n ie = tie;\n\n stream_id = i;\n\n }\n\n empty = 0;\n\n }\n\n if (!empty) {\n\n avist = s->streams[stream_id]->priv_data;\n\n avi_stream2fourcc(tag, stream_id,\n\n s->streams[stream_id]->codecpar->codec_type);\n\n ffio_wfourcc(pb, tag);\n\n avio_wl32(pb, ie->flags);\n\n avio_wl32(pb, ie->pos);\n\n avio_wl32(pb, ie->len);\n\n avist->entry++;\n\n }\n\n } while (!empty);\n\n ff_end_tag(pb, idx_chunk);\n\n\n\n avi_write_counters(s, avi->riff_id);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 7911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_password(char *buf, int buf_size)\n\n{\n\n uint8_t ch;\n\n int i, ret;\n\n\n\n printf(\"password: \");\n\n fflush(stdout);\n\n term_init();\n\n i = 0;\n\n for(;;) {\n\n ret = read(0, &ch, 1);\n\n if (ret == -1) {\n\n if (errno == EAGAIN || errno == EINTR) {\n\n continue;\n\n } else {\n\n break;\n\n }\n\n } else if (ret == 0) {\n\n ret = -1;\n\n break;\n\n } else {\n\n if (ch == '\\r') {\n\n ret = 0;\n\n break;\n\n }\n\n if (i < (buf_size - 1))\n\n buf[i++] = ch;\n\n }\n\n }\n\n term_exit();\n\n buf[i] = '\\0';\n\n printf(\"\\n\");\n\n return ret;\n\n}\n", + "output": "0", + "index": 1124 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void copy_bits(PutBitContext *pb,\n\n const uint8_t *data, int size,\n\n GetBitContext *gb, int nbits)\n\n{\n\n int rmn_bytes, rmn_bits;\n\n\n\n rmn_bits = rmn_bytes = get_bits_left(gb);\n\n if (rmn_bits < nbits)\n\n\n\n\n rmn_bits &= 7; rmn_bytes >>= 3;\n\n if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0)\n\n put_bits(pb, rmn_bits, get_bits(gb, rmn_bits));\n\n ff_copy_bits(pb, data + size - rmn_bytes,\n\n FFMIN(nbits - rmn_bits, rmn_bytes << 3));\n\n}", + "output": "1", + "index": 18579 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, int rwx, vaddr eaddr,\n\n uint64_t base_addr, uint64_t nls,\n\n hwaddr *raddr, int *psize,\n\n int *fault_cause, int *prot,\n\n hwaddr *pte_addr)\n\n{\n\n CPUState *cs = CPU(cpu);\n\n uint64_t index, pde;\n\n\n\n if (nls < 5) { /* Directory maps less than 2**5 entries */\n\n *fault_cause |= DSISR_R_BADCONFIG;\n\n return 0;\n\n }\n\n\n\n /* Read page entry from guest address space */\n\n index = eaddr >> (*psize - nls); /* Shift */\n\n index &= ((1UL << nls) - 1); /* Mask */\n\n pde = ldq_phys(cs->as, base_addr + (index * sizeof(pde)));\n\n if (!(pde & R_PTE_VALID)) { /* Invalid Entry */\n\n *fault_cause |= DSISR_NOPTE;\n\n return 0;\n\n }\n\n\n\n *psize -= nls;\n\n\n\n /* Check if Leaf Entry -> Page Table Entry -> Stop the Search */\n\n if (pde & R_PTE_LEAF) {\n\n uint64_t rpn = pde & R_PTE_RPN;\n\n uint64_t mask = (1UL << *psize) - 1;\n\n\n\n if (ppc_radix64_check_prot(cpu, rwx, pde, fault_cause, prot)) {\n\n return 0; /* Protection Denied Access */\n\n }\n\n\n\n /* Or high bits of rpn and low bits to ea to form whole real addr */\n\n *raddr = (rpn & ~mask) | (eaddr & mask);\n\n *pte_addr = base_addr + (index * sizeof(pde));\n\n return pde;\n\n }\n\n\n\n /* Next Level of Radix Tree */\n\n return ppc_radix64_walk_tree(cpu, rwx, eaddr, pde & R_PDE_NLB,\n\n pde & R_PDE_NLS, raddr, psize,\n\n fault_cause, prot, pte_addr);\n\n}\n", + "output": "0", + "index": 7750 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t omap_wd_timer_read(void *opaque, target_phys_addr_t addr,\n\n 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_read16(opaque, addr);\n\n }\n\n\n\n switch (addr) {\n\n case 0x00:\t/* CNTL_TIMER */\n\n return (s->timer.ptv << 9) | (s->timer.ar << 8) |\n\n (s->timer.st << 7) | (s->free << 1);\n\n\n\n case 0x04:\t/* READ_TIMER */\n\n return omap_timer_read(&s->timer);\n\n\n\n case 0x08:\t/* TIMER_MODE */\n\n return s->mode << 15;\n\n }\n\n\n\n OMAP_BAD_REG(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 8943 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_native_list_string(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefNativeListUnion *cvalue = NULL;\n\n strList *elem = NULL;\n\n Visitor *v;\n\n GString *gstr_list = g_string_new(\"\");\n\n GString *gstr_union = g_string_new(\"\");\n\n int i;\n\n\n\n for (i = 0; i < 32; i++) {\n\n g_string_append_printf(gstr_list, \"'%d'\", i);\n\n if (i != 31) {\n\n g_string_append(gstr_list, \", \");\n\n }\n\n }\n\n g_string_append_printf(gstr_union, \"{ 'type': 'string', 'data': [ %s ] }\",\n\n gstr_list->str);\n\n v = visitor_input_test_init_raw(data, gstr_union->str);\n\n\n\n visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);\n\n g_assert(cvalue != NULL);\n\n g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);\n\n\n\n for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) {\n\n gchar str[8];\n\n sprintf(str, \"%d\", i);\n\n g_assert_cmpstr(elem->value, ==, str);\n\n }\n\n\n\n g_string_free(gstr_union, true);\n\n g_string_free(gstr_list, true);\n\n qapi_free_UserDefNativeListUnion(cvalue);\n\n}\n", + "output": "0", + "index": 14565 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_uint64_as_uint32(QEMUFile *f, void *pv, size_t size,\n\n VMStateField *field)\n\n{\n\n uint64_t *v = pv;\n\n *v = qemu_get_be32(f);\n\n return 0;\n\n}\n", + "output": "0", + "index": 50 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,\n\n const VMStateDescription *vmsd,\n\n void *opaque, int alias_id,\n\n int required_for_version,\n\n Error **errp)\n\n{\n\n SaveStateEntry *se;\n\n\n\n /* If this triggers, alias support can be dropped for the vmsd. */\n\n assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);\n\n\n\n se = g_new0(SaveStateEntry, 1);\n\n se->version_id = vmsd->version_id;\n\n se->section_id = savevm_state.global_section_id++;\n\n se->opaque = opaque;\n\n se->vmsd = vmsd;\n\n se->alias_id = alias_id;\n\n\n\n if (dev) {\n\n char *id = qdev_get_dev_path(dev);\n\n if (id) {\n\n if (snprintf(se->idstr, sizeof(se->idstr), \"%s/\", id) >=\n\n sizeof(se->idstr)) {\n\n error_setg(errp, \"Path too long for VMState (%s)\", id);\n\n\n g_free(se);\n\n\n\n return -1;\n\n }\n\n\n\n\n se->compat = g_new0(CompatEntry, 1);\n\n pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);\n\n se->compat->instance_id = instance_id == -1 ?\n\n calculate_compat_instance_id(vmsd->name) : instance_id;\n\n instance_id = -1;\n\n }\n\n }\n\n pstrcat(se->idstr, sizeof(se->idstr), vmsd->name);\n\n\n\n if (instance_id == -1) {\n\n se->instance_id = calculate_new_instance_id(se->idstr);\n\n } else {\n\n se->instance_id = instance_id;\n\n }\n\n assert(!se->compat || se->instance_id == 0);\n\n savevm_state_handler_insert(se);\n\n return 0;\n\n}", + "output": "1", + "index": 25041 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cudaupload_query_formats(AVFilterContext *ctx)\n\n{\n\n static const enum AVPixelFormat input_pix_fmts[] = {\n\n AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,\n\n AV_PIX_FMT_NONE,\n\n };\n\n static const enum AVPixelFormat output_pix_fmts[] = {\n\n AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,\n\n };\n\n AVFilterFormats *in_fmts = ff_make_format_list(input_pix_fmts);\n\n AVFilterFormats *out_fmts = ff_make_format_list(output_pix_fmts);\n\n\n\n ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats);\n\n ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 19030 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void memory_region_write_thunk_n(void *_mr,\n\n target_phys_addr_t addr,\n\n unsigned size,\n\n uint64_t data)\n\n{\n\n MemoryRegion *mr = _mr;\n\n\n\n if (!memory_region_access_valid(mr, addr, size)) {\n\n return; /* FIXME: better signalling */\n\n }\n\n\n\n if (!mr->ops->write) {\n\n mr->ops->old_mmio.write[bitops_ffsl(size)](mr->opaque, addr, data);\n\n return;\n\n }\n\n\n\n /* FIXME: support unaligned access */\n\n access_with_adjusted_size(addr + mr->offset, &data, size,\n\n mr->ops->impl.min_access_size,\n\n mr->ops->impl.max_access_size,\n\n memory_region_write_accessor, mr);\n\n}\n", + "output": "0", + "index": 4623 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t cc_calc_abs_32(int32_t dst)\n\n{\n\n if ((uint32_t)dst == 0x80000000UL) {\n\n return 3;\n\n } else if (dst) {\n\n return 1;\n\n } else {\n\n return 0;\n\n }\n\n}\n", + "output": "1", + "index": 12346 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint32_t ne2000_mem_readl(NE2000State *s, uint32_t addr)\n\n{\n\n addr &= ~1; /* XXX: check exact behaviour if not even */\n\n if (addr < 32 ||\n\n (addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {\n\n return ldl_le_p(s->mem + addr);\n\n } else {\n\n return 0xffffffff;\n\n }\n\n}\n", + "output": "0", + "index": 18653 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void wm8750_set_bclk_in(void *opaque, int hz)\n\n{\n\n struct wm8750_s *s = (struct wm8750_s *) opaque;\n\n\n\n s->ext_adc_hz = hz;\n\n s->ext_dac_hz = hz;\n\n wm8750_clk_update(s, 1);\n\n}\n", + "output": "1", + "index": 20471 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, \n\n uint32_t *ext_features, \n\n uint32_t *ext2_features, \n\n uint32_t *ext3_features)\n\n{\n\n int i;\n\n int found = 0;\n\n\n\n for ( i = 0 ; i < 32 ; i++ ) \n\n if (feature_name[i] && !strcmp (flagname, feature_name[i])) {\n\n *features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ ) \n\n if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {\n\n *ext_features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ ) \n\n if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {\n\n *ext2_features |= 1 << i;\n\n found = 1;\n\n }\n\n for ( i = 0 ; i < 32 ; i++ ) \n\n if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {\n\n *ext3_features |= 1 << i;\n\n found = 1;\n\n }\n\n if (!found) {\n\n fprintf(stderr, \"CPU feature %s not found\\n\", flagname);\n\n }\n\n}\n", + "output": "0", + "index": 4128 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int write_note(struct memelfnote *men, int fd)\n\n{\n\n struct elf_note en;\n\n\n\n en.n_namesz = men->namesz;\n\n en.n_type = men->type;\n\n en.n_descsz = men->datasz;\n\n\n\n bswap_note(&en);\n\n\n\n if (dump_write(fd, &en, sizeof(en)) != 0)\n\n return (-1);\n\n if (dump_write(fd, men->name, men->namesz_rounded) != 0)\n\n return (-1);\n\n if (dump_write(fd, men->data, men->datasz) != 0)\n\n return (-1);\n\n\n\n return (0);\n\n}\n", + "output": "0", + "index": 1913 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t pxa2xx_i2s_read(void *opaque, hwaddr addr,\n\n unsigned size)\n\n{\n\n PXA2xxI2SState *s = (PXA2xxI2SState *) opaque;\n\n\n\n switch (addr) {\n\n case SACR0:\n\n return s->control[0];\n\n case SACR1:\n\n return s->control[1];\n\n case SASR0:\n\n return s->status;\n\n case SAIMR:\n\n return s->mask;\n\n case SAICR:\n\n return 0;\n\n case SADIV:\n\n return s->clk;\n\n case SADR:\n\n if (s->rx_len > 0) {\n\n s->rx_len --;\n\n pxa2xx_i2s_update(s);\n\n return s->codec_in(s->opaque);\n\n }\n\n return 0;\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": 500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_chown(FsContext *ctx, const char *path, uid_t uid, gid_t gid)\n\n{\n\n return chown(rpath(ctx, path), uid, gid);\n\n}\n", + "output": "0", + "index": 1607 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int load_elf(const char *filename, int64_t virt_to_phys_addend,\n\n uint64_t *pentry)\n\n{\n\n int fd, data_order, must_swab, ret;\n\n uint8_t e_ident[EI_NIDENT];\n\n\n\n fd = open(filename, O_RDONLY | O_BINARY);\n\n if (fd < 0) {\n\n perror(filename);\n\n return -1;\n\n }\n\n if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident))\n\n goto fail;\n\n if (e_ident[0] != ELFMAG0 ||\n\n e_ident[1] != ELFMAG1 ||\n\n e_ident[2] != ELFMAG2 ||\n\n e_ident[3] != ELFMAG3)\n\n goto fail;\n\n#ifdef WORDS_BIGENDIAN\n\n data_order = ELFDATA2MSB;\n\n#else\n\n data_order = ELFDATA2LSB;\n\n#endif\n\n must_swab = data_order != e_ident[EI_DATA];\n\n \n\n lseek(fd, 0, SEEK_SET);\n\n if (e_ident[EI_CLASS] == ELFCLASS64) {\n\n ret = load_elf64(fd, virt_to_phys_addend, must_swab, pentry);\n\n } else {\n\n ret = load_elf32(fd, virt_to_phys_addend, must_swab, pentry);\n\n }\n\n\n\n close(fd);\n\n return ret;\n\n\n\n fail:\n\n close(fd);\n\n return -1;\n\n}\n", + "output": "0", + "index": 6937 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void error_callback_bh(void *opaque)\n\n{\n\n Coroutine *co = opaque;\n\n qemu_coroutine_enter(co);\n\n}\n", + "output": "1", + "index": 1025 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_t len)\n\n{\n\n char *mechname = malloc(len + 1);\n\n if (!mechname) {\n\n VNC_DEBUG(\"Out of memory reading mechname\\n\");\n\n vnc_client_error(vs);\n\n }\n\n strncpy(mechname, (char*)data, len);\n\n mechname[len] = '\\0';\n\n VNC_DEBUG(\"Got client mechname '%s' check against '%s'\\n\",\n\n mechname, vs->sasl.mechlist);\n\n\n\n if (strncmp(vs->sasl.mechlist, mechname, len) == 0) {\n\n if (vs->sasl.mechlist[len] != '\\0' &&\n\n vs->sasl.mechlist[len] != ',') {\n\n VNC_DEBUG(\"One %d\", vs->sasl.mechlist[len]);\n\n vnc_client_error(vs);\n\n return -1;\n\n }\n\n } else {\n\n char *offset = strstr(vs->sasl.mechlist, mechname);\n\n VNC_DEBUG(\"Two %p\\n\", offset);\n\n if (!offset) {\n\n vnc_client_error(vs);\n\n return -1;\n\n }\n\n VNC_DEBUG(\"Two '%s'\\n\", offset);\n\n if (offset[-1] != ',' ||\n\n (offset[len] != '\\0'&&\n\n offset[len] != ',')) {\n\n vnc_client_error(vs);\n\n return -1;\n\n }\n\n }\n\n\n\n free(vs->sasl.mechlist);\n\n vs->sasl.mechlist = mechname;\n\n\n\n VNC_DEBUG(\"Validated mechname '%s'\\n\", mechname);\n\n vnc_read_when(vs, protocol_client_auth_sasl_start_len, 4);\n\n return 0;\n\n}\n", + "output": "1", + "index": 17368 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_primary_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 if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) {\n\n trace_colo_filter_rewriter_pkt_info(__func__,\n\n inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),\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 }\n\n\n\n if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {\n\n /*\n\n * we use this flag update offset func\n\n * run once in independent tcp connection\n\n */\n\n conn->syn_flag = 1;\n\n }\n\n\n\n if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) {\n\n if (conn->syn_flag) {\n\n /*\n\n * offset = secondary_seq - primary seq\n\n * ack packet sent by guest from primary node,\n\n * so we use th_ack - 1 get primary_seq\n\n */\n\n conn->offset -= (ntohl(tcp_pkt->th_ack) - 1);\n\n conn->syn_flag = 0;\n\n }\n\n /* handle packets to the secondary from the primary */\n\n tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + 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": "0", + "index": 10895 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,\n\n const AVFrame *frame, int *got_packet_ptr)\n\n{\n\n NellyMoserEncodeContext *s = avctx->priv_data;\n\n int ret;\n\n\n\n if (s->last_frame)\n\n return 0;\n\n\n\n memcpy(s->buf, s->buf + NELLY_SAMPLES, NELLY_BUF_LEN * sizeof(*s->buf));\n\n if (frame) {\n\n memcpy(s->buf + NELLY_BUF_LEN, frame->data[0],\n\n frame->nb_samples * sizeof(*s->buf));\n\n if (frame->nb_samples < NELLY_SAMPLES) {\n\n memset(s->buf + NELLY_BUF_LEN + avctx->frame_size, 0,\n\n (NELLY_SAMPLES - frame->nb_samples) * sizeof(*s->buf));\n\n if (frame->nb_samples >= NELLY_BUF_LEN)\n\n s->last_frame = 1;\n\n }\n\n if ((ret = ff_af_queue_add(&s->afq, frame) < 0))\n\n return ret;\n\n } else {\n\n memset(s->buf + NELLY_BUF_LEN, 0, NELLY_SAMPLES * sizeof(*s->buf));\n\n s->last_frame = 1;\n\n }\n\n\n\n if ((ret = ff_alloc_packet(avpkt, NELLY_BLOCK_LEN))) {\n\n av_log(avctx, AV_LOG_ERROR, \"Error getting output packet\\n\");\n\n return ret;\n\n }\n\n encode_block(s, avpkt->data, avpkt->size);\n\n\n\n /* Get the next frame pts/duration */\n\n ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,\n\n &avpkt->duration);\n\n\n\n *got_packet_ptr = 1;\n\n return 0;\n\n}\n", + "output": "1", + "index": 24400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)\n\n{\n\n BlockRequest *blkreq;\n\n uint64_t sector;\n\n\n\n sector = virtio_ldq_p(VIRTIO_DEVICE(req->dev), &req->out.sector);\n\n\n\n trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);\n\n\n\n if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {\n\n virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);\n\n virtio_blk_free_request(req);\n\n return;\n\n }\n\n\n\n block_acct_start(bdrv_get_stats(req->dev->bs), &req->acct, req->qiov.size,\n\n BLOCK_ACCT_WRITE);\n\n\n\n if (mrb->num_writes == 32) {\n\n virtio_submit_multiwrite(req->dev->bs, mrb);\n\n }\n\n\n\n blkreq = &mrb->blkreq[mrb->num_writes];\n\n blkreq->sector = sector;\n\n blkreq->nb_sectors = req->qiov.size / BDRV_SECTOR_SIZE;\n\n blkreq->qiov = &req->qiov;\n\n blkreq->cb = virtio_blk_rw_complete;\n\n blkreq->opaque = req;\n\n blkreq->error = 0;\n\n\n\n mrb->num_writes++;\n\n}\n", + "output": "0", + "index": 4632 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void choose_pixel_fmt(AVStream *st, AVCodec *codec)\n\n{\n\n if(codec && codec->pix_fmts){\n\n const enum PixelFormat *p= codec->pix_fmts;\n\n if(st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL){\n\n if(st->codec->codec_id==CODEC_ID_MJPEG){\n\n p= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE};\n\n }else if(st->codec->codec_id==CODEC_ID_LJPEG){\n\n p= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE};\n\n }\n\n }\n\n for(; *p!=-1; p++){\n\n if(*p == st->codec->pix_fmt)\n\n break;\n\n }\n\n if (*p == -1) {\n\n\n av_log(NULL, AV_LOG_WARNING,\n\n \"Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\\n\",\n\n av_pix_fmt_descriptors[st->codec->pix_fmt].name,\n\n codec->name,\n\n av_pix_fmt_descriptors[codec->pix_fmts[0]].name);\n\n st->codec->pix_fmt = codec->pix_fmts[0];\n\n }\n\n }\n\n}", + "output": "1", + "index": 25851 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void frame_thread_free(AVCodecContext *avctx, int thread_count)\n\n{\n\n FrameThreadContext *fctx = avctx->thread_opaque;\n\n AVCodec *codec = avctx->codec;\n\n int i;\n\n\n\n park_frame_worker_threads(fctx, thread_count);\n\n\n\n if (fctx->prev_thread)\n\n update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);\n\n\n\n fctx->die = 1;\n\n\n\n for (i = 0; i < thread_count; i++) {\n\n PerThreadContext *p = &fctx->threads[i];\n\n\n\n pthread_mutex_lock(&p->mutex);\n\n pthread_cond_signal(&p->input_cond);\n\n pthread_mutex_unlock(&p->mutex);\n\n\n\n pthread_join(p->thread, NULL);\n\n\n\n if (codec->close)\n\n codec->close(p->avctx);\n\n\n\n avctx->codec = NULL;\n\n\n\n release_delayed_buffers(p);\n\n }\n\n\n\n for (i = 0; i < thread_count; i++) {\n\n PerThreadContext *p = &fctx->threads[i];\n\n\n\n avcodec_default_free_buffers(p->avctx);\n\n\n\n pthread_mutex_destroy(&p->mutex);\n\n pthread_mutex_destroy(&p->progress_mutex);\n\n pthread_cond_destroy(&p->input_cond);\n\n pthread_cond_destroy(&p->progress_cond);\n\n pthread_cond_destroy(&p->output_cond);\n\n av_freep(&p->avpkt.data);\n\n\n\n if (i)\n\n av_freep(&p->avctx->priv_data);\n\n\n\n av_freep(&p->avctx);\n\n }\n\n\n\n av_freep(&fctx->threads);\n\n pthread_mutex_destroy(&fctx->buffer_mutex);\n\n av_freep(&avctx->thread_opaque);\n\n}\n", + "output": "0", + "index": 12680 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int pam_encode_close(AVCodecContext *avctx)\n\n{\n\n av_frame_free(&avctx->coded_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 24371 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_opendir(FsContext *ctx,\n\n V9fsPath *fs_path, V9fsFidOpenState *fs)\n\n{\n\n char buffer[PATH_MAX];\n\n char *path = fs_path->data;\n\n\n\n fs->dir = opendir(rpath(ctx, path, buffer));\n\n if (!fs->dir) {\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 15058 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int cpu_s390x_handle_mmu_fault (CPUState *env, target_ulong address, int rw,\n\n int mmu_idx, int is_softmmu)\n\n{\n\n target_ulong phys;\n\n int prot;\n\n\n\n /* XXX: implement mmu */\n\n\n\n phys = address;\n\n prot = PAGE_READ | PAGE_WRITE;\n\n\n\n return tlb_set_page(env, address & TARGET_PAGE_MASK,\n\n phys & TARGET_PAGE_MASK, prot,\n\n mmu_idx, is_softmmu);\n\n}\n", + "output": "0", + "index": 20238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void ne2000_mem_writel(NE2000State *s, uint32_t addr,\n\n uint32_t val)\n\n{\n\n addr &= ~1; /* XXX: check exact behaviour if not even */\n\n if (addr < 32 ||\n\n (addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {\n\n stl_le_p(s->mem + addr, val);\n\n }\n\n}\n", + "output": "0", + "index": 11311 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int default_monitor_get_fd(Monitor *mon, const char *name, Error **errp)\n\n{\n\n error_setg(errp, \"only QEMU supports file descriptor passing\");\n\n return -1;\n\n}\n", + "output": "0", + "index": 564 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool iasl_installed(void)\n\n{\n\n gchar *out = NULL, *out_err = NULL;\n\n bool ret;\n\n\n\n /* pass 'out' and 'out_err' in order to be redirected */\n\n ret = g_spawn_command_line_sync(\"iasl\", &out, &out_err, NULL, NULL);\n\n\n\n if (out_err) {\n\n ret = ret && (out_err[0] == '\\0');\n\n g_free(out_err);\n\n }\n\n\n\n if (out) {\n\n g_free(out);\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 23859 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int spapr_rtas_register(const char *name, spapr_rtas_fn fn)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < (rtas_next - rtas_table); i++) {\n\n if (strcmp(name, rtas_table[i].name) == 0) {\n\n fprintf(stderr, \"RTAS call \\\"%s\\\" registered twice\\n\", name);\n\n exit(1);\n\n }\n\n }\n\n\n\n assert(rtas_next < (rtas_table + TOKEN_MAX));\n\n\n\n rtas_next->name = name;\n\n rtas_next->fn = fn;\n\n\n\n return (rtas_next++ - rtas_table) + TOKEN_BASE;\n\n}\n", + "output": "1", + "index": 12963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tosa_init(MachineState *machine)\n\n{\n\n const char *cpu_model = machine->cpu_model;\n\n const char *kernel_filename = machine->kernel_filename;\n\n const char *kernel_cmdline = machine->kernel_cmdline;\n\n const char *initrd_filename = machine->initrd_filename;\n\n MemoryRegion *address_space_mem = get_system_memory();\n\n MemoryRegion *rom = g_new(MemoryRegion, 1);\n\n PXA2xxState *mpu;\n\n TC6393xbState *tmio;\n\n DeviceState *scp0, *scp1;\n\n\n\n if (!cpu_model)\n\n cpu_model = \"pxa255\";\n\n\n\n mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);\n\n\n\n memory_region_init_ram(rom, NULL, \"tosa.rom\", TOSA_ROM, &error_abort);\n\n vmstate_register_ram_global(rom);\n\n memory_region_set_readonly(rom, true);\n\n memory_region_add_subregion(address_space_mem, 0, rom);\n\n\n\n tmio = tc6393xb_init(address_space_mem, 0x10000000,\n\n qdev_get_gpio_in(mpu->gpio, TOSA_GPIO_TC6393XB_INT));\n\n\n\n scp0 = sysbus_create_simple(\"scoop\", 0x08800000, NULL);\n\n scp1 = sysbus_create_simple(\"scoop\", 0x14800040, NULL);\n\n\n\n tosa_gpio_setup(mpu, scp0, scp1, tmio);\n\n\n\n tosa_microdrive_attach(mpu);\n\n\n\n tosa_tg_init(mpu);\n\n\n\n tosa_binfo.kernel_filename = kernel_filename;\n\n tosa_binfo.kernel_cmdline = kernel_cmdline;\n\n tosa_binfo.initrd_filename = initrd_filename;\n\n tosa_binfo.board_id = 0x208;\n\n arm_load_kernel(mpu->cpu, &tosa_binfo);\n\n sl_bootparam_write(SL_PXA_PARAM_BASE);\n\n}\n", + "output": "1", + "index": 11193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool megasas_use_msi(MegasasState *s)\n\n{\n\n return s->msi != ON_OFF_AUTO_OFF;\n\n}\n", + "output": "1", + "index": 4972 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pci_apb_iowritew (void *opaque, target_phys_addr_t addr,\n\n uint32_t val)\n\n{\n\n cpu_outw(addr & IOPORTS_MASK, bswap16(val));\n\n}\n", + "output": "0", + "index": 20570 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,\n\n target_ulong *raddr, int *flags, bool exc)\n\n{\n\n int r = -1;\n\n uint8_t *sk;\n\n\n\n *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC;\n\n vaddr &= TARGET_PAGE_MASK;\n\n\n\n if (!(env->psw.mask & PSW_MASK_DAT)) {\n\n *raddr = vaddr;\n\n r = 0;\n\n goto out;\n\n }\n\n\n\n switch (asc) {\n\n case PSW_ASC_PRIMARY:\n\n PTE_DPRINTF(\"%s: asc=primary\\n\", __func__);\n\n r = mmu_translate_asce(env, vaddr, asc, env->cregs[1], raddr, flags,\n\n rw, exc);\n\n break;\n\n case PSW_ASC_HOME:\n\n PTE_DPRINTF(\"%s: asc=home\\n\", __func__);\n\n r = mmu_translate_asce(env, vaddr, asc, env->cregs[13], raddr, flags,\n\n rw, exc);\n\n break;\n\n case PSW_ASC_SECONDARY:\n\n PTE_DPRINTF(\"%s: asc=secondary\\n\", __func__);\n\n /*\n\n * Instruction: Primary\n\n * Data: Secondary\n\n */\n\n if (rw == MMU_INST_FETCH) {\n\n r = mmu_translate_asce(env, vaddr, PSW_ASC_PRIMARY, env->cregs[1],\n\n raddr, flags, rw, exc);\n\n *flags &= ~(PAGE_READ | PAGE_WRITE);\n\n } else {\n\n r = mmu_translate_asce(env, vaddr, PSW_ASC_SECONDARY, env->cregs[7],\n\n raddr, flags, rw, exc);\n\n *flags &= ~(PAGE_EXEC);\n\n }\n\n break;\n\n case PSW_ASC_ACCREG:\n\n default:\n\n hw_error(\"guest switched to unknown asc mode\\n\");\n\n break;\n\n }\n\n\n\n out:\n\n /* Convert real address -> absolute address */\n\n *raddr = mmu_real2abs(env, *raddr);\n\n\n\n if (*raddr <= ram_size) {\n\n sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE];\n\n if (*flags & PAGE_READ) {\n\n *sk |= SK_R;\n\n }\n\n\n\n if (*flags & PAGE_WRITE) {\n\n *sk |= SK_C;\n\n }\n\n }\n\n\n\n return r;\n\n}\n", + "output": "1", + "index": 8684 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtsp_read_play(AVFormatContext *s)\n\n{\n\n RTSPState *rt = s->priv_data;\n\n RTSPMessageHeader reply1, *reply = &reply1;\n\n int i;\n\n char cmd[1024];\n\n\n\n av_log(s, AV_LOG_DEBUG, \"hello state=%d\\n\", rt->state);\n\n\n\n if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) {\n\n if (rt->state == RTSP_STATE_PAUSED) {\n\n cmd[0] = 0;\n\n } else {\n\n snprintf(cmd, sizeof(cmd),\n\n \"Range: npt=%0.3f-\\r\\n\",\n\n (double)rt->seek_timestamp / AV_TIME_BASE);\n\n }\n\n ff_rtsp_send_cmd(s, \"PLAY\", rt->control_uri, cmd, reply, NULL);\n\n if (reply->status_code != RTSP_STATUS_OK) {\n\n return -1;\n\n }\n\n if (reply->range_start != AV_NOPTS_VALUE &&\n\n rt->transport == RTSP_TRANSPORT_RTP) {\n\n for (i = 0; i < rt->nb_rtsp_streams; i++) {\n\n RTSPStream *rtsp_st = rt->rtsp_streams[i];\n\n RTPDemuxContext *rtpctx = rtsp_st->transport_priv;\n\n AVStream *st = NULL;\n\n\n\n if (rtsp_st->stream_index >= 0)\n\n st = s->streams[rtsp_st->stream_index];\n\n rtpctx->last_rtcp_ntp_time = AV_NOPTS_VALUE;\n\n rtpctx->first_rtcp_ntp_time = AV_NOPTS_VALUE;\n\n if (st)\n\n rtpctx->range_start_offset = av_rescale_q(reply->range_start,\n\n AV_TIME_BASE_Q,\n\n st->time_base);\n\n }\n\n }\n\n }\n\n rt->state = RTSP_STATE_STREAMING;\n\n return 0;\n\n}", + "output": "1", + "index": 3961 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void replay_save_event(Event *event, int checkpoint)\n\n{\n\n if (replay_mode != REPLAY_MODE_PLAY) {\n\n /* put the event into the file */\n\n replay_put_event(EVENT_ASYNC);\n\n replay_put_byte(checkpoint);\n\n replay_put_byte(event->event_kind);\n\n\n\n /* save event-specific data */\n\n switch (event->event_kind) {\n\n default:\n\n error_report(\"Unknown ID %d of replay event\", read_event_kind);\n\n exit(1);\n\n break;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 7071 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MigrationIncomingState *migration_incoming_state_new(QEMUFile* f)\n\n{\n\n mis_current = g_malloc0(sizeof(MigrationIncomingState));\n\n mis_current->file = f;\n\n QLIST_INIT(&mis_current->loadvm_handlers);\n\n\n\n return mis_current;\n\n}\n", + "output": "1", + "index": 16713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_write_u32(VncState *vs, uint32_t value)\n\n{\n\n uint8_t buf[4];\n\n\n\n buf[0] = (value >> 24) & 0xFF;\n\n buf[1] = (value >> 16) & 0xFF;\n\n buf[2] = (value >> 8) & 0xFF;\n\n buf[3] = value & 0xFF;\n\n\n\n vnc_write(vs, buf, 4);\n\n}\n", + "output": "0", + "index": 4704 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int idreg_init1(SysBusDevice *dev)\n\n{\n\n IDRegState *s = MACIO_ID_REGISTER(dev);\n\n\n\n memory_region_init_ram(&s->mem, OBJECT(s),\n\n \"sun4m.idreg\", sizeof(idreg_data), &error_abort);\n\n vmstate_register_ram_global(&s->mem);\n\n memory_region_set_readonly(&s->mem, true);\n\n sysbus_init_mmio(dev, &s->mem);\n\n return 0;\n\n}\n", + "output": "1", + "index": 2624 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[],\n\n int srcStride[], int srcSliceY, int srcSliceH,\n\n uint8_t *dst[], int dstStride[])\n\n{\n\n rgb24toyv12(\n\n src[0],\n\n dst[0] + srcSliceY * dstStride[0],\n\n dst[1] + (srcSliceY >> 1) * dstStride[1],\n\n dst[2] + (srcSliceY >> 1) * dstStride[2],\n\n c->srcW, srcSliceH,\n\n dstStride[0], dstStride[1], srcStride[0]);\n\n if (dst[3])\n\n fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);\n\n return srcSliceH;\n\n}\n", + "output": "1", + "index": 263 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {\n\n int *comp_data;\n\n uint16_t *img_ptr;\n\n int index, x, y;\n\n int adjust[4];\n\n for (x = 0; x < image->numcomps; x++)\n\n adjust[x] = FFMAX(FFMIN(av_pix_fmt_desc_get(picture->format)->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0);\n\n\n\n for (index = 0; index < image->numcomps; index++) {\n\n comp_data = image->comps[index].data;\n\n for (y = 0; y < image->comps[index].h; y++) {\n\n img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);\n\n for (x = 0; x < image->comps[index].w; x++) {\n\n *img_ptr = 0x8000 * image->comps[index].sgnd + (*comp_data << adjust[index]);\n\n img_ptr++;\n\n comp_data++;\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 7902 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qga_vss_fsfreeze(int *nr_volume, Error **errp, bool freeze)\n\n{\n\n const char *func_name = freeze ? \"requester_freeze\" : \"requester_thaw\";\n\n QGAVSSRequesterFunc func;\n\n ErrorSet errset = {\n\n .error_setg_win32 = error_setg_win32,\n\n .errp = errp,\n\n };\n\n\n\n g_assert(errp); /* requester.cpp requires it */\n\n func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);\n\n if (!func) {\n\n error_setg_win32(errp, GetLastError(), \"failed to load %s from %s\",\n\n func_name, QGA_VSS_DLL);\n\n return;\n\n }\n\n\n\n func(nr_volume, &errset);\n\n}\n", + "output": "1", + "index": 19648 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void input_visitor_test_add(const char *testpath,\n\n TestInputVisitorData *data,\n\n void (*test_func)(TestInputVisitorData *data, const void *user_data))\n\n{\n\n g_test_add(testpath, TestInputVisitorData, data, NULL, test_func,\n\n visitor_input_teardown);\n\n}\n", + "output": "0", + "index": 25575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qmp_chardev_open_udp(const char *id,\n\n ChardevBackend *backend,\n\n ChardevReturn *ret,\n\n Error **errp)\n\n{\n\n ChardevUdp *udp = backend->u.udp;\n\n ChardevCommon *common = qapi_ChardevUdp_base(udp);\n\n QIOChannelSocket *sioc = qio_channel_socket_new();\n\n\n\n if (qio_channel_socket_dgram_sync(sioc,\n\n udp->local, udp->remote,\n\n errp) < 0) {\n\n object_unref(OBJECT(sioc));\n\n return NULL;\n\n }\n\n return qemu_chr_open_udp(sioc, common, errp);\n\n}\n", + "output": "0", + "index": 3353 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void term_insert_char(int ch)\n\n{\n\n if (term_cmd_buf_index < TERM_CMD_BUF_SIZE) {\n\n memmove(term_cmd_buf + term_cmd_buf_index + 1,\n\n term_cmd_buf + term_cmd_buf_index,\n\n term_cmd_buf_size - term_cmd_buf_index);\n\n term_cmd_buf[term_cmd_buf_index] = ch;\n\n term_cmd_buf_size++;\n\n term_cmd_buf_index++;\n\n }\n\n}\n", + "output": "0", + "index": 18354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,\n\n int nbits)\n\n{\n\n int i, n, n4, ret;\n\n\n\n n = 1 << nbits;\n\n n4 = n >> 2;\n\n\n\n mdct->nbits = nbits;\n\n\n\n ret = fft_init(avctx, mdct, nbits - 2);\n\n if (ret)\n\n return ret;\n\n\n\n mdct->window = ff_ac3_window;\n\n\n\n FF_ALLOC_OR_GOTO(avctx, mdct->xcos1, n4 * sizeof(*mdct->xcos1), mdct_alloc_fail);\n\n FF_ALLOC_OR_GOTO(avctx, mdct->xsin1, n4 * sizeof(*mdct->xsin1), mdct_alloc_fail);\n\n FF_ALLOC_OR_GOTO(avctx, mdct->rot_tmp, n * sizeof(*mdct->rot_tmp), mdct_alloc_fail);\n\n FF_ALLOC_OR_GOTO(avctx, mdct->cplx_tmp, n4 * sizeof(*mdct->cplx_tmp), mdct_alloc_fail);\n\n\n\n for (i = 0; i < n4; i++) {\n\n float alpha = 2.0 * M_PI * (i + 1.0 / 8.0) / n;\n\n mdct->xcos1[i] = FIX15(-cos(alpha));\n\n mdct->xsin1[i] = FIX15(-sin(alpha));\n\n }\n\n\n\n return 0;\n\nmdct_alloc_fail:\n\n mdct_end(mdct);\n\n return AVERROR(ENOMEM);\n\n}\n", + "output": "0", + "index": 10512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_buffer_sao(HEVCContext *s, AVFrame *frame, const HEVCSPS *sps)\n\n{\n\n int ret, i;\n\n\n\n frame->width = s->avctx->width + 2;\n\n frame->height = s->avctx->height + 2;\n\n if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)\n\n return ret;\n\n for (i = 0; frame->data[i]; i++) {\n\n int offset = frame->linesize[i] + (1 << sps->pixel_shift);\n\n frame->data[i] += offset;\n\n }\n\n frame->width = s->avctx->width;\n\n frame->height = s->avctx->height;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 7048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_init(struct vmsvga_state_s *s,\n\n MemoryRegion *address_space, MemoryRegion *io)\n\n{\n\n DisplaySurface *surface;\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(vmsvga_update_display,\n\n vmsvga_invalidate_display,\n\n vmsvga_screen_dump,\n\n vmsvga_text_update, s);\n\n surface = qemu_console_surface(s->vga.con);\n\n\n\n s->fifo_size = SVGA_FIFO_SIZE;\n\n memory_region_init_ram(&s->fifo_ram, \"vmsvga.fifo\", s->fifo_size);\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);\n\n vga_init(&s->vga, address_space, io, true);\n\n vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);\n\n /* Save some values here in case they are changed later.\n\n * This is suspicious and needs more though why it is needed. */\n\n s->depth = surface_bits_per_pixel(surface);\n\n s->bypp = surface_bytes_per_pixel(surface);\n\n}\n", + "output": "1", + "index": 19737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void aio_write_done(void *opaque, int ret)\n\n{\n\n struct aio_ctx *ctx = opaque;\n\n struct timeval t2;\n\n\n\n gettimeofday(&t2, NULL);\n\n\n\n\n\n if (ret < 0) {\n\n printf(\"aio_write failed: %s\\n\", strerror(-ret));\n\n goto out;\n\n }\n\n\n\n if (ctx->qflag) {\n\n goto out;\n\n }\n\n\n\n /* Finally, report back -- -C gives a parsable format */\n\n t2 = tsub(t2, ctx->t1);\n\n print_report(\"wrote\", &t2, ctx->offset, ctx->qiov.size,\n\n ctx->qiov.size, 1, ctx->Cflag);\n\nout:\n\n qemu_io_free(ctx->buf);\n\n free(ctx);\n\n}\n", + "output": "0", + "index": 6853 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int encode_frame(FlacEncodeContext *s)\n\n{\n\n int ch, count;\n\n\n\n count = count_frame_header(s);\n\n\n\n for (ch = 0; ch < s->channels; ch++)\n\n count += encode_residual_ch(s, ch);\n\n\n\n count += (8 - (count & 7)) & 7; // byte alignment\n\n count += 16; // CRC-16\n\n\n\n return count >> 3;\n\n}\n", + "output": "1", + "index": 12429 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_chr_open_stdio(QemuOpts *opts, CharDriverState **_chr)\n\n{\n\n CharDriverState *chr;\n\n\n\n if (stdio_nb_clients >= STDIO_MAX_CLIENTS) {\n\n return -EBUSY;\n\n }\n\n\n\n if (stdio_nb_clients == 0) {\n\n old_fd0_flags = fcntl(0, F_GETFL);\n\n tcgetattr (0, &oldtty);\n\n fcntl(0, F_SETFL, O_NONBLOCK);\n\n atexit(term_exit);\n\n }\n\n\n\n chr = qemu_chr_open_fd(0, 1);\n\n chr->chr_close = qemu_chr_close_stdio;\n\n chr->chr_set_echo = qemu_chr_set_echo_stdio;\n\n qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);\n\n stdio_nb_clients++;\n\n stdio_allow_signal = qemu_opt_get_bool(opts, \"signal\",\n\n display_type != DT_NOGRAPHIC);\n\n qemu_chr_fe_set_echo(chr, false);\n\n\n\n *_chr = chr;\n\n return 0;\n\n}\n", + "output": "1", + "index": 13434 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_native_list_bool(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefNativeListUnion *cvalue = NULL;\n\n boolList *elem = NULL;\n\n Visitor *v;\n\n GString *gstr_list = g_string_new(\"\");\n\n GString *gstr_union = g_string_new(\"\");\n\n int i;\n\n\n\n for (i = 0; i < 32; i++) {\n\n g_string_append_printf(gstr_list, \"%s\",\n\n (i % 3 == 0) ? \"true\" : \"false\");\n\n if (i != 31) {\n\n g_string_append(gstr_list, \", \");\n\n }\n\n }\n\n g_string_append_printf(gstr_union, \"{ 'type': 'boolean', 'data': [ %s ] }\",\n\n gstr_list->str);\n\n v = visitor_input_test_init_raw(data, gstr_union->str);\n\n\n\n visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);\n\n g_assert(cvalue != NULL);\n\n g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN);\n\n\n\n for (i = 0, elem = cvalue->u.boolean.data; elem; elem = elem->next, i++) {\n\n g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0);\n\n }\n\n\n\n g_string_free(gstr_union, true);\n\n g_string_free(gstr_list, true);\n\n qapi_free_UserDefNativeListUnion(cvalue);\n\n}\n", + "output": "0", + "index": 7014 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, int for_user)\n\n{\n\n int err = 0;\n\n\n\n if (dst != src) {\n\n dst->sub_id = src->sub_id;\n\n dst->time_base = src->time_base;\n\n dst->width = src->width;\n\n dst->height = src->height;\n\n dst->pix_fmt = src->pix_fmt;\n\n\n\n dst->coded_width = src->coded_width;\n\n dst->coded_height = src->coded_height;\n\n\n\n dst->has_b_frames = src->has_b_frames;\n\n dst->idct_algo = src->idct_algo;\n\n dst->slice_count = src->slice_count;\n\n\n\n dst->bits_per_coded_sample = src->bits_per_coded_sample;\n\n dst->sample_aspect_ratio = src->sample_aspect_ratio;\n\n dst->dtg_active_format = src->dtg_active_format;\n\n\n\n dst->profile = src->profile;\n\n dst->level = src->level;\n\n\n\n dst->bits_per_raw_sample = src->bits_per_raw_sample;\n\n dst->ticks_per_frame = src->ticks_per_frame;\n\n dst->color_primaries = src->color_primaries;\n\n\n\n dst->color_trc = src->color_trc;\n\n dst->colorspace = src->colorspace;\n\n dst->color_range = src->color_range;\n\n dst->chroma_sample_location = src->chroma_sample_location;\n\n }\n\n\n\n if (for_user) {\n\n dst->coded_frame = src->coded_frame;\n\n dst->has_b_frames += src->thread_count - 1;\n\n } else {\n\n if (dst->codec->update_thread_context)\n\n err = dst->codec->update_thread_context(dst, src);\n\n }\n\n\n\n return err;\n\n}\n", + "output": "1", + "index": 7391 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)\n\n{\n\n int i = 0, start = 0, num_reqs = 0, niov = 0, nb_sectors = 0;\n\n int max_xfer_len = 0;\n\n int64_t sector_num = 0;\n\n\n\n if (mrb->num_reqs == 1) {\n\n submit_requests(blk, mrb, 0, 1, -1);\n\n mrb->num_reqs = 0;\n\n return;\n\n }\n\n\n\n max_xfer_len = blk_get_max_transfer_length(mrb->reqs[0]->dev->blk);\n\n max_xfer_len = MIN_NON_ZERO(max_xfer_len, BDRV_REQUEST_MAX_SECTORS);\n\n\n\n qsort(mrb->reqs, mrb->num_reqs, sizeof(*mrb->reqs),\n\n &multireq_compare);\n\n\n\n for (i = 0; i < mrb->num_reqs; i++) {\n\n VirtIOBlockReq *req = mrb->reqs[i];\n\n if (num_reqs > 0) {\n\n /*\n\n * NOTE: We cannot merge the requests in below situations:\n\n * 1. requests are not sequential\n\n * 2. merge would exceed maximum number of IOVs\n\n * 3. merge would exceed maximum transfer length of backend device\n\n */\n\n if (sector_num + nb_sectors != req->sector_num ||\n\n niov > blk_get_max_iov(blk) - req->qiov.niov ||\n\n req->qiov.size / BDRV_SECTOR_SIZE > max_xfer_len ||\n\n nb_sectors > max_xfer_len - req->qiov.size / BDRV_SECTOR_SIZE) {\n\n submit_requests(blk, mrb, start, num_reqs, niov);\n\n num_reqs = 0;\n\n }\n\n }\n\n\n\n if (num_reqs == 0) {\n\n sector_num = req->sector_num;\n\n nb_sectors = niov = 0;\n\n start = i;\n\n }\n\n\n\n nb_sectors += req->qiov.size / BDRV_SECTOR_SIZE;\n\n niov += req->qiov.niov;\n\n num_reqs++;\n\n }\n\n\n\n submit_requests(blk, mrb, start, num_reqs, niov);\n\n mrb->num_reqs = 0;\n\n}\n", + "output": "0", + "index": 20231 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_init_output_file(OutputFile *of, int file_index)\n\n{\n\n int ret, i;\n\n\n\n for (i = 0; i < of->ctx->nb_streams; i++) {\n\n OutputStream *ost = output_streams[of->ost_index + i];\n\n if (!ost->initialized)\n\n return 0;\n\n }\n\n\n\n of->ctx->interrupt_callback = int_cb;\n\n\n\n ret = avformat_write_header(of->ctx, &of->opts);\n\n if (ret < 0) {\n\n av_log(NULL, AV_LOG_ERROR,\n\n \"Could not write header for output file #%d \"\n\n \"(incorrect codec parameters ?): %s\\n\",\n\n file_index, av_err2str(ret));\n\n return ret;\n\n }\n\n //assert_avoptions(of->opts);\n\n of->header_written = 1;\n\n\n\n av_dump_format(of->ctx, file_index, of->ctx->filename, 1);\n\n\n\n if (sdp_filename || want_sdp)\n\n print_sdp();\n\n\n\n /* flush the muxing queues */\n\n for (i = 0; i < of->ctx->nb_streams; i++) {\n\n OutputStream *ost = output_streams[of->ost_index + i];\n\n\n\n /* try to improve muxing time_base (only possible if nothing has been written yet) */\n\n if (!av_fifo_size(ost->muxing_queue))\n\n ost->mux_timebase = ost->st->time_base;\n\n\n\n while (av_fifo_size(ost->muxing_queue)) {\n\n AVPacket pkt;\n\n av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL);\n\n write_packet(of, &pkt, ost);\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_requests_pending_all(void)\n\n{\n\n BlockDriverState *bs;\n\n QTAILQ_FOREACH(bs, &bdrv_states, device_list) {\n\n if (bdrv_requests_pending(bs)) {\n\n return true;\n\n }\n\n }\n\n return false;\n\n}\n", + "output": "1", + "index": 9412 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,\n\n uint64_t start, uint64_t count,\n\n bool finish)\n\n{\n\n hbitmap_deserialize_ones(bitmap->bitmap, start, count, finish);\n\n}\n", + "output": "0", + "index": 20193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel16_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_16x16_msa(src - 2,\n\n src - (stride * 2),\n\n stride, dst, stride);\n\n}\n", + "output": "0", + "index": 18734 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void expr_error(Monitor *mon, const char *msg)\n\n{\n\n monitor_printf(mon, \"%s\\n\", msg);\n\n siglongjmp(expr_env, 1);\n\n}\n", + "output": "0", + "index": 18005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void end_last_frame(AVFilterContext *ctx)\n\n{\n\n TileContext *tile = ctx->priv;\n\n AVFilterLink *outlink = ctx->outputs[0];\n\n AVFilterBufferRef *out_buf = outlink->out_buf;\n\n\n\n outlink->out_buf = NULL;\n\n ff_start_frame(outlink, out_buf);\n\n while (tile->current < tile->nb_frames)\n\n draw_blank_frame(ctx, out_buf);\n\n ff_draw_slice(outlink, 0, out_buf->video->h, 1);\n\n ff_end_frame(outlink);\n\n tile->current = 0;\n\n}\n", + "output": "0", + "index": 7649 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hmp_info_cpus(Monitor *mon, const QDict *qdict)\n\n{\n\n CpuInfoList *cpu_list, *cpu;\n\n\n\n cpu_list = qmp_query_cpus(NULL);\n\n\n\n for (cpu = cpu_list; cpu; cpu = cpu->next) {\n\n int active = ' ';\n\n\n\n if (cpu->value->CPU == monitor_get_cpu_index()) {\n\n active = '*';\n\n }\n\n\n\n monitor_printf(mon, \"%c CPU #%\" PRId64 \":\", active, cpu->value->CPU);\n\n\n\n switch (cpu->value->arch) {\n\n case CPU_INFO_ARCH_X86:\n\n monitor_printf(mon, \" pc=0x%016\" PRIx64, cpu->value->u.x86->pc);\n\n break;\n\n case CPU_INFO_ARCH_PPC:\n\n monitor_printf(mon, \" nip=0x%016\" PRIx64, cpu->value->u.ppc->nip);\n\n break;\n\n case CPU_INFO_ARCH_SPARC:\n\n monitor_printf(mon, \" pc=0x%016\" PRIx64,\n\n cpu->value->u.q_sparc->pc);\n\n monitor_printf(mon, \" npc=0x%016\" PRIx64,\n\n cpu->value->u.q_sparc->npc);\n\n break;\n\n case CPU_INFO_ARCH_MIPS:\n\n monitor_printf(mon, \" PC=0x%016\" PRIx64, cpu->value->u.q_mips->PC);\n\n break;\n\n case CPU_INFO_ARCH_TRICORE:\n\n monitor_printf(mon, \" PC=0x%016\" PRIx64, cpu->value->u.tricore->PC);\n\n break;\n\n default:\n\n break;\n\n }\n\n\n\n if (cpu->value->halted) {\n\n monitor_printf(mon, \" (halted)\");\n\n }\n\n\n\n monitor_printf(mon, \" thread_id=%\" PRId64 \"\\n\", cpu->value->thread_id);\n\n }\n\n\n\n qapi_free_CpuInfoList(cpu_list);\n\n}\n", + "output": "1", + "index": 4007 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn qed_aio_write_inplace(QEDAIOCB *acb, uint64_t offset,\n\n size_t len)\n\n{\n\n /* Allocate buffer for zero writes */\n\n if (acb->flags & QED_AIOCB_ZERO) {\n\n struct iovec *iov = acb->qiov->iov;\n\n\n\n if (!iov->iov_base) {\n\n iov->iov_base = qemu_try_blockalign(acb->bs, iov->iov_len);\n\n if (iov->iov_base == NULL) {\n\n return -ENOMEM;\n\n }\n\n memset(iov->iov_base, 0, iov->iov_len);\n\n }\n\n }\n\n\n\n /* Calculate the I/O vector */\n\n acb->cur_cluster = offset;\n\n qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);\n\n\n\n /* Do the actual write */\n\n return qed_aio_write_main(acb);\n\n}\n", + "output": "0", + "index": 24726 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qio_channel_socket_connect_worker(QIOTask *task,\n\n gpointer opaque)\n\n{\n\n QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));\n\n SocketAddress *addr = opaque;\n\n Error *err = NULL;\n\n\n\n qio_channel_socket_connect_sync(ioc, addr, &err);\n\n\n\n qio_task_set_error(task, err);\n\n}\n", + "output": "0", + "index": 24679 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t pcie_mmcfg_data_read(PCIBus *s, uint32_t addr, int len)\n\n{\n\n PCIDevice *pci_dev = pcie_dev_find_by_mmcfg_addr(s, addr);\n\n\n\n if (!pci_dev) {\n\n return ~0x0;\n\n }\n\n return pci_host_config_read_common(pci_dev, PCIE_MMCFG_CONFOFFSET(addr),\n\n pci_config_size(pci_dev), len);\n\n}\n", + "output": "1", + "index": 1943 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bitmap_set(unsigned long *map, long start, long nr)\n{\n unsigned long *p = map + BIT_WORD(start);\n const long size = start + nr;\n int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);\n unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);\n while (nr - bits_to_set >= 0) {\n *p |= mask_to_set;\n nr -= bits_to_set;\n bits_to_set = BITS_PER_LONG;\n mask_to_set = ~0UL;\n p++;\n }\n if (nr) {\n mask_to_set &= BITMAP_LAST_WORD_MASK(size);\n *p |= mask_to_set;\n }\n}", + "output": "1", + "index": 824 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int wmv2_decode_init(AVCodecContext *avctx)\n\n{\n\n Wmv2Context *const w = avctx->priv_data;\n\n int ret;\n\n\n\n if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)\n\n return ret;\n\n\n\n ff_wmv2_common_init(w);\n\n\n\n return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);\n\n}\n", + "output": "0", + "index": 24432 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int trim_filter_frame(AVFilterLink *inlink, AVFrame *frame)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n TrimContext *s = ctx->priv;\n\n int drop;\n\n\n\n /* drop everything if EOF has already been returned */\n\n if (s->eof) {\n\n av_frame_free(&frame);\n\n return 0;\n\n }\n\n\n\n if (s->start_frame >= 0 || s->start_pts != AV_NOPTS_VALUE) {\n\n drop = 1;\n\n if (s->start_frame >= 0 && s->nb_frames >= s->start_frame)\n\n drop = 0;\n\n if (s->start_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE &&\n\n frame->pts >= s->start_pts)\n\n drop = 0;\n\n if (drop)\n\n goto drop;\n\n }\n\n\n\n if (s->first_pts == AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE)\n\n s->first_pts = frame->pts;\n\n\n\n if (s->end_frame != INT64_MAX || s->end_pts != AV_NOPTS_VALUE || s->duration_tb) {\n\n drop = 1;\n\n\n\n if (s->end_frame != INT64_MAX && s->nb_frames < s->end_frame)\n\n drop = 0;\n\n if (s->end_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE &&\n\n frame->pts < s->end_pts)\n\n drop = 0;\n\n if (s->duration_tb && frame->pts != AV_NOPTS_VALUE &&\n\n frame->pts - s->first_pts < s->duration_tb)\n\n drop = 0;\n\n\n\n if (drop) {\n\n s->eof = 1;\n\n goto drop;\n\n }\n\n }\n\n\n\n s->nb_frames++;\n\n s->got_output = 1;\n\n\n\n return ff_filter_frame(ctx->outputs[0], frame);\n\n\n\ndrop:\n\n s->nb_frames++;\n\n av_frame_free(&frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 26989 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void put_int32(QEMUFile *f, void *pv, size_t size)\n\n{\n\n int32_t *v = pv;\n\n qemu_put_sbe32s(f, v);\n\n}\n", + "output": "1", + "index": 22526 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1)\n\n{\n\n target_ulong old, val, mask;\n\n mask = (TARGET_PAGE_MASK << 1) | env->CP0_EntryHi_ASID_mask;\n\n if (((env->CP0_Config4 >> CP0C4_IE) & 0x3) >= 2) {\n\n mask |= 1 << CP0EnHi_EHINV;\n\n }\n\n\n\n /* 1k pages not implemented */\n\n#if defined(TARGET_MIPS64)\n\n if (env->insn_flags & ISA_MIPS32R6) {\n\n int entryhi_r = extract64(arg1, 62, 2);\n\n int config0_at = extract32(env->CP0_Config0, 13, 2);\n\n bool no_supervisor = (env->CP0_Status_rw_bitmask & 0x8) == 0;\n\n if ((entryhi_r == 2) ||\n\n (entryhi_r == 1 && (no_supervisor || config0_at == 1))) {\n\n /* skip EntryHi.R field if new value is reserved */\n\n mask &= ~(0x3ull << 62);\n\n }\n\n }\n\n mask &= env->SEGMask;\n\n#endif\n\n old = env->CP0_EntryHi;\n\n val = (arg1 & mask) | (old & ~mask);\n\n env->CP0_EntryHi = val;\n\n if (env->CP0_Config3 & (1 << CP0C3_MT)) {\n\n sync_c0_entryhi(env, env->current_tc);\n\n }\n\n /* If the ASID changes, flush qemu's TLB. */\n\n if ((old & env->CP0_EntryHi_ASID_mask) !=\n\n (val & env->CP0_EntryHi_ASID_mask)) {\n\n cpu_mips_tlb_flush(env);\n\n }\n\n}\n", + "output": "0", + "index": 11854 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_image_range(int *pfirst_index, int *plast_index,\n\n const char *path, int start_index)\n\n{\n\n char buf[1024];\n\n int range, last_index, range1, first_index;\n\n\n\n /* find the first image */\n\n for (first_index = start_index; first_index < start_index + 5; first_index++) {\n\n if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){\n\n *pfirst_index =\n\n *plast_index = 1;\n\n if (avio_check(buf, AVIO_FLAG_READ) > 0)\n\n return 0;\n\n return -1;\n\n }\n\n if (avio_check(buf, AVIO_FLAG_READ) > 0)\n\n break;\n\n }\n\n if (first_index == 5)\n\n goto fail;\n\n\n\n /* find the last image */\n\n last_index = first_index;\n\n for(;;) {\n\n range = 0;\n\n for(;;) {\n\n if (!range)\n\n range1 = 1;\n\n else\n\n range1 = 2 * range;\n\n if (av_get_frame_filename(buf, sizeof(buf), path,\n\n last_index + range1) < 0)\n\n goto fail;\n\n if (avio_check(buf, AVIO_FLAG_READ) <= 0)\n\n break;\n\n range = range1;\n\n /* just in case... */\n\n if (range >= (1 << 30))\n\n goto fail;\n\n }\n\n /* we are sure than image last_index + range exists */\n\n if (!range)\n\n break;\n\n last_index += range;\n\n }\n\n *pfirst_index = first_index;\n\n *plast_index = last_index;\n\n return 0;\n\n fail:\n\n return -1;\n\n}\n", + "output": "1", + "index": 11351 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvmppc_put_books_sregs(PowerPCCPU *cpu)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n struct kvm_sregs sregs;\n\n int i;\n\n\n\n sregs.pvr = env->spr[SPR_PVR];\n\n\n\n sregs.u.s.sdr1 = env->spr[SPR_SDR1];\n\n\n\n /* Sync SLB */\n\n#ifdef TARGET_PPC64\n\n for (i = 0; i < ARRAY_SIZE(env->slb); i++) {\n\n sregs.u.s.ppc64.slb[i].slbe = env->slb[i].esid;\n\n if (env->slb[i].esid & SLB_ESID_V) {\n\n sregs.u.s.ppc64.slb[i].slbe |= i;\n\n }\n\n sregs.u.s.ppc64.slb[i].slbv = env->slb[i].vsid;\n\n }\n\n#endif\n\n\n\n /* Sync SRs */\n\n for (i = 0; i < 16; i++) {\n\n sregs.u.s.ppc32.sr[i] = env->sr[i];\n\n }\n\n\n\n /* Sync BATs */\n\n for (i = 0; i < 8; i++) {\n\n /* Beware. We have to swap upper and lower bits here */\n\n sregs.u.s.ppc32.dbat[i] = ((uint64_t)env->DBAT[0][i] << 32)\n\n | env->DBAT[1][i];\n\n sregs.u.s.ppc32.ibat[i] = ((uint64_t)env->IBAT[0][i] << 32)\n\n | env->IBAT[1][i];\n\n }\n\n\n\n return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, &sregs);\n\n}\n", + "output": "0", + "index": 2045 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline bool bdrv_req_is_aligned(BlockDriverState *bs,\n\n int64_t offset, size_t bytes)\n\n{\n\n int64_t align = bdrv_get_align(bs);\n\n return !(offset & (align - 1) || (bytes & (align - 1)));\n\n}\n", + "output": "0", + "index": 11972 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qbus_list_bus(DeviceState *dev, char *dest, int len)\n\n{\n\n BusState *child;\n\n const char *sep = \" \";\n\n int pos = 0;\n\n\n\n pos += snprintf(dest+pos, len-pos,\"child busses at \\\"%s\\\":\",\n\n dev->id ? dev->id : dev->info->name);\n\n LIST_FOREACH(child, &dev->child_bus, sibling) {\n\n pos += snprintf(dest+pos, len-pos, \"%s\\\"%s\\\"\", sep, child->name);\n\n sep = \", \";\n\n }\n\n}\n", + "output": "0", + "index": 8018 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,\n\n void *retaddr)\n\n{\n\n TranslationBlock *tb;\n\n CPUState *saved_env;\n\n unsigned long pc;\n\n int ret;\n\n\n\n saved_env = env;\n\n\n ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx);\n\n if (unlikely(ret)) {\n\n if (retaddr) {\n\n /* now we have a real cpu fault */\n\n pc = (unsigned long)retaddr;\n\n tb = tb_find_pc(pc);\n\n if (tb) {\n\n /* the PC is inside the translated code. It means that we have\n\n a virtual CPU fault */\n\n cpu_restore_state(tb, env, pc);\n\n }\n\n }\n\n raise_exception(env->exception_index);\n\n }\n\n env = saved_env;\n\n}", + "output": "1", + "index": 193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int spapr_msicfg_find(sPAPRPHBState *phb, uint32_t config_addr,\n\n bool alloc_new)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < SPAPR_MSIX_MAX_DEVS; ++i) {\n\n if (!phb->msi_table[i].nvec) {\n\n break;\n\n }\n\n if (phb->msi_table[i].config_addr == config_addr) {\n\n return i;\n\n }\n\n }\n\n if ((i < SPAPR_MSIX_MAX_DEVS) && alloc_new) {\n\n trace_spapr_pci_msi(\"Allocating new MSI config\", i, config_addr);\n\n return i;\n\n }\n\n\n\n return -1;\n\n}\n", + "output": "1", + "index": 21595 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_listen_read(void *opaque)\n\n{\n\n VncDisplay *vs = opaque;\n\n struct sockaddr_in addr;\n\n socklen_t addrlen = sizeof(addr);\n\n\n\n /* Catch-up */\n\n vga_hw_update();\n\n\n\n int csock = accept(vs->lsock, (struct sockaddr *)&addr, &addrlen);\n\n if (csock != -1) {\n\n vnc_connect(vs, csock);\n\n }\n\n}\n", + "output": "1", + "index": 11976 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,\n uint8_t *properties)\n{\n Jpeg2000CodingStyle tmp;\n int compno, ret;\n if (bytestream2_get_bytes_left(&s->g) < 5)\n tmp.csty = bytestream2_get_byteu(&s->g);\n // get progression order\n tmp.prog_order = bytestream2_get_byteu(&s->g);\n tmp.nlayers = bytestream2_get_be16u(&s->g);\n tmp.mct = bytestream2_get_byteu(&s->g); // multiple component transformation\n if ((ret = get_cox(s, &tmp)) < 0)\n return ret;\n for (compno = 0; compno < s->ncomponents; compno++)\n if (!(properties[compno] & HAD_COC))\n memcpy(c + compno, &tmp, sizeof(tmp));\n return 0;", + "output": "1", + "index": 15096 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_init_thread_copy(AVCodecContext *avctx)\n\n{\n\n H264Context *h = avctx->priv_data;\n\n\n\n if (!avctx->internal->is_copy)\n\n return 0;\n\n memset(h->sps_buffers, 0, sizeof(h->sps_buffers));\n\n memset(h->pps_buffers, 0, sizeof(h->pps_buffers));\n\n\n\n\n h->rbsp_buffer[0] = NULL;\n\n h->rbsp_buffer[1] = NULL;\n\n h->rbsp_buffer_size[0] = 0;\n\n h->rbsp_buffer_size[1] = 0;\n\n h->context_initialized = 0;\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 2235 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int av_thread_message_queue_recv_locked(AVThreadMessageQueue *mq,\n\n void *msg,\n\n unsigned flags)\n\n{\n\n while (!mq->err_recv && av_fifo_size(mq->fifo) < mq->elsize) {\n\n if ((flags & AV_THREAD_MESSAGE_NONBLOCK))\n\n return AVERROR(EAGAIN);\n\n pthread_cond_wait(&mq->cond, &mq->lock);\n\n }\n\n if (av_fifo_size(mq->fifo) < mq->elsize)\n\n return mq->err_recv;\n\n av_fifo_generic_read(mq->fifo, msg, mq->elsize, NULL);\n\n pthread_cond_signal(&mq->cond);\n\n return 0;\n\n}\n", + "output": "1", + "index": 25554 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)\n\n{\n\n BDRVQuorumState *s = acb->common.bs->opaque;\n\n\n\n acb->qcrs[acb->child_iter].buf =\n\n qemu_blockalign(s->children[acb->child_iter]->bs, acb->qiov->size);\n\n qemu_iovec_init(&acb->qcrs[acb->child_iter].qiov, acb->qiov->niov);\n\n qemu_iovec_clone(&acb->qcrs[acb->child_iter].qiov, acb->qiov,\n\n acb->qcrs[acb->child_iter].buf);\n\n bdrv_aio_readv(s->children[acb->child_iter]->bs, acb->sector_num,\n\n &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors,\n\n quorum_aio_cb, &acb->qcrs[acb->child_iter]);\n\n\n\n return &acb->common;\n\n}\n", + "output": "1", + "index": 14000 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, UID uid)\n\n{\n\n MXFStructuralComponent *source_clip = arg;\n\n switch(tag) {\n\n case 0x0202:\n\n source_clip->duration = avio_rb64(pb);\n\n break;\n\n case 0x1201:\n\n source_clip->start_position = avio_rb64(pb);\n\n break;\n\n case 0x1101:\n\n /* UMID, only get last 16 bytes */\n\n avio_skip(pb, 16);\n\n avio_read(pb, source_clip->source_package_uid, 16);\n\n break;\n\n case 0x1102:\n\n source_clip->source_track_id = avio_rb32(pb);\n\n break;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 18772 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fw_cfg_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->realize = fw_cfg_realize;\n\n dc->no_user = 1;\n\n dc->reset = fw_cfg_reset;\n\n dc->vmsd = &vmstate_fw_cfg;\n\n dc->props = fw_cfg_properties;\n\n}\n", + "output": "1", + "index": 27023 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_machine_test_cases(void)\n\n{\n\n const char *arch = qtest_get_arch();\n\n QDict *response, *minfo;\n\n QList *list;\n\n const QListEntry *p;\n\n QObject *qobj;\n\n QString *qstr;\n\n const char *mname, *path;\n\n\n\n qtest_start(\"-machine none\");\n\n response = qmp(\"{ 'execute': 'query-machines' }\");\n\n g_assert(response);\n\n list = qdict_get_qlist(response, \"return\");\n\n g_assert(list);\n\n\n\n for (p = qlist_first(list); p; p = qlist_next(p)) {\n\n minfo = qobject_to_qdict(qlist_entry_obj(p));\n\n g_assert(minfo);\n\n qobj = qdict_get(minfo, \"name\");\n\n g_assert(qobj);\n\n qstr = qobject_to_qstring(qobj);\n\n g_assert(qstr);\n\n mname = qstring_get_str(qstr);\n\n if (!is_blacklisted(arch, mname)) {\n\n path = g_strdup_printf(\"qom/%s\", mname);\n\n qtest_add_data_func(path, g_strdup(mname), test_machine);\n\n }\n\n }\n\n\n\n qtest_end();\n\n QDECREF(response);\n\n}\n", + "output": "1", + "index": 19747 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hls_write_header(AVFormatContext *s)\n\n{\n\n HLSContext *hls = s->priv_data;\n\n int ret, i;\n\n char *p;\n\n const char *pattern = \"%d.ts\";\n\n int basename_size = strlen(s->filename) + strlen(pattern);\n\n\n\n hls->number = 0;\n\n\n\n hls->recording_time = hls->time * 1000000;\n\n hls->start_pts = AV_NOPTS_VALUE;\n\n\n\n for (i = 0; i < s->nb_streams; i++)\n\n hls->has_video +=\n\n s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO;\n\n\n\n if (hls->has_video > 1)\n\n av_log(s, AV_LOG_WARNING,\n\n \"More than a single video stream present, \"\n\n \"expect issues decoding it.\\n\");\n\n\n\n hls->oformat = av_guess_format(\"mpegts\", NULL, NULL);\n\n\n\n if (!hls->oformat) {\n\n ret = AVERROR_MUXER_NOT_FOUND;\n\n goto fail;\n\n }\n\n\n\n hls->basename = av_malloc(basename_size);\n\n\n\n if (!hls->basename) {\n\n ret = AVERROR(ENOMEM);\n\n goto fail;\n\n }\n\n\n\n strcpy(hls->basename, s->filename);\n\n\n\n p = strrchr(hls->basename, '.');\n\n\n\n if (p)\n\n *p = '\\0';\n\n\n\n av_strlcat(hls->basename, \"%d.ts\", basename_size);\n\n\n\n if ((ret = hls_mux_init(s)) < 0)\n\n goto fail;\n\n\n\n if ((ret = hls_start(s)) < 0)\n\n goto fail;\n\n\n\n if ((ret = avformat_write_header(hls->avf, NULL)) < 0)\n\n return ret;\n\n\n\n\n\nfail:\n\n if (ret) {\n\n av_free(hls->basename);\n\n if (hls->avf)\n\n avformat_free_context(hls->avf);\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 771 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s)\n\n{\n\n uint64_t channel_mask = 0;\n\n int frame_type, i;\n\n\n\n s->codec = get_bits(gb, TAK_ENCODER_CODEC_BITS);\n\n skip_bits(gb, TAK_ENCODER_PROFILE_BITS);\n\n\n\n frame_type = get_bits(gb, TAK_SIZE_FRAME_DURATION_BITS);\n\n s->samples = get_bits64(gb, TAK_SIZE_SAMPLES_NUM_BITS);\n\n\n\n s->data_type = get_bits(gb, TAK_FORMAT_DATA_TYPE_BITS);\n\n s->sample_rate = get_bits(gb, TAK_FORMAT_SAMPLE_RATE_BITS) +\n\n TAK_SAMPLE_RATE_MIN;\n\n s->bps = get_bits(gb, TAK_FORMAT_BPS_BITS) +\n\n TAK_BPS_MIN;\n\n s->channels = get_bits(gb, TAK_FORMAT_CHANNEL_BITS) +\n\n TAK_CHANNELS_MIN;\n\n\n\n if (get_bits1(gb)) {\n\n skip_bits(gb, TAK_FORMAT_VALID_BITS);\n\n if (get_bits1(gb)) {\n\n for (i = 0; i < s->channels; i++) {\n\n int value = get_bits(gb, TAK_FORMAT_CH_LAYOUT_BITS);\n\n\n\n if (value < FF_ARRAY_ELEMS(tak_channel_layouts))\n\n channel_mask |= tak_channel_layouts[value];\n\n }\n\n }\n\n }\n\n\n\n s->ch_layout = channel_mask;\n\n s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);\n\n}\n", + "output": "0", + "index": 25425 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TCGv neon_load_scratch(int scratch)\n\n{\n\n TCGv tmp = new_tmp();\n\n tcg_gen_ld_i32(tmp, cpu_env, offsetof(CPUARMState, vfp.scratch[scratch]));\n\n return tmp;\n\n}\n", + "output": "1", + "index": 22045 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hdev_open(BlockDriverState *bs, QDict *options, int flags,\n\n Error **errp)\n\n{\n\n BDRVRawState *s = bs->opaque;\n\n Error *local_err = NULL;\n\n int ret;\n\n\n\n#if defined(__APPLE__) && defined(__MACH__)\n\n const char *filename = qdict_get_str(options, \"filename\");\n\n\n\n if (strstart(filename, \"/dev/cdrom\", NULL)) {\n\n kern_return_t kernResult;\n\n io_iterator_t mediaIterator;\n\n char bsdPath[ MAXPATHLEN ];\n\n int fd;\n\n\n\n kernResult = FindEjectableCDMedia( &mediaIterator );\n\n kernResult = GetBSDPath(mediaIterator, bsdPath, sizeof(bsdPath),\n\n flags);\n\n if ( bsdPath[ 0 ] != '\\0' ) {\n\n strcat(bsdPath,\"s0\");\n\n /* some CDs don't have a partition 0 */\n\n fd = qemu_open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);\n\n if (fd < 0) {\n\n bsdPath[strlen(bsdPath)-1] = '1';\n\n } else {\n\n qemu_close(fd);\n\n }\n\n filename = bsdPath;\n\n qdict_put(options, \"filename\", qstring_from_str(filename));\n\n }\n\n\n\n if ( mediaIterator )\n\n IOObjectRelease( mediaIterator );\n\n }\n\n#endif\n\n\n\n s->type = FTYPE_FILE;\n\n\n\n ret = raw_open_common(bs, options, flags, 0, &local_err);\n\n if (ret < 0) {\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n }\n\n return ret;\n\n }\n\n\n\n /* Since this does ioctl the device must be already opened */\n\n bs->sg = hdev_is_sg(bs);\n\n\n\n if (flags & BDRV_O_RDWR) {\n\n ret = check_hdev_writable(s);\n\n if (ret < 0) {\n\n raw_close(bs);\n\n error_setg_errno(errp, -ret, \"The device is not writable\");\n\n return ret;\n\n }\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 23362 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)\n\n{\n\n ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;\n\n struct alsa_params_req req;\n\n struct alsa_params_obt obt;\n\n snd_pcm_t *handle;\n\n struct audsettings obt_as;\n\n\n\n req.fmt = aud_to_alsafmt (as->fmt, as->endianness);\n\n req.freq = as->freq;\n\n req.nchannels = as->nchannels;\n\n req.period_size = conf.period_size_in;\n\n req.buffer_size = conf.buffer_size_in;\n\n req.size_in_usec = conf.size_in_usec_in;\n\n req.override_mask =\n\n (conf.period_size_in_overridden ? 1 : 0) |\n\n (conf.buffer_size_in_overridden ? 2 : 0);\n\n\n\n if (alsa_open (1, &req, &obt, &handle)) {\n\n return -1;\n\n }\n\n\n\n obt_as.freq = obt.freq;\n\n obt_as.nchannels = obt.nchannels;\n\n obt_as.fmt = obt.fmt;\n\n obt_as.endianness = obt.endianness;\n\n\n\n audio_pcm_init_info (&hw->info, &obt_as);\n\n hw->samples = obt.samples;\n\n\n\n alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);\n\n if (!alsa->pcm_buf) {\n\n dolog (\"Could not allocate ADC buffer (%d samples, each %d bytes)\\n\",\n\n hw->samples, 1 << hw->info.shift);\n\n alsa_anal_close1 (&handle);\n\n return -1;\n\n }\n\n\n\n alsa->handle = handle;\n\n return 0;\n\n}\n", + "output": "1", + "index": 147 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline TCGv gen_ld16u(TCGv addr, int index)\n\n{\n\n TCGv tmp = new_tmp();\n\n tcg_gen_qemu_ld16u(tmp, addr, index);\n\n return tmp;\n\n}\n", + "output": "1", + "index": 13615 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool fw_cfg_comb_valid(void *opaque, target_phys_addr_t addr,\n\n unsigned size, bool is_write)\n\n{\n\n return (size == 1) || (is_write && size == 2);\n\n}\n", + "output": "0", + "index": 13768 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xen_9pfs_free(struct XenDevice *xendev)\n\n{\n\n return -1;\n\n}\n", + "output": "0", + "index": 16315 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "sbappend(struct socket *so, struct mbuf *m)\n\n{\n\n\tint ret = 0;\n\n\n\n\tDEBUG_CALL(\"sbappend\");\n\n\tDEBUG_ARG(\"so = %p\", so);\n\n\tDEBUG_ARG(\"m = %p\", m);\n\n\tDEBUG_ARG(\"m->m_len = %d\", m->m_len);\n\n\n\n\t/* Shouldn't happen, but... e.g. foreign host closes connection */\n\n\tif (m->m_len <= 0) {\n\n\t\tm_free(m);\n\n\t\treturn;\n\n\t}\n\n\n\n\t/*\n\n\t * If there is urgent data, call sosendoob\n\n\t * if not all was sent, sowrite will take care of the rest\n\n\t * (The rest of this function is just an optimisation)\n\n\t */\n\n\tif (so->so_urgc) {\n\n\t\tsbappendsb(&so->so_rcv, m);\n\n\t\tm_free(m);\n\n\t\tsosendoob(so);\n\n\t\treturn;\n\n\t}\n\n\n\n\t/*\n\n\t * We only write if there's nothing in the buffer,\n\n\t * ottherwise it'll arrive out of order, and hence corrupt\n\n\t */\n\n\tif (!so->so_rcv.sb_cc)\n\n\t ret = slirp_send(so, m->m_data, m->m_len, 0);\n\n\n\n\tif (ret <= 0) {\n\n\t\t/*\n\n\t\t * Nothing was written\n\n\t\t * It's possible that the socket has closed, but\n\n\t\t * we don't need to check because if it has closed,\n\n\t\t * it will be detected in the normal way by soread()\n\n\t\t */\n\n\t\tsbappendsb(&so->so_rcv, m);\n\n\t} else if (ret != m->m_len) {\n\n\t\t/*\n\n\t\t * Something was written, but not everything..\n\n\t\t * sbappendsb the rest\n\n\t\t */\n\n\t\tm->m_len -= ret;\n\n\t\tm->m_data += ret;\n\n\t\tsbappendsb(&so->so_rcv, m);\n\n\t} /* else */\n\n\t/* Whatever happened, we free the mbuf */\n\n\tm_free(m);\n\n}\n", + "output": "1", + "index": 5502 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int wsaud_read_packet(AVFormatContext *s,\n\n AVPacket *pkt)\n\n{\n\n AVIOContext *pb = s->pb;\n\n unsigned char preamble[AUD_CHUNK_PREAMBLE_SIZE];\n\n unsigned int chunk_size;\n\n int ret = 0;\n\n AVStream *st = s->streams[0];\n\n\n\n if (avio_read(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=\n\n AUD_CHUNK_PREAMBLE_SIZE)\n\n return AVERROR(EIO);\n\n\n\n /* validate the chunk */\n\n if (AV_RL32(&preamble[4]) != AUD_CHUNK_SIGNATURE)\n\n return AVERROR_INVALIDDATA;\n\n\n\n chunk_size = AV_RL16(&preamble[0]);\n\n\n\n if (st->codec->codec_id == AV_CODEC_ID_WESTWOOD_SND1) {\n\n /* For Westwood SND1 audio we need to add the output size and input\n\n size to the start of the packet to match what is in VQA.\n\n Specifically, this is needed to signal when a packet should be\n\n decoding as raw 8-bit pcm or variable-size ADPCM. */\n\n int out_size = AV_RL16(&preamble[2]);\n\n if ((ret = av_new_packet(pkt, chunk_size + 4)))\n\n return ret;\n\n if ((ret = avio_read(pb, &pkt->data[4], chunk_size)) != chunk_size)\n\n return ret < 0 ? ret : AVERROR(EIO);\n\n AV_WL16(&pkt->data[0], out_size);\n\n AV_WL16(&pkt->data[2], chunk_size);\n\n\n\n pkt->duration = out_size;\n\n } else {\n\n ret = av_get_packet(pb, pkt, chunk_size);\n\n if (ret != chunk_size)\n\n return AVERROR(EIO);\n\n\n\n /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */\n\n pkt->duration = (chunk_size * 2) / st->codec->channels;\n\n }\n\n pkt->stream_index = st->index;\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 11728 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qio_channel_socket_accept(QIOChannelSocket *ioc,\n\n Error **errp)\n\n{\n\n QIOChannelSocket *cioc;\n\n\n\n cioc = qio_channel_socket_new();\n\n cioc->remoteAddrLen = sizeof(ioc->remoteAddr);\n\n cioc->localAddrLen = sizeof(ioc->localAddr);\n\n\n\n retry:\n\n trace_qio_channel_socket_accept(ioc);\n\n cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr,\n\n &cioc->remoteAddrLen);\n\n if (cioc->fd < 0) {\n\n trace_qio_channel_socket_accept_fail(ioc);\n\n if (errno == EINTR) {\n\n goto retry;\n\n }\n\n goto error;\n\n }\n\n\n\n if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr,\n\n &cioc->localAddrLen) < 0) {\n\n error_setg_errno(errp, errno,\n\n \"Unable to query local socket address\");\n\n goto error;\n\n }\n\n\n\n#ifndef WIN32\n\n if (cioc->localAddr.ss_family == AF_UNIX) {\n\n QIOChannel *ioc_local = QIO_CHANNEL(cioc);\n\n qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS);\n\n }\n\n#endif /* WIN32 */\n\n\n\n trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd);\n\n return cioc;\n\n\n\n error:\n\n object_unref(OBJECT(cioc));\n\n return NULL;\n\n}\n", + "output": "1", + "index": 9883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xtensa_ml605_init(MachineState *machine)\n\n{\n\n static const LxBoardDesc ml605_board = {\n\n .flash_base = 0xf8000000,\n\n .flash_size = 0x01000000,\n\n .flash_sector_size = 0x20000,\n\n .sram_size = 0x2000000,\n\n };\n\n lx_init(&ml605_board, machine);\n\n}\n", + "output": "0", + "index": 20909 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n int ret, fsize;\n\n\n\n ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE);\n\n if (ret < 0)\n\n return ret;\n\n if (ret < ADTS_HEADER_SIZE) {\n\n av_packet_unref(pkt);\n\n return AVERROR(EIO);\n\n }\n\n\n\n if ((AV_RB16(pkt->data) >> 4) != 0xfff) {\n\n av_packet_unref(pkt);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;\n\n if (fsize < ADTS_HEADER_SIZE) {\n\n av_packet_unref(pkt);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n return av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);\n\n}\n", + "output": "1", + "index": 261 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_migrate_set_downtime(double value, Error **errp)\n\n{\n\n value *= 1e9;\n\n value = MAX(0, MIN(UINT64_MAX, value));\n\n max_downtime = (uint64_t)value;\n\n}\n", + "output": "1", + "index": 25153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf)\n\n{\n\n int au_headers_length, au_header_size, i;\n\n GetBitContext getbitcontext;\n\n RTPPayloadData *infos;\n\n\n\n infos = s->rtp_payload_data;\n\n\n\n if (infos == NULL)\n\n return -1;\n\n\n\n /* decode the first 2 bytes where the AUHeader sections are stored\n\n length in bits */\n\n au_headers_length = AV_RB16(buf);\n\n\n\n if (au_headers_length > RTP_MAX_PACKET_LENGTH)\n\n return -1;\n\n\n\n infos->au_headers_length_bytes = (au_headers_length + 7) / 8;\n\n\n\n /* skip AU headers length section (2 bytes) */\n\n buf += 2;\n\n\n\n init_get_bits(&getbitcontext, buf, infos->au_headers_length_bytes * 8);\n\n\n\n /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */\n\n au_header_size = infos->sizelength + infos->indexlength;\n\n if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))\n\n return -1;\n\n\n\n infos->nb_au_headers = au_headers_length / au_header_size;\n\n\n\n infos->au_headers = av_malloc(sizeof(struct AUHeaders) * infos->nb_au_headers);\n\n\n\n\n\n /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving)\n\n In my test, the FAAD decoder does not behave correctly when sending each AU one by one\n\n but does when sending the whole as one big packet... */\n\n infos->au_headers[0].size = 0;\n\n infos->au_headers[0].index = 0;\n\n for (i = 0; i < infos->nb_au_headers; ++i) {\n\n infos->au_headers[0].size += get_bits_long(&getbitcontext, infos->sizelength);\n\n infos->au_headers[0].index = get_bits_long(&getbitcontext, infos->indexlength);\n\n\n\n\n infos->nb_au_headers = 1;\n\n\n\n return 0;\n", + "output": "1", + "index": 2962 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(nv12ToUV)(uint8_t *dstU, uint8_t *dstV,\n\n const uint8_t *src1, const uint8_t *src2,\n\n int width, uint32_t *unused)\n\n{\n\n RENAME(nvXXtoUV)(dstU, dstV, src1, width);\n\n}\n", + "output": "1", + "index": 7298 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "TPMVersion tpm_backend_get_tpm_version(TPMBackend *s)\n\n{\n\n TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);\n\n\n\n assert(k->get_tpm_version);\n\n\n\n return k->get_tpm_version(s);\n\n}\n", + "output": "1", + "index": 23729 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable,\n\n bool csum_enable, uint32_t gso_size)\n\n{\n\n struct tcp_hdr l4hdr;\n\n assert(pkt);\n\n\n\n /* csum has to be enabled if tso is. */\n\n assert(csum_enable || !tso_enable);\n\n\n\n pkt->virt_hdr.gso_type = net_tx_pkt_get_gso_type(pkt, tso_enable);\n\n\n\n switch (pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {\n\n case VIRTIO_NET_HDR_GSO_NONE:\n\n pkt->virt_hdr.hdr_len = 0;\n\n pkt->virt_hdr.gso_size = 0;\n\n break;\n\n\n\n case VIRTIO_NET_HDR_GSO_UDP:\n\n pkt->virt_hdr.gso_size = IP_FRAG_ALIGN_SIZE(gso_size);\n\n pkt->virt_hdr.hdr_len = pkt->hdr_len + sizeof(struct udp_header);\n\n break;\n\n\n\n case VIRTIO_NET_HDR_GSO_TCPV4:\n\n case VIRTIO_NET_HDR_GSO_TCPV6:\n\n iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags,\n\n 0, &l4hdr, sizeof(l4hdr));\n\n pkt->virt_hdr.hdr_len = pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t);\n\n pkt->virt_hdr.gso_size = IP_FRAG_ALIGN_SIZE(gso_size);\n\n break;\n\n\n\n default:\n\n g_assert_not_reached();\n\n }\n\n\n\n if (csum_enable) {\n\n switch (pkt->l4proto) {\n\n case IP_PROTO_TCP:\n\n pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;\n\n pkt->virt_hdr.csum_start = pkt->hdr_len;\n\n pkt->virt_hdr.csum_offset = offsetof(struct tcp_hdr, th_sum);\n\n break;\n\n case IP_PROTO_UDP:\n\n pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;\n\n pkt->virt_hdr.csum_start = pkt->hdr_len;\n\n pkt->virt_hdr.csum_offset = offsetof(struct udp_hdr, uh_sum);\n\n break;\n\n default:\n\n break;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 16957 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size)\n\n{\n\n return kvm_dirty_pages_log_change(phys_addr, size,\n\n 0,\n\n KVM_MEM_LOG_DIRTY_PAGES);\n\n}\n", + "output": "0", + "index": 16039 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)\n\n{\n\n int i;\n\n for(i=0; i<4 && tags[i]; i++){\n\n int tag= codec_get_tag(tags[i], id);\n\n if(tag) return tag;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 7728 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_validate_fail_union_native_list(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefNativeListUnion *tmp = NULL;\n\n Error *err = NULL;\n\n Visitor *v;\n\n\n\n v = validate_test_init(data,\n\n \"{ 'type': 'integer', 'data' : [ 'string' ] }\");\n\n\n\n visit_type_UserDefNativeListUnion(v, NULL, &tmp, &err);\n\n error_free_or_abort(&err);\n\n g_assert(!tmp);\n\n}\n", + "output": "0", + "index": 23822 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, \n\n int nb_codes)\n\n{\n\n uint8_t huff_size[256];\n\n uint16_t huff_code[256];\n\n\n\n memset(huff_size, 0, sizeof(huff_size));\n\n build_huffman_codes(huff_size, huff_code, bits_table, val_table);\n\n \n\n return init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2);\n\n}\n", + "output": "1", + "index": 24239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaque)\n\n{\n\n IOTrampoline *tramp = opaque;\n\n\n\n if (tramp->opaque == NULL) {\n\n return FALSE;\n\n }\n\n\n\n if ((cond & G_IO_IN) && tramp->fd_read) {\n\n tramp->fd_read(tramp->opaque);\n\n }\n\n\n\n if ((cond & G_IO_OUT) && tramp->fd_write) {\n\n tramp->fd_write(tramp->opaque);\n\n }\n\n\n\n return TRUE;\n\n}\n", + "output": "1", + "index": 17365 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmxnet3_rx_need_csum_calculate(struct VmxnetRxPkt *pkt,\n\n const void *pkt_data,\n\n size_t pkt_len)\n\n{\n\n struct virtio_net_hdr *vhdr;\n\n bool isip4, isip6, istcp, isudp;\n\n uint8_t *data;\n\n int len;\n\n\n\n if (!vmxnet_rx_pkt_has_virt_hdr(pkt)) {\n\n return;\n\n }\n\n\n\n vhdr = vmxnet_rx_pkt_get_vhdr(pkt);\n\n if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {\n\n return;\n\n }\n\n\n\n vmxnet_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp);\n\n if (!(isip4 || isip6) || !(istcp || isudp)) {\n\n return;\n\n }\n\n\n\n vmxnet3_dump_virt_hdr(vhdr);\n\n\n\n /* Validate packet len: csum_start + scum_offset + length of csum field */\n\n if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) {\n\n VMW_PKPRN(\"packet len:%d < csum_start(%d) + csum_offset(%d) + 2, \"\n\n \"cannot calculate checksum\",\n\n len, vhdr->csum_start, vhdr->csum_offset);\n\n return;\n\n }\n\n\n\n data = (uint8_t *)pkt_data + vhdr->csum_start;\n\n len = pkt_len - vhdr->csum_start;\n\n /* Put the checksum obtained into the packet */\n\n stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));\n\n\n\n vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;\n\n vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;\n\n}\n", + "output": "1", + "index": 573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void avc_biwgt_4width_msa(uint8_t *src,\n\n int32_t src_stride,\n\n uint8_t *dst,\n\n int32_t dst_stride,\n\n int32_t height,\n\n int32_t log2_denom,\n\n int32_t src_weight,\n\n int32_t dst_weight,\n\n int32_t offset_in)\n\n{\n\n if (2 == height) {\n\n avc_biwgt_4x2_msa(src, src_stride, dst, dst_stride,\n\n log2_denom, src_weight, dst_weight,\n\n offset_in);\n\n } else {\n\n avc_biwgt_4x4multiple_msa(src, src_stride, dst, dst_stride,\n\n height, log2_denom, src_weight,\n\n dst_weight, offset_in);\n\n }\n\n}\n", + "output": "0", + "index": 23467 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int ucf64_exceptbits_from_host(int host_bits)\n\n{\n\n int target_bits = 0;\n\n\n\n if (host_bits & float_flag_invalid) {\n\n target_bits |= UCF64_FPSCR_FLAG_INVALID;\n\n }\n\n if (host_bits & float_flag_divbyzero) {\n\n target_bits |= UCF64_FPSCR_FLAG_DIVZERO;\n\n }\n\n if (host_bits & float_flag_overflow) {\n\n target_bits |= UCF64_FPSCR_FLAG_OVERFLOW;\n\n }\n\n if (host_bits & float_flag_underflow) {\n\n target_bits |= UCF64_FPSCR_FLAG_UNDERFLOW;\n\n }\n\n if (host_bits & float_flag_inexact) {\n\n target_bits |= UCF64_FPSCR_FLAG_INEXACT;\n\n }\n\n return target_bits;\n\n}\n", + "output": "0", + "index": 4190 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_fft_init_arm(FFTContext *s)\n\n{\n\n if (HAVE_NEON) {\n\n s->fft_permute = ff_fft_permute_neon;\n\n s->fft_calc = ff_fft_calc_neon;\n\n s->imdct_calc = ff_imdct_calc_neon;\n\n s->imdct_half = ff_imdct_half_neon;\n\n s->mdct_calc = ff_mdct_calc_neon;\n\n s->permutation = FF_MDCT_PERM_INTERLEAVE;\n\n }\n\n}\n", + "output": "0", + "index": 19495 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,\n\n InputEvent *evt)\n\n{\n\n HIDState *hs = (HIDState *)dev;\n\n int scancodes[3], i, count;\n\n int slot;\n\n\n\n count = qemu_input_key_value_to_scancode(evt->key->key,\n\n evt->key->down,\n\n scancodes);\n\n if (hs->n + count > QUEUE_LENGTH) {\n\n fprintf(stderr, \"usb-kbd: warning: key event queue full\\n\");\n\n return;\n\n }\n\n for (i = 0; i < count; i++) {\n\n slot = (hs->head + hs->n) & QUEUE_MASK; hs->n++;\n\n hs->kbd.keycodes[slot] = scancodes[i];\n\n }\n\n hs->event(hs);\n\n}\n", + "output": "0", + "index": 17313 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)\n\n{\n\n AVPicture dummy_pict;\n\n if(av_image_check_size(width, height, 0, NULL))\n\n return -1;\n\n switch (pix_fmt) {\n\n case PIX_FMT_RGB8:\n\n case PIX_FMT_BGR8:\n\n case PIX_FMT_RGB4_BYTE:\n\n case PIX_FMT_BGR4_BYTE:\n\n case PIX_FMT_GRAY8:\n\n // do not include palette for these pseudo-paletted formats\n\n return width * height;\n\n }\n\n return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);\n\n}\n", + "output": "1", + "index": 6422 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *vnc_display_local_addr(DisplayState *ds)\n\n{\n\n VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;\n\n \n\n return vnc_socket_local_addr(\"%s:%s\", vs->lsock);\n\n}\n", + "output": "1", + "index": 6798 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void spapr_cpu_parse_features(sPAPRMachineState *spapr)\n\n{\n\n /*\n\n * Backwards compatibility hack:\n\n *\n\n * CPUs had a \"compat=\" property which didn't make sense for\n\n * anything except pseries. It was replaced by \"max-cpu-compat\"\n\n * machine option. This supports old command lines like\n\n * -cpu POWER8,compat=power7\n\n * By stripping the compat option and applying it to the machine\n\n * before passing it on to the cpu level parser.\n\n */\n\n gchar **inpieces;\n\n gchar *newprops;\n\n int i, j;\n\n gchar *compat_str = NULL;\n\n\n\n inpieces = g_strsplit(MACHINE(spapr)->cpu_model, \",\", 0);\n\n\n\n /* inpieces[0] is the actual model string */\n\n i = 1;\n\n j = 1;\n\n while (inpieces[i]) {\n\n if (g_str_has_prefix(inpieces[i], \"compat=\")) {\n\n /* in case of multiple compat= options */\n\n g_free(compat_str);\n\n compat_str = inpieces[i];\n\n } else {\n\n j++;\n\n }\n\n\n\n i++;\n\n /* Excise compat options from list */\n\n inpieces[j] = inpieces[i];\n\n }\n\n\n\n if (compat_str) {\n\n char *val = compat_str + strlen(\"compat=\");\n\n\n\n object_property_set_str(OBJECT(spapr), val, \"max-cpu-compat\",\n\n &error_fatal);\n\n\n\n }\n\n\n\n newprops = g_strjoinv(\",\", inpieces);\n\n cpu_parse_cpu_model(TYPE_POWERPC_CPU, newprops);\n\n g_free(newprops);\n\n g_strfreev(inpieces);\n\n}\n", + "output": "0", + "index": 18657 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool cpu_exec_all(void)\n\n{\n\n int r;\n\n\n\n /* Account partial waits to the vm_clock. */\n\n qemu_clock_warp(vm_clock);\n\n\n\n if (next_cpu == NULL) {\n\n next_cpu = first_cpu;\n\n }\n\n for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {\n\n CPUState *env = next_cpu;\n\n\n\n qemu_clock_enable(vm_clock,\n\n (env->singlestep_enabled & SSTEP_NOTIMER) == 0);\n\n\n\n#ifndef CONFIG_IOTHREAD\n\n if (qemu_alarm_pending()) {\n\n break;\n\n }\n\n#endif\n\n if (cpu_can_run(env)) {\n\n if (kvm_enabled()) {\n\n r = kvm_cpu_exec(env);\n\n qemu_kvm_eat_signals(env);\n\n } else {\n\n r = tcg_cpu_exec(env);\n\n }\n\n if (r == EXCP_DEBUG) {\n\n cpu_handle_guest_debug(env);\n\n break;\n\n }\n\n } else if (env->stop || env->stopped) {\n\n break;\n\n }\n\n }\n\n exit_request = 0;\n\n return !all_cpu_threads_idle();\n\n}\n", + "output": "1", + "index": 14616 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void adx_encode(unsigned char *adx,const short *wav,\n\n ADXChannelState *prev)\n\n{\n\n int scale;\n\n int i;\n\n int s0,s1,s2,d;\n\n int max=0;\n\n int min=0;\n\n int data[32];\n\n\n\n s1 = prev->s1;\n\n s2 = prev->s2;\n\n for(i=0;i<32;i++) {\n\n s0 = wav[i];\n\n d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;\n\n data[i]=d;\n\n if (maxd) min=d;\n\n s2 = s1;\n\n s1 = s0;\n\n }\n\n prev->s1 = s1;\n\n prev->s2 = s2;\n\n\n\n /* -8..+7 */\n\n\n\n if (max==0 && min==0) {\n\n memset(adx,0,18);\n\n return;\n\n }\n\n\n\n if (max/7>-min/8) scale = max/7;\n\n else scale = -min/8;\n\n\n\n if (scale==0) scale=1;\n\n\n\n AV_WB16(adx, scale);\n\n\n\n for(i=0;i<16;i++) {\n\n adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);\n\n }\n\n}\n", + "output": "1", + "index": 3872 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t cmd646_data_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n CMD646BAR *cmd646bar = opaque;\n\n\n\n if (size == 1) {\n\n return ide_ioport_read(cmd646bar->bus, addr);\n\n } else if (addr == 0) {\n\n if (size == 2) {\n\n return ide_data_readw(cmd646bar->bus, addr);\n\n } else {\n\n return ide_data_readl(cmd646bar->bus, addr);\n\n }\n\n }\n\n return ((uint64_t)1 << (size * 8)) - 1;\n\n}\n", + "output": "0", + "index": 4713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes)\n\n{\n\n uint8_t buf[4096];\n\n target_phys_addr_t dst_begin = dst_addr;\n\n size_t want, did;\n\n\n\n while (nbytes) {\n\n\twant = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;\n\n\tdid = read(fd, buf, want);\n\n\tif (did != want) break;\n\n\n\n\tcpu_physical_memory_write_rom(dst_addr, buf, did);\n\n\tdst_addr += did;\n\n\tnbytes -= did;\n\n }\n\n return dst_addr - dst_begin;\n\n}\n", + "output": "0", + "index": 23864 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_avg_h264_qpel8_mc33_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 sizeof(uint8_t), stride, dst, stride);\n\n}\n", + "output": "0", + "index": 3111 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_pci_config_write(void *opaque, hwaddr addr,\n\n uint64_t val, unsigned size)\n\n{\n\n VirtIOPCIProxy *proxy = opaque;\n\n uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);\n\n VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);\n\n if (addr < config) {\n\n virtio_ioport_write(proxy, addr, val);\n\n return;\n\n }\n\n addr -= config;\n\n /*\n\n * Virtio-PCI is odd. Ioports are LE but config space is target native\n\n * endian.\n\n */\n\n switch (size) {\n\n case 1:\n\n virtio_config_writeb(vdev, addr, val);\n\n break;\n\n case 2:\n\n if (virtio_is_big_endian()) {\n\n val = bswap16(val);\n\n }\n\n virtio_config_writew(vdev, addr, val);\n\n break;\n\n case 4:\n\n if (virtio_is_big_endian()) {\n\n val = bswap32(val);\n\n }\n\n virtio_config_writel(vdev, addr, val);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 2394 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t HELPER(shl_cc)(CPUM68KState *env, uint32_t val, uint32_t shift)\n\n{\n\n uint64_t result;\n\n\n\n shift &= 63;\n\n result = (uint64_t)val << shift;\n\n\n\n env->cc_c = (result >> 32) & 1;\n\n env->cc_n = result;\n\n env->cc_z = result;\n\n env->cc_v = 0;\n\n env->cc_x = shift ? env->cc_c : env->cc_x;\n\n\n\n return result;\n\n}\n", + "output": "1", + "index": 6362 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *avio_enum_protocols(void **opaque, int output)\n\n{\n\n URLProtocol *p;\n\n *opaque = ffurl_protocol_next(*opaque);\n\n if (!(p = *opaque))\n\n return NULL;\n\n if ((output && p->url_write) || (!output && p->url_read))\n\n return p->name;\n\n return avio_enum_protocols(opaque, output);\n\n}\n", + "output": "0", + "index": 10835 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cris_mmu_enabled(uint32_t rw_gc_cfg)\n\n{\n\n\treturn (rw_gc_cfg & 12) != 0;\n\n}\n", + "output": "0", + "index": 11404 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_pred16x16(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 int pred_mode;\n\n declare_func(void, uint8_t *src, ptrdiff_t stride);\n\n\n\n for (pred_mode = 0; pred_mode < 9; pred_mode++) {\n\n if (check_pred_func(h->pred16x16[pred_mode], \"16x16\", pred16x16_modes[codec][pred_mode])) {\n\n randomize_buffers();\n\n call_ref(src0, 48);\n\n call_new(src1, 48);\n\n if (memcmp(buf0, buf1, BUF_SIZE))\n\n fail();\n\n bench_new(src1, 48);\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 13921 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down)\n\n{\n\n if (row >= 5 || row < 0)\n\n hw_error(\"%s: No key %i-%i\\n\", __FUNCTION__, col, row);\n\n\n\n if (down)\n\n s->buttons[row] |= 1 << col;\n\n else\n\n s->buttons[row] &= ~(1 << col);\n\n\n\n omap_mpuio_kbd_update(s);\n\n}\n", + "output": "0", + "index": 6246 + }, + { + "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, CPUCRISState *env)\n\n{\n\n\tstruct target_signal_frame *frame;\n\n\tabi_ulong frame_addr;\n\n\tint err = 0;\n\n\tint i;\n\n\n\n\tframe_addr = get_sigframe(env, sizeof *frame);\n\n\tif (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))\n\n\t\tgoto badframe;\n\n\n\n\t/*\n\n\t * The CRIS signal return trampoline. A real linux/CRIS kernel doesn't\n\n\t * use this trampoline anymore but it sets it up for GDB.\n\n\t * In QEMU, using the trampoline simplifies things a bit so we use it.\n\n\t *\n\n\t * This is movu.w __NR_sigreturn, r9; break 13;\n\n\t */\n\n __put_user(0x9c5f, frame->retcode+0);\n\n __put_user(TARGET_NR_sigreturn,\n\n frame->retcode + 1);\n\n __put_user(0xe93d, frame->retcode + 2);\n\n\n\n\t/* Save the mask. */\n\n __put_user(set->sig[0], &frame->sc.oldmask);\n\n\tif (err)\n\n\t\tgoto badframe;\n\n\n\n\tfor(i = 1; i < TARGET_NSIG_WORDS; i++) {\n\n\t\tif (__put_user(set->sig[i], &frame->extramask[i - 1]))\n\n\t\t\tgoto badframe;\n\n\t}\n\n\n\n\tsetup_sigcontext(&frame->sc, env);\n\n\n\n\t/* Move the stack and setup the arguments for the handler. */\n\n\tenv->regs[R_SP] = frame_addr;\n\n\tenv->regs[10] = sig;\n\n\tenv->pc = (unsigned long) ka->_sa_handler;\n\n\t/* Link SRP so the guest returns through the trampoline. */\n\n\tenv->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode);\n\n\n\n\tunlock_user_struct(frame, frame_addr, 1);\n\n\treturn;\n\n badframe:\n\n\tunlock_user_struct(frame, frame_addr, 1);\n\n\tforce_sig(TARGET_SIGSEGV);\n\n}\n", + "output": "1", + "index": 7703 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel4_mc01_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_vt_qrt_4w_msa(src - (stride * 2), stride, dst, stride, 4, 0);\n\n}\n", + "output": "0", + "index": 4788 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int floatx80_lt(floatx80 a, floatx80 b, float_status *status)\n\n{\n\n flag aSign, bSign;\n\n\n\n if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )\n\n && (uint64_t) ( extractFloatx80Frac( a )<<1 ) )\n\n || ( ( extractFloatx80Exp( b ) == 0x7FFF )\n\n && (uint64_t) ( extractFloatx80Frac( b )<<1 ) )\n\n ) {\n\n float_raise(float_flag_invalid, status);\n\n return 0;\n\n }\n\n aSign = extractFloatx80Sign( a );\n\n bSign = extractFloatx80Sign( b );\n\n if ( aSign != bSign ) {\n\n return\n\n aSign\n\n && ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )\n\n != 0 );\n\n }\n\n return\n\n aSign ? lt128( b.high, b.low, a.high, a.low )\n\n : lt128( a.high, a.low, b.high, b.low );\n\n\n\n}\n", + "output": "0", + "index": 5565 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int write_reftable_entry(BlockDriverState *bs, int rt_index)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n uint64_t buf[RT_ENTRIES_PER_SECTOR];\n\n int rt_start_index;\n\n int i, ret;\n\n\n\n rt_start_index = rt_index & ~(RT_ENTRIES_PER_SECTOR - 1);\n\n for (i = 0; i < RT_ENTRIES_PER_SECTOR; i++) {\n\n buf[i] = cpu_to_be64(s->refcount_table[rt_start_index + i]);\n\n }\n\n\n\n ret = qcow2_pre_write_overlap_check(bs,\n\n QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE,\n\n s->refcount_table_offset + rt_start_index * sizeof(uint64_t),\n\n sizeof(buf));\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_UPDATE);\n\n ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset +\n\n rt_start_index * sizeof(uint64_t), buf, sizeof(buf));\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 24367 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len)\n\n{\n\n MuxDriver *d = chr->opaque;\n\n int ret;\n\n if (!d->timestamps) {\n\n ret = d->drv->chr_write(d->drv, buf, len);\n\n } else {\n\n int i;\n\n\n\n ret = 0;\n\n for (i = 0; i < len; i++) {\n\n if (d->linestart) {\n\n char buf1[64];\n\n int64_t ti;\n\n int secs;\n\n\n\n ti = qemu_get_clock(rt_clock);\n\n if (d->timestamps_start == -1)\n\n d->timestamps_start = ti;\n\n ti -= d->timestamps_start;\n\n secs = ti / 1000;\n\n snprintf(buf1, sizeof(buf1),\n\n \"[%02d:%02d:%02d.%03d] \",\n\n secs / 3600,\n\n (secs / 60) % 60,\n\n secs % 60,\n\n (int)(ti % 1000));\n\n d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1));\n\n d->linestart = 0;\n\n }\n\n ret += d->drv->chr_write(d->drv, buf+i, 1);\n\n if (buf[i] == '\\n') {\n\n d->linestart = 1;\n\n }\n\n }\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 6086 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int query_formats(AVFilterContext *ctx)\n\n{\n\n static const enum AVPixelFormat pix_fmts[] = {\n\n AV_PIX_FMT_GRAY8,\n\n AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,\n\n AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,\n\n AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,\n\n AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,\n\n AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,\n\n AV_PIX_FMT_YUVJ411P,\n\n AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P,\n\n AV_PIX_FMT_NONE\n\n };\n\n\n\n AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);\n\n if (!fmts_list)\n\n return AVERROR(ENOMEM);\n\n ff_set_common_formats(ctx, fmts_list);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 12669 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static double compute_target_time(double frame_current_pts, VideoState *is)\n\n{\n\n double delay, sync_threshold, diff;\n\n\n\n /* compute nominal delay */\n\n delay = frame_current_pts - is->frame_last_pts;\n\n if (delay <= 0 || delay >= 10.0) {\n\n /* if incorrect delay, use previous one */\n\n delay = is->frame_last_delay;\n\n } else {\n\n is->frame_last_delay = delay;\n\n }\n\n is->frame_last_pts = frame_current_pts;\n\n\n\n /* update delay to follow master synchronisation source */\n\n if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) ||\n\n is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {\n\n /* if video is slave, we try to correct big delays by\n\n duplicating or deleting a frame */\n\n diff = get_video_clock(is) - get_master_clock(is);\n\n\n\n /* skip or repeat frame. We take into account the\n\n delay to compute the threshold. I still don't know\n\n if it is the best guess */\n\n sync_threshold = FFMAX(AV_SYNC_THRESHOLD, delay);\n\n if (fabs(diff) < AV_NOSYNC_THRESHOLD) {\n\n if (diff <= -sync_threshold)\n\n delay = 0;\n\n else if (diff >= sync_threshold)\n\n delay = 2 * delay;\n\n }\n\n }\n\n is->frame_timer += delay;\n\n\n\n av_log(NULL, AV_LOG_TRACE, \"video: delay=%0.3f pts=%0.3f A-V=%f\\n\",\n\n delay, frame_current_pts, -diff);\n\n\n\n return is->frame_timer;\n\n}\n", + "output": "1", + "index": 8890 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void imx_timerp_create(const target_phys_addr_t addr,\n\n qemu_irq irq,\n\n DeviceState *ccm)\n\n{\n\n IMXTimerPState *pp;\n\n DeviceState *dev;\n\n\n\n dev = sysbus_create_simple(\"imx_timerp\", addr, irq);\n\n pp = container_of(dev, IMXTimerPState, busdev.qdev);\n\n pp->ccm = ccm;\n\n}\n", + "output": "0", + "index": 2738 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "connect_to_qemu(\n\n const char *host,\n\n const char *port\n\n) {\n\n struct addrinfo hints;\n\n struct addrinfo *server;\n\n int ret, sock;\n\n\n\n sock = qemu_socket(AF_INET, SOCK_STREAM, 0);\n\n if (sock < 0) {\n\n /* Error */\n\n fprintf(stderr, \"Error opening socket!\\n\");\n\n return -1;\n\n }\n\n\n\n memset(&hints, 0, sizeof(struct addrinfo));\n\n hints.ai_family = AF_UNSPEC;\n\n hints.ai_socktype = SOCK_STREAM;\n\n hints.ai_flags = 0;\n\n hints.ai_protocol = 0; /* Any protocol */\n\n\n\n ret = getaddrinfo(host, port, &hints, &server);\n\n\n\n if (ret != 0) {\n\n /* Error */\n\n fprintf(stderr, \"getaddrinfo failed\\n\");\n\n return -1;\n\n }\n\n\n\n if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {\n\n /* Error */\n\n fprintf(stderr, \"Could not connect\\n\");\n\n return -1;\n\n }\n\n if (verbose) {\n\n printf(\"Connected (sizeof Header=%zd)!\\n\", sizeof(VSCMsgHeader));\n\n }\n\n return sock;\n\n}\n", + "output": "1", + "index": 13661 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qdict_destroy_obj(QObject *obj)\n\n{\n\n int i;\n\n QDict *qdict;\n\n\n\n assert(obj != NULL);\n\n qdict = qobject_to_qdict(obj);\n\n\n\n for (i = 0; i < QDICT_BUCKET_MAX; i++) {\n\n QDictEntry *entry = QLIST_FIRST(&qdict->table[i]);\n\n while (entry) {\n\n QDictEntry *tmp = QLIST_NEXT(entry, next);\n\n QLIST_REMOVE(entry, next);\n\n qentry_destroy(entry);\n\n entry = tmp;\n\n }\n\n }\n\n\n\n g_free(qdict);\n\n}\n", + "output": "0", + "index": 610 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_gdbserver(int argc, const char **argv)\n\n{\n\n int port;\n\n\n\n port = DEFAULT_GDBSTUB_PORT;\n\n if (argc >= 2)\n\n port = atoi(argv[1]);\n\n if (gdbserver_start(port) < 0) {\n\n qemu_printf(\"Could not open gdbserver socket on port %d\\n\", port);\n\n } else {\n\n qemu_printf(\"Waiting gdb connection on port %d\\n\", port);\n\n }\n\n}\n", + "output": "0", + "index": 16408 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_default_query_formats(AVFilterContext *ctx)\n\n{\n\n return default_query_formats_common(ctx, ff_all_channel_layouts);\n\n}\n", + "output": "0", + "index": 11857 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool release_pending(sPAPRDRConnector *drc)\n\n{\n\n return drc->awaiting_release;\n\n}\n", + "output": "0", + "index": 1707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static IOMMUTLBEntry amdvi_translate(MemoryRegion *iommu, hwaddr addr,\n\n bool is_write)\n\n{\n\n AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);\n\n AMDVIState *s = as->iommu_state;\n\n IOMMUTLBEntry ret = {\n\n .target_as = &address_space_memory,\n\n .iova = addr,\n\n .translated_addr = 0,\n\n .addr_mask = ~(hwaddr)0,\n\n .perm = IOMMU_NONE\n\n };\n\n\n\n if (!s->enabled) {\n\n /* AMDVI disabled - corresponds to iommu=off not\n\n * failure to provide any parameter\n\n */\n\n ret.iova = addr & AMDVI_PAGE_MASK_4K;\n\n ret.translated_addr = addr & AMDVI_PAGE_MASK_4K;\n\n ret.addr_mask = ~AMDVI_PAGE_MASK_4K;\n\n ret.perm = IOMMU_RW;\n\n return ret;\n\n } else if (amdvi_is_interrupt_addr(addr)) {\n\n ret.iova = addr & AMDVI_PAGE_MASK_4K;\n\n ret.translated_addr = addr & AMDVI_PAGE_MASK_4K;\n\n ret.addr_mask = ~AMDVI_PAGE_MASK_4K;\n\n ret.perm = IOMMU_WO;\n\n return ret;\n\n }\n\n\n\n amdvi_do_translate(as, addr, is_write, &ret);\n\n trace_amdvi_translation_result(as->bus_num, PCI_SLOT(as->devfn),\n\n PCI_FUNC(as->devfn), addr, ret.translated_addr);\n\n return ret;\n\n}\n", + "output": "0", + "index": 6824 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vhost_user_set_owner(struct vhost_dev *dev)\n\n{\n\n VhostUserMsg msg = {\n\n .request = VHOST_USER_SET_OWNER,\n\n .flags = VHOST_USER_VERSION,\n\n };\n\n\n\n vhost_user_write(dev, &msg, NULL, 0);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 13917 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vorbis_decode_frame(AVCodecContext *avccontext,\n\n void *data, int *data_size,\n\n AVPacket *avpkt)\n\n{\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n vorbis_context *vc = avccontext->priv_data ;\n\n GetBitContext *gb = &(vc->gb);\n\n const float *channel_ptrs[255];\n\n int i, len;\n\n\n\n if (!buf_size)\n\n return 0;\n\n\n\n av_dlog(NULL, \"packet length %d \\n\", buf_size);\n\n\n\n init_get_bits(gb, buf, buf_size*8);\n\n\n\n len = vorbis_parse_audio_packet(vc);\n\n\n\n if (len <= 0) {\n\n *data_size = 0;\n\n return buf_size;\n\n }\n\n\n\n if (!vc->first_frame) {\n\n vc->first_frame = 1;\n\n *data_size = 0;\n\n return buf_size ;\n\n }\n\n\n\n av_dlog(NULL, \"parsed %d bytes %d bits, returned %d samples (*ch*bits) \\n\",\n\n get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);\n\n\n\n if (vc->audio_channels > 8) {\n\n for (i = 0; i < vc->audio_channels; i++)\n\n channel_ptrs[i] = vc->channel_floors + i * len;\n\n } else {\n\n for (i = 0; i < vc->audio_channels; i++)\n\n channel_ptrs[i] = vc->channel_floors +\n\n len * ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i];\n\n }\n\n\n\n if (avccontext->sample_fmt == AV_SAMPLE_FMT_FLT)\n\n vc->fmt_conv.float_interleave(data, channel_ptrs, len, vc->audio_channels);\n\n else\n\n vc->fmt_conv.float_to_int16_interleave(data, channel_ptrs, len,\n\n vc->audio_channels);\n\n\n\n *data_size = len * vc->audio_channels *\n\n av_get_bytes_per_sample(avccontext->sample_fmt);\n\n\n\n return buf_size ;\n\n}\n", + "output": "0", + "index": 357 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ftp_shutdown(URLContext *h, int flags)\n\n{\n\n FTPContext *s = h->priv_data;\n\n\n\n av_dlog(h, \"ftp protocol shutdown\\n\");\n\n\n\n if (s->conn_data)\n\n return ffurl_shutdown(s->conn_data, flags);\n\n\n\n return AVERROR(EIO);\n\n}\n", + "output": "0", + "index": 23652 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpc8_probe(AVProbeData *p)\n\n{\n\n const uint8_t *bs = p->buf + 4;\n\n const uint8_t *bs_end = bs + p->buf_size;\n\n int64_t size;\n\n\n\n if (p->buf_size < 16)\n\n return 0;\n\n if (AV_RL32(p->buf) != TAG_MPCK)\n\n return 0;\n\n while (bs < bs_end + 3) {\n\n int header_found = (bs[0] == 'S' && bs[1] == 'H');\n\n if (bs[0] < 'A' || bs[0] > 'Z' || bs[1] < 'A' || bs[1] > 'Z')\n\n return 0;\n\n bs += 2;\n\n size = bs_get_v(&bs);\n\n if (size < 2)\n\n return 0;\n\n if (bs + size - 2 >= bs_end)\n\n return AVPROBE_SCORE_EXTENSION - 1; // seems to be valid MPC but no header yet\n\n if (header_found) {\n\n if (size < 11 || size > 28)\n\n return 0;\n\n if (!AV_RL32(bs)) //zero CRC is invalid\n\n return 0;\n\n return AVPROBE_SCORE_MAX;\n\n } else {\n\n bs += size - 2;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 24823 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool is_zero_cluster_top_locked(BlockDriverState *bs, int64_t start)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n int nr = s->cluster_sectors;\n\n uint64_t off;\n\n int ret;\n\n\n\n ret = qcow2_get_cluster_offset(bs, start << BDRV_SECTOR_BITS, &nr, &off);\n\n assert(nr == s->cluster_sectors);\n\n return ret == QCOW2_CLUSTER_UNALLOCATED || ret == QCOW2_CLUSTER_ZERO;\n\n}\n", + "output": "1", + "index": 10972 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_goto_tb(DisasContext *s, int tb_num, target_ulong eip)\n\n{\n\n target_ulong pc = s->cs_base + eip;\n\n\n\n if (use_goto_tb(s, pc)) {\n\n /* jump to same page: we can use a direct jump */\n\n tcg_gen_goto_tb(tb_num);\n\n gen_jmp_im(eip);\n\n tcg_gen_exit_tb((uintptr_t)s->tb + tb_num);\n\n } else {\n\n /* jump to another page: currently not optimized */\n\n gen_jmp_im(eip);\n\n gen_eob(s);\n\n }\n\n}\n", + "output": "0", + "index": 22067 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void frame_start(H264Context *h){\n\n MpegEncContext * const s = &h->s;\n\n int i;\n\n\n\n MPV_frame_start(s, s->avctx);\n\n ff_er_frame_start(s);\n\n\n\n assert(s->linesize && s->uvlinesize);\n\n\n\n for(i=0; i<16; i++){\n\n h->block_offset[i]= 4*((scan8[i] - scan8[0])&7) + 4*s->linesize*((scan8[i] - scan8[0])>>3);\n\n h->block_offset[24+i]= 4*((scan8[i] - scan8[0])&7) + 8*s->linesize*((scan8[i] - scan8[0])>>3);\n\n }\n\n for(i=0; i<4; i++){\n\n h->block_offset[16+i]=\n\n h->block_offset[20+i]= 4*((scan8[i] - scan8[0])&7) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3);\n\n h->block_offset[24+16+i]=\n\n h->block_offset[24+20+i]= 4*((scan8[i] - scan8[0])&7) + 8*s->uvlinesize*((scan8[i] - scan8[0])>>3);\n\n }\n\n\n\n /* can't be in alloc_tables because linesize isn't known there.\n\n * FIXME: redo bipred weight to not require extra buffer? */\n\n if(!s->obmc_scratchpad)\n\n s->obmc_scratchpad = av_malloc(16*s->linesize + 2*8*s->uvlinesize);\n\n\n\n// s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1;\n\n}\n", + "output": "0", + "index": 11026 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_requests_pending(BlockDriverState *bs)\n\n{\n\n if (!QLIST_EMPTY(&bs->tracked_requests)) {\n\n return true;\n\n }\n\n if (!qemu_co_queue_empty(&bs->throttled_reqs[0])) {\n\n return true;\n\n }\n\n if (!qemu_co_queue_empty(&bs->throttled_reqs[1])) {\n\n return true;\n\n }\n\n if (bs->file && bdrv_requests_pending(bs->file)) {\n\n return true;\n\n }\n\n if (bs->backing_hd && bdrv_requests_pending(bs->backing_hd)) {\n\n return true;\n\n }\n\n return false;\n\n}\n", + "output": "0", + "index": 4511 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_exception(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 mask, buf, len;\n\n uint64_t xinfo;\n\n\n\n if ((nargs < 6) || (nargs > 7) || nret != 1) {\n\n rtas_st(rets, 0, -3);\n\n return;\n\n }\n\n\n\n xinfo = rtas_ld(args, 1);\n\n mask = rtas_ld(args, 2);\n\n buf = rtas_ld(args, 4);\n\n len = rtas_ld(args, 5);\n\n if (nargs == 7) {\n\n xinfo |= (uint64_t)rtas_ld(args, 6) << 32;\n\n }\n\n\n\n if ((mask & EVENT_MASK_EPOW) && pending_epow) {\n\n if (sizeof(*pending_epow) < len) {\n\n len = sizeof(*pending_epow);\n\n }\n\n\n\n cpu_physical_memory_write(buf, pending_epow, len);\n\n g_free(pending_epow);\n\n pending_epow = NULL;\n\n rtas_st(rets, 0, 0);\n\n } else {\n\n rtas_st(rets, 0, 1);\n\n }\n\n}\n", + "output": "0", + "index": 5252 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dump_cook_context(COOKContext *q, COOKextradata *e)\n\n{\n\n //int i=0;\n\n#define PRINT(a,b) av_log(NULL,AV_LOG_ERROR,\" %s = %d\\n\", a, b);\n\n av_log(NULL,AV_LOG_ERROR,\"COOKextradata\\n\");\n\n av_log(NULL,AV_LOG_ERROR,\"cookversion=%x\\n\",e->cookversion);\n\n if (e->cookversion > MONO_COOK2) {\n\n PRINT(\"js_subband_start\",e->js_subband_start);\n\n PRINT(\"js_vlc_bits\",e->js_vlc_bits);\n\n }\n\n av_log(NULL,AV_LOG_ERROR,\"COOKContext\\n\");\n\n PRINT(\"nb_channels\",q->nb_channels);\n\n PRINT(\"bit_rate\",q->bit_rate);\n\n PRINT(\"sample_rate\",q->sample_rate);\n\n PRINT(\"samples_per_channel\",q->samples_per_channel);\n\n PRINT(\"samples_per_frame\",q->samples_per_frame);\n\n PRINT(\"subbands\",q->subbands);\n\n PRINT(\"random_state\",q->random_state);\n\n PRINT(\"mlt_size\",q->mlt_size);\n\n PRINT(\"js_subband_start\",q->js_subband_start);\n\n PRINT(\"numvector_bits\",q->numvector_bits);\n\n PRINT(\"numvector_size\",q->numvector_size);\n\n PRINT(\"total_subbands\",q->total_subbands);\n\n PRINT(\"frame_reorder_counter\",q->frame_reorder_counter);\n\n PRINT(\"frame_reorder_index_size\",q->frame_reorder_index_size);\n\n}\n", + "output": "0", + "index": 4789 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coded_frame_add(void *list, struct FrameListData *cx_frame)\n\n{\n\n struct FrameListData **p = list;\n\n\n\n while (*p != NULL)\n\n p = &(*p)->next;\n\n *p = cx_frame;\n\n cx_frame->next = NULL;\n\n}\n", + "output": "0", + "index": 15805 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pxa2xx_timer_init(SysBusDevice *dev)\n\n{\n\n int i;\n\n int iomemtype;\n\n PXA2xxTimerInfo *s;\n\n qemu_irq irq4;\n\n\n\n s = FROM_SYSBUS(PXA2xxTimerInfo, dev);\n\n s->irq_enabled = 0;\n\n s->oldclock = 0;\n\n s->clock = 0;\n\n s->lastload = qemu_get_clock(vm_clock);\n\n s->reset3 = 0;\n\n\n\n for (i = 0; i < 4; i ++) {\n\n s->timer[i].value = 0;\n\n sysbus_init_irq(dev, &s->timer[i].irq);\n\n s->timer[i].info = s;\n\n s->timer[i].num = i;\n\n s->timer[i].level = 0;\n\n s->timer[i].qtimer = qemu_new_timer(vm_clock,\n\n pxa2xx_timer_tick, &s->timer[i]);\n\n }\n\n if (s->flags & (1 << PXA2XX_TIMER_HAVE_TM4)) {\n\n sysbus_init_irq(dev, &irq4);\n\n\n\n for (i = 0; i < 8; i ++) {\n\n s->tm4[i].tm.value = 0;\n\n s->tm4[i].tm.info = s;\n\n s->tm4[i].tm.num = i + 4;\n\n s->tm4[i].tm.level = 0;\n\n s->tm4[i].freq = 0;\n\n s->tm4[i].control = 0x0;\n\n s->tm4[i].tm.qtimer = qemu_new_timer(vm_clock,\n\n pxa2xx_timer_tick4, &s->tm4[i]);\n\n s->tm4[i].tm.irq = irq4;\n\n }\n\n }\n\n\n\n iomemtype = cpu_register_io_memory(pxa2xx_timer_readfn,\n\n pxa2xx_timer_writefn, s, DEVICE_NATIVE_ENDIAN);\n\n sysbus_init_mmio(dev, 0x00001000, iomemtype);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 16995 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_nvram_realize(VIOsPAPRDevice *dev, Error **errp)\n\n{\n\n sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev);\n\n int ret;\n\n\n\n if (nvram->blk) {\n\n nvram->size = blk_getlength(nvram->blk);\n\n\n\n ret = blk_set_perm(nvram->blk,\n\n BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,\n\n BLK_PERM_ALL, errp);\n\n if (ret < 0) {\n\n return;\n\n }\n\n } else {\n\n nvram->size = DEFAULT_NVRAM_SIZE;\n\n }\n\n\n\n nvram->buf = g_malloc0(nvram->size);\n\n\n\n if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) {\n\n error_setg(errp, \"spapr-nvram must be between %d and %d bytes in size\",\n\n MIN_NVRAM_SIZE, MAX_NVRAM_SIZE);\n\n return;\n\n }\n\n\n\n if (nvram->blk) {\n\n int alen = blk_pread(nvram->blk, 0, nvram->buf, nvram->size);\n\n\n\n if (alen != nvram->size) {\n\n error_setg(errp, \"can't read spapr-nvram contents\");\n\n return;\n\n }\n\n } else if (nb_prom_envs > 0) {\n\n /* Create a system partition to pass the -prom-env variables */\n\n chrp_nvram_create_system_partition(nvram->buf, MIN_NVRAM_SIZE / 4);\n\n chrp_nvram_create_free_partition(&nvram->buf[MIN_NVRAM_SIZE / 4],\n\n nvram->size - MIN_NVRAM_SIZE / 4);\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", + "output": "0", + "index": 11642 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf)\n\n{\n\n return s->ops->lstat(&s->ctx, path->data, stbuf);\n\n}\n", + "output": "0", + "index": 5657 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_client_read(VncState *vs)\n\n{\n\n ssize_t ret;\n\n\n\n#ifdef CONFIG_VNC_SASL\n\n if (vs->sasl.conn && vs->sasl.runSSF)\n\n ret = vnc_client_read_sasl(vs);\n\n else\n\n#endif /* CONFIG_VNC_SASL */\n\n ret = vnc_client_read_plain(vs);\n\n if (!ret) {\n\n if (vs->disconnecting) {\n\n vnc_disconnect_finish(vs);\n\n }\n\n return;\n\n }\n\n\n\n while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {\n\n size_t len = vs->read_handler_expect;\n\n int ret;\n\n\n\n ret = vs->read_handler(vs, vs->input.buffer, len);\n\n if (vs->disconnecting) {\n\n vnc_disconnect_finish(vs);\n\n return;\n\n }\n\n\n\n if (!ret) {\n\n buffer_advance(&vs->input, len);\n\n } else {\n\n vs->read_handler_expect = ret;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 11658 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hpet_init(SysBusDevice *dev)\n\n{\n\n HPETState *s = FROM_SYSBUS(HPETState, dev);\n\n int i, iomemtype;\n\n HPETTimer *timer;\n\n\n\n if (hpet_cfg.count == UINT8_MAX) {\n\n /* first instance */\n\n hpet_cfg.count = 0;\n\n }\n\n\n\n if (hpet_cfg.count == 8) {\n\n fprintf(stderr, \"Only 8 instances of HPET is allowed\\n\");\n\n return -1;\n\n }\n\n\n\n s->hpet_id = hpet_cfg.count++;\n\n\n\n for (i = 0; i < HPET_NUM_IRQ_ROUTES; i++) {\n\n sysbus_init_irq(dev, &s->irqs[i]);\n\n }\n\n\n\n if (s->num_timers < HPET_MIN_TIMERS) {\n\n s->num_timers = HPET_MIN_TIMERS;\n\n } else if (s->num_timers > HPET_MAX_TIMERS) {\n\n s->num_timers = HPET_MAX_TIMERS;\n\n }\n\n for (i = 0; i < HPET_MAX_TIMERS; i++) {\n\n timer = &s->timer[i];\n\n timer->qemu_timer = qemu_new_timer(vm_clock, hpet_timer, timer);\n\n timer->tn = i;\n\n timer->state = s;\n\n }\n\n\n\n /* 64-bit main counter; LegacyReplacementRoute. */\n\n s->capability = 0x8086a001ULL;\n\n s->capability |= (s->num_timers - 1) << HPET_ID_NUM_TIM_SHIFT;\n\n s->capability |= ((HPET_CLK_PERIOD) << 32);\n\n\n\n isa_reserve_irq(RTC_ISA_IRQ);\n\n qdev_init_gpio_in(&dev->qdev, hpet_handle_rtc_irq, 1);\n\n\n\n /* HPET Area */\n\n iomemtype = cpu_register_io_memory(hpet_ram_read,\n\n hpet_ram_write, s,\n\n DEVICE_NATIVE_ENDIAN);\n\n sysbus_init_mmio(dev, 0x400, iomemtype);\n\n return 0;\n\n}\n", + "output": "0", + "index": 3433 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)\n\n{\n\n AVIndexEntry *sample = NULL;\n\n int64_t best_dts = INT64_MAX;\n\n int i;\n\n for (i = 0; i < s->nb_streams; i++) {\n\n AVStream *avst = s->streams[i];\n\n MOVStreamContext *msc = avst->priv_data;\n\n if (msc->pb && msc->current_sample < avst->nb_index_entries) {\n\n AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample];\n\n int64_t dts;\n\n if (msc->ctts_data)\n\n dts = av_rescale(current_sample->timestamp - msc->dts_shift - msc->ctts_data[msc->ctts_index].duration,\n\n AV_TIME_BASE, msc->time_scale);\n\n else\n\n dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);\n\n av_dlog(s, \"stream %d, sample %d, dts %\"PRId64\"\\n\", i, msc->current_sample, dts);\n\n if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) ||\n\n (s->pb->seekable &&\n\n ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&\n\n ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||\n\n (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {\n\n sample = current_sample;\n\n best_dts = dts;\n\n *st = avst;\n\n }\n\n }\n\n }\n\n return sample;\n\n}\n", + "output": "0", + "index": 13755 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static GIOStatus ga_channel_write(GAChannel *c, const char *buf, size_t size,\n\n size_t *count)\n\n{\n\n GIOStatus status;\n\n OVERLAPPED ov = {0};\n\n BOOL ret;\n\n DWORD written;\n\n\n\n ov.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);\n\n ret = WriteFile(c->handle, buf, size, &written, &ov);\n\n if (!ret) {\n\n if (GetLastError() == ERROR_IO_PENDING) {\n\n /* write is pending */\n\n ret = GetOverlappedResult(c->handle, &ov, &written, TRUE);\n\n if (!ret) {\n\n if (!GetLastError()) {\n\n status = G_IO_STATUS_AGAIN;\n\n } else {\n\n status = G_IO_STATUS_ERROR;\n\n\n } else {\n\n /* write is complete */\n\n status = G_IO_STATUS_NORMAL;\n\n *count = written;\n\n\n } else {\n\n status = G_IO_STATUS_ERROR;\n\n\n } else {\n\n /* write returned immediately */\n\n status = G_IO_STATUS_NORMAL;\n\n *count = written;\n\n\n\n\n\n\n\n\n return status;\n", + "output": "1", + "index": 13739 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ftp_passive_mode_epsv(FTPContext *s)\n\n{\n\n char *res = NULL, *start = NULL, *end = NULL;\n\n int i;\n\n static const char d = '|';\n\n static const char *command = \"EPSV\\r\\n\";\n\n static const int epsv_codes[] = {229, 0};\n\n\n\n if (ftp_send_command(s, command, epsv_codes, &res) != 229 || !res)\n\n goto fail;\n\n\n\n for (i = 0; res[i]; ++i) {\n\n if (res[i] == '(') {\n\n start = res + i + 1;\n\n } else if (res[i] == ')') {\n\n end = res + i;\n\n break;\n\n }\n\n }\n\n if (!start || !end)\n\n goto fail;\n\n\n\n *end = '\\0';\n\n if (strlen(start) < 5)\n\n goto fail;\n\n if (start[0] != d || start[1] != d || start[2] != d || end[-1] != d)\n\n goto fail;\n\n start += 3;\n\n end[-1] = '\\0';\n\n\n\n s->server_data_port = atoi(start);\n\n av_dlog(s, \"Server data port: %d\\n\", s->server_data_port);\n\n\n\n av_free(res);\n\n return 0;\n\n\n\n fail:\n\n av_free(res);\n\n s->server_data_port = -1;\n\n return AVERROR(ENOSYS);\n\n}\n", + "output": "0", + "index": 18583 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ac3_downmix(AC3DecodeContext *s)\n\n{\n\n int i, j;\n\n float v0, v1;\n\n\n\n for(i=0; i<256; i++) {\n\n v0 = v1 = 0.0f;\n\n for(j=0; jfbw_channels; j++) {\n\n v0 += s->output[j][i] * s->downmix_coeffs[j][0];\n\n v1 += s->output[j][i] * s->downmix_coeffs[j][1];\n\n }\n\n v0 /= s->downmix_coeff_sum[0];\n\n v1 /= s->downmix_coeff_sum[1];\n\n if(s->output_mode == AC3_CHMODE_MONO) {\n\n s->output[0][i] = (v0 + v1) * LEVEL_MINUS_3DB;\n\n } else if(s->output_mode == AC3_CHMODE_STEREO) {\n\n s->output[0][i] = v0;\n\n s->output[1][i] = v1;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 12998 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_is_valid_name(const char *name)\n\n{\n\n return qemu_opts_id_wellformed(name);\n\n}\n", + "output": "0", + "index": 17639 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_arch_init(KVMState *s)\n\n{\n\n uint64_t identity_base = 0xfffbc000;\n\n int ret;\n\n struct utsname utsname;\n\n\n\n ret = kvm_get_supported_msrs(s);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n uname(&utsname);\n\n lm_capable_kernel = strcmp(utsname.machine, \"x86_64\") == 0;\n\n\n\n /*\n\n * On older Intel CPUs, KVM uses vm86 mode to emulate 16-bit code directly.\n\n * In order to use vm86 mode, an EPT identity map and a TSS are needed.\n\n * Since these must be part of guest physical memory, we need to allocate\n\n * them, both by setting their start addresses in the kernel and by\n\n * creating a corresponding e820 entry. We need 4 pages before the BIOS.\n\n *\n\n * Older KVM versions may not support setting the identity map base. In\n\n * that case we need to stick with the default, i.e. a 256K maximum BIOS\n\n * size.\n\n */\n\n#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR\n\n if (kvm_check_extension(s, KVM_CAP_SET_IDENTITY_MAP_ADDR)) {\n\n /* Allows up to 16M BIOSes. */\n\n identity_base = 0xfeffc000;\n\n\n\n ret = kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &identity_base);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n }\n\n#endif\n\n /* Set TSS base one page after EPT identity map. */\n\n ret = kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base + 0x1000);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n /* Tell fw_cfg to notify the BIOS to reserve the range. */\n\n ret = e820_add_entry(identity_base, 0x4000, E820_RESERVED);\n\n if (ret < 0) {\n\n fprintf(stderr, \"e820_add_entry() table is full\\n\");\n\n return ret;\n\n }\n\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 8772 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,\n\n target_ulong pc)\n\n{\n\n struct kvm_sw_breakpoint *bp;\n\n\n\n TAILQ_FOREACH(bp, &env->kvm_state->kvm_sw_breakpoints, entry) {\n\n if (bp->pc == pc)\n\n return bp;\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 16952 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static SpiceChannelList *qmp_query_spice_channels(void)\n\n{\n\n SpiceChannelList *cur_item = NULL, *head = NULL;\n\n ChannelList *item;\n\n\n\n QTAILQ_FOREACH(item, &channel_list, link) {\n\n SpiceChannelList *chan;\n\n char host[NI_MAXHOST], port[NI_MAXSERV];\n\n struct sockaddr *paddr;\n\n socklen_t plen;\n\n\n\n assert(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT);\n\n\n\n chan = g_malloc0(sizeof(*chan));\n\n chan->value = g_malloc0(sizeof(*chan->value));\n\n chan->value->base = g_malloc0(sizeof(*chan->value->base));\n\n\n\n paddr = (struct sockaddr *)&item->info->paddr_ext;\n\n plen = item->info->plen_ext;\n\n getnameinfo(paddr, plen,\n\n host, sizeof(host), port, sizeof(port),\n\n NI_NUMERICHOST | NI_NUMERICSERV);\n\n chan->value->base->host = g_strdup(host);\n\n chan->value->base->port = g_strdup(port);\n\n chan->value->base->family = inet_netfamily(paddr->sa_family);\n\n\n\n chan->value->connection_id = item->info->connection_id;\n\n chan->value->channel_type = item->info->type;\n\n chan->value->channel_id = item->info->id;\n\n chan->value->tls = item->info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS;\n\n\n\n /* XXX: waiting for the qapi to support GSList */\n\n if (!cur_item) {\n\n head = cur_item = chan;\n\n } else {\n\n cur_item->next = chan;\n\n cur_item = chan;\n\n }\n\n }\n\n\n\n return head;\n\n}\n", + "output": "0", + "index": 19276 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)\n\n{\n\n int pid;\n\n\n\n pid = filter->pid;\n\n if (filter->type == MPEGTS_SECTION)\n\n av_freep(&filter->u.section_filter.section_buf);\n\n\n\n\n\n\n\n\n\n\n av_free(filter);\n\n ts->pids[pid] = NULL;\n", + "output": "1", + "index": 9125 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)\n\n{\n\n /* We don't actually refresh here, but just return data queried in\n\n * iscsi_open(): iscsi targets don't change their limits. */\n\n\n\n IscsiLun *iscsilun = bs->opaque;\n\n uint64_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffffff : 0xffff;\n\n\n\n bs->bl.request_alignment = iscsilun->block_size;\n\n\n\n if (iscsilun->bl.max_xfer_len) {\n\n max_xfer_len = MIN(max_xfer_len, iscsilun->bl.max_xfer_len);\n\n }\n\n\n\n if (max_xfer_len * iscsilun->block_size < INT_MAX) {\n\n bs->bl.max_transfer = max_xfer_len * iscsilun->block_size;\n\n }\n\n\n\n if (iscsilun->lbp.lbpu) {\n\n if (iscsilun->bl.max_unmap < 0xffffffff / iscsilun->block_size) {\n\n bs->bl.max_pdiscard =\n\n iscsilun->bl.max_unmap * iscsilun->block_size;\n\n }\n\n bs->bl.pdiscard_alignment =\n\n iscsilun->bl.opt_unmap_gran * iscsilun->block_size;\n\n } else {\n\n bs->bl.pdiscard_alignment = iscsilun->block_size;\n\n }\n\n\n\n if (iscsilun->bl.max_ws_len < 0xffffffff / iscsilun->block_size) {\n\n bs->bl.max_pwrite_zeroes =\n\n iscsilun->bl.max_ws_len * iscsilun->block_size;\n\n }\n\n if (iscsilun->lbp.lbpws) {\n\n bs->bl.pwrite_zeroes_alignment =\n\n iscsilun->bl.opt_unmap_gran * iscsilun->block_size;\n\n } else {\n\n bs->bl.pwrite_zeroes_alignment = iscsilun->block_size;\n\n }\n\n if (iscsilun->bl.opt_xfer_len &&\n\n iscsilun->bl.opt_xfer_len < INT_MAX / iscsilun->block_size) {\n\n bs->bl.opt_transfer = pow2floor(iscsilun->bl.opt_xfer_len *\n\n iscsilun->block_size);\n\n }\n\n}\n", + "output": "1", + "index": 860 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t block_crypto_init_func(QCryptoBlock *block,\n\n size_t headerlen,\n\n Error **errp,\n\n void *opaque)\n\n{\n\n struct BlockCryptoCreateData *data = opaque;\n\n int ret;\n\n\n\n /* User provided size should reflect amount of space made\n\n * available to the guest, so we must take account of that\n\n * which will be used by the crypto header\n\n */\n\n data->size += headerlen;\n\n\n\n qemu_opt_set_number(data->opts, BLOCK_OPT_SIZE, data->size, &error_abort);\n\n ret = bdrv_create_file(data->filename, data->opts, errp);\n\n if (ret < 0) {\n\n return -1;\n\n }\n\n\n\n data->blk = blk_new_open(data->filename, NULL, NULL,\n\n BDRV_O_RDWR | BDRV_O_PROTOCOL, errp);\n\n if (!data->blk) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 20251 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *grow_array(void *array, int elem_size, int *size, int new_size)\n\n{\n\n if (new_size >= INT_MAX / elem_size) {\n\n av_log(NULL, AV_LOG_ERROR, \"Array too big.\\n\");\n\n exit(1);\n\n }\n\n if (*size < new_size) {\n\n uint8_t *tmp = av_realloc(array, new_size*elem_size);\n\n if (!tmp) {\n\n av_log(NULL, AV_LOG_ERROR, \"Could not alloc buffer.\\n\");\n\n exit(1);\n\n }\n\n memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);\n\n *size = new_size;\n\n return tmp;\n\n }\n\n return array;\n\n}\n", + "output": "1", + "index": 1135 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dvdsub_decode(AVCodecContext *avctx,\n\n void *data, int *data_size,\n\n AVPacket *avpkt)\n\n{\n\n DVDSubContext *ctx = avctx->priv_data;\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n AVSubtitle *sub = data;\n\n int is_menu;\n\n\n\n if (ctx->buf) {\n\n int ret = append_to_cached_buf(avctx, buf, buf_size);\n\n if (ret < 0) {\n\n *data_size = 0;\n\n return ret;\n\n }\n\n buf = ctx->buf;\n\n buf_size = ctx->buf_size;\n\n }\n\n\n\n is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);\n\n if (is_menu == AVERROR(EAGAIN)) {\n\n *data_size = 0;\n\n return append_to_cached_buf(avctx, buf, buf_size);\n\n }\n\n\n\n if (is_menu < 0) {\n\n no_subtitle:\n\n reset_rects(sub);\n\n *data_size = 0;\n\n\n\n return buf_size;\n\n }\n\n if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)\n\n goto no_subtitle;\n\n\n\n if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))\n\n goto no_subtitle;\n\n\n\n#if defined(DEBUG)\n\n {\n\n char ppm_name[32];\n\n\n\n snprintf(ppm_name, sizeof(ppm_name), \"/tmp/%05d.ppm\", ctx->sub_id++);\n\n av_dlog(NULL, \"start=%d ms end =%d ms\\n\",\n\n sub->start_display_time,\n\n sub->end_display_time);\n\n ppm_save(ppm_name, sub->rects[0]->pict.data[0],\n\n sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);\n\n }\n\n#endif\n\n\n\n av_freep(&ctx->buf);\n\n ctx->buf_size = 0;\n\n *data_size = 1;\n\n return buf_size;\n\n}\n", + "output": "1", + "index": 25745 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int slirp_can_output(void)\n\n{\n\n return 1;\n\n}\n", + "output": "1", + "index": 16350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool qemu_vmstop_requested(RunState *r)\n\n{\n\n if (vmstop_requested < RUN_STATE_MAX) {\n\n *r = vmstop_requested;\n\n vmstop_requested = RUN_STATE_MAX;\n\n return true;\n\n }\n\n\n\n return false;\n\n}\n", + "output": "1", + "index": 6170 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void select_soundhw(const char *optarg)\n\n{\n\n struct soundhw *c;\n\n\n\n if (*optarg == '?') {\n\n show_valid_cards:\n\n\n\n printf(\"Valid sound card names (comma separated):\\n\");\n\n for (c = soundhw; c->name; ++c) {\n\n printf (\"%-11s %s\\n\", c->name, c->descr);\n\n }\n\n printf(\"\\n-soundhw all will enable all of the above\\n\");\n\n exit(*optarg != '?');\n\n }\n\n else {\n\n size_t l;\n\n const char *p;\n\n char *e;\n\n int bad_card = 0;\n\n\n\n if (!strcmp(optarg, \"all\")) {\n\n for (c = soundhw; c->name; ++c) {\n\n c->enabled = 1;\n\n }\n\n return;\n\n }\n\n\n\n p = optarg;\n\n while (*p) {\n\n e = strchr(p, ',');\n\n l = !e ? strlen(p) : (size_t) (e - p);\n\n\n\n for (c = soundhw; c->name; ++c) {\n\n if (!strncmp(c->name, p, l) && !c->name[l]) {\n\n c->enabled = 1;\n\n break;\n\n }\n\n }\n\n\n\n if (!c->name) {\n\n if (l > 80) {\n\n fprintf(stderr,\n\n \"Unknown sound card name (too big to show)\\n\");\n\n }\n\n else {\n\n fprintf(stderr, \"Unknown sound card name `%.*s'\\n\",\n\n (int) l, p);\n\n }\n\n bad_card = 1;\n\n }\n\n p += l + (e != NULL);\n\n }\n\n\n\n if (bad_card) {\n\n goto show_valid_cards;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 7676 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)\n\n{\n\n const char *filename = qemu_opt_get(opts, \"path\");\n\n CharDriverState *chr;\n\n int fd;\n\n\n\n fd = open(filename, O_RDWR);\n\n if (fd < 0)\n\n return NULL;\n\n\n\n chr = g_malloc0(sizeof(CharDriverState));\n\n chr->opaque = (void *)(intptr_t)fd;\n\n chr->chr_write = null_chr_write;\n\n chr->chr_ioctl = pp_ioctl;\n\n return chr;\n\n}\n", + "output": "1", + "index": 7200 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hd_geometry_guess(BlockDriverState *bs,\n\n uint32_t *pcyls, uint32_t *pheads, uint32_t *psecs,\n\n int *ptrans)\n\n{\n\n int cylinders, heads, secs, translation;\n\n\n\n if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) {\n\n /* no LCHS guess: use a standard physical disk geometry */\n\n guess_chs_for_size(bs, pcyls, pheads, psecs);\n\n translation = hd_bios_chs_auto_trans(*pcyls, *pheads, *psecs);\n\n } else if (heads > 16) {\n\n /* LCHS guess with heads > 16 means that a BIOS LBA\n\n translation was active, so a standard physical disk\n\n geometry is OK */\n\n guess_chs_for_size(bs, pcyls, pheads, psecs);\n\n translation = *pcyls * *pheads <= 131072\n\n ? BIOS_ATA_TRANSLATION_LARGE\n\n : BIOS_ATA_TRANSLATION_LBA;\n\n } else {\n\n /* LCHS guess with heads <= 16: use as physical geometry */\n\n *pcyls = cylinders;\n\n *pheads = heads;\n\n *psecs = secs;\n\n /* disable any translation to be in sync with\n\n the logical geometry */\n\n translation = BIOS_ATA_TRANSLATION_NONE;\n\n }\n\n if (ptrans) {\n\n *ptrans = translation;\n\n }\n\n trace_hd_geometry_guess(bs, *pcyls, *pheads, *psecs, translation);\n\n}\n", + "output": "0", + "index": 18006 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_validate_fail_list(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefOneList *head = NULL;\n\n Error *err = NULL;\n\n Visitor *v;\n\n\n\n v = validate_test_init(data, \"[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]\");\n\n\n\n visit_type_UserDefOneList(v, NULL, &head, &err);\n\n error_free_or_abort(&err);\n\n g_assert(!head);\n\n}\n", + "output": "0", + "index": 16610 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mirror_iteration_done(MirrorOp *op, int ret)\n\n{\n\n MirrorBlockJob *s = op->s;\n\n struct iovec *iov;\n\n int64_t chunk_num;\n\n int i, nb_chunks, sectors_per_chunk;\n\n\n\n trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret);\n\n\n\n s->in_flight--;\n\n s->sectors_in_flight -= op->nb_sectors;\n\n iov = op->qiov.iov;\n\n for (i = 0; i < op->qiov.niov; i++) {\n\n MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base;\n\n QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next);\n\n s->buf_free_count++;\n\n }\n\n\n\n sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;\n\n chunk_num = op->sector_num / sectors_per_chunk;\n\n nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk);\n\n bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks);\n\n if (ret >= 0) {\n\n if (s->cow_bitmap) {\n\n bitmap_set(s->cow_bitmap, chunk_num, nb_chunks);\n\n }\n\n s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE;\n\n }\n\n\n\n qemu_iovec_destroy(&op->qiov);\n\n g_free(op);\n\n\n\n if (s->waiting_for_io) {\n\n qemu_coroutine_enter(s->common.co, NULL);\n\n }\n\n}\n", + "output": "1", + "index": 11350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void start_children(FFStream *feed)\n\n{\n\n if (no_launch)\n\n return;\n\n\n\n for (; feed; feed = feed->next) {\n\n if (feed->child_argv && !feed->pid) {\n\n feed->pid_start = time(0);\n\n\n\n feed->pid = fork();\n\n\n\n if (feed->pid < 0) {\n\n http_log(\"Unable to create children\\n\");\n\n exit(1);\n\n }\n\n if (!feed->pid) {\n\n /* In child */\n\n char pathname[1024];\n\n char *slash;\n\n int i;\n\n\n\n av_strlcpy(pathname, my_program_name, sizeof(pathname));\n\n\n\n slash = strrchr(pathname, '/');\n\n if (!slash)\n\n slash = pathname;\n\n else\n\n slash++;\n\n strcpy(slash, \"ffmpeg\");\n\n\n\n http_log(\"Launch command line: \");\n\n http_log(\"%s \", pathname);\n\n for (i = 1; feed->child_argv[i] && feed->child_argv[i][0]; i++)\n\n http_log(\"%s \", feed->child_argv[i]);\n\n http_log(\"\\n\");\n\n\n\n for (i = 3; i < 256; i++)\n\n close(i);\n\n\n\n if (!ffserver_debug) {\n\n i = open(\"/dev/null\", O_RDWR);\n\n if (i != -1) {\n\n dup2(i, 0);\n\n dup2(i, 1);\n\n dup2(i, 2);\n\n close(i);\n\n }\n\n }\n\n\n\n /* This is needed to make relative pathnames work */\n\n chdir(my_program_dir);\n\n\n\n signal(SIGPIPE, SIG_DFL);\n\n\n\n execvp(pathname, feed->child_argv);\n\n\n\n _exit(1);\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 5416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int flush_blks(QEMUFile *f)\n\n{\n\n BlkMigBlock *blk;\n\n int ret = 0;\n\n\n\n DPRINTF(\"%s Enter submitted %d read_done %d transferred %d\\n\",\n\n __FUNCTION__, block_mig_state.submitted, block_mig_state.read_done,\n\n block_mig_state.transferred);\n\n\n\n blk_mig_lock();\n\n while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {\n\n if (qemu_file_rate_limit(f)) {\n\n break;\n\n }\n\n if (blk->ret < 0) {\n\n ret = blk->ret;\n\n break;\n\n }\n\n\n\n QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);\n\n blk_mig_unlock();\n\n blk_send(f, blk);\n\n blk_mig_lock();\n\n\n\n g_free(blk->buf);\n\n g_free(blk);\n\n\n\n block_mig_state.read_done--;\n\n block_mig_state.transferred++;\n\n assert(block_mig_state.read_done >= 0);\n\n }\n\n blk_mig_unlock();\n\n\n\n DPRINTF(\"%s Exit submitted %d read_done %d transferred %d\\n\", __FUNCTION__,\n\n block_mig_state.submitted, block_mig_state.read_done,\n\n block_mig_state.transferred);\n\n return ret;\n\n}\n", + "output": "1", + "index": 7919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "target_ulong helper_load_slb_vsid(CPUPPCState *env, target_ulong rb)\n\n{\n\n target_ulong rt;\n\n\n\n if (ppc_load_slb_vsid(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": 8325 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int32_t scsi_req_enqueue(SCSIRequest *req, uint8_t *buf)\n\n{\n\n int32_t rc;\n\n\n\n assert(!req->enqueued);\n\n scsi_req_ref(req);\n\n req->enqueued = true;\n\n QTAILQ_INSERT_TAIL(&req->dev->requests, req, next);\n\n\n\n scsi_req_ref(req);\n\n rc = req->ops->send_command(req, buf);\n\n scsi_req_unref(req);\n\n return rc;\n\n}\n", + "output": "0", + "index": 1499 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void read_chapter(AVFormatContext *s, AVIOContext *pb, int len, char *ttag, ID3v2ExtraMeta **extra_meta)\n\n{\n\n AVRational time_base = {1, 1000};\n\n uint32_t start, end;\n\n AVChapter *chapter;\n\n uint8_t *dst = NULL;\n\n int taglen;\n\n char tag[5];\n\n\n\n decode_str(s, pb, 0, &dst, &len);\n\n if (len < 16)\n\n return;\n\n\n\n start = avio_rb32(pb);\n\n end = avio_rb32(pb);\n\n avio_skip(pb, 8);\n\n\n\n chapter = avpriv_new_chapter(s, s->nb_chapters + 1, time_base, start, end, dst);\n\n if (!chapter) {\n\n av_free(dst);\n\n return;\n\n }\n\n\n\n len -= 16;\n\n while (len > 10) {\n\n avio_read(pb, tag, 4);\n\n tag[4] = 0;\n\n taglen = avio_rb32(pb);\n\n avio_skip(pb, 2);\n\n len -= 10;\n\n if (taglen < 0 || taglen > len) {\n\n av_free(dst);\n\n return;\n\n }\n\n if (tag[0] == 'T')\n\n read_ttag(s, pb, taglen, &chapter->metadata, tag);\n\n else\n\n avio_skip(pb, taglen);\n\n len -= taglen;\n\n }\n\n\n\n ff_metadata_conv(&chapter->metadata, NULL, ff_id3v2_34_metadata_conv);\n\n ff_metadata_conv(&chapter->metadata, NULL, ff_id3v2_4_metadata_conv);\n\n av_free(dst);\n\n}\n", + "output": "0", + "index": 16808 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)\n\n{\n\n int len, count, i;\n\n NetClientState *ncs[MAX_QUEUE_NUM];\n\n\n\n if (nb_args != 2) {\n\n return;\n\n }\n\n\n\n len = strlen(str);\n\n readline_set_completion_index(rs, len);\n\n count = qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS_KIND_NIC,\n\n MAX_QUEUE_NUM);\n\n for (i = 0; i < count; i++) {\n\n QemuOpts *opts;\n\n const char *name = ncs[i]->name;\n\n if (strncmp(str, name, len)) {\n\n continue;\n\n }\n\n opts = qemu_opts_find(qemu_find_opts_err(\"netdev\", NULL), name);\n\n if (opts) {\n\n readline_add_completion(rs, name);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 18695 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)\n\n{\n\n return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_SAMPLE_FMT, \"sample\", AV_SAMPLE_FMT_NB-1);\n\n}\n", + "output": "0", + "index": 17719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov)\n\n{\n\n int ret;\n\n\n\n ret = bdrv_prwv_co(bs, offset, qiov, true, 0);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n return qiov->size;\n\n}\n", + "output": "0", + "index": 14977 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_label(TCGContext *s, int label_index, tcg_insn_unit *ptr)\n\n{\n\n TCGLabel *l = &s->labels[label_index];\n\n intptr_t value = (intptr_t)ptr;\n\n TCGRelocation *r;\n\n\n\n assert(!l->has_value);\n\n\n\n for (r = l->u.first_reloc; r != NULL; r = r->next) {\n\n patch_reloc(r->ptr, r->type, value, r->addend);\n\n }\n\n\n\n l->has_value = 1;\n\n l->u.value_ptr = ptr;\n\n}\n", + "output": "0", + "index": 20097 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)\n\n{\n\n USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev);\n\n USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);\n\n int rc;\n\n\n\n pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);\n\n dev->info = info;\n\n dev->auto_attach = 1;\n\n QLIST_INIT(&dev->strings);\n\n rc = dev->info->init(dev);\n\n if (rc == 0 && dev->auto_attach)\n\n rc = usb_device_attach(dev);\n\n return rc;\n\n}\n", + "output": "0", + "index": 12643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_info_uuid(Monitor *mon)\n\n{\n\n monitor_printf(mon, UUID_FMT \"\\n\", qemu_uuid[0], qemu_uuid[1],\n\n qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5],\n\n qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9],\n\n qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],\n\n qemu_uuid[14], qemu_uuid[15]);\n\n}\n", + "output": "0", + "index": 7507 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline TranslationBlock *tb_find_fast(CPUState *cpu,\n\n TranslationBlock *last_tb,\n\n int tb_exit)\n\n{\n\n CPUArchState *env = (CPUArchState *)cpu->env_ptr;\n\n TranslationBlock *tb;\n\n target_ulong cs_base, pc;\n\n uint32_t flags;\n\n\n\n /* we record a subset of the CPU state. It will\n\n always be the same before a given translated block\n\n is executed. */\n\n cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);\n\n tb_lock();\n\n tb = atomic_rcu_read(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]);\n\n if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||\n\n tb->flags != flags)) {\n\n tb = tb_find_slow(cpu, pc, cs_base, flags);\n\n }\n\n#ifndef CONFIG_USER_ONLY\n\n /* We don't take care of direct jumps when address mapping changes in\n\n * system emulation. So it's not safe to make a direct jump to a TB\n\n * spanning two pages because the mapping for the second page can change.\n\n */\n\n if (tb->page_addr[1] != -1) {\n\n last_tb = NULL;\n\n }\n\n#endif\n\n /* See if we can patch the calling TB. */\n\n if (last_tb && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {\n\n /* Check if translation buffer has been flushed */\n\n if (cpu->tb_flushed) {\n\n cpu->tb_flushed = false;\n\n } else {\n\n tb_add_jump(last_tb, tb_exit, tb);\n\n }\n\n }\n\n tb_unlock();\n\n return tb;\n\n}\n", + "output": "0", + "index": 6287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t block_crypto_init_func(QCryptoBlock *block,\n\n void *opaque,\n\n size_t headerlen,\n\n Error **errp)\n\n{\n\n struct BlockCryptoCreateData *data = opaque;\n\n int ret;\n\n\n\n /* User provided size should reflect amount of space made\n\n * available to the guest, so we must take account of that\n\n * which will be used by the crypto header\n\n */\n\n data->size += headerlen;\n\n\n\n qemu_opt_set_number(data->opts, BLOCK_OPT_SIZE, data->size, &error_abort);\n\n ret = bdrv_create_file(data->filename, data->opts, errp);\n\n if (ret < 0) {\n\n return -1;\n\n }\n\n\n\n data->blk = blk_new_open(data->filename, NULL, NULL,\n\n BDRV_O_RDWR | BDRV_O_PROTOCOL, errp);\n\n if (!data->blk) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 6931 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int flashsv_encode_end(AVCodecContext *avctx)\n\n{\n\n FlashSVContext *s = avctx->priv_data;\n\n\n\n deflateEnd(&s->zstream);\n\n\n\n av_free(s->encbuffer);\n\n av_free(s->previous_frame);\n\n av_free(s->tmpblock);\n\n\n\n av_frame_free(&avctx->coded_frame);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t HELPER(abs_i64)(int64_t val)\n\n{\n\n HELPER_LOG(\"%s: val 0x%\" PRIx64 \"\\n\", __func__, val);\n\n\n\n if (val < 0) {\n\n return -val;\n\n } else {\n\n return val;\n\n }\n\n}\n", + "output": "0", + "index": 16791 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void phys_sections_clear(void)\n\n{\n\n phys_sections_nb = 0;\n\n}\n", + "output": "1", + "index": 14302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void op_subo (void)\n\n{\n\n target_ulong tmp;\n\n\n\n tmp = T0;\n\n T0 = (int32_t)T0 - (int32_t)T1;\n\n if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) {\n\n CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);\n\n }\n\n RETURN();\n\n}\n", + "output": "1", + "index": 784 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static MpegTSService *mpegts_add_service(MpegTSWrite *ts, int sid,\n\n const char *provider_name,\n\n const char *name)\n\n{\n\n MpegTSService *service;\n\n\n\n service = av_mallocz(sizeof(MpegTSService));\n\n if (!service)\n\n return NULL;\n\n service->pmt.pid = ts->pmt_start_pid + ts->nb_services;\n\n service->sid = sid;\n\n service->provider_name = av_strdup(provider_name);\n\n service->name = av_strdup(name);\n\n service->pcr_pid = 0x1fff;\n\n dynarray_add(&ts->services, &ts->nb_services, service);\n\n return service;\n\n}\n", + "output": "1", + "index": 6412 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static sPAPRDRConnector *spapr_phb_get_pci_drc(sPAPRPHBState *phb,\n\n PCIDevice *pdev)\n\n{\n\n uint32_t busnr = pci_bus_num(PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))));\n\n return spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_PCI,\n\n (phb->index << 16) |\n\n (busnr << 8) |\n\n pdev->devfn);\n\n}\n", + "output": "1", + "index": 3224 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)\n\n{\n\n WaitObjects *w = &wait_objects;\n\n\n\n if (w->num >= MAXIMUM_WAIT_OBJECTS)\n\n return -1;\n\n w->events[w->num] = handle;\n\n w->func[w->num] = func;\n\n w->opaque[w->num] = opaque;\n\n w->num++;\n\n return 0;\n\n}\n", + "output": "0", + "index": 10280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int thp_read_packet(AVFormatContext *s,\n\n AVPacket *pkt)\n\n{\n\n ThpDemuxContext *thp = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n unsigned int size;\n\n int ret;\n\n\n\n if (thp->audiosize == 0) {\n\n /* Terminate when last frame is reached. */\n\n if (thp->frame >= thp->framecnt)\n\n return AVERROR_EOF;\n\n\n\n avio_seek(pb, thp->next_frame, SEEK_SET);\n\n\n\n /* Locate the next frame and read out its size. */\n\n thp->next_frame += FFMAX(thp->next_framesz, 1);\n\n thp->next_framesz = avio_rb32(pb);\n\n\n\n avio_rb32(pb); /* Previous total size. */\n\n size = avio_rb32(pb); /* Total size of this frame. */\n\n\n\n /* Store the audiosize so the next time this function is called,\n\n the audio can be read. */\n\n if (thp->has_audio)\n\n thp->audiosize = avio_rb32(pb); /* Audio size. */\n\n else\n\n thp->frame++;\n\n\n\n ret = av_get_packet(pb, pkt, size);\n\n\n\n if (ret != size) {\n\n av_free_packet(pkt);\n\n return AVERROR(EIO);\n\n }\n\n\n\n pkt->stream_index = thp->video_stream_index;\n\n } else {\n\n ret = av_get_packet(pb, pkt, thp->audiosize);\n\n\n\n if (ret != thp->audiosize) {\n\n av_free_packet(pkt);\n\n return AVERROR(EIO);\n\n }\n\n\n\n pkt->stream_index = thp->audio_stream_index;\n\n if (thp->audiosize >= 8)\n\n pkt->duration = AV_RB32(&pkt->data[4]);\n\n\n\n thp->audiosize = 0;\n\n thp->frame++;\n\n }\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 22249 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int teletext_close_decoder(AVCodecContext *avctx)\n\n{\n\n TeletextContext *ctx = avctx->priv_data;\n\n\n\n av_dlog(avctx, \"lines_total=%u\\n\", ctx->lines_processed);\n\n while (ctx->nb_pages)\n\n subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);\n\n av_freep(&ctx->pages);\n\n\n\n vbi_decoder_delete(ctx->vbi);\n\n ctx->vbi = NULL;\n\n ctx->pts = AV_NOPTS_VALUE;\n\n return 0;\n\n}\n", + "output": "0", + "index": 18036 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size)\n\n{\n\n register const uint8_t* s=src;\n\n register uint8_t* d=dst;\n\n register const uint8_t *end;\n\n const uint8_t *mm_end;\n\n end = s + src_size;\n\n#ifdef HAVE_MMX\n\n __asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s));\n\n __asm __volatile(\"movq\t%0, %%mm4\"::\"m\"(mask15s));\n\n mm_end = end - 15;\n\n while(stype) {\n\n case PCI_REQ_ID_BDF:\n\n result = pci_get_bdf(cache->dev);\n\n break;\n\n case PCI_REQ_ID_SECONDARY_BUS:\n\n bus_n = pci_bus_num(cache->dev->bus);\n\n result = PCI_BUILD_BDF(bus_n, 0);\n\n break;\n\n default:\n\n error_printf(\"Invalid PCI requester ID cache type: %d\\n\",\n\n cache->type);\n\n exit(1);\n\n break;\n\n }\n\n\n\n return result;\n\n}\n", + "output": "0", + "index": 6390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aasc_decode_frame(AVCodecContext *avctx,\n\n void *data, int *got_frame,\n\n AVPacket *avpkt)\n\n{\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n AascContext *s = avctx->priv_data;\n\n int compr, i, stride, ret;\n\n\n\n if (buf_size < 4)\n\n\n\n\n if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"reget_buffer() failed\\n\");\n\n return ret;\n\n }\n\n\n\n compr = AV_RL32(buf);\n\n buf += 4;\n\n buf_size -= 4;\n\n switch (compr) {\n\n case 0:\n\n stride = (avctx->width * 3 + 3) & ~3;\n\n\n\n for (i = avctx->height - 1; i >= 0; i--) {\n\n memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * 3);\n\n buf += stride;\n\n }\n\n break;\n\n case 1:\n\n bytestream2_init(&s->gb, buf, buf_size);\n\n ff_msrle_decode(avctx, (AVPicture*)s->frame, 8, &s->gb);\n\n break;\n\n default:\n\n av_log(avctx, AV_LOG_ERROR, \"Unknown compression type %d\\n\", compr);\n\n\n }\n\n\n\n *got_frame = 1;\n\n if ((ret = av_frame_ref(data, s->frame)) < 0)\n\n return ret;\n\n\n\n /* report that the buffer was completely consumed */\n\n return buf_size;\n\n}", + "output": "1", + "index": 22324 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void t_gen_zext(TCGv d, TCGv s, int size)\n\n{\n\n\tif (size == 1)\n\n\t\ttcg_gen_ext8u_i32(d, s);\n\n\telse if (size == 2)\n\n\t\ttcg_gen_ext16u_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": 18895 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dec_bcc(DisasContext *dc)\n\n{\n\n unsigned int cc;\n\n unsigned int dslot;\n\n\n\n cc = EXTRACT_FIELD(dc->ir, 21, 23);\n\n dslot = dc->ir & (1 << 25);\n\n LOG_DIS(\"bcc%s r%d %x\\n\", dslot ? \"d\" : \"\", dc->ra, dc->imm);\n\n\n\n dc->delayed_branch = 1;\n\n if (dslot) {\n\n dc->delayed_branch = 2;\n\n dc->tb_flags |= D_FLAG;\n\n tcg_gen_st_tl(tcg_const_tl(dc->type_b && (dc->tb_flags & IMM_FLAG)),\n\n cpu_env, offsetof(CPUState, bimm));\n\n }\n\n\n\n if (dec_alu_op_b_is_small_imm(dc)) {\n\n int32_t offset = (int32_t)((int16_t)dc->imm); /* sign-extend. */\n\n\n\n tcg_gen_movi_tl(env_btarget, dc->pc + offset);\n\n } else {\n\n tcg_gen_movi_tl(env_btarget, dc->pc);\n\n tcg_gen_add_tl(env_btarget, env_btarget, *(dec_alu_op_b(dc)));\n\n }\n\n dc->jmp = JMP_INDIRECT;\n\n eval_cc(dc, cc, env_btaken, cpu_R[dc->ra], tcg_const_tl(0));\n\n}\n", + "output": "0", + "index": 4208 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_handle_scsi(VirtIOBlockReq *req)\n\n{\n\n int status;\n\n\n\n status = virtio_blk_handle_scsi_req(req->dev, req->elem);\n\n virtio_blk_req_complete(req, status);\n\n virtio_blk_free_request(req);\n\n}\n", + "output": "1", + "index": 3899 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check_refcounts(BlockDriverState *bs)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int64_t size;\n\n int nb_clusters, refcount1, refcount2, i;\n\n QCowSnapshot *sn;\n\n uint16_t *refcount_table;\n\n\n\n size = bdrv_getlength(s->hd);\n\n nb_clusters = size_to_clusters(s, size);\n\n refcount_table = qemu_mallocz(nb_clusters * sizeof(uint16_t));\n\n\n\n /* header */\n\n inc_refcounts(bs, refcount_table, nb_clusters,\n\n 0, s->cluster_size);\n\n\n\n check_refcounts_l1(bs, refcount_table, nb_clusters,\n\n s->l1_table_offset, s->l1_size, 1);\n\n\n\n /* snapshots */\n\n for(i = 0; i < s->nb_snapshots; i++) {\n\n sn = s->snapshots + i;\n\n check_refcounts_l1(bs, refcount_table, nb_clusters,\n\n sn->l1_table_offset, sn->l1_size, 0);\n\n }\n\n inc_refcounts(bs, refcount_table, nb_clusters,\n\n s->snapshots_offset, s->snapshots_size);\n\n\n\n /* refcount data */\n\n inc_refcounts(bs, refcount_table, nb_clusters,\n\n s->refcount_table_offset,\n\n s->refcount_table_size * sizeof(uint64_t));\n\n for(i = 0; i < s->refcount_table_size; i++) {\n\n int64_t offset;\n\n offset = s->refcount_table[i];\n\n if (offset != 0) {\n\n inc_refcounts(bs, refcount_table, nb_clusters,\n\n offset, s->cluster_size);\n\n }\n\n }\n\n\n\n /* compare ref counts */\n\n for(i = 0; i < nb_clusters; i++) {\n\n refcount1 = get_refcount(bs, i);\n\n refcount2 = refcount_table[i];\n\n if (refcount1 != refcount2)\n\n fprintf(stderr, \"ERROR cluster %d refcount=%d reference=%d\\n\",\n\n i, refcount1, refcount2);\n\n }\n\n\n\n qemu_free(refcount_table);\n\n}\n", + "output": "0", + "index": 8568 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int convert_read(ImgConvertState *s, int64_t sector_num, int nb_sectors,\n\n uint8_t *buf)\n\n{\n\n int n;\n\n int ret;\n\n\n\n if (s->status == BLK_ZERO || s->status == BLK_BACKING_FILE) {\n\n return 0;\n\n }\n\n\n\n assert(nb_sectors <= s->buf_sectors);\n\n while (nb_sectors > 0) {\n\n BlockBackend *blk;\n\n int64_t bs_sectors;\n\n\n\n /* In the case of compression with multiple source files, we can get a\n\n * nb_sectors that spreads into the next part. So we must be able to\n\n * read across multiple BDSes for one convert_read() call. */\n\n convert_select_part(s, sector_num);\n\n blk = s->src[s->src_cur];\n\n bs_sectors = s->src_sectors[s->src_cur];\n\n\n\n n = MIN(nb_sectors, bs_sectors - (sector_num - s->src_cur_offset));\n\n ret = blk_read(blk, sector_num - s->src_cur_offset, buf, n);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n sector_num += n;\n\n nb_sectors -= n;\n\n buf += n * BDRV_SECTOR_SIZE;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 25811 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_opt_set(QemuOpts *opts, const char *name, const char *value)\n\n{\n\n QemuOpt *opt;\n\n\n\n opt = qemu_opt_find(opts, name);\n\n if (!opt) {\n\n QemuOptDesc *desc = opts->list->desc;\n\n int i;\n\n\n\n for (i = 0; desc[i].name != NULL; i++) {\n\n if (strcmp(desc[i].name, name) == 0) {\n\n break;\n\n }\n\n }\n\n if (desc[i].name == NULL) {\n\n if (i == 0) {\n\n /* empty list -> allow any */;\n\n } else {\n\n fprintf(stderr, \"option \\\"%s\\\" is not valid for %s\\n\",\n\n name, opts->list->name);\n\n return -1;\n\n }\n\n }\n\n opt = qemu_mallocz(sizeof(*opt));\n\n opt->name = qemu_strdup(name);\n\n opt->opts = opts;\n\n TAILQ_INSERT_TAIL(&opts->head, opt, next);\n\n if (desc[i].name != NULL) {\n\n opt->desc = desc+i;\n\n }\n\n }\n\n qemu_free((/* !const */ char*)opt->str);\n\n opt->str = NULL;\n\n if (value) {\n\n opt->str = qemu_strdup(value);\n\n }\n\n if (qemu_opt_parse(opt) < 0) {\n\n fprintf(stderr, \"Failed to parse \\\"%s\\\" for \\\"%s.%s\\\"\\n\", opt->str,\n\n opts->list->name, opt->name);\n\n qemu_opt_del(opt);\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 20070 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int put_flac_codecpriv(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)\n\n{\n\n // if the extradata_size is greater than FLAC_STREAMINFO_SIZE,\n\n // assume that it's in Matroska format already\n\n if (codec->extradata_size < FLAC_STREAMINFO_SIZE) {\n\n av_log(s, AV_LOG_ERROR, \"Invalid FLAC extradata\\n\");\n\n return -1;\n\n } else if (codec->extradata_size == FLAC_STREAMINFO_SIZE) {\n\n // only the streaminfo packet\n\n put_buffer(pb, \"fLaC\", 4);\n\n put_byte(pb, 0x80);\n\n put_be24(pb, FLAC_STREAMINFO_SIZE);\n\n } else if(memcmp(\"fLaC\", codec->extradata, 4)) {\n\n av_log(s, AV_LOG_ERROR, \"Invalid FLAC extradata\\n\");\n\n return -1;\n\n }\n\n put_buffer(pb, codec->extradata, codec->extradata_size);\n\n return 0;\n\n}\n", + "output": "0", + "index": 26165 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_ri32(TCGContext *s, int const_arg, TCGArg arg)\n\n{\n\n if (const_arg) {\n\n assert(const_arg == 1);\n\n tcg_out8(s, TCG_CONST);\n\n tcg_out32(s, arg);\n\n } else {\n\n tcg_out_r(s, arg);\n\n }\n\n}\n", + "output": "0", + "index": 21322 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_set_Rc0 (void)\n\n{\n\n env->crf[0] = T0 | xer_ov;\n\n RETURN();\n\n}\n", + "output": "1", + "index": 1401 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nbd_detach_aio_context(BlockDriverState *bs)\n\n{\n\n BDRVNBDState *s = bs->opaque;\n\n\n\n nbd_client_session_detach_aio_context(&s->client);\n\n}\n", + "output": "0", + "index": 16404 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_dump_state(CPUXtensaState *env, FILE *f, fprintf_function cpu_fprintf,\n\n int flags)\n\n{\n\n int i, j;\n\n\n\n cpu_fprintf(f, \"PC=%08x\\n\\n\", env->pc);\n\n\n\n for (i = j = 0; i < 256; ++i) {\n\n if (sregnames[i]) {\n\n cpu_fprintf(f, \"%s=%08x%c\", sregnames[i], env->sregs[i],\n\n (j++ % 4) == 3 ? '\\n' : ' ');\n\n }\n\n }\n\n\n\n cpu_fprintf(f, (j % 4) == 0 ? \"\\n\" : \"\\n\\n\");\n\n\n\n for (i = j = 0; i < 256; ++i) {\n\n if (uregnames[i]) {\n\n cpu_fprintf(f, \"%s=%08x%c\", uregnames[i], env->uregs[i],\n\n (j++ % 4) == 3 ? '\\n' : ' ');\n\n }\n\n }\n\n\n\n cpu_fprintf(f, (j % 4) == 0 ? \"\\n\" : \"\\n\\n\");\n\n\n\n for (i = 0; i < 16; ++i) {\n\n cpu_fprintf(f, \"A%02d=%08x%c\", i, env->regs[i],\n\n (i % 4) == 3 ? '\\n' : ' ');\n\n }\n\n\n\n cpu_fprintf(f, \"\\n\");\n\n\n\n for (i = 0; i < env->config->nareg; ++i) {\n\n cpu_fprintf(f, \"AR%02d=%08x%c\", i, env->phys_regs[i],\n\n (i % 4) == 3 ? '\\n' : ' ');\n\n }\n\n\n\n if (xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) {\n\n cpu_fprintf(f, \"\\n\");\n\n\n\n for (i = 0; i < 16; ++i) {\n\n cpu_fprintf(f, \"F%02d=%08x (%+10.8e)%c\", i,\n\n float32_val(env->fregs[i]),\n\n *(float *)&env->fregs[i], (i % 2) == 1 ? '\\n' : ' ');\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 8771 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_init_mp3on4(AVCodecContext * avctx)\n\n{\n\n MP3On4DecodeContext *s = avctx->priv_data;\n\n int i;\n\n\n\n if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {\n\n av_log(avctx, AV_LOG_ERROR, \"Codec extradata missing or too short.\\n\");\n\n return -1;\n\n }\n\n\n\n s->chan_cfg = (((unsigned char *)avctx->extradata)[1] >> 3) & 0x0f;\n\n s->frames = mp3Frames[s->chan_cfg];\n\n if(!s->frames) {\n\n av_log(avctx, AV_LOG_ERROR, \"Invalid channel config number.\\n\");\n\n return -1;\n\n }\n\n avctx->channels = mp3Channels[s->chan_cfg];\n\n\n\n /* Init the first mp3 decoder in standard way, so that all tables get builded\n\n * We replace avctx->priv_data with the context of the first decoder so that\n\n * decode_init() does not have to be changed.\n\n * Other decoders will be inited here copying data from the first context\n\n */\n\n // Allocate zeroed memory for the first decoder context\n\n s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));\n\n // Put decoder context in place to make init_decode() happy\n\n avctx->priv_data = s->mp3decctx[0];\n\n decode_init(avctx);\n\n // Restore mp3on4 context pointer\n\n avctx->priv_data = s;\n\n s->mp3decctx[0]->adu_mode = 1; // Set adu mode\n\n\n\n /* Create a separate codec/context for each frame (first is already ok).\n\n * Each frame is 1 or 2 channels - up to 5 frames allowed\n\n */\n\n for (i = 1; i < s->frames; i++) {\n\n s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));\n\n s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias;\n\n s->mp3decctx[i]->adu_mode = 1;\n\n s->mp3decctx[i]->avctx = avctx;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13571 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_readlink(void *opaque)\n\n{\n\n V9fsPDU *pdu = opaque;\n\n size_t offset = 7;\n\n V9fsString target;\n\n int32_t fid;\n\n int err = 0;\n\n V9fsFidState *fidp;\n\n\n\n pdu_unmarshal(pdu, offset, \"d\", &fid);\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\n\n v9fs_string_init(&target);\n\n err = v9fs_co_readlink(pdu, &fidp->path, &target);\n\n if (err < 0) {\n\n goto out;\n\n }\n\n offset += pdu_marshal(pdu, offset, \"s\", &target);\n\n err = offset;\n\n v9fs_string_free(&target);\n\nout:\n\n put_fid(pdu, fidp);\n\nout_nofid:\n\n trace_v9fs_readlink_return(pdu->tag, pdu->id, target.data);\n\n complete_pdu(pdu->s, pdu, err);\n\n}", + "output": "1", + "index": 1386 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_uuid_parse(const char *str, uint8_t *uuid)\n\n{\n\n int ret;\n\n\n\n if(strlen(str) != 36)\n\n return -1;\n\n\n\n ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],\n\n &uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],\n\n &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14], &uuid[15]);\n\n\n\n if(ret != 16)\n\n return -1;\n\n\n\n#ifdef TARGET_I386\n\n smbios_add_field(1, offsetof(struct smbios_type_1, uuid), 16, uuid);\n\n#endif\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8281 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int net_tap_init(VLANState *vlan, const char *model,\n\n const char *name, const char *ifname1,\n\n const char *setup_script, const char *down_script)\n\n{\n\n TAPState *s;\n\n int fd;\n\n char ifname[128];\n\n\n\n if (ifname1 != NULL)\n\n pstrcpy(ifname, sizeof(ifname), ifname1);\n\n else\n\n ifname[0] = '\\0';\n\n TFR(fd = tap_open(ifname, sizeof(ifname)));\n\n if (fd < 0)\n\n return -1;\n\n\n\n if (!setup_script || !strcmp(setup_script, \"no\"))\n\n setup_script = \"\";\n\n if (setup_script[0] != '\\0') {\n\n\tif (launch_script(setup_script, ifname, fd))\n\n\t return -1;\n\n }\n\n s = net_tap_fd_init(vlan, model, name, fd);\n\n if (!s)\n\n return -1;\n\n snprintf(s->vc->info_str, sizeof(s->vc->info_str),\n\n \"ifname=%s,script=%s,downscript=%s\",\n\n ifname, setup_script, down_script);\n\n if (down_script && strcmp(down_script, \"no\"))\n\n snprintf(s->down_script, sizeof(s->down_script), \"%s\", down_script);\n\n return 0;\n\n}\n", + "output": "0", + "index": 16261 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps,\n\n uint64_t pte0, uint64_t pte1)\n\n{\n\n int i;\n\n\n\n if (!(pte0 & HPTE64_V_LARGE)) {\n\n if (sps->page_shift != 12) {\n\n /* 4kiB page in a non 4kiB segment */\n\n return 0;\n\n }\n\n /* Normal 4kiB page */\n\n return 12;\n\n }\n\n\n\n for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {\n\n const struct ppc_one_page_size *ps = &sps->enc[i];\n\n uint64_t mask;\n\n\n\n if (!ps->page_shift) {\n\n break;\n\n }\n\n\n\n if (ps->page_shift == 12) {\n\n /* L bit is set so this can't be a 4kiB page */\n\n continue;\n\n }\n\n\n\n mask = ((1ULL << ps->page_shift) - 1) & HPTE64_R_RPN;\n\n\n\n if ((pte1 & mask) == (ps->pte_enc << HPTE64_R_RPN_SHIFT)) {\n\n return ps->page_shift;\n\n }\n\n }\n\n\n\n return 0; /* Bad page size encoding */\n\n}\n", + "output": "1", + "index": 4250 + }, + { + "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 xhci_set_ep_state(xhci, epctx, NULL, EP_DISABLED);\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": "1", + "index": 7287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint_fast16_t float64_to_uint16_round_to_zero(float64 a STATUS_PARAM)\n\n{\n\n int64_t v;\n\n uint_fast16_t res;\n\n\n\n v = float64_to_int64_round_to_zero(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 > 0xffff) {\n\n res = 0xffff;\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": "1", + "index": 17464 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int handle_primary_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 if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) {\n\n trace_colo_filter_rewriter_pkt_info(__func__,\n\n inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),\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 }\n\n\n\n if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {\n\n /*\n\n * we use this flag update offset func\n\n * run once in independent tcp connection\n\n */\n\n conn->syn_flag = 1;\n\n }\n\n\n\n if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) {\n\n if (conn->syn_flag) {\n\n /*\n\n * offset = secondary_seq - primary seq\n\n * ack packet sent by guest from primary node,\n\n * so we use th_ack - 1 get primary_seq\n\n */\n\n conn->offset -= (ntohl(tcp_pkt->th_ack) - 1);\n\n conn->syn_flag = 0;\n\n }\n\n if (conn->offset) {\n\n /* handle packets to the secondary from the primary */\n\n tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset);\n\n\n\n net_checksum_calculate((uint8_t *)pkt->data, pkt->size);\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 437 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static 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 struct omap_eac_s *s = (struct omap_eac_s *)\n\n g_malloc0(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 AUD_register_card(\"OMAP EAC\", &s->codec.card);\n\n\n\n memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, \"omap.eac\",\n\n omap_l4_region_size(ta, 0));\n\n omap_l4_attach(ta, 0, &s->iomem);\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 26102 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn bdrv_co_do_writev(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_pwritev(child->bs, sector_num << BDRV_SECTOR_BITS,\n\n nb_sectors << BDRV_SECTOR_BITS, qiov, flags);\n\n}\n", + "output": "0", + "index": 24165 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *choose_pix_fmts(OutputStream *ost)\n\n{\n\n if (ost->keep_pix_fmt) {\n\n if (ost->filter)\n\n avfilter_graph_set_auto_convert(ost->filter->graph->graph,\n\n AVFILTER_AUTO_CONVERT_NONE);\n\n if (ost->st->codec->pix_fmt == PIX_FMT_NONE)\n\n return NULL;\n\n return av_strdup(av_get_pix_fmt_name(ost->st->codec->pix_fmt));\n\n }\n\n if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {\n\n return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));\n\n } else if (ost->enc->pix_fmts) {\n\n const enum PixelFormat *p;\n\n AVIOContext *s = NULL;\n\n uint8_t *ret;\n\n int len;\n\n\n\n if (avio_open_dyn_buf(&s) < 0)\n\n exit_program(1);\n\n\n\n p = ost->enc->pix_fmts;\n\n if (ost->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {\n\n if (ost->st->codec->codec_id == CODEC_ID_MJPEG) {\n\n p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };\n\n } else if (ost->st->codec->codec_id == CODEC_ID_LJPEG) {\n\n p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,\n\n PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };\n\n }\n\n }\n\n\n\n for (; *p != PIX_FMT_NONE; p++) {\n\n const char *name = av_get_pix_fmt_name(*p);\n\n avio_printf(s, \"%s:\", name);\n\n }\n\n len = avio_close_dyn_buf(s, &ret);\n\n ret[len - 1] = 0;\n\n return ret;\n\n } else\n\n return NULL;\n\n}\n", + "output": "1", + "index": 27295 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint8_t *csrhci_out_packet(struct csrhci_s *s, int len)\n\n{\n\n int off = s->out_start + s->out_len;\n\n\n\n /* TODO: do the padding here, i.e. align len */\n\n s->out_len += len;\n\n\n\n if (off < FIFO_LEN) {\n\n if (off + len > FIFO_LEN && (s->out_size = off + len) > FIFO_LEN * 2) {\n\n fprintf(stderr, \"%s: can't alloc %i bytes\\n\", __func__, len);\n\n exit(-1);\n\n }\n\n return s->outfifo + off;\n\n }\n\n\n\n if (s->out_len > s->out_size) {\n\n fprintf(stderr, \"%s: can't alloc %i bytes\\n\", __func__, len);\n\n exit(-1);\n\n }\n\n\n\n return s->outfifo + off - s->out_size;\n\n}\n", + "output": "0", + "index": 20736 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_init(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(vmsvga_update_display,\n\n vmsvga_invalidate_display,\n\n vmsvga_screen_dump,\n\n vmsvga_text_update, s);\n\n\n\n s->fifo_size = SVGA_FIFO_SIZE;\n\n memory_region_init_ram(&s->fifo_ram, \"vmsvga.fifo\", s->fifo_size);\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);\n\n vga_init(&s->vga, 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": "0", + "index": 10331 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int add_av_stream(FFStream *feed,\n\n AVStream *st)\n\n{\n\n AVStream *fst;\n\n AVCodecContext *av, *av1;\n\n int i;\n\n\n\n av = &st->codec;\n\n for(i=0;inb_streams;i++) {\n\n st = feed->streams[i];\n\n av1 = &st->codec;\n\n if (av1->codec_id == av->codec_id &&\n\n av1->codec_type == av->codec_type &&\n\n av1->bit_rate == av->bit_rate) {\n\n\n\n switch(av->codec_type) {\n\n case CODEC_TYPE_AUDIO:\n\n if (av1->channels == av->channels &&\n\n av1->sample_rate == av->sample_rate)\n\n goto found;\n\n break;\n\n case CODEC_TYPE_VIDEO:\n\n if (av1->width == av->width &&\n\n av1->height == av->height &&\n\n av1->frame_rate == av->frame_rate &&\n\n av1->gop_size == av->gop_size)\n\n goto found;\n\n break;\n\n default:\n\n abort();\n\n }\n\n }\n\n }\n\n \n\n fst = av_mallocz(sizeof(AVStream));\n\n if (!fst)\n\n return -1;\n\n fst->priv_data = av_mallocz(sizeof(FeedData));\n\n memcpy(&fst->codec, av, sizeof(AVCodecContext));\n\n feed->streams[feed->nb_streams++] = fst;\n\n return feed->nb_streams - 1;\n\n found:\n\n return i;\n\n}\n", + "output": "1", + "index": 5616 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,\n\n VirtIODevice *vdev)\n\n{\n\n VirtIOSerialPortClass *vsc;\n\n\n\n assert(port);\n\n assert(virtio_queue_ready(vq));\n\n\n\n vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n\n\n\n while (!port->throttled) {\n\n unsigned int i;\n\n\n\n /* Pop an elem only if we haven't left off a previous one mid-way */\n\n if (!port->elem.out_num) {\n\n if (!virtqueue_pop(vq, &port->elem)) {\n\n break;\n\n }\n\n port->iov_idx = 0;\n\n port->iov_offset = 0;\n\n }\n\n\n\n for (i = port->iov_idx; i < port->elem.out_num; i++) {\n\n size_t buf_size;\n\n ssize_t ret;\n\n\n\n buf_size = port->elem.out_sg[i].iov_len - port->iov_offset;\n\n ret = vsc->have_data(port,\n\n port->elem.out_sg[i].iov_base\n\n + port->iov_offset,\n\n buf_size);\n\n if (port->throttled) {\n\n port->iov_idx = i;\n\n if (ret > 0) {\n\n port->iov_offset += ret;\n\n }\n\n break;\n\n }\n\n port->iov_offset = 0;\n\n }\n\n if (port->throttled) {\n\n break;\n\n }\n\n virtqueue_push(vq, &port->elem, 0);\n\n port->elem.out_num = 0;\n\n }\n\n virtio_notify(vdev, vq);\n\n}\n", + "output": "0", + "index": 12536 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_packet(AVFormatContext *s,\n\n AVPacket *pkt)\n\n{\n\n MmDemuxContext *mm = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n unsigned char preamble[MM_PREAMBLE_SIZE];\n\n unsigned int type, length;\n\n\n\n while(1) {\n\n\n\n if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {\n\n return AVERROR(EIO);\n\n }\n\n\n\n type = AV_RL16(&preamble[0]);\n\n length = AV_RL16(&preamble[2]);\n\n\n\n switch(type) {\n\n case MM_TYPE_PALETTE :\n\n case MM_TYPE_INTER :\n\n case MM_TYPE_INTRA :\n\n case MM_TYPE_INTRA_HH :\n\n case MM_TYPE_INTER_HH :\n\n case MM_TYPE_INTRA_HHV :\n\n case MM_TYPE_INTER_HHV :\n\n /* output preamble + data */\n\n if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))\n\n return AVERROR(ENOMEM);\n\n memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);\n\n if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)\n\n return AVERROR(EIO);\n\n pkt->size = length + MM_PREAMBLE_SIZE;\n\n pkt->stream_index = 0;\n\n pkt->pts = mm->video_pts;\n\n if (type!=MM_TYPE_PALETTE)\n\n mm->video_pts++;\n\n return 0;\n\n\n\n case MM_TYPE_AUDIO :\n\n if (av_get_packet(s->pb, pkt, length)<0)\n\n return AVERROR(ENOMEM);\n\n pkt->size = length;\n\n pkt->stream_index = 1;\n\n pkt->pts = mm->audio_pts++;\n\n return 0;\n\n\n\n default :\n\n av_log(s, AV_LOG_INFO, \"unknown chunk type 0x%x\\n\", type);\n\n avio_skip(pb, length);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 26773 + }, + { + "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, int width)\n\n{\n\n#ifdef HAVE_MMXFIXME\n\n#else\n\n\tint i;\n\n\tfor(i=0; i>1;\n\n\t\tdstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1;\n\n\t}\n\n#endif\n\n}\n", + "output": "0", + "index": 2801 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_divw_AX_T0(void)\n\n{\n\n unsigned int num, den, q, r;\n\n\n\n num = (EAX & 0xffff) | ((EDX & 0xffff) << 16);\n\n den = (T0 & 0xffff);\n\n if (den == 0) {\n\n raise_exception(EXCP00_DIVZ);\n\n }\n\n q = (num / den) & 0xffff;\n\n r = (num % den) & 0xffff;\n\n EAX = (EAX & ~0xffff) | q;\n\n EDX = (EDX & ~0xffff) | r;\n\n}\n", + "output": "1", + "index": 15138 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void quantize_mantissas(AC3EncodeContext *s)\n\n{\n\n int blk, ch;\n\n\n\n\n\n for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {\n\n AC3Block *block = &s->blocks[blk];\n\n s->mant1_cnt = s->mant2_cnt = s->mant4_cnt = 0;\n\n s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL;\n\n\n\n for (ch = 0; ch < s->channels; ch++) {\n\n quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch],\n\n block->exp[ch], block->bap[ch],\n\n block->qmant[ch], s->nb_coefs[ch]);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 21 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,\n\n const uint8_t **bands, const int* num_bands,\n\n int num_groups, const uint8_t *group_map)\n\n{\n\n int i, j, k = 0;\n\n\n\n ctx->avctx = avctx;\n\n ctx->ch = av_mallocz_array(sizeof(ctx->ch[0]), avctx->channels * 2);\n\n ctx->group = av_mallocz_array(sizeof(ctx->group[0]), num_groups);\n\n ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens);\n\n ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens);\n\n\n\n\n if (!ctx->ch || !ctx->group || !ctx->bands || !ctx->num_bands) {\n\n ff_psy_end(ctx);\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens);\n\n memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens);\n\n\n\n /* assign channels to groups (with virtual channels for coupling) */\n\n for (i = 0; i < num_groups; i++) {\n\n /* NOTE: Add 1 to handle the AAC chan_config without modification.\n\n * This has the side effect of allowing an array of 0s to map\n\n * to one channel per group.\n\n */\n\n ctx->group[i].num_ch = group_map[i] + 1;\n\n for (j = 0; j < ctx->group[i].num_ch * 2; j++)\n\n ctx->group[i].ch[j] = &ctx->ch[k++];\n\n }\n\n\n\n switch (ctx->avctx->codec_id) {\n\n case AV_CODEC_ID_AAC:\n\n ctx->model = &ff_aac_psy_model;\n\n break;\n\n }\n\n if (ctx->model->init)\n\n return ctx->model->init(ctx);\n\n return 0;\n\n}", + "output": "1", + "index": 7546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int is_dup_page(uint8_t *page)\n\n{\n\n VECTYPE *p = (VECTYPE *)page;\n\n VECTYPE val = SPLAT(page);\n\n int i;\n\n\n\n for (i = 0; i < TARGET_PAGE_SIZE / sizeof(VECTYPE); i++) {\n\n if (!ALL_EQ(val, p[i])) {\n\n return 0;\n\n }\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "0", + "index": 12842 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void parse_option_number(const char *name, const char *value,\n\n uint64_t *ret, Error **errp)\n\n{\n\n char *postfix;\n\n uint64_t number;\n\n\n\n number = strtoull(value, &postfix, 0);\n\n if (*postfix != '\\0') {\n\n error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, \"a number\");\n\n return;\n\n }\n\n *ret = number;\n\n}\n", + "output": "1", + "index": 1793 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void mix_stereo_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];\n\n memset(output[2], 0, sizeof(output[2]));\n\n}\n", + "output": "0", + "index": 13195 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned tget(const uint8_t **p, int type, int le)\n\n{\n\n switch (type) {\n\n case TIFF_BYTE : return *(*p)++;\n\n case TIFF_SHORT: return tget_short(p, le);\n\n case TIFF_LONG : return tget_long(p, le);\n\n default : return UINT_MAX;\n\n }\n\n}\n", + "output": "0", + "index": 23060 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cpu_exec_nocache(CPUState *cpu, int max_cycles,\n\n TranslationBlock *orig_tb)\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 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->tc_ptr);\n\n cpu->current_tb = NULL;\n\n tb_phys_invalidate(tb, -1);\n\n tb_free(tb);\n\n}\n", + "output": "0", + "index": 10185 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_pcnet_init(PCIDevice *pci_dev)\n\n{\n\n PCIPCNetState *d = PCI_PCNET(pci_dev);\n\n PCNetState *s = &d->state;\n\n uint8_t *pci_conf;\n\n\n\n#if 0\n\n printf(\"sizeof(RMD)=%d, sizeof(TMD)=%d\\n\",\n\n sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));\n\n#endif\n\n\n\n pci_conf = pci_dev->config;\n\n\n\n pci_set_word(pci_conf + PCI_STATUS,\n\n PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM);\n\n\n\n pci_set_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID, 0x0);\n\n pci_set_word(pci_conf + PCI_SUBSYSTEM_ID, 0x0);\n\n\n\n pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */\n\n pci_conf[PCI_MIN_GNT] = 0x06;\n\n pci_conf[PCI_MAX_LAT] = 0xff;\n\n\n\n /* Handler for memory-mapped I/O */\n\n memory_region_init_io(&d->state.mmio, OBJECT(d), &pcnet_mmio_ops, s,\n\n \"pcnet-mmio\", PCNET_PNPMMIO_SIZE);\n\n\n\n memory_region_init_io(&d->io_bar, OBJECT(d), &pcnet_io_ops, s, \"pcnet-io\",\n\n PCNET_IOPORT_SIZE);\n\n pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &d->io_bar);\n\n\n\n pci_register_bar(pci_dev, 1, 0, &s->mmio);\n\n\n\n s->irq = pci_allocate_irq(pci_dev);\n\n s->phys_mem_read = pci_physical_memory_read;\n\n s->phys_mem_write = pci_physical_memory_write;\n\n s->dma_opaque = pci_dev;\n\n\n\n return pcnet_common_init(DEVICE(pci_dev), s, &net_pci_pcnet_info);\n\n}\n", + "output": "1", + "index": 2112 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t pci_default_read_config(PCIDevice *d,\n\n uint32_t address, int len)\n\n{\n\n uint32_t val = 0;\n\n assert(len == 1 || len == 2 || len == 4);\n\n len = MIN(len, pci_config_size(d) - address);\n\n memcpy(&val, d->config + address, len);\n\n return le32_to_cpu(val);\n\n}\n", + "output": "1", + "index": 23874 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockAIOCB *blkverify_aio_readv(BlockDriverState *bs,\n\n int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\n\n BlockCompletionFunc *cb, void *opaque)\n\n{\n\n BDRVBlkverifyState *s = bs->opaque;\n\n BlkverifyAIOCB *acb = blkverify_aio_get(bs, false, sector_num, qiov,\n\n nb_sectors, cb, opaque);\n\n\n\n acb->verify = blkverify_verify_readv;\n\n acb->buf = qemu_blockalign(bs->file->bs, qiov->size);\n\n qemu_iovec_init(&acb->raw_qiov, acb->qiov->niov);\n\n qemu_iovec_clone(&acb->raw_qiov, qiov, acb->buf);\n\n\n\n bdrv_aio_readv(s->test_file, sector_num, qiov, nb_sectors,\n\n blkverify_aio_cb, acb);\n\n bdrv_aio_readv(bs->file, sector_num, &acb->raw_qiov, nb_sectors,\n\n blkverify_aio_cb, acb);\n\n return &acb->common;\n\n}\n", + "output": "1", + "index": 2318 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id)\n\n{\n\n VirtIORNG *vrng = opaque;\n\n VirtIODevice *vdev = VIRTIO_DEVICE(vrng);\n\n\n\n if (version_id != 1) {\n\n return -EINVAL;\n\n }\n\n virtio_load(vdev, f, version_id);\n\n\n\n /* We may have an element ready but couldn't process it due to a quota\n\n * limit. Make sure to try again after live migration when the quota may\n\n * have been reset.\n\n */\n\n virtio_rng_process(vrng);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 7382 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pci_register_vga(PCIDevice *pci_dev, MemoryRegion *mem,\n\n MemoryRegion *io_lo, MemoryRegion *io_hi)\n\n{\n\n assert(!pci_dev->has_vga);\n\n\n\n assert(memory_region_size(mem) == QEMU_PCI_VGA_MEM_SIZE);\n\n pci_dev->vga_regions[QEMU_PCI_VGA_MEM] = mem;\n\n memory_region_add_subregion_overlap(pci_dev->bus->address_space_mem,\n\n QEMU_PCI_VGA_MEM_BASE, mem, 1);\n\n\n\n assert(memory_region_size(io_lo) == QEMU_PCI_VGA_IO_LO_SIZE);\n\n pci_dev->vga_regions[QEMU_PCI_VGA_IO_LO] = io_lo;\n\n memory_region_add_subregion_overlap(pci_dev->bus->address_space_io,\n\n QEMU_PCI_VGA_IO_LO_BASE, io_lo, 1);\n\n\n\n assert(memory_region_size(io_hi) == QEMU_PCI_VGA_IO_HI_SIZE);\n\n pci_dev->vga_regions[QEMU_PCI_VGA_IO_HI] = io_hi;\n\n memory_region_add_subregion_overlap(pci_dev->bus->address_space_io,\n\n QEMU_PCI_VGA_IO_HI_BASE, io_hi, 1);\n\n pci_dev->has_vga = true;\n\n\n\n pci_update_vga(pci_dev);\n\n}\n", + "output": "0", + "index": 17306 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,\n\n int flags, CPUWatchpoint **watchpoint)\n\n{\n\n target_ulong len_mask = ~(len - 1);\n\n CPUWatchpoint *wp;\n\n\n\n /* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */\n\n if ((len != 1 && len != 2 && len != 4 && len != 8) || (addr & ~len_mask)) {\n\n fprintf(stderr, \"qemu: tried to set invalid watchpoint at \"\n\n TARGET_FMT_lx \", len=\" TARGET_FMT_lu \"\\n\", addr, len);\n\n return -EINVAL;\n\n }\n\n wp = qemu_malloc(sizeof(*wp));\n\n\n\n wp->vaddr = addr;\n\n wp->len_mask = len_mask;\n\n wp->flags = flags;\n\n\n\n /* keep all GDB-injected watchpoints in front */\n\n if (flags & BP_GDB)\n\n TAILQ_INSERT_HEAD(&env->watchpoints, wp, entry);\n\n else\n\n TAILQ_INSERT_TAIL(&env->watchpoints, wp, entry);\n\n\n\n tlb_flush_page(env, addr);\n\n\n\n if (watchpoint)\n\n *watchpoint = wp;\n\n return 0;\n\n}\n", + "output": "0", + "index": 219 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void win_chr_readfile(CharDriverState *chr)\n\n{\n\n WinCharState *s = chr->opaque;\n\n int ret, err;\n\n uint8_t buf[1024];\n\n DWORD size;\n\n\n\n ZeroMemory(&s->orecv, sizeof(s->orecv));\n\n s->orecv.hEvent = s->hrecv;\n\n ret = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);\n\n if (!ret) {\n\n err = GetLastError();\n\n if (err == ERROR_IO_PENDING) {\n\n ret = GetOverlappedResult(s->hcom, &s->orecv, &size, TRUE);\n\n }\n\n }\n\n\n\n if (size > 0) {\n\n qemu_chr_read(chr, buf, size);\n\n }\n\n}\n", + "output": "0", + "index": 1911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)\n\n{\n\n int v;\n\n int i = 0;\n\n uint8_t state[CONTEXT_SIZE];\n\n\n\n memset(state, 128, sizeof(state));\n\n\n\n for (v = 0; i < 128; v++) {\n\n unsigned len = get_symbol(c, state, 0) + 1;\n\n\n\n if (len > 128 - i)\n\n return AVERROR_INVALIDDATA;\n\n\n\n while (len--) {\n\n quant_table[i] = scale * v;\n\n i++;\n\n }\n\n }\n\n\n\n for (i = 1; i < 128; i++)\n\n quant_table[256 - i] = -quant_table[i];\n\n quant_table[128] = -quant_table[127];\n\n\n\n return 2 * v - 1;\n\n}\n", + "output": "0", + "index": 17723 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_inject_x86_mce_on(CPUState *env, struct kvm_x86_mce *mce,\n\n int flag)\n\n{\n\n struct kvm_x86_mce_data data = {\n\n .env = env,\n\n .mce = mce,\n\n .abort_on_error = (flag & ABORT_ON_ERROR),\n\n };\n\n\n\n if (!env->mcg_cap) {\n\n fprintf(stderr, \"MCE support is not enabled!\\n\");\n\n return;\n\n }\n\n\n\n run_on_cpu(env, kvm_do_inject_x86_mce, &data);\n\n}\n", + "output": "0", + "index": 22417 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,\n\n const AVFrame *frame, int *got_packet_ptr)\n\n{\n\n AlacEncodeContext *s = avctx->priv_data;\n\n int out_bytes, max_frame_size, ret;\n\n\n\n s->frame_size = frame->nb_samples;\n\n\n\n if (frame->nb_samples < DEFAULT_FRAME_SIZE)\n\n max_frame_size = get_max_frame_size(s->frame_size, avctx->channels,\n\n avctx->bits_per_raw_sample);\n\n else\n\n max_frame_size = s->max_coded_frame_size;\n\n\n\n if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size)))\n\n return ret;\n\n\n\n /* use verbatim mode for compression_level 0 */\n\n if (s->compression_level) {\n\n s->verbatim = 0;\n\n s->extra_bits = avctx->bits_per_raw_sample - 16;\n\n } else {\n\n s->verbatim = 1;\n\n s->extra_bits = 0;\n\n }\n\n\n\n out_bytes = write_frame(s, avpkt, frame->extended_data);\n\n\n\n if (out_bytes > max_frame_size) {\n\n /* frame too large. use verbatim mode */\n\n s->verbatim = 1;\n\n s->extra_bits = 0;\n\n out_bytes = write_frame(s, avpkt, frame->extended_data);\n\n }\n\n\n\n avpkt->size = out_bytes;\n\n *got_packet_ptr = 1;\n\n return 0;\n\n}\n", + "output": "0", + "index": 10566 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t ntohll(uint64_t v) {\n\n union { uint32_t lv[2]; uint64_t llv; } u;\n\n u.llv = v;\n\n return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]);\n\n}\n", + "output": "1", + "index": 16974 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_5(SANMVideoContext *ctx)\n\n{\n\n#if HAVE_BIGENDIAN\n\n uint16_t *frm;\n\n int npixels;\n\n#endif\n\n uint8_t *dst = (uint8_t*)ctx->frm0;\n\n\n\n if (rle_decode(ctx, dst, ctx->buf_size))\n\n return AVERROR_INVALIDDATA;\n\n\n\n#if HAVE_BIGENDIAN\n\n npixels = ctx->npixels;\n\n frm = ctx->frm0;\n\n while (npixels--)\n\n *frm++ = av_bswap16(*frm);\n\n#endif\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 26294 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static size_t write_to_port(VirtIOSerialPort *port,\n\n const uint8_t *buf, size_t size)\n\n{\n\n VirtQueueElement elem;\n\n VirtQueue *vq;\n\n size_t offset = 0;\n\n size_t len = 0;\n\n\n\n vq = port->ivq;\n\n if (!virtio_queue_ready(vq)) {\n\n return 0;\n\n }\n\n if (!size) {\n\n return 0;\n\n }\n\n\n\n while (offset < size) {\n\n int i;\n\n\n\n if (!virtqueue_pop(vq, &elem)) {\n\n break;\n\n }\n\n\n\n for (i = 0; offset < size && i < elem.in_num; i++) {\n\n len = MIN(elem.in_sg[i].iov_len, size - offset);\n\n\n\n memcpy(elem.in_sg[i].iov_base, buf + offset, len);\n\n offset += len;\n\n }\n\n virtqueue_push(vq, &elem, len);\n\n }\n\n\n\n virtio_notify(&port->vser->vdev, vq);\n\n return offset;\n\n}\n", + "output": "0", + "index": 8256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_spr_power8_fscr(CPUPPCState *env)\n\n{\n\n spr_register_kvm(env, SPR_FSCR, \"FSCR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n KVM_REG_PPC_FSCR, 0x00000000);\n\n}\n", + "output": "1", + "index": 1329 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int decode_ac_coeffs(GetBitContext *gb, int16_t *out,\n\n int blocks_per_slice,\n\n int plane_size_factor,\n\n const uint8_t *scan)\n\n{\n\n int pos, block_mask, run, level, sign, run_cb_index, lev_cb_index;\n\n int max_coeffs, bits_left;\n\n\n\n /* set initial prediction values */\n\n run = 4;\n\n level = 2;\n\n\n\n max_coeffs = blocks_per_slice << 6;\n\n block_mask = blocks_per_slice - 1;\n\n\n\n for (pos = blocks_per_slice - 1; pos < max_coeffs;) {\n\n run_cb_index = ff_prores_run_to_cb_index[FFMIN(run, 15)];\n\n lev_cb_index = ff_prores_lev_to_cb_index[FFMIN(level, 9)];\n\n\n\n bits_left = get_bits_left(gb);\n\n if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))\n\n return 0;\n\n\n\n run = decode_vlc_codeword(gb, ff_prores_ac_codebook[run_cb_index]);\n\n if (run < 0)\n\n return AVERROR_INVALIDDATA;\n\n\n\n bits_left = get_bits_left(gb);\n\n if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))\n\n return AVERROR_INVALIDDATA;\n\n\n\n level = decode_vlc_codeword(gb, ff_prores_ac_codebook[lev_cb_index]) + 1;\n\n if (level < 0)\n\n return AVERROR_INVALIDDATA;\n\n\n\n pos += run + 1;\n\n if (pos >= max_coeffs)\n\n break;\n\n\n\n sign = get_sbits(gb, 1);\n\n out[((pos & block_mask) << 6) + scan[pos >> plane_size_factor]] =\n\n (level ^ sign) - sign;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 23184 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd,\n\n bool force)\n\n{\n\n\n return NULL;\n\n}", + "output": "1", + "index": 143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg)\n\n{\n\n IComplex in[FN], in1[FN];\n\n int k, n, i;\n\n float sum_re, sum_im, a;\n\n\n\n for (i = 0; i < FN; i++) {\n\n in[i].re = av_lfg_get(lfg) % 65535 - 32767;\n\n in[i].im = av_lfg_get(lfg) % 65535 - 32767;\n\n in1[i] = in[i];\n\n }\n\n fft(mdct, in, 7);\n\n\n\n /* do it by hand */\n\n for (k = 0; k < FN; k++) {\n\n sum_re = 0;\n\n sum_im = 0;\n\n for (n = 0; n < FN; n++) {\n\n a = -2 * M_PI * (n * k) / FN;\n\n sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);\n\n sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);\n\n }\n\n av_log(NULL, AV_LOG_DEBUG, \"%3d: %6d,%6d %6.0f,%6.0f\\n\",\n\n k, in[k].re, in[k].im, sum_re / FN, sum_im / FN);\n\n }\n\n}\n", + "output": "0", + "index": 20775 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_thread_self(QemuThread *thread)\n\n{\n\n thread->thread = pthread_self();\n\n}\n", + "output": "0", + "index": 9646 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int opt_sameq(void *optctx, const char *opt, const char *arg)\n\n{\n\n av_log(NULL, AV_LOG_WARNING, \"Ignoring option '%s'\\n\", opt);\n\n return 0;\n\n}\n", + "output": "1", + "index": 1681 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_wsr_debugcause(DisasContext *dc, uint32_t sr, TCGv_i32 v)\n\n{\n\n}\n", + "output": "1", + "index": 4882 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "__org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,\n\n __org_qemu_x_StructList *b,\n\n __org_qemu_x_Union2 *c,\n\n __org_qemu_x_Alt *d,\n\n Error **errp)\n\n{\n\n __org_qemu_x_Union1 *ret = g_new0(__org_qemu_x_Union1, 1);\n\n\n\n ret->kind = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH;\n\n ret->__org_qemu_x_branch = strdup(\"blah1\");\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 23606 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void hmp_info_memdev(Monitor *mon, const QDict *qdict)\n\n{\n\n Error *err = NULL;\n\n MemdevList *memdev_list = qmp_query_memdev(&err);\n\n MemdevList *m = memdev_list;\n\n StringOutputVisitor *ov;\n\n char *str;\n\n int i = 0;\n\n\n\n\n\n while (m) {\n\n ov = string_output_visitor_new(false);\n\n visit_type_uint16List(string_output_get_visitor(ov), NULL,\n\n &m->value->host_nodes, NULL);\n\n monitor_printf(mon, \"memory backend: %d\\n\", i);\n\n monitor_printf(mon, \" size: %\" PRId64 \"\\n\", m->value->size);\n\n monitor_printf(mon, \" merge: %s\\n\",\n\n m->value->merge ? \"true\" : \"false\");\n\n monitor_printf(mon, \" dump: %s\\n\",\n\n m->value->dump ? \"true\" : \"false\");\n\n monitor_printf(mon, \" prealloc: %s\\n\",\n\n m->value->prealloc ? \"true\" : \"false\");\n\n monitor_printf(mon, \" policy: %s\\n\",\n\n HostMemPolicy_lookup[m->value->policy]);\n\n str = string_output_get_string(ov);\n\n monitor_printf(mon, \" host nodes: %s\\n\", str);\n\n\n\n g_free(str);\n\n string_output_visitor_cleanup(ov);\n\n m = m->next;\n\n i++;\n\n }\n\n\n\n monitor_printf(mon, \"\\n\");\n\n\n\n qapi_free_MemdevList(memdev_list);\n\n}\n", + "output": "0", + "index": 7234 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool blit_is_unsafe(struct CirrusVGAState *s)\n{\n /* should be the case, see cirrus_bitblt_start */\n assert(s->cirrus_blt_width > 0);\n assert(s->cirrus_blt_height > 0);\n if (blit_region_is_unsafe(s, s->cirrus_blt_dstpitch,\n s->cirrus_blt_dstaddr & s->cirrus_addr_mask)) {\n if (blit_region_is_unsafe(s, s->cirrus_blt_srcpitch,\n s->cirrus_blt_srcaddr & s->cirrus_addr_mask)) {\n return false;", + "output": "1", + "index": 7637 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool vtd_decide_config(IntelIOMMUState *s, Error **errp)\n\n{\n\n X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);\n\n\n\n /* Currently Intel IOMMU IR only support \"kernel-irqchip={off|split}\" */\n\n if (x86_iommu->intr_supported && kvm_irqchip_in_kernel() &&\n\n !kvm_irqchip_is_split()) {\n\n error_setg(errp, \"Intel Interrupt Remapping cannot work with \"\n\n \"kernel-irqchip=on, please use 'split|off'.\");\n\n return false;\n\n }\n\n if (s->intr_eim == ON_OFF_AUTO_ON && !x86_iommu->intr_supported) {\n\n error_setg(errp, \"eim=on cannot be selected without intremap=on\");\n\n return false;\n\n }\n\n\n\n if (s->intr_eim == ON_OFF_AUTO_AUTO) {\n\n s->intr_eim = x86_iommu->intr_supported ?\n\n ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;\n\n }\n\n\n\n return true;\n\n}\n", + "output": "1", + "index": 17362 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pdu_free(V9fsPDU *pdu)\n\n{\n\n if (pdu) {\n\n V9fsState *s = pdu->s;\n\n /*\n\n * Cancelled pdu are added back to the freelist\n\n * by flush request .\n\n */\n\n if (!pdu->cancelled) {\n\n QLIST_REMOVE(pdu, next);\n\n QLIST_INSERT_HEAD(&s->free_list, pdu, next);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 14923 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "connect_to_qemu(\n\n const char *host,\n\n const char *port\n\n) {\n\n struct addrinfo hints;\n\n struct addrinfo *server;\n\n int ret, sock;\n\n\n\n sock = qemu_socket(AF_INET, SOCK_STREAM, 0);\n\n if (sock < 0) {\n\n /* Error */\n\n fprintf(stderr, \"Error opening socket!\\n\");\n\n return -1;\n\n }\n\n\n\n memset(&hints, 0, sizeof(struct addrinfo));\n\n hints.ai_family = AF_UNSPEC;\n\n hints.ai_socktype = SOCK_STREAM;\n\n hints.ai_flags = 0;\n\n hints.ai_protocol = 0; /* Any protocol */\n\n\n\n ret = getaddrinfo(host, port, &hints, &server);\n\n\n\n if (ret != 0) {\n\n /* Error */\n\n fprintf(stderr, \"getaddrinfo failed\\n\");\n\n goto cleanup_socket;\n\n }\n\n\n\n if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {\n\n /* Error */\n\n fprintf(stderr, \"Could not connect\\n\");\n\n goto cleanup_socket;\n\n }\n\n if (verbose) {\n\n printf(\"Connected (sizeof Header=%zd)!\\n\", sizeof(VSCMsgHeader));\n\n }\n\n return sock;\n\n\n\ncleanup_socket:\n\n closesocket(sock);\n\n return -1;\n\n}\n", + "output": "0", + "index": 12883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *object_property_get_str(Object *obj, const char *name,\n\n Error **errp)\n\n{\n\n QObject *ret = object_property_get_qobject(obj, name, errp);\n\n QString *qstring;\n\n char *retval;\n\n\n\n if (!ret) {\n\n return NULL;\n\n }\n\n qstring = qobject_to_qstring(ret);\n\n if (!qstring) {\n\n error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, \"string\");\n\n retval = NULL;\n\n } else {\n\n retval = g_strdup(qstring_get_str(qstring));\n\n }\n\n\n\n QDECREF(qstring);\n\n return retval;\n\n}\n", + "output": "1", + "index": 23319 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static Visitor *validate_test_init_internal(TestInputVisitorData *data,\n\n const char *json_string,\n\n va_list *ap)\n\n{\n\n validate_teardown(data, NULL);\n\n\n\n data->obj = qobject_from_jsonv(json_string, ap);\n\n g_assert(data->obj);\n\n\n\n data->qiv = qmp_input_visitor_new(data->obj, true);\n\n g_assert(data->qiv);\n\n return data->qiv;\n\n}\n", + "output": "0", + "index": 15707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int authenticate(BDRVSSHState *s, const char *user)\n\n{\n\n int r, ret;\n\n const char *userauthlist;\n\n LIBSSH2_AGENT *agent = NULL;\n\n struct libssh2_agent_publickey *identity;\n\n struct libssh2_agent_publickey *prev_identity = NULL;\n\n\n\n userauthlist = libssh2_userauth_list(s->session, user, strlen(user));\n\n if (strstr(userauthlist, \"publickey\") == NULL) {\n\n ret = -EPERM;\n\n error_report(\"remote server does not support \\\"publickey\\\" authentication\");\n\n goto out;\n\n }\n\n\n\n /* Connect to ssh-agent and try each identity in turn. */\n\n agent = libssh2_agent_init(s->session);\n\n if (!agent) {\n\n ret = -EINVAL;\n\n session_error_report(s, \"failed to initialize ssh-agent support\");\n\n goto out;\n\n }\n\n if (libssh2_agent_connect(agent)) {\n\n ret = -ECONNREFUSED;\n\n session_error_report(s, \"failed to connect to ssh-agent\");\n\n goto out;\n\n }\n\n if (libssh2_agent_list_identities(agent)) {\n\n ret = -EINVAL;\n\n session_error_report(s, \"failed requesting identities from ssh-agent\");\n\n goto out;\n\n }\n\n\n\n for(;;) {\n\n r = libssh2_agent_get_identity(agent, &identity, prev_identity);\n\n if (r == 1) { /* end of list */\n\n break;\n\n }\n\n if (r < 0) {\n\n ret = -EINVAL;\n\n session_error_report(s, \"failed to obtain identity from ssh-agent\");\n\n goto out;\n\n }\n\n r = libssh2_agent_userauth(agent, user, identity);\n\n if (r == 0) {\n\n /* Authenticated! */\n\n ret = 0;\n\n goto out;\n\n }\n\n /* Failed to authenticate with this identity, try the next one. */\n\n prev_identity = identity;\n\n }\n\n\n\n ret = -EPERM;\n\n error_report(\"failed to authenticate using publickey authentication \"\n\n \"and the identities held by your ssh-agent\");\n\n\n\n out:\n\n if (agent != NULL) {\n\n /* Note: libssh2 implementation implicitly calls\n\n * libssh2_agent_disconnect if necessary.\n\n */\n\n libssh2_agent_free(agent);\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 17637 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t cc_calc_abs_64(int64_t dst)\n\n{\n\n if ((uint64_t)dst == 0x8000000000000000ULL) {\n\n return 3;\n\n } else if (dst) {\n\n return 1;\n\n } else {\n\n return 0;\n\n }\n\n}\n", + "output": "1", + "index": 577 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void disas_fp_ccomp(DisasContext *s, uint32_t insn)\n\n{\n\n unsigned int mos, type, rm, cond, rn, op, nzcv;\n\n TCGv_i64 tcg_flags;\n\n int label_continue = -1;\n\n\n\n mos = extract32(insn, 29, 3);\n\n type = extract32(insn, 22, 2); /* 0 = single, 1 = double */\n\n rm = extract32(insn, 16, 5);\n\n cond = extract32(insn, 12, 4);\n\n rn = extract32(insn, 5, 5);\n\n op = extract32(insn, 4, 1);\n\n nzcv = extract32(insn, 0, 4);\n\n\n\n if (mos || type > 1) {\n\n unallocated_encoding(s);\n\n return;\n\n }\n\n\n\n if (!fp_access_check(s)) {\n\n return;\n\n }\n\n\n\n if (cond < 0x0e) { /* not always */\n\n int label_match = gen_new_label();\n\n label_continue = gen_new_label();\n\n arm_gen_test_cc(cond, label_match);\n\n /* nomatch: */\n\n tcg_flags = tcg_const_i64(nzcv << 28);\n\n gen_set_nzcv(tcg_flags);\n\n tcg_temp_free_i64(tcg_flags);\n\n tcg_gen_br(label_continue);\n\n gen_set_label(label_match);\n\n }\n\n\n\n handle_fp_compare(s, type, rn, rm, false, op);\n\n\n\n if (cond < 0x0e) {\n\n gen_set_label(label_continue);\n\n }\n\n}\n", + "output": "0", + "index": 27083 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_drain_recurse(BlockDriverState *bs)\n\n{\n\n BdrvChild *child;\n\n bool waited;\n\n\n\n waited = BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0);\n\n\n\n if (bs->drv && bs->drv->bdrv_drain) {\n\n bs->drv->bdrv_drain(bs);\n\n }\n\n\n\n QLIST_FOREACH(child, &bs->children, next) {\n\n waited |= bdrv_drain_recurse(child->bs);\n\n }\n\n\n\n return waited;\n\n}\n", + "output": "1", + "index": 4238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_2(SANMVideoContext *ctx)\n\n{\n\n int cx, cy, ret;\n\n\n\n for (cy = 0; cy != ctx->aligned_height; cy += 8) {\n\n for (cx = 0; cx != ctx->aligned_width; cx += 8) {\n\n if (ret = codec2subblock(ctx, cx, cy, 8))\n\n return ret;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8275 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "restore_fpu_state(CPUSPARCState *env, qemu_siginfo_fpu_t *fpu)\n\n{\n\n int err;\n\n#if 0\n\n#ifdef CONFIG_SMP\n\n if (current->flags & PF_USEDFPU)\n\n regs->psr &= ~PSR_EF;\n\n#else\n\n if (current == last_task_used_math) {\n\n last_task_used_math = 0;\n\n regs->psr &= ~PSR_EF;\n\n }\n\n#endif\n\n current->used_math = 1;\n\n current->flags &= ~PF_USEDFPU;\n\n#endif\n\n#if 0\n\n if (verify_area (VERIFY_READ, fpu, sizeof(*fpu)))\n\n return -EFAULT;\n\n#endif\n\n\n\n#if 0\n\n /* XXX: incorrect */\n\n err = __copy_from_user(&env->fpr[0], &fpu->si_float_regs[0],\n\n\t (sizeof(unsigned long) * 32));\n\n#endif\n\n err |= __get_user(env->fsr, &fpu->si_fsr);\n\n#if 0\n\n err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);\n\n if (current->thread.fpqdepth != 0)\n\n err |= __copy_from_user(¤t->thread.fpqueue[0],\n\n &fpu->si_fpqueue[0],\n\n ((sizeof(unsigned long) +\n\n (sizeof(unsigned long *)))*16));\n\n#endif\n\n return err;\n\n}\n", + "output": "1", + "index": 22935 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int dec_movs_r(DisasContext *dc)\n\n{\n\n\tTCGv t0;\n\n\tint size = memsize_z(dc);\n\n\tDIS(fprintf (logfile, \"movs.%c $r%u, $r%u\\n\",\n\n\t\t memsize_char(size),\n\n\t\t dc->op1, dc->op2));\n\n\n\n\tcris_cc_mask(dc, CC_MASK_NZ);\n\n\tt0 = tcg_temp_new(TCG_TYPE_TL);\n\n\t/* Size can only be qi or hi. */\n\n\tt_gen_sext(t0, cpu_R[dc->op1], size);\n\n\tcris_alu(dc, CC_OP_MOVE,\n\n\t\t cpu_R[dc->op2], cpu_R[dc->op1], t0, 4);\n\n\ttcg_temp_free(t0);\n\n\treturn 2;\n\n}\n", + "output": "0", + "index": 21358 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_gluster_open(BlockDriverState *bs, QDict *options,\n\n int bdrv_flags, Error **errp)\n\n{\n\n BDRVGlusterState *s = bs->opaque;\n\n int open_flags = O_BINARY;\n\n int ret = 0;\n\n GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));\n\n QemuOpts *opts;\n\n Error *local_err = NULL;\n\n const char *filename;\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 out;\n\n }\n\n\n\n filename = qemu_opt_get(opts, \"filename\");\n\n\n\n s->glfs = qemu_gluster_init(gconf, filename, errp);\n\n if (!s->glfs) {\n\n ret = -errno;\n\n goto out;\n\n }\n\n\n\n if (bdrv_flags & BDRV_O_RDWR) {\n\n open_flags |= O_RDWR;\n\n } else {\n\n open_flags |= O_RDONLY;\n\n }\n\n\n\n if ((bdrv_flags & BDRV_O_NOCACHE)) {\n\n open_flags |= O_DIRECT;\n\n }\n\n\n\n s->fd = glfs_open(s->glfs, gconf->image, open_flags);\n\n if (!s->fd) {\n\n ret = -errno;\n\n }\n\n\n\nout:\n\n qemu_opts_del(opts);\n\n qemu_gluster_gconf_free(gconf);\n\n if (!ret) {\n\n return ret;\n\n }\n\n if (s->fd) {\n\n glfs_close(s->fd);\n\n }\n\n if (s->glfs) {\n\n glfs_fini(s->glfs);\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 5687 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_socket(const char *path, uid_t uid, gid_t gid)\n\n{\n\n int sock, client;\n\n struct sockaddr_un proxy, qemu;\n\n socklen_t size;\n\n\n\n /* requested socket already exists, refuse to start */\n\n if (!access(path, F_OK)) {\n\n do_log(LOG_CRIT, \"socket already exists\\n\");\n\n return -1;\n\n }\n\n\n\n\n sock = socket(AF_UNIX, SOCK_STREAM, 0);\n\n if (sock < 0) {\n\n do_perror(\"socket\");\n\n return -1;\n\n }\n\n\n\n /* mask other part of mode bits */\n\n umask(7);\n\n\n\n proxy.sun_family = AF_UNIX;\n\n strcpy(proxy.sun_path, path);\n\n if (bind(sock, (struct sockaddr *)&proxy,\n\n sizeof(struct sockaddr_un)) < 0) {\n\n do_perror(\"bind\");\n\n goto error;\n\n }\n\n if (chown(proxy.sun_path, uid, gid) < 0) {\n\n do_perror(\"chown\");\n\n goto error;\n\n }\n\n if (listen(sock, 1) < 0) {\n\n do_perror(\"listen\");\n\n goto error;\n\n }\n\n\n\n size = sizeof(qemu);\n\n client = accept(sock, (struct sockaddr *)&qemu, &size);\n\n if (client < 0) {\n\n do_perror(\"accept\");\n\n goto error;\n\n }\n\n close(sock);\n\n return client;\n\n\n\nerror:\n\n close(sock);\n\n return -1;\n\n}", + "output": "1", + "index": 2377 + }, + { + "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));\n\n visit_type_UserDefTwo(qmp_input_get_visitor(qiv), &ud2, NULL, &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 assert(err != NULL);\n\n error_free(err);\n\n\n\n /* tear down partial object */\n\n qapi_free_UserDefTwo(ud2);\n\n}\n", + "output": "1", + "index": 17826 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_ir(AVFilterLink *inlink, AVFrame *frame)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n HeadphoneContext *s = ctx->priv;\n\n int ir_len, max_ir_len, input_number;\n\n\n\n for (input_number = 0; input_number < s->nb_inputs; input_number++)\n\n if (inlink == ctx->inputs[input_number])\n\n break;\n\n\n\n av_audio_fifo_write(s->in[input_number].fifo, (void **)frame->extended_data,\n\n frame->nb_samples);\n\n av_frame_free(&frame);\n\n\n\n ir_len = av_audio_fifo_size(s->in[input_number].fifo);\n\n max_ir_len = 65536;\n\n if (ir_len > max_ir_len) {\n\n av_log(ctx, AV_LOG_ERROR, \"Too big length of IRs: %d > %d.\\n\", ir_len, max_ir_len);\n\n return AVERROR(EINVAL);\n\n }\n\n s->in[input_number].ir_len = ir_len;\n\n s->ir_len = FFMAX(ir_len, s->ir_len);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4195 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int spapr_tce_table_realize(DeviceState *dev)\n\n{\n\n sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev);\n\n\n\n if (kvm_enabled()) {\n\n tcet->table = kvmppc_create_spapr_tce(tcet->liobn,\n\n tcet->window_size,\n\n &tcet->fd);\n\n }\n\n\n\n if (!tcet->table) {\n\n size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT)\n\n * sizeof(uint64_t);\n\n tcet->table = g_malloc0(table_size);\n\n }\n\n tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT;\n\n\n\n trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd);\n\n\n\n memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops,\n\n \"iommu-spapr\", UINT64_MAX);\n\n\n\n QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);\n\n\n\n vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table,\n\n tcet);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8849 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aac_decode_frame(AVCodecContext *avctx, void *data,\n\n int *got_frame_ptr, AVPacket *avpkt)\n\n{\n\n AACContext *ac = avctx->priv_data;\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n GetBitContext gb;\n\n int buf_consumed;\n\n int buf_offset;\n\n int err;\n\n int new_extradata_size;\n\n const uint8_t *new_extradata = av_packet_get_side_data(avpkt,\n\n AV_PKT_DATA_NEW_EXTRADATA,\n\n &new_extradata_size);\n\n\n\n if (new_extradata) {\n\n av_free(avctx->extradata);\n\n avctx->extradata = av_mallocz(new_extradata_size +\n\n FF_INPUT_BUFFER_PADDING_SIZE);\n\n if (!avctx->extradata)\n\n return AVERROR(ENOMEM);\n\n avctx->extradata_size = new_extradata_size;\n\n memcpy(avctx->extradata, new_extradata, new_extradata_size);\n\n push_output_configuration(ac);\n\n if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,\n\n avctx->extradata,\n\n avctx->extradata_size*8, 1) < 0) {\n\n pop_output_configuration(ac);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n }\n\n\n\n init_get_bits(&gb, buf, buf_size * 8);\n\n\n\n if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb)) < 0)\n\n return err;\n\n\n\n buf_consumed = (get_bits_count(&gb) + 7) >> 3;\n\n for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)\n\n if (buf[buf_offset])\n\n break;\n\n\n\n return buf_size > buf_offset ? buf_consumed : buf_size;\n\n}\n", + "output": "0", + "index": 9247 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void RENAME(vertical_compose53iL0)(uint8_t *_b0, uint8_t *_b1, uint8_t *_b2,\n\n int width)\n\n{\n\n int i;\n\n TYPE *b0 = (TYPE *)_b0;\n\n TYPE *b1 = (TYPE *)_b1;\n\n TYPE *b2 = (TYPE *)_b2;\n\n for (i = 0; i < width; i++)\n\n b1[i] -= (b0[i] + b2[i] + 2) >> 2;\n\n}\n", + "output": "1", + "index": 368 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qapi_dealloc_visitor_cleanup(QapiDeallocVisitor *v)\n\n{\n\n g_free(v);\n\n}\n", + "output": "0", + "index": 11691 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int verify_expr(AVExpr *e)\n\n{\n\n if (!e) return 0;\n\n switch (e->type) {\n\n case e_value:\n\n case e_const: return 1;\n\n case e_func0:\n\n case e_func1:\n\n case e_squish:\n\n case e_ld:\n\n case e_gauss:\n\n case e_isnan:\n\n case e_floor:\n\n case e_ceil:\n\n case e_trunc:\n\n case e_sqrt:\n\n case e_not:\n\n case e_random:\n\n return verify_expr(e->param[0]) && !e->param[2];\n\n case e_taylor:\n\n return verify_expr(e->param[0]) && verify_expr(e->param[1])\n\n && (!e->param[2] || verify_expr(e->param[2]));\n\n default: return verify_expr(e->param[0]) && verify_expr(e->param[1]) && !e->param[2];\n\n }\n\n}\n", + "output": "0", + "index": 15007 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static SocketAddress *unix_build_address(const char *path)\n\n{\n\n SocketAddress *saddr;\n\n\n\n saddr = g_new0(SocketAddress, 1);\n\n saddr->type = SOCKET_ADDRESS_KIND_UNIX;\n\n saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);\n\n saddr->u.q_unix.data->path = g_strdup(path);\n\n\n\n return saddr;\n\n}\n", + "output": "0", + "index": 19528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpeg1_decode_picture(AVCodecContext *avctx, \n\n const uint8_t *buf, int buf_size)\n\n{\n\n Mpeg1Context *s1 = avctx->priv_data;\n\n MpegEncContext *s = &s1->mpeg_enc_ctx;\n\n int ref, f_code, vbv_delay;\n\n\n\n if(mpeg_decode_postinit(s->avctx) < 0) \n\n return -2;\n\n\n\n init_get_bits(&s->gb, buf, buf_size*8);\n\n\n\n ref = get_bits(&s->gb, 10); /* temporal ref */\n\n s->pict_type = get_bits(&s->gb, 3);\n\n\n\n vbv_delay= get_bits(&s->gb, 16);\n\n if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {\n\n s->full_pel[0] = get_bits1(&s->gb);\n\n f_code = get_bits(&s->gb, 3);\n\n if (f_code == 0)\n\n return -1;\n\n s->mpeg_f_code[0][0] = f_code;\n\n s->mpeg_f_code[0][1] = f_code;\n\n }\n\n if (s->pict_type == B_TYPE) {\n\n s->full_pel[1] = get_bits1(&s->gb);\n\n f_code = get_bits(&s->gb, 3);\n\n if (f_code == 0)\n\n return -1;\n\n s->mpeg_f_code[1][0] = f_code;\n\n s->mpeg_f_code[1][1] = f_code;\n\n }\n\n s->current_picture.pict_type= s->pict_type;\n\n s->current_picture.key_frame= s->pict_type == I_TYPE;\n\n \n\n// if(avctx->debug & FF_DEBUG_PICT_INFO)\n\n// av_log(avctx, AV_LOG_DEBUG, \"vbv_delay %d, ref %d\\n\", vbv_delay, ref);\n\n \n\n s->y_dc_scale = 8;\n\n s->c_dc_scale = 8;\n\n s->first_slice = 1;\n\n return 0;\n\n}\n", + "output": "1", + "index": 2614 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1);\n\n\n\n *spec_info = (ImageInfoSpecific){\n\n .kind = IMAGE_INFO_SPECIFIC_KIND_QCOW2,\n\n {\n\n .qcow2 = g_new(ImageInfoSpecificQCow2, 1),\n\n },\n\n };\n\n if (s->qcow_version == 2) {\n\n *spec_info->qcow2 = (ImageInfoSpecificQCow2){\n\n .compat = g_strdup(\"0.10\"),\n\n .refcount_bits = s->refcount_bits,\n\n };\n\n } else if (s->qcow_version == 3) {\n\n *spec_info->qcow2 = (ImageInfoSpecificQCow2){\n\n .compat = g_strdup(\"1.1\"),\n\n .lazy_refcounts = s->compatible_features &\n\n QCOW2_COMPAT_LAZY_REFCOUNTS,\n\n .has_lazy_refcounts = true,\n\n .corrupt = s->incompatible_features &\n\n QCOW2_INCOMPAT_CORRUPT,\n\n .has_corrupt = true,\n\n .refcount_bits = s->refcount_bits,\n\n };\n\n }\n\n\n\n return spec_info;\n\n}\n", + "output": "0", + "index": 8258 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int source_init(AVFilterContext *ctx, const char *args, void *opaque)\n\n{\n\n Frei0rContext *frei0r = ctx->priv;\n\n char dl_name[1024], c;\n\n char frame_size[128] = \"\";\n\n char frame_rate[128] = \"\";\n\n AVRational frame_rate_q;\n\n\n\n memset(frei0r->params, 0, sizeof(frei0r->params));\n\n\n\n if (args)\n\n sscanf(args, \"%127[^:]:%127[^:]:%1023[^:=]%c%255c\",\n\n frame_size, frame_rate, dl_name, &c, frei0r->params);\n\n\n\n if (av_parse_video_size(&frei0r->w, &frei0r->h, frame_size) < 0) {\n\n av_log(ctx, AV_LOG_ERROR, \"Invalid frame size: '%s'\\n\", frame_size);\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 ||\n\n frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {\n\n av_log(ctx, AV_LOG_ERROR, \"Invalid frame rate: '%s'\\n\", frame_rate);\n\n return AVERROR(EINVAL);\n\n }\n\n frei0r->time_base.num = frame_rate_q.den;\n\n frei0r->time_base.den = frame_rate_q.num;\n\n\n\n return frei0r_init(ctx, dl_name, F0R_PLUGIN_TYPE_SOURCE);\n\n}\n", + "output": "0", + "index": 1962 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_sendkey(const char *string)\n\n{\n\n uint8_t keycodes[16];\n\n int nb_keycodes = 0;\n\n char keyname_buf[16];\n\n char *separator;\n\n int keyname_len, keycode, i;\n\n\n\n while (1) {\n\n separator = strchr(string, '-');\n\n keyname_len = separator ? separator - string : strlen(string);\n\n if (keyname_len > 0) {\n\n pstrcpy(keyname_buf, sizeof(keyname_buf), string);\n\n if (keyname_len > sizeof(keyname_buf) - 1) {\n\n term_printf(\"invalid key: '%s...'\\n\", keyname_buf);\n\n return;\n\n }\n\n if (nb_keycodes == sizeof(keycodes)) {\n\n term_printf(\"too many keys\\n\");\n\n return;\n\n }\n\n keyname_buf[keyname_len] = 0;\n\n keycode = get_keycode(keyname_buf);\n\n if (keycode < 0) {\n\n term_printf(\"unknown key: '%s'\\n\", keyname_buf);\n\n return;\n\n }\n\n keycodes[nb_keycodes++] = keycode;\n\n }\n\n if (!separator)\n\n break;\n\n string = separator + 1;\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": "0", + "index": 6003 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_divw (void)\n\n{\n\n if (unlikely(((int32_t)T0 == INT32_MIN && (int32_t)T1 == -1) ||\n\n (int32_t)T1 == 0)) {\n\n T0 = (int32_t)((-1) * ((uint32_t)T0 >> 31));\n\n } else {\n\n T0 = (int32_t)T0 / (int32_t)T1;\n\n }\n\n RETURN();\n\n}\n", + "output": "1", + "index": 7658 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_image_alloc(uint8_t *pointers[4], int linesizes[4],\n int w, int h, enum AVPixelFormat pix_fmt, int align)\n{\n const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);\n int i, ret;\n uint8_t *buf;\n if (!desc)\n return AVERROR(EINVAL);\n if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)\n return ret;\n if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, align>7 ? FFALIGN(w, 8) : w)) < 0)\n return ret;\n for (i = 0; i < 4; i++)\n linesizes[i] = FFALIGN(linesizes[i], align);\n if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)\n return ret;\n buf = av_malloc(ret + align);\n if (!buf)\n return AVERROR(ENOMEM);\n if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {\n av_free(buf);\n return ret;\n if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)\n avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);\n return ret;", + "output": "1", + "index": 618 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sd_erase(SDState *sd)\n\n{\n\n int i, start, end;\n\n if (!sd->erase_start || !sd->erase_end) {\n\n sd->card_status |= ERASE_SEQ_ERROR;\n\n return;\n\n }\n\n\n\n start = sd->erase_start >>\n\n (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT);\n\n end = sd->erase_end >>\n\n (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT);\n\n sd->erase_start = 0;\n\n sd->erase_end = 0;\n\n sd->csd[14] |= 0x40;\n\n\n\n for (i = start; i <= end; i ++)\n\n if (sd->wp_groups[i])\n\n sd->card_status |= WP_ERASE_SKIP;\n\n}\n", + "output": "0", + "index": 16947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool arm_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)\n\n{\n\n return regime_using_lpae_format(env, mmu_idx);\n\n}\n", + "output": "0", + "index": 5554 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_slice_luma(AVCodecContext *avctx, SliceContext *slice,\n\n uint16_t *dst, int dst_stride,\n\n const uint8_t *buf, unsigned buf_size,\n\n const int16_t *qmat)\n\n{\n\n ProresContext *ctx = avctx->priv_data;\n\n LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]);\n\n int16_t *block;\n\n GetBitContext gb;\n\n int i, blocks_per_slice = slice->mb_count<<2;\n\n int ret;\n\n\n\n for (i = 0; i < blocks_per_slice; i++)\n\n ctx->bdsp.clear_block(blocks+(i<<6));\n\n\n\n init_get_bits(&gb, buf, buf_size << 3);\n\n\n\n decode_dc_coeffs(&gb, blocks, blocks_per_slice);\n\n if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)\n\n return ret;\n\n\n\n block = blocks;\n\n for (i = 0; i < slice->mb_count; i++) {\n\n ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat);\n\n ctx->prodsp.idct_put(dst +8, dst_stride, block+(1<<6), qmat);\n\n ctx->prodsp.idct_put(dst+4*dst_stride , dst_stride, block+(2<<6), qmat);\n\n ctx->prodsp.idct_put(dst+4*dst_stride+8, dst_stride, block+(3<<6), qmat);\n\n block += 4*64;\n\n dst += 16;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 9877 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,\n\n uint8_t* heads, uint8_t* secs_per_cyl)\n\n{\n\n uint32_t cyls_times_heads;\n\n\n\n if (total_sectors > 65535 * 16 * 255)\n\n return -EFBIG;\n\n\n\n if (total_sectors > 65535 * 16 * 63) {\n\n *secs_per_cyl = 255;\n\n *heads = 16;\n\n cyls_times_heads = total_sectors / *secs_per_cyl;\n\n } else {\n\n *secs_per_cyl = 17;\n\n cyls_times_heads = total_sectors / *secs_per_cyl;\n\n *heads = (cyls_times_heads + 1023) / 1024;\n\n\n\n if (*heads < 4)\n\n *heads = 4;\n\n\n\n if (cyls_times_heads >= (*heads * 1024) || *heads > 16) {\n\n *secs_per_cyl = 31;\n\n *heads = 16;\n\n cyls_times_heads = total_sectors / *secs_per_cyl;\n\n }\n\n\n\n if (cyls_times_heads >= (*heads * 1024)) {\n\n *secs_per_cyl = 63;\n\n *heads = 16;\n\n cyls_times_heads = total_sectors / *secs_per_cyl;\n\n }\n\n }\n\n\n\n *cyls = cyls_times_heads / *heads;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 16741 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_del_net_client(NetClientState *nc)\n\n{\n\n NetClientState *ncs[MAX_QUEUE_NUM];\n\n int queues, i;\n\n\n\n /* If the NetClientState belongs to a multiqueue backend, we will change all\n\n * other NetClientStates also.\n\n */\n\n queues = qemu_find_net_clients_except(nc->name, ncs,\n\n NET_CLIENT_OPTIONS_KIND_NIC,\n\n MAX_QUEUE_NUM);\n\n assert(queues != 0);\n\n\n\n /* If there is a peer NIC, delete and cleanup client, but do not free. */\n\n if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {\n\n NICState *nic = qemu_get_nic(nc->peer);\n\n if (nic->peer_deleted) {\n\n return;\n\n }\n\n nic->peer_deleted = true;\n\n\n\n for (i = 0; i < queues; i++) {\n\n ncs[i]->peer->link_down = true;\n\n }\n\n\n\n if (nc->peer->info->link_status_changed) {\n\n nc->peer->info->link_status_changed(nc->peer);\n\n }\n\n\n\n for (i = 0; i < queues; i++) {\n\n qemu_cleanup_net_client(ncs[i]);\n\n }\n\n\n\n return;\n\n }\n\n\n\n assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC);\n\n\n\n for (i = 0; i < queues; i++) {\n\n qemu_cleanup_net_client(ncs[i]);\n\n qemu_free_net_client(ncs[i]);\n\n }\n\n}\n", + "output": "0", + "index": 2747 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_udivx_T1_T0(void)\n\n{\n\n\n\n\n T0 /= T1;\n\n FORCE_RET();\n", + "output": "1", + "index": 340 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter,\n\n const int16_t **lumSrc, int lumFilterSize,\n\n const int16_t *chrFilter, const int16_t **chrUSrc,\n\n const int16_t **chrVSrc,\n\n int chrFilterSize, const int16_t **alpSrc,\n\n uint8_t *dest, uint8_t *uDest, uint8_t *vDest,\n\n uint8_t *aDest, int dstW, int chrDstW)\n\n{\n\n //FIXME Optimize (just quickly written not optimized..)\n\n int i;\n\n for (i=0; i>19);\n\n }\n\n\n\n if (uDest)\n\n for (i=0; i>19);\n\n vDest[i]= av_clip_uint8(v>>19);\n\n }\n\n\n\n if (CONFIG_SWSCALE_ALPHA && aDest)\n\n for (i=0; i>19);\n\n }\n\n}\n", + "output": "0", + "index": 6320 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_bt_initfn(USBDevice *dev)\n\n{\n\n struct USBBtState *s = DO_UPCAST(struct USBBtState, dev, dev);\n\n s->dev.speed = USB_SPEED_HIGH;\n\n return 0;\n\n}\n", + "output": "0", + "index": 10708 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,\n\n const uint8_t *buf, int nb_sectors,\n\n BlockDriverCompletionFunc *cb, void *opaque)\n\n{\n\n BlockDriver *drv = bs->drv;\n\n BlockDriverAIOCB *ret;\n\n\n\n if (!drv)\n\n return NULL;\n\n if (bs->read_only)\n\n return NULL;\n\n if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {\n\n memcpy(bs->boot_sector_data, buf, 512);\n\n }\n\n\n\n ret = drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque);\n\n\n\n if (ret) {\n\n\t/* Update stats even though technically transfer has not happened. */\n\n\tbs->wr_bytes += (unsigned) nb_sectors * SECTOR_SIZE;\n\n\tbs->wr_ops ++;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 2561 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, int tcq,\n\n scsi_completionfn completion, void *opaque)\n\n{\n\n SCSIDevice *d;\n\n SCSIDeviceState *s;\n\n\n\n\n s = (SCSIDeviceState *)qemu_mallocz(sizeof(SCSIDeviceState));\n\n s->bdrv = bdrv;\n\n s->tcq = tcq;\n\n s->completion = completion;\n\n s->opaque = opaque;\n\n if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {\n\n s->cluster_size = 4;\n\n } else {\n\n s->cluster_size = 1;\n\n }\n\n bdrv_get_geometry(s->bdrv, &nb_sectors);\n\n nb_sectors /= s->cluster_size;\n\n if (nb_sectors)\n\n nb_sectors--;\n\n s->max_lba = nb_sectors;\n\n strncpy(s->drive_serial_str, drive_get_serial(s->bdrv),\n\n sizeof(s->drive_serial_str));\n\n if (strlen(s->drive_serial_str) == 0)\n\n pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), \"0\");\n\n qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);\n\n d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice));\n\n d->state = s;\n\n d->destroy = scsi_destroy;\n\n d->send_command = scsi_send_command;\n\n d->read_data = scsi_read_data;\n\n d->write_data = scsi_write_data;\n\n d->cancel_io = scsi_cancel_io;\n\n d->get_buf = scsi_get_buf;\n\n\n\n return d;\n\n}", + "output": "1", + "index": 21903 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,\n\n uint64_t iova, uint64_t len)\n\n{\n\n struct vhost_iotlb_msg imsg;\n\n\n\n imsg.iova = iova;\n\n imsg.size = len;\n\n imsg.type = VHOST_IOTLB_INVALIDATE;\n\n\n\n return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);\n\n}\n", + "output": "1", + "index": 1089 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_chan(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 (atom.size < 16)\n\n return 0;\n\n\n\n ff_mov_read_chan(c->fc, st, atom.size - 4);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 15383 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void store_reg(DisasContext *s, int reg, TCGv var)\n\n{\n\n if (reg == 15) {\n\n tcg_gen_andi_i32(var, var, ~1);\n\n s->is_jmp = DISAS_JUMP;\n\n }\n\n tcg_gen_mov_i32(cpu_R[reg], var);\n\n dead_tmp(var);\n\n}\n", + "output": "1", + "index": 7350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool virtio_disk_is_eckd(void)\n\n{\n\n if (guessed_disk_nature) {\n\n return (blk_cfg.blk_size == 4096);\n\n }\n\n return (blk_cfg.geometry.heads == 15)\n\n && (blk_cfg.geometry.sectors == 12)\n\n && (blk_cfg.blk_size == 4096);\n\n}\n", + "output": "0", + "index": 14915 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void loadvm_postcopy_handle_run_bh(void *opaque)\n\n{\n\n Error *local_err = NULL;\n\n MigrationIncomingState *mis = opaque;\n\n\n\n /* TODO we should move all of this lot into postcopy_ram.c or a shared code\n\n * in migration.c\n\n */\n\n cpu_synchronize_all_post_init();\n\n\n\n qemu_announce_self();\n\n\n\n /* Make sure all file formats flush their mutable metadata */\n\n bdrv_invalidate_cache_all(&local_err);\n\n if (local_err) {\n\n error_report_err(local_err);\n\n }\n\n\n\n trace_loadvm_postcopy_handle_run_cpu_sync();\n\n cpu_synchronize_all_post_init();\n\n\n\n trace_loadvm_postcopy_handle_run_vmstart();\n\n\n\n if (autostart) {\n\n /* Hold onto your hats, starting the CPU */\n\n vm_start();\n\n } else {\n\n /* leave it paused and let management decide when to start the CPU */\n\n runstate_set(RUN_STATE_PAUSED);\n\n }\n\n\n\n qemu_bh_delete(mis->bh);\n\n}\n", + "output": "1", + "index": 20691 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_notify(void)\n\n{\n\n g_assert(!aio_poll(ctx, false));\n\n aio_notify(ctx);\n\n g_assert(!aio_poll(ctx, true));\n\n g_assert(!aio_poll(ctx, false));\n\n}\n", + "output": "1", + "index": 14185 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xen_pt_bar_reg_init(XenPCIPassthroughState *s, XenPTRegInfo *reg,\n\n uint32_t real_offset, uint32_t *data)\n\n{\n\n uint32_t reg_field = 0;\n\n int index;\n\n\n\n index = xen_pt_bar_offset_to_index(reg->offset);\n\n if (index < 0 || index >= PCI_NUM_REGIONS) {\n\n XEN_PT_ERR(&s->dev, \"Internal error: Invalid BAR index [%d].\\n\", index);\n\n return -1;\n\n }\n\n\n\n /* set BAR flag */\n\n s->bases[index].bar_flag = xen_pt_bar_reg_parse(s, reg);\n\n if (s->bases[index].bar_flag == XEN_PT_BAR_FLAG_UNUSED) {\n\n reg_field = XEN_PT_INVALID_REG;\n\n }\n\n\n\n *data = reg_field;\n\n return 0;\n\n}\n", + "output": "0", + "index": 16533 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_phys_addr(CPUState *env, uint32_t address,\n\n int access_type, int is_user,\n\n uint32_t *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;\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 (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": 20815 + }, + { + "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 = iscsi_allocationmap_init(iscsilun);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15546 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void rgb32tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)\n\n{\n\n\tunsigned i;\n\n\tunsigned num_pixels = src_size >> 2;\n\n\tfor(i=0; iirqs[OPENPIC_OUTPUT_INT]);\n\n\n\n irq = IRQ_get_next(opp, &dst->raised);\n\n DPRINTF(\"IACK: irq=%d\\n\", irq);\n\n\n\n if (irq == -1) {\n\n /* No more interrupt pending */\n\n return opp->spve;\n\n }\n\n\n\n src = &opp->src[irq];\n\n if (!(src->ivpr & IVPR_ACTIVITY_MASK) ||\n\n !(IVPR_PRIORITY(src->ivpr) > dst->ctpr)) {\n\n /* - Spurious level-sensitive IRQ\n\n * - Priorities has been changed\n\n * and the pending IRQ isn't allowed anymore\n\n */\n\n src->ivpr &= ~IVPR_ACTIVITY_MASK;\n\n retval = opp->spve;\n\n } else {\n\n /* IRQ enter servicing state */\n\n IRQ_setbit(&dst->servicing, irq);\n\n retval = IVPR_VECTOR(opp, src->ivpr);\n\n }\n\n IRQ_resetbit(&dst->raised, irq);\n\n if (!src->level) {\n\n /* edge-sensitive IRQ */\n\n src->ivpr &= ~IVPR_ACTIVITY_MASK;\n\n src->pending = 0;\n\n }\n\n\n\n if ((irq >= opp->irq_ipi0) && (irq < (opp->irq_ipi0 + MAX_IPI))) {\n\n src->idr &= ~(1 << cpu);\n\n if (src->idr && !src->level) {\n\n /* trigger on CPUs that didn't know about it yet */\n\n openpic_set_irq(opp, irq, 1);\n\n openpic_set_irq(opp, irq, 0);\n\n /* if all CPUs knew about it, set active bit again */\n\n src->ivpr |= IVPR_ACTIVITY_MASK;\n\n }\n\n }\n\n\n\n return retval;\n\n}\n", + "output": "0", + "index": 19573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "sorecvoob(struct socket *so)\n\n{\n\n\tstruct tcpcb *tp = sototcpcb(so);\n\n\n\n\tDEBUG_CALL(\"sorecvoob\");\n\n\tDEBUG_ARG(\"so = %p\", so);\n\n\n\n\t/*\n\n\t * We take a guess at how much urgent data has arrived.\n\n\t * In most situations, when urgent data arrives, the next\n\n\t * read() should get all the urgent data. This guess will\n\n\t * be wrong however if more data arrives just after the\n\n\t * urgent data, or the read() doesn't return all the\n\n\t * urgent data.\n\n\t */\n\n\tsoread(so);\n\n\ttp->snd_up = tp->snd_una + so->so_snd.sb_cc;\n\n\ttp->t_force = 1;\n\n\ttcp_output(tp);\n\n\ttp->t_force = 0;\n\n}\n", + "output": "1", + "index": 27127 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_error_internal(const char *file, int linenr, const char *func,\n\n const char *fmt, ...)\n\n{\n\n va_list va;\n\n QError *qerror;\n\n\n\n assert(qemu_error_sink != NULL);\n\n\n\n va_start(va, fmt);\n\n qerror = qerror_from_info(file, linenr, func, fmt, &va);\n\n va_end(va);\n\n\n\n switch (qemu_error_sink->dest) {\n\n case ERR_SINK_FILE:\n\n qerror_print(qerror);\n\n QDECREF(qerror);\n\n break;\n\n case ERR_SINK_MONITOR:\n\n assert(qemu_error_sink->mon->error == NULL);\n\n qemu_error_sink->mon->error = qerror;\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 12094 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static double setup_compress_thresh(double threshold)\n\n{\n\n if ((threshold > DBL_EPSILON) && (threshold < (1.0 - DBL_EPSILON))) {\n\n double current_threshold = threshold;\n\n double step_size = 1.0;\n\n\n\n while (step_size > DBL_EPSILON) {\n\n while ((current_threshold + step_size > current_threshold) &&\n\n (bound(current_threshold + step_size, 1.0) <= threshold)) {\n\n current_threshold += step_size;\n\n }\n\n\n\n step_size /= 2.0;\n\n }\n\n\n\n return current_threshold;\n\n } else {\n\n return threshold;\n\n }\n\n}\n", + "output": "0", + "index": 15750 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)\n\n{\n\n PowerPCCPU *cpu = POWERPC_CPU(cs);\n\n CPUPPCState *env = &cpu->env;\n\n mmu_ctx_t ctx;\n\n\n\n switch (env->mmu_model) {\n\n#if defined(TARGET_PPC64)\n\n case POWERPC_MMU_64B:\n\n case POWERPC_MMU_2_03:\n\n case POWERPC_MMU_2_06:\n\n\n case POWERPC_MMU_2_07:\n\n\n return ppc_hash64_get_phys_page_debug(env, addr);\n\n#endif\n\n\n\n case POWERPC_MMU_32B:\n\n case POWERPC_MMU_601:\n\n return ppc_hash32_get_phys_page_debug(env, addr);\n\n\n\n default:\n\n ;\n\n }\n\n\n\n if (unlikely(get_physical_address(env, &ctx, addr, 0, ACCESS_INT) != 0)) {\n\n\n\n /* Some MMUs have separate TLBs for code and data. If we only try an\n\n * ACCESS_INT, we may not be able to read instructions mapped by code\n\n * TLBs, so we also try a ACCESS_CODE.\n\n */\n\n if (unlikely(get_physical_address(env, &ctx, addr, 0,\n\n ACCESS_CODE) != 0)) {\n\n return -1;\n\n }\n\n }\n\n\n\n return ctx.raddr & TARGET_PAGE_MASK;\n\n}", + "output": "1", + "index": 8696 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,\n\n int level, int strategy)\n\n{\n\n z_streamp zstream = &vs->tight_stream[stream_id];\n\n int previous_out;\n\n\n\n if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {\n\n vnc_write(vs, vs->tight.buffer, vs->tight.offset);\n\n return bytes;\n\n }\n\n\n\n if (tight_init_stream(vs, stream_id, level, strategy)) {\n\n return -1;\n\n }\n\n\n\n /* reserve memory in output buffer */\n\n buffer_reserve(&vs->tight_zlib, bytes + 64);\n\n\n\n /* set pointers */\n\n zstream->next_in = vs->tight.buffer;\n\n zstream->avail_in = vs->tight.offset;\n\n zstream->next_out = vs->tight_zlib.buffer + vs->tight_zlib.offset;\n\n zstream->avail_out = vs->tight_zlib.capacity - vs->tight_zlib.offset;\n\n zstream->data_type = Z_BINARY;\n\n previous_out = zstream->total_out;\n\n\n\n /* start encoding */\n\n if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {\n\n fprintf(stderr, \"VNC: error during tight compression\\n\");\n\n return -1;\n\n }\n\n\n\n vs->tight_zlib.offset = vs->tight_zlib.capacity - zstream->avail_out;\n\n bytes = zstream->total_out - previous_out;\n\n\n\n tight_send_compact_size(vs, bytes);\n\n vnc_write(vs, vs->tight_zlib.buffer, bytes);\n\n\n\n buffer_reset(&vs->tight_zlib);\n\n\n\n return bytes;\n\n}\n", + "output": "0", + "index": 14391 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t assigned_dev_ioport_read(void *opaque,\n\n target_phys_addr_t addr, unsigned size)\n\n{\n\n return assigned_dev_ioport_rw(opaque, addr, size, NULL);\n\n}\n", + "output": "0", + "index": 12767 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void force_sigsegv(int oldsig)\n\n{\n\n CPUState *cpu = thread_cpu;\n\n CPUArchState *env = cpu->env_ptr;\n\n target_siginfo_t info;\n\n\n\n if (oldsig == SIGSEGV) {\n\n /* Make sure we don't try to deliver the signal again; this will\n\n * end up with handle_pending_signal() calling force_sig().\n\n */\n\n sigact_table[oldsig - 1]._sa_handler = TARGET_SIG_DFL;\n\n }\n\n info.si_signo = TARGET_SIGSEGV;\n\n info.si_errno = 0;\n\n info.si_code = TARGET_SI_KERNEL;\n\n info._sifields._kill._pid = 0;\n\n info._sifields._kill._uid = 0;\n\n queue_signal(env, info.si_signo, QEMU_SI_KILL, &info);\n\n}\n", + "output": "1", + "index": 4659 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void lag_pred_line(LagarithContext *l, uint8_t *buf,\n\n int width, int stride, int line)\n\n{\n\n int L, TL;\n\n\n\n /* Left pixel is actually prev_row[width] */\n\n L = buf[width - stride - 1];\n\n if (!line) {\n\n /* Left prediction only for first line */\n\n L = l->dsp.add_hfyu_left_prediction(buf + 1, buf + 1,\n\n width - 1, buf[0]);\n\n return;\n\n } else if (line == 1) {\n\n /* Second line, left predict first pixel, the rest of the line is median predicted\n\n * NOTE: In the case of RGB this pixel is top predicted */\n\n TL = l->avctx->pix_fmt == PIX_FMT_YUV420P ? buf[-stride] : L;\n\n } else {\n\n /* Top left is 2 rows back, last pixel */\n\n TL = buf[width - (2 * stride) - 1];\n\n }\n\n\n\n add_lag_median_prediction(buf, buf - stride, buf,\n\n width, &L, &TL);\n\n}\n", + "output": "0", + "index": 22457 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_getlock(void *opaque)\n{\n size_t offset = 7;\n struct stat stbuf;\n V9fsFidState *fidp;\n V9fsGetlock *glock;\n int32_t fid, err = 0;\n V9fsPDU *pdu = opaque;\n V9fsState *s = pdu->s;\n glock = g_malloc(sizeof(*glock));\n pdu_unmarshal(pdu, offset, \"dbqqds\", &fid, &glock->type,\n &glock->start, &glock->length, &glock->proc_id,\n &glock->client_id);\n trace_v9fs_getlock(pdu->tag, pdu->id, fid,\n glock->type, glock->start, glock->length);\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 glock->type = P9_LOCK_TYPE_UNLCK;\n offset += pdu_marshal(pdu, offset, \"bqqds\", glock->type,\n glock->start, glock->length, glock->proc_id,\n &glock->client_id);\n err = offset;\nout:\n put_fid(pdu, fidp);\nout_nofid:\n complete_pdu(s, pdu, err);\n v9fs_string_free(&glock->client_id);\n g_free(glock);\n}", + "output": "1", + "index": 2011 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int omap2_gpio_init(SysBusDevice *sbd)\n\n{\n\n DeviceState *dev = DEVICE(sbd);\n\n struct omap2_gpif_s *s = OMAP2_GPIO(dev);\n\n int i;\n\n\n\n if (!s->iclk) {\n\n hw_error(\"omap2-gpio: iclk not connected\\n\");\n\n }\n\n if (s->mpu_model < omap3430) {\n\n s->modulecount = (s->mpu_model < omap2430) ? 4 : 5;\n\n memory_region_init_io(&s->iomem, OBJECT(s), &omap2_gpif_top_ops, s,\n\n \"omap2.gpio\", 0x1000);\n\n sysbus_init_mmio(sbd, &s->iomem);\n\n } else {\n\n s->modulecount = 6;\n\n }\n\n s->modules = g_new0(struct omap2_gpio_s, s->modulecount);\n\n s->handler = g_new0(qemu_irq, s->modulecount * 32);\n\n qdev_init_gpio_in(dev, omap2_gpio_set, s->modulecount * 32);\n\n qdev_init_gpio_out(dev, s->handler, s->modulecount * 32);\n\n for (i = 0; i < s->modulecount; i++) {\n\n struct omap2_gpio_s *m = &s->modules[i];\n\n if (!s->fclk[i]) {\n\n hw_error(\"omap2-gpio: fclk%d not connected\\n\", i);\n\n }\n\n m->revision = (s->mpu_model < omap3430) ? 0x18 : 0x25;\n\n m->handler = &s->handler[i * 32];\n\n sysbus_init_irq(sbd, &m->irq[0]); /* mpu irq */\n\n sysbus_init_irq(sbd, &m->irq[1]); /* dsp irq */\n\n sysbus_init_irq(sbd, &m->wkup);\n\n memory_region_init_io(&m->iomem, OBJECT(s), &omap2_gpio_module_ops, m,\n\n \"omap.gpio-module\", 0x1000);\n\n sysbus_init_mmio(sbd, &m->iomem);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 20601 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int i440fx_initfn(PCIDevice *dev)\n\n{\n\n PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev);\n\n\n\n pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL);\n\n pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82441);\n\n d->dev.config[0x08] = 0x02; // revision\n\n pci_config_set_class(d->dev.config, PCI_CLASS_BRIDGE_HOST);\n\n\n\n d->dev.config[I440FX_SMRAM] = 0x02;\n\n\n\n cpu_smm_register(&i440fx_set_smm, d);\n\n return 0;\n\n}\n", + "output": "0", + "index": 14889 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,\n\n long width, long height,\n\n long lumStride, long chromStride, long srcStride)\n\n{\n\n long y;\n\n const long chromWidth= -((-width)>>1);\n\n\n\n for (y=0; ydir.stream);\n\n if (!entry) {\n\n return NULL;\n\n }\n\n\n\n if (ctx->export_flags & V9FS_SM_MAPPED) {\n\n entry->d_type = DT_UNKNOWN;\n\n } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n\n if (!strcmp(entry->d_name, VIRTFS_META_DIR)) {\n\n /* skp the meta data directory */\n\n goto again;\n\n }\n\n entry->d_type = DT_UNKNOWN;\n\n }\n\n\n\n return entry;\n\n}\n", + "output": "1", + "index": 26346 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_blk_migration(Monitor *mon, QEMUFile *f)\n\n{\n\n BlkMigDevState *bmds;\n\n BlockDriverState *bs;\n\n\n\n block_mig_state.submitted = 0;\n\n block_mig_state.read_done = 0;\n\n block_mig_state.transferred = 0;\n\n block_mig_state.total_sector_sum = 0;\n\n block_mig_state.prev_progress = -1;\n\n\n\n for (bs = bdrv_first; bs != NULL; bs = bs->next) {\n\n if (bs->type == BDRV_TYPE_HD) {\n\n bmds = qemu_mallocz(sizeof(BlkMigDevState));\n\n bmds->bs = bs;\n\n bmds->bulk_completed = 0;\n\n bmds->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;\n\n bmds->completed_sectors = 0;\n\n bmds->shared_base = block_mig_state.shared_base;\n\n\n\n block_mig_state.total_sector_sum += bmds->total_sectors;\n\n\n\n if (bmds->shared_base) {\n\n monitor_printf(mon, \"Start migration for %s with shared base \"\n\n \"image\\n\",\n\n bs->device_name);\n\n } else {\n\n monitor_printf(mon, \"Start full migration for %s\\n\",\n\n bs->device_name);\n\n }\n\n\n\n QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 3396 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void block_set_params(const MigrationParams *params, void *opaque)\n\n{\n\n block_mig_state.blk_enable = params->blk;\n\n block_mig_state.shared_base = params->shared;\n\n\n\n /* shared base means that blk_enable = 1 */\n\n block_mig_state.blk_enable |= params->shared;\n\n}\n", + "output": "1", + "index": 12603 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int scsi_get_configuration(SCSIDiskState *s, uint8_t *outbuf)\n\n{\n\n int current;\n\n\n\n if (s->qdev.type != TYPE_ROM) {\n\n return -1;\n\n }\n\n current = media_is_dvd(s) ? MMC_PROFILE_DVD_ROM : MMC_PROFILE_CD_ROM;\n\n memset(outbuf, 0, 40);\n\n stl_be_p(&outbuf[0], 36); /* Bytes after the data length field */\n\n stw_be_p(&outbuf[6], current);\n\n /* outbuf[8] - outbuf[19]: Feature 0 - Profile list */\n\n outbuf[10] = 0x03; /* persistent, current */\n\n outbuf[11] = 8; /* two profiles */\n\n stw_be_p(&outbuf[12], MMC_PROFILE_DVD_ROM);\n\n outbuf[14] = (current == MMC_PROFILE_DVD_ROM);\n\n stw_be_p(&outbuf[16], MMC_PROFILE_CD_ROM);\n\n outbuf[18] = (current == MMC_PROFILE_CD_ROM);\n\n /* outbuf[20] - outbuf[31]: Feature 1 - Core feature */\n\n stw_be_p(&outbuf[20], 1);\n\n outbuf[22] = 0x08 | 0x03; /* version 2, persistent, current */\n\n outbuf[23] = 8;\n\n stl_be_p(&outbuf[24], 1); /* SCSI */\n\n outbuf[28] = 1; /* DBE = 1, mandatory */\n\n /* outbuf[32] - outbuf[39]: Feature 3 - Removable media feature */\n\n stw_be_p(&outbuf[32], 3);\n\n outbuf[34] = 0x08 | 0x03; /* version 2, persistent, current */\n\n outbuf[35] = 4;\n\n outbuf[36] = 0x39; /* tray, load=1, eject=1, unlocked at powerup, lock=1 */\n\n /* TODO: Random readable, CD read, DVD read, drive serial number,\n\n power management */\n\n return 40;\n\n}\n", + "output": "1", + "index": 11343 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_fsdev_add(QemuOpts *opts)\n\n{\n\n struct FsTypeListEntry *fsle;\n\n int i;\n\n\n\n if (qemu_opts_id(opts) == NULL) {\n\n fprintf(stderr, \"fsdev: No id specified\\n\");\n\n return -1;\n\n }\n\n\n\n for (i = 0; i < ARRAY_SIZE(FsTypes); i++) {\n\n if (strcmp(FsTypes[i].name, qemu_opt_get(opts, \"fstype\")) == 0) {\n\n break;\n\n }\n\n }\n\n\n\n if (i == ARRAY_SIZE(FsTypes)) {\n\n fprintf(stderr, \"fsdev: fstype %s not found\\n\",\n\n qemu_opt_get(opts, \"fstype\"));\n\n return -1;\n\n }\n\n\n\n fsle = qemu_malloc(sizeof(*fsle));\n\n\n\n fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts));\n\n fsle->fse.path = qemu_strdup(qemu_opt_get(opts, \"path\"));\n\n fsle->fse.ops = FsTypes[i].ops;\n\n\n\n QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next);\n\n return 0;\n\n\n\n}\n", + "output": "0", + "index": 14807 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void json_lexer_destroy(JSONLexer *lexer)\n\n{\n\n QDECREF(lexer->token);\n\n}\n", + "output": "0", + "index": 24873 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mmubooke206_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 ppcmas_tlb_t *tlb;\n\n target_phys_addr_t raddr;\n\n int i, j, ret;\n\n\n\n ret = -1;\n\n raddr = (target_phys_addr_t)-1ULL;\n\n\n\n for (i = 0; i < BOOKE206_MAX_TLBN; i++) {\n\n int ways = booke206_tlb_ways(env, i);\n\n\n\n for (j = 0; j < ways; j++) {\n\n tlb = booke206_get_tlbm(env, i, address, j);\n\n\n\n\n ret = mmubooke206_check_tlb(env, tlb, &raddr, &ctx->prot, address,\n\n rw, access_type);\n\n if (ret != -1) {\n\n goto found_tlb;\n\n\n\n\n\n\nfound_tlb:\n\n\n\n if (ret >= 0) {\n\n ctx->raddr = raddr;\n\n LOG_SWTLB(\"%s: access granted \" TARGET_FMT_lx \" => \" TARGET_FMT_plx\n\n \" %d %d\\n\", __func__, address, ctx->raddr, ctx->prot,\n\n ret);\n\n } else {\n\n LOG_SWTLB(\"%s: access refused \" TARGET_FMT_lx \" => \" TARGET_FMT_plx\n\n \" %d %d\\n\", __func__, address, raddr, ctx->prot, ret);\n\n\n\n\n return ret;\n", + "output": "1", + "index": 9404 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t msix_bar_size(PCIDevice *dev)\n\n{\n\n return (dev->cap_present & QEMU_PCI_CAP_MSIX) ?\n\n dev->msix_bar_size : 0;\n\n}\n", + "output": "0", + "index": 10020 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_setuid(FsContext *ctx, uid_t uid)\n\n{\n\n struct passwd *pw;\n\n gid_t groups[33];\n\n int ngroups;\n\n static uid_t cur_uid = -1;\n\n\n\n if (cur_uid == uid) {\n\n return 0;\n\n }\n\n\n\n if (setreuid(0, 0)) {\n\n return -1;\n\n }\n\n\n\n pw = getpwuid(uid);\n\n if (pw == NULL) {\n\n return -1;\n\n }\n\n\n\n ngroups = 33;\n\n if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups) == -1) {\n\n return -1;\n\n }\n\n\n\n if (setgroups(ngroups, groups)) {\n\n return -1;\n\n }\n\n\n\n if (setregid(-1, pw->pw_gid)) {\n\n return -1;\n\n }\n\n\n\n if (setreuid(-1, uid)) {\n\n return -1;\n\n }\n\n\n\n cur_uid = uid;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11765 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gd_ungrab_pointer(GtkDisplayState *s)\n\n{\n\n#if GTK_CHECK_VERSION(3, 0, 0)\n\n GdkDisplay *display = gtk_widget_get_display(s->drawing_area);\n\n GdkDeviceManager *mgr = gdk_display_get_device_manager(display);\n\n GList *devices = gdk_device_manager_list_devices(mgr,\n\n GDK_DEVICE_TYPE_MASTER);\n\n GList *tmp = devices;\n\n while (tmp) {\n\n GdkDevice *dev = tmp->data;\n\n if (gdk_device_get_source(dev) == GDK_SOURCE_MOUSE) {\n\n gdk_device_ungrab(dev,\n\n GDK_CURRENT_TIME);\n\n }\n\n tmp = tmp->next;\n\n }\n\n g_list_free(devices);\n\n#else\n\n gdk_pointer_ungrab(GDK_CURRENT_TIME);\n\n#endif\n\n}\n", + "output": "0", + "index": 11693 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_receive_status(V9fsProxy *proxy,\n\n struct iovec *reply, int *status)\n\n{\n\n int retval;\n\n ProxyHeader header;\n\n\n\n *status = 0;\n\n reply->iov_len = 0;\n\n retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ);\n\n if (retval < 0) {\n\n return retval;\n\n }\n\n reply->iov_len = PROXY_HDR_SZ;\n\n proxy_unmarshal(reply, 0, \"dd\", &header.type, &header.size);\n\n if (header.size != sizeof(int)) {\n\n *status = -ENOBUFS;\n\n return 0;\n\n }\n\n retval = socket_read(proxy->sockfd,\n\n reply->iov_base + PROXY_HDR_SZ, header.size);\n\n if (retval < 0) {\n\n return retval;\n\n }\n\n reply->iov_len += header.size;\n\n proxy_unmarshal(reply, PROXY_HDR_SZ, \"d\", status);\n\n return 0;\n\n}\n", + "output": "1", + "index": 22963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t raw_getlength(BlockDriverState *bs)\n\n{\n\n int64_t len;\n\n BDRVRawState *s = bs->opaque;\n\n\n\n /* Update size. It should not change unless the file was externally\n\n * modified. */\n\n len = bdrv_getlength(bs->file->bs);\n\n if (len < 0) {\n\n return len;\n\n }\n\n\n\n if (len < s->offset) {\n\n s->size = 0;\n\n } else {\n\n if (s->has_size) {\n\n /* Try to honour the size */\n\n s->size = MIN(s->size, len - s->offset);\n\n } else {\n\n s->size = len - s->offset;\n\n }\n\n }\n\n\n\n return s->size;\n\n}\n", + "output": "0", + "index": 8680 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn v9fs_link(void *opaque)\n\n{\n\n V9fsPDU *pdu = opaque;\n\n int32_t dfid, oldfid;\n\n V9fsFidState *dfidp, *oldfidp;\n\n V9fsString name;\n\n size_t offset = 7;\n\n int err = 0;\n\n\n\n v9fs_string_init(&name);\n\n err = pdu_unmarshal(pdu, offset, \"dds\", &dfid, &oldfid, &name);\n\n if (err < 0) {\n\n goto out_nofid;\n\n }\n\n trace_v9fs_link(pdu->tag, pdu->id, dfid, oldfid, name.data);\n\n\n\n if (name_is_illegal(name.data)) {\n\n err = -ENOENT;\n\n goto out_nofid;\n\n }\n\n\n\n if (!strcmp(\".\", name.data) || !strcmp(\"..\", name.data)) {\n\n err = -EEXIST;\n\n goto out_nofid;\n\n }\n\n\n\n dfidp = get_fid(pdu, dfid);\n\n if (dfidp == NULL) {\n\n err = -ENOENT;\n\n goto out_nofid;\n\n }\n\n\n\n oldfidp = get_fid(pdu, oldfid);\n\n if (oldfidp == NULL) {\n\n err = -ENOENT;\n\n goto out;\n\n }\n\n err = v9fs_co_link(pdu, oldfidp, dfidp, &name);\n\n if (!err) {\n\n err = offset;\n\n }\n\n\nout:\n\n put_fid(pdu, dfidp);\n\nout_nofid:\n\n v9fs_string_free(&name);\n\n pdu_complete(pdu, err);\n\n}", + "output": "1", + "index": 11486 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void avc_h_loop_filter_chroma422_msa(uint8_t *src,\n\n int32_t stride,\n\n int32_t alpha_in,\n\n int32_t beta_in,\n\n int8_t *tc0)\n\n{\n\n int32_t col, tc_val;\n\n int16_t out0, out1, out2, out3;\n\n v16u8 alpha, beta, res;\n\n\n\n alpha = (v16u8) __msa_fill_b(alpha_in);\n\n beta = (v16u8) __msa_fill_b(beta_in);\n\n\n\n for (col = 0; col < 4; col++) {\n\n tc_val = (tc0[col] - 1) + 1;\n\n\n\n if (tc_val <= 0) {\n\n src += (4 * stride);\n\n continue;\n\n }\n\n\n\n AVC_LPF_H_CHROMA_422(src, stride, tc_val, alpha, beta, res);\n\n\n\n out0 = __msa_copy_s_h((v8i16) res, 0);\n\n out1 = __msa_copy_s_h((v8i16) res, 1);\n\n out2 = __msa_copy_s_h((v8i16) res, 2);\n\n out3 = __msa_copy_s_h((v8i16) res, 3);\n\n\n\n STORE_HWORD((src - 1), out0);\n\n src += stride;\n\n STORE_HWORD((src - 1), out1);\n\n src += stride;\n\n STORE_HWORD((src - 1), out2);\n\n src += stride;\n\n STORE_HWORD((src - 1), out3);\n\n src += stride;\n\n }\n\n}\n", + "output": "0", + "index": 9102 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void denoise_depth(HQDN3DContext *s,\n\n uint8_t *src, uint8_t *dst,\n\n uint16_t *line_ant, uint16_t **frame_ant_ptr,\n\n int w, int h, int sstride, int dstride,\n\n int16_t *spatial, int16_t *temporal, int depth)\n\n{\n\n // FIXME: For 16bit depth, frame_ant could be a pointer to the previous\n\n // filtered frame rather than a separate buffer.\n\n long x, y;\n\n uint16_t *frame_ant = *frame_ant_ptr;\n\n if (!frame_ant) {\n\n uint8_t *frame_src = src;\n\n *frame_ant_ptr = frame_ant = av_malloc(w*h*sizeof(uint16_t));\n\n for (y = 0; y < h; y++, src += sstride, frame_ant += w)\n\n for (x = 0; x < w; x++)\n\n frame_ant[x] = LOAD(x);\n\n src = frame_src;\n\n frame_ant = *frame_ant_ptr;\n\n }\n\n\n\n if (spatial[0])\n\n denoise_spatial(s, src, dst, line_ant, frame_ant,\n\n w, h, sstride, dstride, spatial, temporal, depth);\n\n else\n\n denoise_temporal(src, dst, frame_ant,\n\n w, h, sstride, dstride, temporal, depth);\n\n emms_c();\n\n}\n", + "output": "0", + "index": 2469 + }, + { + "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 ret;\n\n#ifdef CONFIG_UTIMENSAT\n\n int fd;\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#else\n\n ret = -1;\n\n errno = ENOSYS;\n\n#endif\n\n return ret;\n\n}\n", + "output": "1", + "index": 16692 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void copy_video_props(AVFilterBufferRefVideoProps *dst, AVFilterBufferRefVideoProps *src) {\n\n *dst = *src;\n\n if (src->qp_table) {\n\n int qsize = src->qp_table_size;\n\n dst->qp_table = av_malloc(qsize);\n\n memcpy(dst->qp_table, src->qp_table, qsize);\n\n }\n\n}\n", + "output": "1", + "index": 26345 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_send_option_request(QIOChannel *ioc, uint32_t opt,\n\n uint32_t len, const char *data,\n\n Error **errp)\n\n{\n\n nbd_option req;\n\n QEMU_BUILD_BUG_ON(sizeof(req) != 16);\n\n\n\n if (len == -1) {\n\n req.length = len = strlen(data);\n\n }\n\n TRACE(\"Sending option request %\" PRIu32\", len %\" PRIu32, opt, len);\n\n\n\n stq_be_p(&req.magic, NBD_OPTS_MAGIC);\n\n stl_be_p(&req.option, opt);\n\n stl_be_p(&req.length, len);\n\n\n\n if (write_sync(ioc, &req, sizeof(req), errp) < 0) {\n\n error_prepend(errp, \"Failed to send option request header\");\n\n return -1;\n\n }\n\n\n\n if (len && write_sync(ioc, (char *) data, len, errp) < 0) {\n\n error_prepend(errp, \"Failed to send option request data\");\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 14916 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vfio_enable_intx(VFIODevice *vdev)\n\n{\n\n VFIOIRQSetFD irq_set_fd = {\n\n .irq_set = {\n\n .argsz = sizeof(irq_set_fd),\n\n .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER,\n\n .index = VFIO_PCI_INTX_IRQ_INDEX,\n\n .start = 0,\n\n .count = 1,\n\n },\n\n };\n\n uint8_t pin = vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1);\n\n int ret;\n\n\n\n if (vdev->intx.disabled || !pin) {\n\n return 0;\n\n }\n\n\n\n vfio_disable_interrupts(vdev);\n\n\n\n vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */\n\n ret = event_notifier_init(&vdev->intx.interrupt, 0);\n\n if (ret) {\n\n error_report(\"vfio: Error: event_notifier_init failed\\n\");\n\n return ret;\n\n }\n\n\n\n irq_set_fd.fd = event_notifier_get_fd(&vdev->intx.interrupt);\n\n qemu_set_fd_handler(irq_set_fd.fd, vfio_intx_interrupt, NULL, vdev);\n\n\n\n if (ioctl(vdev->fd, VFIO_DEVICE_SET_IRQS, &irq_set_fd)) {\n\n error_report(\"vfio: Error: Failed to setup INTx fd: %m\\n\");\n\n return -errno;\n\n }\n\n\n\n /*\n\n * Disable mmaps so we can trap on BAR accesses. We interpret any\n\n * access as a response to an interrupt and unmask the physical\n\n * device. The device will re-assert if the interrupt is still\n\n * pending. We'll likely retrigger on the host multiple times per\n\n * guest interrupt, but without EOI notification it's better than\n\n * nothing. Acceleration paths through KVM will avoid this.\n\n */\n\n vfio_mmap_set_enabled(vdev, false);\n\n\n\n vdev->interrupt = VFIO_INT_INTx;\n\n\n\n DPRINTF(\"%s(%04x:%02x:%02x.%x)\\n\", __func__, vdev->host.domain,\n\n vdev->host.bus, vdev->host.slot, vdev->host.function);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 1900 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cmd_args_init(CmdArgs *cmd_args)\n\n{\n\n cmd_args->name = qstring_new();\n\n cmd_args->type = cmd_args->flag = cmd_args->optional = 0;\n\n}\n", + "output": "0", + "index": 5287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_char(GDBState *s)\n\n{\n\n uint8_t ch;\n\n int ret;\n\n\n\n for(;;) {\n\n ret = qemu_recv(s->fd, &ch, 1, 0);\n\n if (ret < 0) {\n\n if (errno == ECONNRESET)\n\n s->fd = -1;\n\n if (errno != EINTR && errno != EAGAIN)\n\n return -1;\n\n } else if (ret == 0) {\n\n close(s->fd);\n\n s->fd = -1;\n\n return -1;\n\n } else {\n\n break;\n\n }\n\n }\n\n return ch;\n\n}\n", + "output": "0", + "index": 23367 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)\n\n{\n\n SCSIBus *bus = sreq->bus;\n\n VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);\n\n VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);\n\n VirtIOSCSIReq *req;\n\n uint32_t n;\n\n\n\n req = g_malloc(sizeof(*req));\n\n qemu_get_be32s(f, &n);\n\n assert(n < vs->conf.num_queues);\n\n qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));\n\n /* TODO: add a way for SCSIBusInfo's load_request to fail,\n\n * and fail migration instead 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(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg));\n\n assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg));\n\n virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);\n\n\n\n scsi_req_ref(sreq);\n\n req->sreq = sreq;\n\n if (req->sreq->cmd.mode != SCSI_XFER_NONE) {\n\n int req_mode =\n\n (req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);\n\n\n\n assert(req->sreq->cmd.mode == req_mode);\n\n }\n\n return req;\n\n}\n", + "output": "0", + "index": 25635 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en)\n\n{\n\n uint64_t iqa_val = vtd_get_quad_raw(s, DMAR_IQA_REG);\n\n\n\n trace_vtd_inv_qi_enable(en);\n\n\n\n if (en) {\n\n s->iq = iqa_val & VTD_IQA_IQA_MASK(VTD_HOST_ADDRESS_WIDTH);\n\n /* 2^(x+8) entries */\n\n s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8);\n\n s->qi_enabled = true;\n\n trace_vtd_inv_qi_setup(s->iq, s->iq_size);\n\n /* Ok - report back to driver */\n\n vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_QIES);\n\n\n\n if (s->iq_tail != 0) {\n\n /*\n\n * This is a spec violation but Windows guests are known to set up\n\n * Queued Invalidation this way so we allow the write and process\n\n * Invalidation Descriptors right away.\n\n */\n\n trace_vtd_warn_invalid_qi_tail(s->iq_tail);\n\n if (!(vtd_get_long_raw(s, DMAR_FSTS_REG) & VTD_FSTS_IQE)) {\n\n vtd_fetch_inv_desc(s);\n\n }\n\n }\n\n } else {\n\n if (vtd_queued_inv_disable_check(s)) {\n\n /* disable Queued Invalidation */\n\n vtd_set_quad_raw(s, DMAR_IQH_REG, 0);\n\n s->iq_head = 0;\n\n s->qi_enabled = false;\n\n /* Ok - report back to driver */\n\n vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_QIES, 0);\n\n } else {\n\n trace_vtd_err_qi_disable(s->iq_head, s->iq_tail, s->iq_last_desc_type);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 5202 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nbd_restart_write(void *opaque)\n\n{\n\n BlockDriverState *bs = opaque;\n\n\n\n qemu_coroutine_enter(nbd_get_client_session(bs)->send_coroutine, NULL);\n\n}\n", + "output": "1", + "index": 3093 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SocketAddress *socket_parse(const char *str, Error **errp)\n\n{\n\n SocketAddress *addr;\n\n\n\n addr = g_new0(SocketAddress, 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_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_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_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_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_SocketAddress(addr);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 14533 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp)\n\n{\n\n int err = -1;\n\n int serrno = 0;\n\n\n\n /* Determine the security model */\n\n if (fs_ctx->fs_sm == SM_MAPPED) {\n\n err = mknod(rpath(fs_ctx, path), SM_LOCAL_MODE_BITS|S_IFREG, 0);\n\n if (err == -1) {\n\n return err;\n\n }\n\n local_set_xattr(rpath(fs_ctx, path), credp);\n\n if (err == -1) {\n\n serrno = errno;\n\n goto err_end;\n\n }\n\n } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {\n\n err = mknod(rpath(fs_ctx, path), credp->fc_mode, credp->fc_rdev);\n\n if (err == -1) {\n\n return err;\n\n }\n\n err = local_post_create_passthrough(fs_ctx, path, credp);\n\n if (err == -1) {\n\n serrno = errno;\n\n goto err_end;\n\n }\n\n }\n\n return err;\n\n\n\nerr_end:\n\n remove(rpath(fs_ctx, path));\n\n errno = serrno;\n\n return err;\n\n}\n", + "output": "1", + "index": 19686 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_notify_vector(VirtIODevice *vdev, uint16_t vector)\n{\n BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));\n VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n if (k->notify) {\n k->notify(qbus->parent, vector);", + "output": "1", + "index": 22307 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool is_zero_cluster(BlockDriverState *bs, int64_t start)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n int nr;\n\n BlockDriverState *file;\n\n int64_t res = bdrv_get_block_status_above(bs, NULL, start,\n\n s->cluster_sectors, &nr, &file);\n\n return res >= 0 && (res & BDRV_BLOCK_ZERO);\n\n}\n", + "output": "0", + "index": 9262 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int raw_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)\n\n{\n\n BDRVRawState *s = bs->opaque;\n\n int ret;\n\n\n\n ret = bdrv_probe_blocksizes(bs->file->bs, bsz);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n if (!QEMU_IS_ALIGNED(s->offset, MAX(bsz->log, bsz->phys))) {\n\n return -ENOTSUP;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 9869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_aio_complete(void *opaque, int ret)\n\n{\n\n struct ioreq *ioreq = opaque;\n\n\n\n if (ret != 0) {\n\n xen_be_printf(&ioreq->blkdev->xendev, 0, \"%s I/O error\\n\",\n\n ioreq->req.operation == BLKIF_OP_READ ? \"read\" : \"write\");\n\n ioreq->aio_errors++;\n\n }\n\n\n\n ioreq->aio_inflight--;\n\n if (ioreq->presync) {\n\n ioreq->presync = 0;\n\n ioreq_runio_qemu_aio(ioreq);\n\n return;\n\n }\n\n if (ioreq->aio_inflight > 0) {\n\n return;\n\n }\n\n if (ioreq->postsync) {\n\n ioreq->postsync = 0;\n\n ioreq->aio_inflight++;\n\n bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);\n\n return;\n\n }\n\n\n\n ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;\n\n ioreq_unmap(ioreq);\n\n ioreq_finish(ioreq);\n\n switch (ioreq->req.operation) {\n\n case BLKIF_OP_WRITE:\n\n case BLKIF_OP_FLUSH_DISKCACHE:\n\n if (!ioreq->req.nr_segments) {\n\n break;\n\n }\n\n case BLKIF_OP_READ:\n\n block_acct_done(bdrv_get_stats(ioreq->blkdev->bs), &ioreq->acct);\n\n break;\n\n case BLKIF_OP_DISCARD:\n\n default:\n\n break;\n\n }\n\n qemu_bh_schedule(ioreq->blkdev->bh);\n\n}\n", + "output": "0", + "index": 23099 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t virtio_read_config(PCIDevice *pci_dev,\n\n uint32_t address, int len)\n\n{\n\n VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);\n\n struct virtio_pci_cfg_cap *cfg;\n\n\n\n if (proxy->config_cap &&\n\n ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,\n\n pci_cfg_data),\n\n sizeof cfg->pci_cfg_data)) {\n\n uint32_t off;\n\n uint32_t len;\n\n\n\n cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);\n\n off = le32_to_cpu(cfg->cap.offset);\n\n len = le32_to_cpu(cfg->cap.length);\n\n\n\n if (len <= sizeof cfg->pci_cfg_data) {\n\n virtio_address_space_read(&proxy->modern_as, off,\n\n cfg->pci_cfg_data, len);\n\n }\n\n }\n\n\n\n return pci_default_read_config(pci_dev, address, len);\n\n}\n", + "output": "1", + "index": 9451 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void slow_bar_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)\n\n{\n\n AssignedDevRegion *d = opaque;\n\n uint8_t *out = d->u.r_virtbase + addr;\n\n\n\n DEBUG(\"slow_bar_writeb addr=0x\" TARGET_FMT_plx \" val=0x%02x\\n\", addr, val);\n\n *out = val;\n\n}\n", + "output": "0", + "index": 6280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,\n\n qemu_irq *irq, omap_clk clk)\n\n{\n\n int iomemtype;\n\n struct omap_rtc_s *s = (struct omap_rtc_s *)\n\n qemu_mallocz(sizeof(struct omap_rtc_s));\n\n\n\n s->irq = irq[0];\n\n s->alarm = irq[1];\n\n s->clk = qemu_new_timer(rt_clock, omap_rtc_tick, s);\n\n\n\n omap_rtc_reset(s);\n\n\n\n iomemtype = cpu_register_io_memory(omap_rtc_readfn,\n\n omap_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);\n\n cpu_register_physical_memory(base, 0x800, iomemtype);\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 23463 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_inherited_options(int *child_flags, QDict *child_options,\n\n int parent_flags, QDict *parent_options)\n\n{\n\n int flags = parent_flags;\n\n\n\n /* Enable protocol handling, disable format probing for bs->file */\n\n flags |= BDRV_O_PROTOCOL;\n\n\n\n /* If the cache mode isn't explicitly set, inherit direct and no-flush from\n\n * the parent. */\n\n qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIRECT);\n\n qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FLUSH);\n\n\n\n /* Inherit the read-only option from the parent if it's not set */\n\n qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);\n\n\n\n /* Our block drivers take care to send flushes and respect unmap policy,\n\n * so we can default to enable both on lower layers regardless of the\n\n * corresponding parent options. */\n\n flags |= BDRV_O_UNMAP;\n\n\n\n /* Clear flags that only apply to the top layer */\n\n flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ |\n\n BDRV_O_NO_IO);\n\n\n\n *child_flags = flags;\n\n}\n", + "output": "0", + "index": 16303 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)\n\n{\n\n const QDictEntry *ent;\n\n const char *arg_name;\n\n const QObject *arg_obj;\n\n bool has_exec_key = false;\n\n QDict *dict = NULL;\n\n\n\n dict = qobject_to_qdict(request);\n\n if (!dict) {\n\n error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT,\n\n \"request is not a dictionary\");\n\n return NULL;\n\n }\n\n\n\n for (ent = qdict_first(dict); ent;\n\n ent = qdict_next(dict, ent)) {\n\n arg_name = qdict_entry_key(ent);\n\n arg_obj = qdict_entry_value(ent);\n\n\n\n if (!strcmp(arg_name, \"execute\")) {\n\n if (qobject_type(arg_obj) != QTYPE_QSTRING) {\n\n error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, \"execute\",\n\n \"string\");\n\n return NULL;\n\n }\n\n has_exec_key = true;\n\n } else if (!strcmp(arg_name, \"arguments\")) {\n\n if (qobject_type(arg_obj) != QTYPE_QDICT) {\n\n error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,\n\n \"arguments\", \"object\");\n\n return NULL;\n\n }\n\n } else {\n\n error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name);\n\n return NULL;\n\n }\n\n }\n\n\n\n if (!has_exec_key) {\n\n error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, \"execute\");\n\n return NULL;\n\n }\n\n\n\n return dict;\n\n}\n", + "output": "1", + "index": 12798 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const char *bdrv_get_parent_name(const BlockDriverState *bs)\n\n{\n\n BdrvChild *c;\n\n const char *name;\n\n\n\n /* If multiple parents have a name, just pick the first one. */\n\n QLIST_FOREACH(c, &bs->parents, next_parent) {\n\n if (c->role->get_name) {\n\n name = c->role->get_name(c);\n\n if (name && *name) {\n\n return name;\n\n }\n\n }\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 27248 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t helper_fctid(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_signaling_nan(farg.d))) {\n\n /* sNaN conversion */\n\n farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN |\n\n POWERPC_EXCP_FP_VXCVI);\n\n } else if (unlikely(float64_is_quiet_nan(farg.d) ||\n\n float64_is_infinity(farg.d))) {\n\n /* qNan / infinity conversion */\n\n farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI);\n\n } else {\n\n farg.ll = float64_to_int64(farg.d, &env->fp_status);\n\n }\n\n return farg.ll;\n\n}\n", + "output": "0", + "index": 15950 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_io_channel_setup_async(SocketAddressLegacy *listen_addr,\n\n SocketAddressLegacy *connect_addr,\n\n QIOChannel **src,\n\n QIOChannel **dst)\n\n{\n\n QIOChannelSocket *lioc;\n\n struct TestIOChannelData data;\n\n\n\n data.loop = g_main_loop_new(g_main_context_default(),\n\n TRUE);\n\n\n\n lioc = qio_channel_socket_new();\n\n qio_channel_socket_listen_async(\n\n lioc, listen_addr,\n\n test_io_channel_complete, &data, NULL);\n\n\n\n g_main_loop_run(data.loop);\n\n g_main_context_iteration(g_main_context_default(), FALSE);\n\n\n\n g_assert(!data.err);\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\n\n qio_channel_socket_connect_async(\n\n QIO_CHANNEL_SOCKET(*src), connect_addr,\n\n test_io_channel_complete, &data, NULL);\n\n\n\n g_main_loop_run(data.loop);\n\n g_main_context_iteration(g_main_context_default(), FALSE);\n\n\n\n g_assert(!data.err);\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 qio_channel_set_delay(*src, false);\n\n test_io_channel_set_socket_bufs(*src, *dst);\n\n\n\n object_unref(OBJECT(lioc));\n\n\n\n g_main_loop_unref(data.loop);\n\n}\n", + "output": "0", + "index": 18787 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpeg_decode_frame(AVCodecContext *avctx,\n\n void *data, int *data_size,\n\n const uint8_t *buf, int buf_size)\n\n{\n\n Mpeg1Context *s = avctx->priv_data;\n\n AVFrame *picture = data;\n\n MpegEncContext *s2 = &s->mpeg_enc_ctx;\n\n dprintf(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 *picture= *(AVFrame*)s2->next_picture_ptr;\n\n s2->next_picture_ptr= NULL;\n\n\n\n *data_size = sizeof(AVFrame);\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, buf_size);\n\n\n\n if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )\n\n return buf_size;\n\n }\n\n\n\n#if 0\n\n if (s->repeat_field % 2 == 1) {\n\n s->repeat_field++;\n\n //fprintf(stderr,\"\\nRepeating last frame: %d -> %d! pict: %d %d\", avctx->frame_number-1, avctx->frame_number,\n\n // s2->picture_number, s->repeat_field);\n\n if (avctx->flags & CODEC_FLAG_REPEAT_FIELD) {\n\n *data_size = sizeof(AVPicture);\n\n goto the_end;\n\n }\n\n }\n\n#endif\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 && !avctx->frame_number)\n\n decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);\n\n\n\n return decode_chunks(avctx, picture, data_size, buf, buf_size);\n\n}\n", + "output": "0", + "index": 20554 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_band_structure(GetBitContext *gbc, int blk, int eac3,\n\n int ecpl, int start_subband, int end_subband,\n\n const uint8_t *default_band_struct,\n\n uint8_t *band_struct, int *num_subbands,\n\n int *num_bands, int *band_sizes)\n\n{\n\n int subbnd, bnd, n_subbands, n_bands, bnd_sz[22];\n\n\n\n n_subbands = end_subband - start_subband;\n\n\n\n /* decode band structure from bitstream or use default */\n\n if (!eac3 || get_bits1(gbc)) {\n\n for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {\n\n band_struct[subbnd] = get_bits1(gbc);\n\n }\n\n } else if (!blk) {\n\n memcpy(band_struct,\n\n &default_band_struct[start_subband+1],\n\n n_subbands-1);\n\n }\n\n band_struct[n_subbands-1] = 0;\n\n\n\n /* calculate number of bands and band sizes based on band structure.\n\n note that the first 4 subbands in enhanced coupling span only 6 bins\n\n instead of 12. */\n\n if (num_bands || band_sizes ) {\n\n n_bands = n_subbands;\n\n bnd_sz[0] = ecpl ? 6 : 12;\n\n for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {\n\n int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;\n\n if (band_struct[subbnd-1]) {\n\n n_bands--;\n\n bnd_sz[bnd] += subbnd_size;\n\n } else {\n\n bnd_sz[++bnd] = subbnd_size;\n\n }\n\n }\n\n }\n\n\n\n /* set optional output params */\n\n if (num_subbands)\n\n *num_subbands = n_subbands;\n\n if (num_bands)\n\n *num_bands = n_bands;\n\n if (band_sizes)\n\n memcpy(band_sizes, bnd_sz, sizeof(int)*n_bands);\n\n}\n", + "output": "1", + "index": 25412 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_h261_loop_filter(MpegEncContext *s){\n\n H261Context * h= (H261Context*)s;\n\n const int linesize = s->linesize;\n\n const int uvlinesize= s->uvlinesize;\n\n uint8_t *dest_y = s->dest[0];\n\n uint8_t *dest_cb= s->dest[1];\n\n uint8_t *dest_cr= s->dest[2];\n\n\n\n if(!(IS_FIL (h->mtype)))\n\n return;\n\n\n\n s->dsp.h261_loop_filter(dest_y , linesize);\n\n s->dsp.h261_loop_filter(dest_y + 8, linesize);\n\n s->dsp.h261_loop_filter(dest_y + 8 * linesize , linesize);\n\n s->dsp.h261_loop_filter(dest_y + 8 * linesize + 8, linesize);\n\n s->dsp.h261_loop_filter(dest_cb, uvlinesize);\n\n s->dsp.h261_loop_filter(dest_cr, uvlinesize);\n\n}\n", + "output": "0", + "index": 25311 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpegts_probe(AVProbeData *p)\n\n{\n\n const int size = p->buf_size;\n\n int score, fec_score, dvhs_score;\n\n int check_count = size / TS_FEC_PACKET_SIZE;\n\n#define CHECK_COUNT 10\n\n\n\n if (check_count < CHECK_COUNT)\n\n return AVERROR_INVALIDDATA;\n\n\n\n score = analyze(p->buf, TS_PACKET_SIZE * check_count,\n\n TS_PACKET_SIZE, NULL) * CHECK_COUNT / check_count;\n\n dvhs_score = analyze(p->buf, TS_DVHS_PACKET_SIZE * check_count,\n\n TS_DVHS_PACKET_SIZE, NULL) * CHECK_COUNT / check_count;\n\n fec_score = analyze(p->buf, TS_FEC_PACKET_SIZE * check_count,\n\n TS_FEC_PACKET_SIZE, NULL) * CHECK_COUNT / check_count;\n\n av_dlog(NULL, \"score: %d, dvhs_score: %d, fec_score: %d \\n\",\n\n score, dvhs_score, fec_score);\n\n\n\n /* we need a clear definition for the returned score otherwise\n\n * things will become messy sooner or later */\n\n if (score > fec_score && score > dvhs_score && score > 6)\n\n return AVPROBE_SCORE_MAX + score - CHECK_COUNT;\n\n else if (dvhs_score > score && dvhs_score > fec_score && dvhs_score > 6)\n\n return AVPROBE_SCORE_MAX + dvhs_score - CHECK_COUNT;\n\n else if (fec_score > 6)\n\n return AVPROBE_SCORE_MAX + fec_score - CHECK_COUNT;\n\n else\n\n return AVERROR_INVALIDDATA;\n\n}\n", + "output": "1", + "index": 5184 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_i_block(FourXContext *f, DCTELEM *block){\n int code, i, j, level, val;\n /* DC coef */\n val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);\n if (val>>4){\n av_log(f->avctx, AV_LOG_ERROR, \"error dc run != 0\\n\");\n if(val)\n val = get_xbits(&f->gb, val);\n val = val * dequant_table[0] + f->last_dc;\n f->last_dc =\n block[0] = val;\n /* AC coefs */\n i = 1;\n for(;;) {\n code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);\n /* EOB */\n if (code == 0)\n break;\n if (code == 0xf0) {\n i += 16;\n } else {\n level = get_xbits(&f->gb, code & 0xf);\n i += code >> 4;\n if (i >= 64) {\n av_log(f->avctx, AV_LOG_ERROR, \"run %d oveflow\\n\", i);\n return 0;\n j= ff_zigzag_direct[i];\n block[j] = level * dequant_table[j];\n i++;\n if (i >= 64)\n break;\n return 0;", + "output": "1", + "index": 15262 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_compat_2_0(MachineState *machine)\n\n{\n\n pc_compat_2_1(machine);\n\n smbios_legacy_mode = true;\n\n has_reserved_memory = false;\n\n pc_set_legacy_acpi_data_size();\n\n}\n", + "output": "0", + "index": 23120 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "set_interrupt_cause(E1000State *s, int index, uint32_t val)\n\n{\n\n if (val)\n\n val |= E1000_ICR_INT_ASSERTED;\n\n s->mac_reg[ICR] = val;\n\n s->mac_reg[ICS] = val;\n\n qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);\n\n}\n", + "output": "0", + "index": 15065 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct omap_mpuio_s *omap_mpuio_init(MemoryRegion *memory,\n\n target_phys_addr_t base,\n\n qemu_irq kbd_int, qemu_irq gpio_int, qemu_irq wakeup,\n\n omap_clk clk)\n\n{\n\n struct omap_mpuio_s *s = (struct omap_mpuio_s *)\n\n g_malloc0(sizeof(struct omap_mpuio_s));\n\n\n\n s->irq = gpio_int;\n\n s->kbd_irq = kbd_int;\n\n s->wakeup = wakeup;\n\n s->in = qemu_allocate_irqs(omap_mpuio_set, s, 16);\n\n omap_mpuio_reset(s);\n\n\n\n memory_region_init_io(&s->iomem, &omap_mpuio_ops, s,\n\n \"omap-mpuio\", 0x800);\n\n memory_region_add_subregion(memory, base, &s->iomem);\n\n\n\n omap_clk_adduser(clk, qemu_allocate_irqs(omap_mpuio_onoff, s, 1)[0]);\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 6393 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void create_fw_cfg(const VirtBoardInfo *vbi, AddressSpace *as)\n\n{\n\n hwaddr base = vbi->memmap[VIRT_FW_CFG].base;\n\n hwaddr size = vbi->memmap[VIRT_FW_CFG].size;\n\n char *nodename;\n\n\n\n fw_cfg_init_mem_wide(base + 8, base, 8, base + 16, as);\n\n\n\n nodename = g_strdup_printf(\"/fw-cfg@%\" PRIx64, base);\n\n qemu_fdt_add_subnode(vbi->fdt, nodename);\n\n qemu_fdt_setprop_string(vbi->fdt, nodename,\n\n \"compatible\", \"qemu,fw-cfg-mmio\");\n\n qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, \"reg\",\n\n 2, base, 2, size);\n\n g_free(nodename);\n\n}\n", + "output": "0", + "index": 5671 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool memory_region_present(MemoryRegion *parent, hwaddr addr)\n\n{\n\n MemoryRegion *mr = memory_region_find(parent, addr, 1).mr;\n\n if (!mr) {\n\n return false;\n\n }\n\n memory_region_unref(mr);\n\n return true;\n\n}\n", + "output": "0", + "index": 7783 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vnc_set_x509_credential(VncDisplay *vd,\n\n const char *certdir,\n\n const char *filename,\n\n char **cred,\n\n int ignoreMissing)\n\n{\n\n struct stat sb;\n\n\n\n g_free(*cred);\n\n *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);\n\n\n\n strcpy(*cred, certdir);\n\n strcat(*cred, \"/\");\n\n strcat(*cred, filename);\n\n\n\n VNC_DEBUG(\"Check %s\\n\", *cred);\n\n if (stat(*cred, &sb) < 0) {\n\n g_free(*cred);\n\n *cred = NULL;\n\n if (ignoreMissing && errno == ENOENT)\n\n return 0;\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 23666 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,\n\n const char *model,\n\n const char *name,\n\n int fd, int is_connected)\n\n{\n\n NetSocketState *s;\n\n s = qemu_mallocz(sizeof(NetSocketState));\n\n s->fd = fd;\n\n s->vc = qemu_new_vlan_client(vlan, model, name,\n\n net_socket_receive, NULL, s);\n\n snprintf(s->vc->info_str, sizeof(s->vc->info_str),\n\n \"socket: fd=%d\", fd);\n\n if (is_connected) {\n\n net_socket_connect(s);\n\n } else {\n\n qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);\n\n }\n\n return s;\n\n}\n", + "output": "1", + "index": 17771 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "floatx80 floatx80_scalbn( floatx80 a, int n STATUS_PARAM )\n\n{\n\n flag aSign;\n\n int16 aExp;\n\n uint64_t aSig;\n\n\n\n aSig = extractFloatx80Frac( a );\n\n aExp = extractFloatx80Exp( a );\n\n aSign = extractFloatx80Sign( a );\n\n\n\n if ( aExp == 0x7FF ) {\n\n return a;\n\n }\n\n if (aExp == 0 && aSig == 0)\n\n return a;\n\n\n\n aExp += n;\n\n return normalizeRoundAndPackFloatx80( STATUS(floatx80_rounding_precision),\n\n aSign, aExp, aSig, 0 STATUS_VAR );\n\n}\n", + "output": "1", + "index": 18497 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qdev_property_add_child(DeviceState *dev, const char *name,\n\n DeviceState *child, Error **errp)\n\n{\n\n gchar *type;\n\n\n\n type = g_strdup_printf(\"child<%s>\", child->info->name);\n\n\n\n qdev_property_add(dev, name, type, qdev_get_child_property,\n\n NULL, NULL, child, errp);\n\n\n\n qdev_ref(child);\n\n g_assert(child->parent == NULL);\n\n child->parent = dev;\n\n\n\n g_free(type);\n\n}\n", + "output": "0", + "index": 7554 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "matroska_read_close (AVFormatContext *s)\n\n{\n\n MatroskaDemuxContext *matroska = s->priv_data;\n\n int n = 0;\n\n\n\n if (matroska->writing_app)\n\n av_free(matroska->writing_app);\n\n if (matroska->muxing_app)\n\n av_free(matroska->muxing_app);\n\n if (matroska->index)\n\n av_free(matroska->index);\n\n\n\n if (matroska->packets != NULL) {\n\n for (n = 0; n < matroska->num_packets; n++) {\n\n av_free_packet(matroska->packets[n]);\n\n av_free(matroska->packets[n]);\n\n }\n\n av_free(matroska->packets);\n\n }\n\n\n\n for (n = 0; n < matroska->num_tracks; n++) {\n\n MatroskaTrack *track = matroska->tracks[n];\n\n if (track->codec_id)\n\n av_free(track->codec_id);\n\n if (track->codec_name)\n\n av_free(track->codec_name);\n\n if (track->codec_priv)\n\n av_free(track->codec_priv);\n\n if (track->name)\n\n av_free(track->name);\n\n if (track->language)\n\n av_free(track->language);\n\n\n\n av_free(track);\n\n }\n\n\n\n memset(matroska, 0, sizeof(MatroskaDemuxContext));\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21842 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,\n\n unsigned priority)\n\n{\n\n sysbus_mmio_map_common(dev, n, addr, true, priority);\n\n}\n", + "output": "0", + "index": 9945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)\n\n{\n\n USBDevice *udev = USB_DEVICE(s);\n\n struct libusb_config_descriptor *conf;\n\n int rc, i;\n\n\n\n for (i = 0; i < USB_MAX_INTERFACES; i++) {\n\n udev->altsetting[i] = 0;\n\n }\n\n udev->ninterfaces = 0;\n\n udev->configuration = 0;\n\n\n\n if (configuration == 0) {\n\n /* address state - ignore */\n\n return USB_RET_SUCCESS;\n\n }\n\n\n\n usb_host_detach_kernel(s);\n\n\n\n rc = libusb_get_active_config_descriptor(s->dev, &conf);\n\n if (rc != 0) {\n\n return USB_RET_STALL;\n\n }\n\n\n\n for (i = 0; i < conf->bNumInterfaces; i++) {\n\n trace_usb_host_claim_interface(s->bus_num, s->addr, configuration, i);\n\n rc = libusb_claim_interface(s->dh, i);\n\n usb_host_libusb_error(\"libusb_claim_interface\", rc);\n\n if (rc != 0) {\n\n return USB_RET_STALL;\n\n }\n\n s->ifs[i].claimed = true;\n\n }\n\n\n\n udev->ninterfaces = conf->bNumInterfaces;\n\n udev->configuration = configuration;\n\n\n\n libusb_free_config_descriptor(conf);\n\n return USB_RET_SUCCESS;\n\n}\n", + "output": "0", + "index": 11264 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool rtas_event_log_contains(uint32_t event_mask, bool exception)\n\n{\n\n sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());\n\n sPAPREventLogEntry *entry = NULL;\n\n\n\n /* we only queue EPOW events atm. */\n\n if ((event_mask & EVENT_MASK_EPOW) == 0) {\n\n return false;\n\n }\n\n\n\n QTAILQ_FOREACH(entry, &spapr->pending_events, next) {\n\n if (entry->exception != exception) {\n\n continue;\n\n }\n\n\n\n /* EPOW and hotplug events are surfaced in the same manner */\n\n if (entry->log_type == RTAS_LOG_TYPE_EPOW ||\n\n entry->log_type == RTAS_LOG_TYPE_HOTPLUG) {\n\n return true;\n\n }\n\n }\n\n\n\n return false;\n\n}\n", + "output": "0", + "index": 11678 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state)\n\n{\n\n QEMUFileBuffered *s;\n\n\n\n s = g_malloc0(sizeof(*s));\n\n\n\n s->migration_state = migration_state;\n\n s->xfer_limit = migration_state->bandwidth_limit / 10;\n\n\n\n s->file = qemu_fopen_ops(s, &buffered_file_ops);\n\n\n\n s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s);\n\n\n\n qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100);\n\n\n\n return s->file;\n\n}\n", + "output": "0", + "index": 22212 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_lswi(DisasContext *ctx)\n\n{\n\n TCGv t0;\n\n TCGv_i32 t1, t2;\n\n int nb = NB(ctx->opcode);\n\n int start = rD(ctx->opcode);\n\n int ra = rA(ctx->opcode);\n\n int nr;\n\n\n\n if (nb == 0)\n\n nb = 32;\n\n nr = (nb + 3) / 4;\n\n if (unlikely(lsw_reg_in_range(start, nr, ra))) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);\n\n return;\n\n }\n\n gen_set_access_type(ctx, ACCESS_INT);\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 t0 = tcg_temp_new();\n\n gen_addr_register(ctx, t0);\n\n t1 = tcg_const_i32(nb);\n\n t2 = tcg_const_i32(start);\n\n gen_helper_lsw(cpu_env, t0, t1, t2);\n\n tcg_temp_free(t0);\n\n tcg_temp_free_i32(t1);\n\n tcg_temp_free_i32(t2);\n\n}\n", + "output": "1", + "index": 3182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int setup_common(char *argv[], int argv_sz)\n\n{\n\n memset(cur_ide, 0, sizeof(cur_ide));\n\n return append_arg(0, argv, argv_sz,\n\n g_strdup(\"-nodefaults -display none\"));\n\n}\n", + "output": "1", + "index": 10726 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,\n\n void *value, size_t vsize)\n\n{\n\n ssize_t size = 0;\n\n char *buffer;\n\n void *ovalue = value;\n\n XattrOperations *xops;\n\n char *orig_value, *orig_value_start;\n\n ssize_t xattr_len, parsed_len = 0, attr_len;\n\n\n\n /* Get the actual len */\n\n buffer = rpath(ctx, path);\n\n xattr_len = llistxattr(buffer, value, 0);\n\n if (xattr_len <= 0) {\n\n g_free(buffer);\n\n return xattr_len;\n\n }\n\n\n\n /* Now fetch the xattr and find the actual size */\n\n orig_value = g_malloc(xattr_len);\n\n xattr_len = llistxattr(buffer, orig_value, xattr_len);\n\n g_free(buffer);\n\n\n\n /* store the orig pointer */\n\n orig_value_start = orig_value;\n\n while (xattr_len > parsed_len) {\n\n xops = get_xattr_operations(ctx->xops, orig_value);\n\n if (!xops) {\n\n goto next_entry;\n\n }\n\n\n\n if (!value) {\n\n size += xops->listxattr(ctx, path, orig_value, value, vsize);\n\n } else {\n\n size = xops->listxattr(ctx, path, orig_value, value, vsize);\n\n if (size < 0) {\n\n goto err_out;\n\n }\n\n value += size;\n\n vsize -= size;\n\n }\n\nnext_entry:\n\n /* Got the next entry */\n\n attr_len = strlen(orig_value) + 1;\n\n parsed_len += attr_len;\n\n orig_value += attr_len;\n\n }\n\n if (value) {\n\n size = value - ovalue;\n\n }\n\n\n\nerr_out:\n\n g_free(orig_value_start);\n\n return size;\n\n}\n", + "output": "1", + "index": 20418 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bios_linker_loader_add_checksum(GArray *linker, const char *file,\n\n GArray *table,\n\n void *start, unsigned size,\n\n uint8_t *checksum)\n\n{\n\n BiosLinkerLoaderEntry entry;\n\n ptrdiff_t checksum_offset = (gchar *)checksum - table->data;\n\n ptrdiff_t start_offset = (gchar *)start - table->data;\n\n\n\n assert(checksum_offset >= 0);\n\n assert(start_offset >= 0);\n\n assert(checksum_offset + 1 <= table->len);\n\n assert(start_offset + size <= table->len);\n\n assert(*checksum == 0x0);\n\n\n\n memset(&entry, 0, sizeof entry);\n\n strncpy(entry.cksum.file, file, sizeof entry.cksum.file - 1);\n\n entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM);\n\n entry.cksum.offset = cpu_to_le32(checksum_offset);\n\n entry.cksum.start = cpu_to_le32(start_offset);\n\n entry.cksum.length = cpu_to_le32(size);\n\n\n\n g_array_append_vals(linker, &entry, sizeof entry);\n\n}\n", + "output": "0", + "index": 8937 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_hybrid_window(int order, int n, int non_rec, const float *in,\n\n float *out, float *hist, float *out2,\n\n const float *window)\n\n{\n\n int i;\n\n float buffer1[order + 1];\n\n float buffer2[order + 1];\n\n float work[order + n + non_rec];\n\n\n\n /* update history */\n\n memmove(hist, hist + n, (order + non_rec)*sizeof(*hist));\n\n\n\n for (i=0; i < n; i++)\n\n hist[order + non_rec + i] = in[n-i-1];\n\n\n\n colmult(work, window, hist, order + n + non_rec);\n\n\n\n convolve(buffer1, work + order , n , order);\n\n convolve(buffer2, work + order + n, non_rec, order);\n\n\n\n for (i=0; i <= order; i++) {\n\n out2[i] = out2[i] * 0.5625 + buffer1[i];\n\n out [i] = out2[i] + buffer2[i];\n\n }\n\n\n\n /* Multiply by the white noise correcting factor (WNCF) */\n\n *out *= 257./256.;\n\n}\n", + "output": "0", + "index": 15942 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s)\n\n{\n\n if (s->state & PNG_IDAT) {\n\n av_log(avctx, AV_LOG_ERROR, \"pHYs after IDAT\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n avctx->sample_aspect_ratio.num = bytestream2_get_be32(&s->gb);\n\n avctx->sample_aspect_ratio.den = bytestream2_get_be32(&s->gb);\n\n if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0)\n\n avctx->sample_aspect_ratio = (AVRational){ 0, 1 };\n\n bytestream2_skip(&s->gb, 1); /* unit specifier */\n\n bytestream2_skip(&s->gb, 4); /* crc */\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 2103 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TRBCCode xhci_disable_ep(XHCIState *xhci, unsigned int slotid,\n unsigned int epid)\n{\n XHCISlot *slot;\n XHCIEPContext *epctx;\n int i;\n trace_usb_xhci_ep_disable(slotid, epid);\n assert(slotid >= 1 && slotid <= xhci->numslots);\n assert(epid >= 1 && epid <= 31);\n slot = &xhci->slots[slotid-1];\n if (!slot->eps[epid-1]) {\n DPRINTF(\"xhci: slot %d ep %d already disabled\\n\", slotid, epid);\n return CC_SUCCESS;\n xhci_ep_nuke_xfers(xhci, slotid, epid);\n epctx = slot->eps[epid-1];\n if (epctx->nr_pstreams) {\n xhci_free_streams(epctx);\n xhci_set_ep_state(xhci, epctx, NULL, EP_DISABLED);\n timer_free(epctx->kick_timer);\n g_free(epctx);\n slot->eps[epid-1] = NULL;\n return CC_SUCCESS;", + "output": "1", + "index": 9189 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static SocketAddress *sd_socket_address(const char *path,\n\n const char *host, const char *port)\n\n{\n\n SocketAddress *addr = g_new0(SocketAddress, 1);\n\n\n\n if (path) {\n\n addr->type = SOCKET_ADDRESS_KIND_UNIX;\n\n addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);\n\n addr->u.q_unix.data->path = g_strdup(path);\n\n } else {\n\n addr->type = SOCKET_ADDRESS_KIND_INET;\n\n addr->u.inet.data = g_new0(InetSocketAddress, 1);\n\n addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);\n\n addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));\n\n }\n\n\n\n return addr;\n\n}\n", + "output": "0", + "index": 10242 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *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 CPUState *cs = CPU(cpu);\n\n CPUPPCState *env = &cpu->env;\n\n\n\n\n cs->halted = 1;\n\n qemu_cpu_kick(cs);\n\n /*\n\n * While stopping a CPU, the guest calls H_CPPR which\n\n * effectively disables interrupts on XICS level.\n\n * However decrementer interrupts in TCG can still\n\n * wake the CPU up so here we disable interrupts in MSR\n\n * as well.\n\n * As rtas_start_cpu() resets the whole MSR anyway, there is\n\n * no need to bother with specific bits, we just clear it.\n\n */\n\n env->msr = 0;\n\n\n\n /* Disable Power-saving mode Exit Cause exceptions for the CPU.\n\n * This could deliver an interrupt on a dying CPU and crash the\n\n * guest */\n\n env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;\n\n}", + "output": "1", + "index": 2772 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_http_do_new_request(URLContext *h, const char *uri)\n{\n HTTPContext *s = h->priv_data;\n AVDictionary *options = NULL;\n int ret;\n ret = http_shutdown(h, h->flags);\n if (ret < 0)\n return ret;\n s->end_chunked_post = 0;\n s->chunkend = 0;\n s->off = 0;\n s->icy_data_read = 0;\n av_free(s->location);\n s->location = av_strdup(uri);\n if (!s->location)\n return AVERROR(ENOMEM);\n ret = http_open_cnx(h, &options);\n av_dict_free(&options);\n return ret;", + "output": "1", + "index": 11990 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_cabac_mb_dqp( H264Context *h) {\n\n MpegEncContext * const s = &h->s;\n\n int mbn_xy;\n\n int ctx = 0;\n\n int val = 0;\n\n\n\n if( s->mb_x > 0 )\n\n mbn_xy = s->mb_x + s->mb_y*s->mb_stride - 1;\n\n else\n\n mbn_xy = s->mb_width - 1 + (s->mb_y-1)*s->mb_stride;\n\n\n\n if( h->last_qscale_diff != 0 )\n\n ctx++;\n\n\n\n while( get_cabac( &h->cabac, &h->cabac_state[60 + ctx] ) ) {\n\n if( ctx < 2 )\n\n ctx = 2;\n\n else\n\n ctx = 3;\n\n val++;\n\n if(val > 102) //prevent infinite loop\n\n return INT_MIN;\n\n }\n\n\n\n if( val&0x01 )\n\n return (val + 1)/2;\n\n else\n\n return -(val + 1)/2;\n\n}\n", + "output": "0", + "index": 24762 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xan_huffman_decode(unsigned char *dest, unsigned char *src)\n\n{\n\n unsigned char byte = *src++;\n\n unsigned char ival = byte + 0x16;\n\n unsigned char * ptr = src + byte*2;\n\n unsigned char val = ival;\n\n int counter = 0;\n\n\n\n unsigned char bits = *ptr++;\n\n\n\n while ( val != 0x16 ) {\n\n if ( (1 << counter) & bits )\n\n val = src[byte + val - 0x17];\n\n else\n\n val = src[val - 0x17];\n\n\n\n if ( val < 0x16 ) {\n\n *dest++ = val;\n\n val = ival;\n\n }\n\n\n\n if (counter++ == 7) {\n\n counter = 0;\n\n bits = *ptr++;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 20903 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void icount_adjust_rt(void * opaque)\n\n{\n\n qemu_mod_timer(icount_rt_timer,\n\n qemu_get_clock(rt_clock) + 1000);\n\n icount_adjust();\n\n}\n", + "output": "0", + "index": 11905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int srt_decode_frame(AVCodecContext *avctx,\n\n void *data, int *got_sub_ptr, AVPacket *avpkt)\n\n{\n\n AVSubtitle *sub = data;\n\n AVBPrint buffer;\n\n int x1 = -1, y1 = -1, x2 = -1, y2 = -1;\n\n int size, ret;\n\n const uint8_t *p = av_packet_get_side_data(avpkt, AV_PKT_DATA_SUBTITLE_POSITION, &size);\n\n FFASSDecoderContext *s = avctx->priv_data;\n\n\n\n if (p && size == 16) {\n\n x1 = AV_RL32(p );\n\n y1 = AV_RL32(p + 4);\n\n x2 = AV_RL32(p + 8);\n\n y2 = AV_RL32(p + 12);\n\n }\n\n\n\n if (avpkt->size <= 0)\n\n return avpkt->size;\n\n\n\n av_bprint_init(&buffer, 0, AV_BPRINT_SIZE_UNLIMITED);\n\n\n\n srt_to_ass(avctx, &buffer, avpkt->data, x1, y1, x2, y2);\n\n ret = ff_ass_add_rect(sub, buffer.str, s->readorder++, 0, NULL, NULL);\n\n av_bprint_finalize(&buffer, NULL);\n\n if (ret < 0)\n\n return ret;\n\n\n\n *got_sub_ptr = sub->num_rects > 0;\n\n return avpkt->size;\n\n}\n", + "output": "0", + "index": 6708 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline SoftFloat autocorr_calc(int64_t accu)\n\n{\n\n int nz, mant, expo, round;\n\n int i = (int)(accu >> 32);\n\n if (i == 0) {\n\n nz = 1;\n\n } else {\n\n nz = 0;\n\n while (FFABS(i) < 0x40000000) {\n\n i <<= 1;\n\n nz++;\n\n }\n\n nz = 32-nz;\n\n }\n\n\n\n round = 1 << (nz-1);\n\n mant = (int)((accu + round) >> nz);\n\n mant = (mant + 0x40)>>7;\n\n mant <<= 6;\n\n expo = nz + 15;\n\n return av_int2sf(mant, 30 - expo);\n\n}\n", + "output": "1", + "index": 9610 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockDriverState *bdrv_next_node(BlockDriverState *bs)\n\n{\n\n if (!bs) {\n\n return QTAILQ_FIRST(&graph_bdrv_states);\n\n }\n\n return QTAILQ_NEXT(bs, node_list);\n\n}\n", + "output": "0", + "index": 7835 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)\n\n{\n\n BusState *bus;\n\n char *buf;\n\n int i,len;\n\n\n\n bus = qemu_mallocz(info->size);\n\n bus->info = info;\n\n bus->parent = parent;\n\n\n\n if (name) {\n\n /* use supplied name */\n\n bus->name = qemu_strdup(name);\n\n } else if (parent && parent->id) {\n\n /* parent device has id -> use it for bus name */\n\n len = strlen(parent->id) + 16;\n\n buf = qemu_malloc(len);\n\n snprintf(buf, len, \"%s.%d\", parent->id, parent->num_child_bus);\n\n bus->name = buf;\n\n } else {\n\n /* no id -> use lowercase bus type for bus name */\n\n len = strlen(info->name) + 16;\n\n buf = qemu_malloc(len);\n\n len = snprintf(buf, len, \"%s.%d\", info->name,\n\n parent ? parent->num_child_bus : 0);\n\n for (i = 0; i < len; i++)\n\n buf[i] = qemu_tolower(buf[i]);\n\n bus->name = buf;\n\n }\n\n\n\n LIST_INIT(&bus->children);\n\n if (parent) {\n\n LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);\n\n parent->num_child_bus++;\n\n }\n\n return bus;\n\n}\n", + "output": "0", + "index": 3934 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,\n\n Error **errp)\n\n{\n\n BlockInfo *info = g_malloc0(sizeof(*info));\n\n BlockDriverState *bs = blk_bs(blk);\n\n BlockDriverState *bs0;\n\n ImageInfo **p_image_info;\n\n Error *local_err = NULL;\n\n info->device = g_strdup(blk_name(blk));\n\n info->type = g_strdup(\"unknown\");\n\n info->locked = blk_dev_is_medium_locked(blk);\n\n info->removable = blk_dev_has_removable_media(blk);\n\n\n\n if (blk_dev_has_removable_media(blk)) {\n\n info->has_tray_open = true;\n\n info->tray_open = blk_dev_is_tray_open(blk);\n\n }\n\n\n\n if (bdrv_iostatus_is_enabled(bs)) {\n\n info->has_io_status = true;\n\n info->io_status = bs->iostatus;\n\n }\n\n\n\n if (!QLIST_EMPTY(&bs->dirty_bitmaps)) {\n\n info->has_dirty_bitmaps = true;\n\n info->dirty_bitmaps = bdrv_query_dirty_bitmaps(bs);\n\n }\n\n\n\n if (bs->drv) {\n\n info->has_inserted = true;\n\n info->inserted = bdrv_block_device_info(bs);\n\n\n\n bs0 = bs;\n\n p_image_info = &info->inserted->image;\n\n while (1) {\n\n bdrv_query_image_info(bs0, p_image_info, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n goto err;\n\n }\n\n if (bs0->drv && bs0->backing_hd) {\n\n bs0 = bs0->backing_hd;\n\n (*p_image_info)->has_backing_image = true;\n\n p_image_info = &((*p_image_info)->backing_image);\n\n } else {\n\n break;\n\n }\n\n }\n\n }\n\n\n\n *p_info = info;\n\n return;\n\n\n\n err:\n\n qapi_free_BlockInfo(info);\n\n}\n", + "output": "1", + "index": 23834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_divduo (void)\n\n{\n\n if (likely((uint64_t)T1 != 0)) {\n\n xer_ov = 0;\n\n T0 = (uint64_t)T0 / (uint64_t)T1;\n\n } else {\n\n xer_so = 1;\n\n xer_ov = 1;\n\n T0 = 0;\n\n }\n\n}\n", + "output": "1", + "index": 1747 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool hpet_find(void)\n\n{\n\n return object_resolve_path_type(\"\", TYPE_HPET, NULL);\n\n}\n", + "output": "0", + "index": 10200 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int onenand_load_main(OneNANDState *s, int sec, int secn,\n\n void *dest)\n\n{\n\n if (s->bdrv_cur)\n\n return bdrv_read(s->bdrv_cur, sec, dest, secn) < 0;\n\n else if (sec + secn > s->secs_cur)\n\n return 1;\n\n\n\n memcpy(dest, s->current + (sec << 9), secn << 9);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 319 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc,\n\n const int16_t *chrUSrc, const int16_t *chrVSrc,\n\n const int16_t *alpSrc,\n\n uint8_t *dest, uint8_t *uDest, uint8_t *vDest,\n\n uint8_t *aDest, int dstW, int chrDstW)\n\n{\n\n int p= 4;\n\n const uint8_t *src[4]= { alpSrc + dstW, lumSrc + dstW, chrUSrc + chrDstW, chrVSrc + chrDstW };\n\n uint8_t *dst[4]= { aDest, dest, uDest, vDest };\n\n x86_reg counter[4]= { dstW, dstW, chrDstW, chrDstW };\n\n\n\n while (p--) {\n\n if (dst[p]) {\n\n __asm__ volatile(\n\n \"mov %2, %%\"REG_a\" \\n\\t\"\n\n \".p2align 4 \\n\\t\" /* FIXME Unroll? */\n\n \"1: \\n\\t\"\n\n \"movq (%0, %%\"REG_a\", 2), %%mm0 \\n\\t\"\n\n \"movq 8(%0, %%\"REG_a\", 2), %%mm1 \\n\\t\"\n\n \"psraw $7, %%mm0 \\n\\t\"\n\n \"psraw $7, %%mm1 \\n\\t\"\n\n \"packuswb %%mm1, %%mm0 \\n\\t\"\n\n MOVNTQ(%%mm0, (%1, %%REGa))\n\n \"add $8, %%\"REG_a\" \\n\\t\"\n\n \"jnc 1b \\n\\t\"\n\n :: \"r\" (src[p]), \"r\" (dst[p] + counter[p]),\n\n \"g\" (-counter[p])\n\n : \"%\"REG_a\n\n );\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 26280 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int blah (int32_t i)\n\n{\n\n if (i > 0x43c07fff)\n\n return 32767;\n\n else if (i < 0x43bf8000)\n\n return -32768;\n\n else\n\n return i - 0x43c00000;\n\n}\n", + "output": "0", + "index": 20536 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)\n\n{\n\n int i, err;\n\n AVFormatContext *ic = avformat_alloc_context();\n\n\n\n\n\n ic->interrupt_callback = int_cb;\n\n err = avformat_open_input(&ic, filename, NULL, NULL);\n\n if (err < 0)\n\n return err;\n\n /* copy stream format */\n\n for(i=0;inb_streams;i++) {\n\n AVStream *st;\n\n OutputStream *ost;\n\n AVCodec *codec;\n\n const char *enc_config;\n\n\n\n codec = avcodec_find_encoder(ic->streams[i]->codecpar->codec_id);\n\n if (!codec) {\n\n av_log(s, AV_LOG_ERROR, \"no encoder found for codec id %i\\n\", ic->streams[i]->codecpar->codec_id);\n\n return AVERROR(EINVAL);\n\n }\n\n if (codec->type == AVMEDIA_TYPE_AUDIO)\n\n opt_audio_codec(o, \"c:a\", codec->name);\n\n else if (codec->type == AVMEDIA_TYPE_VIDEO)\n\n opt_video_codec(o, \"c:v\", codec->name);\n\n ost = new_output_stream(o, s, codec->type, -1);\n\n st = ost->st;\n\n\n\n avcodec_get_context_defaults3(st->codec, codec);\n\n enc_config = av_stream_get_recommended_encoder_configuration(ic->streams[i]);\n\n if (enc_config) {\n\n AVDictionary *opts = NULL;\n\n av_dict_parse_string(&opts, enc_config, \"=\", \",\", 0);\n\n av_opt_set_dict2(st->codec, &opts, AV_OPT_SEARCH_CHILDREN);\n\n av_dict_free(&opts);\n\n }\n\n\n\n if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)\n\n choose_sample_fmt(st, codec);\n\n else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)\n\n choose_pixel_fmt(st, st->codec, codec, st->codecpar->format);\n\n avcodec_copy_context(ost->enc_ctx, st->codec);\n\n if (enc_config)\n\n av_dict_parse_string(&ost->encoder_opts, enc_config, \"=\", \",\", 0);\n\n }\n\n\n\n avformat_close_input(&ic);\n\n return err;\n\n}", + "output": "1", + "index": 5527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_enum(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n Error *err = NULL;\n\n Visitor *v;\n\n EnumOne i;\n\n\n\n for (i = 0; EnumOne_lookup[i]; i++) {\n\n EnumOne res = -1;\n\n\n\n v = visitor_input_test_init(data, \"%s\", EnumOne_lookup[i]);\n\n\n\n visit_type_EnumOne(v, &res, NULL, &err);\n\n g_assert(!err);\n\n g_assert_cmpint(i, ==, res);\n\n }\n\n}\n", + "output": "0", + "index": 16320 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_input_key_value_to_qcode(const KeyValue *value)\n\n{\n\n if (value->type == KEY_VALUE_KIND_QCODE) {\n\n return value->u.qcode;\n\n } else {\n\n assert(value->type == KEY_VALUE_KIND_NUMBER);\n\n return qemu_input_key_number_to_qcode(value->u.number);\n\n }\n\n}\n", + "output": "0", + "index": 10530 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tcg_region_init(void)\n\n{\n\n void *buf = tcg_init_ctx.code_gen_buffer;\n\n void *aligned;\n\n size_t size = tcg_init_ctx.code_gen_buffer_size;\n\n size_t page_size = qemu_real_host_page_size;\n\n size_t region_size;\n\n size_t n_regions;\n\n size_t i;\n\n\n\n /* We do not yet support multiple TCG contexts, so use one region for now */\n\n n_regions = 1;\n\n\n\n /* The first region will be 'aligned - buf' bytes larger than the others */\n\n aligned = QEMU_ALIGN_PTR_UP(buf, page_size);\n\n g_assert(aligned < tcg_init_ctx.code_gen_buffer + size);\n\n /*\n\n * Make region_size a multiple of page_size, using aligned as the start.\n\n * As a result of this we might end up with a few extra pages at the end of\n\n * the buffer; we will assign those to the last region.\n\n */\n\n region_size = (size - (aligned - buf)) / n_regions;\n\n region_size = QEMU_ALIGN_DOWN(region_size, page_size);\n\n\n\n /* A region must have at least 2 pages; one code, one guard */\n\n g_assert(region_size >= 2 * page_size);\n\n\n\n /* init the region struct */\n\n qemu_mutex_init(®ion.lock);\n\n region.n = n_regions;\n\n region.size = region_size - page_size;\n\n region.stride = region_size;\n\n region.start = buf;\n\n region.start_aligned = aligned;\n\n /* page-align the end, since its last page will be a guard page */\n\n region.end = QEMU_ALIGN_PTR_DOWN(buf + size, page_size);\n\n /* account for that last guard page */\n\n region.end -= page_size;\n\n\n\n /* set guard pages */\n\n for (i = 0; i < region.n; i++) {\n\n void *start, *end;\n\n int rc;\n\n\n\n tcg_region_bounds(i, &start, &end);\n\n rc = qemu_mprotect_none(end, page_size);\n\n g_assert(!rc);\n\n }\n\n\n\n /* We do not yet support multiple TCG contexts so allocate the region now */\n\n {\n\n bool err = tcg_region_initial_alloc__locked(tcg_ctx);\n\n\n\n g_assert(!err);\n\n }\n\n}\n", + "output": "0", + "index": 26570 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dma_aio_cancel(BlockDriverAIOCB *acb)\n\n{\n\n DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);\n\n\n\n if (dbs->acb) {\n\n bdrv_aio_cancel(dbs->acb);\n\n }\n\n}\n", + "output": "1", + "index": 1859 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Jpeg2000TgtNode *ff_j2k_tag_tree_init(int w, int h)\n\n{\n\n int pw = w, ph = h;\n\n Jpeg2000TgtNode *res, *t, *t2;\n\n int32_t tt_size;\n\n\n\n tt_size = tag_tree_size(w, h);\n\n\n\n t = res = av_mallocz(tt_size, sizeof(*t));\n\n if (!res)\n\n return NULL;\n\n\n\n while (w > 1 || h > 1) {\n\n int i, j;\n\n pw = w;\n\n ph = h;\n\n\n\n w = (w + 1) >> 1;\n\n h = (h + 1) >> 1;\n\n t2 = t + pw * ph;\n\n\n\n for (i = 0; i < ph; i++)\n\n for (j = 0; j < pw; j++)\n\n t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];\n\n\n\n t = t2;\n\n }\n\n t[0].parent = NULL;\n\n return res;\n\n}\n", + "output": "1", + "index": 11222 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)\n\n{\n\n time_t t = 631112400LL + 86400*av_int2dbl(value);\n\n strftime(buf, buf_size, \"%Y-%m-%d %H:%M:%S\", gmtime(&t));\n\n}\n", + "output": "1", + "index": 18295 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,\n\n uint8_t devfn, VTDContextEntry *ce)\n\n{\n\n VTDRootEntry re;\n\n int ret_fr;\n\n\n\n ret_fr = vtd_get_root_entry(s, bus_num, &re);\n\n if (ret_fr) {\n\n return ret_fr;\n\n }\n\n\n\n if (!vtd_root_entry_present(&re)) {\n\n /* Not error - it's okay we don't have root entry. */\n\n trace_vtd_re_not_present(bus_num);\n\n return -VTD_FR_ROOT_ENTRY_P;\n\n } else if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD)) {\n\n trace_vtd_re_invalid(re.rsvd, re.val);\n\n return -VTD_FR_ROOT_ENTRY_RSVD;\n\n }\n\n\n\n ret_fr = vtd_get_context_entry_from_root(&re, devfn, ce);\n\n if (ret_fr) {\n\n return ret_fr;\n\n }\n\n\n\n if (!vtd_ce_present(ce)) {\n\n /* Not error - it's okay we don't have context entry. */\n\n trace_vtd_ce_not_present(bus_num, devfn);\n\n return -VTD_FR_CONTEXT_ENTRY_P;\n\n } else if ((ce->hi & VTD_CONTEXT_ENTRY_RSVD_HI) ||\n\n (ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO)) {\n\n trace_vtd_ce_invalid(ce->hi, ce->lo);\n\n return -VTD_FR_CONTEXT_ENTRY_RSVD;\n\n }\n\n /* Check if the programming of context-entry is valid */\n\n if (!vtd_is_level_supported(s, vtd_ce_get_level(ce))) {\n\n trace_vtd_ce_invalid(ce->hi, ce->lo);\n\n return -VTD_FR_CONTEXT_ENTRY_INV;\n\n } else {\n\n switch (vtd_ce_get_type(ce)) {\n\n case VTD_CONTEXT_TT_MULTI_LEVEL:\n\n /* fall through */\n\n case VTD_CONTEXT_TT_DEV_IOTLB:\n\n break;\n\n default:\n\n trace_vtd_ce_invalid(ce->hi, ce->lo);\n\n return -VTD_FR_CONTEXT_ENTRY_INV;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 15761 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_xvmc_field_end(MpegEncContext *s)\n\n{\n\n struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];\n\n assert(render);\n\n\n\n if (render->filled_mv_blocks_num > 0)\n\n ff_mpeg_draw_horiz_band(s, 0, 0);\n\n}\n", + "output": "0", + "index": 21224 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow_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 = 65536;\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 qcow_create2(filename, sectors, backing_file, backing_fmt, flags,\n\n cluster_size, prealloc);\n\n}\n", + "output": "0", + "index": 2803 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool virtio_pci_modern_state_needed(void *opaque)\n\n{\n\n VirtIOPCIProxy *proxy = opaque;\n\n\n\n return !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);\n\n}\n", + "output": "0", + "index": 6303 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int proxy_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)\n\n{\n\n int retval;\n\n retval = v9fs_request(fs_ctx->private, T_CHMOD, NULL, \"sd\",\n\n fs_path, credp->fc_mode);\n\n if (retval < 0) {\n\n errno = -retval;\n\n }\n\n return retval;\n\n}\n", + "output": "0", + "index": 22398 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void uc32_cpu_class_init(ObjectClass *oc, void *data)\n{\n DeviceClass *dc = DEVICE_CLASS(oc);\n CPUClass *cc = CPU_CLASS(oc);\n UniCore32CPUClass *ucc = UNICORE32_CPU_CLASS(oc);\n ucc->parent_realize = dc->realize;\n dc->realize = uc32_cpu_realizefn;\n cc->class_by_name = uc32_cpu_class_by_name;\n cc->has_work = uc32_cpu_has_work;\n cc->do_interrupt = uc32_cpu_do_interrupt;\n cc->cpu_exec_interrupt = uc32_cpu_exec_interrupt;\n cc->dump_state = uc32_cpu_dump_state;\n cc->set_pc = uc32_cpu_set_pc;\n#ifdef CONFIG_USER_ONLY\n cc->handle_mmu_fault = uc32_cpu_handle_mmu_fault;\n#else\n cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;\n#endif\n dc->vmsd = &vmstate_uc32_cpu;\n}", + "output": "1", + "index": 19560 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_h264_check_intra4x4_pred_mode(H264Context *h){\n\n MpegEncContext * const s = &h->s;\n\n static const int8_t top [12]= {-1, 0,LEFT_DC_PRED,-1,-1,-1,-1,-1, 0};\n\n static const int8_t left[12]= { 0,-1, TOP_DC_PRED, 0,-1,-1,-1, 0,-1,DC_128_PRED};\n\n int i;\n\n\n\n if(!(h->top_samples_available&0x8000)){\n\n for(i=0; i<4; i++){\n\n int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ];\n\n if(status<0){\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"top block unavailable for requested intra4x4 mode %d at %d %d\\n\", status, s->mb_x, s->mb_y);\n\n return -1;\n\n } else if(status){\n\n h->intra4x4_pred_mode_cache[scan8[0] + i]= status;\n\n }\n\n }\n\n }\n\n\n\n if((h->left_samples_available&0x8888)!=0x8888){\n\n static const int mask[4]={0x8000,0x2000,0x80,0x20};\n\n for(i=0; i<4; i++){\n\n if(!(h->left_samples_available&mask[i])){\n\n int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ];\n\n if(status<0){\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"left block unavailable for requested intra4x4 mode %d at %d %d\\n\", status, s->mb_x, s->mb_y);\n\n return -1;\n\n } else if(status){\n\n h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status;\n\n }\n\n }\n\n }\n\n }\n\n\n\n return 0;\n\n} //FIXME cleanup like ff_h264_check_intra_pred_mode\n", + "output": "0", + "index": 8741 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,\n\n int *beta, int *tc, uint8_t *no_p,\n\n uint8_t *no_q)\n\n{\n\n FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,\n\n beta, tc, no_p, no_q);\n\n}\n", + "output": "0", + "index": 3607 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv)\n\n{\n\n TPMInfo *res = g_new0(TPMInfo, 1);\n\n TPMPassthroughOptions *tpo;\n\n\n\n res->id = g_strdup(drv->id);\n\n res->model = drv->fe_model;\n\n res->options = g_new0(TpmTypeOptions, 1);\n\n\n\n switch (drv->ops->type) {\n\n case TPM_TYPE_PASSTHROUGH:\n\n res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH;\n\n tpo = g_new0(TPMPassthroughOptions, 1);\n\n res->options->u.passthrough = tpo;\n\n if (drv->path) {\n\n tpo->path = g_strdup(drv->path);\n\n tpo->has_path = true;\n\n }\n\n if (drv->cancel_path) {\n\n tpo->cancel_path = g_strdup(drv->cancel_path);\n\n tpo->has_cancel_path = true;\n\n }\n\n break;\n\n case TPM_TYPE__MAX:\n\n break;\n\n }\n\n\n\n return res;\n\n}\n", + "output": "0", + "index": 26462 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame,\n\n AVPacket *avpkt)\n\n{\n\n uint64_t frame_size = (uint64_t)avctx->width * (uint64_t)avctx->height * 20;\n\n uint64_t packet_size = avpkt->size * 8;\n\n GetBitContext bc;\n\n uint16_t *y, *u, *v;\n\n int ret, i;\n\n\n\n ret = ff_get_buffer(avctx, frame, 0);\n\n if (ret < 0)\n\n return ret;\n\n\n\n y = (uint16_t*)frame->data[0];\n\n u = (uint16_t*)frame->data[1];\n\n v = (uint16_t*)frame->data[2];\n\n\n\n if (frame_size > packet_size)\n\n return AVERROR_INVALIDDATA;\n\n\n\n if (avctx->width % 2)\n\n return AVERROR_PATCHWELCOME;\n\n\n\n ret = init_get_bits(&bc, avpkt->data, avctx->width * avctx->height * 20);\n\n if (ret)\n\n return ret;\n\n\n\n for (i = 0; i < avctx->height; i++) {\n\n y = (uint16_t*)(frame->data[0] + i * frame->linesize[0]);\n\n u = (uint16_t*)(frame->data[1] + i * frame->linesize[1]);\n\n v = (uint16_t*)(frame->data[2] + i * frame->linesize[2]);\n\n\n\n for (int j = 0; j < avctx->width; j += 2) {\n\n *u++ = get_bits(&bc, 10);\n\n *y++ = get_bits(&bc, 10);\n\n *v++ = get_bits(&bc, 10);\n\n *y++ = get_bits(&bc, 10);\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 17812 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int i, nb_clusters;\n\n\n\n nb_clusters = size_to_clusters(s, size);\n\nretry:\n\n for(i = 0; i < nb_clusters; i++) {\n\n int64_t i = s->free_cluster_index++;\n\n if (get_refcount(bs, i) != 0)\n\n goto retry;\n\n }\n\n#ifdef DEBUG_ALLOC2\n\n printf(\"alloc_clusters: size=%\" PRId64 \" -> %\" PRId64 \"\\n\",\n\n size,\n\n (s->free_cluster_index - nb_clusters) << s->cluster_bits);\n\n#endif\n\n return (s->free_cluster_index - nb_clusters) << s->cluster_bits;\n\n}\n", + "output": "0", + "index": 23055 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, void *target)\n\n{\n\n uintptr_t dest = (uintptr_t)target;\n\n uintptr_t from = (uintptr_t)s->code_ptr + 4;\n\n int32_t inst;\n\n\n\n /* The pc-region branch happens within the 256MB region of\n\n the delay slot (thus the +4). */\n\n if ((from ^ dest) & -(1 << 28)) {\n\n return false;\n\n }\n\n assert((dest & 3) == 0);\n\n\n\n inst = opc;\n\n inst |= (dest >> 2) & 0x3ffffff;\n\n tcg_out32(s, inst);\n\n return true;\n\n}\n", + "output": "0", + "index": 17265 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dec_sru(DisasContext *dc)\n\n{\n\n if (dc->format == OP_FMT_RI) {\n\n LOG_DIS(\"srui r%d, r%d, %d\\n\", dc->r1, dc->r0, dc->imm5);\n\n } else {\n\n LOG_DIS(\"sru 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_SHIFT)) {\n\n if (dc->format == OP_FMT_RI) {\n\n /* TODO: check r1 == 1 during runtime */\n\n } else {\n\n if (dc->imm5 != 1) {\n\n cpu_abort(dc->env, \"hardware shifter is not available\\n\");\n\n }\n\n }\n\n }\n\n\n\n if (dc->format == OP_FMT_RI) {\n\n tcg_gen_shri_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5);\n\n } else {\n\n TCGv t0 = tcg_temp_new();\n\n tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f);\n\n tcg_gen_shr_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0);\n\n tcg_temp_free(t0);\n\n }\n\n}\n", + "output": "1", + "index": 9416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qed_unplug_allocating_write_reqs(BDRVQEDState *s)\n\n{\n\n assert(s->allocating_write_reqs_plugged);\n\n\n\n s->allocating_write_reqs_plugged = false;\n\n qemu_co_enter_next(&s->allocating_write_reqs);\n\n}\n", + "output": "0", + "index": 16527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,\n\n size_t srclen)\n\n{\n\n z_stream s;\n\n ssize_t dstbytes;\n\n int r, i, flags;\n\n\n\n /* skip header */\n\n i = 10;\n\n flags = src[3];\n\n if (src[2] != DEFLATED || (flags & RESERVED) != 0) {\n\n puts (\"Error: Bad gzipped data\\n\");\n\n return -1;\n\n }\n\n if ((flags & EXTRA_FIELD) != 0)\n\n i = 12 + src[10] + (src[11] << 8);\n\n if ((flags & ORIG_NAME) != 0)\n\n while (src[i++] != 0)\n\n ;\n\n if ((flags & COMMENT) != 0)\n\n while (src[i++] != 0)\n\n ;\n\n if ((flags & HEAD_CRC) != 0)\n\n i += 2;\n\n if (i >= srclen) {\n\n puts (\"Error: gunzip out of data in header\\n\");\n\n return -1;\n\n }\n\n\n\n s.zalloc = zalloc;\n\n s.zfree = zfree;\n\n\n\n r = inflateInit2(&s, -MAX_WBITS);\n\n if (r != Z_OK) {\n\n printf (\"Error: inflateInit2() returned %d\\n\", r);\n\n return (-1);\n\n }\n\n s.next_in = src + i;\n\n s.avail_in = srclen - i;\n\n s.next_out = dst;\n\n s.avail_out = dstlen;\n\n r = inflate(&s, Z_FINISH);\n\n if (r != Z_OK && r != Z_STREAM_END) {\n\n printf (\"Error: inflate() returned %d\\n\", r);\n\n return -1;\n\n }\n\n dstbytes = s.next_out - (unsigned char *) dst;\n\n inflateEnd(&s);\n\n\n\n return dstbytes;\n\n}\n", + "output": "1", + "index": 24560 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_int32(DeviceState *dev, Property *prop, const char *str)\n\n{\n\n int32_t *ptr = qdev_get_prop_ptr(dev, prop);\n\n char *end;\n\n\n\n *ptr = strtol(str, &end, 10);\n\n if ((*end != '\\0') || (end == str)) {\n\n return -EINVAL;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 3229 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sigp_stop_and_store_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 struct kvm_s390_irq irq = {\n\n .type = KVM_S390_SIGP_STOP,\n\n };\n\n\n\n /* disabled wait - sleeping in user space */\n\n if (s390_cpu_get_state(cpu) == CPU_STATE_OPERATING && cs->halted) {\n\n s390_cpu_set_state(CPU_STATE_STOPPED, cpu);\n\n }\n\n\n\n switch (s390_cpu_get_state(cpu)) {\n\n case CPU_STATE_OPERATING:\n\n cpu->env.sigp_order = SIGP_STOP_STORE_STATUS;\n\n kvm_s390_vcpu_interrupt(cpu, &irq);\n\n /* store will be performed when handling the stop intercept */\n\n break;\n\n case CPU_STATE_STOPPED:\n\n /* already stopped, just store the status */\n\n cpu_synchronize_state(cs);\n\n kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, true);\n\n break;\n\n }\n\n si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;\n\n}\n", + "output": "0", + "index": 10203 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static UserDefTwo *nested_struct_create(void)\n\n{\n\n UserDefTwo *udnp = g_malloc0(sizeof(*udnp));\n\n udnp->string0 = strdup(\"test_string0\");\n\n udnp->dict1 = g_malloc0(sizeof(*udnp->dict1));\n\n udnp->dict1->string1 = strdup(\"test_string1\");\n\n udnp->dict1->dict2 = g_malloc0(sizeof(*udnp->dict1->dict2));\n\n udnp->dict1->dict2->userdef = g_new0(UserDefOne, 1);\n\n udnp->dict1->dict2->userdef->base = g_new0(UserDefZero, 1);\n\n udnp->dict1->dict2->userdef->base->integer = 42;\n\n udnp->dict1->dict2->userdef->string = strdup(\"test_string\");\n\n udnp->dict1->dict2->string = strdup(\"test_string2\");\n\n udnp->dict1->dict3 = g_malloc0(sizeof(*udnp->dict1->dict3));\n\n udnp->dict1->has_dict3 = true;\n\n udnp->dict1->dict3->userdef = g_new0(UserDefOne, 1);\n\n udnp->dict1->dict3->userdef->base = g_new0(UserDefZero, 1);\n\n udnp->dict1->dict3->userdef->base->integer = 43;\n\n udnp->dict1->dict3->userdef->string = strdup(\"test_string\");\n\n udnp->dict1->dict3->string = strdup(\"test_string3\");\n\n return udnp;\n\n}\n", + "output": "0", + "index": 8267 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,\n\n uint64_t cpu_addr)\n\n{\n\n int cc = SIGP_CC_ORDER_CODE_ACCEPTED;\n\n\n\n HELPER_LOG(\"%s: %016\" PRIx64 \" %08x %016\" PRIx64 \"\\n\",\n\n __func__, order_code, r1, cpu_addr);\n\n\n\n /* Remember: Use \"R1 or R1 + 1, whichever is the odd-numbered register\"\n\n as parameter (input). Status (output) is always R1. */\n\n\n\n switch (order_code) {\n\n case SIGP_SET_ARCH:\n\n /* switch arch */\n\n break;\n\n case SIGP_SENSE:\n\n /* enumerate CPU status */\n\n if (cpu_addr) {\n\n /* XXX implement when SMP comes */\n\n return 3;\n\n }\n\n env->regs[r1] &= 0xffffffff00000000ULL;\n\n cc = 1;\n\n break;\n\n#if !defined(CONFIG_USER_ONLY)\n\n case SIGP_RESTART:\n\n qemu_system_reset_request();\n\n cpu_loop_exit(CPU(s390_env_get_cpu(env)));\n\n break;\n\n case SIGP_STOP:\n\n qemu_system_shutdown_request();\n\n cpu_loop_exit(CPU(s390_env_get_cpu(env)));\n\n break;\n\n#endif\n\n default:\n\n /* unknown sigp */\n\n fprintf(stderr, \"XXX unknown sigp: 0x%\" PRIx64 \"\\n\", order_code);\n\n cc = SIGP_CC_NOT_OPERATIONAL;\n\n }\n\n\n\n return cc;\n\n}\n", + "output": "0", + "index": 26152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *choose_pixel_fmts(OutputStream *ost)\n\n{\n\n if (ost->keep_pix_fmt) {\n\n if (ost->filter)\n\n avfilter_graph_set_auto_convert(ost->filter->graph->graph,\n\n AVFILTER_AUTO_CONVERT_NONE);\n\n if (ost->st->codec->pix_fmt == PIX_FMT_NONE)\n\n return NULL;\n\n ost->pix_fmts[0] = ost->st->codec->pix_fmt;\n\n return ost->pix_fmts;\n\n }\n\n if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {\n\n return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));\n\n } else if (ost->enc->pix_fmts) {\n\n const enum PixelFormat *p;\n\n AVIOContext *s = NULL;\n\n uint8_t *ret;\n\n int len;\n\n\n\n if (avio_open_dyn_buf(&s) < 0)\n\n exit_program(1);\n\n\n\n p = ost->enc->pix_fmts;\n\n if (ost->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {\n\n if (ost->st->codec->codec_id == CODEC_ID_MJPEG) {\n\n p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };\n\n } else if (ost->st->codec->codec_id == CODEC_ID_LJPEG) {\n\n p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,\n\n PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };\n\n }\n\n }\n\n\n\n for (; *p != PIX_FMT_NONE; p++)\n\n avio_printf(s, \"%s:\", av_get_pix_fmt_name(*p));\n\n len = avio_close_dyn_buf(s, &ret);\n\n ret[len - 1] = 0;\n\n return ret;\n\n } else\n\n return NULL;\n\n}\n", + "output": "1", + "index": 16693 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "matroska_probe (AVProbeData *p)\n\n{\n\n uint64_t total = 0;\n\n int len_mask = 0x80, size = 1, n = 1;\n\n uint8_t probe_data[] = { 'm', 'a', 't', 'r', 'o', 's', 'k', 'a' };\n\n\n\n if (p->buf_size < 5)\n\n return 0;\n\n\n\n /* ebml header? */\n\n if ((p->buf[0] << 24 | p->buf[1] << 16 |\n\n p->buf[2] << 8 | p->buf[3]) != EBML_ID_HEADER)\n\n return 0;\n\n\n\n /* length of header */\n\n total = p->buf[4];\n\n while (size <= 8 && !(total & len_mask)) {\n\n size++;\n\n len_mask >>= 1;\n\n }\n\n if (size > 8)\n\n return 0;\n\n total &= (len_mask - 1);\n\n while (n < size)\n\n total = (total << 8) | p->buf[4 + n++];\n\n\n\n /* does the probe data contain the whole header? */\n\n if (p->buf_size < 4 + size + total)\n\n return 0;\n\n\n\n /* the header must contain the document type 'matroska'. For now,\n\n * we don't parse the whole header but simply check for the\n\n * availability of that array of characters inside the header.\n\n * Not fully fool-proof, but good enough. */\n\n for (n = 4 + size; n < 4 + size + total - sizeof(probe_data); n++)\n\n if (!memcmp (&p->buf[n], probe_data, sizeof(probe_data)))\n\n return AVPROBE_SCORE_MAX;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 21951 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int net_init_vde(QemuOpts *opts, const char *name, VLANState *vlan)\n\n{\n\n const char *sock;\n\n const char *group;\n\n int port, mode;\n\n\n\n sock = qemu_opt_get(opts, \"sock\");\n\n group = qemu_opt_get(opts, \"group\");\n\n\n\n port = qemu_opt_get_number(opts, \"port\", 0);\n\n mode = qemu_opt_get_number(opts, \"mode\", 0700);\n\n\n\n if (net_vde_init(vlan, \"vde\", name, sock, port, group, mode) == -1) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 17781 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t mipsnet_receive(NetClientState *nc, const uint8_t *buf, size_t size)\n\n{\n\n MIPSnetState *s = qemu_get_nic_opaque(nc);\n\n\n\n trace_mipsnet_receive(size);\n\n if (!mipsnet_can_receive(nc))\n\n\n\n\n\n\n\n s->busy = 1;\n\n\n\n /* Just accept everything. */\n\n\n\n /* Write packet data. */\n\n memcpy(s->rx_buffer, buf, size);\n\n\n\n s->rx_count = size;\n\n s->rx_read = 0;\n\n\n\n /* Now we can signal we have received something. */\n\n s->intctl |= MIPSNET_INTCTL_RXDONE;\n\n mipsnet_update_irq(s);\n\n\n\n return size;\n", + "output": "1", + "index": 26527 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t scsi_init_iovec(SCSIDiskReq *r, size_t size)\n\n{\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n\n\n\n if (!r->iov.iov_base) {\n\n r->buflen = size;\n\n r->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, r->buflen);\n\n }\n\n r->iov.iov_len = MIN(r->sector_count * 512, r->buflen);\n\n qemu_iovec_init_external(&r->qiov, &r->iov, 1);\n\n return r->qiov.size / 512;\n\n}\n", + "output": "0", + "index": 8260 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)\n\n{\n\n int ret;\n\n\n\n av_frame_unref(frame);\n\n\n\n if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))\n\n return AVERROR(EINVAL);\n\n\n\n if (avctx->codec->receive_frame) {\n\n if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))\n\n return AVERROR_EOF;\n\n return avctx->codec->receive_frame(avctx, frame);\n\n }\n\n\n\n // Emulation via old API.\n\n\n\n if (!avctx->internal->buffer_frame->buf[0]) {\n\n if (!avctx->internal->buffer_pkt->size && !avctx->internal->draining)\n\n return AVERROR(EAGAIN);\n\n\n\n while (1) {\n\n if ((ret = do_decode(avctx, avctx->internal->buffer_pkt)) < 0) {\n\n av_packet_unref(avctx->internal->buffer_pkt);\n\n return ret;\n\n }\n\n // Some audio decoders may consume partial data without returning\n\n // a frame (fate-wmapro-2ch). There is no way to make the caller\n\n // call avcodec_receive_frame() again without returning a frame,\n\n // so try to decode more in these cases.\n\n if (avctx->internal->buffer_frame->buf[0] ||\n\n !avctx->internal->buffer_pkt->size)\n\n break;\n\n }\n\n }\n\n\n\n if (!avctx->internal->buffer_frame->buf[0])\n\n return avctx->internal->draining ? AVERROR_EOF : AVERROR(EAGAIN);\n\n\n\n av_frame_move_ref(frame, avctx->internal->buffer_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 14394 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void msi_notify(PCIDevice *dev, unsigned int vector)\n\n{\n\n uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));\n\n bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;\n\n unsigned int nr_vectors = msi_nr_vectors(flags);\n\n MSIMessage msg;\n\n\n\n assert(vector < nr_vectors);\n\n if (msi_is_masked(dev, vector)) {\n\n assert(flags & PCI_MSI_FLAGS_MASKBIT);\n\n pci_long_test_and_set_mask(\n\n dev->config + msi_pending_off(dev, msi64bit), 1U << vector);\n\n MSI_DEV_PRINTF(dev, \"pending vector 0x%x\\n\", vector);\n\n return;\n\n }\n\n\n\n msg = msi_get_message(dev, vector);\n\n\n\n MSI_DEV_PRINTF(dev,\n\n \"notify vector 0x%x\"\n\n \" address: 0x%\"PRIx64\" data: 0x%\"PRIx32\"\\n\",\n\n vector, msg.address, msg.data);\n\n stl_le_phys(&address_space_memory, msg.address, msg.data);\n\n}\n", + "output": "0", + "index": 10050 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_numa_cpu(const void *data)\n\n{\n\n char *cli;\n\n QDict *resp;\n\n QList *cpus;\n\n const QObject *e;\n\n\n\n cli = make_cli(data, \"-cpu pentium -smp 8,sockets=2,cores=2,threads=2 \"\n\n \"-numa node,nodeid=0 -numa node,nodeid=1 \"\n\n \"-numa cpu,node-id=1,socket-id=0 \"\n\n \"-numa cpu,node-id=0,socket-id=1,core-id=0 \"\n\n \"-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 \"\n\n \"-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1\");\n\n qtest_start(cli);\n\n cpus = get_cpus(&resp);\n\n g_assert(cpus);\n\n\n\n while ((e = qlist_pop(cpus))) {\n\n QDict *cpu, *props;\n\n int64_t socket, core, thread, node;\n\n\n\n cpu = qobject_to_qdict(e);\n\n g_assert(qdict_haskey(cpu, \"props\"));\n\n props = qdict_get_qdict(cpu, \"props\");\n\n\n\n g_assert(qdict_haskey(props, \"node-id\"));\n\n node = qdict_get_int(props, \"node-id\");\n\n g_assert(qdict_haskey(props, \"socket-id\"));\n\n socket = qdict_get_int(props, \"socket-id\");\n\n g_assert(qdict_haskey(props, \"core-id\"));\n\n core = qdict_get_int(props, \"core-id\");\n\n g_assert(qdict_haskey(props, \"thread-id\"));\n\n thread = qdict_get_int(props, \"thread-id\");\n\n\n\n if (socket == 0) {\n\n g_assert_cmpint(node, ==, 1);\n\n } else if (socket == 1 && core == 0) {\n\n g_assert_cmpint(node, ==, 0);\n\n } else if (socket == 1 && core == 1 && thread == 0) {\n\n g_assert_cmpint(node, ==, 0);\n\n } else if (socket == 1 && core == 1 && thread == 1) {\n\n g_assert_cmpint(node, ==, 1);\n\n } else {\n\n g_assert(false);\n\n }\n\n }\n\n\n\n QDECREF(resp);\n\n qtest_end();\n\n g_free(cli);\n\n}\n", + "output": "1", + "index": 14370 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold void ffat_encode_flush(AVCodecContext *avctx)\n\n{\n\n ATDecodeContext *at = avctx->priv_data;\n\n AudioConverterReset(at->converter);\n\n av_frame_unref(&at->new_in_frame);\n\n av_frame_unref(&at->in_frame);\n\n}\n", + "output": "0", + "index": 13832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors,\n\n IscsiLun *iscsilun)\n\n{\n\n assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS);\n\n return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS,\n\n nb_sectors << BDRV_SECTOR_BITS,\n\n iscsilun);\n\n}\n", + "output": "1", + "index": 9987 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ehci_update_frindex(EHCIState *ehci, int frames)\n\n{\n\n int i;\n\n\n\n if (!ehci_enabled(ehci)) {\n\n return;\n\n }\n\n\n\n for (i = 0; i < frames; i++) {\n\n ehci->frindex += 8;\n\n\n\n if (ehci->frindex == 0x00002000) {\n\n ehci_raise_irq(ehci, USBSTS_FLR);\n\n }\n\n\n\n if (ehci->frindex == 0x00004000) {\n\n ehci_raise_irq(ehci, USBSTS_FLR);\n\n ehci->frindex = 0;\n\n if (ehci->usbsts_frindex >= 0x00004000) {\n\n ehci->usbsts_frindex -= 0x00004000;\n\n } else {\n\n ehci->usbsts_frindex = 0;\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 20095 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void process_incoming_migration(QEMUFile *f)\n\n{\n\n if (qemu_loadvm_state(f) < 0) {\n\n fprintf(stderr, \"load of migration failed\\n\");\n\n exit(0);\n\n }\n\n qemu_announce_self();\n\n DPRINTF(\"successfully loaded vm state\\n\");\n\n\n\n incoming_expected = false;\n\n\n\n if (autostart) {\n\n vm_start();\n\n } else {\n\n runstate_set(RSTATE_PRE_LAUNCH);\n\n }\n\n}\n", + "output": "0", + "index": 10194 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rv40_v_strong_loop_filter(uint8_t *src, const int stride,\n\n const int alpha, const int lims,\n\n const int dmode, const int chroma)\n\n{\n\n rv40_strong_loop_filter(src, 1, stride, alpha, lims, dmode, chroma);\n\n}\n", + "output": "1", + "index": 8436 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_load_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp)\n\n{\n\n TCGv tmp;\n\n TCGv_i64 t64;\n\n int index = IS_USER(s);\n\n\n\n t64 = tcg_temp_new_i64();\n\n tmp = tcg_temp_new();\n\n switch (opsize) {\n\n case OS_BYTE:\n\n tcg_gen_qemu_ld8s(tmp, addr, index);\n\n gen_helper_exts32(cpu_env, fp, tmp);\n\n break;\n\n case OS_WORD:\n\n tcg_gen_qemu_ld16s(tmp, addr, index);\n\n gen_helper_exts32(cpu_env, fp, tmp);\n\n break;\n\n case OS_LONG:\n\n tcg_gen_qemu_ld32u(tmp, addr, index);\n\n gen_helper_exts32(cpu_env, fp, tmp);\n\n break;\n\n case OS_SINGLE:\n\n tcg_gen_qemu_ld32u(tmp, addr, index);\n\n gen_helper_extf32(cpu_env, fp, tmp);\n\n break;\n\n case OS_DOUBLE:\n\n tcg_gen_qemu_ld64(t64, addr, index);\n\n gen_helper_extf64(cpu_env, fp, t64);\n\n tcg_temp_free_i64(t64);\n\n break;\n\n case OS_EXTENDED:\n\n if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {\n\n gen_exception(s, s->insn_pc, EXCP_FP_UNIMP);\n\n break;\n\n }\n\n tcg_gen_qemu_ld32u(tmp, addr, index);\n\n tcg_gen_shri_i32(tmp, tmp, 16);\n\n tcg_gen_st16_i32(tmp, fp, offsetof(FPReg, l.upper));\n\n tcg_gen_addi_i32(tmp, addr, 4);\n\n tcg_gen_qemu_ld64(t64, tmp, index);\n\n tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower));\n\n break;\n\n case OS_PACKED:\n\n /* unimplemented data type on 68040/ColdFire\n\n * FIXME if needed for another FPU\n\n */\n\n gen_exception(s, s->insn_pc, EXCP_FP_UNIMP);\n\n break;\n\n default:\n\n g_assert_not_reached();\n\n }\n\n tcg_temp_free(tmp);\n\n tcg_temp_free_i64(t64);\n\n}\n", + "output": "1", + "index": 4350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_virtio_rng_instance_init(Object *obj)\n\n{\n\n VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj);\n\n object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);\n\n object_property_add_child(obj, \"virtio-backend\", OBJECT(&dev->vdev), NULL);\n\n object_property_add_link(obj, \"rng\", TYPE_RNG_BACKEND,\n\n (Object **)&dev->vdev.conf.rng,\n\n\n OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL);\n\n}", + "output": "1", + "index": 1045 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cuda_receive_packet(CUDAState *s,\n\n const uint8_t *data, int len)\n\n{\n\n uint8_t obuf[16];\n\n int ti, autopoll;\n\n\n\n switch(data[0]) {\n\n case CUDA_AUTOPOLL:\n\n autopoll = (data[1] != 0);\n\n if (autopoll != s->autopoll) {\n\n s->autopoll = autopoll;\n\n if (autopoll) {\n\n qemu_mod_timer(s->adb_poll_timer,\n\n qemu_get_clock(vm_clock) +\n\n (ticks_per_sec / CUDA_ADB_POLL_FREQ));\n\n } else {\n\n qemu_del_timer(s->adb_poll_timer);\n\n }\n\n }\n\n obuf[0] = CUDA_PACKET;\n\n obuf[1] = data[1];\n\n cuda_send_packet_to_host(s, obuf, 2);\n\n break;\n\n case CUDA_GET_TIME:\n\n case CUDA_SET_TIME:\n\n /* XXX: add time support ? */\n\n ti = time(NULL) + RTC_OFFSET;\n\n obuf[0] = CUDA_PACKET;\n\n obuf[1] = 0;\n\n obuf[2] = 0;\n\n obuf[3] = ti >> 24;\n\n obuf[4] = ti >> 16;\n\n obuf[5] = ti >> 8;\n\n obuf[6] = ti;\n\n cuda_send_packet_to_host(s, obuf, 7);\n\n break;\n\n case CUDA_FILE_SERVER_FLAG:\n\n case CUDA_SET_DEVICE_LIST:\n\n case CUDA_SET_AUTO_RATE:\n\n case CUDA_SET_POWER_MESSAGES:\n\n obuf[0] = CUDA_PACKET;\n\n obuf[1] = 0;\n\n cuda_send_packet_to_host(s, obuf, 2);\n\n break;\n\n case CUDA_POWERDOWN:\n\n obuf[0] = CUDA_PACKET;\n\n obuf[1] = 0;\n\n cuda_send_packet_to_host(s, obuf, 2);\n\n\tqemu_system_shutdown_request();\n\n\tbreak;\n\n case CUDA_RESET_SYSTEM:\n\n obuf[0] = CUDA_PACKET;\n\n obuf[1] = 0;\n\n cuda_send_packet_to_host(s, obuf, 2);\n\n qemu_system_reset_request();\n\n break;\n\n default:\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 20211 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_dynamic_globalprop_subprocess(void)\n\n{\n\n MyType *mt;\n\n static GlobalProperty props[] = {\n\n { TYPE_DYNAMIC_PROPS, \"prop1\", \"101\", true },\n\n { TYPE_DYNAMIC_PROPS, \"prop2\", \"102\", true },\n\n { TYPE_DYNAMIC_PROPS\"-bad\", \"prop3\", \"103\", true },\n\n /* .not_used=false to emulate what qdev_add_one_global() does: */\n\n { TYPE_UNUSED_HOTPLUG, \"prop4\", \"104\", false },\n\n { TYPE_UNUSED_NOHOTPLUG, \"prop5\", \"105\", true },\n\n { TYPE_NONDEVICE, \"prop6\", \"106\", 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 all_used = qdev_prop_check_globals();\n\n g_assert_cmpuint(all_used, ==, 1);\n\n g_assert(!props[0].not_used);\n\n g_assert(!props[1].not_used);\n\n g_assert(props[2].not_used);\n\n g_assert(!props[3].not_used);\n\n g_assert(props[4].not_used);\n\n g_assert(props[5].not_used);\n\n}\n", + "output": "0", + "index": 12539 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "test_tls_get_ipaddr(const char *addrstr,\n\n char **data,\n\n int *datalen)\n\n{\n\n struct addrinfo *res;\n\n struct addrinfo hints;\n\n\n\n memset(&hints, 0, sizeof(hints));\n\n hints.ai_flags = AI_NUMERICHOST;\n\n g_assert(getaddrinfo(addrstr, NULL, &hints, &res) == 0);\n\n\n\n *datalen = res->ai_addrlen;\n\n *data = g_new(char, *datalen);\n\n memcpy(*data, res->ai_addr, *datalen);\n\n\n}", + "output": "1", + "index": 14453 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t unassigned_mem_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n#ifdef DEBUG_UNASSIGNED\n\n printf(\"Unassigned mem read \" TARGET_FMT_plx \"\\n\", addr);\n\n#endif\n\n#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)\n\n cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);\n\n#endif\n\n return 0;\n\n}\n", + "output": "0", + "index": 10985 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int tap_open(char *ifname, int ifname_size, int *vnet_hdr,\n\n int vnet_hdr_required, int mq_required, Error **errp)\n\n{\n\n /* FIXME error_setg(errp, ...) on failure */\n\n char dev[10]=\"\";\n\n int fd;\n\n if( (fd = tap_alloc(dev, sizeof(dev))) < 0 ){\n\n fprintf(stderr, \"Cannot allocate TAP device\\n\");\n\n return -1;\n\n }\n\n pstrcpy(ifname, ifname_size, dev);\n\n if (*vnet_hdr) {\n\n /* Solaris doesn't have IFF_VNET_HDR */\n\n *vnet_hdr = 0;\n\n\n\n if (vnet_hdr_required && !*vnet_hdr) {\n\n error_report(\"vnet_hdr=1 requested, but no kernel \"\n\n \"support for IFF_VNET_HDR available\");\n\n close(fd);\n\n return -1;\n\n }\n\n }\n\n fcntl(fd, F_SETFL, O_NONBLOCK);\n\n return fd;\n\n}\n", + "output": "1", + "index": 20036 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void apic_update_irq(APICState *s)\n\n{\n\n int irrv, ppr;\n\n if (!(s->spurious_vec & APIC_SV_ENABLE))\n\n return;\n\n irrv = get_highest_priority_int(s->irr);\n\n if (irrv < 0)\n\n return;\n\n ppr = apic_get_ppr(s);\n\n if (ppr && (irrv & 0xf0) <= (ppr & 0xf0))\n\n return;\n\n cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);\n\n}\n", + "output": "0", + "index": 8927 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int read_channel_params(MLPDecodeContext *m, unsigned int substr,\n\n GetBitContext *gbp, unsigned int ch)\n\n{\n\n ChannelParams *cp = &m->channel_params[ch];\n\n FilterParams *fir = &cp->filter_params[FIR];\n\n FilterParams *iir = &cp->filter_params[IIR];\n\n SubStream *s = &m->substream[substr];\n\n\n\n if (s->param_presence_flags & PARAM_FIR)\n\n if (get_bits1(gbp))\n\n if (read_filter_params(m, gbp, ch, FIR) < 0)\n\n return -1;\n\n\n\n if (s->param_presence_flags & PARAM_IIR)\n\n if (get_bits1(gbp))\n\n if (read_filter_params(m, gbp, ch, IIR) < 0)\n\n return -1;\n\n\n\n if (fir->order && iir->order &&\n\n fir->shift != iir->shift) {\n\n av_log(m->avctx, AV_LOG_ERROR,\n\n \"FIR and IIR filters must use the same precision.\\n\");\n\n return -1;\n\n }\n\n /* The FIR and IIR filters must have the same precision.\n\n * To simplify the filtering code, only the precision of the\n\n * FIR filter is considered. If only the IIR filter is employed,\n\n * the FIR filter precision is set to that of the IIR filter, so\n\n * that the filtering code can use it. */\n\n if (!fir->order && iir->order)\n\n fir->shift = iir->shift;\n\n\n\n if (s->param_presence_flags & PARAM_HUFFOFFSET)\n\n if (get_bits1(gbp))\n\n cp->huff_offset = get_sbits(gbp, 15);\n\n\n\n cp->codebook = get_bits(gbp, 2);\n\n cp->huff_lsbs = get_bits(gbp, 5);\n\n\n\n cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);\n\n\n\n /* TODO: validate */\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11279 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean pty_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)\n\n{\n\n CharDriverState *chr = opaque;\n\n PtyCharDriver *s = chr->opaque;\n\n gsize size, len;\n\n uint8_t buf[READ_BUF_LEN];\n\n GIOStatus status;\n\n\n\n len = sizeof(buf);\n\n if (len > s->read_bytes)\n\n len = s->read_bytes;\n\n if (len == 0)\n\n return FALSE;\n\n status = g_io_channel_read_chars(s->fd, (gchar *)buf, len, &size, NULL);\n\n if (status != G_IO_STATUS_NORMAL) {\n\n pty_chr_state(chr, 0);\n\n return FALSE;\n\n } else {\n\n pty_chr_state(chr, 1);\n\n qemu_chr_be_write(chr, buf, size);\n\n }\n\n return TRUE;\n\n}\n", + "output": "0", + "index": 26467 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean io_watch_poll_prepare(GSource *source, gint *timeout_)\n\n{\n\n IOWatchPoll *iwp = io_watch_poll_from_source(source);\n\n bool now_active = iwp->fd_can_read(iwp->opaque) > 0;\n\n bool was_active = g_source_get_context(iwp->src) != NULL;\n\n if (was_active == now_active) {\n\n return FALSE;\n\n }\n\n\n\n if (now_active) {\n\n g_source_attach(iwp->src, NULL);\n\n } else {\n\n g_source_remove(g_source_get_id(iwp->src));\n\n }\n\n return FALSE;\n\n}\n", + "output": "0", + "index": 5244 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_pkt(AVFormatContext *s, AVPacket *pkt)\n{\n MOVMuxContext *mov = s->priv_data;\n MOVTrack *trk = &mov->tracks[pkt->stream_index];\n int64_t ref;\n uint64_t duration;\n if (trk->entry) {\n ref = trk->cluster[trk->entry - 1].dts;\n } else if ( trk->start_dts != AV_NOPTS_VALUE\n && !trk->frag_discont) {\n ref = trk->start_dts + trk->track_duration;\n } else\n ref = pkt->dts; // Skip tests for the first packet\n duration = pkt->dts - ref;\n if (pkt->dts < ref || duration >= INT_MAX) {\n av_log(s, AV_LOG_ERROR, \"Application provided duration: %\"PRId64\" / timestamp: %\"PRId64\" is out of range for mov/mp4 format\\n\",\n duration, pkt->dts\n );\n pkt->dts = ref + 1;\n pkt->pts = AV_NOPTS_VALUE;\n if (pkt->duration < 0 || pkt->duration > INT_MAX) {\n av_log(s, AV_LOG_ERROR, \"Application provided duration: %\"PRId64\" is invalid\\n\", pkt->duration);\n return AVERROR(EINVAL);\n return 0;", + "output": "1", + "index": 11283 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void write_odml_master(AVFormatContext *s, int stream_index)\n\n{\n\n AVIOContext *pb = s->pb;\n\n AVStream *st = s->streams[stream_index];\n\n AVCodecContext *enc = st->codec;\n\n AVIStream *avist = st->priv_data;\n\n unsigned char tag[5];\n\n int j;\n\n\n\n /* Starting to lay out AVI OpenDML master index.\n\n * We want to make it JUNK entry for now, since we'd\n\n * like to get away without making AVI an OpenDML one\n\n * for compatibility reasons. */\n\n avist->indexes.entry = avist->indexes.ents_allocated = 0;\n\n avist->indexes.indx_start = ff_start_tag(pb, \"JUNK\");\n\n avio_wl16(pb, 4); /* wLongsPerEntry */\n\n avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */\n\n avio_w8(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */\n\n avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */\n\n ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, enc->codec_type));\n\n /* dwChunkId */\n\n avio_wl64(pb, 0); /* dwReserved[3] */\n\n avio_wl32(pb, 0); /* Must be 0. */\n\n for (j = 0; j < AVI_MASTER_INDEX_SIZE * 2; j++)\n\n avio_wl64(pb, 0);\n\n ff_end_tag(pb, avist->indexes.indx_start);\n\n}\n", + "output": "0", + "index": 5077 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_init(TestData *d)\n\n{\n\n QPCIBus *bus;\n\n QTestState *qs;\n\n char *s;\n\n\n\n s = g_strdup_printf(\"-machine q35 %s %s\",\n\n d->noreboot ? \"\" : \"-global ICH9-LPC.noreboot=false\",\n\n !d->args ? \"\" : d->args);\n\n qs = qtest_start(s);\n\n qtest_irq_intercept_in(qs, \"ioapic\");\n\n g_free(s);\n\n\n\n bus = qpci_init_pc(NULL);\n\n d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));\n\n g_assert(d->dev != NULL);\n\n\n\n qpci_device_enable(d->dev);\n\n\n\n /* set ACPI PM I/O space base address */\n\n qpci_config_writel(d->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1);\n\n /* enable ACPI I/O */\n\n qpci_config_writeb(d->dev, ICH9_LPC_ACPI_CTRL, 0x80);\n\n /* set Root Complex BAR */\n\n qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1);\n\n\n\n d->tco_io_base = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60);\n\n}\n", + "output": "1", + "index": 9 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void *qemu_get_ram_ptr(ram_addr_t addr)\n\n{\n\n RAMBlock *prev;\n\n RAMBlock **prevp;\n\n RAMBlock *block;\n\n\n\n#ifdef CONFIG_KQEMU\n\n if (kqemu_phys_ram_base) {\n\n return kqemu_phys_ram_base + addr;\n\n }\n\n#endif\n\n\n\n prev = NULL;\n\n prevp = &ram_blocks;\n\n block = ram_blocks;\n\n while (block && (block->offset > addr\n\n || block->offset + block->length <= addr)) {\n\n if (prev)\n\n prevp = &prev->next;\n\n prev = block;\n\n block = block->next;\n\n }\n\n if (!block) {\n\n fprintf(stderr, \"Bad ram offset %\" PRIx64 \"\\n\", (uint64_t)addr);\n\n abort();\n\n }\n\n /* Move this entry to to start of the list. */\n\n if (prev) {\n\n prev->next = block->next;\n\n block->next = *prevp;\n\n *prevp = block;\n\n }\n\n return block->host + (addr - block->offset);\n\n}\n", + "output": "0", + "index": 2645 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_index_entry(AVStream *st,\n\n int64_t pos, int64_t timestamp, int flags)\n\n{\n\n AVIndexEntry *entries, *ie;\n\n \n\n entries = av_fast_realloc(st->index_entries,\n\n &st->index_entries_allocated_size,\n\n (st->nb_index_entries + 1) * \n\n sizeof(AVIndexEntry));\n\n if (entries) {\n\n st->index_entries = entries;\n\n ie = &entries[st->nb_index_entries++];\n\n ie->pos = pos;\n\n ie->timestamp = timestamp;\n\n ie->flags = flags;\n\n }\n\n}\n", + "output": "0", + "index": 18200 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int add_doubles_metadata(const uint8_t **buf, int count,\n\n const char *name, const char *sep,\n\n TiffContext *s)\n\n{\n\n char *ap;\n\n int i;\n\n double *dp = av_malloc(count * sizeof(double));\n\n if (!dp)\n\n return AVERROR(ENOMEM);\n\n\n\n for (i = 0; i < count; i++)\n\n dp[i] = tget_double(buf, s->le);\n\n ap = doubles2str(dp, count, sep);\n\n av_freep(&dp);\n\n if (!ap)\n\n return AVERROR(ENOMEM);\n\n av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);\n\n return 0;\n\n}\n", + "output": "0", + "index": 15224 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn nfs_co_writev(BlockDriverState *bs,\n\n int64_t sector_num, int nb_sectors,\n\n QEMUIOVector *iov)\n\n{\n\n NFSClient *client = bs->opaque;\n\n NFSRPC task;\n\n char *buf = NULL;\n\n\n\n nfs_co_init_task(client, &task);\n\n\n\n buf = g_malloc(nb_sectors * BDRV_SECTOR_SIZE);\n\n qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);\n\n\n\n if (nfs_pwrite_async(client->context, client->fh,\n\n sector_num * BDRV_SECTOR_SIZE,\n\n nb_sectors * BDRV_SECTOR_SIZE,\n\n buf, nfs_co_generic_cb, &task) != 0) {\n\n g_free(buf);\n\n return -ENOMEM;\n\n }\n\n\n\n while (!task.complete) {\n\n nfs_set_events(client);\n\n qemu_coroutine_yield();\n\n }\n\n\n\n g_free(buf);\n\n\n\n if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {\n\n return task.ret < 0 ? task.ret : -EIO;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 5405 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nbd_send_rep_list(int csock, NBDExport *exp)\n\n{\n\n uint64_t magic, name_len;\n\n uint32_t opt, type, len;\n\n\n\n name_len = strlen(exp->name);\n\n magic = cpu_to_be64(NBD_REP_MAGIC);\n\n if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {\n\n LOG(\"write failed (magic)\");\n\n return -EINVAL;\n\n }\n\n opt = cpu_to_be32(NBD_OPT_LIST);\n\n if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) {\n\n LOG(\"write failed (opt)\");\n\n return -EINVAL;\n\n }\n\n type = cpu_to_be32(NBD_REP_SERVER);\n\n if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) {\n\n LOG(\"write failed (reply type)\");\n\n return -EINVAL;\n\n }\n\n len = cpu_to_be32(name_len + sizeof(len));\n\n if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {\n\n LOG(\"write failed (length)\");\n\n return -EINVAL;\n\n }\n\n len = cpu_to_be32(name_len);\n\n if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {\n\n LOG(\"write failed (length)\");\n\n return -EINVAL;\n\n }\n\n if (write_sync(csock, exp->name, name_len) != name_len) {\n\n LOG(\"write failed (buffer)\");\n\n return -EINVAL;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 1773 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t slow_bar_readb(void *opaque, target_phys_addr_t addr)\n\n{\n\n AssignedDevRegion *d = opaque;\n\n uint8_t *in = d->u.r_virtbase + addr;\n\n uint32_t r;\n\n\n\n r = *in;\n\n DEBUG(\"slow_bar_readl addr=0x\" TARGET_FMT_plx \" val=0x%08x\\n\", addr, r);\n\n\n\n return r;\n\n}\n", + "output": "0", + "index": 7093 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)\n\n{\n\n QEMUFile *f;\n\n\n\n f = g_malloc0(sizeof(QEMUFile));\n\n\n\n f->opaque = opaque;\n\n f->ops = ops;\n\n f->is_write = 0;\n\n\n\n return f;\n\n}\n", + "output": "0", + "index": 23518 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hmp_cont_cb(void *opaque, int err)\n\n{\n\n if (!err) {\n\n qmp_cont(NULL);\n\n }\n\n}\n", + "output": "1", + "index": 16093 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_loadvm(int argc, const char **argv)\n\n{\n\n if (argc != 2) {\n\n help_cmd(argv[0]);\n\n return;\n\n }\n\n if (qemu_loadvm(argv[1]) < 0) \n\n term_printf(\"I/O error when loading VM from '%s'\\n\", argv[1]);\n\n}\n", + "output": "0", + "index": 4928 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int xen_pt_cmd_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 uint16_t emu_mask = reg->emu_mask;\n\n\n\n if (s->is_virtfn) {\n\n emu_mask |= PCI_COMMAND_MEMORY;\n\n }\n\n\n\n /* emulate word register */\n\n valid_emu_mask = 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": "1", + "index": 26509 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext)\n\n{\n\n OggVorbisContext *context = avccontext->priv_data;\n\n ogg_packet header, header_comm, header_code;\n\n uint8_t *p;\n\n unsigned int offset;\n\n\n\n vorbis_info_init(&context->vi);\n\n if (oggvorbis_init_encoder(&context->vi, avccontext) < 0) {\n\n av_log(avccontext, AV_LOG_ERROR, \"oggvorbis_encode_init: init_encoder failed\\n\");\n\n return -1;\n\n }\n\n vorbis_analysis_init(&context->vd, &context->vi);\n\n vorbis_block_init(&context->vd, &context->vb);\n\n\n\n vorbis_comment_init(&context->vc);\n\n vorbis_comment_add_tag(&context->vc, \"encoder\", LIBAVCODEC_IDENT);\n\n\n\n vorbis_analysis_headerout(&context->vd, &context->vc, &header,\n\n &header_comm, &header_code);\n\n\n\n avccontext->extradata_size =\n\n 1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes) +\n\n header_code.bytes;\n\n p = avccontext->extradata =\n\n av_malloc(avccontext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);\n\n p[0] = 2;\n\n offset = 1;\n\n offset += av_xiphlacing(&p[offset], header.bytes);\n\n offset += av_xiphlacing(&p[offset], header_comm.bytes);\n\n memcpy(&p[offset], header.packet, header.bytes);\n\n offset += header.bytes;\n\n memcpy(&p[offset], header_comm.packet, header_comm.bytes);\n\n offset += header_comm.bytes;\n\n memcpy(&p[offset], header_code.packet, header_code.bytes);\n\n offset += header_code.bytes;\n\n assert(offset == avccontext->extradata_size);\n\n\n\n#if 0\n\n vorbis_block_clear(&context->vb);\n\n vorbis_dsp_clear(&context->vd);\n\n vorbis_info_clear(&context->vi);\n\n#endif\n\n vorbis_comment_clear(&context->vc);\n\n\n\n avccontext->frame_size = OGGVORBIS_FRAME_SIZE;\n\n\n\n avccontext->coded_frame = avcodec_alloc_frame();\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8093 + }, + { + "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 - really any YUV 4:2:0 input format should 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, IMGFMT_YV12);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 13836 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "char *desc_get_buf(DescInfo *info, bool read_only)\n\n{\n\n PCIDevice *dev = PCI_DEVICE(info->ring->r);\n\n size_t size = read_only ? le16_to_cpu(info->desc.tlv_size) :\n\n le16_to_cpu(info->desc.buf_size);\n\n\n\n if (size > info->buf_size) {\n\n info->buf = g_realloc(info->buf, size);\n\n info->buf_size = size;\n\n }\n\n\n\n if (!info->buf) {\n\n return NULL;\n\n }\n\n\n\n pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size);\n\n\n\n return info->buf;\n\n}\n", + "output": "1", + "index": 11814 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)\n\n{\n\n int i;\n\n register int t1,t2,t3,t4;\n\n DCTELEM *src, *dst;\n\n const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n src = block;\n\n dst = block;\n\n for(i = 0; i < 4; i++){\n\n t1 = 17 * (src[0] + src[2]) + 4;\n\n t2 = 17 * (src[0] - src[2]) + 4;\n\n t3 = 22 * src[1] + 10 * src[3];\n\n t4 = 22 * src[3] - 10 * src[1];\n\n\n\n dst[0] = (t1 + t3) >> 3;\n\n dst[1] = (t2 - t4) >> 3;\n\n dst[2] = (t2 + t4) >> 3;\n\n dst[3] = (t1 - t3) >> 3;\n\n\n\n src += 8;\n\n dst += 8;\n\n }\n\n\n\n src = block;\n\n for(i = 0; i < 4; i++){\n\n t1 = 17 * (src[ 0] + src[16]) + 64;\n\n t2 = 17 * (src[ 0] - src[16]) + 64;\n\n t3 = 22 * src[ 8] + 10 * src[24];\n\n t4 = 22 * src[24] - 10 * src[ 8];\n\n\n\n dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];\n\n dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];\n\n dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];\n\n dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];\n\n\n\n src ++;\n\n dest++;\n\n }\n\n}\n", + "output": "1", + "index": 26106 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num,\n\n int nb_sectors, QEMUIOVector *qiov)\n\n{\n\n BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);\n\n return bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov);\n\n}\n", + "output": "1", + "index": 15114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void configure_alarms(char const *opt)\n\n{\n\n int i;\n\n int cur = 0;\n\n int count = ARRAY_SIZE(alarm_timers) - 1;\n\n char *arg;\n\n char *name;\n\n struct qemu_alarm_timer tmp;\n\n\n\n if (!strcmp(opt, \"?\")) {\n\n show_available_alarms();\n\n exit(0);\n\n }\n\n\n\n arg = g_strdup(opt);\n\n\n\n /* Reorder the array */\n\n name = strtok(arg, \",\");\n\n while (name) {\n\n for (i = 0; i < count && alarm_timers[i].name; 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 g_free(arg);\n\n\n\n if (cur) {\n\n /* Disable remaining timers */\n\n for (i = cur; i < count; i++)\n\n alarm_timers[i].name = NULL;\n\n } else {\n\n show_available_alarms();\n\n exit(1);\n\n }\n\n}\n", + "output": "1", + "index": 449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_rtl8168_window_quirk_write(void *opaque, hwaddr addr,\n\n uint64_t data, unsigned size)\n\n{\n\n VFIOQuirk *quirk = opaque;\n\n VFIOPCIDevice *vdev = quirk->vdev;\n\n\n\n switch (addr) {\n\n case 4: /* address */\n\n if ((data & 0x7fff0000) == 0x10000) {\n\n if (data & 0x80000000U &&\n\n vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) {\n\n\n\n trace_vfio_rtl8168_window_quirk_write_table(\n\n memory_region_name(&quirk->mem),\n\n vdev->vbasedev.name);\n\n\n\n memory_region_dispatch_write(&vdev->pdev.msix_table_mmio,\n\n (hwaddr)(data & 0xfff),\n\n (uint64_t)quirk->data.address_mask,\n\n size, MEMTXATTRS_UNSPECIFIED);\n\n }\n\n\n\n quirk->data.flags = 1;\n\n quirk->data.address_match = data;\n\n\n\n return;\n\n }\n\n quirk->data.flags = 0;\n\n break;\n\n case 0: /* data */\n\n quirk->data.address_mask = data;\n\n break;\n\n }\n\n\n\n trace_vfio_rtl8168_window_quirk_write_direct(\n\n memory_region_name(&quirk->mem),\n\n vdev->vbasedev.name);\n\n\n\n vfio_region_write(&vdev->bars[quirk->data.bar].region,\n\n addr + 0x70, data, size);\n\n}\n", + "output": "1", + "index": 19152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int poll(struct pollfd *fds, nfds_t numfds, int timeout)\n\n{\n\n fd_set read_set;\n\n fd_set write_set;\n\n fd_set exception_set;\n\n nfds_t i;\n\n int n;\n\n int rc;\n\n\n\n#ifdef __MINGW32__\n\n if (numfds >= FD_SETSIZE) {\n\n errno = EINVAL;\n\n return -1;\n\n }\n\n#endif\n\n\n\n FD_ZERO(&read_set);\n\n FD_ZERO(&write_set);\n\n FD_ZERO(&exception_set);\n\n\n\n n = -1;\n\n for(i = 0; i < numfds; i++) {\n\n if (fds[i].fd < 0)\n\n continue;\n\n#ifndef __MINGW32__\n\n if (fds[i].fd >= FD_SETSIZE) {\n\n errno = EINVAL;\n\n return -1;\n\n }\n\n#endif\n\n\n\n if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &read_set);\n\n if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &write_set);\n\n if (fds[i].events & POLLERR) FD_SET(fds[i].fd, &exception_set);\n\n\n\n if (fds[i].fd > n)\n\n n = fds[i].fd;\n\n };\n\n\n\n if (n == -1)\n\n /* Hey!? Nothing to poll, in fact!!! */\n\n return 0;\n\n\n\n if (timeout < 0)\n\n rc = select(n+1, &read_set, &write_set, &exception_set, NULL);\n\n else {\n\n struct timeval tv;\n\n\n\n tv.tv_sec = timeout / 1000;\n\n tv.tv_usec = 1000 * (timeout % 1000);\n\n rc = select(n+1, &read_set, &write_set, &exception_set, &tv);\n\n };\n\n\n\n if (rc < 0)\n\n return rc;\n\n\n\n for(i = 0; i < (nfds_t) n; i++) {\n\n fds[i].revents = 0;\n\n\n\n if (FD_ISSET(fds[i].fd, &read_set)) fds[i].revents |= POLLIN;\n\n if (FD_ISSET(fds[i].fd, &write_set)) fds[i].revents |= POLLOUT;\n\n if (FD_ISSET(fds[i].fd, &exception_set)) fds[i].revents |= POLLERR;\n\n };\n\n\n\n return rc;\n\n}\n", + "output": "0", + "index": 25837 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cpu_x86_fill_model_id(char *str)\n\n{\n\n uint32_t eax, ebx, ecx, edx;\n\n int i;\n\n\n\n for (i = 0; i < 3; i++) {\n\n host_cpuid(0x80000002 + i, 0, &eax, &ebx, &ecx, &edx);\n\n memcpy(str + i * 16 + 0, &eax, 4);\n\n memcpy(str + i * 16 + 4, &ebx, 4);\n\n memcpy(str + i * 16 + 8, &ecx, 4);\n\n memcpy(str + i * 16 + 12, &edx, 4);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 22114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){\n\n AVPacketList *pktl, **next_point, *this_pktl;\n\n int stream_count=0;\n\n int streams[MAX_STREAMS];\n\n\n\n if(pkt){\n\n AVStream *st= s->streams[ pkt->stream_index];\n\n\n\n// assert(pkt->destruct != av_destruct_packet); //FIXME\n\n\n\n this_pktl = av_mallocz(sizeof(AVPacketList));\n\n this_pktl->pkt= *pkt;\n\n if(pkt->destruct == av_destruct_packet)\n\n pkt->destruct= NULL; // not shared -> must keep original from being freed\n\n else\n\n av_dup_packet(&this_pktl->pkt); //shared -> must dup\n\n\n\n next_point = &s->packet_buffer;\n\n while(*next_point){\n\n AVStream *st2= s->streams[ (*next_point)->pkt.stream_index];\n\n int64_t left= st2->time_base.num * (int64_t)st ->time_base.den;\n\n int64_t right= st ->time_base.num * (int64_t)st2->time_base.den;\n\n if((*next_point)->pkt.dts * left > pkt->dts * right) //FIXME this can overflow\n\n break;\n\n next_point= &(*next_point)->next;\n\n }\n\n this_pktl->next= *next_point;\n\n *next_point= this_pktl;\n\n }\n\n\n\n memset(streams, 0, sizeof(streams));\n\n pktl= s->packet_buffer;\n\n while(pktl){\n\n//av_log(s, AV_LOG_DEBUG, \"show st:%d dts:%\"PRId64\"\\n\", pktl->pkt.stream_index, pktl->pkt.dts);\n\n if(streams[ pktl->pkt.stream_index ] == 0)\n\n stream_count++;\n\n streams[ pktl->pkt.stream_index ]++;\n\n pktl= pktl->next;\n\n }\n\n\n\n if(s->nb_streams == stream_count || (flush && stream_count)){\n\n pktl= s->packet_buffer;\n\n *out= pktl->pkt;\n\n\n\n s->packet_buffer= pktl->next;\n\n av_freep(&pktl);\n\n return 1;\n\n }else{\n\n av_init_packet(out);\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 8919 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void free_picture(MpegEncContext *s, Picture *pic){\n\n int i;\n\n\n\n if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){\n\n free_frame_buffer(s, pic);\n\n }\n\n\n\n av_freep(&pic->mb_var);\n\n av_freep(&pic->mc_mb_var);\n\n av_freep(&pic->mb_mean);\n\n av_freep(&pic->mbskip_table);\n\n av_freep(&pic->qscale_table);\n\n av_freep(&pic->mb_type_base);\n\n av_freep(&pic->dct_coeff);\n\n av_freep(&pic->pan_scan);\n\n pic->mb_type= NULL;\n\n for(i=0; i<2; i++){\n\n av_freep(&pic->motion_val_base[i]);\n\n av_freep(&pic->ref_index[i]);\n\n }\n\n\n\n if(pic->type == FF_BUFFER_TYPE_SHARED){\n\n for(i=0; i<4; i++){\n\n pic->base[i]=\n\n pic->data[i]= NULL;\n\n }\n\n pic->type= 0;\n\n }\n\n}\n", + "output": "1", + "index": 25598 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int inet_connect_opts(QemuOpts *opts, Error **errp,\n\n NonBlockingConnectHandler *callback, void *opaque)\n\n{\n\n struct addrinfo *res, *e;\n\n int sock = -1;\n\n bool in_progress;\n\n ConnectState *connect_state = NULL;\n\n\n\n res = inet_parse_connect_opts(opts, errp);\n\n if (!res) {\n\n return -1;\n\n }\n\n\n\n if (callback != NULL) {\n\n connect_state = g_malloc0(sizeof(*connect_state));\n\n connect_state->addr_list = res;\n\n connect_state->callback = callback;\n\n connect_state->opaque = opaque;\n\n }\n\n\n\n for (e = res; e != NULL; e = e->ai_next) {\n\n if (error_is_set(errp)) {\n\n error_free(*errp);\n\n *errp = NULL;\n\n }\n\n if (connect_state != NULL) {\n\n connect_state->current_addr = e;\n\n }\n\n sock = inet_connect_addr(e, &in_progress, connect_state, errp);\n\n if (in_progress) {\n\n return sock;\n\n } else if (sock >= 0) {\n\n /* non blocking socket immediate success, call callback */\n\n if (callback != NULL) {\n\n callback(sock, opaque);\n\n }\n\n break;\n\n }\n\n }\n\n g_free(connect_state);\n\n freeaddrinfo(res);\n\n return sock;\n\n}\n", + "output": "0", + "index": 17077 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mkv_field_order(MatroskaDemuxContext *matroska, int64_t field_order)\n\n{\n\n int major, minor, micro, bttb = 0;\n\n\n\n /* workaround a bug in our Matroska muxer, introduced in version 57.36 alongside\n\n * this function, and fixed in 57.52 */\n\n if (sscanf(matroska->muxingapp, \"Lavf%d.%d.%d\", &major, &minor, µ) == 3)\n\n bttb = (major == 57 && minor >= 36 && minor <= 51 && micro >= 100);\n\n\n\n switch (field_order) {\n\n case MATROSKA_VIDEO_FIELDORDER_PROGRESSIVE:\n\n return AV_FIELD_PROGRESSIVE;\n\n case MATROSKA_VIDEO_FIELDORDER_UNDETERMINED:\n\n return AV_FIELD_UNKNOWN;\n\n case MATROSKA_VIDEO_FIELDORDER_TT:\n\n return AV_FIELD_TT;\n\n case MATROSKA_VIDEO_FIELDORDER_BB:\n\n return AV_FIELD_BB;\n\n case MATROSKA_VIDEO_FIELDORDER_BT:\n\n return bttb ? AV_FIELD_TB : AV_FIELD_BT;\n\n case MATROSKA_VIDEO_FIELDORDER_TB:\n\n return bttb ? AV_FIELD_BT : AV_FIELD_TB;\n\n default:\n\n return AV_FIELD_UNKNOWN;\n\n }\n\n}\n", + "output": "1", + "index": 17860 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_xattr_write(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,\n\n uint64_t off, uint32_t count,\n\n struct iovec *sg, int cnt)\n\n{\n\n int i, to_copy;\n\n ssize_t err = 0;\n\n int write_count;\n\n int64_t xattr_len;\n\n size_t offset = 7;\n\n\n\n\n\n xattr_len = fidp->fs.xattr.len;\n\n write_count = xattr_len - off;\n\n if (write_count > count) {\n\n write_count = count;\n\n } else if (write_count < 0) {\n\n /*\n\n * write beyond XATTR value len specified in\n\n * xattrcreate\n\n */\n\n err = -ENOSPC;\n\n goto out;\n\n }\n\n offset += pdu_marshal(pdu, offset, \"d\", write_count);\n\n err = offset;\n\n fidp->fs.xattr.copied_len += write_count;\n\n /*\n\n * Now copy the content from sg list\n\n */\n\n for (i = 0; i < cnt; i++) {\n\n if (write_count > sg[i].iov_len) {\n\n to_copy = sg[i].iov_len;\n\n } else {\n\n to_copy = write_count;\n\n }\n\n memcpy((char *)fidp->fs.xattr.value + off, sg[i].iov_base, to_copy);\n\n /* updating vs->off since we are not using below */\n\n off += to_copy;\n\n write_count -= to_copy;\n\n }\n\nout:\n\n return err;\n\n}\n", + "output": "0", + "index": 7975 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)\n\n{\n\n UHCIState *s = DO_UPCAST(UHCIState, dev, dev);\n\n uint8_t *pci_conf = s->dev.config;\n\n\n\n pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);\n\n pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_UHCI);\n\n\n\n /* USB misc control 1/2 */\n\n pci_set_long(pci_conf + 0x40,0x00001000);\n\n /* PM capability */\n\n pci_set_long(pci_conf + 0x80,0x00020001);\n\n /* USB legacy support */\n\n pci_set_long(pci_conf + 0xc0,0x00002000);\n\n\n\n return usb_uhci_common_initfn(s);\n\n}\n", + "output": "0", + "index": 19389 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qemu_irq sh7750_irl(SH7750State *s)\n\n{\n\n sh_intc_toggle_source(sh_intc_source(&s->intc, IRL), 1, 0); /* enable */\n\n return qemu_allocate_irqs(sh_intc_set_irl, sh_intc_source(&s->intc, IRL),\n\n 1)[0];\n\n}\n", + "output": "1", + "index": 13028 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void init_excp_4xx_real (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_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_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": 17392 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)\n\n{\n\n AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));\n\n\n\n if(avctx==NULL) return NULL;\n\n\n\n if(avcodec_get_context_defaults3(avctx, codec) < 0){\n\n av_free(avctx);\n\n return NULL;\n\n }\n\n\n\n return avctx;\n\n}\n", + "output": "0", + "index": 20275 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precission)\n\n{\n\n AVRational q;\n\n int j;\n\n\n\n if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {\n\n q = (AVRational){1, st->codec->sample_rate};\n\n } else {\n\n q = st->codec->time_base;\n\n }\n\n for (j=2; j<2000; j+= 1+(j>2))\n\n while (q.den / q.num < min_precission && q.num % j == 0)\n\n q.num /= j;\n\n while (q.den / q.num < min_precission && q.den < (1<<24))\n\n q.den <<= 1;\n\n\n\n return q;\n\n}\n", + "output": "1", + "index": 4804 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void uhci_port_test(struct qhc *hc, int port, uint16_t expect)\n\n{\n\n void *addr = hc->base + 0x10 + 2 * port;\n\n uint16_t value = qpci_io_readw(hc->dev, addr);\n\n uint16_t mask = ~(UHCI_PORT_WRITE_CLEAR | UHCI_PORT_RSVD1);\n\n\n\n g_assert((value & mask) == (expect & mask));\n\n}\n", + "output": "1", + "index": 9027 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_purge_queued_packets(VLANClientState *vc)\n\n{\n\n VLANPacket *packet, *next;\n\n\n\n TAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) {\n\n if (packet->sender == vc) {\n\n TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);\n\n qemu_free(packet);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 25291 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static Visitor *visitor_input_test_init_raw(TestInputVisitorData *data,\n\n const char *json_string)\n\n{\n\n return visitor_input_test_init_internal(data, json_string, NULL);\n\n}\n", + "output": "0", + "index": 17085 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,\n\n bool may_overlap, unsigned priority)\n\n{\n\n assert(n >= 0 && n < dev->num_mmio);\n\n\n\n if (dev->mmio[n].addr == addr) {\n\n /* ??? region already mapped here. */\n\n return;\n\n }\n\n if (dev->mmio[n].addr != (hwaddr)-1) {\n\n /* Unregister previous mapping. */\n\n memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory);\n\n }\n\n dev->mmio[n].addr = addr;\n\n if (may_overlap) {\n\n memory_region_add_subregion_overlap(get_system_memory(),\n\n addr,\n\n dev->mmio[n].memory,\n\n priority);\n\n }\n\n else {\n\n memory_region_add_subregion(get_system_memory(),\n\n addr,\n\n dev->mmio[n].memory);\n\n }\n\n}\n", + "output": "0", + "index": 14085 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_disk_realize(SCSIDevice *dev, Error **errp)\n\n{\n\n DriveInfo *dinfo;\n\n Error *local_err = NULL;\n\n\n\n if (!dev->conf.bs) {\n\n scsi_realize(dev, &local_err);\n\n assert(local_err);\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n dinfo = drive_get_by_blockdev(dev->conf.bs);\n\n if (dinfo->media_cd) {\n\n scsi_cd_realize(dev, errp);\n\n } else {\n\n scsi_hd_realize(dev, errp);\n\n }\n\n}\n", + "output": "0", + "index": 886 + }, + { + "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 g_free(vs->display);\n\n vs->display = NULL;\n\n if (vs->lsock != -1) {\n\n qemu_set_fd_handler2(vs->lsock, NULL, NULL, NULL, NULL);\n\n close(vs->lsock);\n\n vs->lsock = -1;\n\n }\n\n#ifdef CONFIG_VNC_WS\n\n g_free(vs->ws_display);\n\n vs->ws_display = NULL;\n\n if (vs->lwebsock != -1) {\n\n qemu_set_fd_handler2(vs->lwebsock, NULL, NULL, NULL, NULL);\n\n close(vs->lwebsock);\n\n vs->lwebsock = -1;\n\n }\n\n#endif /* CONFIG_VNC_WS */\n\n vs->auth = VNC_AUTH_INVALID;\n\n#ifdef CONFIG_VNC_TLS\n\n vs->subauth = VNC_AUTH_INVALID;\n\n vs->tls.x509verify = 0;\n\n#endif\n\n}\n", + "output": "0", + "index": 26939 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void parse_context_init(SchroParseUnitContext *parse_ctx,\n\n const uint8_t *buf, int buf_size)\n\n{\n\n parse_ctx->buf = buf;\n\n parse_ctx->buf_size = buf_size;\n\n}\n", + "output": "1", + "index": 157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel16_mc21_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_midv_qrt_16w_msa(src - (2 * stride) - 2,\n\n stride, dst, stride, 16, 0);\n\n}\n", + "output": "0", + "index": 13197 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bufp_alloc(USBRedirDevice *dev, uint8_t *data, uint16_t len,\n\n uint8_t status, uint8_t ep, void *free_on_destroy)\n\n{\n\n struct buf_packet *bufp;\n\n\n\n if (!dev->endpoint[EP2I(ep)].bufpq_dropping_packets &&\n\n dev->endpoint[EP2I(ep)].bufpq_size >\n\n 2 * dev->endpoint[EP2I(ep)].bufpq_target_size) {\n\n DPRINTF(\"bufpq overflow, dropping packets ep %02X\\n\", ep);\n\n dev->endpoint[EP2I(ep)].bufpq_dropping_packets = 1;\n\n }\n\n /* Since we're interupting the stream anyways, drop enough packets to get\n\n back to our target buffer size */\n\n if (dev->endpoint[EP2I(ep)].bufpq_dropping_packets) {\n\n if (dev->endpoint[EP2I(ep)].bufpq_size >\n\n dev->endpoint[EP2I(ep)].bufpq_target_size) {\n\n free(data);\n\n return;\n\n }\n\n dev->endpoint[EP2I(ep)].bufpq_dropping_packets = 0;\n\n }\n\n\n\n bufp = g_new(struct buf_packet, 1);\n\n bufp->data = data;\n\n bufp->len = len;\n\n bufp->offset = 0;\n\n bufp->status = status;\n\n bufp->free_on_destroy = free_on_destroy;\n\n QTAILQ_INSERT_TAIL(&dev->endpoint[EP2I(ep)].bufpq, bufp, next);\n\n dev->endpoint[EP2I(ep)].bufpq_size++;\n\n}\n", + "output": "1", + "index": 6636 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_disconnect_finish(VncState *vs)\n\n{\n\n int i;\n\n\n\n vnc_jobs_join(vs); /* Wait encoding jobs */\n\n\n\n vnc_lock_output(vs);\n\n vnc_qmp_event(vs, QAPI_EVENT_VNC_DISCONNECTED);\n\n\n\n buffer_free(&vs->input);\n\n buffer_free(&vs->output);\n\n buffer_free(&vs->ws_input);\n\n buffer_free(&vs->ws_output);\n\n\n\n qapi_free_VncClientInfo(vs->info);\n\n\n\n vnc_zlib_clear(vs);\n\n vnc_tight_clear(vs);\n\n vnc_zrle_clear(vs);\n\n\n\n#ifdef CONFIG_VNC_TLS\n\n vnc_tls_client_cleanup(vs);\n\n#endif /* CONFIG_VNC_TLS */\n\n#ifdef CONFIG_VNC_SASL\n\n vnc_sasl_client_cleanup(vs);\n\n#endif /* CONFIG_VNC_SASL */\n\n audio_del(vs);\n\n vnc_release_modifiers(vs);\n\n\n\n if (vs->initialized) {\n\n QTAILQ_REMOVE(&vs->vd->clients, vs, next);\n\n qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier);\n\n }\n\n\n\n if (vs->vd->lock_key_sync)\n\n qemu_remove_led_event_handler(vs->led);\n\n vnc_unlock_output(vs);\n\n\n\n qemu_mutex_destroy(&vs->output_mutex);\n\n if (vs->bh != NULL) {\n\n qemu_bh_delete(vs->bh);\n\n }\n\n buffer_free(&vs->jobs_buffer);\n\n\n\n for (i = 0; i < VNC_STAT_ROWS; ++i) {\n\n g_free(vs->lossy_rect[i]);\n\n }\n\n g_free(vs->lossy_rect);\n\n g_free(vs);\n\n}\n", + "output": "1", + "index": 22680 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,\n\n u_int lport, int flags)\n\n{\n\n\tstruct sockaddr_in addr;\n\n\tstruct socket *so;\n\n\tsocklen_t addrlen = sizeof(struct sockaddr_in);\n\n\n\n\tso = socreate(slirp);\n\n\tif (!so) {\n\n\n\n\tso->s = qemu_socket(AF_INET,SOCK_DGRAM,0);\n\n\n\n\n\n\tso->so_expire = curtime + SO_EXPIRE;\n\n\tinsque(so, &slirp->udb);\n\n\n\n\taddr.sin_family = AF_INET;\n\n\taddr.sin_addr.s_addr = haddr;\n\n\taddr.sin_port = hport;\n\n\n\n\tif (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {\n\n\t\tudp_detach(so);\n\n\n\n\tsocket_set_fast_reuse(so->s);\n\n\n\n\tgetsockname(so->s,(struct sockaddr *)&addr,&addrlen);\n\n\tso->fhost.sin = addr;\n\n\tsotranslate_accept(so);\n\n\tso->so_lfamily = AF_INET;\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_PERSISTENT_MASK;\n\n\tso->so_state |= SS_ISFCONNECTED | flags;\n\n\n\n\treturn so;\n", + "output": "1", + "index": 25452 + }, + { + "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 if (!ctx->epoll_available) {\n\n return false;\n\n }\n\n if (aio_epoll_enabled(ctx)) {\n\n return true;\n\n }\n\n if (npfd >= EPOLL_ENABLE_THRESHOLD) {\n\n if (aio_epoll_try_enable(ctx)) {\n\n return true;\n\n } else {\n\n aio_epoll_disable(ctx);\n\n }\n\n }\n\n return false;\n\n}\n", + "output": "0", + "index": 16829 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qed_read_l1_table_sync(BDRVQEDState *s)\n\n{\n\n int ret = -EINPROGRESS;\n\n\n\n async_context_push();\n\n\n\n qed_read_table(s, s->header.l1_table_offset,\n\n s->l1_table, qed_sync_cb, &ret);\n\n while (ret == -EINPROGRESS) {\n\n qemu_aio_wait();\n\n }\n\n\n\n async_context_pop();\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 2597 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *circular_buffer_task( void *_URLContext)\n\n{\n\n URLContext *h = _URLContext;\n\n UDPContext *s = h->priv_data;\n\n fd_set rfds;\n\n struct timeval tv;\n\n\n\n while(!s->exit_thread) {\n\n int left;\n\n int ret;\n\n int len;\n\n\n\n if (ff_check_interrupt(&h->interrupt_callback)) {\n\n s->circular_buffer_error = AVERROR(EINTR);\n\n goto end;\n\n }\n\n\n\n FD_ZERO(&rfds);\n\n FD_SET(s->udp_fd, &rfds);\n\n tv.tv_sec = 1;\n\n tv.tv_usec = 0;\n\n ret = select(s->udp_fd + 1, &rfds, NULL, NULL, &tv);\n\n if (ret < 0) {\n\n if (ff_neterrno() == AVERROR(EINTR))\n\n continue;\n\n s->circular_buffer_error = AVERROR(EIO);\n\n goto end;\n\n }\n\n\n\n if (!(ret > 0 && FD_ISSET(s->udp_fd, &rfds)))\n\n continue;\n\n\n\n /* How much do we have left to the end of the buffer */\n\n /* Whats the minimum we can read so that we dont comletely fill the buffer */\n\n left = av_fifo_space(s->fifo);\n\n\n\n /* No Space left, error, what do we do now */\n\n if(left < UDP_MAX_PKT_SIZE + 4) {\n\n av_log(h, AV_LOG_ERROR, \"circular_buffer: OVERRUN\\n\");\n\n s->circular_buffer_error = AVERROR(EIO);\n\n goto end;\n\n }\n\n len = recv(s->udp_fd, s->tmp+4, sizeof(s->tmp)-4, 0);\n\n if (len < 0) {\n\n if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) {\n\n s->circular_buffer_error = AVERROR(EIO);\n\n goto end;\n\n }\n\n continue;\n\n }\n\n AV_WL32(s->tmp, len);\n\n pthread_mutex_lock(&s->mutex);\n\n av_fifo_generic_write(s->fifo, s->tmp, len+4, NULL);\n\n pthread_cond_signal(&s->cond);\n\n pthread_mutex_unlock(&s->mutex);\n\n }\n\n\n\nend:\n\n pthread_mutex_lock(&s->mutex);\n\n pthread_cond_signal(&s->cond);\n\n pthread_mutex_unlock(&s->mutex);\n\n return NULL;\n\n}\n", + "output": "1", + "index": 22040 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_validate_alternate(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefAlternate *tmp = NULL;\n\n Visitor *v;\n\n\n\n v = validate_test_init(data, \"42\");\n\n\n\n visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);\n\n qapi_free_UserDefAlternate(tmp);\n\n}\n", + "output": "0", + "index": 3364 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)\n\n{\n\n int ret;\n\n AVStream *st;\n\n\n\n ff_read_frame_flush(s);\n\n\n\n if(flags & AVSEEK_FLAG_BYTE)\n\n return seek_frame_byte(s, stream_index, timestamp, flags);\n\n\n\n if(stream_index < 0){\n\n stream_index= av_find_default_stream_index(s);\n\n if(stream_index < 0)\n\n return -1;\n\n\n\n st= s->streams[stream_index];\n\n /* timestamp for default must be expressed in AV_TIME_BASE units */\n\n timestamp = av_rescale(timestamp, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);\n\n }\n\n\n\n /* first, we try the format specific seek */\n\n if (s->iformat->read_seek)\n\n ret = s->iformat->read_seek(s, stream_index, timestamp, flags);\n\n else\n\n ret = -1;\n\n if (ret >= 0) {\n\n return 0;\n\n }\n\n\n\n if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH))\n\n return av_seek_frame_binary(s, stream_index, timestamp, flags);\n\n else if (!(s->iformat->flags & AVFMT_NOGENSEARCH))\n\n return seek_frame_generic(s, stream_index, timestamp, flags);\n\n else\n\n return -1;\n\n}\n", + "output": "0", + "index": 25345 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t ff_start_tag(AVIOContext *pb, const char *tag)\n\n{\n\n ffio_wfourcc(pb, tag);\n\n avio_wl32(pb, 0);\n\n return avio_tell(pb);\n\n}\n", + "output": "0", + "index": 20273 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int sclp_service_call(CPUS390XState *env, uint32_t sccb, uint64_t code)\n\n{\n\n int r = 0;\n\n int shift = 0;\n\n\n\n#ifdef DEBUG_HELPER\n\n printf(\"sclp(0x%x, 0x%\" PRIx64 \")\\n\", sccb, code);\n\n#endif\n\n\n\n if (sccb & ~0x7ffffff8ul) {\n\n fprintf(stderr, \"KVM: invalid sccb address 0x%x\\n\", sccb);\n\n r = -1;\n\n goto out;\n\n }\n\n\n\n switch(code) {\n\n case SCLP_CMDW_READ_SCP_INFO:\n\n case SCLP_CMDW_READ_SCP_INFO_FORCED:\n\n while ((ram_size >> (20 + shift)) > 65535) {\n\n shift++;\n\n }\n\n stw_phys(sccb + SCP_MEM_CODE, ram_size >> (20 + shift));\n\n stb_phys(sccb + SCP_INCREMENT, 1 << shift);\n\n stw_phys(sccb + SCP_RESPONSE_CODE, 0x10);\n\n\n\n if (kvm_enabled()) {\n\n#ifdef CONFIG_KVM\n\n kvm_s390_interrupt_internal(env, KVM_S390_INT_SERVICE,\n\n sccb & ~3, 0, 1);\n\n#endif\n\n } else {\n\n env->psw.addr += 4;\n\n ext_interrupt(env, EXT_SERVICE, sccb & ~3, 0);\n\n }\n\n break;\n\n default:\n\n#ifdef DEBUG_HELPER\n\n printf(\"KVM: invalid sclp call 0x%x / 0x%\" PRIx64 \"x\\n\", sccb, code);\n\n#endif\n\n r = -1;\n\n break;\n\n }\n\n\n\nout:\n\n return r;\n\n}\n", + "output": "0", + "index": 15422 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count)\n\n{\n\n Coroutine *co;\n\n DiscardCo rwco = {\n\n .bs = bs,\n\n .offset = offset,\n\n .count = count,\n\n .ret = NOT_DONE,\n\n };\n\n\n\n if (qemu_in_coroutine()) {\n\n /* Fast-path if already in coroutine context */\n\n bdrv_pdiscard_co_entry(&rwco);\n\n } else {\n\n co = qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco);\n\n qemu_coroutine_enter(co);\n\n BDRV_POLL_WHILE(bs, rwco.ret == NOT_DONE);\n\n }\n\n\n\n return rwco.ret;\n\n}\n", + "output": "1", + "index": 15153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)\n\n{\n\n uint64_t r;\n\n\n\n switch (num) {\n\n case 0x500:\n\n /* KVM hypercall */\n\n\n r = s390_virtio_hypercall(env);\n\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\n handle_diag_308(env, r1, r3);\n\n\n r = 0;\n\n break;\n\n case 0x288:\n\n /* time bomb (watchdog) */\n\n r = handle_diag_288(env, r1, r3);\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_SPECIFICATION, ILEN_AUTO);\n\n }\n\n}", + "output": "1", + "index": 13655 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "aio_ctx_dispatch(GSource *source,\n\n GSourceFunc callback,\n\n gpointer user_data)\n\n{\n\n AioContext *ctx = (AioContext *) source;\n\n\n\n assert(callback == NULL);\n\n aio_dispatch(ctx, true);\n\n return true;\n\n}\n", + "output": "0", + "index": 3444 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,\n\n size_t size)\n\n{\n\n int64_t len;\n\n\n\n if (!bdrv_is_inserted(bs))\n\n return -ENOMEDIUM;\n\n\n\n if (bs->growable)\n\n return 0;\n\n\n\n len = bdrv_getlength(bs);\n\n\n\n if ((offset + size) > len)\n\n return -EIO;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18510 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void encode_gray_bitstream(HYuvContext *s, int count){\n\n int i;\n\n \n\n count/=2;\n\n if(s->flags&CODEC_FLAG_PASS1){\n\n for(i=0; istats[0][ s->temp[0][2*i ] ]++;\n\n s->stats[0][ s->temp[0][2*i+1] ]++;\n\n }\n\n }else if(s->context){\n\n for(i=0; istats[0][ s->temp[0][2*i ] ]++;\n\n put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);\n\n s->stats[0][ s->temp[0][2*i+1] ]++;\n\n put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);\n\n }\n\n }else{\n\n for(i=0; ipb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);\n\n put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 27219 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void spapr_tce_set_bypass(sPAPRTCETable *tcet, bool bypass)\n\n{\n\n tcet->bypass = bypass;\n\n}\n", + "output": "0", + "index": 1909 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void netfilter_finalize(Object *obj)\n\n{\n\n NetFilterState *nf = NETFILTER(obj);\n\n NetFilterClass *nfc = NETFILTER_GET_CLASS(obj);\n\n\n\n if (nfc->cleanup) {\n\n nfc->cleanup(nf);\n\n }\n\n\n\n if (nf->netdev && !QTAILQ_EMPTY(&nf->netdev->filters)) {\n\n QTAILQ_REMOVE(&nf->netdev->filters, nf, next);\n\n }\n\n\n}", + "output": "1", + "index": 21962 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void neon_load_reg64(TCGv var, int reg)\n\n{\n\n tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));\n\n}\n", + "output": "0", + "index": 12873 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)\n\n{\n\n AVCodecContext *const avctx = h->avctx;\n\n H264SliceContext *sl;\n\n int i;\n\n\n\n av_assert0(context_count && h->slice_ctx[context_count - 1].mb_y < h->mb_height);\n\n\n\n if (h->avctx->hwaccel ||\n\n h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)\n\n return 0;\n\n if (context_count == 1) {\n\n int ret = decode_slice(avctx, &h->slice_ctx[0]);\n\n h->mb_y = h->slice_ctx[0].mb_y;\n\n return ret;\n\n } else {\n\n av_assert0(context_count > 0);\n\n for (i = 1; i < context_count; i++) {\n\n sl = &h->slice_ctx[i];\n\n if (CONFIG_ERROR_RESILIENCE) {\n\n sl->er.error_count = 0;\n\n }\n\n }\n\n\n\n avctx->execute(avctx, decode_slice, h->slice_ctx,\n\n NULL, context_count, sizeof(h->slice_ctx[0]));\n\n\n\n /* pull back stuff from slices to master context */\n\n sl = &h->slice_ctx[context_count - 1];\n\n h->mb_y = sl->mb_y;\n\n if (CONFIG_ERROR_RESILIENCE) {\n\n for (i = 1; i < context_count; i++)\n\n h->slice_ctx[0].er.error_count += h->slice_ctx[i].er.error_count;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 16373 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static MemTxResult memory_region_write_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 MemTxAttrs attrs)\n\n{\n\n uint64_t tmp;\n\n\n\n tmp = (*value >> shift) & mask;\n\n if (mr->subpage) {\n\n trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, size);\n\n\n\n\n\n\n } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {\n\n hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);\n\n trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, size);\n\n }\n\n mr->ops->write(mr->opaque, addr, tmp, size);\n\n return MEMTX_OK;\n\n}", + "output": "1", + "index": 22449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)\n\n{\n\n int i;\n\n unsigned char __align8 vector128[8] =\n\n { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };\n\n\n\n movq_m2r(*vector128, mm1);\n\n for (i = 0; i < 8; i++) {\n\n movq_m2r(*(block), mm0);\n\n packsswb_m2r(*(block + 4), mm0);\n\n block += 8;\n\n paddb_r2r(mm1, mm0);\n\n movq_r2m(mm0, *pixels);\n\n pixels += line_size;\n\n }\n\n}\n", + "output": "0", + "index": 1367 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qio_dns_resolver_lookup_sync_nop(QIODNSResolver *resolver,\n\n SocketAddressLegacy *addr,\n\n size_t *naddrs,\n\n SocketAddressLegacy ***addrs,\n\n Error **errp)\n\n{\n\n *naddrs = 1;\n\n *addrs = g_new0(SocketAddressLegacy *, 1);\n\n (*addrs)[0] = QAPI_CLONE(SocketAddressLegacy, addr);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22183 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void monitor_readline(const char *prompt, int is_password,\n\n char *buf, int buf_size)\n\n{\n\n int i;\n\n\n\n if (is_password) {\n\n for (i = 0; i < MAX_MON; i++)\n\n if (monitor_hd[i] && monitor_hd[i]->focus == 0)\n\n qemu_chr_send_event(monitor_hd[i], CHR_EVENT_FOCUS);\n\n }\n\n readline_start(prompt, is_password, monitor_readline_cb, NULL);\n\n monitor_readline_buf = buf;\n\n monitor_readline_buf_size = buf_size;\n\n monitor_readline_started = 1;\n\n while (monitor_readline_started) {\n\n main_loop_wait(10);\n\n }\n\n}\n", + "output": "0", + "index": 10046 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hScale8To15_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src,\n\n const int16_t *filter, const int16_t *filterPos,\n\n int filterSize)\n\n{\n\n int i;\n\n for (i=0; i>7, (1<<15)-1); // the cubic equation does overflow ...\n\n //dst[i] = val>>7;\n\n }\n\n}\n", + "output": "1", + "index": 3293 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool vring_should_notify(VirtIODevice *vdev, Vring *vring)\n\n{\n\n uint16_t old, new;\n\n bool v;\n\n /* Flush out used index updates. This is paired\n\n * with the barrier that the Guest executes when enabling\n\n * interrupts. */\n\n smp_mb();\n\n\n\n if ((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) &&\n\n unlikely(!vring_more_avail(vdev, vring))) {\n\n return true;\n\n }\n\n\n\n if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {\n\n return !(vring_get_avail_flags(vdev, vring) &\n\n VRING_AVAIL_F_NO_INTERRUPT);\n\n }\n\n old = vring->signalled_used;\n\n v = vring->signalled_used_valid;\n\n new = vring->signalled_used = vring->last_used_idx;\n\n vring->signalled_used_valid = true;\n\n\n\n if (unlikely(!v)) {\n\n return true;\n\n }\n\n\n\n return vring_need_event(vring_used_event(&vring->vr), new, old);\n\n}\n", + "output": "0", + "index": 13156 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)\n\n{\n\n unsigned char *destptr_bak = destptr;\n\n unsigned char *destptr_end = destptr + destsize;\n\n const unsigned char *srcptr_end = srcptr + srclen;\n\n unsigned mask = *srcptr++;\n\n unsigned maskbit = 0x80;\n\n\n\n while (srcptr < srcptr_end && destptr < destptr_end) {\n\n if (!(mask & maskbit)) {\n\n memcpy(destptr, srcptr, 4);\n\n destptr += 4;\n\n srcptr += 4;\n\n } else {\n\n unsigned ofs = bytestream_get_le16(&srcptr);\n\n unsigned cnt = (ofs >> 11) + 1;\n\n ofs &= 0x7ff;\n\n ofs = FFMIN(ofs, destptr - destptr_bak);\n\n cnt *= 4;\n\n cnt = FFMIN(cnt, destptr_end - destptr);\n\n av_memcpy_backptr(destptr, ofs, cnt);\n\n destptr += cnt;\n\n }\n\n maskbit >>= 1;\n\n if (!maskbit) {\n\n mask = *srcptr++;\n\n while (!mask) {\n\n if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break;\n\n memcpy(destptr, srcptr, 32);\n\n destptr += 32;\n\n srcptr += 32;\n\n mask = *srcptr++;\n\n }\n\n maskbit = 0x80;\n\n }\n\n }\n\n\n\n return destptr - destptr_bak;\n\n}\n", + "output": "1", + "index": 3595 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,\n\n uint64_t *data)\n\n{\n\n PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);\n\n uint32_t val;\n\n\n\n switch(addr) {\n\n case 0x00:\n\n val = acpi_pm1_evt_get_sts(&s->ar, s->ar.tmr.overflow_time);\n\n break;\n\n case 0x02:\n\n val = s->ar.pm1.evt.en;\n\n break;\n\n case 0x04:\n\n val = s->ar.pm1.cnt.cnt;\n\n break;\n\n case 0x08:\n\n val = acpi_pm_tmr_get(&s->ar);\n\n break;\n\n default:\n\n val = 0;\n\n break;\n\n }\n\n PIIX4_DPRINTF(\"PM readw port=0x%04x val=0x%04x\\n\", (unsigned int)addr, val);\n\n *data = val;\n\n}\n", + "output": "1", + "index": 13988 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t allocate_cluster(BlockDriverState *bs, int64_t sector_num)\n\n{\n\n BDRVParallelsState *s = bs->opaque;\n\n uint32_t idx, offset, tmp;\n\n int64_t pos;\n\n int ret;\n\n\n\n idx = sector_num / s->tracks;\n\n offset = sector_num % s->tracks;\n\n\n\n if (idx >= s->catalog_size) {\n\n return -EINVAL;\n\n }\n\n if (s->catalog_bitmap[idx] != 0) {\n\n return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;\n\n }\n\n\n\n pos = bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS;\n\n if (s->has_truncate) {\n\n ret = bdrv_truncate(bs->file, (pos + s->tracks) << BDRV_SECTOR_BITS);\n\n } else {\n\n ret = bdrv_write_zeroes(bs->file, pos, s->tracks, 0);\n\n }\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n s->catalog_bitmap[idx] = pos / s->off_multiplier;\n\n\n\n tmp = cpu_to_le32(s->catalog_bitmap[idx]);\n\n\n\n ret = bdrv_pwrite(bs->file,\n\n sizeof(ParallelsHeader) + idx * sizeof(tmp), &tmp, sizeof(tmp));\n\n if (ret < 0) {\n\n s->catalog_bitmap[idx] = 0;\n\n return ret;\n\n }\n\n return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;\n\n}\n", + "output": "0", + "index": 27054 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td)\n\n{\n\n uint32_t int_mask = 0;\n\n uint32_t plink = td->link;\n\n UHCI_TD ptd;\n\n int ret;\n\n\n\n while (is_valid(plink)) {\n\n uhci_read_td(q->uhci, &ptd, plink);\n\n if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {\n\n break;\n\n }\n\n if (uhci_queue_token(&ptd) != q->token) {\n\n break;\n\n }\n\n trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);\n\n ret = uhci_handle_td(q->uhci, q, &ptd, plink, &int_mask);\n\n if (ret == TD_RESULT_ASYNC_CONT) {\n\n break;\n\n }\n\n assert(ret == TD_RESULT_ASYNC_START);\n\n assert(int_mask == 0);\n\n plink = ptd.link;\n\n }\n\n usb_device_flush_ep_queue(q->ep->dev, q->ep);\n\n}\n", + "output": "1", + "index": 3089 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_bt_handle_data(USBDevice *dev, USBPacket *p)\n\n{\n\n struct USBBtState *s = (struct USBBtState *) dev->opaque;\n\n int ret = 0;\n\n\n\n if (!s->config)\n\n goto fail;\n\n\n\n switch (p->pid) {\n\n case USB_TOKEN_IN:\n\n switch (p->devep & 0xf) {\n\n case USB_EVT_EP:\n\n ret = usb_bt_fifo_dequeue(&s->evt, p);\n\n break;\n\n\n\n case USB_ACL_EP:\n\n ret = usb_bt_fifo_dequeue(&s->acl, p);\n\n break;\n\n\n\n case USB_SCO_EP:\n\n ret = usb_bt_fifo_dequeue(&s->sco, p);\n\n break;\n\n\n\n default:\n\n goto fail;\n\n }\n\n break;\n\n\n\n case USB_TOKEN_OUT:\n\n switch (p->devep & 0xf) {\n\n case USB_ACL_EP:\n\n usb_bt_fifo_out_enqueue(s, &s->outacl, s->hci->acl_send,\n\n usb_bt_hci_acl_complete, p);\n\n break;\n\n\n\n case USB_SCO_EP:\n\n usb_bt_fifo_out_enqueue(s, &s->outsco, s->hci->sco_send,\n\n usb_bt_hci_sco_complete, p);\n\n break;\n\n\n\n default:\n\n goto fail;\n\n }\n\n break;\n\n\n\n default:\n\n fail:\n\n ret = USB_RET_STALL;\n\n break;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 19384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "type_init(parallel_register_types)\n\n\n\nstatic bool parallel_init(ISABus *bus, int index, CharDriverState *chr)\n\n{\n\n DeviceState *dev;\n\n ISADevice *isadev;\n\n\n\n isadev = isa_try_create(bus, \"isa-parallel\");\n\n if (!isadev) {\n\n return false;\n\n }\n\n dev = DEVICE(isadev);\n\n qdev_prop_set_uint32(dev, \"index\", index);\n\n qdev_prop_set_chr(dev, \"chardev\", chr);\n\n if (qdev_init(dev) < 0) {\n\n return false;\n\n }\n\n return true;\n\n}\n", + "output": "1", + "index": 5944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_rfi(CPUPPCState *env)\n\n{\n\n do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1],\n\n ~((target_ulong)0x783F0000), 1);\n\n}\n", + "output": "1", + "index": 22878 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)\n\n{\n\n libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);\n\n enum dshowDeviceType devtype = pin->filter->type;\n\n void *priv_data;\n\n uint8_t *buf;\n\n int buf_size;\n\n int index;\n\n int64_t curtime;\n\n\n\n dshowdebug(\"libAVMemInputPin_Receive(%p)\\n\", this);\n\n\n\n if (!sample)\n\n return E_POINTER;\n\n\n\n if (devtype == VideoDevice) {\n\n /* PTS from video devices is unreliable. */\n\n IReferenceClock *clock = pin->filter->clock;\n\n IReferenceClock_GetTime(clock, &curtime);\n\n } else {\n\n int64_t dummy;\n\n IMediaSample_GetTime(sample, &curtime, &dummy);\n\n curtime += pin->filter->start_time;\n\n }\n\n\n\n buf_size = IMediaSample_GetActualDataLength(sample);\n\n IMediaSample_GetPointer(sample, &buf);\n\n priv_data = pin->filter->priv_data;\n\n index = pin->filter->stream_index;\n\n\n\n pin->filter->callback(priv_data, index, buf, buf_size, curtime);\n\n\n\n return S_OK;\n\n}\n", + "output": "1", + "index": 8499 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void assert_avoptions(AVDictionary *m)\n\n{\n\n AVDictionaryEntry *t;\n\n if ((t = av_dict_get(m, \"\", NULL, AV_DICT_IGNORE_SUFFIX))) {\n\n av_log(NULL, AV_LOG_FATAL, \"Option %s not found.\\n\", t->key);\n\n exit(1);\n\n }\n\n}\n", + "output": "1", + "index": 11 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int compute_mask(int step, uint32_t *mask)\n\n{\n\n int i, z, ret = 0;\n\n int counter_size = sizeof(uint32_t) * (2 * step + 1);\n\n uint32_t *temp1_counter, *temp2_counter, **counter;\n\n temp1_counter = av_mallocz(counter_size);\n\n if (!temp1_counter) {\n\n ret = AVERROR(ENOMEM);\n\n goto end;\n\n }\n\n temp2_counter = av_mallocz(counter_size);\n\n if (!temp2_counter) {\n\n ret = AVERROR(ENOMEM);\n\n goto end;\n\n }\n\n counter = av_mallocz_array(2 * step + 1, sizeof(uint32_t *));\n\n if (!counter) {\n\n ret = AVERROR(ENOMEM);\n\n goto end;\n\n }\n\n for (i = 0; i < 2 * step + 1; i++) {\n\n counter[i] = av_mallocz(counter_size);\n\n if (!counter[i]) {\n\n ret = AVERROR(ENOMEM);\n\n goto end;\n\n }\n\n }\n\n for (i = 0; i < 2 * step + 1; i++) {\n\n memset(temp1_counter, 0, counter_size);\n\n temp1_counter[i] = 1;\n\n for (z = 0; z < step * 2; z += 2) {\n\n add_mask_counter(temp2_counter, counter[z], temp1_counter, step * 2);\n\n memcpy(counter[z], temp1_counter, counter_size);\n\n add_mask_counter(temp1_counter, counter[z + 1], temp2_counter, step * 2);\n\n memcpy(counter[z + 1], temp2_counter, counter_size);\n\n }\n\n }\n\n memcpy(mask, temp1_counter, counter_size);\n\nend:\n\n av_freep(&temp1_counter);\n\n av_freep(&temp2_counter);\n\n for (i = 0; i < 2 * step + 1; i++) {\n\n av_freep(&counter[i]);\n\n }\n\n av_freep(&counter);\n\n return ret;\n\n}\n", + "output": "1", + "index": 9182 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int avr_probe(AVProbeData *p)\n\n{\n\n if (AV_RL32(p->buf) == MKTAG('2', 'B', 'I', 'T'))\n\n return AVPROBE_SCORE_EXTENSION;\n\n return 0;\n\n}\n", + "output": "1", + "index": 14202 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,\n\n SocketAddress *addr,\n\n Error **errp)\n\n{\n\n int fd;\n\n\n\n trace_qio_channel_socket_listen_sync(ioc, addr);\n\n fd = socket_listen(addr, errp);\n\n if (fd < 0) {\n\n trace_qio_channel_socket_listen_fail(ioc);\n\n return -1;\n\n }\n\n\n\n trace_qio_channel_socket_listen_complete(ioc, fd);\n\n if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {\n\n close(fd);\n\n return -1;\n\n }\n\n qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 6088 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qed_write_header_sync(BDRVQEDState *s)\n\n{\n\n QEDHeader le;\n\n int ret;\n\n\n\n qed_header_cpu_to_le(&s->header, &le);\n\n ret = bdrv_pwrite(s->bs->file, 0, &le, sizeof(le));\n\n if (ret != sizeof(le)) {\n\n return ret;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 9531 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int pp_check(int key, int pp, int nx)\n\n{\n\n int access;\n\n\n\n /* Compute access rights */\n\n /* When pp is 3/7, the result is undefined. Set it to noaccess */\n\n access = 0;\n\n if (key == 0) {\n\n switch (pp) {\n\n case 0x0:\n\n case 0x1:\n\n case 0x2:\n\n access |= PAGE_WRITE;\n\n /* No break here */\n\n case 0x3:\n\n case 0x6:\n\n access |= PAGE_READ;\n\n break;\n\n }\n\n } else {\n\n switch (pp) {\n\n case 0x0:\n\n case 0x6:\n\n access = 0;\n\n break;\n\n case 0x1:\n\n case 0x3:\n\n access = PAGE_READ;\n\n break;\n\n case 0x2:\n\n access = PAGE_READ | PAGE_WRITE;\n\n break;\n\n }\n\n }\n\n if (nx == 0) {\n\n access |= PAGE_EXEC;\n\n }\n\n\n\n return access;\n\n}\n", + "output": "0", + "index": 21730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic)\n\n{\n\n av_assert0(0);\n\n\n}", + "output": "1", + "index": 15124 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "print_syscall_ret(int num, abi_long ret)\n\n{\n\n int i;\n\n\n\n for(i=0;i= req->overlap_offset + req->overlap_bytes) {\n\n return false;\n\n }\n\n /* bbbb aaaa */\n\n if (req->overlap_offset >= offset + bytes) {\n\n return false;\n\n }\n\n return true;\n\n}\n", + "output": "0", + "index": 19292 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_thread_report_progress(ThreadFrame *f, int n, int field)\n\n{\n\n PerThreadContext *p;\n\n atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL;\n\n\n\n if (!progress ||\n\n atomic_load_explicit(&progress[field], memory_order_relaxed) >= n)\n\n return;\n\n\n\n p = f->owner[field]->internal->thread_ctx;\n\n\n\n if (f->owner[field]->debug&FF_DEBUG_THREADS)\n\n av_log(f->owner[field], AV_LOG_DEBUG,\n\n \"%p finished %d field %d\\n\", progress, n, field);\n\n\n\n pthread_mutex_lock(&p->progress_mutex);\n\n\n\n atomic_store_explicit(&progress[field], n, memory_order_release);\n\n\n\n pthread_cond_broadcast(&p->progress_cond);\n\n pthread_mutex_unlock(&p->progress_mutex);\n\n}\n", + "output": "1", + "index": 4989 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adpcm_decode_init(AVCodecContext * avctx)\n\n{\n\n ADPCMContext *c = avctx->priv_data;\n\n\n\n if(avctx->channels > 2U){\n\n return -1;\n\n }\n\n\n\n c->channel = 0;\n\n c->status[0].predictor = c->status[1].predictor = 0;\n\n c->status[0].step_index = c->status[1].step_index = 0;\n\n c->status[0].step = c->status[1].step = 0;\n\n\n\n switch(avctx->codec->id) {\n\n case CODEC_ID_ADPCM_CT:\n\n c->status[0].step = c->status[1].step = 511;\n\n break;\n\n case CODEC_ID_ADPCM_IMA_WS:\n\n if (avctx->extradata && avctx->extradata_size == 2 * 4) {\n\n c->status[0].predictor = AV_RL32(avctx->extradata);\n\n c->status[1].predictor = AV_RL32(avctx->extradata + 4);\n\n }\n\n break;\n\n default:\n\n break;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 1713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(wsr_ibreaka)(uint32_t i, uint32_t v)\n\n{\n\n if (env->sregs[IBREAKENABLE] & (1 << i) && env->sregs[IBREAKA + i] != v) {\n\n tb_invalidate_phys_page_range(\n\n env->sregs[IBREAKA + i], env->sregs[IBREAKA + i] + 1, 0);\n\n tb_invalidate_phys_page_range(v, v + 1, 0);\n\n }\n\n env->sregs[IBREAKA + i] = v;\n\n}\n", + "output": "0", + "index": 3349 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64_t r2)\n\n{\n\n /* XXX missing r0 handling */\n\n env->cc_op = 0;\n\n#ifdef CONFIG_USER_ONLY\n\n memmove(g2h(r1), g2h(r2), TARGET_PAGE_SIZE);\n\n#else\n\n mvc_fast_memmove(env, TARGET_PAGE_SIZE, r1, r2);\n\n#endif\n\n}\n", + "output": "0", + "index": 7755 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,\n\n enum AVResampleDitherMethod method)\n\n{\n\n int cpu_flags = av_get_cpu_flags();\n\n\n\n if (EXTERNAL_SSE2(cpu_flags)) {\n\n ddsp->quantize = ff_quantize_sse2;\n\n ddsp->ptr_align = 16;\n\n ddsp->samples_align = 8;\n\n }\n\n\n\n if (method == AV_RESAMPLE_DITHER_RECTANGULAR) {\n\n if (EXTERNAL_SSE2(cpu_flags)) {\n\n ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_sse2;\n\n }\n\n if (EXTERNAL_AVX(cpu_flags)) {\n\n ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_avx;\n\n }\n\n } else {\n\n if (EXTERNAL_SSE2(cpu_flags)) {\n\n ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_sse2;\n\n }\n\n if (EXTERNAL_AVX(cpu_flags)) {\n\n ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_avx;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 3976 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,\n\n Error **errp)\n\n{\n\n struct addrinfo ai, *res;\n\n int rc;\n\n Error *err = NULL;\n\n\n\n memset(&ai, 0, sizeof(ai));\n\n\n\n ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;\n\n ai.ai_family = inet_ai_family_from_address(saddr, &err);\n\n ai.ai_socktype = SOCK_STREAM;\n\n\n\n if (err) {\n\n error_propagate(errp, err);\n\n return NULL;\n\n }\n\n\n\n if (saddr->host == NULL || saddr->port == NULL) {\n\n error_setg(errp, \"host and/or port not specified\");\n\n return NULL;\n\n }\n\n\n\n /* lookup */\n\n rc = getaddrinfo(saddr->host, saddr->port, &ai, &res);\n\n if (rc != 0) {\n\n error_setg(errp, \"address resolution failed for %s:%s: %s\",\n\n saddr->host, saddr->port, gai_strerror(rc));\n\n return NULL;\n\n }\n\n return res;\n\n}\n", + "output": "1", + "index": 6374 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_readlink(struct iovec *iovec, struct iovec *out_iovec)\n\n{\n\n char *buffer;\n\n int size, retval;\n\n V9fsString target, path;\n\n\n\n v9fs_string_init(&path);\n\n retval = proxy_unmarshal(iovec, PROXY_HDR_SZ, \"sd\", &path, &size);\n\n if (retval < 0) {\n\n v9fs_string_free(&path);\n\n return retval;\n\n }\n\n buffer = g_malloc(size);\n\n v9fs_string_init(&target);\n\n retval = readlink(path.data, buffer, size);\n\n if (retval > 0) {\n\n buffer[retval] = '\\0';\n\n v9fs_string_sprintf(&target, \"%s\", buffer);\n\n retval = proxy_marshal(out_iovec, PROXY_HDR_SZ, \"s\", &target);\n\n } else {\n\n retval = -errno;\n\n }\n\n g_free(buffer);\n\n v9fs_string_free(&target);\n\n v9fs_string_free(&path);\n\n return retval;\n\n}\n", + "output": "1", + "index": 17555 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void parse_header_digest(struct iscsi_context *iscsi, const char *target)\n\n{\n\n QemuOptsList *list;\n\n QemuOpts *opts;\n\n const char *digest = NULL;\n\n\n\n list = qemu_find_opts(\"iscsi\");\n\n if (!list) {\n\n return;\n\n }\n\n\n\n opts = qemu_opts_find(list, target);\n\n if (opts == NULL) {\n\n opts = QTAILQ_FIRST(&list->head);\n\n if (!opts) {\n\n return;\n\n }\n\n }\n\n\n\n digest = qemu_opt_get(opts, \"header-digest\");\n\n if (!digest) {\n\n return;\n\n }\n\n\n\n if (!strcmp(digest, \"CRC32C\")) {\n\n iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C);\n\n } else if (!strcmp(digest, \"NONE\")) {\n\n iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE);\n\n } else if (!strcmp(digest, \"CRC32C-NONE\")) {\n\n iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE);\n\n } else if (!strcmp(digest, \"NONE-CRC32C\")) {\n\n iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);\n\n } else {\n\n error_report(\"Invalid header-digest setting : %s\", digest);\n\n }\n\n}\n", + "output": "1", + "index": 681 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MSA_ST_DF(DF_BYTE, b, helper_ret_stb_mmu, oi, GETRA())\n\nMSA_ST_DF(DF_HALF, h, helper_ret_stw_mmu, oi, GETRA())\n\nMSA_ST_DF(DF_WORD, w, helper_ret_stl_mmu, oi, GETRA())\n\nMSA_ST_DF(DF_DOUBLE, d, helper_ret_stq_mmu, oi, GETRA())\n\n#else\n\nMSA_ST_DF(DF_BYTE, b, cpu_stb_data)\n\nMSA_ST_DF(DF_HALF, h, cpu_stw_data)\n\nMSA_ST_DF(DF_WORD, w, cpu_stl_data)\n\nMSA_ST_DF(DF_DOUBLE, d, cpu_stq_data)\n\n#endif\n\n\n\nvoid helper_cache(CPUMIPSState *env, target_ulong addr, uint32_t op)\n\n{\n\n#ifndef CONFIG_USER_ONLY\n\n target_ulong index = addr & 0x1fffffff;\n\n if (op == 9) {\n\n /* Index Store Tag */\n\n memory_region_dispatch_write(env->itc_tag, index, env->CP0_TagLo,\n\n 8, MEMTXATTRS_UNSPECIFIED);\n\n } else if (op == 5) {\n\n /* Index Load Tag */\n\n memory_region_dispatch_read(env->itc_tag, index, &env->CP0_TagLo,\n\n 8, MEMTXATTRS_UNSPECIFIED);\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 10054 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n int ret, flush = 0;\n\n\n\n ret = check_packet(s, pkt);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n if (pkt) {\n\n AVStream *st = s->streams[pkt->stream_index];\n\n\n\n //FIXME/XXX/HACK drop zero sized packets\n\n if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size == 0) {\n\n ret = 0;\n\n goto fail;\n\n }\n\n\n\n av_dlog(s, \"av_interleaved_write_frame size:%d dts:%\" PRId64 \" pts:%\" PRId64 \"\\n\",\n\n pkt->size, pkt->dts, pkt->pts);\n\n if ((ret = compute_pkt_fields2(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))\n\n goto fail;\n\n\n\n if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {\n\n ret = AVERROR(EINVAL);\n\n goto fail;\n\n }\n\n } else {\n\n av_dlog(s, \"av_interleaved_write_frame FLUSH\\n\");\n\n flush = 1;\n\n }\n\n\n\n for (;; ) {\n\n AVPacket opkt;\n\n int ret = interleave_packet(s, &opkt, pkt, flush);\n\n if (pkt) {\n\n memset(pkt, 0, sizeof(*pkt));\n\n av_init_packet(pkt);\n\n pkt = NULL;\n\n }\n\n if (ret <= 0) //FIXME cleanup needed for ret<0 ?\n\n return ret;\n\n\n\n ret = write_packet(s, &opkt);\n\n if (ret >= 0)\n\n s->streams[opkt.stream_index]->nb_frames++;\n\n\n\n av_free_packet(&opkt);\n\n\n\n if (ret < 0)\n\n return ret;\n\n }\n\nfail:\n\n av_packet_unref(pkt);\n\n return ret;\n\n}\n", + "output": "0", + "index": 5602 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void audio_encode_example(const char *filename)\n\n{\n\n AVCodec *codec;\n\n AVCodecContext *c= NULL;\n\n int frame_size, i, j, out_size, outbuf_size;\n\n FILE *f;\n\n short *samples;\n\n float t, tincr;\n\n uint8_t *outbuf;\n\n\n\n printf(\"Audio encoding\\n\");\n\n\n\n /* find the MP2 encoder */\n\n codec = avcodec_find_encoder(CODEC_ID_MP2);\n\n if (!codec) {\n\n fprintf(stderr, \"codec not found\\n\");\n\n exit(1);\n\n }\n\n\n\n c= avcodec_alloc_context();\n\n \n\n /* put sample parameters */\n\n c->bit_rate = 64000;\n\n c->sample_rate = 44100;\n\n c->channels = 2;\n\n\n\n /* open it */\n\n if (avcodec_open(c, codec) < 0) {\n\n fprintf(stderr, \"could not open codec\\n\");\n\n exit(1);\n\n }\n\n \n\n /* the codec gives us the frame size, in samples */\n\n frame_size = c->frame_size;\n\n samples = malloc(frame_size * 2 * c->channels);\n\n outbuf_size = 10000;\n\n outbuf = malloc(outbuf_size);\n\n\n\n f = fopen(filename, \"w\");\n\n if (!f) {\n\n fprintf(stderr, \"could not open %s\\n\", filename);\n\n exit(1);\n\n }\n\n \n\n /* encode a single tone sound */\n\n t = 0;\n\n tincr = 2 * M_PI * 440.0 / c->sample_rate;\n\n for(i=0;i<200;i++) {\n\n for(j=0;jmode & value;\n\n s->mode = value & 0x2fff;\n\n if (diff & (0x3ff << 2)) {\n\n if (value & (1 << 4)) {\t\t\t/* PLL_ENABLE */\n\n div = ((value >> 5) & 3) + 1;\t\t/* PLL_DIV */\n\n mult = MIN((value >> 7) & 0x1f, 1);\t/* PLL_MULT */\n\n } else {\n\n div = bypass_div[((value >> 2) & 3)];\t/* BYPASS_DIV */\n\n mult = 1;\n\n }\n\n omap_clk_setrate(s->dpll, div, mult);\n\n }\n\n\n\n /* Enter the desired mode. */\n\n s->mode = (s->mode & 0xfffe) | ((s->mode >> 4) & 1);\n\n\n\n /* Act as if the lock is restored. */\n\n s->mode |= 2;\n\n } else {\n\n OMAP_BAD_REG(addr);\n\n }\n\n}\n", + "output": "0", + "index": 5638 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)\nint ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,\n int level)\n{\n VDPAUHWContext *hwctx = avctx->hwaccel_context;\n VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;\n VdpDecoderCreate *create;\n void *func;\n VdpStatus status;\n /* See vdpau/vdpau.h for alignment constraints. */\n uint32_t width = (avctx->coded_width + 1) & ~1;\n uint32_t height = (avctx->coded_height + 3) & ~3;\n if (hwctx->context.decoder != VDP_INVALID_HANDLE) {\n vdctx->decoder = hwctx->context.decoder;\n vdctx->render = hwctx->context.render;\n return 0; /* Decoder created by user */\n vdctx->device = hwctx->device;\n vdctx->get_proc_address = hwctx->get_proc_address;\n status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,\n &func);\n if (status != VDP_STATUS_OK)\n return vdpau_error(status);\n else\n create = func;\n status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,\n &func);\n if (status != VDP_STATUS_OK)\n return vdpau_error(status);\n else\n vdctx->render = func;\n status = create(vdctx->device, profile, width, height, avctx->refs,\n &vdctx->decoder);\n return vdpau_error(status);", + "output": "1", + "index": 6971 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ipmi_init_sensors_from_sdrs(IPMIBmcSim *s)\n\n{\n\n unsigned int i, pos;\n\n IPMISensor *sens;\n\n\n\n for (i = 0; i < MAX_SENSORS; i++) {\n\n memset(s->sensors + i, 0, sizeof(*sens));\n\n }\n\n\n\n pos = 0;\n\n for (i = 0; !sdr_find_entry(&s->sdr, i, &pos, NULL); i++) {\n\n struct ipmi_sdr_compact *sdr =\n\n (struct ipmi_sdr_compact *) &s->sdr.sdr[pos];\n\n unsigned int len = sdr->header.rec_length;\n\n\n\n if (len < 20) {\n\n continue;\n\n }\n\n if (sdr->header.rec_type != IPMI_SDR_COMPACT_TYPE) {\n\n continue; /* Not a sensor SDR we set from */\n\n }\n\n\n\n if (sdr->sensor_owner_number > MAX_SENSORS) {\n\n continue;\n\n }\n\n sens = s->sensors + sdr->sensor_owner_number;\n\n\n\n IPMI_SENSOR_SET_PRESENT(sens, 1);\n\n IPMI_SENSOR_SET_SCAN_ON(sens, (sdr->sensor_init >> 6) & 1);\n\n IPMI_SENSOR_SET_EVENTS_ON(sens, (sdr->sensor_init >> 5) & 1);\n\n sens->assert_suppt = sdr->assert_mask[0] | (sdr->assert_mask[1] << 8);\n\n sens->deassert_suppt =\n\n sdr->deassert_mask[0] | (sdr->deassert_mask[1] << 8);\n\n sens->states_suppt =\n\n sdr->discrete_mask[0] | (sdr->discrete_mask[1] << 8);\n\n sens->sensor_type = sdr->sensor_type;\n\n sens->evt_reading_type_code = sdr->reading_type & 0x7f;\n\n\n\n /* Enable all the events that are supported. */\n\n sens->assert_enable = sens->assert_suppt;\n\n sens->deassert_enable = sens->deassert_suppt;\n\n }\n\n}\n", + "output": "1", + "index": 3203 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pollfds_fill(GArray *pollfds, fd_set *rfds, fd_set *wfds,\n\n fd_set *xfds)\n\n{\n\n int nfds = -1;\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 events = pfd->events;\n\n if (events & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {\n\n FD_SET(fd, rfds);\n\n nfds = MAX(nfds, fd);\n\n }\n\n if (events & (G_IO_OUT | G_IO_ERR)) {\n\n FD_SET(fd, wfds);\n\n nfds = MAX(nfds, fd);\n\n }\n\n if (events & G_IO_PRI) {\n\n FD_SET(fd, xfds);\n\n nfds = MAX(nfds, fd);\n\n }\n\n }\n\n return nfds;\n\n}\n", + "output": "1", + "index": 17608 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int g726_decode_init(AVCodecContext *avctx)\n\n{\n\n G726Context* c = avctx->priv_data;\n\n\n\n if (avctx->sample_rate <= 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Samplerate is invalid\\n\");\n\n return -1;\n\n }\n\n\n\n if(avctx->channels != 1){\n\n av_log(avctx, AV_LOG_ERROR, \"Only mono is supported\\n\");\n\n return -1;\n\n }\n\n\n\n c->code_size = avctx->bits_per_coded_sample;\n\n if (c->code_size < 2 || c->code_size > 5) {\n\n av_log(avctx, AV_LOG_ERROR, \"Invalid number of bits %d\\n\", c->code_size);\n\n return AVERROR(EINVAL);\n\n }\n\n g726_reset(c, c->code_size - 2);\n\n\n\n avctx->sample_fmt = AV_SAMPLE_FMT_S16;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 11000 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void vmxnet3_ring_read_curr_cell(Vmxnet3Ring *ring, void *buff)\n\n{\n\n vmw_shmem_read(vmxnet3_ring_curr_cell_pa(ring), buff, ring->cell_size);\n\n}\n", + "output": "1", + "index": 25676 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate)\n\n{\n\n /* any failed or completed migration keeps its state to allow probing of\n\n * migration data, but has no associated file anymore */\n\n if (f && f->ops->set_rate_limit)\n\n return f->ops->set_rate_limit(f->opaque, new_rate);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4559 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_stop(int argc, const char **argv)\n\n{\n\n vm_stop(EXCP_INTERRUPT);\n\n}\n", + "output": "0", + "index": 17720 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_flush(void)\n\n{\n\n AHCIQState *ahci;\n\n\n\n ahci = ahci_boot_and_enable();\n\n ahci_test_flush(ahci);\n\n ahci_shutdown(ahci);\n\n}\n", + "output": "0", + "index": 5678 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_in_use(BlockDriverState *bs)\n\n{\n\n return bs->in_use;\n\n}\n", + "output": "0", + "index": 9848 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int rom_load_all(void)\n\n{\n\n target_phys_addr_t addr = 0;\n\n MemoryRegionSection section;\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 (addr > rom->addr) {\n\n fprintf(stderr, \"rom: requested regions overlap \"\n\n \"(rom %s. free=0x\" TARGET_FMT_plx\n\n \", addr=0x\" TARGET_FMT_plx \")\\n\",\n\n rom->name, addr, rom->addr);\n\n return -1;\n\n }\n\n addr = rom->addr;\n\n addr += rom->romsize;\n\n section = memory_region_find(get_system_memory(), rom->addr, 1);\n\n rom->isrom = section.size && memory_region_is_rom(section.mr);\n\n }\n\n qemu_register_reset(rom_reset, NULL);\n\n roms_loaded = 1;\n\n return 0;\n\n}\n", + "output": "0", + "index": 22779 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,\n\n DeviceState *dev, Error **errp)\n\n{\n\n PCIDevice *pdev = PCI_DEVICE(dev);\n\n int slot = PCI_SLOT(pdev->devfn);\n\n int bsel = acpi_pcihp_get_bsel(pdev->bus);\n\n if (bsel < 0) {\n\n error_setg(errp, \"Unsupported bus. Bus doesn't have property '\"\n\n ACPI_PCIHP_PROP_BSEL \"' set\");\n\n return;\n\n }\n\n\n\n /* Don't send event when device is enabled during qemu machine creation:\n\n * it is present on boot, no hotplug event is necessary. We do send an\n\n * event when the device is disabled later. */\n\n if (!dev->hotplugged) {\n\n return;\n\n }\n\n\n\n s->acpi_pcihp_pci_status[bsel].up |= (1U << slot);\n\n acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);\n\n}\n", + "output": "0", + "index": 3780 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ssh_parse_filename(const char *filename, QDict *options,\n\n Error **errp)\n\n{\n\n if (qdict_haskey(options, \"user\") ||\n\n qdict_haskey(options, \"host\") ||\n\n qdict_haskey(options, \"port\") ||\n\n qdict_haskey(options, \"path\") ||\n\n qdict_haskey(options, \"host_key_check\")) {\n\n error_setg(errp, \"user, host, port, path, host_key_check cannot be used at the same time as a file option\");\n\n return;\n\n }\n\n\n\n parse_uri(filename, options, errp);\n\n}\n", + "output": "0", + "index": 22119 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_next_tick(rc4030State *s)\n\n{\n\n qemu_irq_lower(s->timer_irq);\n\n uint32_t hz;\n\n\n\n hz = 1000 / (s->itr + 1);\n\n\n\n qemu_mod_timer(s->periodic_timer, qemu_get_clock(vm_clock) + ticks_per_sec / hz);\n\n}\n", + "output": "1", + "index": 5321 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,\n\n struct sockaddr *addr,\n\n socklen_t len)\n\n{\n\n struct target_sockaddr *target_saddr;\n\n\n\n if (len == 0) {\n\n return 0;\n\n }\n\n\n\n\n target_saddr = lock_user(VERIFY_WRITE, target_addr, len, 0);\n\n if (!target_saddr)\n\n return -TARGET_EFAULT;\n\n memcpy(target_saddr, addr, len);\n\n if (len >= offsetof(struct target_sockaddr, sa_family) +\n\n sizeof(target_saddr->sa_family)) {\n\n target_saddr->sa_family = tswap16(addr->sa_family);\n\n }\n\n if (addr->sa_family == AF_NETLINK && len >= sizeof(struct sockaddr_nl)) {\n\n struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr;\n\n target_nl->nl_pid = tswap32(target_nl->nl_pid);\n\n target_nl->nl_groups = tswap32(target_nl->nl_groups);\n\n } else if (addr->sa_family == AF_PACKET) {\n\n struct sockaddr_ll *target_ll = (struct sockaddr_ll *)target_saddr;\n\n target_ll->sll_ifindex = tswap32(target_ll->sll_ifindex);\n\n target_ll->sll_hatype = tswap16(target_ll->sll_hatype);\n\n } else if (addr->sa_family == AF_INET6 &&\n\n len >= sizeof(struct target_sockaddr_in6)) {\n\n struct target_sockaddr_in6 *target_in6 =\n\n (struct target_sockaddr_in6 *)target_saddr;\n\n target_in6->sin6_scope_id = tswap16(target_in6->sin6_scope_id);\n\n }\n\n unlock_user(target_saddr, target_addr, len);\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 18433 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nprobe(AVFormatContext *s, uint8_t *enc_header, const uint8_t *n_val)\n\n{\n\n OMAContext *oc = s->priv_data;\n\n uint32_t pos, taglen, datalen;\n\n struct AVDES av_des;\n\n\n\n if (!enc_header || !n_val)\n\n return -1;\n\n\n\n pos = OMA_ENC_HEADER_SIZE + oc->k_size;\n\n if (!memcmp(&enc_header[pos], \"EKB \", 4))\n\n pos += 32;\n\n\n\n if (AV_RB32(&enc_header[pos]) != oc->rid)\n\n av_log(s, AV_LOG_DEBUG, \"Mismatching RID\\n\");\n\n\n\n taglen = AV_RB32(&enc_header[pos+32]);\n\n datalen = AV_RB32(&enc_header[pos+36]) >> 4;\n\n\n\n pos += 44 + taglen;\n\n\n\n av_des_init(&av_des, n_val, 192, 1);\n\n while (datalen-- > 0) {\n\n av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);\n\n kset(s, oc->r_val, NULL, 16);\n\n if (!rprobe(s, enc_header, oc->r_val))\n\n return 0;\n\n pos += 16;\n\n }\n\n\n\n return -1;\n\n}\n", + "output": "0", + "index": 11825 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)\n\n{\n\n ObjectClass *oc;\n\n CPUClass *cc;\n\n Error *err = NULL;\n\n gchar **model_pieces;\n\n const char *cpu_type;\n\n\n\n model_pieces = g_strsplit(cpu_model, \",\", 2);\n\n\n\n oc = cpu_class_by_name(typename, model_pieces[0]);\n\n if (oc == NULL) {\n\n g_strfreev(model_pieces);\n\n return NULL;\n\n }\n\n\n\n cpu_type = object_class_get_name(oc);\n\n cc = CPU_CLASS(oc);\n\n cc->parse_features(cpu_type, model_pieces[1], &err);\n\n g_strfreev(model_pieces);\n\n if (err != NULL) {\n\n error_report_err(err);\n\n return NULL;\n\n }\n\n return cpu_type;\n\n}\n", + "output": "1", + "index": 10734 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qdev_property_add_static(DeviceState *dev, Property *prop,\n\n Error **errp)\n\n{\n\n Error *local_err = NULL;\n\n Object *obj = OBJECT(dev);\n\n\n\n /*\n\n * TODO qdev_prop_ptr does not have getters or setters. It must\n\n * go now that it can be replaced with links. The test should be\n\n * removed along with it: all static properties are read/write.\n\n */\n\n if (!prop->info->get && !prop->info->set) {\n\n return;\n\n }\n\n\n\n object_property_add(obj, prop->name, prop->info->name,\n\n prop->info->get, prop->info->set,\n\n prop->info->release,\n\n prop, &local_err);\n\n\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n object_property_set_description(obj, prop->name,\n\n prop->info->description,\n\n &error_abort);\n\n\n\n if (prop->info->set_default_value) {\n\n prop->info->set_default_value(obj, prop);\n\n }\n\n}\n", + "output": "0", + "index": 9267 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint16_t nvme_del_cq(NvmeCtrl *n, NvmeCmd *cmd)\n\n{\n\n NvmeDeleteQ *c = (NvmeDeleteQ *)cmd;\n\n NvmeCQueue *cq;\n\n uint16_t qid = le16_to_cpu(c->qid);\n\n\n\n if (!qid || nvme_check_cqid(n, qid)) {\n\n return NVME_INVALID_CQID | NVME_DNR;\n\n }\n\n\n\n cq = n->cq[qid];\n\n if (!QTAILQ_EMPTY(&cq->sq_list)) {\n\n return NVME_INVALID_QUEUE_DEL;\n\n }\n\n nvme_free_cq(cq, n);\n\n return NVME_SUCCESS;\n\n}\n", + "output": "1", + "index": 23726 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int eject_device(Monitor *mon, BlockDriverState *bs, int force)\n\n{\n\n if (bdrv_is_inserted(bs)) {\n\n if (!force) {\n\n if (!bdrv_is_removable(bs)) {\n\n qerror_report(QERR_DEVICE_NOT_REMOVABLE,\n\n bdrv_get_device_name(bs));\n\n return -1;\n\n }\n\n if (bdrv_is_locked(bs)) {\n\n qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));\n\n return -1;\n\n }\n\n }\n\n bdrv_close(bs);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 18711 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_tco2_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 = \"-watchdog-action none\";\n\n test_init(&d);\n\n\n\n stop_tco(&d);\n\n clear_tco_status(&d);\n\n reset_on_second_timeout(true);\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 * 2);\n\n\n\n val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);\n\n ret = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;\n\n g_assert(ret == 1);\n\n qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);\n\n g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);\n\n qtest_end();\n\n}\n", + "output": "0", + "index": 1193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "rdt_parse_sdp_line (AVFormatContext *s, int st_index,\n\n PayloadContext *rdt, const char *line)\n\n{\n\n AVStream *stream = s->streams[st_index];\n\n const char *p = line;\n\n\n\n if (av_strstart(p, \"OpaqueData:buffer;\", &p)) {\n\n rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p);\n\n } else if (av_strstart(p, \"StartTime:integer;\", &p))\n\n stream->first_dts = atoi(p);\n\n else if (av_strstart(p, \"ASMRuleBook:string;\", &p)) {\n\n int n, first = -1;\n\n\n\n for (n = 0; n < s->nb_streams; n++)\n\n if (s->streams[n]->id == stream->id) {\n\n int count = s->streams[n]->index + 1;\n\n if (first == -1) first = n;\n\n if (rdt->nb_rmst < count) {\n\n RMStream **rmst= av_realloc(rdt->rmst, count*sizeof(*rmst));\n\n if (!rmst)\n\n return AVERROR(ENOMEM);\n\n memset(rmst + rdt->nb_rmst, 0,\n\n (count - rdt->nb_rmst) * sizeof(*rmst));\n\n rdt->rmst = rmst;\n\n rdt->nb_rmst = count;\n\n }\n\n rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream();\n\n rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2);\n\n\n\n if (s->streams[n]->codec->codec_id == CODEC_ID_AAC)\n\n s->streams[n]->codec->frame_size = 1; // FIXME\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void tlb_flush_page(CPUState *env, target_ulong addr)\n\n{\n\n int i;\n\n\n\n#if defined(DEBUG_TLB)\n\n printf(\"tlb_flush_page: \" TARGET_FMT_lx \"\\n\", addr);\n\n#endif\n\n /* must reset current TB so that interrupts cannot modify the\n\n links while we are modifying them */\n\n env->current_tb = NULL;\n\n\n\n addr &= TARGET_PAGE_MASK;\n\n i = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);\n\n tlb_flush_entry(&env->tlb_table[0][i], addr);\n\n tlb_flush_entry(&env->tlb_table[1][i], addr);\n\n#if (NB_MMU_MODES >= 3)\n\n tlb_flush_entry(&env->tlb_table[2][i], addr);\n\n#if (NB_MMU_MODES == 4)\n\n tlb_flush_entry(&env->tlb_table[3][i], addr);\n\n#endif\n\n#endif\n\n\n\n tlb_flush_jmp_cache(env, addr);\n\n\n\n#ifdef USE_KQEMU\n\n if (env->kqemu_enabled) {\n\n kqemu_flush_page(env, addr);\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 18161 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_rtp_get_payload_type(AVFormatContext *fmt,\n\n AVCodecContext *codec, int idx)\n\n{\n\n int i;\n\n AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL;\n\n\n\n /* Was the payload type already specified for the RTP muxer? */\n\n if (ofmt && ofmt->priv_class && fmt->priv_data) {\n\n int64_t payload_type;\n\n if (av_opt_get_int(fmt->priv_data, \"payload_type\", 0, &payload_type) >= 0 &&\n\n payload_type >= 0)\n\n return (int)payload_type;\n\n }\n\n\n\n /* static payload type */\n\n for (i = 0; rtp_payload_types[i].pt >= 0; ++i)\n\n if (rtp_payload_types[i].codec_id == codec->codec_id) {\n\n if (codec->codec_id == AV_CODEC_ID_H263 && (!fmt ||\n\n !fmt->oformat->priv_class ||\n\n !av_opt_flag_is_set(fmt->priv_data, \"rtpflags\", \"rfc2190\")))\n\n continue;\n\n /* G722 has 8000 as nominal rate even if the sample rate is 16000,\n\n * see section 4.5.2 in RFC 3551. */\n\n if (codec->codec_id == AV_CODEC_ID_ADPCM_G722 &&\n\n codec->sample_rate == 16000 && codec->channels == 1)\n\n return rtp_payload_types[i].pt;\n\n if (codec->codec_type == AVMEDIA_TYPE_AUDIO &&\n\n ((rtp_payload_types[i].clock_rate > 0 &&\n\n codec->sample_rate != rtp_payload_types[i].clock_rate) ||\n\n (rtp_payload_types[i].audio_channels > 0 &&\n\n codec->channels != rtp_payload_types[i].audio_channels)))\n\n continue;\n\n return rtp_payload_types[i].pt;\n\n }\n\n\n\n if (idx < 0)\n\n idx = codec->codec_type == AVMEDIA_TYPE_AUDIO;\n\n\n\n /* dynamic payload type */\n\n return RTP_PT_PRIVATE + idx;\n\n}\n", + "output": "1", + "index": 9337 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_open_sparse(BlockDriverState *bs,\n\n BlockDriverState *file, int flags,\n\n char *buf, Error **errp)\n\n{\n\n uint32_t magic;\n\n\n\n magic = ldl_be_p(buf);\n\n switch (magic) {\n\n case VMDK3_MAGIC:\n\n return vmdk_open_vmfs_sparse(bs, file, flags, errp);\n\n break;\n\n case VMDK4_MAGIC:\n\n return vmdk_open_vmdk4(bs, file, flags, errp);\n\n break;\n\n default:\n\n return -EMEDIUMTYPE;\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 14736 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void notdirty_mem_write(void *opaque, target_phys_addr_t ram_addr,\n\n uint64_t val, unsigned size)\n\n{\n\n int dirty_flags;\n\n dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);\n\n if (!(dirty_flags & CODE_DIRTY_FLAG)) {\n\n#if !defined(CONFIG_USER_ONLY)\n\n tb_invalidate_phys_page_fast(ram_addr, size);\n\n dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);\n\n#endif\n\n }\n\n switch (size) {\n\n case 1:\n\n stb_p(qemu_get_ram_ptr(ram_addr), val);\n\n break;\n\n case 2:\n\n stw_p(qemu_get_ram_ptr(ram_addr), val);\n\n break;\n\n case 4:\n\n stl_p(qemu_get_ram_ptr(ram_addr), val);\n\n break;\n\n default:\n\n abort();\n\n }\n\n dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);\n\n cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);\n\n /* we remove the notdirty callback only if the code has been\n\n flushed */\n\n if (dirty_flags == 0xff)\n\n tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr);\n\n}\n", + "output": "0", + "index": 7031 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int libgsm_close(AVCodecContext *avctx) {\n\n\n gsm_destroy(avctx->priv_data);\n\n avctx->priv_data = NULL;\n\n return 0;\n\n}", + "output": "1", + "index": 17455 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void mix_3f_2r_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] + output[4][i] + output[5][i]);\n\n memset(output[2], 0, sizeof(output[2]));\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": 11823 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void idct4col_put(uint8_t *dest, int line_size, const DCTELEM *col)\n\n{\n\n int c0, c1, c2, c3, a0, a1, a2, a3;\n\n const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n a0 = col[8*0];\n\n a1 = col[8*2];\n\n a2 = col[8*4];\n\n a3 = col[8*6];\n\n c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));\n\n c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));\n\n c1 = a1 * C1 + a3 * C2;\n\n c3 = a1 * C2 - a3 * C1;\n\n dest[0] = cm[(c0 + c1) >> C_SHIFT];\n\n dest += line_size;\n\n dest[0] = cm[(c2 + c3) >> C_SHIFT];\n\n dest += line_size;\n\n dest[0] = cm[(c2 - c3) >> C_SHIFT];\n\n dest += line_size;\n\n dest[0] = cm[(c0 - c1) >> C_SHIFT];\n\n}\n", + "output": "1", + "index": 8883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx)\n\n{\n\n#if HAVE_SSE2_INLINE\n\n if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) {\n\n if (ctx->cid_table->bit_depth == 8)\n\n ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;\n\n }\n\n#endif /* HAVE_SSE2_INLINE */\n\n}\n", + "output": "0", + "index": 10707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int pnm_encode_close(AVCodecContext *avctx)\n\n{\n\n av_frame_free(&avctx->coded_frame);\n\n return 0;\n\n}\n", + "output": "0", + "index": 19756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int signed_shift(int i, int shift) {\n\n if (shift > 0)\n\n return i << shift;\n\n return i >> -shift;\n\n}\n", + "output": "1", + "index": 23316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < nb_clusters; i++) {\n\n int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i]));\n\n\n\n if (type != QCOW2_CLUSTER_UNALLOCATED) {\n\n break;\n\n }\n\n }\n\n\n\n return i;\n\n}\n", + "output": "0", + "index": 1899 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int jp2_find_codestream(J2kDecoderContext *s)\n\n{\n\n uint32_t atom_size;\n\n int found_codestream = 0, search_range = 10;\n\n\n\n // skip jpeg2k signature atom\n\n s->buf += 12;\n\n\n\n while(!found_codestream && search_range && s->buf_end - s->buf >= 8) {\n\n atom_size = AV_RB32(s->buf);\n\n if(AV_RB32(s->buf + 4) == JP2_CODESTREAM) {\n\n found_codestream = 1;\n\n s->buf += 8;\n\n } else {\n\n if (s->buf_end - s->buf < atom_size)\n\n return 0;\n\n s->buf += atom_size;\n\n search_range--;\n\n }\n\n }\n\n\n\n if(found_codestream)\n\n return 1;\n\n return 0;\n\n}\n", + "output": "1", + "index": 22035 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "dprint(int level, const char *fmt, ...)\n\n{\n\n va_list args;\n\n\n\n if (level <= debug) {\n\n va_start(args, fmt);\n\n vfprintf(stderr, fmt, args);\n\n va_end(args);\n\n }\n\n}\n", + "output": "0", + "index": 12130 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,\n\n dirac_source_params *source)\n\n{\n\n unsigned version_major;\n\n unsigned video_format, picture_coding_mode;\n\n\n\n version_major = svq3_get_ue_golomb(gb);\n\n svq3_get_ue_golomb(gb); /* version_minor */\n\n avctx->profile = svq3_get_ue_golomb(gb);\n\n avctx->level = svq3_get_ue_golomb(gb);\n\n video_format = svq3_get_ue_golomb(gb);\n\n\n\n if (version_major < 2)\n\n av_log(avctx, AV_LOG_WARNING, \"Stream is old and may not work\\n\");\n\n else if (version_major > 2)\n\n av_log(avctx, AV_LOG_WARNING, \"Stream may have unhandled features\\n\");\n\n\n\n if (video_format > 20)\n\n return -1;\n\n\n\n // Fill in defaults for the source parameters.\n\n *source = dirac_source_parameters_defaults[video_format];\n\n\n\n // Override the defaults.\n\n if (parse_source_parameters(avctx, gb, source))\n\n return -1;\n\n\n\n if (av_image_check_size(source->width, source->height, 0, avctx))\n\n return -1;\n\n\n\n avcodec_set_dimensions(avctx, source->width, source->height);\n\n\n\n // currently only used to signal field coding\n\n picture_coding_mode = svq3_get_ue_golomb(gb);\n\n if (picture_coding_mode != 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Unsupported picture coding mode %d\",\n\n picture_coding_mode);\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 4267 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_in_fail_list(TestInputVisitorData *data,\n\n const void *unused)\n\n{\n\n int64_t i64 = -1;\n\n Visitor *v;\n\n\n\n /* Unvisited list tail */\n\n\n\n v = visitor_input_test_init(data, \"[ 1, 2, 3 ]\");\n\n\n\n visit_start_list(v, NULL, NULL, 0, &error_abort);\n\n visit_type_int(v, NULL, &i64, &error_abort);\n\n g_assert_cmpint(i64, ==, 1);\n\n visit_type_int(v, NULL, &i64, &error_abort);\n\n g_assert_cmpint(i64, ==, 2);\n\n visit_end_list(v, NULL);\n\n /* BUG: unvisited tail not reported; actually not reportable by design */\n\n}\n", + "output": "0", + "index": 14885 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mv88w8618_register_devices(void)\n\n{\n\n#ifdef HAS_AUDIO\n\n sysbus_register_withprop(&mv88w8618_audio_info);\n\n#endif\n\n}\n", + "output": "0", + "index": 15699 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,\n const char *name,\n uint64_t ram_size)\n{\n uint64_t addr = 0;\n int i;\n if (nb_numa_nodes == 0 || !have_memdevs) {\n allocate_system_memory_nonnuma(mr, owner, name, ram_size);\n return;\n memory_region_init(mr, owner, name, ram_size);\n for (i = 0; i < MAX_NODES; i++) {\n Error *local_err = NULL;\n uint64_t size = numa_info[i].node_mem;\n HostMemoryBackend *backend = numa_info[i].node_memdev;\n if (!backend) {\n continue;\n MemoryRegion *seg = host_memory_backend_get_memory(backend, &local_err);\n if (local_err) {\n qerror_report_err(local_err);\n memory_region_add_subregion(mr, addr, seg);\n vmstate_register_ram_global(seg);\n addr += size;", + "output": "1", + "index": 18627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qmp_chardev_open_serial(const char *id,\n\n ChardevBackend *backend,\n\n ChardevReturn *ret,\n\n Error **errp)\n\n{\n\n ChardevHostdev *serial = backend->serial;\n\n int fd;\n\n\n\n fd = qmp_chardev_open_file_source(serial->device, O_RDWR, errp);\n\n if (fd < 0) {\n\n return NULL;\n\n }\n\n qemu_set_nonblock(fd);\n\n return qemu_chr_open_tty_fd(fd);\n\n}\n", + "output": "0", + "index": 11840 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_io_unplugged_begin(BlockDriverState *bs)\n\n{\n\n BdrvChild *child;\n\n\n\n if (bs->io_plug_disabled++ == 0 && bs->io_plugged > 0) {\n\n BlockDriver *drv = bs->drv;\n\n if (drv && drv->bdrv_io_unplug) {\n\n drv->bdrv_io_unplug(bs);\n\n }\n\n }\n\n\n\n QLIST_FOREACH(child, &bs->children, next) {\n\n bdrv_io_unplugged_begin(child->bs);\n\n }\n\n}\n", + "output": "0", + "index": 19385 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32 float64_to_uint32_round_to_zero( float64 a STATUS_PARAM )\n\n{\n\n int64_t v;\n\n uint32 res;\n\n\n\n v = float64_to_int64_round_to_zero(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": 19168 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)\n\n{\n\n BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s->vdev)));\n\n VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n\n VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);\n\n unsigned i;\n\n unsigned nvqs = s->conf->num_queues;\n\n\n\n if (!vblk->dataplane_started || s->stopping) {\n\n return;\n\n }\n\n\n\n /* Better luck next time. */\n\n if (vblk->dataplane_disabled) {\n\n vblk->dataplane_disabled = false;\n\n vblk->dataplane_started = false;\n\n return;\n\n }\n\n s->stopping = true;\n\n trace_virtio_blk_data_plane_stop(s);\n\n\n\n aio_context_acquire(s->ctx);\n\n\n\n /* Stop notifications for new requests from guest */\n\n for (i = 0; i < nvqs; i++) {\n\n VirtQueue *vq = virtio_get_queue(s->vdev, i);\n\n\n\n virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, NULL);\n\n }\n\n\n\n /* Drain and switch bs back to the QEMU main loop */\n\n blk_set_aio_context(s->conf->conf.blk, qemu_get_aio_context());\n\n\n\n aio_context_release(s->ctx);\n\n\n\n for (i = 0; i < nvqs; i++) {\n\n virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);\n\n }\n\n\n\n /* Clean up guest notifier (irq) */\n\n k->set_guest_notifiers(qbus->parent, nvqs, false);\n\n\n\n vblk->dataplane_started = false;\n\n s->stopping = false;\n\n}\n", + "output": "0", + "index": 7439 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "tight_detect_smooth_image(VncState *vs, int w, int h)\n\n{\n\n uint errors;\n\n int compression = vs->tight.compression;\n\n int quality = vs->tight.quality;\n\n\n\n if (!vs->vd->lossy) {\n\n return 0;\n\n }\n\n\n\n if (ds_get_bytes_per_pixel(vs->ds) == 1 ||\n\n vs->clientds.pf.bytes_per_pixel == 1 ||\n\n w < VNC_TIGHT_DETECT_MIN_WIDTH || h < VNC_TIGHT_DETECT_MIN_HEIGHT) {\n\n return 0;\n\n }\n\n\n\n if (vs->tight.quality != -1) {\n\n if (w * h < VNC_TIGHT_JPEG_MIN_RECT_SIZE) {\n\n return 0;\n\n }\n\n } else {\n\n if (w * h < tight_conf[compression].gradient_min_rect_size) {\n\n return 0;\n\n }\n\n }\n\n\n\n if (vs->clientds.pf.bytes_per_pixel == 4) {\n\n if (vs->tight.pixel24) {\n\n errors = tight_detect_smooth_image24(vs, w, h);\n\n if (vs->tight.quality != -1) {\n\n return (errors < tight_conf[quality].jpeg_threshold24);\n\n }\n\n return (errors < tight_conf[compression].gradient_threshold24);\n\n } else {\n\n errors = tight_detect_smooth_image32(vs, w, h);\n\n }\n\n } else {\n\n errors = tight_detect_smooth_image16(vs, w, h);\n\n }\n\n if (quality != -1) {\n\n return (errors < tight_conf[quality].jpeg_threshold);\n\n }\n\n return (errors < tight_conf[compression].gradient_threshold);\n\n}\n", + "output": "0", + "index": 26058 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct vm_area_struct *vma_next(struct vm_area_struct *vma)\n\n{\n\n return (TAILQ_NEXT(vma, vma_link));\n\n}\n", + "output": "0", + "index": 15830 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_inject_mce(Monitor *mon, const QDict *qdict)\n\n{\n\n CPUState *cenv;\n\n int cpu_index = qdict_get_int(qdict, \"cpu_index\");\n\n int bank = qdict_get_int(qdict, \"bank\");\n\n uint64_t status = qdict_get_int(qdict, \"status\");\n\n uint64_t mcg_status = qdict_get_int(qdict, \"mcg_status\");\n\n uint64_t addr = qdict_get_int(qdict, \"addr\");\n\n uint64_t misc = qdict_get_int(qdict, \"misc\");\n\n\n\n for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu)\n\n if (cenv->cpu_index == cpu_index && cenv->mcg_cap) {\n\n cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 6704 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,\n\n uint16_t subchannel_nr, uint32_t io_int_parm,\n\n uint32_t io_int_word)\n\n{\n\n uint32_t type;\n\n\n\n if (io_int_word & IO_INT_WORD_AI) {\n\n type = KVM_S390_INT_IO(1, 0, 0, 0);\n\n } else {\n\n 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) | subchannel_nr,\n\n ((uint64_t)io_int_parm << 32) | io_int_word, 1);\n\n}\n", + "output": "0", + "index": 168 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int probe(AVProbeData *p)\n\n{\n\n if (p->buf_size < 13)\n\n return 0;\n\n\n\n if (p->buf[0] == 0x01 && p->buf[1] == 0x00 &&\n\n p->buf[4] == 0x01 + p->buf[2] &&\n\n p->buf[8] == p->buf[4] + p->buf[6] &&\n\n p->buf[12] == p->buf[8] + p->buf[10])\n\n return AVPROBE_SCORE_MAX;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 2434 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void rgb15tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size)\n\n{\n\n\tunsigned i;\n\n\tunsigned num_pixels = src_size >> 1;\n\n\t\n\n\tfor(i=0; i>5;\n\n\t b = (rgb&0x7C00)>>10;\n\n\t dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);\n\n\t}\n\n}\n", + "output": "1", + "index": 3142 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_device_unrealize(SCSIDevice *s, Error **errp)\n\n{\n\n SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);\n\n if (sc->unrealize) {\n\n sc->unrealize(s, errp);\n\n }\n\n}\n", + "output": "0", + "index": 10281 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt,\n\n QObject *token, const char *msg, ...)\n\n{\n\n va_list ap;\n\n char message[1024];\n\n va_start(ap, msg);\n\n vsnprintf(message, sizeof(message), msg, ap);\n\n va_end(ap);\n\n if (ctxt->err) {\n\n error_free(ctxt->err);\n\n ctxt->err = NULL;\n\n }\n\n error_setg(&ctxt->err, \"JSON parse error, %s\", message);\n\n}\n", + "output": "0", + "index": 11147 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DISAS_INSN(fsave)\n\n{\n\n /* TODO: Implement fsave. */\n\n qemu_assert(0, \"FSAVE not implemented\");\n\n}\n", + "output": "1", + "index": 8700 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vm_change_state_handler(void *opaque, int running,\n\n RunState state)\n\n{\n\n GICv3ITSState *s = (GICv3ITSState *)opaque;\n\n Error *err = NULL;\n\n int ret;\n\n\n\n if (running) {\n\n return;\n\n }\n\n\n\n ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,\n\n KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err);\n\n if (err) {\n\n error_report_err(err);\n\n }\n\n if (ret < 0 && ret != -EFAULT) {\n\n abort();\n\n }\n\n}\n", + "output": "1", + "index": 17377 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_divwuo (void)\n\n{\n\n if (likely((uint32_t)T1 != 0)) {\n\n xer_ov = 0;\n\n T0 = (uint32_t)T0 / (uint32_t)T1;\n\n } else {\n\n xer_so = 1;\n\n xer_ov = 1;\n\n T0 = 0;\n\n }\n\n}\n", + "output": "1", + "index": 1040 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "GList *range_list_insert(GList *list, Range *data)\n\n{\n\n GList *l;\n\n\n\n /* Range lists require no empty ranges */\n\n assert(data->begin < data->end || (data->begin && !data->end));\n\n\n\n /* Skip all list elements strictly less than data */\n\n for (l = list; l && range_compare(l->data, data) < 0; l = l->next) {\n\n }\n\n\n\n if (!l || range_compare(l->data, data) > 0) {\n\n /* Rest of the list (if any) is strictly greater than @data */\n\n return g_list_insert_before(list, l, data);\n\n }\n\n\n\n /* Current list element overlaps @data, merge the two */\n\n range_extend(l->data, data);\n\n g_free(data);\n\n\n\n /* Merge any subsequent list elements that now also overlap */\n\n while (l->next && range_compare(l->data, l->next->data) == 0) {\n\n GList *new_l;\n\n\n\n range_extend(l->data, l->next->data);\n\n g_free(l->next->data);\n\n new_l = g_list_delete_link(list, l->next);\n\n assert(new_l == list);\n\n }\n\n\n\n return list;\n\n}\n", + "output": "0", + "index": 18864 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DeviceState *qdev_device_add(QemuOpts *opts)\n\n{\n\n DeviceClass *k;\n\n const char *driver, *path, *id;\n\n DeviceState *qdev;\n\n BusState *bus;\n\n\n\n driver = qemu_opt_get(opts, \"driver\");\n\n if (!driver) {\n\n qerror_report(QERR_MISSING_PARAMETER, \"driver\");\n\n return NULL;\n\n }\n\n\n\n /* find driver */\n\n k = DEVICE_CLASS(object_class_by_name(driver));\n\n\n\n /* find bus */\n\n path = qemu_opt_get(opts, \"bus\");\n\n if (path != NULL) {\n\n bus = qbus_find(path);\n\n if (!bus) {\n\n return NULL;\n\n }\n\n if (bus->info != k->bus_info) {\n\n qerror_report(QERR_BAD_BUS_FOR_DEVICE,\n\n driver, bus->info->name);\n\n return NULL;\n\n }\n\n } else {\n\n bus = qbus_find_recursive(main_system_bus, NULL, k->bus_info);\n\n if (!bus) {\n\n qerror_report(QERR_NO_BUS_FOR_DEVICE,\n\n driver, k->bus_info->name);\n\n return NULL;\n\n }\n\n }\n\n if (qdev_hotplug && !bus->allow_hotplug) {\n\n qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);\n\n return NULL;\n\n }\n\n\n\n /* create device, set properties */\n\n qdev = qdev_create_from_info(bus, driver);\n\n id = qemu_opts_id(opts);\n\n if (id) {\n\n qdev->id = id;\n\n qdev_property_add_child(qdev_get_peripheral(), qdev->id, qdev, NULL);\n\n } else {\n\n static int anon_count;\n\n gchar *name = g_strdup_printf(\"device[%d]\", anon_count++);\n\n qdev_property_add_child(qdev_get_peripheral_anon(), name,\n\n qdev, NULL);\n\n g_free(name);\n\n } \n\n if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {\n\n qdev_free(qdev);\n\n return NULL;\n\n }\n\n if (qdev_init(qdev) < 0) {\n\n qerror_report(QERR_DEVICE_INIT_FAILED, driver);\n\n return NULL;\n\n }\n\n qdev->opts = opts;\n\n return qdev;\n\n}\n", + "output": "0", + "index": 22551 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_bink_idct_c(DCTELEM *block)\n\n{\n\n int i;\n\n DCTELEM temp[64];\n\n\n\n for (i = 0; i < 8; i++)\n\n bink_idct_col(&temp[i], &block[i]);\n\n for (i = 0; i < 8; i++) {\n\n IDCT_ROW( (&block[8*i]), (&temp[8*i]) );\n\n }\n\n}\n", + "output": "1", + "index": 9607 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void writer_print_time(WriterContext *wctx, const char *key,\n\n int64_t ts, const AVRational *time_base, int is_duration)\n\n{\n\n char buf[128];\n\n\n\n if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {\n\n writer_print_string(wctx, key, \"N/A\", 1);\n\n } else {\n\n double d = ts * av_q2d(*time_base);\n\n struct unit_value uv;\n\n uv.val.d = d;\n\n uv.unit = unit_second_str;\n\n value_string(buf, sizeof(buf), uv);\n\n writer_print_string(wctx, key, buf, 0);\n\n }\n\n}\n", + "output": "0", + "index": 16106 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,\n\n uint8_t *properties)\n\n{\n\n int compno;\n\n\n\n if (s->buf_end - s->buf < 1)\n\n return AVERROR(EINVAL);\n\n\n\n compno = bytestream_get_byte(&s->buf);\n\n properties[compno] |= HAD_QCC;\n\n return get_qcx(s, n - 1, q + compno);\n\n}\n", + "output": "0", + "index": 11575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_qemu_strtoll_max(void)\n\n{\n\n const char *str = g_strdup_printf(\"%lld\", LLONG_MAX);\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, ==, LLONG_MAX);\n\n g_assert(endptr == str + strlen(str));\n\n}\n", + "output": "1", + "index": 25042 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int swr_convert_frame(SwrContext *s,\n\n AVFrame *out, const AVFrame *in)\n\n{\n\n int ret, setup = 0;\n\n\n\n if (!swr_is_initialized(s)) {\n\n if ((ret = swr_config_frame(s, out, in)) < 0)\n\n return ret;\n\n if ((ret = swr_init(s)) < 0)\n\n return ret;\n\n setup = 1;\n\n } else {\n\n // return as is or reconfigure for input changes?\n\n if ((ret = config_changed(s, out, in)))\n\n return ret;\n\n }\n\n\n\n if (out) {\n\n if (!out->linesize[0]) {\n\n out->nb_samples = swr_get_delay(s, s->out_sample_rate)\n\n + in->nb_samples*(int64_t)s->out_sample_rate / s->in_sample_rate\n\n + 3;\n\n if ((ret = av_frame_get_buffer(out, 0)) < 0) {\n\n if (setup)\n\n swr_close(s);\n\n return ret;\n\n }\n\n } else {\n\n if (!out->nb_samples)\n\n out->nb_samples = available_samples(out);\n\n }\n\n }\n\n\n\n return convert_frame(s, out, in);\n\n}\n", + "output": "1", + "index": 20452 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static float quantize_band_cost_bits(struct AACEncContext *s, const float *in,\n\n const float *scaled, int size, int scale_idx,\n\n int cb, const float lambda, const float uplim,\n\n int *bits, int rtz)\n\n{\n\n return get_band_numbits(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits);\n\n}\n", + "output": "1", + "index": 16719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I)\n\n{\n\n LOAD_PIXELS\n\n return simple_limit(p, stride, 2*E+I)\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": 24912 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool adding_first_cpu(void)\n\n{\n\n CPUState *cpu;\n\n size_t count = 0;\n\n CPU_FOREACH(cpu) {\n\n count++;\n\n if (count > 1) {\n\n return false;\n\n }\n\n }\n\n return true;\n\n}\n", + "output": "1", + "index": 1451 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_net_handle_dataout(USBNetState *s, USBPacket *p)\n\n{\n\n int ret = p->len;\n\n int sz = sizeof(s->out_buf) - s->out_ptr;\n\n struct rndis_packet_msg_type *msg =\n\n (struct rndis_packet_msg_type *) s->out_buf;\n\n uint32_t len;\n\n\n\n#ifdef TRAFFIC_DEBUG\n\n fprintf(stderr, \"usbnet: data out len %u\\n\", p->len);\n\n {\n\n int i;\n\n fprintf(stderr, \":\");\n\n for (i = 0; i < p->len; i++) {\n\n if (!(i & 15))\n\n fprintf(stderr, \"\\n%04x:\", i);\n\n fprintf(stderr, \" %02x\", p->data[i]);\n\n }\n\n fprintf(stderr, \"\\n\\n\");\n\n }\n\n#endif\n\n\n\n if (sz > ret)\n\n sz = ret;\n\n memcpy(&s->out_buf[s->out_ptr], p->data, sz);\n\n s->out_ptr += sz;\n\n\n\n if (!s->rndis) {\n\n if (ret < 64) {\n\n qemu_send_packet(&s->nic->nc, s->out_buf, s->out_ptr);\n\n s->out_ptr = 0;\n\n }\n\n return ret;\n\n }\n\n len = le32_to_cpu(msg->MessageLength);\n\n if (s->out_ptr < 8 || s->out_ptr < len)\n\n return ret;\n\n if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {\n\n uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);\n\n uint32_t size = le32_to_cpu(msg->DataLength);\n\n if (offs + size <= len)\n\n qemu_send_packet(&s->nic->nc, s->out_buf + offs, size);\n\n }\n\n s->out_ptr -= len;\n\n memmove(s->out_buf, &s->out_buf[len], s->out_ptr);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 4112 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_chroma_qp(int chroma_qp_index_offset, int qscale){\n\n\n\n return chroma_qp[av_clip(qscale + chroma_qp_index_offset, 0, 51)];\n\n}\n", + "output": "1", + "index": 8097 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_cpu_reset(void *opaque)\n\n{\n\n X86CPU *cpu = opaque;\n\n CPUX86State *env = &cpu->env;\n\n\n\n cpu_reset(CPU(cpu));\n\n env->halted = !cpu_is_bsp(env);\n\n}\n", + "output": "0", + "index": 11407 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "VLANState *qemu_find_vlan(int id, int allocate)\n\n{\n\n VLANState **pvlan, *vlan;\n\n for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) {\n\n if (vlan->id == id)\n\n return vlan;\n\n }\n\n if (!allocate) {\n\n return NULL;\n\n }\n\n vlan = qemu_mallocz(sizeof(VLANState));\n\n vlan->id = id;\n\n TAILQ_INIT(&vlan->send_queue);\n\n vlan->next = NULL;\n\n pvlan = &first_vlan;\n\n while (*pvlan != NULL)\n\n pvlan = &(*pvlan)->next;\n\n *pvlan = vlan;\n\n return vlan;\n\n}\n", + "output": "0", + "index": 22199 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_dimm_check_memdev_is_busy(Object *obj, const char *name,\n\n Object *val, Error **errp)\n\n{\n\n MemoryRegion *mr;\n\n Error *local_err = NULL;\n\n\n\n mr = host_memory_backend_get_memory(MEMORY_BACKEND(val), &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n if (memory_region_is_mapped(mr)) {\n\n char *path = object_get_canonical_path_component(val);\n\n error_setg(&local_err, \"can't use already busy memdev: %s\", path);\n\n g_free(path);\n\n } else {\n\n qdev_prop_allow_set_link_before_realize(obj, name, val, &local_err);\n\n }\n\n\n\nout:\n\n error_propagate(errp, local_err);\n\n}\n", + "output": "0", + "index": 2193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_savevm_state_iterate(QEMUFile *f)\n\n{\n\n SaveStateEntry *se;\n\n int ret = 1;\n\n\n\n TAILQ_FOREACH(se, &savevm_handlers, entry) {\n\n if (se->save_live_state == NULL)\n\n continue;\n\n\n\n /* Section type */\n\n qemu_put_byte(f, QEMU_VM_SECTION_PART);\n\n qemu_put_be32(f, se->section_id);\n\n\n\n ret &= !!se->save_live_state(f, QEMU_VM_SECTION_PART, se->opaque);\n\n }\n\n\n\n if (ret)\n\n return 1;\n\n\n\n if (qemu_file_has_error(f))\n\n return -EIO;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 3648 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_system_reset_request(void)\n\n{\n\n if (no_reboot) {\n\n shutdown_requested = 1;\n\n } else {\n\n reset_requested = 1;\n\n }\n\n cpu_stop_current();\n\n qemu_notify_event();\n\n}\n", + "output": "1", + "index": 9600 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void realtime_init(void)\n\n{\n\n if (enable_mlock) {\n\n if (os_mlock() < 0) {\n\n fprintf(stderr, \"qemu: locking memory failed\\n\");\n\n exit(1);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 14224 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int update_offset(RTMPContext *rt, int size)\n\n{\n\n int old_flv_size;\n\n\n\n // generate packet header and put data into buffer for FLV demuxer\n\n if (rt->flv_off < rt->flv_size) {\n\n // There is old unread data in the buffer, thus append at the end\n\n old_flv_size = rt->flv_size;\n\n rt->flv_size += size + 15;\n\n } else {\n\n // All data has been read, write the new data at the start of the buffer\n\n old_flv_size = 0;\n\n rt->flv_size = size + 15;\n\n rt->flv_off = 0;\n\n }\n\n\n\n return old_flv_size;\n\n}\n", + "output": "1", + "index": 19855 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg)\n\n{\n\n if (!s->chr_ioctl)\n\n return -ENOTSUP;\n\n return s->chr_ioctl(s, cmd, arg);\n\n}\n", + "output": "0", + "index": 7223 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_device_attach(USBDevice *dev, Error **errp)\n\n{\n\n USBBus *bus = usb_bus_from_device(dev);\n\n USBPort *port = dev->port;\n\n char devspeed[32], portspeed[32];\n\n\n\n assert(port != NULL);\n\n assert(!dev->attached);\n\n usb_mask_to_str(devspeed, sizeof(devspeed), dev->speedmask);\n\n usb_mask_to_str(portspeed, sizeof(portspeed), port->speedmask);\n\n trace_usb_port_attach(bus->busnr, port->path,\n\n devspeed, portspeed);\n\n\n\n if (!(port->speedmask & dev->speedmask)) {\n\n error_setg(errp, \"Warning: speed mismatch trying to attach\"\n\n \" usb device \\\"%s\\\" (%s speed)\"\n\n \" to bus \\\"%s\\\", port \\\"%s\\\" (%s speed)\",\n\n dev->product_desc, devspeed,\n\n bus->qbus.name, port->path, portspeed);\n\n return;\n\n }\n\n\n\n dev->attached++;\n\n usb_attach(port);\n\n}\n", + "output": "0", + "index": 9573 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void process_tns_coeffs(TemporalNoiseShaping *tns, double *coef_raw,\n\n int *order_p, int w, int filt)\n\n{\n\n int i, j, order = *order_p;\n\n int *idx = tns->coef_idx[w][filt];\n\n float *lpc = tns->coef[w][filt];\n\n float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};\n\n\n\n if (!order)\n\n return;\n\n\n\n /* Not what the specs say, but it's better */\n\n for (i = 0; i < order; i++) {\n\n idx[i] = quant_array_idx(coef_raw[i], tns_tmp2_map_0_4, 16);\n\n lpc[i] = tns_tmp2_map_0_4[idx[i]];\n\n }\n\n\n\n /* Trim any coeff less than 0.1f from the end */\n\n for (i = order-1; i > -1; i--) {\n\n lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f;\n\n if (lpc[i] != 0.0 ) {\n\n order = i;\n\n break;\n\n }\n\n }\n\n\n\n /* Step up procedure, convert to LPC coeffs */\n\n out[0] = 1.0f;\n\n for (i = 1; i <= order; i++) {\n\n for (j = 1; j < i; j++) {\n\n temp[j] = out[j] + lpc[i]*out[i-j];\n\n }\n\n for (j = 1; j <= i; j++) {\n\n out[j] = temp[j];\n\n }\n\n out[i] = lpc[i-1];\n\n }\n\n *order_p = order;\n\n memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float));\n\n}\n", + "output": "1", + "index": 19841 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)\n\n{\n\n int64_t start, end, nb_sectors;\n\n QEMUIOVector iov;\n\n\n\n if (!s->bdrv || bdrv_is_read_only(s->bdrv)) {\n\n return;\n\n }\n\n\n\n assert(!(len % BDRV_SECTOR_SIZE));\n\n start = off / BDRV_SECTOR_SIZE;\n\n end = (off + len) / BDRV_SECTOR_SIZE;\n\n nb_sectors = end - start;\n\n qemu_iovec_init(&iov, 1);\n\n qemu_iovec_add(&iov, s->storage + (start * BDRV_SECTOR_SIZE),\n\n nb_sectors * BDRV_SECTOR_SIZE);\n\n bdrv_aio_writev(s->bdrv, start, &iov, nb_sectors, bdrv_sync_complete, NULL);\n\n}\n", + "output": "0", + "index": 14426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void t_gen_lsl(TCGv d, TCGv a, TCGv b)\n\n{\n\n\tTCGv t0, t_31;\n\n\n\n\tt0 = tcg_temp_new(TCG_TYPE_TL);\n\n\tt_31 = tcg_temp_new(TCG_TYPE_TL);\n\n\ttcg_gen_shl_tl(d, a, b);\n\n\n\n\ttcg_gen_movi_tl(t_31, 31);\n\n\ttcg_gen_sub_tl(t0, t_31, b);\n\n\ttcg_gen_sar_tl(t0, t0, t_31);\n\n\ttcg_gen_and_tl(t0, t0, d);\n\n\ttcg_gen_xor_tl(d, d, t0);\n\n\ttcg_temp_free(t0);\n\n\ttcg_temp_free(t_31);\n\n}\n", + "output": "1", + "index": 6440 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtqueue_map(VirtQueueElement *elem)\n\n{\n\n virtqueue_map_iovec(elem->in_sg, elem->in_addr, &elem->in_num,\n\n VIRTQUEUE_MAX_SIZE, 1);\n\n virtqueue_map_iovec(elem->out_sg, elem->out_addr, &elem->out_num,\n\n VIRTQUEUE_MAX_SIZE, 0);\n\n}\n", + "output": "0", + "index": 2491 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_enqueue_packet(VLANClientState *sender,\n\n const uint8_t *buf, int size,\n\n NetPacketSent *sent_cb)\n\n{\n\n VLANPacket *packet;\n\n\n\n packet = qemu_malloc(sizeof(VLANPacket) + size);\n\n packet->sender = sender;\n\n packet->size = size;\n\n packet->sent_cb = sent_cb;\n\n memcpy(packet->data, buf, size);\n\n\n\n TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry);\n\n}\n", + "output": "0", + "index": 18596 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int kvm_arch_handle_exit(CPUPPCState *env, struct kvm_run *run)\n\n{\n\n int ret;\n\n\n\n switch (run->exit_reason) {\n\n case KVM_EXIT_DCR:\n\n if (run->dcr.is_write) {\n\n dprintf(\"handle dcr write\\n\");\n\n ret = kvmppc_handle_dcr_write(env, run->dcr.dcrn, run->dcr.data);\n\n } else {\n\n dprintf(\"handle dcr read\\n\");\n\n ret = kvmppc_handle_dcr_read(env, run->dcr.dcrn, &run->dcr.data);\n\n }\n\n break;\n\n case KVM_EXIT_HLT:\n\n dprintf(\"handle halt\\n\");\n\n ret = kvmppc_handle_halt(env);\n\n break;\n\n#ifdef CONFIG_PSERIES\n\n case KVM_EXIT_PAPR_HCALL:\n\n dprintf(\"handle PAPR hypercall\\n\");\n\n run->papr_hcall.ret = spapr_hypercall(env, run->papr_hcall.nr,\n\n run->papr_hcall.args);\n\n ret = 1;\n\n break;\n\n#endif\n\n default:\n\n fprintf(stderr, \"KVM: unknown exit reason %d\\n\", run->exit_reason);\n\n ret = -1;\n\n break;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 5861 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_audio_interleave_init(AVFormatContext *s,\n\n const int *samples_per_frame,\n\n AVRational time_base)\n\n{\n\n int i;\n\n\n\n if (!samples_per_frame)\n\n return -1;\n\n\n\n if (!time_base.num) {\n\n av_log(s, AV_LOG_ERROR, \"timebase not set for audio interleave\\n\");\n\n return -1;\n\n }\n\n for (i = 0; i < s->nb_streams; i++) {\n\n AVStream *st = s->streams[i];\n\n AudioInterleaveContext *aic = st->priv_data;\n\n\n\n if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {\n\n aic->sample_size = (st->codec->channels *\n\n av_get_bits_per_sample(st->codec->codec_id)) / 8;\n\n if (!aic->sample_size) {\n\n av_log(s, AV_LOG_ERROR, \"could not compute sample size\\n\");\n\n return -1;\n\n }\n\n aic->samples_per_frame = samples_per_frame;\n\n aic->samples = aic->samples_per_frame;\n\n aic->time_base = time_base;\n\n\n\n aic->fifo_size = 100* *aic->samples;\n\n aic->fifo= av_fifo_alloc_array(100, *aic->samples);\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 7143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)\n\n{\n\n int cssid, ssid, schid, m;\n\n SubchDev *sch;\n\n ORB orig_orb, orb;\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, &orig_orb, sizeof(orb))) {\n\n return;\n\n }\n\n copy_orb_from_guest(&orb, &orig_orb);\n\n if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) ||\n\n !ioinst_orb_valid(&orb)) {\n\n program_interrupt(env, PGM_OPERAND, 2);\n\n return;\n\n }\n\n trace_ioinst_sch_id(\"ssch\", 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_ssch(sch, &orb);\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 -EFAULT:\n\n /*\n\n * TODO:\n\n * I'm wondering whether there is something better\n\n * to do for us here (like setting some device or\n\n * subchannel status).\n\n */\n\n program_interrupt(env, PGM_ADDRESSING, 4);\n\n return;\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": 26959 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void aio_rfifolock_cb(void *opaque)\n\n{\n\n /* Kick owner thread in case they are blocked in aio_poll() */\n\n aio_notify(opaque);\n\n}\n", + "output": "1", + "index": 8349 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "long do_rt_sigreturn(CPUPPCState *env)\n\n{\n\n struct target_rt_sigframe *rt_sf = NULL;\n\n target_ulong rt_sf_addr;\n\n\n\n rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + 16;\n\n if (!lock_user_struct(VERIFY_READ, rt_sf, rt_sf_addr, 1))\n\n goto sigsegv;\n\n\n\n if (do_setcontext(&rt_sf->uc, env, 1))\n\n goto sigsegv;\n\n\n\n do_sigaltstack(rt_sf_addr\n\n + offsetof(struct target_rt_sigframe, uc.tuc_stack),\n\n 0, env->gpr[1]);\n\n\n\n unlock_user_struct(rt_sf, rt_sf_addr, 1);\n\n return -TARGET_QEMU_ESIGRETURN;\n\n\n\nsigsegv:\n\n unlock_user_struct(rt_sf, rt_sf_addr, 1);\n\n force_sig(TARGET_SIGSEGV);\n\n return 0;\n\n}\n", + "output": "1", + "index": 3713 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian)\n\n{\n\n if (native_endian) {\n\n switch (bpp) {\n\n case 15:\n\n return PIXMAN_x1r5g5b5;\n\n case 16:\n\n return PIXMAN_r5g6b5;\n\n case 24:\n\n return PIXMAN_r8g8b8;\n\n case 32:\n\n return PIXMAN_x8r8g8b8;\n\n }\n\n } else {\n\n switch (bpp) {\n\n case 24:\n\n return PIXMAN_b8g8r8;\n\n case 32:\n\n return PIXMAN_b8g8r8x8;\n\n break;\n\n }\n\n }\n\n g_assert_not_reached();\n\n}\n", + "output": "1", + "index": 12247 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int source_request_frame(AVFilterLink *outlink)\n\n{\n\n Frei0rContext *frei0r = outlink->src->priv;\n\n AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);\n\n int ret;\n\n\n\n picref->video->pixel_aspect = (AVRational) {1, 1};\n\n picref->pts = frei0r->pts++;\n\n picref->pos = -1;\n\n\n\n ret = ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));\n\n if (ret < 0)\n\n goto fail;\n\n\n\n frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}),\n\n NULL, (uint32_t *)picref->data[0]);\n\n ret = ff_draw_slice(outlink, 0, outlink->h, 1);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n ret = ff_end_frame(outlink);\n\n\n\nfail:\n\n avfilter_unref_buffer(picref);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 12400 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_read(BlockDriverState *bs, int64_t sector_num,\n\n uint8_t *buf, int nb_sectors)\n\n{\n\n BDRVVmdkState *s = bs->opaque;\n\n int ret;\n\n uint64_t n, index_in_cluster;\n\n VmdkExtent *extent = NULL;\n\n uint64_t cluster_offset;\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 ret = get_cluster_offset(\n\n bs, extent, NULL,\n\n sector_num << 9, 0, &cluster_offset);\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 if (ret) {\n\n /* if not allocated, try to read from parent image, if exist */\n\n if (bs->backing_hd) {\n\n if (!vmdk_is_cid_valid(bs))\n\n return -EINVAL;\n\n ret = bdrv_read(bs->backing_hd, sector_num, buf, n);\n\n if (ret < 0)\n\n return ret;\n\n } else {\n\n memset(buf, 0, 512 * n);\n\n }\n\n } else {\n\n ret = bdrv_pread(extent->file,\n\n cluster_offset + index_in_cluster * 512,\n\n buf, n * 512);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n }\n\n nb_sectors -= n;\n\n sector_num += n;\n\n buf += n * 512;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 15089 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtsp_close_streams(RTSPState *rt)\n\n{\n\n int i;\n\n RTSPStream *rtsp_st;\n\n\n\n for(i=0;inb_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 (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(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}\n", + "output": "0", + "index": 16810 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int gif_encode_init(AVCodecContext *avctx)\n\n{\n\n GIFContext *s = avctx->priv_data;\n\n\n\n if (avctx->width > 65535 || avctx->height > 65535) {\n\n av_log(avctx, AV_LOG_ERROR, \"GIF does not support resolutions above 65535x65535\\n\");\n\n return AVERROR(EINVAL);\n\n }\n\n#if FF_API_CODED_FRAME\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;\n\n avctx->coded_frame->key_frame = 1;\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n s->transparent_index = -1;\n\n\n\n s->lzw = av_mallocz(ff_lzw_encode_state_size);\n\n s->buf = av_malloc(avctx->width*avctx->height*2);\n\n s->tmpl = av_malloc(avctx->width);\n\n if (!s->tmpl || !s->buf || !s->lzw)\n\n return AVERROR(ENOMEM);\n\n\n\n if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0)\n\n av_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 3222 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void IMLT(float *pInput, float *pOutput, int odd_band)\n\n{\n\n int i;\n\n\n\n if (odd_band) {\n\n /**\n\n * Reverse the odd bands before IMDCT, this is an effect of the QMF transform\n\n * or it gives better compression to do it this way.\n\n * FIXME: It should be possible to handle this in ff_imdct_calc\n\n * for that to happen a modification of the prerotation step of\n\n * all SIMD code and C code is needed.\n\n * Or fix the functions before so they generate a pre reversed spectrum.\n\n */\n\n\n\n for (i=0; i<128; i++)\n\n FFSWAP(float, pInput[i], pInput[255-i]);\n\n }\n\n\n\n ff_imdct_calc(&mdct_ctx,pOutput,pInput);\n\n\n\n /* Perform windowing on the output. */\n\n dsp.vector_fmul(pOutput,mdct_window,512);\n\n\n\n}\n", + "output": "1", + "index": 2001 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "DescRing *desc_ring_alloc(Rocker *r, int index)\n\n{\n\n DescRing *ring;\n\n\n\n ring = g_malloc0(sizeof(DescRing));\n\n if (!ring) {\n\n return NULL;\n\n }\n\n\n\n ring->r = r;\n\n ring->index = index;\n\n\n\n return ring;\n\n}\n", + "output": "1", + "index": 3297 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void decode_channel_map(uint8_t layout_map[][3],\n\n enum ChannelPosition type,\n\n GetBitContext *gb, int n)\n\n{\n\n while (n--) {\n\n enum RawDataBlockType syn_ele;\n\n switch (type) {\n\n case AAC_CHANNEL_FRONT:\n\n case AAC_CHANNEL_BACK:\n\n case AAC_CHANNEL_SIDE:\n\n syn_ele = get_bits1(gb);\n\n break;\n\n case AAC_CHANNEL_CC:\n\n skip_bits1(gb);\n\n syn_ele = TYPE_CCE;\n\n break;\n\n case AAC_CHANNEL_LFE:\n\n syn_ele = TYPE_LFE;\n\n break;\n\n\n\n }\n\n layout_map[0][0] = syn_ele;\n\n layout_map[0][1] = get_bits(gb, 4);\n\n layout_map[0][2] = type;\n\n layout_map++;\n\n }\n\n}", + "output": "1", + "index": 3239 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void coroutine_fn c1_fn(void *opaque)\n\n{\n\n Coroutine *c2 = opaque;\n\n qemu_coroutine_enter(c2, NULL);\n\n}\n", + "output": "1", + "index": 17548 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState* create_eventfd_chr_device(IVShmemState *s,\n\n EventNotifier *n,\n\n int vector)\n\n{\n\n /* create a event character device based on the passed eventfd */\n\n PCIDevice *pdev = PCI_DEVICE(s);\n\n int eventfd = event_notifier_get_fd(n);\n\n CharDriverState *chr;\n\n\n\n s->msi_vectors[vector].pdev = pdev;\n\n\n\n chr = qemu_chr_open_eventfd(eventfd);\n\n\n\n if (chr == NULL) {\n\n error_report(\"creating chardriver for eventfd %d failed\", eventfd);\n\n return NULL;\n\n }\n\n qemu_chr_fe_claim_no_fail(chr);\n\n\n\n /* if MSI is supported we need multiple interrupts */\n\n if (ivshmem_has_feature(s, IVSHMEM_MSI)) {\n\n s->msi_vectors[vector].pdev = PCI_DEVICE(s);\n\n\n\n qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd,\n\n ivshmem_event, &s->msi_vectors[vector]);\n\n } else {\n\n qemu_chr_add_handlers(chr, ivshmem_can_receive, ivshmem_receive,\n\n ivshmem_event, s);\n\n }\n\n\n\n return chr;\n\n\n\n}\n", + "output": "1", + "index": 15737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_help(int argc, const char **argv)\n\n{\n\n help_cmd(argv[1]);\n\n}\n", + "output": "0", + "index": 13591 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void event_notifier_dummy_cb(EventNotifier *e)\n\n{\n\n}\n", + "output": "0", + "index": 11412 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(qlist_new_test)\n\n{\n\n QList *qlist;\n\n\n\n qlist = qlist_new();\n\n fail_unless(qlist != NULL);\n\n fail_unless(qlist->base.refcnt == 1);\n\n fail_unless(qobject_type(QOBJECT(qlist)) == QTYPE_QLIST);\n\n\n\n // destroy doesn't exist yet\n\n g_free(qlist);\n\n}\n", + "output": "0", + "index": 23856 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void disas_cond_b_imm(DisasContext *s, uint32_t insn)\n\n{\n\n unsigned int cond;\n\n uint64_t addr;\n\n\n\n if ((insn & (1 << 4)) || (insn & (1 << 24))) {\n\n unallocated_encoding(s);\n\n return;\n\n }\n\n addr = s->pc + sextract32(insn, 5, 19) * 4 - 4;\n\n cond = extract32(insn, 0, 4);\n\n\n\n if (cond < 0x0e) {\n\n /* genuinely conditional branches */\n\n int label_match = gen_new_label();\n\n arm_gen_test_cc(cond, label_match);\n\n gen_goto_tb(s, 0, s->pc);\n\n gen_set_label(label_match);\n\n gen_goto_tb(s, 1, addr);\n\n } else {\n\n /* 0xe and 0xf are both \"always\" conditions */\n\n gen_goto_tb(s, 0, addr);\n\n }\n\n}\n", + "output": "0", + "index": 18277 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_wrpil(CPUSPARCState *env, target_ulong new_pil)\n\n{\n\n#if !defined(CONFIG_USER_ONLY)\n\n trace_win_helper_wrpil(env->psrpil, (uint32_t)new_pil);\n\n\n\n env->psrpil = new_pil;\n\n\n\n if (cpu_interrupts_enabled(env)) {\n\n\n cpu_check_irqs(env);\n\n\n }\n\n#endif\n\n}", + "output": "1", + "index": 26638 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel4_mc31_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_4w_msa(src - 2,\n\n src - (stride * 2) +\n\n sizeof(uint8_t), stride, dst, stride, 4);\n\n}\n", + "output": "0", + "index": 10762 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)\n\n{\n\n trace_colo_compare_main(\"compare other\");\n\n if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {\n\n char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];\n\n\n\n strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));\n\n strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));\n\n strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));\n\n strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));\n\n\n\n trace_colo_compare_ip_info(ppkt->size, pri_ip_src,\n\n pri_ip_dst, spkt->size,\n\n sec_ip_src, sec_ip_dst);\n\n }\n\n\n\n return colo_packet_compare_common(ppkt, spkt, 0);\n\n}\n", + "output": "1", + "index": 21121 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_ioctl_bh_cb(void *opaque)\n\n{\n\n BdrvIoctlCompletionData *data = opaque;\n\n\n\n bdrv_co_io_em_complete(data->co, -ENOTSUP);\n\n qemu_bh_delete(data->bh);\n\n}\n", + "output": "1", + "index": 20128 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean qemu_chr_be_generic_open_bh(gpointer opaque)\n\n{\n\n CharDriverState *s = opaque;\n\n qemu_chr_be_event(s, CHR_EVENT_OPENED);\n\n s->idle_tag = 0;\n\n return FALSE;\n\n}\n", + "output": "0", + "index": 12687 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,\n\n int64_t count, int flags, int64_t *total)\n\n{\n\n Coroutine *co;\n\n CoWriteZeroes data = {\n\n .blk = blk,\n\n .offset = offset,\n\n .count = count,\n\n .total = total,\n\n .flags = flags,\n\n .done = false,\n\n };\n\n\n\n if (count >> BDRV_SECTOR_BITS > INT_MAX) {\n\n return -ERANGE;\n\n }\n\n\n\n co = qemu_coroutine_create(co_pwrite_zeroes_entry);\n\n qemu_coroutine_enter(co, &data);\n\n while (!data.done) {\n\n aio_poll(blk_get_aio_context(blk), true);\n\n }\n\n if (data.ret < 0) {\n\n return data.ret;\n\n } else {\n\n return 1;\n\n }\n\n}\n", + "output": "1", + "index": 20683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static off_t read_off(BlockDriverState *bs, int64_t offset)\n\n{\n\n\tuint64_t buffer;\n\n\tif (bdrv_pread(bs->file, offset, &buffer, 8) < 8)\n\n\t\treturn 0;\n\n\treturn be64_to_cpu(buffer);\n\n}\n", + "output": "1", + "index": 4358 + }, + { + "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 < 76;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": "1", + "index": 17797 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)\n\n{\n\n int code;\n\n code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);\n\n if (code < 0) {\n\n av_log(s->avctx, AV_LOG_WARNING,\n\n \"mjpeg_decode_dc: bad vlc: %d:%d (%p)\\n\",\n\n 0, dc_index, &s->vlcs[0][dc_index]);\n\n return 0xffff;\n\n }\n\n\n\n if (code)\n\n return get_xbits(&s->gb, code);\n\n else\n\n return 0;\n\n}\n", + "output": "1", + "index": 18423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_blockdev_snapshot(const char *node, const char *overlay,\n\n Error **errp)\n\n{\n\n BlockdevSnapshot snapshot_data = {\n\n .node = (char *) node,\n\n .overlay = (char *) overlay\n\n };\n\n TransactionAction action = {\n\n .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT,\n\n .u.blockdev_snapshot = &snapshot_data,\n\n };\n\n blockdev_do_action(&action, errp);\n\n}\n", + "output": "0", + "index": 20940 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int cris_lz(int x)\n\n{\n\n\tint r;\n\n\tasm (\"lz\\t%1, %0\\n\" : \"=r\" (r) : \"r\" (x));\n\n\treturn r;\n\n}\n", + "output": "1", + "index": 10214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,\n\n 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_read(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": 4005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "INLINE bits32 extractFloat32Frac( float32 a )\n\n{\n\n\n\n return a & 0x007FFFFF;\n\n\n\n}\n", + "output": "0", + "index": 15715 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int event_qdev_exit(DeviceState *qdev)\n\n{\n\n SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);\n\n SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);\n\n if (child->exit) {\n\n child->exit(event);\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 5522 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void xen_config_cleanup(void)\n\n{\n\n struct xs_dirs *d;\n\n\n\n TAILQ_FOREACH(d, &xs_cleanup, list) {\n\n\txs_rm(xenstore, 0, d->xs_dir);\n\n }\n\n}\n", + "output": "0", + "index": 1286 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spr_write_40x_sler (void *opaque, int sprn)\n\n{\n\n DisasContext *ctx = opaque;\n\n\n\n gen_op_store_40x_sler();\n\n /* We must stop the translation as we may have changed\n\n * some regions endianness\n\n */\n\n RET_STOP(ctx);\n\n}\n", + "output": "0", + "index": 18256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int dnxhd_decode_close(AVCodecContext *avctx)\n\n{\n\n DNXHDContext *ctx = avctx->priv_data;\n\n\n\n ff_free_vlc(&ctx->ac_vlc);\n\n ff_free_vlc(&ctx->dc_vlc);\n\n ff_free_vlc(&ctx->run_vlc);\n\n\n\n av_freep(&ctx->mb_scan_index);\n\n av_freep(&ctx->rows);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 22718 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void stream_start(BlockDriverState *bs, BlockDriverState *base,\n\n const char *base_id, BlockDriverCompletionFunc *cb,\n\n void *opaque, Error **errp)\n\n{\n\n StreamBlockJob *s;\n\n Coroutine *co;\n\n\n\n s = block_job_create(&stream_job_type, bs, cb, opaque, errp);\n\n if (!s) {\n\n return;\n\n }\n\n\n\n s->base = base;\n\n if (base_id) {\n\n pstrcpy(s->backing_file_id, sizeof(s->backing_file_id), base_id);\n\n }\n\n\n\n co = qemu_coroutine_create(stream_run);\n\n trace_stream_start(bs, base, s, co, opaque);\n\n qemu_coroutine_enter(co, s);\n\n}\n", + "output": "0", + "index": 4324 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_test_validate_qmp_introspect(TestInputVisitorData *data,\n\n const char *schema_json)\n\n{\n\n SchemaInfoList *schema = NULL;\n\n Visitor *v;\n\n\n\n v = validate_test_init_raw(data, schema_json);\n\n\n\n visit_type_SchemaInfoList(v, NULL, &schema, &error_abort);\n\n g_assert(schema);\n\n\n\n qapi_free_SchemaInfoList(schema);\n\n}\n", + "output": "0", + "index": 16157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_uas_command(UASDevice *uas, uas_ui *ui)\n{\n UASRequest *req;\n uint32_t len;\n uint16_t tag = be16_to_cpu(ui->hdr.tag);\n if (uas_using_streams(uas) && tag > UAS_MAX_STREAMS) {\n goto invalid_tag;\n }\n req = usb_uas_find_request(uas, tag);\n if (req) {\n goto overlapped_tag;\n }\n req = usb_uas_alloc_request(uas, ui);\n if (req->dev == NULL) {\n goto bad_target;\n }\n trace_usb_uas_command(uas->dev.addr, req->tag,\n usb_uas_get_lun(req->lun),\n req->lun >> 32, req->lun & 0xffffffff);\n QTAILQ_INSERT_TAIL(&uas->requests, req, next);\n if (uas_using_streams(uas) && uas->data3[req->tag] != NULL) {\n req->data = uas->data3[req->tag];\n req->data_async = true;\n uas->data3[req->tag] = NULL;\n }\n req->req = scsi_req_new(req->dev, req->tag,\n usb_uas_get_lun(req->lun),\n ui->command.cdb, req);\n if (uas->requestlog) {\n scsi_req_print(req->req);\n }\n len = scsi_req_enqueue(req->req);\n if (len) {\n req->data_size = len;\n scsi_req_continue(req->req);\n }\noverlapped_tag:\n usb_uas_queue_fake_sense(uas, tag, sense_code_OVERLAPPED_COMMANDS);\nbad_target:\n usb_uas_queue_fake_sense(uas, tag, sense_code_LUN_NOT_SUPPORTED);\n g_free(req);\n}", + "output": "1", + "index": 25407 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ehci_mem_writeb(void *ptr, target_phys_addr_t addr, uint32_t val)\n\n{\n\n fprintf(stderr, \"EHCI doesn't handle byte writes to MMIO\\n\");\n\n exit(1);\n\n}\n", + "output": "1", + "index": 14660 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd)\n\n{\n\n struct mfi_ld_list info;\n\n size_t dcmd_size = sizeof(info), resid;\n\n uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns;\n\n uint64_t ld_size;\n\n BusChild *kid;\n\n\n\n memset(&info, 0, dcmd_size);\n\n if (cmd->iov_size < dcmd_size) {\n\n trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,\n\n dcmd_size);\n\n return MFI_STAT_INVALID_PARAMETER;\n\n }\n\n\n\n if (megasas_is_jbod(s)) {\n\n max_ld_disks = 0;\n\n }\n\n QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {\n\n SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child);\n\n BlockConf *conf = &sdev->conf;\n\n\n\n if (num_ld_disks >= max_ld_disks) {\n\n break;\n\n }\n\n /* Logical device size is in blocks */\n\n bdrv_get_geometry(conf->bs, &ld_size);\n\n info.ld_list[num_ld_disks].ld.v.target_id = sdev->id;\n\n info.ld_list[num_ld_disks].ld.v.lun_id = sdev->lun;\n\n info.ld_list[num_ld_disks].state = MFI_LD_STATE_OPTIMAL;\n\n info.ld_list[num_ld_disks].size = cpu_to_le64(ld_size);\n\n num_ld_disks++;\n\n }\n\n info.ld_count = cpu_to_le32(num_ld_disks);\n\n trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);\n\n\n\n resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg);\n\n cmd->iov_size = dcmd_size - resid;\n\n return MFI_STAT_OK;\n\n}\n", + "output": "0", + "index": 6096 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "const char *qdev_fw_name(DeviceState *dev)\n\n{\n\n DeviceClass *dc = DEVICE_GET_CLASS(dev);\n\n\n\n if (dc->fw_name) {\n\n return dc->fw_name;\n\n } else if (dc->alias) {\n\n return dc->alias;\n\n }\n\n\n\n return object_get_typename(OBJECT(dev));\n\n}\n", + "output": "0", + "index": 3511 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hmp_migrate_status_cb(void *opaque)\n\n{\n\n MigrationStatus *status = opaque;\n\n MigrationInfo *info;\n\n\n\n info = qmp_query_migrate(NULL);\n\n if (!info->has_status || strcmp(info->status, \"active\") == 0) {\n\n if (info->has_disk) {\n\n int progress;\n\n\n\n if (info->disk->remaining) {\n\n progress = info->disk->transferred * 100 / info->disk->total;\n\n } else {\n\n progress = 100;\n\n }\n\n\n\n monitor_printf(status->mon, \"Completed %d %%\\r\", progress);\n\n monitor_flush(status->mon);\n\n }\n\n\n\n timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000);\n\n } else {\n\n if (status->is_block_migration) {\n\n monitor_printf(status->mon, \"\\n\");\n\n }\n\n monitor_resume(status->mon);\n\n timer_del(status->timer);\n\n g_free(status);\n\n }\n\n\n\n qapi_free_MigrationInfo(info);\n\n}\n", + "output": "1", + "index": 2967 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,\n\n bool query_backing)\n\n{\n\n BlockStats *s = NULL;\n\n\n\n s = g_malloc0(sizeof(*s));\n\n s->stats = g_malloc0(sizeof(*s->stats));\n\n\n\n if (!bs) {\n\n return s;\n\n }\n\n\n\n if (bdrv_get_node_name(bs)[0]) {\n\n s->has_node_name = true;\n\n s->node_name = g_strdup(bdrv_get_node_name(bs));\n\n }\n\n\n\n s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset);\n\n\n\n if (bs->file) {\n\n s->has_parent = true;\n\n s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing);\n\n }\n\n\n\n if (query_backing && bs->backing) {\n\n s->has_backing = true;\n\n s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);\n\n }\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 4006 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_spr_thrm (CPUPPCState *env)\n\n{\n\n /* Thermal management */\n\n /* XXX : not implemented */\n\n spr_register(env, SPR_THRM1, \"THRM1\",\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_THRM2, \"THRM2\",\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_THRM3, \"THRM3\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n}\n", + "output": "1", + "index": 5739 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int bt_hid_out(struct bt_hid_device_s *s)\n\n{\n\n USBPacket p;\n\n\n\n if (s->data_type == BT_DATA_OUTPUT) {\n\n p.pid = USB_TOKEN_OUT;\n\n p.devep = 1;\n\n p.data = s->dataout.buffer;\n\n p.len = s->dataout.len;\n\n s->dataout.len = s->usbdev->info->handle_data(s->usbdev, &p);\n\n\n\n return s->dataout.len;\n\n }\n\n\n\n if (s->data_type == BT_DATA_FEATURE) {\n\n /* XXX:\n\n * does this send a USB_REQ_CLEAR_FEATURE/USB_REQ_SET_FEATURE\n\n * or a SET_REPORT? */\n\n p.devep = 0;\n\n }\n\n\n\n return -1;\n\n}\n", + "output": "1", + "index": 22166 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int create_stream(AVFormatContext *s)\n\n{\n\n XCBGrabContext *c = s->priv_data;\n\n AVStream *st = avformat_new_stream(s, NULL);\n\n xcb_get_geometry_cookie_t gc;\n\n xcb_get_geometry_reply_t *geo;\n\n int ret;\n\n\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n ret = av_parse_video_size(&c->width, &c->height, c->video_size);\n\n if (ret < 0)\n\n return ret;\n\n\n\n ret = av_parse_video_rate(&st->avg_frame_rate, c->framerate);\n\n if (ret < 0)\n\n return ret;\n\n\n\n avpriv_set_pts_info(st, 64, 1, 1000000);\n\n\n\n gc = xcb_get_geometry(c->conn, c->screen->root);\n\n geo = xcb_get_geometry_reply(c->conn, gc, NULL);\n\n\n\n c->width = FFMIN(geo->width, c->width);\n\n c->height = FFMIN(geo->height, c->height);\n\n c->time_base = (AVRational){ st->avg_frame_rate.den,\n\n st->avg_frame_rate.num };\n\n c->time_frame = av_gettime();\n\n\n\n st->codec->codec_type = AVMEDIA_TYPE_VIDEO;\n\n st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;\n\n st->codec->width = c->width;\n\n st->codec->height = c->height;\n\n st->codec->time_base = c->time_base;\n\n\n\n ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codec->pix_fmt);\n\n\n\n free(geo);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 10161 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mp_decode_frame(MPADecodeContext *s, \n\n short *samples)\n\n{\n\n int i, nb_frames, ch;\n\n short *samples_ptr;\n\n\n\n init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, \n\n s->inbuf_ptr - s->inbuf - HEADER_SIZE);\n\n \n\n /* skip error protection field */\n\n if (s->error_protection)\n\n get_bits(&s->gb, 16);\n\n\n\n dprintf(\"frame %d:\\n\", s->frame_count);\n\n switch(s->layer) {\n\n case 1:\n\n nb_frames = mp_decode_layer1(s);\n\n break;\n\n case 2:\n\n nb_frames = mp_decode_layer2(s);\n\n break;\n\n case 3:\n\n default:\n\n nb_frames = mp_decode_layer3(s);\n\n break;\n\n }\n\n#if defined(DEBUG)\n\n for(i=0;inb_channels;ch++) {\n\n int j;\n\n printf(\"%d-%d:\", i, ch);\n\n for(j=0;jsb_samples[ch][i][j] / FRAC_ONE);\n\n printf(\"\\n\");\n\n }\n\n }\n\n#endif\n\n /* apply the synthesis filter */\n\n for(ch=0;chnb_channels;ch++) {\n\n samples_ptr = samples + ch;\n\n for(i=0;inb_channels,\n\n s->sb_samples[ch][i]);\n\n samples_ptr += 32 * s->nb_channels;\n\n }\n\n }\n\n#ifdef DEBUG\n\n s->frame_count++; \n\n#endif\n\n return nb_frames * 32 * sizeof(short) * s->nb_channels;\n\n}\n", + "output": "0", + "index": 94 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block,\n\n int n, int qscale, int *overflow)\n\n{\n\n const uint8_t *scantable= ctx->intra_scantable.scantable;\n\n const int *qmat = ctx->q_intra_matrix[qscale];\n\n int last_non_zero = 0;\n\n\n\n ctx->dsp.fdct(block);\n\n\n\n // Divide by 4 with rounding, to compensate scaling of DCT coefficients\n\n block[0] = (block[0] + 2) >> 2;\n\n\n\n for (int i = 1; i < 64; ++i) {\n\n int j = scantable[i];\n\n int sign = block[j] >> 31;\n\n int level = (block[j] ^ sign) - sign;\n\n level = level * qmat[j] >> DNX10BIT_QMAT_SHIFT;\n\n block[j] = (level ^ sign) - sign;\n\n if (level)\n\n last_non_zero = i;\n\n }\n\n\n\n return last_non_zero;\n\n}\n", + "output": "0", + "index": 15293 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)\n\n{\n\n kvm_s390_interrupt_internal(cpu, type, code, 0, 0);\n\n}\n", + "output": "0", + "index": 5032 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_unassigned_access(target_ulong addr, int is_write, int is_exec,\n\n int is_asi, int size)\n\n#else\n\nvoid do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,\n\n int is_asi, int size)\n\n#endif\n\n{\n\n CPUState *saved_env;\n\n\n\n /* XXX: hack to restore env in all cases, even if not called from\n\n generated code */\n\n saved_env = env;\n\n env = cpu_single_env;\n\n\n\n#ifdef DEBUG_UNASSIGNED\n\n printf(\"Unassigned mem access to \" TARGET_FMT_plx \" from \" TARGET_FMT_lx\n\n \"\\n\", addr, env->pc);\n\n#endif\n\n\n\n if (is_exec)\n\n raise_exception(TT_CODE_ACCESS);\n\n else\n\n raise_exception(TT_DATA_ACCESS);\n\n\n\n env = saved_env;\n\n}\n", + "output": "1", + "index": 1399 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmgenid_set_guid_auto_test(void)\n\n{\n\n const char *cmd;\n\n QemuUUID measured;\n\n\n\n cmd = \"-machine accel=tcg -device vmgenid,id=testvgid,\" \"guid=auto\";\n\n qtest_start(cmd);\n\n\n\n read_guid_from_memory(&measured);\n\n\n\n /* Just check that the GUID is non-null */\n\n g_assert(!qemu_uuid_is_null(&measured));\n\n\n\n qtest_quit(global_qtest);\n\n}\n", + "output": "1", + "index": 20450 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static 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\n\n /* Check for additional signaled events */\n\n for (i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) {\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 }\n\n } else if (ret2 != WAIT_TIMEOUT) {\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 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": 14077 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int nsv_read_close(AVFormatContext *s)\n\n{\n\n/* int i; */\n\n NSVContext *nsv = s->priv_data;\n\n\n\n av_freep(&nsv->nsvs_file_offset);\n\n av_freep(&nsv->nsvs_timestamps);\n\n\n\n\n\n\n\n#if 0\n\n\n\n for(i=0;inb_streams;i++) {\n\n AVStream *st = s->streams[i];\n\n NSVStream *ast = st->priv_data;\n\n if(ast){\n\n av_free(ast->index_entries);\n\n av_free(ast);\n\n }\n\n av_free(st->codec->palctrl);\n\n }\n\n\n\n#endif\n\n return 0;\n\n}", + "output": "1", + "index": 20864 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offset)\n\n{\n\n outl(0xcf8, (1 << 31) | (devfn << 8) | offset);\n\n return inl(0xcfc);\n\n}\n", + "output": "1", + "index": 22834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)\n\n{\n\n struct vaapi_context * const vactx = avctx->hwaccel_context;\n\n MpegEncContext *s = avctx->priv_data;\n\n int ret;\n\n\n\n ret = ff_vaapi_commit_slices(vactx);\n\n if (ret < 0)\n\n goto finish;\n\n\n\n ret = ff_vaapi_render_picture(vactx,\n\n ff_vaapi_get_surface_id(&s->current_picture_ptr->f));\n\n if (ret < 0)\n\n goto finish;\n\n\n\n ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);\n\n\n\nfinish:\n\n ff_vaapi_common_end_frame(avctx);\n\n return ret;\n\n}\n", + "output": "1", + "index": 25406 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq)\n\n{\n\n VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev);\n\n VFIOINTp *intp;\n\n\n\n if (!kvm_irqfds_enabled() || !kvm_resamplefds_enabled() ||\n\n !vdev->irqfd_allowed) {\n\n goto fail_irqfd;\n\n }\n\n\n\n QLIST_FOREACH(intp, &vdev->intp_list, next) {\n\n if (intp->qemuirq == irq) {\n\n break;\n\n }\n\n }\n\n assert(intp);\n\n\n\n if (kvm_irqchip_add_irqfd_notifier(kvm_state, intp->interrupt,\n\n intp->unmask, irq) < 0) {\n\n goto fail_irqfd;\n\n }\n\n\n\n if (vfio_set_trigger_eventfd(intp, NULL) < 0) {\n\n goto fail_vfio;\n\n }\n\n if (vfio_set_resample_eventfd(intp) < 0) {\n\n goto fail_vfio;\n\n }\n\n\n\n intp->kvm_accel = true;\n\n\n\n trace_vfio_platform_start_irqfd_injection(intp->pin,\n\n event_notifier_get_fd(intp->interrupt),\n\n event_notifier_get_fd(intp->unmask));\n\n return;\n\nfail_vfio:\n\n kvm_irqchip_remove_irqfd_notifier(kvm_state, intp->interrupt, irq);\n\n error_report(\"vfio: failed to start eventfd signaling for IRQ %d: %m\",\n\n intp->pin);\n\n abort();\n\nfail_irqfd:\n\n vfio_start_eventfd_injection(sbdev, irq);\n\n return;\n\n}\n", + "output": "1", + "index": 15858 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "TCGv_i32 tcg_global_reg_new_i32(int reg, const char *name)\n\n{\n\n int idx;\n\n\n\n idx = tcg_global_reg_new_internal(TCG_TYPE_I32, reg, name);\n\n return MAKE_TCGV_I32(idx);\n\n}\n", + "output": "0", + "index": 5803 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_os_timer_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque;\n\n int offset = addr & OMAP_MPUI_REG_MASK;\n\n\n\n if (size != 4) {\n\n return omap_badwidth_write32(opaque, addr, value);\n\n }\n\n\n\n switch (offset) {\n\n case 0x00:\t/* TVR */\n\n s->timer.reset_val = value & 0x00ffffff;\n\n break;\n\n\n\n case 0x04:\t/* TCR */\n\n OMAP_RO_REG(addr);\n\n break;\n\n\n\n case 0x08:\t/* CR */\n\n s->timer.ar = (value >> 3) & 1;\n\n s->timer.it_ena = (value >> 2) & 1;\n\n if (s->timer.st != (value & 1) || (value & 2)) {\n\n omap_timer_sync(&s->timer);\n\n s->timer.enable = value & 1;\n\n s->timer.st = value & 1;\n\n omap_timer_update(&s->timer);\n\n }\n\n break;\n\n\n\n default:\n\n OMAP_BAD_REG(addr);\n\n }\n\n}\n", + "output": "0", + "index": 9696 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 1);\n\n}\n", + "output": "0", + "index": 23028 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_pcmcia_realize(DeviceState *dev, Error **errp)\n\n{\n\n PXA2xxPCMCIAState *s = PXA2XX_PCMCIA(dev);\n\n\n\n pcmcia_socket_register(&s->slot);\n\n}\n", + "output": "1", + "index": 4149 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,\n\n int sock, const char *export, Error **errp)\n\n{\n\n int ret;\n\n\n\n /* NBD handshake */\n\n logout(\"session init %s\\n\", export);\n\n qemu_set_block(sock);\n\n ret = nbd_receive_negotiate(sock, export,\n\n &client->nbdflags, &client->size,\n\n &client->blocksize, errp);\n\n if (ret < 0) {\n\n logout(\"Failed to negotiate with the NBD server\\n\");\n\n closesocket(sock);\n\n return ret;\n\n }\n\n\n\n qemu_co_mutex_init(&client->send_mutex);\n\n qemu_co_mutex_init(&client->free_sema);\n\n client->bs = bs;\n\n client->sock = sock;\n\n\n\n /* Now that we're connected, set the socket to be non-blocking and\n\n * kick the reply mechanism. */\n\n qemu_set_nonblock(sock);\n\n nbd_client_session_attach_aio_context(client, bdrv_get_aio_context(bs));\n\n\n\n logout(\"Established connection with NBD server\\n\");\n\n return 0;\n\n}\n", + "output": "0", + "index": 10051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)\n{\n VirtualConsole *vc = opaque;\n GtkDisplayState *s = vc->s;\n int gdk_keycode = key->hardware_keycode;\n int qemu_keycode;\n int i;\n if (key->keyval == GDK_KEY_Pause) {\n qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,\n key->type == GDK_KEY_PRESS);\n qemu_keycode = gd_map_keycode(s, gtk_widget_get_display(widget),\n gdk_keycode);\n trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode,\n (key->type == GDK_KEY_PRESS) ? \"down\" : \"up\");\n for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {\n if (qemu_keycode == modifier_keycode[i]) {\n s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);\n qemu_input_event_send_key_number(vc->gfx.dcl.con, qemu_keycode,\n key->type == GDK_KEY_PRESS);", + "output": "1", + "index": 1780 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint16_t vring_avail_idx(VirtQueue *vq)\n\n{\n\n VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);\n\n hwaddr pa = offsetof(VRingAvail, idx);\n\n vq->shadow_avail_idx = virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa);\n\n return vq->shadow_avail_idx;\n\n}\n", + "output": "1", + "index": 25384 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int caca_write_trailer(AVFormatContext *s)\n\n{\n\n CACAContext *c = s->priv_data;\n\n\n\n av_freep(&c->window_title);\n\n\n\n caca_free_dither(c->dither);\n\n caca_free_display(c->display);\n\n caca_free_canvas(c->canvas);\n\n return 0;\n\n}\n", + "output": "1", + "index": 26334 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tgen_ext16s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)\n\n{\n\n if (facilities & FACILITY_EXT_IMM) {\n\n tcg_out_insn(s, RRE, LGHR, dest, src);\n\n return;\n\n }\n\n\n\n if (type == TCG_TYPE_I32) {\n\n if (dest == src) {\n\n tcg_out_sh32(s, RS_SLL, dest, TCG_REG_NONE, 16);\n\n } else {\n\n tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 16);\n\n }\n\n tcg_out_sh32(s, RS_SRA, dest, TCG_REG_NONE, 16);\n\n } else {\n\n tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 48);\n\n tcg_out_sh64(s, RSY_SRAG, dest, dest, TCG_REG_NONE, 48);\n\n }\n\n}\n", + "output": "0", + "index": 17244 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cow_open(BlockDriverState *bs, QDict *options, int flags,\n\n Error **errp)\n\n{\n\n BDRVCowState *s = bs->opaque;\n\n struct cow_header_v2 cow_header;\n\n int bitmap_size;\n\n int64_t size;\n\n int ret;\n\n\n\n /* see if it is a cow image */\n\n ret = bdrv_pread(bs->file, 0, &cow_header, sizeof(cow_header));\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n if (be32_to_cpu(cow_header.magic) != COW_MAGIC) {\n\n error_setg(errp, \"Image not in COW format\");\n\n ret = -EINVAL;\n\n goto fail;\n\n }\n\n\n\n if (be32_to_cpu(cow_header.version) != COW_VERSION) {\n\n char version[64];\n\n snprintf(version, sizeof(version),\n\n \"COW version %\" PRIu32, cow_header.version);\n\n error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,\n\n bs->device_name, \"cow\", version);\n\n ret = -ENOTSUP;\n\n goto fail;\n\n }\n\n\n\n /* cow image found */\n\n size = be64_to_cpu(cow_header.size);\n\n bs->total_sectors = size / 512;\n\n\n\n pstrcpy(bs->backing_file, sizeof(bs->backing_file),\n\n cow_header.backing_file);\n\n\n\n bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);\n\n s->cow_sectors_offset = (bitmap_size + 511) & ~511;\n\n qemu_co_mutex_init(&s->lock);\n\n return 0;\n\n fail:\n\n return ret;\n\n}\n", + "output": "0", + "index": 14794 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int float64_lt( float64 a, float64 b STATUS_PARAM )\n\n{\n\n flag aSign, bSign;\n\n\n\n if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )\n\n || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )\n\n ) {\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n return 0;\n\n }\n\n aSign = extractFloat64Sign( a );\n\n bSign = extractFloat64Sign( b );\n\n if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );\n\n return ( a != b ) && ( aSign ^ ( a < b ) );\n\n\n\n}\n", + "output": "0", + "index": 7460 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)\n\n{\n\n char desc[DESC_SIZE], tmp_desc[DESC_SIZE];\n\n char *p_name, *tmp_str;\n\n BDRVVmdkState *s = bs->opaque;\n\n\n\n memset(desc, 0, sizeof(desc));\n\n if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) {\n\n return -EIO;\n\n }\n\n\n\n tmp_str = strstr(desc,\"parentCID\");\n\n pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);\n\n if ((p_name = strstr(desc,\"CID\")) != NULL) {\n\n p_name += sizeof(\"CID\");\n\n snprintf(p_name, sizeof(desc) - (p_name - desc), \"%x\\n\", cid);\n\n pstrcat(desc, sizeof(desc), tmp_desc);\n\n }\n\n\n\n if (bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE) < 0) {\n\n return -EIO;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 10219 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_pcm(HEVCContext *s, int x, int y)\n\n{\n\n int log2_min_pu_size = s->sps->log2_min_pu_size;\n\n int x_pu = x >> log2_min_pu_size;\n\n int y_pu = y >> log2_min_pu_size;\n\n\n\n if (x < 0 || x_pu >= s->sps->min_pu_width ||\n\n y < 0 || y_pu >= s->sps->min_pu_height)\n\n return 2;\n\n return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu];\n\n}\n", + "output": "0", + "index": 10547 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PPC_OP(addic)\n\n{\n\n T1 = T0;\n\n T0 += PARAM(1);\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": 22257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qjson_register_types(void)\n\n{\n\n type_register_static(&qjson_type_info);\n\n}\n", + "output": "0", + "index": 18350 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void css_generate_css_crws(uint8_t cssid)\n\n{\n\n if (!channel_subsys.sei_pending) {\n\n css_queue_crw(CRW_RSC_CSS, CRW_ERC_EVENT, 0, cssid);\n\n }\n\n channel_subsys.sei_pending = true;\n\n}\n", + "output": "0", + "index": 10279 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold int ffv1_init_slice_contexts(FFV1Context *f)\n{\n int i;\n f->slice_count = f->num_h_slices * f->num_v_slices;\n av_assert0(f->slice_count > 0);\n for (i = 0; i < f->slice_count; i++) {\n FFV1Context *fs = av_mallocz(sizeof(*fs));\n int sx = i % f->num_h_slices;\n int sy = i / f->num_h_slices;\n int sxs = f->avctx->width * sx / f->num_h_slices;\n int sxe = f->avctx->width * (sx + 1) / f->num_h_slices;\n int sys = f->avctx->height * sy / f->num_v_slices;\n int sye = f->avctx->height * (sy + 1) / f->num_v_slices;\n f->slice_context[i] = fs;\n memcpy(fs, f, sizeof(*fs));\n memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));\n fs->slice_width = sxe - sxs;\n fs->slice_height = sye - sys;\n fs->slice_x = sxs;\n fs->slice_y = sys;\n fs->sample_buffer = av_malloc(3 * MAX_PLANES * (fs->width + 6) *\n sizeof(*fs->sample_buffer));\n if (!fs->sample_buffer)\n }\n return 0;\n}", + "output": "1", + "index": 1650 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void clear_sel(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 IPMI_CHECK_CMD_LEN(8);\n\n IPMI_CHECK_RESERVATION(2, ibs->sel.reservation);\n\n if (cmd[4] != 'C' || cmd[5] != 'L' || cmd[6] != 'R') {\n\n rsp[2] = IPMI_CC_INVALID_DATA_FIELD;\n\n return;\n\n }\n\n if (cmd[7] == 0xaa) {\n\n ibs->sel.next_free = 0;\n\n ibs->sel.overflow = 0;\n\n set_timestamp(ibs, ibs->sdr.last_clear);\n\n IPMI_ADD_RSP_DATA(1); /* Erasure complete */\n\n sel_inc_reservation(&ibs->sel);\n\n } else if (cmd[7] == 0) {\n\n IPMI_ADD_RSP_DATA(1); /* Erasure complete */\n\n } else {\n\n rsp[2] = IPMI_CC_INVALID_DATA_FIELD;\n\n return;\n\n }\n\n}\n", + "output": "1", + "index": 18692 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_extu(int ot, TCGv reg)\n\n{\n\n switch(ot) {\n\n case OT_BYTE:\n\n tcg_gen_ext8u_tl(reg, reg);\n\n break;\n\n case OT_WORD:\n\n tcg_gen_ext16u_tl(reg, reg);\n\n break;\n\n case OT_LONG:\n\n tcg_gen_ext32u_tl(reg, reg);\n\n break;\n\n default:\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 22549 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_exception_return(DisasContext *s, TCGv pc)\n\n{\n\n TCGv tmp;\n\n store_reg(s, 15, pc);\n\n tmp = load_cpu_field(spsr);\n\n gen_set_cpsr(tmp, 0xffffffff);\n\n dead_tmp(tmp);\n\n s->is_jmp = DISAS_UPDATE;\n\n}\n", + "output": "1", + "index": 390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ram_addr_t qemu_ram_alloc(ram_addr_t size)\n\n{\n\n RAMBlock *new_block;\n\n\n\n#ifdef CONFIG_KQEMU\n\n if (kqemu_phys_ram_base) {\n\n return kqemu_ram_alloc(size);\n\n }\n\n#endif\n\n\n\n size = TARGET_PAGE_ALIGN(size);\n\n new_block = qemu_malloc(sizeof(*new_block));\n\n\n\n new_block->host = qemu_vmalloc(size);\n\n new_block->offset = last_ram_offset;\n\n new_block->length = size;\n\n\n\n new_block->next = ram_blocks;\n\n ram_blocks = new_block;\n\n\n\n phys_ram_dirty = qemu_realloc(phys_ram_dirty,\n\n (last_ram_offset + size) >> TARGET_PAGE_BITS);\n\n memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS),\n\n 0xff, size >> TARGET_PAGE_BITS);\n\n\n\n last_ram_offset += size;\n\n\n\n if (kvm_enabled())\n\n kvm_setup_guest_memory(new_block->host, size);\n\n\n\n return new_block->offset;\n\n}\n", + "output": "0", + "index": 17018 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usb_serial_handle_data(USBDevice *dev, USBPacket *p)\n\n{\n\n USBSerialState *s = (USBSerialState *)dev;\n\n uint8_t devep = p->ep->nr;\n\n struct iovec *iov;\n\n uint8_t header[2];\n\n int i, first_len, len;\n\n\n\n switch (p->pid) {\n\n case USB_TOKEN_OUT:\n\n if (devep != 2)\n\n goto fail;\n\n for (i = 0; i < p->iov.niov; i++) {\n\n iov = p->iov.iov + i;\n\n qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len);\n\n }\n\n p->actual_length = p->iov.size;\n\n break;\n\n\n\n case USB_TOKEN_IN:\n\n if (devep != 1)\n\n goto fail;\n\n first_len = RECV_BUF - s->recv_ptr;\n\n len = p->iov.size;\n\n if (len <= 2) {\n\n p->status = USB_RET_NAK;\n\n break;\n\n }\n\n header[0] = usb_get_modem_lines(s) | 1;\n\n /* We do not have the uart details */\n\n /* handle serial break */\n\n if (s->event_trigger && s->event_trigger & FTDI_BI) {\n\n s->event_trigger &= ~FTDI_BI;\n\n header[1] = FTDI_BI;\n\n usb_packet_copy(p, header, 2);\n\n break;\n\n } else {\n\n header[1] = 0;\n\n }\n\n len -= 2;\n\n if (len > s->recv_used)\n\n len = s->recv_used;\n\n if (!len) {\n\n p->status = USB_RET_NAK;\n\n break;\n\n }\n\n if (first_len > len)\n\n first_len = len;\n\n usb_packet_copy(p, header, 2);\n\n usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len);\n\n if (len > first_len)\n\n usb_packet_copy(p, s->recv_buf, len - first_len);\n\n s->recv_used -= len;\n\n s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;\n\n break;\n\n\n\n default:\n\n DPRINTF(\"Bad token\\n\");\n\n fail:\n\n p->status = USB_RET_STALL;\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 14316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)\n\n{\n\n char *pix_fmts;\n\n AVCodecContext *codec = ofilter->ost->st->codec;\n\n AVFilterContext *last_filter = out->filter_ctx;\n\n int pad_idx = out->pad_idx;\n\n int ret;\n\n AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();\n\n\n\n#if FF_API_OLD_VSINK_API\n\n ret = avfilter_graph_create_filter(&ofilter->filter,\n\n avfilter_get_by_name(\"buffersink\"),\n\n \"out\", NULL, NULL, fg->graph);\n\n#else\n\n ret = avfilter_graph_create_filter(&ofilter->filter,\n\n avfilter_get_by_name(\"buffersink\"),\n\n \"out\", NULL, buffersink_params, fg->graph);\n\n#endif\n\n av_freep(&buffersink_params);\n\n\n\n if (ret < 0)\n\n return ret;\n\n\n\n if (codec->width || codec->height) {\n\n char args[255];\n\n AVFilterContext *filter;\n\n\n\n snprintf(args, sizeof(args), \"%d:%d:flags=0x%X\",\n\n codec->width,\n\n codec->height,\n\n (unsigned)ofilter->ost->sws_flags);\n\n if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name(\"scale\"),\n\n NULL, args, NULL, fg->graph)) < 0)\n\n return ret;\n\n if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)\n\n return ret;\n\n\n\n last_filter = filter;\n\n pad_idx = 0;\n\n }\n\n\n\n if ((pix_fmts = choose_pixel_fmts(ofilter->ost))) {\n\n AVFilterContext *filter;\n\n if ((ret = avfilter_graph_create_filter(&filter,\n\n avfilter_get_by_name(\"format\"),\n\n \"format\", pix_fmts, NULL,\n\n fg->graph)) < 0)\n\n return ret;\n\n if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)\n\n return ret;\n\n\n\n last_filter = filter;\n\n pad_idx = 0;\n\n av_freep(&pix_fmts);\n\n }\n\n\n\n if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)\n\n return ret;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 26448 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int get_lowest_part_list_y(H264Context *h, Picture *pic, int n,\n\n int height, int y_offset, int list)\n\n{\n\n int raw_my = h->mv_cache[list][scan8[n]][1];\n\n int filter_height = (raw_my & 3) ? 2 : 0;\n\n int full_my = (raw_my >> 2) + y_offset;\n\n int top = full_my - filter_height;\n\n int bottom = full_my + filter_height + height;\n\n\n\n return FFMAX(abs(top), bottom);\n\n}\n", + "output": "1", + "index": 19214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_block_commit(const char *device,\n\n bool has_base, const char *base, const char *top,\n\n bool has_speed, int64_t speed,\n\n Error **errp)\n\n{\n\n BlockDriverState *bs;\n\n BlockDriverState *base_bs, *top_bs;\n\n Error *local_err = NULL;\n\n /* This will be part of the QMP command, if/when the\n\n * BlockdevOnError change for blkmirror makes it in\n\n */\n\n BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;\n\n\n\n /* drain all i/o before commits */\n\n bdrv_drain_all();\n\n\n\n bs = bdrv_find(device);\n\n if (!bs) {\n\n error_set(errp, QERR_DEVICE_NOT_FOUND, device);\n\n return;\n\n }\n\n if (base && has_base) {\n\n base_bs = bdrv_find_backing_image(bs, base);\n\n } else {\n\n base_bs = bdrv_find_base(bs);\n\n }\n\n\n\n if (base_bs == NULL) {\n\n error_set(errp, QERR_BASE_NOT_FOUND, base ? base : \"NULL\");\n\n return;\n\n }\n\n\n\n /* default top_bs is the active layer */\n\n top_bs = bs;\n\n\n\n if (top) {\n\n if (strcmp(bs->filename, top) != 0) {\n\n top_bs = bdrv_find_backing_image(bs, top);\n\n }\n\n }\n\n\n\n if (top_bs == NULL) {\n\n error_setg(errp, \"Top image file %s not found\", top ? top : \"NULL\");\n\n return;\n\n }\n\n\n\n commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs,\n\n &local_err);\n\n if (local_err != NULL) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n /* Grab a reference so hotplug does not delete the BlockDriverState from\n\n * underneath us.\n\n */\n\n drive_get_ref(drive_get_by_blockdev(bs));\n\n}\n", + "output": "1", + "index": 385 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,\n\n const char *backing_file)\n\n{\n\n char *filename_full = NULL;\n\n char *backing_file_full = NULL;\n\n char *filename_tmp = NULL;\n\n int is_protocol = 0;\n\n BlockDriverState *curr_bs = NULL;\n\n BlockDriverState *retval = NULL;\n\n\n\n if (!bs || !bs->drv || !backing_file) {\n\n return NULL;\n\n }\n\n\n\n filename_full = g_malloc(PATH_MAX);\n\n backing_file_full = g_malloc(PATH_MAX);\n\n filename_tmp = g_malloc(PATH_MAX);\n\n\n\n is_protocol = path_has_protocol(backing_file);\n\n\n\n for (curr_bs = bs; curr_bs->backing_hd; curr_bs = curr_bs->backing_hd) {\n\n\n\n /* If either of the filename paths is actually a protocol, then\n\n * compare unmodified paths; otherwise make paths relative */\n\n if (is_protocol || path_has_protocol(curr_bs->backing_file)) {\n\n if (strcmp(backing_file, curr_bs->backing_file) == 0) {\n\n retval = curr_bs->backing_hd;\n\n break;\n\n }\n\n } else {\n\n /* If not an absolute filename path, make it relative to the current\n\n * image's filename path */\n\n path_combine(filename_tmp, PATH_MAX, curr_bs->filename,\n\n backing_file);\n\n\n\n /* We are going to compare absolute pathnames */\n\n if (!realpath(filename_tmp, filename_full)) {\n\n continue;\n\n }\n\n\n\n /* We need to make sure the backing filename we are comparing against\n\n * is relative to the current image filename (or absolute) */\n\n path_combine(filename_tmp, PATH_MAX, curr_bs->filename,\n\n curr_bs->backing_file);\n\n\n\n if (!realpath(filename_tmp, backing_file_full)) {\n\n continue;\n\n }\n\n\n\n if (strcmp(backing_file_full, filename_full) == 0) {\n\n retval = curr_bs->backing_hd;\n\n break;\n\n }\n\n }\n\n }\n\n\n\n g_free(filename_full);\n\n g_free(backing_file_full);\n\n g_free(filename_tmp);\n\n return retval;\n\n}\n", + "output": "0", + "index": 7407 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int media_present(IDEState *s)\n\n{\n\n return (s->nb_sectors > 0);\n\n}\n", + "output": "1", + "index": 5593 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pci_bridge_region_init(PCIBridge *br)\n\n{\n\n PCIBus *parent = br->dev.bus;\n\n uint16_t cmd = pci_get_word(br->dev.config + PCI_COMMAND);\n\n\n\n pci_bridge_init_alias(br, &br->alias_pref_mem,\n\n PCI_BASE_ADDRESS_MEM_PREFETCH,\n\n \"pci_bridge_pref_mem\",\n\n &br->address_space_mem,\n\n parent->address_space_mem,\n\n cmd & PCI_COMMAND_MEMORY);\n\n pci_bridge_init_alias(br, &br->alias_mem,\n\n PCI_BASE_ADDRESS_SPACE_MEMORY,\n\n \"pci_bridge_mem\",\n\n &br->address_space_mem,\n\n parent->address_space_mem,\n\n cmd & PCI_COMMAND_MEMORY);\n\n pci_bridge_init_alias(br, &br->alias_io,\n\n PCI_BASE_ADDRESS_SPACE_IO,\n\n \"pci_bridge_io\",\n\n &br->address_space_io,\n\n parent->address_space_io,\n\n cmd & PCI_COMMAND_IO);\n\n /* TODO: optinal VGA and VGA palette snooping support. */\n\n}\n", + "output": "1", + "index": 23335 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rtas_get_xive(sPAPREnvironment *spapr, uint32_t token,\n\n uint32_t nargs, target_ulong args,\n\n uint32_t nret, target_ulong rets)\n\n{\n\n struct ics_state *ics = spapr->icp->ics;\n\n uint32_t nr;\n\n\n\n if ((nargs != 1) || (nret != 3)) {\n\n rtas_st(rets, 0, -3);\n\n return;\n\n }\n\n\n\n nr = rtas_ld(args, 0);\n\n\n\n if (!ics_valid_irq(ics, nr)) {\n\n rtas_st(rets, 0, -3);\n\n return;\n\n }\n\n\n\n rtas_st(rets, 0, 0); /* Success */\n\n rtas_st(rets, 1, ics->irqs[nr - ics->offset].server);\n\n rtas_st(rets, 2, ics->irqs[nr - ics->offset].priority);\n\n}\n", + "output": "0", + "index": 13171 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t cpu_get_apic_base(DeviceState *d)\n\n{\n\n if (d) {\n\n APICCommonState *s = APIC_COMMON(d);\n\n trace_cpu_get_apic_base((uint64_t)s->apicbase);\n\n return s->apicbase;\n\n } else {\n\n trace_cpu_get_apic_base(0);\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 26967 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_quit(int argc, const char **argv)\n\n{\n\n exit(0);\n\n}\n", + "output": "0", + "index": 25580 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qmp_monitor_complete(void *opaque, QObject *ret_data)\n\n{\n\n monitor_protocol_emitter(opaque, ret_data);\n\n}\n", + "output": "1", + "index": 14002 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)\n\n{\n\n QSVFrame *cur;\n\n AVPacket pkt;\n\n int ret = 0;\n\n mfxVideoParam param = { { 0 } };\n\n\n\n if (q->reinit_pending) {\n\n close_decoder(q);\n\n } else if (q->engine_ready) {\n\n ret = MFXVideoDECODE_GetVideoParam(q->session, ¶m);\n\n if (ret < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"MFX decode get param error %d\\n\", ret);\n\n }\n\n\n\n ret = MFXVideoDECODE_Reset(q->session, ¶m);\n\n if (ret < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"MFX decode reset error %d\\n\", ret);\n\n }\n\n\n\n /* Free all frames*/\n\n cur = q->work_frames;\n\n while (cur) {\n\n q->work_frames = cur->next;\n\n av_frame_free(&cur->frame);\n\n av_freep(&cur);\n\n cur = q->work_frames;\n\n }\n\n }\n\n\n\n /* Reset output surfaces */\n\n av_fifo_reset(q->async_fifo);\n\n\n\n /* Reset input packets fifo */\n\n while (av_fifo_size(q->pkt_fifo)) {\n\n av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);\n\n av_packet_unref(&pkt);\n\n }\n\n\n\n /* Reset input bitstream fifo */\n\n av_fifo_reset(q->input_fifo);\n\n}\n", + "output": "1", + "index": 3227 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int opt_streamid(const char *opt, const char *arg)\n\n{\n\n int idx;\n\n char *p;\n\n char idx_str[16];\n\n\n\n av_strlcpy(idx_str, arg, sizeof(idx_str));\n\n p = strchr(idx_str, ':');\n\n if (!p) {\n\n fprintf(stderr,\n\n \"Invalid value '%s' for option '%s', required syntax is 'index:value'\\n\",\n\n arg, opt);\n\n ffmpeg_exit(1);\n\n }\n\n *p++ = '\\0';\n\n idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX);\n\n streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);\n\n streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);\n\n return 0;\n\n}\n", + "output": "0", + "index": 25642 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_tag(AVIOContext *s, int offset, unsigned int len)\n\n{\n\n char tag[4];\n\n\n\n if (len > 4 ||\n\n avio_seek(s, offset, SEEK_SET) < 0 ||\n\n avio_read(s, tag, len) < len)\n\n return -1;\n\n else if (!AV_RB32(tag) || is_tag(tag, len))\n\n return 1;\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 24460 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void arm_thiswdog_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n arm_mptimer_state *s = (arm_mptimer_state *)opaque;\n\n int id = get_current_cpu(s);\n\n timerblock_write(&s->timerblock[id * 2 + 1], addr, value, size);\n\n}\n", + "output": "0", + "index": 25318 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_int8(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 int8_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": 12083 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_synth_truncate(FsContext *ctx, V9fsPath *path, off_t offset)\n\n{\n\n errno = ENOSYS;\n\n return -1;\n\n}\n", + "output": "0", + "index": 23817 + }, + { + "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 /* FIXME - also support UYVY output? */\n\n return ff_vf_next_config(vf, width * vf->priv->scalew,\n\n height / vf->priv->scaleh - vf->priv->skipline, d_width, d_height, flags, IMGFMT_YV12);\n\n}\n", + "output": "1", + "index": 7886 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_strtox_error(const char *nptr, char *ep,\n\n const char **endptr, int libc_errno)\n\n{\n\n if (libc_errno == 0 && ep == nptr) {\n\n libc_errno = EINVAL;\n\n }\n\n if (!endptr && *ep) {\n\n return -EINVAL;\n\n }\n\n if (endptr) {\n\n *endptr = ep;\n\n }\n\n return -libc_errno;\n\n}\n", + "output": "0", + "index": 9034 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)\n\n{\n\n VT686PMState *s = opaque;\n\n uint32_t val;\n\n\n\n addr &= 0x0f;\n\n switch (addr) {\n\n case 0x00:\n\n val = acpi_pm1_evt_get_sts(&s->ar, s->ar.tmr.overflow_time);\n\n break;\n\n case 0x02:\n\n val = s->ar.pm1.evt.en;\n\n break;\n\n case 0x04:\n\n val = s->ar.pm1.cnt.cnt;\n\n break;\n\n default:\n\n val = 0;\n\n break;\n\n }\n\n DPRINTF(\"PM readw port=0x%04x val=0x%02x\\n\", addr, val);\n\n return val;\n\n}\n", + "output": "1", + "index": 15095 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void hpet_timer(void *opaque)\n\n{\n\n HPETTimer *t = (HPETTimer*)opaque;\n\n uint64_t diff;\n\n\n\n uint64_t period = t->period;\n\n uint64_t cur_tick = hpet_get_ticks();\n\n\n\n if (timer_is_periodic(t) && period != 0) {\n\n if (t->config & HPET_TN_32BIT) {\n\n while (hpet_time_after(cur_tick, t->cmp))\n\n t->cmp = (uint32_t)(t->cmp + t->period);\n\n } else\n\n while (hpet_time_after64(cur_tick, t->cmp))\n\n t->cmp += period;\n\n\n\n diff = hpet_calculate_diff(t, cur_tick);\n\n qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)\n\n + (int64_t)ticks_to_ns(diff));\n\n } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {\n\n if (t->wrap_flag) {\n\n diff = hpet_calculate_diff(t, cur_tick);\n\n qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)\n\n + (int64_t)ticks_to_ns(diff));\n\n t->wrap_flag = 0;\n\n }\n\n }\n\n update_irq(t);\n\n}\n", + "output": "1", + "index": 6113 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit)\n\n{\n\n const char *driver;\n\n DeviceState *dev;\n\n\n\n driver = bdrv_is_sg(dinfo->bdrv) ? \"scsi-generic\" : \"scsi-disk\";\n\n dev = qdev_create(&bus->qbus, driver);\n\n qdev_prop_set_uint32(dev, \"scsi-id\", unit);\n\n qdev_prop_set_drive(dev, \"drive\", dinfo);\n\n qdev_init(dev);\n\n return DO_UPCAST(SCSIDevice, qdev, dev);\n\n}\n", + "output": "1", + "index": 27140 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_dds1(GetByteContext *gb, uint8_t *frame, int width, int height)\n\n{\n\n const uint8_t *frame_start = frame;\n\n const uint8_t *frame_end = frame + width * height;\n\n int mask = 0x10000, bitbuf = 0;\n\n int i, v, offset, count, segments;\n\n\n\n segments = bytestream2_get_le16(gb);\n\n while (segments--) {\n\n if (bytestream2_get_bytes_left(gb) < 2)\n\n return AVERROR_INVALIDDATA;\n\n if (mask == 0x10000) {\n\n bitbuf = bytestream2_get_le16u(gb);\n\n mask = 1;\n\n }\n\n\n\n if (bitbuf & mask) {\n\n v = bytestream2_get_le16(gb);\n\n offset = (v & 0x1FFF) << 2;\n\n count = ((v >> 13) + 2) << 1;\n\n if (frame - frame_start < offset || frame_end - frame < count*2 + width)\n\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < count; i++) {\n\n frame[0] = frame[1] =\n\n frame[width] = frame[width + 1] = frame[-offset];\n\n\n\n frame += 2;\n\n }\n\n } else if (bitbuf & (mask << 1)) {\n\n v = bytestream2_get_le16(gb)*2;\n\n if (frame - frame_end < v)\n\n return AVERROR_INVALIDDATA;\n\n frame += v;\n\n } else {\n\n if (frame_end - frame < width + 3)\n\n return AVERROR_INVALIDDATA;\n\n frame[0] = frame[1] =\n\n frame[width] = frame[width + 1] = bytestream2_get_byte(gb);\n\n frame += 2;\n\n frame[0] = frame[1] =\n\n frame[width] = frame[width + 1] = bytestream2_get_byte(gb);\n\n frame += 2;\n\n }\n\n mask <<= 2;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 24799 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)\n\n{\n\n uint32_t *copy;\n\n\n\n copy = g_malloc(sizeof(value));\n\n *copy = cpu_to_le32(value);\n\n return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));\n\n}\n", + "output": "1", + "index": 17944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,\n\n unsigned char *dest, int dest_size)\n\n{\n\n PixFmtInfo* pf = &pix_fmt_info[pix_fmt];\n\n int i, j, w, h, data_planes;\n\n const unsigned char* s; \n\n int size = avpicture_get_size(pix_fmt, width, height);\n\n\n\n if (size > dest_size)\n\n return -1;\n\n\n\n if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {\n\n if (pix_fmt == PIX_FMT_YUV422 || \n\n pix_fmt == PIX_FMT_UYVY422 || \n\n pix_fmt == PIX_FMT_RGB565 ||\n\n pix_fmt == PIX_FMT_RGB555)\n\n w = width * 2;\n\n\telse if (pix_fmt == PIX_FMT_UYVY411)\n\n\t w = width + width/2;\n\n\telse if (pix_fmt == PIX_FMT_PAL8)\n\n\t w = width;\n\n\telse\n\n\t w = width * (pf->depth * pf->nb_channels / 8);\n\n\t \n\n\tdata_planes = 1;\n\n\th = height;\n\n } else {\n\n data_planes = pf->nb_channels;\n\n\tw = (width*pf->depth + 7)/8;\n\n\th = height;\n\n }\n\n \n\n for (i=0; i> pf->x_chroma_shift;\n\n\t h = height >> pf->y_chroma_shift;\n\n\t }\n\n s = src->data[i];\n\n\t for(j=0; jlinesize[i];\n\n\t }\n\n }\n\n \n\n if (pf->pixel_type == FF_PIXEL_PALETTE)\n\n\tmemcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);\n\n \n\n return size;\n\n}\n", + "output": "1", + "index": 25493 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_arch_init_irq_routing(KVMState *s)\n\n{\n\n if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {\n\n /* If kernel can't do irq routing, interrupt source\n\n * override 0->2 cannot be set up as required by HPET.\n\n * So we have to disable it.\n\n */\n\n no_hpet = 1;\n\n }\n\n /* We know at this point that we're using the in-kernel\n\n * irqchip, so we can use irqfds, and on x86 we know\n\n * we can use msi via irqfd and GSI routing.\n\n */\n\n kvm_irqfds_allowed = true;\n\n kvm_msi_via_irqfd_allowed = true;\n\n kvm_gsi_routing_allowed = true;\n\n}\n", + "output": "0", + "index": 22776 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_out_any(TestOutputVisitorData *data,\n\n const void *unused)\n\n{\n\n QObject *qobj;\n\n QInt *qint;\n\n QBool *qbool;\n\n QString *qstring;\n\n QDict *qdict;\n\n QObject *obj;\n\n\n\n qobj = QOBJECT(qint_from_int(-42));\n\n visit_type_any(data->ov, NULL, &qobj, &error_abort);\n\n obj = visitor_get(data);\n\n g_assert(qobject_type(obj) == QTYPE_QINT);\n\n g_assert_cmpint(qint_get_int(qobject_to_qint(obj)), ==, -42);\n\n qobject_decref(qobj);\n\n\n\n visitor_reset(data);\n\n qdict = qdict_new();\n\n qdict_put(qdict, \"integer\", qint_from_int(-42));\n\n qdict_put(qdict, \"boolean\", qbool_from_bool(true));\n\n qdict_put(qdict, \"string\", qstring_from_str(\"foo\"));\n\n qobj = QOBJECT(qdict);\n\n visit_type_any(data->ov, NULL, &qobj, &error_abort);\n\n qobject_decref(qobj);\n\n qdict = qobject_to_qdict(visitor_get(data));\n\n g_assert(qdict);\n\n qobj = qdict_get(qdict, \"integer\");\n\n g_assert(qobj);\n\n qint = qobject_to_qint(qobj);\n\n g_assert(qint);\n\n g_assert_cmpint(qint_get_int(qint), ==, -42);\n\n qobj = qdict_get(qdict, \"boolean\");\n\n g_assert(qobj);\n\n qbool = qobject_to_qbool(qobj);\n\n g_assert(qbool);\n\n g_assert(qbool_get_bool(qbool) == true);\n\n qstring = qobject_to_qstring(qdict_get(qdict, \"string\"));\n\n g_assert(qstring);\n\n g_assert_cmpstr(qstring_get_str(qstring), ==, \"foo\");\n\n}\n", + "output": "0", + "index": 19578 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void configure_icount(const char *option)\n\n{\n\n vmstate_register(NULL, 0, &vmstate_timers, &timers_state);\n\n if (!option)\n\n return;\n\n\n\n#ifdef CONFIG_IOTHREAD\n\n vm_clock->warp_timer = qemu_new_timer_ns(rt_clock, icount_warp_rt, NULL);\n\n#endif\n\n\n\n if (strcmp(option, \"auto\") != 0) {\n\n icount_time_shift = strtol(option, NULL, 0);\n\n use_icount = 1;\n\n return;\n\n }\n\n\n\n use_icount = 2;\n\n\n\n /* 125MIPS seems a reasonable initial guess at the guest speed.\n\n It will be corrected fairly quickly anyway. */\n\n icount_time_shift = 3;\n\n\n\n /* Have both realtime and virtual time triggers for speed adjustment.\n\n The realtime trigger catches emulated time passing too slowly,\n\n the virtual time trigger catches emulated time passing too fast.\n\n Realtime triggers occur even when idle, so use them less frequently\n\n than VM triggers. */\n\n icount_rt_timer = qemu_new_timer_ms(rt_clock, icount_adjust_rt, NULL);\n\n qemu_mod_timer(icount_rt_timer,\n\n qemu_get_clock_ms(rt_clock) + 1000);\n\n icount_vm_timer = qemu_new_timer_ns(vm_clock, icount_adjust_vm, NULL);\n\n qemu_mod_timer(icount_vm_timer,\n\n qemu_get_clock_ns(vm_clock) + get_ticks_per_sec() / 10);\n\n}\n", + "output": "1", + "index": 4415 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mm_stop_timer(struct qemu_alarm_timer *t)\n\n{\n\n timeKillEvent(mm_timer);\n\n timeEndPeriod(mm_period);\n\n}\n", + "output": "1", + "index": 25185 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_id_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n if (size != 4) {\n\n return omap_badwidth_write32(opaque, addr, value);\n\n }\n\n\n\n OMAP_BAD_REG(addr);\n\n}\n", + "output": "0", + "index": 26198 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_unit(SCPRContext *s, PixelModel *pixel, unsigned step, unsigned *rval)\n\n{\n\n GetByteContext *gb = &s->gb;\n\n RangeCoder *rc = &s->rc;\n\n unsigned totfr = pixel->total_freq;\n\n unsigned value, x = 0, cumfr = 0, cnt_x = 0;\n\n int i, j, ret, c, cnt_c;\n\n\n\n if ((ret = s->get_freq(rc, totfr, &value)) < 0)\n\n return ret;\n\n\n\n while (x < 16) {\n\n cnt_x = pixel->lookup[x];\n\n if (value >= cumfr + cnt_x)\n\n cumfr += cnt_x;\n\n else\n\n break;\n\n x++;\n\n }\n\n\n\n c = x * 16;\n\n cnt_c = 0;\n\n while (c < 256) {\n\n cnt_c = pixel->freq[c];\n\n if (value >= cumfr + cnt_c)\n\n cumfr += cnt_c;\n\n else\n\n break;\n\n c++;\n\n }\n\n s->decode(gb, rc, cumfr, cnt_c, totfr);\n\n pixel->freq[c] = cnt_c + step;\n\n pixel->lookup[x] = cnt_x + step;\n\n totfr += step;\n\n if (totfr > BOT) {\n\n totfr = 0;\n\n for (i = 0; i < 256; i++) {\n\n unsigned nc = (pixel->freq[i] >> 1) + 1;\n\n pixel->freq[i] = nc;\n\n totfr += nc;\n\n }\n\n for (i = 0; i < 16; i++) {\n\n unsigned sum = 0;\n\n unsigned i16_17 = i << 4;\n\n for (j = 0; j < 16; j++)\n\n sum += pixel->freq[i16_17 + j];\n\n pixel->lookup[i] = sum;\n\n }\n\n }\n\n pixel->total_freq = totfr;\n\n\n\n *rval = c & s->cbits;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17896 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int raw_pwrite(BlockDriverState *bs, int64_t offset,\n\n const uint8_t *buf, int count)\n\n{\n\n BDRVRawState *s = bs->opaque;\n\n int size, ret, shift, sum;\n\n\n\n sum = 0;\n\n\n\n if (s->aligned_buf != NULL) {\n\n\n\n if (offset & 0x1ff) {\n\n /* align offset on a 512 bytes boundary */\n\n shift = offset & 0x1ff;\n\n ret = raw_pread_aligned(bs, offset - shift, s->aligned_buf, 512);\n\n if (ret < 0)\n\n return ret;\n\n\n\n size = 512 - shift;\n\n if (size > count)\n\n size = count;\n\n memcpy(s->aligned_buf + shift, buf, size);\n\n\n\n ret = raw_pwrite_aligned(bs, offset - shift, s->aligned_buf, 512);\n\n if (ret < 0)\n\n return ret;\n\n\n\n buf += size;\n\n offset += size;\n\n count -= size;\n\n sum += size;\n\n\n\n if (count == 0)\n\n return sum;\n\n }\n\n if (count & 0x1ff || (uintptr_t) buf & 0x1ff) {\n\n\n\n while ((size = (count & ~0x1ff)) != 0) {\n\n\n\n if (size > ALIGNED_BUFFER_SIZE)\n\n size = ALIGNED_BUFFER_SIZE;\n\n\n\n memcpy(s->aligned_buf, buf, size);\n\n\n\n ret = raw_pwrite_aligned(bs, offset, s->aligned_buf, size);\n\n if (ret < 0)\n\n return ret;\n\n\n\n buf += ret;\n\n offset += ret;\n\n count -= ret;\n\n sum += ret;\n\n }\n\n /* here, count < 512 because (count & ~0x1ff) == 0 */\n\n if (count) {\n\n ret = raw_pread_aligned(bs, offset, s->aligned_buf, 512);\n\n if (ret < 0)\n\n return ret;\n\n memcpy(s->aligned_buf, buf, count);\n\n\n\n ret = raw_pwrite_aligned(bs, offset, s->aligned_buf, 512);\n\n if (ret < 0)\n\n return ret;\n\n if (count < ret)\n\n ret = count;\n\n\n\n sum += ret;\n\n }\n\n return sum;\n\n }\n\n }\n\n return raw_pwrite_aligned(bs, offset, buf, count) + sum;\n\n}\n", + "output": "0", + "index": 23368 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_last_needed_nal(H264Context *h)\n\n{\n\n int nals_needed = 0;\n\n int i;\n\n\n\n for (i = 0; i < h->pkt.nb_nals; i++) {\n\n H2645NAL *nal = &h->pkt.nals[i];\n\n GetBitContext gb;\n\n\n\n /* packets can sometimes contain multiple PPS/SPS,\n\n * e.g. two PAFF field pictures in one packet, or a demuxer\n\n * which splits NALs strangely if so, when frame threading we\n\n * can't start the next thread until we've read all of them */\n\n switch (nal->type) {\n\n case NAL_SPS:\n\n case NAL_PPS:\n\n nals_needed = i;\n\n break;\n\n case NAL_DPA:\n\n case NAL_IDR_SLICE:\n\n case NAL_SLICE:\n\n init_get_bits(&gb, nal->data + 1, (nal->size - 1) * 8);\n\n if (!get_ue_golomb(&gb))\n\n nals_needed = i;\n\n }\n\n }\n\n\n\n return nals_needed;\n\n}\n", + "output": "0", + "index": 3850 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void destroy_all_mappings(void)\n\n{\n\n destroy_l2_mapping(&phys_map, P_L2_LEVELS - 1);\n\n phys_map_nodes_reset();\n\n}\n", + "output": "0", + "index": 9044 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mirror_complete(BlockJob *job, Error **errp)\n\n{\n\n MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);\n\n Error *local_err = NULL;\n\n int ret;\n\n\n\n ret = bdrv_open_backing_file(s->target, NULL, &local_err);\n\n if (ret < 0) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n if (!s->synced) {\n\n error_setg(errp, QERR_BLOCK_JOB_NOT_READY,\n\n bdrv_get_device_name(job->bs));\n\n return;\n\n }\n\n\n\n /* check the target bs is not blocked and block all operations on it */\n\n if (s->replaces) {\n\n AioContext *replace_aio_context;\n\n\n\n s->to_replace = check_to_replace_node(s->replaces, &local_err);\n\n if (!s->to_replace) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n replace_aio_context = bdrv_get_aio_context(s->to_replace);\n\n aio_context_acquire(replace_aio_context);\n\n\n\n error_setg(&s->replace_blocker,\n\n \"block device is in use by block-job-complete\");\n\n bdrv_op_block_all(s->to_replace, s->replace_blocker);\n\n bdrv_ref(s->to_replace);\n\n\n\n aio_context_release(replace_aio_context);\n\n }\n\n\n\n s->should_complete = true;\n\n block_job_enter(&s->common);\n\n}\n", + "output": "0", + "index": 114 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_sigp_status(SigpInfo *si, uint64_t status)\n\n{\n\n *si->status_reg &= 0xffffffff00000000ULL;\n\n *si->status_reg |= status;\n\n si->cc = SIGP_CC_STATUS_STORED;\n\n}\n", + "output": "0", + "index": 20403 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void command_loop(void)\n\n{\n\n int c, i, j = 0, done = 0, fetchable = 0, prompted = 0;\n\n char *input;\n\n char **v;\n\n const cmdinfo_t *ct;\n\n\n\n for (i = 0; !done && i < ncmdline; i++) {\n\n input = strdup(cmdline[i]);\n\n if (!input) {\n\n fprintf(stderr, _(\"cannot strdup command '%s': %s\\n\"),\n\n cmdline[i], strerror(errno));\n\n exit(1);\n\n }\n\n v = breakline(input, &c);\n\n if (c) {\n\n ct = find_command(v[0]);\n\n if (ct) {\n\n if (ct->flags & CMD_FLAG_GLOBAL) {\n\n done = command(ct, c, v);\n\n } else {\n\n j = 0;\n\n while (!done && (j = args_command(j))) {\n\n done = command(ct, c, v);\n\n }\n\n }\n\n } else {\n\n fprintf(stderr, _(\"command \\\"%s\\\" not found\\n\"), v[0]);\n\n }\n\n\t}\n\n doneline(input, v);\n\n }\n\n if (cmdline) {\n\n free(cmdline);\n\n return;\n\n }\n\n\n\n while (!done) {\n\n if (!prompted) {\n\n printf(\"%s\", get_prompt());\n\n fflush(stdout);\n\n qemu_aio_set_fd_handler(STDIN_FILENO, prep_fetchline, NULL, NULL,\n\n NULL, &fetchable);\n\n prompted = 1;\n\n }\n\n\n\n qemu_aio_wait();\n\n\n\n if (!fetchable) {\n\n continue;\n\n }\n\n input = fetchline();\n\n if (input == NULL) {\n\n break;\n\n }\n\n v = breakline(input, &c);\n\n if (c) {\n\n ct = find_command(v[0]);\n\n if (ct) {\n\n done = command(ct, c, v);\n\n } else {\n\n fprintf(stderr, _(\"command \\\"%s\\\" not found\\n\"), v[0]);\n\n }\n\n }\n\n doneline(input, v);\n\n\n\n prompted = 0;\n\n fetchable = 0;\n\n }\n\n qemu_aio_set_fd_handler(STDIN_FILENO, NULL, NULL, NULL, NULL, NULL);\n\n}\n", + "output": "1", + "index": 16191 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int webm_dash_manifest_write_trailer(AVFormatContext *s)\n\n{\n\n WebMDashMuxContext *w = s->priv_data;\n\n int i;\n\n for (i = 0; i < w->nb_as; i++) {\n\n av_freep(&w->as[i].streams);\n\n }\n\n av_freep(&w->as);\n\n return 0;\n\n}\n", + "output": "1", + "index": 4427 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tricore_cpu_class_init(ObjectClass *c, void *data)\n\n{\n\n TriCoreCPUClass *mcc = TRICORE_CPU_CLASS(c);\n\n CPUClass *cc = CPU_CLASS(c);\n\n DeviceClass *dc = DEVICE_CLASS(c);\n\n\n\n mcc->parent_realize = dc->realize;\n\n dc->realize = tricore_cpu_realizefn;\n\n\n\n mcc->parent_reset = cc->reset;\n\n cc->reset = tricore_cpu_reset;\n\n cc->class_by_name = tricore_cpu_class_by_name;\n\n cc->has_work = tricore_cpu_has_work;\n\n\n\n cc->dump_state = tricore_cpu_dump_state;\n\n cc->set_pc = tricore_cpu_set_pc;\n\n cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;\n\n\n}", + "output": "1", + "index": 24886 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tlb_info(Monitor *mon)\n\n{\n\n CPUState *env;\n\n int l1, l2;\n\n uint32_t pgd, pde, pte;\n\n\n\n env = mon_get_cpu();\n\n\n\n if (!(env->cr[0] & CR0_PG_MASK)) {\n\n monitor_printf(mon, \"PG disabled\\n\");\n\n return;\n\n }\n\n pgd = env->cr[3] & ~0xfff;\n\n for(l1 = 0; l1 < 1024; l1++) {\n\n cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4);\n\n pde = le32_to_cpu(pde);\n\n if (pde & PG_PRESENT_MASK) {\n\n if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {\n\n print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1));\n\n } else {\n\n for(l2 = 0; l2 < 1024; l2++) {\n\n cpu_physical_memory_read((pde & ~0xfff) + l2 * 4,\n\n (uint8_t *)&pte, 4);\n\n pte = le32_to_cpu(pte);\n\n if (pte & PG_PRESENT_MASK) {\n\n print_pte(mon, (l1 << 22) + (l2 << 12),\n\n pte & ~PG_PSE_MASK,\n\n ~0xfff);\n\n }\n\n }\n\n }\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 1792 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static HTTPContext *find_rtp_session_with_url(const char *url, \n\n const char *session_id)\n\n{\n\n HTTPContext *rtp_c;\n\n char path1[1024];\n\n const char *path;\n\n char buf[1024];\n\n int s;\n\n\n\n rtp_c = find_rtp_session(session_id);\n\n if (!rtp_c)\n\n return NULL;\n\n\n\n /* find which url is asked */\n\n url_split(NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);\n\n path = path1;\n\n if (*path == '/')\n\n path++;\n\n if(!strcmp(path, rtp_c->stream->filename)) return rtp_c;\n\n for(s=0; sstream->nb_streams; ++s) {\n\n snprintf(buf, sizeof(buf), \"%s/streamid=%d\",\n\n rtp_c->stream->filename, s);\n\n if(!strncmp(path, buf, sizeof(buf))) {\n\n // XXX: Should we reply with RTSP_STATUS_ONLY_AGGREGATE if nb_streams>1?\n\n return rtp_c;\n\n }\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 11590 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)\n\n{\n\n AMFDataType type;\n\n AVStream *stream, *astream, *vstream;\n\n AVIOContext *ioc;\n\n int i;\n\n // only needs to hold the string \"onMetaData\".\n\n // Anything longer is something we don't want.\n\n char buffer[11];\n\n\n\n astream = NULL;\n\n vstream = NULL;\n\n ioc = s->pb;\n\n\n\n // first object needs to be \"onMetaData\" string\n\n type = avio_r8(ioc);\n\n if (type != AMF_DATA_TYPE_STRING ||\n\n amf_get_string(ioc, buffer, sizeof(buffer)) < 0)\n\n return -1;\n\n\n\n if (!strcmp(buffer, \"onTextData\"))\n\n return 1;\n\n\n\n if (strcmp(buffer, \"onMetaData\"))\n\n return -1;\n\n\n\n // find the streams now so that amf_parse_object doesn't need to do\n\n // the lookup every time it is called.\n\n for (i = 0; i < s->nb_streams; i++) {\n\n stream = s->streams[i];\n\n if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO)\n\n astream = stream;\n\n else if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)\n\n vstream = stream;\n\n }\n\n\n\n // parse the second object (we want a mixed array)\n\n if (amf_parse_object(s, astream, vstream, buffer, next_pos, 0) < 0)\n\n return -1;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 9036 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void zero_remaining(unsigned int b, unsigned int b_max,\n\n const unsigned int *div_blocks, int32_t *buf)\n\n{\n\n unsigned int count = 0;\n\n\n\n while (b < b_max)\n\n count += div_blocks[b];\n\n\n\n if (count)\n\n memset(buf, 0, sizeof(*buf) * count);\n\n}\n", + "output": "0", + "index": 1667 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size)\n\n{\n\n /* This writes the bottom N bits of a 128 bit wide vector to memory */\n\n TCGv_i64 tmp = tcg_temp_new_i64();\n\n tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(srcidx, MO_64));\n\n if (size < 4) {\n\n tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TE + size);\n\n } else {\n\n TCGv_i64 tcg_hiaddr = tcg_temp_new_i64();\n\n tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TEQ);\n\n tcg_gen_qemu_st64(tmp, tcg_addr, get_mem_index(s));\n\n tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(srcidx));\n\n tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);\n\n tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(s), MO_TEQ);\n\n tcg_temp_free_i64(tcg_hiaddr);\n\n }\n\n\n\n tcg_temp_free_i64(tmp);\n\n}\n", + "output": "0", + "index": 16605 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(simple_dict)\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);\n\n fail_unless(obj != NULL);\n\n fail_unless(qobject_type(obj) == QTYPE_QDICT);\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_QDICT);\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": 9860 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mxf_write_identification(AVFormatContext *s)\n\n{\n\n MXFContext *mxf = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n const char *company = \"Libav\";\n\n const char *product = \"OP1a Muxer\";\n\n const char *version;\n\n int length;\n\n\n\n mxf_write_metadata_key(pb, 0x013000);\n\n PRINT_KEY(s, \"identification key\", pb->buf_ptr - 16);\n\n\n\n version = s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT ?\n\n \"0.0.0\" : AV_STRINGIFY(LIBAVFORMAT_VERSION);\n\n length = 84 + (strlen(company)+strlen(product)+strlen(version))*2; // utf-16\n\n klv_encode_ber_length(pb, length);\n\n\n\n // write uid\n\n mxf_write_local_tag(pb, 16, 0x3C0A);\n\n mxf_write_uuid(pb, Identification, 0);\n\n PRINT_KEY(s, \"identification uid\", pb->buf_ptr - 16);\n\n\n\n // write generation uid\n\n mxf_write_local_tag(pb, 16, 0x3C09);\n\n mxf_write_uuid(pb, Identification, 1);\n\n\n\n mxf_write_local_tag_utf16(pb, 0x3C01, company); // Company Name\n\n mxf_write_local_tag_utf16(pb, 0x3C02, product); // Product Name\n\n mxf_write_local_tag_utf16(pb, 0x3C04, version); // Version String\n\n\n\n // write product uid\n\n mxf_write_local_tag(pb, 16, 0x3C05);\n\n mxf_write_uuid(pb, Identification, 2);\n\n\n\n // modification date\n\n mxf_write_local_tag(pb, 8, 0x3C06);\n\n avio_wb64(pb, mxf->timestamp);\n\n}\n", + "output": "0", + "index": 20355 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qtest_init(const char *qtest_chrdev, const char *qtest_log)\n\n{\n\n CharDriverState *chr;\n\n\n\n chr = qemu_chr_new(\"qtest\", qtest_chrdev, NULL);\n\n\n\n qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);\n\n qemu_chr_fe_set_echo(chr, true);\n\n\n\n inbuf = g_string_new(\"\");\n\n\n\n if (qtest_log) {\n\n if (strcmp(qtest_log, \"none\") != 0) {\n\n qtest_log_fp = fopen(qtest_log, \"w+\");\n\n }\n\n } else {\n\n qtest_log_fp = stderr;\n\n }\n\n\n\n qtest_chr = chr;\n\n}\n", + "output": "1", + "index": 4237 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t blk_mig_bytes_transferred(void)\n\n{\n\n BlkMigDevState *bmds;\n\n uint64_t sum = 0;\n\n\n\n blk_mig_lock();\n\n QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {\n\n sum += bmds->completed_sectors;\n\n }\n\n blk_mig_unlock();\n\n return sum << BDRV_SECTOR_BITS;\n\n}\n", + "output": "1", + "index": 18173 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t hb_regs_read(void *opaque, target_phys_addr_t offset,\n\n unsigned size)\n\n{\n\n uint32_t *regs = opaque;\n\n uint32_t value = regs[offset/4];\n\n\n\n if ((offset == 0x100) || (offset == 0x108) || (offset == 0x10C)) {\n\n value |= 0x30000000;\n\n }\n\n\n\n return value;\n\n}\n", + "output": "0", + "index": 9738 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_unlock_avcodec(const AVCodec *codec)\n\n{\n\n _Bool exp = 1;\n\n if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)\n\n return 0;\n\n\n\n av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 0));\n\n atomic_fetch_add(&entangled_thread_counter, -1);\n\n if (lockmgr_cb) {\n\n if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13252 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bastardized_rice_decompress(ALACContext *alac,\n\n int32_t *output_buffer,\n\n int output_size,\n\n int readsamplesize,\n\n int rice_history_mult)\n\n{\n\n int output_count;\n\n unsigned int history = alac->rice_initial_history;\n\n int sign_modifier = 0;\n\n\n\n for (output_count = 0; output_count < output_size; output_count++) {\n\n int32_t x;\n\n int32_t x_modified;\n\n int32_t final_val;\n\n\n\n /* standard rice encoding */\n\n int k; /* size of extra bits */\n\n\n\n /* read k, that is bits as is */\n\n k = av_log2((history >> 9) + 3);\n\n x = decode_scalar(&alac->gb, k, alac->rice_limit, readsamplesize);\n\n\n\n x_modified = sign_modifier + x;\n\n final_val = (x_modified + 1) / 2;\n\n if (x_modified & 1) final_val *= -1;\n\n\n\n output_buffer[output_count] = final_val;\n\n\n\n sign_modifier = 0;\n\n\n\n /* now update the history */\n\n history += x_modified * rice_history_mult -\n\n ((history * rice_history_mult) >> 9);\n\n\n\n if (x_modified > 0xffff)\n\n history = 0xffff;\n\n\n\n /* special case: there may be compressed blocks of 0 */\n\n if ((history < 128) && (output_count+1 < output_size)) {\n\n int k;\n\n unsigned int block_size;\n\n\n\n sign_modifier = 1;\n\n\n\n k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */);\n\n\n\n block_size = decode_scalar(&alac->gb, k, alac->rice_limit, 16);\n\n\n\n if (block_size > 0) {\n\n if(block_size >= output_size - output_count){\n\n av_log(alac->avctx, AV_LOG_ERROR, \"invalid zero block size of %d %d %d\\n\", block_size, output_size, output_count);\n\n block_size= output_size - output_count - 1;\n\n }\n\n memset(&output_buffer[output_count+1], 0, block_size * 4);\n\n output_count += block_size;\n\n }\n\n\n\n if (block_size > 0xffff)\n\n sign_modifier = 0;\n\n\n\n history = 0;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 3709 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void replay_save_event(Event *event, int checkpoint)\n\n{\n\n if (replay_mode != REPLAY_MODE_PLAY) {\n\n /* put the event into the file */\n\n replay_put_event(EVENT_ASYNC);\n\n replay_put_byte(checkpoint);\n\n replay_put_byte(event->event_kind);\n\n\n\n /* save event-specific data */\n\n switch (event->event_kind) {\n\n case REPLAY_ASYNC_EVENT_BH:\n\n replay_put_qword(event->id);\n\n break;\n\n case REPLAY_ASYNC_EVENT_INPUT:\n\n replay_save_input_event(event->opaque);\n\n break;\n\n case REPLAY_ASYNC_EVENT_INPUT_SYNC:\n\n break;\n\n case REPLAY_ASYNC_EVENT_CHAR_READ:\n\n replay_event_char_read_save(event->opaque);\n\n break;\n\n default:\n\n error_report(\"Unknown ID %d of replay event\", read_event_kind);\n\n exit(1);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 3220 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_do_symlink(V9fsState *s, V9fsString *oldpath,\n\n V9fsString *newpath)\n\n{\n\n return s->ops->symlink(&s->ctx, oldpath->data, newpath->data);\n\n}\n", + "output": "0", + "index": 1550 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void stm32f2xx_usart_write(void *opaque, hwaddr addr,\n\n uint64_t val64, unsigned int size)\n\n{\n\n STM32F2XXUsartState *s = opaque;\n\n uint32_t value = val64;\n\n unsigned char ch;\n\n\n\n DB_PRINT(\"Write 0x%\" PRIx32 \", 0x%\"HWADDR_PRIx\"\\n\", value, addr);\n\n\n\n switch (addr) {\n\n case USART_SR:\n\n if (value <= 0x3FF) {\n\n s->usart_sr = value;\n\n } else {\n\n s->usart_sr &= value;\n\n }\n\n if (!(s->usart_sr & USART_SR_RXNE)) {\n\n qemu_set_irq(s->irq, 0);\n\n }\n\n return;\n\n case USART_DR:\n\n if (value < 0xF000) {\n\n ch = value;\n\n if (s->chr) {\n\n\n\n qemu_chr_fe_write_all(s->chr, &ch, 1);\n\n }\n\n s->usart_sr |= USART_SR_TC;\n\n s->usart_sr &= ~USART_SR_TXE;\n\n }\n\n return;\n\n case USART_BRR:\n\n s->usart_brr = value;\n\n return;\n\n case USART_CR1:\n\n s->usart_cr1 = value;\n\n if (s->usart_cr1 & USART_CR1_RXNEIE &&\n\n s->usart_sr & USART_SR_RXNE) {\n\n qemu_set_irq(s->irq, 1);\n\n }\n\n return;\n\n case USART_CR2:\n\n s->usart_cr2 = value;\n\n return;\n\n case USART_CR3:\n\n s->usart_cr3 = value;\n\n return;\n\n case USART_GTPR:\n\n s->usart_gtpr = value;\n\n return;\n\n default:\n\n qemu_log_mask(LOG_GUEST_ERROR,\n\n \"%s: Bad offset 0x%\"HWADDR_PRIx\"\\n\", __func__, addr);\n\n }\n\n}", + "output": "1", + "index": 2777 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void moxie_cpu_initfn(Object *obj)\n\n{\n\n CPUState *cs = CPU(obj);\n\n MoxieCPU *cpu = MOXIE_CPU(obj);\n\n static int inited;\n\n\n\n cs->env_ptr = &cpu->env;\n\n cpu_exec_init(cs, &error_abort);\n\n\n\n if (tcg_enabled() && !inited) {\n\n inited = 1;\n\n moxie_translate_init();\n\n }\n\n}\n", + "output": "1", + "index": 25435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void dsputil_init_mlib(void)\n\n{\n\n put_pixels_tab[0][0] = put_pixels16_mlib;\n\n put_pixels_tab[0][1] = put_pixels16_x2_mlib;\n\n put_pixels_tab[0][2] = put_pixels16_y2_mlib;\n\n put_pixels_tab[0][3] = put_pixels16_xy2_mlib;\n\n put_pixels_tab[1][0] = put_pixels8_mlib;\n\n put_pixels_tab[1][1] = put_pixels8_x2_mlib;\n\n put_pixels_tab[1][2] = put_pixels8_y2_mlib;\n\n put_pixels_tab[1][3] = put_pixels8_xy2_mlib;\n\n\n\n avg_pixels_tab[0][0] = avg_pixels16_mlib;\n\n avg_pixels_tab[0][1] = avg_pixels16_x2_mlib;\n\n avg_pixels_tab[0][2] = avg_pixels16_y2_mlib;\n\n avg_pixels_tab[0][3] = avg_pixels16_xy2_mlib;\n\n avg_pixels_tab[1][0] = avg_pixels8_mlib;\n\n avg_pixels_tab[1][1] = avg_pixels8_x2_mlib;\n\n avg_pixels_tab[1][2] = avg_pixels8_y2_mlib;\n\n avg_pixels_tab[1][3] = avg_pixels8_xy2_mlib;\n\n \n\n put_no_rnd_pixels_tab[0][0] = put_pixels16_mlib;\n\n put_no_rnd_pixels_tab[1][0] = put_pixels8_mlib;\n\n \n\n add_pixels_clamped = add_pixels_clamped_mlib;\n\n}\n", + "output": "0", + "index": 9359 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pci_bridge_exitfn(PCIDevice *pci_dev)\n\n{\n\n PCIBridge *s = DO_UPCAST(PCIBridge, dev, pci_dev);\n\n assert(QLIST_EMPTY(&s->sec_bus.child));\n\n QLIST_REMOVE(&s->sec_bus, sibling);\n\n pci_bridge_region_cleanup(s);\n\n memory_region_destroy(&s->address_space_mem);\n\n memory_region_destroy(&s->address_space_io);\n\n /* qbus_free() is called automatically by qdev_free() */\n\n}\n", + "output": "1", + "index": 4060 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)\n\n{\n\n int ret, i;\n\n\n\n ret = ff_hevc_decode_extradata(buf, length, &s->ps, &s->sei, &s->is_nalff,\n\n &s->nal_length_size, s->avctx->err_recognition,\n\n s->apply_defdispwin, s->avctx);\n\n if (ret < 0)\n\n return ret;\n\n\n\n /* export stream parameters from the first SPS */\n\n for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {\n\n if (s->ps.sps_list[i]) {\n\n const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data;\n\n export_stream_params(s->avctx, &s->ps, sps);\n\n break;\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 11798 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int sd_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)\n\n{\n\n /* FIXME: Delete specified snapshot id. */\n\n return 0;\n\n}\n", + "output": "1", + "index": 10757 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int host_to_target_errno(int err)\n\n{\n\n if(host_to_target_errno_table[err])\n\n return host_to_target_errno_table[err];\n\n return err;\n\n}\n", + "output": "1", + "index": 26316 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void colored_fputs(int level, int tint, const char *str)\n\n{\n\n if (!*str)\n\n return;\n\n\n\n if (use_color < 0)\n\n check_color_terminal();\n\n\n\n#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE\n\n if (use_color && level != AV_LOG_INFO/8)\n\n SetConsoleTextAttribute(con, background | color[level]);\n\n fputs(str, stderr);\n\n if (use_color && level != AV_LOG_INFO/8)\n\n SetConsoleTextAttribute(con, attr_orig);\n\n#else\n\n if (use_color == 1 && level != AV_LOG_INFO/8) {\n\n fprintf(stderr,\n\n \"\\033[%d;3%dm%s\\033[0m\",\n\n (color[level] >> 4) & 15,\n\n color[level] & 15,\n\n str);\n\n } else if (tint && use_color == 256) {\n\n fprintf(stderr,\n\n \"\\033[48;5;%dm\\033[38;5;%dm%s\\033[0m\",\n\n (color[level] >> 16) & 0xff,\n\n tint,\n\n str);\n\n } else if (use_color == 256 && level != AV_LOG_INFO/8) {\n\n fprintf(stderr,\n\n \"\\033[48;5;%dm\\033[38;5;%dm%s\\033[0m\",\n\n (color[level] >> 16) & 0xff,\n\n (color[level] >> 8) & 0xff,\n\n str);\n\n } else\n\n fputs(str, stderr);\n\n#endif\n\n\n\n}\n", + "output": "0", + "index": 24520 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "g_malloc0(size_t n_bytes)\n\n{\n\n void *mem;\n\n __coverity_negative_sink__(n_bytes);\n\n mem = calloc(1, n_bytes == 0 ? 1 : n_bytes);\n\n if (!mem) __coverity_panic__();\n\n return mem;\n\n}\n", + "output": "1", + "index": 18644 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_parent_drained_end(BlockDriverState *bs)\n\n{\n\n BdrvChild *c;\n\n\n\n QLIST_FOREACH(c, &bs->parents, next_parent) {\n\n if (c->role->drained_end) {\n\n c->role->drained_end(c);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 22737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int inet_connect_opts(QemuOpts *opts, bool block, bool *in_progress,\n\n Error **errp)\n\n{\n\n struct addrinfo *res, *e;\n\n int sock = -1;\n\n\n\n res = inet_parse_connect_opts(opts, errp);\n\n if (!res) {\n\n return -1;\n\n }\n\n\n\n if (in_progress) {\n\n *in_progress = false;\n\n }\n\n\n\n for (e = res; e != NULL; e = e->ai_next) {\n\n sock = inet_connect_addr(e, block, in_progress);\n\n if (sock >= 0) {\n\n break;\n\n }\n\n }\n\n if (sock < 0) {\n\n error_set(errp, QERR_SOCKET_CONNECT_FAILED);\n\n }\n\n freeaddrinfo(res);\n\n return sock;\n\n}\n", + "output": "1", + "index": 12060 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QIOChannelSocket *nbd_establish_connection(SocketAddressFlat *saddr_flat,\n\n Error **errp)\n\n{\n\n SocketAddress *saddr = socket_address_crumple(saddr_flat);\n\n QIOChannelSocket *sioc;\n\n Error *local_err = NULL;\n\n\n\n sioc = qio_channel_socket_new();\n\n qio_channel_set_name(QIO_CHANNEL(sioc), \"nbd-client\");\n\n\n\n qio_channel_socket_connect_sync(sioc,\n\n saddr,\n\n &local_err);\n\n qapi_free_SocketAddress(saddr);\n\n if (local_err) {\n\n object_unref(OBJECT(sioc));\n\n error_propagate(errp, local_err);\n\n return NULL;\n\n }\n\n\n\n qio_channel_set_delay(QIO_CHANNEL(sioc), false);\n\n\n\n return sioc;\n\n}\n", + "output": "0", + "index": 17250 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dummy_signal(int sig)\n\n{\n\n}\n", + "output": "1", + "index": 16193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist)\n\n{\n\n AHCICmdHdr *cmd = ad->cur_cmd;\n\n uint32_t opts = le32_to_cpu(cmd->opts);\n\n uint64_t prdt_addr = le64_to_cpu(cmd->tbl_addr) + 0x80;\n\n int sglist_alloc_hint = opts >> AHCI_CMD_HDR_PRDT_LEN;\n\n dma_addr_t prdt_len = (sglist_alloc_hint * sizeof(AHCI_SG));\n\n dma_addr_t real_prdt_len = prdt_len;\n\n uint8_t *prdt;\n\n int i;\n\n int r = 0;\n\n\n\n if (!sglist_alloc_hint) {\n\n DPRINTF(ad->port_no, \"no sg list given by guest: 0x%08x\\n\", opts);\n\n return -1;\n\n }\n\n\n\n /* map PRDT */\n\n if (!(prdt = dma_memory_map(ad->hba->dma, prdt_addr, &prdt_len,\n\n DMA_DIRECTION_TO_DEVICE))){\n\n DPRINTF(ad->port_no, \"map failed\\n\");\n\n return -1;\n\n }\n\n\n\n if (prdt_len < real_prdt_len) {\n\n DPRINTF(ad->port_no, \"mapped less than expected\\n\");\n\n r = -1;\n\n goto out;\n\n }\n\n\n\n /* Get entries in the PRDT, init a qemu sglist accordingly */\n\n if (sglist_alloc_hint > 0) {\n\n AHCI_SG *tbl = (AHCI_SG *)prdt;\n\n\n\n qemu_sglist_init(sglist, sglist_alloc_hint, ad->hba->dma);\n\n for (i = 0; i < sglist_alloc_hint; i++) {\n\n /* flags_size is zero-based */\n\n qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),\n\n le32_to_cpu(tbl[i].flags_size) + 1);\n\n }\n\n }\n\n\n\nout:\n\n dma_memory_unmap(ad->hba->dma, prdt, prdt_len,\n\n DMA_DIRECTION_TO_DEVICE, prdt_len);\n\n return r;\n\n}\n", + "output": "1", + "index": 8541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void arm_sysctl_init(uint32_t base, uint32_t sys_id)\n\n{\n\n arm_sysctl_state *s;\n\n int iomemtype;\n\n\n\n s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));\n\n if (!s)\n\n return;\n\n s->base = base;\n\n s->sys_id = sys_id;\n\n iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,\n\n arm_sysctl_writefn, s);\n\n cpu_register_physical_memory(base, 0x00000fff, iomemtype);\n\n /* ??? Save/restore. */\n\n}\n", + "output": "1", + "index": 24577 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int float32_lt_quiet( float32 a, float32 b STATUS_PARAM )\n\n{\n\n flag aSign, bSign;\n\n\n\n if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )\n\n || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )\n\n ) {\n\n if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n }\n\n return 0;\n\n }\n\n aSign = extractFloat32Sign( a );\n\n bSign = extractFloat32Sign( b );\n\n if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );\n\n return ( a != b ) && ( aSign ^ ( a < b ) );\n\n\n\n}\n", + "output": "0", + "index": 14079 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,\n\n uint32_t index, int reg)\n\n{\n\n struct kvm_cpuid2 *cpuid;\n\n int i, max;\n\n uint32_t ret = 0;\n\n uint32_t cpuid_1_edx;\n\n int has_kvm_features = 0;\n\n\n\n max = 1;\n\n while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {\n\n max *= 2;\n\n }\n\n\n\n for (i = 0; i < cpuid->nent; ++i) {\n\n if (cpuid->entries[i].function == function &&\n\n cpuid->entries[i].index == index) {\n\n if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {\n\n has_kvm_features = 1;\n\n }\n\n switch (reg) {\n\n case R_EAX:\n\n ret = cpuid->entries[i].eax;\n\n break;\n\n case R_EBX:\n\n ret = cpuid->entries[i].ebx;\n\n break;\n\n case R_ECX:\n\n ret = cpuid->entries[i].ecx;\n\n break;\n\n case R_EDX:\n\n ret = cpuid->entries[i].edx;\n\n switch (function) {\n\n case 1:\n\n /* KVM before 2.6.30 misreports the following features */\n\n ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;\n\n break;\n\n case 0x80000001:\n\n /* On Intel, kvm returns cpuid according to the Intel spec,\n\n * so add missing bits according to the AMD spec:\n\n */\n\n cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);\n\n ret |= cpuid_1_edx & 0x183f7ff;\n\n break;\n\n }\n\n break;\n\n }\n\n }\n\n }\n\n\n\n qemu_free(cpuid);\n\n\n\n /* fallback for older kernels */\n\n if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {\n\n ret = get_para_features(env);\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 4455 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void balloon_stats_poll_cb(void *opaque)\n\n{\n\n VirtIOBalloon *s = opaque;\n\n VirtIODevice *vdev = VIRTIO_DEVICE(s);\n\n\n\n if (!balloon_stats_supported(s)) {\n\n /* re-schedule */\n\n balloon_stats_change_timer(s, s->stats_poll_interval);\n\n return;\n\n }\n\n\n\n virtqueue_push(s->svq, s->stats_vq_elem, s->stats_vq_offset);\n\n virtio_notify(vdev, s->svq);\n\n g_free(s->stats_vq_elem);\n\n s->stats_vq_elem = NULL;\n\n}\n", + "output": "1", + "index": 5627 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ram_addr_t qemu_ram_addr_from_host(void *ptr)\n\n{\n\n RAMBlock *prev;\n\n RAMBlock **prevp;\n\n RAMBlock *block;\n\n uint8_t *host = ptr;\n\n\n\n#ifdef CONFIG_KQEMU\n\n if (kqemu_phys_ram_base) {\n\n return host - kqemu_phys_ram_base;\n\n }\n\n#endif\n\n\n\n prev = NULL;\n\n prevp = &ram_blocks;\n\n block = ram_blocks;\n\n while (block && (block->host > host\n\n || block->host + block->length <= host)) {\n\n if (prev)\n\n prevp = &prev->next;\n\n prev = block;\n\n block = block->next;\n\n }\n\n if (!block) {\n\n fprintf(stderr, \"Bad ram pointer %p\\n\", ptr);\n\n abort();\n\n }\n\n return block->offset + (host - block->host);\n\n}\n", + "output": "0", + "index": 9389 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "RGB_FUNCTIONS(rgba32)\n\n\n\n#undef RGB_IN\n\n#undef RGB_OUT\n\n#undef BPP\n\n\n\n\n\nstatic void rgb24_to_rgb565(AVPicture *dst, AVPicture *src,\n\n int width, int height)\n\n{\n\n const unsigned char *p;\n\n unsigned char *q;\n\n int r, g, b, dst_wrap, src_wrap;\n\n int x, y;\n\n\n\n p = src->data[0];\n\n src_wrap = src->linesize[0] - 3 * width;\n\n\n\n q = dst->data[0];\n\n dst_wrap = dst->linesize[0] - 2 * width;\n\n\n\n for(y=0;y> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\n\n q += 2;\n\n p += 3;\n\n }\n\n p += src_wrap;\n\n q += dst_wrap;\n\n }\n\n}\n", + "output": "0", + "index": 347 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qdev_print_devinfo(DeviceClass *dc)\n\n{\n\n error_printf(\"name \\\"%s\\\"\", object_class_get_name(OBJECT_CLASS(dc)));\n\n if (dc->bus_type) {\n\n error_printf(\", bus %s\", dc->bus_type);\n\n }\n\n if (qdev_class_has_alias(dc)) {\n\n error_printf(\", alias \\\"%s\\\"\", qdev_class_get_alias(dc));\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": "1", + "index": 4818 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aiff_probe(AVProbeData *p)\n\n{\n\n /* check file header */\n\n if (p->buf_size < 16)\n\n return 0;\n\n if (p->buf[0] == 'F' && p->buf[1] == 'O' &&\n\n p->buf[2] == 'R' && p->buf[3] == 'M' &&\n\n p->buf[8] == 'A' && p->buf[9] == 'I' &&\n\n p->buf[10] == 'F' && (p->buf[11] == 'F' || p->buf[11] == 'C'))\n\n return AVPROBE_SCORE_MAX;\n\n else\n\n return 0;\n\n}\n", + "output": "0", + "index": 19655 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static char *SocketAddress_to_str(const char *prefix, SocketAddress *addr,\n\n bool is_listen, bool is_telnet)\n\n{\n\n switch (addr->type) {\n\n case SOCKET_ADDRESS_KIND_INET:\n\n return g_strdup_printf(\"%s%s:%s:%s%s\", prefix,\n\n is_telnet ? \"telnet\" : \"tcp\", addr->u.inet->host,\n\n addr->u.inet->port, is_listen ? \",server\" : \"\");\n\n break;\n\n case SOCKET_ADDRESS_KIND_UNIX:\n\n return g_strdup_printf(\"%sunix:%s%s\", prefix,\n\n addr->u.q_unix->path,\n\n is_listen ? \",server\" : \"\");\n\n break;\n\n case SOCKET_ADDRESS_KIND_FD:\n\n return g_strdup_printf(\"%sfd:%s%s\", prefix, addr->u.fd->str,\n\n is_listen ? \",server\" : \"\");\n\n break;\n\n default:\n\n abort();\n\n }\n\n}\n", + "output": "0", + "index": 15433 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void padzero(unsigned long elf_bss)\n\n{\n\n unsigned long nbyte;\n\n char * fpnt;\n\n\n\n nbyte = elf_bss & (host_page_size-1);\t/* was TARGET_PAGE_SIZE - JRP */\n\n if (nbyte) {\n\n\t nbyte = host_page_size - nbyte;\n\n\t fpnt = (char *) elf_bss;\n\n\t do {\n\n\t\t*fpnt++ = 0;\n\n\t } while (--nbyte);\n\n }\n\n}\n", + "output": "0", + "index": 12851 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t mv88w8618_eth_read(void *opaque, target_phys_addr_t offset,\n\n unsigned size)\n\n{\n\n mv88w8618_eth_state *s = opaque;\n\n\n\n switch (offset) {\n\n case MP_ETH_SMIR:\n\n if (s->smir & MP_ETH_SMIR_OPCODE) {\n\n switch (s->smir & MP_ETH_SMIR_ADDR) {\n\n case MP_ETH_PHY1_BMSR:\n\n return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |\n\n MP_ETH_SMIR_RDVALID;\n\n case MP_ETH_PHY1_PHYSID1:\n\n return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;\n\n case MP_ETH_PHY1_PHYSID2:\n\n return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;\n\n default:\n\n return MP_ETH_SMIR_RDVALID;\n\n }\n\n }\n\n return 0;\n\n\n\n case MP_ETH_ICR:\n\n return s->icr;\n\n\n\n case MP_ETH_IMR:\n\n return s->imr;\n\n\n\n case MP_ETH_FRDP0 ... MP_ETH_FRDP3:\n\n return s->frx_queue[(offset - MP_ETH_FRDP0)/4];\n\n\n\n case MP_ETH_CRDP0 ... MP_ETH_CRDP3:\n\n return s->rx_queue[(offset - MP_ETH_CRDP0)/4];\n\n\n\n case MP_ETH_CTDP0 ... MP_ETH_CTDP3:\n\n return s->tx_queue[(offset - MP_ETH_CTDP0)/4];\n\n\n\n default:\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 21318 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void load_module(const char *filename)\n\n{\n\n void *dll;\n\n void (*init_func)(void);\n\n dll = dlopen(filename, RTLD_NOW);\n\n if (!dll) {\n\n fprintf(stderr, \"Could not load module '%s' - %s\\n\",\n\n filename, dlerror());\n\n\n }\n\n\n\n init_func = dlsym(dll, \"ffserver_module_init\");\n\n if (!init_func) {\n\n fprintf(stderr,\n\n \"%s: init function 'ffserver_module_init()' not found\\n\",\n\n filename);\n\n dlclose(dll);\n\n\n }\n\n\n\n init_func();\n\n}", + "output": "1", + "index": 22576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs)\n\n{\n\n struct dirent *entry;\n\n\n\nagain:\n\n entry = readdir(fs->dir.stream);\n\n if (!entry) {\n\n return NULL;\n\n }\n\n\n\n if (ctx->export_flags & V9FS_SM_MAPPED) {\n\n entry->d_type = DT_UNKNOWN;\n\n } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n\n if (local_is_mapped_file_metadata(ctx, entry->d_name)) {\n\n /* skip the meta data directory */\n\n goto again;\n\n }\n\n entry->d_type = DT_UNKNOWN;\n\n }\n\n\n\n return entry;\n\n}\n", + "output": "0", + "index": 24884 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unassigned_mem_write(void *opaque, hwaddr addr,\n\n uint64_t val, unsigned size)\n\n{\n\n#ifdef DEBUG_UNASSIGNED\n\n printf(\"Unassigned mem write \" TARGET_FMT_plx \" = 0x%\"PRIx64\"\\n\", addr, val);\n\n#endif\n\n#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)\n\n cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);\n\n#endif\n\n}\n", + "output": "0", + "index": 21099 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n FFMContext *ffm = s->priv_data;\n\n AVStream *st = s->streams[pkt->stream_index];\n\n int64_t pts;\n\n uint8_t header[FRAME_HEADER_SIZE];\n\n\n\n pts = ffm->start_time + pkt->pts;\n\n /* packet size & key_frame */\n\n header[0] = pkt->stream_index;\n\n header[1] = 0;\n\n if (pkt->flags & PKT_FLAG_KEY)\n\n header[1] |= FLAG_KEY_FRAME;\n\n AV_WB24(header+2, pkt->size);\n\n AV_WB24(header+5, pkt->duration);\n\n ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);\n\n ffm_write_data(s, pkt->data, pkt->size, pts, 0);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)\n\n{\n\n struct iovec *iov = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];\n\n uint32_t csum_cntr;\n\n uint16_t csum = 0;\n\n /* num of iovec without vhdr */\n\n uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;\n\n uint16_t csl;\n\n struct ip_header *iphdr;\n\n size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;\n\n\n\n /* Put zero to checksum field */\n\n iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);\n\n\n\n /* Calculate L4 TCP/UDP checksum */\n\n csl = pkt->payload_len;\n\n\n\n /* data checksum */\n\n csum_cntr =\n\n net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl);\n\n /* add pseudo header to csum */\n\n iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;\n\n csum_cntr += eth_calc_pseudo_hdr_csum(iphdr, csl);\n\n\n\n /* Put the checksum obtained into the packet */\n\n csum = cpu_to_be16(net_checksum_finish(csum_cntr));\n\n iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);\n\n}\n", + "output": "0", + "index": 5380 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_tw (int flags)\n\n{\n\n if (!likely(!(((int32_t)T0 < (int32_t)T1 && (flags & 0x10)) ||\n\n ((int32_t)T0 > (int32_t)T1 && (flags & 0x08)) ||\n\n ((int32_t)T0 == (int32_t)T1 && (flags & 0x04)) ||\n\n ((uint32_t)T0 < (uint32_t)T1 && (flags & 0x02)) ||\n\n ((uint32_t)T0 > (uint32_t)T1 && (flags & 0x01))))) {\n\n do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);\n\n }\n\n}\n", + "output": "0", + "index": 18675 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int fp_reg_hi_offset(int regno)\n\n{\n\n return offsetof(CPUARMState, vfp.regs[regno * 2 + 1]);\n\n}\n", + "output": "0", + "index": 25570 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,\n\n Error **errp)\n\n{\n\n QObjectInputVisitor *qiv = to_qiv(v);\n\n QObject *qobj = qobject_input_get_object(qiv, name, true, errp);\n\n QBool *qbool;\n\n\n\n if (!qobj) {\n\n return;\n\n }\n\n qbool = qobject_to_qbool(qobj);\n\n if (!qbool) {\n\n error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",\n\n \"boolean\");\n\n return;\n\n }\n\n\n\n *obj = qbool_get_bool(qbool);\n\n}\n", + "output": "1", + "index": 18329 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)\n\n{\n\n if(min_ts > ts || max_ts < ts)\n\n return -1;\n\n\n\n if (s->iformat->read_seek2) {\n\n int ret;\n\n ff_read_frame_flush(s);\n\n\n\n if (stream_index == -1 && s->nb_streams == 1) {\n\n AVRational time_base = s->streams[0]->time_base;\n\n ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);\n\n min_ts = av_rescale_rnd(min_ts, time_base.den,\n\n time_base.num * (int64_t)AV_TIME_BASE,\n\n AV_ROUND_UP);\n\n max_ts = av_rescale_rnd(max_ts, time_base.den,\n\n time_base.num * (int64_t)AV_TIME_BASE,\n\n AV_ROUND_DOWN);\n\n }\n\n\n\n ret = s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);\n\n\n\n if (ret >= 0)\n\n avformat_queue_attached_pictures(s);\n\n return ret;\n\n }\n\n\n\n if(s->iformat->read_timestamp){\n\n //try to seek via read_timestamp()\n\n }\n\n\n\n //Fallback to old API if new is not implemented but old is\n\n //Note the old has somewhat different semantics\n\n if (s->iformat->read_seek || 1) {\n\n int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);\n\n int ret = av_seek_frame(s, stream_index, ts, flags | dir);\n\n if (ret<0 && ts != min_ts && max_ts != ts) {\n\n ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);\n\n if (ret >= 0)\n\n ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));\n\n }\n\n return ret;\n\n }\n\n\n\n // try some generic seek like seek_frame_generic() but with new ts semantics\n\n}\n", + "output": "1", + "index": 2417 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)\n\n{\n\n PCIBonitoState *s = opaque;\n\n PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);\n\n uint32_t cfgaddr;\n\n uint32_t idsel;\n\n uint32_t devno;\n\n uint32_t funno;\n\n uint32_t regno;\n\n uint32_t pciaddr;\n\n\n\n /* support type0 pci config */\n\n if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {\n\n return 0xffffffff;\n\n }\n\n\n\n cfgaddr = addr & 0xffff;\n\n cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;\n\n\n\n idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;\n\n devno = ffs(idsel) - 1;\n\n funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;\n\n regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;\n\n\n\n if (idsel == 0) {\n\n fprintf(stderr, \"error in bonito pci config address \" TARGET_FMT_plx\n\n \",pcimap_cfg=%x\\n\", addr, s->regs[BONITO_PCIMAP_CFG]);\n\n exit(1);\n\n }\n\n pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);\n\n DPRINTF(\"cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\\n\",\n\n cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);\n\n\n\n return pciaddr;\n\n}\n", + "output": "0", + "index": 27044 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_i2c_slave_class_init(ObjectClass *klass, void *data)\n\n{\n\n I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);\n\n\n\n k->init = pxa2xx_i2c_slave_init;\n\n k->event = pxa2xx_i2c_event;\n\n k->recv = pxa2xx_i2c_rx;\n\n k->send = pxa2xx_i2c_tx;\n\n}\n", + "output": "0", + "index": 18127 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_net_stop_one(struct vhost_net *net,\n\n VirtIODevice *dev)\n\n{\n\n struct vhost_vring_file file = { .fd = -1 };\n\n\n\n if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {\n\n for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {\n\n const VhostOps *vhost_ops = net->dev.vhost_ops;\n\n int r = vhost_ops->vhost_net_set_backend(&net->dev, &file);\n\n assert(r >= 0);\n\n }\n\n }\n\n if (net->nc->info->poll) {\n\n net->nc->info->poll(net->nc, true);\n\n }\n\n vhost_dev_stop(&net->dev, dev);\n\n vhost_dev_disable_notifiers(&net->dev, dev);\n\n}\n", + "output": "1", + "index": 12577 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxb_host_class_init(ObjectClass *class, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(class);\n\n SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(class);\n\n PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class);\n\n\n\n dc->fw_name = \"pci\";\n\n\n\n sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;\n\n hc->root_bus_path = pxb_host_root_bus_path;\n\n}", + "output": "1", + "index": 7593 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean qio_channel_websock_handshake_io(QIOChannel *ioc,\n\n GIOCondition condition,\n\n gpointer user_data)\n\n{\n\n QIOTask *task = user_data;\n\n QIOChannelWebsock *wioc = QIO_CHANNEL_WEBSOCK(\n\n qio_task_get_source(task));\n\n Error *err = NULL;\n\n int ret;\n\n\n\n ret = qio_channel_websock_handshake_read(wioc, &err);\n\n if (ret < 0) {\n\n trace_qio_channel_websock_handshake_fail(ioc);\n\n qio_task_abort(task, err);\n\n error_free(err);\n\n return FALSE;\n\n }\n\n if (ret == 0) {\n\n trace_qio_channel_websock_handshake_pending(ioc, G_IO_IN);\n\n /* need more data still */\n\n return TRUE;\n\n }\n\n\n\n object_ref(OBJECT(task));\n\n trace_qio_channel_websock_handshake_reply(ioc);\n\n qio_channel_add_watch(\n\n wioc->master,\n\n G_IO_OUT,\n\n qio_channel_websock_handshake_send,\n\n task,\n\n (GDestroyNotify)object_unref);\n\n return FALSE;\n\n}\n", + "output": "1", + "index": 5342 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cmd_read_cd(IDEState *s, uint8_t* buf)\n\n{\n\n int nb_sectors, lba, transfer_request;\n\n\n\n nb_sectors = (buf[6] << 16) | (buf[7] << 8) | buf[8];\n\n lba = ube32_to_cpu(buf + 2);\n\n\n\n if (nb_sectors == 0) {\n\n ide_atapi_cmd_ok(s);\n\n return;\n\n }\n\n\n\n transfer_request = buf[9];\n\n switch(transfer_request & 0xf8) {\n\n case 0x00:\n\n /* nothing */\n\n ide_atapi_cmd_ok(s);\n\n break;\n\n case 0x10:\n\n /* normal read */\n\n ide_atapi_cmd_read(s, lba, nb_sectors, 2048);\n\n break;\n\n case 0xf8:\n\n /* read all data */\n\n ide_atapi_cmd_read(s, lba, nb_sectors, 2352);\n\n break;\n\n default:\n\n ide_atapi_cmd_error(s, ILLEGAL_REQUEST,\n\n ASC_INV_FIELD_IN_CMD_PACKET);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 4053 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ExitStatus op_ex(DisasContext *s, DisasOps *o)\n\n{\n\n /* ??? Perhaps a better way to implement EXECUTE is to set a bit in\n\n tb->flags, (ab)use the tb->cs_base field as the address of\n\n the template in memory, and grab 8 bits of tb->flags/cflags for\n\n the contents of the register. We would then recognize all this\n\n in gen_intermediate_code_internal, generating code for exactly\n\n one instruction. This new TB then gets executed normally.\n\n\n\n On the other hand, this seems to be mostly used for modifying\n\n MVC inside of memcpy, which needs a helper call anyway. So\n\n perhaps this doesn't bear thinking about any further. */\n\n\n\n TCGv_i64 tmp;\n\n\n\n update_psw_addr(s);\n\n update_cc_op(s);\n\n\n\n tmp = tcg_const_i64(s->next_pc);\n\n gen_helper_ex(cc_op, cpu_env, cc_op, o->in1, o->in2, tmp);\n\n tcg_temp_free_i64(tmp);\n\n\n\n set_cc_static(s);\n\n return NO_EXIT;\n\n}\n", + "output": "1", + "index": 4365 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ogg_write_pages(AVFormatContext *s, int flush)\n\n{\n\n OGGContext *ogg = s->priv_data;\n\n OGGPageList *next, *p;\n\n\n\n if (!ogg->page_list)\n\n return;\n\n\n\n for (p = ogg->page_list; p; ) {\n\n OGGStreamContext *oggstream =\n\n s->streams[p->page.stream_index]->priv_data;\n\n if (oggstream->page_count < 2 && !flush)\n\n break;\n\n ogg_write_page(s, &p->page,\n\n flush && oggstream->page_count == 1 ? 4 : 0); // eos\n\n next = p->next;\n\n av_freep(&p);\n\n p = next;\n\n }\n\n ogg->page_list = p;\n\n}\n", + "output": "1", + "index": 2025 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cadence_ttc_write(void *opaque, target_phys_addr_t offset,\n\n uint64_t value, unsigned size)\n\n{\n\n CadenceTimerState *s = cadence_timer_from_addr(opaque, offset);\n\n\n\n DB_PRINT(\"addr: %08x data %08x\\n\", offset, (unsigned)value);\n\n\n\n cadence_timer_sync(s);\n\n\n\n switch (offset) {\n\n case 0x00: /* clock control */\n\n case 0x04:\n\n case 0x08:\n\n s->reg_clock = value & 0x3F;\n\n break;\n\n\n\n case 0x0c: /* counter control */\n\n case 0x10:\n\n case 0x14:\n\n if (value & COUNTER_CTRL_RST) {\n\n s->reg_value = 0;\n\n }\n\n s->reg_count = value & 0x3f & ~COUNTER_CTRL_RST;\n\n break;\n\n\n\n case 0x24: /* interval register */\n\n case 0x28:\n\n case 0x2c:\n\n s->reg_interval = value & 0xffff;\n\n break;\n\n\n\n case 0x30: /* match register */\n\n case 0x34:\n\n case 0x38:\n\n s->reg_match[0] = value & 0xffff;\n\n\n\n case 0x3c: /* match register */\n\n case 0x40:\n\n case 0x44:\n\n s->reg_match[1] = value & 0xffff;\n\n\n\n case 0x48: /* match register */\n\n case 0x4c:\n\n case 0x50:\n\n s->reg_match[2] = value & 0xffff;\n\n break;\n\n\n\n case 0x54: /* interrupt register */\n\n case 0x58:\n\n case 0x5c:\n\n break;\n\n\n\n case 0x60: /* interrupt enable */\n\n case 0x64:\n\n case 0x68:\n\n s->reg_intr_en = value & 0x3f;\n\n break;\n\n\n\n case 0x6c: /* event control */\n\n case 0x70:\n\n case 0x74:\n\n s->reg_event_ctrl = value & 0x07;\n\n break;\n\n\n\n default:\n\n return;\n\n }\n\n\n\n cadence_timer_run(s);\n\n cadence_timer_update(s);\n\n}\n", + "output": "0", + "index": 5090 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QError *qerror_from_info(const char *file, int linenr, const char *func,\n\n const char *fmt, va_list *va)\n\n{\n\n QError *qerr;\n\n\n\n qerr = qerror_new();\n\n loc_save(&qerr->loc);\n\n qerr->linenr = linenr;\n\n qerr->file = file;\n\n qerr->func = func;\n\n\n\n if (!fmt) {\n\n qerror_abort(qerr, \"QDict not specified\");\n\n }\n\n\n\n qerror_set_data(qerr, fmt, va);\n\n qerror_set_desc(qerr, fmt);\n\n\n\n return qerr;\n\n}\n", + "output": "0", + "index": 8282 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tosa_dac_event(I2CSlave *i2c, enum i2c_event event)\n\n{\n\n TosaDACState *s = TOSA_DAC(i2c);\n\n\n\n s->len = 0;\n\n switch (event) {\n\n case I2C_START_SEND:\n\n break;\n\n case I2C_START_RECV:\n\n printf(\"%s: recv not supported!!!\\n\", __FUNCTION__);\n\n break;\n\n case I2C_FINISH:\n\n#ifdef VERBOSE\n\n if (s->len < 2)\n\n printf(\"%s: message too short (%i bytes)\\n\", __FUNCTION__, s->len);\n\n if (s->len > 2)\n\n printf(\"%s: message too long\\n\", __FUNCTION__);\n\n#endif\n\n break;\n\n default:\n\n break;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 4936 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int output_data_internal(MLPDecodeContext *m, unsigned int substr,\n\n uint8_t *data, unsigned int *data_size, int is32)\n\n{\n\n SubStream *s = &m->substream[substr];\n\n unsigned int i, out_ch = 0;\n\n int32_t *data_32 = (int32_t*) data;\n\n int16_t *data_16 = (int16_t*) data;\n\n\n\n if (*data_size < (s->max_channel + 1) * s->blockpos * (is32 ? 4 : 2))\n\n return -1;\n\n\n\n for (i = 0; i < s->blockpos; i++) {\n\n for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {\n\n int mat_ch = s->ch_assign[out_ch];\n\n int32_t sample = m->sample_buffer[i][mat_ch]\n\n << s->output_shift[mat_ch];\n\n s->lossless_check_data ^= (sample & 0xffffff) << mat_ch;\n\n if (is32) *data_32++ = sample << 8;\n\n else *data_16++ = sample >> 8;\n\n }\n\n }\n\n\n\n *data_size = i * out_ch * (is32 ? 4 : 2);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13081 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void io_mem_init(void)\n\n{\n\n cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read, unassigned_mem_write, NULL);\n\n cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);\n\n cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, notdirty_mem_write, NULL);\n\n io_mem_nb = 5;\n\n\n\n\n\n\n\n /* alloc dirty bits array */\n\n phys_ram_dirty = qemu_vmalloc(phys_ram_size >> TARGET_PAGE_BITS);\n\n memset(phys_ram_dirty, 0xff, phys_ram_size >> TARGET_PAGE_BITS);\n\n}", + "output": "1", + "index": 3994 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void co_test_cb(void *opaque)\n\n{\n\n WorkerTestData *data = opaque;\n\n\n\n active = 1;\n\n data->n = 0;\n\n data->ret = -EINPROGRESS;\n\n thread_pool_submit_co(worker_cb, data);\n\n\n\n /* The test continues in test_submit_co, after qemu_coroutine_enter... */\n\n\n\n g_assert_cmpint(data->n, ==, 1);\n\n data->ret = 0;\n\n active--;\n\n\n\n /* The test continues in test_submit_co, after qemu_aio_wait_all... */\n\n}\n", + "output": "0", + "index": 7083 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int compare_floats(const float *a, const float *b, int len,\n\n float max_diff)\n\n{\n\n int i;\n\n for (i = 0; i < len; i++) {\n\n if (fabsf(a[i] - b[i]) > max_diff) {\n\n av_log(NULL, AV_LOG_ERROR, \"%d: %- .12f - %- .12f = % .12g\\n\",\n\n i, a[i], b[i], a[i] - b[i]);\n\n return -1;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 18630 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mpeg_decode_sequence_extension(MpegEncContext *s)\n\n{\n\n int horiz_size_ext, vert_size_ext;\n\n int bit_rate_ext, vbv_buf_ext, low_delay;\n\n int frame_rate_ext_n, frame_rate_ext_d;\n\n\n\n skip_bits(&s->gb, 8); /* profil and level */\n\n skip_bits(&s->gb, 1); /* progressive_sequence */\n\n skip_bits(&s->gb, 2); /* chroma_format */\n\n horiz_size_ext = get_bits(&s->gb, 2);\n\n vert_size_ext = get_bits(&s->gb, 2);\n\n s->width |= (horiz_size_ext << 12);\n\n s->height |= (vert_size_ext << 12);\n\n bit_rate_ext = get_bits(&s->gb, 12); /* XXX: handle it */\n\n s->bit_rate = ((s->bit_rate / 400) | (bit_rate_ext << 12)) * 400;\n\n skip_bits1(&s->gb); /* marker */\n\n vbv_buf_ext = get_bits(&s->gb, 8);\n\n low_delay = get_bits1(&s->gb);\n\n frame_rate_ext_n = get_bits(&s->gb, 2);\n\n frame_rate_ext_d = get_bits(&s->gb, 5);\n\n if (frame_rate_ext_d >= 1)\n\n s->frame_rate = (s->frame_rate * frame_rate_ext_n) / frame_rate_ext_d;\n\n dprintf(\"sequence extension\\n\");\n\n s->mpeg2 = 1;\n\n}\n", + "output": "1", + "index": 2256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_client_set_memory(struct CPUPhysMemoryClient *client,\n\n target_phys_addr_t start_addr,\n\n ram_addr_t size, ram_addr_t phys_offset,\n\n bool log_dirty)\n\n{\n\n kvm_set_phys_mem(start_addr, size, phys_offset, log_dirty);\n\n}\n", + "output": "1", + "index": 16426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void framebuffer_update_request(VncState *vs, int incremental,\n\n\t\t\t\t int x_position, int y_position,\n\n\t\t\t\t int w, int h)\n\n{\n\n if (x_position > ds_get_width(vs->ds))\n\n x_position = ds_get_width(vs->ds);\n\n if (y_position > ds_get_height(vs->ds))\n\n y_position = ds_get_height(vs->ds);\n\n if (x_position + w >= ds_get_width(vs->ds))\n\n w = ds_get_width(vs->ds) - x_position;\n\n if (y_position + h >= ds_get_height(vs->ds))\n\n h = ds_get_height(vs->ds) - y_position;\n\n\n\n int i;\n\n vs->need_update = 1;\n\n if (!incremental) {\n\n\tchar *old_row = vs->old_data + y_position * ds_get_linesize(vs->ds);\n\n\n\n\tfor (i = 0; i < h; i++) {\n\n vnc_set_bits(vs->dirty_row[y_position + i],\n\n (ds_get_width(vs->ds) / 16), VNC_DIRTY_WORDS);\n\n\t memset(old_row, 42, ds_get_width(vs->ds) * vs->depth);\n\n\t old_row += ds_get_linesize(vs->ds);\n\n\t}\n\n }\n\n}\n", + "output": "1", + "index": 12494 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sdl_mouse_mode_change(Notifier *notify, void *data)\n\n{\n\n if (kbd_mouse_is_absolute()) {\n\n if (!absolute_enabled) {\n\n sdl_hide_cursor();\n\n if (gui_grab) {\n\n sdl_grab_end();\n\n }\n\n absolute_enabled = 1;\n\n }\n\n } else if (absolute_enabled) {\n\n\tsdl_show_cursor();\n\n\tabsolute_enabled = 0;\n\n }\n\n}\n", + "output": "0", + "index": 22191 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_alloc_packet(AVPacket *avpkt, int size)\n\n{\n\n if (size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)\n\n return AVERROR(EINVAL);\n\n\n\n if (avpkt->data) {\n\n void *destruct = avpkt->destruct;\n\n\n\n if (avpkt->size < size)\n\n return AVERROR(EINVAL);\n\n\n\n av_init_packet(avpkt);\n\n avpkt->destruct = destruct;\n\n avpkt->size = size;\n\n return 0;\n\n } else {\n\n return av_new_packet(avpkt, size);\n\n }\n\n}\n", + "output": "0", + "index": 6911 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void emulated_push_error(EmulatedState *card, uint64_t code)\n\n{\n\n EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent));\n\n\n\n assert(event);\n\n event->p.error.type = EMUL_ERROR;\n\n event->p.error.code = code;\n\n emulated_push_event(card, event);\n\n}\n", + "output": "1", + "index": 22 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_fcmpu(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 && (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 }\n\n}\n", + "output": "0", + "index": 19586 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aea_read_header(AVFormatContext *s)\n\n{\n\n AVStream *st = avformat_new_stream(s, NULL);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n /* Parse the amount of channels and skip to pos 2048(0x800) */\n\n avio_skip(s->pb, 264);\n\n st->codec->channels = avio_r8(s->pb);\n\n avio_skip(s->pb, 1783);\n\n\n\n\n\n st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n\n st->codec->codec_id = AV_CODEC_ID_ATRAC1;\n\n st->codec->sample_rate = 44100;\n\n st->codec->bit_rate = 292000;\n\n\n\n if (st->codec->channels != 1 && st->codec->channels != 2) {\n\n av_log(s,AV_LOG_ERROR,\"Channels %d not supported!\\n\",st->codec->channels);\n\n return -1;\n\n }\n\n\n\n st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;\n\n\n\n st->codec->block_align = AT1_SU_SIZE * st->codec->channels;\n\n return 0;\n\n}\n", + "output": "0", + "index": 25915 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int init(AVCodecParserContext *s)\n\n{\n\n H264Context *h = s->priv_data;\n\n h->thread_context[0] = h;\n\n\n return 0;\n\n}", + "output": "1", + "index": 5131 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check_strtox_error(const char *p, char *endptr, const char **next,\n\n int err)\n\n{\n\n /* If no conversion was performed, prefer BSD behavior over glibc\n\n * behavior.\n\n */\n\n if (err == 0 && endptr == p) {\n\n err = EINVAL;\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": 21642 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int find_pte (CPUState *env, mmu_ctx_t *ctx, int h, int rw)\n\n{\n\n#if defined(TARGET_PPC64)\n\n if (env->mmu_model == POWERPC_MMU_64B ||\n\n env->mmu_model == POWERPC_MMU_64BRIDGE)\n\n return find_pte64(ctx, h, rw);\n\n#endif\n\n\n\n return find_pte32(ctx, h, rw);\n\n}\n", + "output": "1", + "index": 1143 + }, + { + "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 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#if defined(DEBUG_SIGNAL)\n\n fprintf(stderr, \"qemu: got signal %d\\n\", sig);\n\n#endif\n\n host_to_target_siginfo_noswap(&tinfo, info);\n\n if (queue_signal(thread_env, sig, &tinfo) == 1) {\n\n /* interrupt the virtual CPU as soon as possible */\n\n cpu_interrupt(thread_env, CPU_INTERRUPT_EXIT);\n\n }\n\n}\n", + "output": "0", + "index": 17071 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t pmac_ide_readl (void *opaque,target_phys_addr_t addr)\n\n{\n\n uint32_t retval;\n\n MACIOIDEState *d = opaque;\n\n\n\n addr = (addr & 0xFFF) >> 4;\n\n if (addr == 0) {\n\n retval = ide_data_readl(&d->bus, 0);\n\n } else {\n\n retval = 0xFFFFFFFF;\n\n }\n\n retval = bswap32(retval);\n\n return retval;\n\n}\n", + "output": "0", + "index": 17243 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void portio_list_init(PortioList *piolist,\n\n const MemoryRegionPortio *callbacks,\n\n void *opaque, const char *name)\n\n{\n\n unsigned n = 0;\n\n\n\n while (callbacks[n].size) {\n\n ++n;\n\n }\n\n\n\n piolist->ports = callbacks;\n\n piolist->nr = 0;\n\n piolist->regions = g_new0(MemoryRegion *, n);\n\n piolist->aliases = g_new0(MemoryRegion *, n);\n\n piolist->address_space = NULL;\n\n piolist->opaque = opaque;\n\n piolist->name = name;\n\n}\n", + "output": "0", + "index": 6199 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xtensa_lx60_init(MachineState *machine)\n\n{\n\n static const LxBoardDesc lx60_board = {\n\n .flash_base = 0xf8000000,\n\n .flash_size = 0x00400000,\n\n .flash_sector_size = 0x10000,\n\n .sram_size = 0x20000,\n\n };\n\n lx_init(&lx60_board, machine);\n\n}\n", + "output": "0", + "index": 6237 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size)\n\n{\n\n int l;\n\n while (size > 0) {\n\n l = IO_BUF_SIZE - f->buf_index;\n\n if (l > size)\n\n l = size;\n\n memcpy(f->buf + f->buf_index, buf, l);\n\n f->buf_index += l;\n\n buf += l;\n\n size -= l;\n\n if (f->buf_index >= IO_BUF_SIZE)\n\n qemu_fflush(f);\n\n }\n\n}\n", + "output": "0", + "index": 5668 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)\n\n{\n\n SaveStateEntry *se;\n\n int ret = 1;\n\n\n\n QTAILQ_FOREACH(se, &savevm_handlers, entry) {\n\n if (se->save_live_state == NULL)\n\n continue;\n\n\n\n /* Section type */\n\n qemu_put_byte(f, QEMU_VM_SECTION_PART);\n\n qemu_put_be32(f, se->section_id);\n\n\n\n ret = se->save_live_state(mon, f, QEMU_VM_SECTION_PART, se->opaque);\n\n if (!ret) {\n\n /* Do not proceed to the next vmstate before this one reported\n\n completion of the current stage. This serializes the migration\n\n and reduces the probability that a faster changing state is\n\n synchronized over and over again. */\n\n break;\n\n }\n\n }\n\n if (ret != 0) {\n\n return ret;\n\n }\n\n ret = qemu_file_get_error(f);\n\n if (ret != 0) {\n\n qemu_savevm_state_cancel(mon, f);\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 14909 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ast_probe(AVProbeData *p)\n\n{\n\n if (AV_RL32(p->buf) == MKTAG('S','T','R','M') &&\n\n AV_RB16(p->buf + 10) &&\n\n AV_RB16(p->buf + 12) &&\n\n AV_RB32(p->buf + 16))\n\n return AVPROBE_SCORE_MAX / 3 * 2;\n\n return 0;\n\n}\n", + "output": "1", + "index": 14145 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CharDriverState *chr_baum_init(void)\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_be_generic_open(chr);\n\n\n\n return chr;\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 NULL;\n\n}\n", + "output": "0", + "index": 14703 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MemTxResult memory_region_dispatch_write(MemoryRegion *mr,\n hwaddr addr,\n uint64_t data,\n unsigned size,\n MemTxAttrs attrs)\n{\n if (!memory_region_access_valid(mr, addr, size, true)) {\n unassigned_mem_write(mr, addr, data, size);\n return MEMTX_DECODE_ERROR;\n adjust_endianness(mr, &data, size);\n if (mr->ops->write) {\n return access_with_adjusted_size(addr, &data, size,\n mr->ops->impl.min_access_size,\n mr->ops->impl.max_access_size,\n memory_region_write_accessor, mr,\n attrs);\n } else if (mr->ops->write_with_attrs) {\n return\n access_with_adjusted_size(addr, &data, size,\n mr->ops->impl.min_access_size,\n mr->ops->impl.max_access_size,\n memory_region_write_with_attrs_accessor,\n mr, attrs);\n } else {\n return access_with_adjusted_size(addr, &data, size, 1, 4,\n memory_region_oldmmio_write_accessor,\n mr, attrs);", + "output": "1", + "index": 4008 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_slbmte(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);\n\n#else\n\n if (unlikely(ctx->pr)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);\n\n return;\n\n }\n\n gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)],\n\n cpu_gpr[rS(ctx->opcode)]);\n\n#endif\n\n}\n", + "output": "1", + "index": 10428 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow_set_key(BlockDriverState *bs, const char *key)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n uint8_t keybuf[16];\n\n int len, i;\n\n Error *err;\n\n\n\n memset(keybuf, 0, 16);\n\n len = strlen(key);\n\n if (len > 16)\n\n len = 16;\n\n /* XXX: we could compress the chars to 7 bits to increase\n\n entropy */\n\n for(i = 0;i < len;i++) {\n\n keybuf[i] = key[i];\n\n }\n\n assert(bs->encrypted);\n\n\n\n qcrypto_cipher_free(s->cipher);\n\n s->cipher = qcrypto_cipher_new(\n\n QCRYPTO_CIPHER_ALG_AES_128,\n\n QCRYPTO_CIPHER_MODE_CBC,\n\n keybuf, G_N_ELEMENTS(keybuf),\n\n &err);\n\n\n\n if (!s->cipher) {\n\n /* XXX would be nice if errors in this method could\n\n * be properly propagate to the caller. Would need\n\n * the bdrv_set_key() API signature to be fixed. */\n\n error_free(err);\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 464 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs,\n\n int64_t sector_num, int nb_sectors, int *num_same)\n\n{\n\n int64_t bitnum = sector_num + sizeof(struct cow_header_v2) * 8;\n\n uint64_t offset = (bitnum / 8) & -BDRV_SECTOR_SIZE;\n\n uint8_t bitmap[BDRV_SECTOR_SIZE];\n\n int ret;\n\n int changed;\n\n\n\n ret = bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap));\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n bitnum &= BITS_PER_BITMAP_SECTOR - 1;\n\n changed = cow_test_bit(bitnum, bitmap);\n\n *num_same = cow_find_streak(bitmap, changed, bitnum, nb_sectors);\n\n return changed;\n\n}\n", + "output": "1", + "index": 8543 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n TInterlaceContext *tinterlace = ctx->priv;\n\n\n\n avfilter_unref_buffer(tinterlace->cur);\n\n tinterlace->cur = tinterlace->next;\n\n tinterlace->next = picref;\n\n\n return 0;\n\n}", + "output": "1", + "index": 5076 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void string_output_append(StringOutputVisitor *sov, int64_t a)\n\n{\n\n Range *r = g_malloc0(sizeof(*r));\n\n r->begin = a;\n\n r->end = a + 1;\n\n sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);\n\n}\n", + "output": "1", + "index": 8834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cmd_seek(IDEState *s, uint8_t* buf)\n\n{\n\n unsigned int lba;\n\n uint64_t total_sectors = s->nb_sectors >> 2;\n\n\n\n if (total_sectors == 0) {\n\n ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);\n\n return;\n\n }\n\n\n\n lba = ube32_to_cpu(buf + 2);\n\n if (lba >= total_sectors) {\n\n ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);\n\n return;\n\n }\n\n\n\n ide_atapi_cmd_ok(s);\n\n}\n", + "output": "0", + "index": 14986 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)\n\n{\n\n VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);\n\n GArray *table_offsets;\n\n unsigned dsdt, rsdt;\n\n GArray *tables_blob = tables->table_data;\n\n\n\n table_offsets = g_array_new(false, true /* clear */,\n\n sizeof(uint32_t));\n\n\n\n bios_linker_loader_alloc(tables->linker,\n\n ACPI_BUILD_TABLE_FILE, tables_blob,\n\n 64, false /* high memory */);\n\n\n\n /* DSDT is pointed to by FADT */\n\n dsdt = tables_blob->len;\n\n build_dsdt(tables_blob, tables->linker, vms);\n\n\n\n /* FADT MADT GTDT MCFG SPCR pointed to by RSDT */\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_fadt(tables_blob, tables->linker, vms, dsdt);\n\n\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_madt(tables_blob, tables->linker, vms);\n\n\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_gtdt(tables_blob, tables->linker, vms);\n\n\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_mcfg(tables_blob, tables->linker, vms);\n\n\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_spcr(tables_blob, tables->linker, vms);\n\n\n\n if (nb_numa_nodes > 0) {\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_srat(tables_blob, tables->linker, vms);\n\n }\n\n\n\n if (its_class_name() && !vmc->no_its) {\n\n acpi_add_table(table_offsets, tables_blob);\n\n build_iort(tables_blob, tables->linker);\n\n }\n\n\n\n /* RSDT is pointed to by RSDP */\n\n rsdt = tables_blob->len;\n\n build_rsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);\n\n\n\n /* RSDP is in FSEG memory, so allocate it separately */\n\n build_rsdp(tables->rsdp, tables->linker, rsdt);\n\n\n\n /* Cleanup memory that's no longer used. */\n\n g_array_free(table_offsets, true);\n\n}\n", + "output": "0", + "index": 25511 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mmu_translate_sfaa(CPUS390XState *env, target_ulong vaddr,\n\n uint64_t asc, uint64_t asce, target_ulong *raddr,\n\n int *flags, int rw)\n\n{\n\n if (asce & _SEGMENT_ENTRY_INV) {\n\n DPRINTF(\"%s: SEG=0x%\" PRIx64 \" invalid\\n\", __func__, asce);\n\n trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw);\n\n return -1;\n\n }\n\n\n\n if (asce & _SEGMENT_ENTRY_RO) {\n\n *flags &= ~PAGE_WRITE;\n\n }\n\n\n\n *raddr = (asce & 0xfffffffffff00000ULL) | (vaddr & 0xfffff);\n\n\n\n PTE_DPRINTF(\"%s: SEG=0x%\" PRIx64 \"\\n\", __func__, asce);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 8618 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int RENAME(resample_common)(ResampleContext *c,\n\n DELEM *dst, const DELEM *src,\n\n int n, int update_ctx)\n\n{\n\n int dst_index;\n\n int index= c->index;\n\n int frac= c->frac;\n\n int sample_index = index >> c->phase_shift;\n\n\n\n index &= c->phase_mask;\n\n for (dst_index = 0; dst_index < n; dst_index++) {\n\n FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;\n\n\n\n FELEM2 val=0;\n\n int i;\n\n for (i = 0; i < c->filter_length; i++) {\n\n val += src[sample_index + i] * (FELEM2)filter[i];\n\n }\n\n OUT(dst[dst_index], val);\n\n\n\n frac += c->dst_incr_mod;\n\n index += c->dst_incr_div;\n\n if (frac >= c->src_incr) {\n\n frac -= c->src_incr;\n\n index++;\n\n }\n\n sample_index += index >> c->phase_shift;\n\n index &= c->phase_mask;\n\n }\n\n\n\n if(update_ctx){\n\n c->frac= frac;\n\n c->index= index;\n\n }\n\n\n\n return sample_index;\n\n}\n", + "output": "0", + "index": 22251 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void debug_print_fis(uint8_t *fis, int cmd_len)\n\n{\n\n#ifdef DEBUG_AHCI\n\n int i;\n\n\n\n fprintf(stderr, \"fis:\");\n\n for (i = 0; i < cmd_len; i++) {\n\n if ((i & 0xf) == 0) {\n\n fprintf(stderr, \"\\n%02x:\",i);\n\n }\n\n fprintf(stderr, \"%02x \",fis[i]);\n\n }\n\n fprintf(stderr, \"\\n\");\n\n#endif\n\n}\n", + "output": "1", + "index": 13784 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)\n\n{\n\n\tint i;\n\n assert(src1==src2);\n\n\tfor(i=0; i>8;\n\n\t\tconst int b= l>>16;\n\n\n\n\t\tdstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128;\n\n\t\tdstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128;\n\n\t}\n\n}\n", + "output": "1", + "index": 2947 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size)\n\n{\n\n switch (AV_RB32(src)) {\n\n case DCA_SYNCWORD_CORE_BE:\n\n case DCA_SYNCWORD_SUBSTREAM:\n\n memcpy(dst, src, src_size);\n\n return src_size;\n\n case DCA_SYNCWORD_CORE_LE:\n\n case DCA_SYNCWORD_CORE_14B_BE:\n\n case DCA_SYNCWORD_CORE_14B_LE:\n\n return avpriv_dca_convert_bitstream(src, src_size, dst, max_size);\n\n default:\n\n return AVERROR_INVALIDDATA;\n\n }\n\n}\n", + "output": "0", + "index": 14048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,\n\n VP8Frame *prev_frame)\n\n{\n\n VP8Context *s = avctx->priv_data;\n\n int mb_x, mb_y;\n\n\n\n s->mv_min.y = -MARGIN;\n\n s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;\n\n for (mb_y = 0; mb_y < s->mb_height; mb_y++) {\n\n VP8Macroblock *mb = s->macroblocks_base +\n\n ((s->mb_width + 1) * (mb_y + 1) + 1);\n\n int mb_xy = mb_y * s->mb_width;\n\n\n\n AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);\n\n\n\n s->mv_min.x = -MARGIN;\n\n s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;\n\n for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {\n\n if (mb_y == 0)\n\n AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,\n\n DC_PRED * 0x01010101);\n\n decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,\n\n prev_frame && prev_frame->seg_map ?\n\n prev_frame->seg_map->data + mb_xy : NULL, 1);\n\n s->mv_min.x -= 64;\n\n s->mv_max.x -= 64;\n\n }\n\n s->mv_min.y -= 64;\n\n s->mv_max.y -= 64;\n\n }\n\n}\n", + "output": "1", + "index": 26101 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bmdma_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t val, unsigned size)\n\n{\n\n BMDMAState *bm = opaque;\n\n\n\n if (size != 1) {\n\n return;\n\n }\n\n\n\n#ifdef DEBUG_IDE\n\n printf(\"bmdma: writeb 0x%02x : 0x%02x\\n\", addr, val);\n\n#endif\n\n switch (addr & 3) {\n\n case 0:\n\n bmdma_cmd_writeb(bm, val);\n\n break;\n\n case 2:\n\n bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06);\n\n break;\n\n default:;\n\n }\n\n}\n", + "output": "0", + "index": 24207 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mcf_fec_do_tx(mcf_fec_state *s)\n\n{\n\n uint32_t addr;\n\n mcf_fec_bd bd;\n\n int frame_size;\n\n int len;\n\n uint8_t frame[FEC_MAX_FRAME_SIZE];\n\n uint8_t *ptr;\n\n\n\n DPRINTF(\"do_tx\\n\");\n\n ptr = frame;\n\n frame_size = 0;\n\n addr = s->tx_descriptor;\n\n while (1) {\n\n mcf_fec_read_bd(&bd, addr);\n\n DPRINTF(\"tx_bd %x flags %04x len %d data %08x\\n\",\n\n addr, bd.flags, bd.length, bd.data);\n\n if ((bd.flags & FEC_BD_R) == 0) {\n\n /* Run out of descriptors to transmit. */\n\n break;\n\n }\n\n len = bd.length;\n\n if (frame_size + len > FEC_MAX_FRAME_SIZE) {\n\n len = FEC_MAX_FRAME_SIZE - frame_size;\n\n s->eir |= FEC_INT_BABT;\n\n }\n\n cpu_physical_memory_read(bd.data, ptr, len);\n\n ptr += len;\n\n frame_size += len;\n\n if (bd.flags & FEC_BD_L) {\n\n /* Last buffer in frame. */\n\n DPRINTF(\"Sending packet\\n\");\n\n qemu_send_packet(qemu_get_queue(s->nic), frame, len);\n\n ptr = frame;\n\n frame_size = 0;\n\n s->eir |= FEC_INT_TXF;\n\n }\n\n s->eir |= FEC_INT_TXB;\n\n bd.flags &= ~FEC_BD_R;\n\n /* Write back the modified descriptor. */\n\n mcf_fec_write_bd(&bd, addr);\n\n /* Advance to the next descriptor. */\n\n if ((bd.flags & FEC_BD_W) != 0) {\n\n addr = s->etdsr;\n\n } else {\n\n addr += 8;\n\n }\n\n }\n\n s->tx_descriptor = addr;\n\n}\n", + "output": "0", + "index": 1165 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vm_can_run(void)\n\n{\n\n if (powerdown_requested)\n\n return 0;\n\n if (reset_requested)\n\n return 0;\n\n if (shutdown_requested)\n\n return 0;\n\n if (debug_requested)\n\n return 0;\n\n return 1;\n\n}\n", + "output": "0", + "index": 15936 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_query_tests(QmpSchema *schema)\n\n{\n\n SchemaInfoList *tail;\n\n SchemaInfo *si, *arg_type, *ret_type;\n\n const char *test_name;\n\n\n\n /* Test the query-like commands */\n\n for (tail = schema->list; tail; tail = tail->next) {\n\n si = tail->value;\n\n if (si->meta_type != SCHEMA_META_TYPE_COMMAND) {\n\n continue;\n\n }\n\n\n\n if (query_is_blacklisted(si->name)) {\n\n continue;\n\n }\n\n\n\n arg_type = qmp_schema_lookup(schema, si->u.command.arg_type);\n\n if (object_type_has_mandatory_members(arg_type)) {\n\n continue;\n\n }\n\n\n\n ret_type = qmp_schema_lookup(schema, si->u.command.ret_type);\n\n if (ret_type->meta_type == SCHEMA_META_TYPE_OBJECT\n\n && !ret_type->u.object.members) {\n\n continue;\n\n }\n\n\n\n test_name = g_strdup_printf(\"qmp/%s\", si->name);\n\n qtest_add_data_func(test_name, si->name, test_query);\n\n }\n\n}\n", + "output": "1", + "index": 4031 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void print_formats(AVFilterContext *filter_ctx)\n\n{\n\n int i, j;\n\n\n\n#define PRINT_FMTS(inout, outin, INOUT) \\\n\n for (i = 0; i < filter_ctx->nb_##inout##puts; i++) { \\\n\n if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \\\n\n AVFilterFormats *fmts = \\\n\n filter_ctx->inout##puts[i]->outin##_formats; \\\n\n for (j = 0; j < fmts->nb_formats; j++) \\\n\n if(av_get_pix_fmt_name(fmts->formats[j])) \\\n\n printf(#INOUT \"PUT[%d] %s: fmt:%s\\n\", \\\n\n i, filter_ctx->filter->inout##puts[i].name, \\\n\n av_get_pix_fmt_name(fmts->formats[j])); \\\n\n } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \\\n\n AVFilterFormats *fmts; \\\n\n AVFilterChannelLayouts *layouts; \\\n\n \\\n\n fmts = filter_ctx->inout##puts[i]->outin##_formats; \\\n\n for (j = 0; j < fmts->nb_formats; j++) \\\n\n printf(#INOUT \"PUT[%d] %s: fmt:%s\\n\", \\\n\n i, filter_ctx->filter->inout##puts[i].name, \\\n\n av_get_sample_fmt_name(fmts->formats[j])); \\\n\n \\\n\n layouts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \\\n\n for (j = 0; j < layouts->nb_channel_layouts; j++) { \\\n\n char buf[256]; \\\n\n av_get_channel_layout_string(buf, sizeof(buf), -1, \\\n\n layouts->channel_layouts[j]); \\\n\n printf(#INOUT \"PUT[%d] %s: chlayout:%s\\n\", \\\n\n i, filter_ctx->filter->inout##puts[i].name, buf); \\\n\n } \\\n\n } \\\n\n } \\\n\n\n\n PRINT_FMTS(in, out, IN);\n\n PRINT_FMTS(out, in, OUT);\n\n}\n", + "output": "1", + "index": 23435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_pbm_init_device(SysBusDevice *dev)\n\n{\n\n\n\n APBState *s;\n\n int pci_mem_config, pci_mem_data, apb_config, pci_ioport;\n\n\n\n s = FROM_SYSBUS(APBState, dev);\n\n /* apb_config */\n\n apb_config = cpu_register_io_memory(apb_config_read,\n\n apb_config_write, s);\n\n sysbus_init_mmio(dev, 0x40ULL, apb_config);\n\n /* pci_ioport */\n\n pci_ioport = cpu_register_io_memory(pci_apb_ioread,\n\n pci_apb_iowrite, s);\n\n sysbus_init_mmio(dev, 0x10000ULL, pci_ioport);\n\n /* mem_config */\n\n pci_mem_config = cpu_register_io_memory(pci_apb_config_read,\n\n pci_apb_config_write, s);\n\n sysbus_init_mmio(dev, 0x10ULL, pci_mem_config);\n\n /* mem_data */\n\n pci_mem_data = cpu_register_io_memory(pci_apb_read,\n\n pci_apb_write, &s->host_state);\n\n sysbus_init_mmio(dev, 0x10000000ULL, pci_mem_data);\n\n return 0;\n\n}\n", + "output": "0", + "index": 10257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_client_session_co_readv(NbdClientSession *client, int64_t sector_num,\n\n int nb_sectors, QEMUIOVector *qiov)\n\n{\n\n int offset = 0;\n\n int ret;\n\n while (nb_sectors > NBD_MAX_SECTORS) {\n\n ret = nbd_co_readv_1(client, sector_num,\n\n NBD_MAX_SECTORS, qiov, offset);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n offset += NBD_MAX_SECTORS * 512;\n\n sector_num += NBD_MAX_SECTORS;\n\n nb_sectors -= NBD_MAX_SECTORS;\n\n }\n\n return nbd_co_readv_1(client, sector_num, nb_sectors, qiov, offset);\n\n}\n", + "output": "0", + "index": 4205 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){\n\n int i;\n\n uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n block[0] += 1<<(shift-1);\n\n\n\n for(i=0; i<4; i++){\n\n const int z0= block[0 + block_stride*i] + block[2 + block_stride*i];\n\n const int z1= block[0 + block_stride*i] - block[2 + block_stride*i];\n\n const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i];\n\n const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1);\n\n\n\n block[0 + block_stride*i]= z0 + z3;\n\n block[1 + block_stride*i]= z1 + z2;\n\n block[2 + block_stride*i]= z1 - z2;\n\n block[3 + block_stride*i]= z0 - z3;\n\n }\n\n\n\n for(i=0; i<4; i++){\n\n const int z0= block[i + block_stride*0] + block[i + block_stride*2];\n\n const int z1= block[i + block_stride*0] - block[i + block_stride*2];\n\n const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3];\n\n const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1);\n\n\n\n dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];\n\n dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];\n\n dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];\n\n dst[i + 3*stride]= cm[ add*dst[i + 3*stride] + ((z0 - z3) >> shift) ];\n\n }\n\n}\n", + "output": "0", + "index": 21449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int RENAME(resample_common)(ResampleContext *c,\n\n void *dest, const void *source,\n\n int n, int update_ctx)\n\n{\n\n DELEM *dst = dest;\n\n const DELEM *src = source;\n\n int dst_index;\n\n int index= c->index;\n\n int frac= c->frac;\n\n int sample_index = 0;\n\n\n\n while (index >= c->phase_count) {\n\n sample_index++;\n\n index -= c->phase_count;\n\n }\n\n\n\n for (dst_index = 0; dst_index < n; dst_index++) {\n\n FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;\n\n\n\n FELEM2 val= FOFFSET;\n\n int i;\n\n for (i = 0; i < c->filter_length; i++) {\n\n val += src[sample_index + i] * (FELEM2)filter[i];\n\n }\n\n OUT(dst[dst_index], val);\n\n\n\n frac += c->dst_incr_mod;\n\n index += c->dst_incr_div;\n\n if (frac >= c->src_incr) {\n\n frac -= c->src_incr;\n\n index++;\n\n }\n\n\n\n while (index >= c->phase_count) {\n\n sample_index++;\n\n index -= c->phase_count;\n\n }\n\n }\n\n\n\n if(update_ctx){\n\n c->frac= frac;\n\n c->index= index;\n\n }\n\n\n\n return sample_index;\n\n}\n", + "output": "1", + "index": 27119 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_close(BlockDriverState *bs)\n\n{\n\n if (bs->drv) {\n\n if (bs->backing_hd)\n\n bdrv_delete(bs->backing_hd);\n\n bs->drv->bdrv_close(bs);\n\n qemu_free(bs->opaque);\n\n#ifdef _WIN32\n\n if (bs->is_temporary) {\n\n unlink(bs->filename);\n\n }\n\n#endif\n\n bs->opaque = NULL;\n\n bs->drv = NULL;\n\n\n\n /* call the change callback */\n\n bs->total_sectors = 0;\n\n bs->media_changed = 1;\n\n if (bs->change_cb)\n\n bs->change_cb(bs->change_opaque);\n\n }\n\n}\n", + "output": "1", + "index": 26719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "Aml *aml_and(Aml *arg1, Aml *arg2)\n\n{\n\n Aml *var = aml_opcode(0x7B /* AndOp */);\n\n aml_append(var, arg1);\n\n aml_append(var, arg2);\n\n build_append_byte(var->buf, 0x00 /* NullNameOp */);\n\n return var;\n\n}\n", + "output": "0", + "index": 8242 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int url_connect(struct playlist *pls, AVDictionary *opts, AVDictionary *opts2)\n\n{\n\n AVDictionary *tmp = NULL;\n\n int ret;\n\n\n\n av_dict_copy(&tmp, opts, 0);\n\n av_dict_copy(&tmp, opts2, 0);\n\n\n\n av_opt_set_dict(pls->input, &tmp);\n\n\n\n if ((ret = ffurl_connect(pls->input, NULL)) < 0) {\n\n ffurl_close(pls->input);\n\n pls->input = NULL;\n\n }\n\n\n\n av_dict_free(&tmp);\n\n return ret;\n\n}\n", + "output": "1", + "index": 6774 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_tight_clear(VncState *vs)\n\n{\n\n int i;\n\n for (i=0; itight_stream); i++) {\n\n if (vs->tight_stream[i].opaque) {\n\n deflateEnd(&vs->tight_stream[i]);\n\n }\n\n }\n\n\n\n buffer_free(&vs->tight);\n\n buffer_free(&vs->tight_zlib);\n\n buffer_free(&vs->tight_gradient);\n\n#ifdef CONFIG_VNC_JPEG\n\n buffer_free(&vs->tight_jpeg);\n\n#endif\n\n}\n", + "output": "0", + "index": 15414 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1);\n\n\n\n *spec_info = (ImageInfoSpecific){\n\n .type = IMAGE_INFO_SPECIFIC_KIND_QCOW2,\n\n .u.qcow2.data = g_new(ImageInfoSpecificQCow2, 1),\n\n };\n\n if (s->qcow_version == 2) {\n\n *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){\n\n .compat = g_strdup(\"0.10\"),\n\n .refcount_bits = s->refcount_bits,\n\n };\n\n } else if (s->qcow_version == 3) {\n\n *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){\n\n .compat = g_strdup(\"1.1\"),\n\n .lazy_refcounts = s->compatible_features &\n\n QCOW2_COMPAT_LAZY_REFCOUNTS,\n\n .has_lazy_refcounts = true,\n\n .corrupt = s->incompatible_features &\n\n QCOW2_INCOMPAT_CORRUPT,\n\n .has_corrupt = true,\n\n .refcount_bits = s->refcount_bits,\n\n };\n\n } else {\n\n /* if this assertion fails, this probably means a new version was\n\n * added without having it covered here */\n\n assert(false);\n\n }\n\n\n\n return spec_info;\n\n}\n", + "output": "1", + "index": 16103 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_dsputil_init_armv5te(DSPContext *c, AVCodecContext *avctx)\n\n{\n\n if (avctx->bits_per_raw_sample <= 8 &&\n\n (avctx->idct_algo == FF_IDCT_AUTO ||\n\n avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {\n\n c->idct_put = ff_simple_idct_put_armv5te;\n\n c->idct_add = ff_simple_idct_add_armv5te;\n\n c->idct = ff_simple_idct_armv5te;\n\n c->idct_permutation_type = FF_NO_IDCT_PERM;\n\n }\n\n\n\n c->prefetch = ff_prefetch_arm;\n\n}\n", + "output": "0", + "index": 21727 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_pci_device_unplugged(DeviceState *d)\n\n{\n\n VirtIOPCIProxy *proxy = VIRTIO_PCI(d);\n\n bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);\n\n bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY;\n\n\n\n virtio_pci_stop_ioeventfd(proxy);\n\n\n\n if (modern) {\n\n virtio_pci_modern_mem_region_unmap(proxy, &proxy->common);\n\n virtio_pci_modern_mem_region_unmap(proxy, &proxy->isr);\n\n virtio_pci_modern_mem_region_unmap(proxy, &proxy->device);\n\n virtio_pci_modern_mem_region_unmap(proxy, &proxy->notify);\n\n if (modern_pio) {\n\n virtio_pci_modern_io_region_unmap(proxy, &proxy->notify_pio);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 15867 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vtd_realize(DeviceState *dev, Error **errp)\n\n{\n\n PCMachineState *pcms = PC_MACHINE(qdev_get_machine());\n\n PCIBus *bus = pcms->bus;\n\n IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);\n\n X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev);\n\n\n\n VTD_DPRINTF(GENERAL, \"\");\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": "1", + "index": 10505 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void vmsvga_check_size(struct vmsvga_state_s *s)\n\n{\n\n DisplaySurface *surface = qemu_console_surface(s->vga.con);\n\n\n\n if (s->new_width != surface_width(surface) ||\n\n s->new_height != surface_height(surface)) {\n\n qemu_console_resize(s->vga.con, s->new_width, s->new_height);\n\n s->invalidated = 1;\n\n }\n\n}\n", + "output": "1", + "index": 11541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,\n\n hwaddr base,\n\n BlockDriverState *bd, qemu_irq irq,\n\n qemu_irq rx_dma, qemu_irq tx_dma)\n\n{\n\n PXA2xxMMCIState *s;\n\n\n\n s = (PXA2xxMMCIState *) g_malloc0(sizeof(PXA2xxMMCIState));\n\n s->irq = irq;\n\n s->rx_dma = rx_dma;\n\n s->tx_dma = tx_dma;\n\n\n\n memory_region_init_io(&s->iomem, NULL, &pxa2xx_mmci_ops, s,\n\n \"pxa2xx-mmci\", 0x00100000);\n\n memory_region_add_subregion(sysmem, base, &s->iomem);\n\n\n\n /* Instantiate the actual storage */\n\n s->card = sd_init(bd, false);\n\n if (s->card == NULL) {\n\n exit(1);\n\n }\n\n\n\n register_savevm(NULL, \"pxa2xx_mmci\", 0, 0,\n\n pxa2xx_mmci_save, pxa2xx_mmci_load, s);\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 14121 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "START_TEST(qlist_iter_test)\n\n{\n\n int i;\n\n QList *qlist;\n\n\n\n qlist = qlist_new();\n\n\n\n for (i = 0; i < iter_max; i++)\n\n qlist_append(qlist, qint_from_int(i));\n\n\n\n iter_called = 0;\n\n qlist_iter(qlist, iter_func, NULL);\n\n\n\n fail_unless(iter_called == iter_max);\n\n\n\n QDECREF(qlist);\n\n}\n", + "output": "0", + "index": 18732 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mpc8544_guts_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t value, unsigned size)\n\n{\n\n addr &= MPC8544_GUTS_MMIO_SIZE - 1;\n\n\n\n switch (addr) {\n\n case MPC8544_GUTS_ADDR_RSTCR:\n\n if (value & MPC8544_GUTS_RSTCR_RESET) {\n\n qemu_system_reset_request();\n\n }\n\n break;\n\n default:\n\n fprintf(stderr, \"guts: Unknown register write: %x = %x\\n\",\n\n (int)addr, (unsigned)value);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 5882 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp,\n\n int32_t ag, uint32_t ap)\n\n{\n\n AVReplayGain *replaygain;\n\n\n\n if (tg == INT32_MIN && ag == INT32_MIN)\n\n return 0;\n\n\n\n replaygain = (AVReplayGain*)ff_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN,\n\n sizeof(*replaygain));\n\n if (!replaygain)\n\n return AVERROR(ENOMEM);\n\n\n\n replaygain->track_gain = tg;\n\n replaygain->track_peak = tp;\n\n replaygain->album_gain = ag;\n\n replaygain->album_peak = ap;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 24454 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)\n\n{\n\n av_unused int cpu_flags = av_get_cpu_flags();\n\n\n\n cavsdsp_init_mmx(c, avctx);\n\n#if HAVE_AMD3DNOW_INLINE\n\n if (INLINE_AMD3DNOW(cpu_flags))\n\n cavsdsp_init_3dnow(c, avctx);\n\n#endif /* HAVE_AMD3DNOW_INLINE */\n\n#if HAVE_MMXEXT_INLINE\n\n if (INLINE_MMXEXT(cpu_flags)) {\n\n DSPFUNC(put, 0, 16, mmxext);\n\n DSPFUNC(put, 1, 8, mmxext);\n\n DSPFUNC(avg, 0, 16, mmxext);\n\n DSPFUNC(avg, 1, 8, mmxext);\n\n }\n\n#endif\n\n#if HAVE_MMX_EXTERNAL\n\n if (EXTERNAL_MMXEXT(cpu_flags)) {\n\n c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;\n\n c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;\n\n }\n\n#endif\n\n#if HAVE_SSE2_EXTERNAL\n\n if (EXTERNAL_SSE2(cpu_flags)) {\n\n c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;\n\n c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;\n\n }\n\n#endif\n\n}\n", + "output": "1", + "index": 24416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int mace_decode_init(AVCodecContext * avctx)\n\n{\n\n MACEContext *ctx = avctx->priv_data;\n\n\n\n if (avctx->channels > 2)\n\n return -1;\n\n avctx->sample_fmt = AV_SAMPLE_FMT_S16;\n\n\n\n avcodec_get_frame_defaults(&ctx->frame);\n\n avctx->coded_frame = &ctx->frame;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 14508 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_vio_quiesce_one(VIOsPAPRDevice *dev)\n\n{\n\n if (dev->tcet) {\n\n spapr_tce_reset(dev->tcet);\n\n }\n\n free_crq(dev);\n\n}\n", + "output": "0", + "index": 14118 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ram_save_iterate(QEMUFile *f, void *opaque)\n\n{\n\n int ret;\n\n int i;\n\n int64_t t0;\n\n int total_sent = 0;\n\n\n\n qemu_mutex_lock_ramlist();\n\n\n\n if (ram_list.version != last_version) {\n\n reset_ram_globals();\n\n }\n\n\n\n ram_control_before_iterate(f, RAM_CONTROL_ROUND);\n\n\n\n t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);\n\n i = 0;\n\n while ((ret = qemu_file_rate_limit(f)) == 0) {\n\n int bytes_sent;\n\n\n\n bytes_sent = ram_save_block(f, false);\n\n /* no more blocks to sent */\n\n if (bytes_sent == 0) {\n\n break;\n\n }\n\n total_sent += bytes_sent;\n\n acct_info.iterations++;\n\n check_guest_throttling();\n\n /* we want to check in the 1st loop, just in case it was the 1st time\n\n and we had to sync the dirty bitmap.\n\n qemu_get_clock_ns() is a bit expensive, so we only check each some\n\n iterations\n\n */\n\n if ((i & 63) == 0) {\n\n uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;\n\n if (t1 > MAX_WAIT) {\n\n DPRINTF(\"big wait: %\" PRIu64 \" milliseconds, %d iterations\\n\",\n\n t1, i);\n\n break;\n\n }\n\n }\n\n i++;\n\n }\n\n\n\n qemu_mutex_unlock_ramlist();\n\n\n\n /*\n\n * Must occur before EOS (or any QEMUFile operation)\n\n * because of RDMA protocol.\n\n */\n\n ram_control_after_iterate(f, RAM_CONTROL_ROUND);\n\n\n\n if (ret < 0) {\n\n bytes_transferred += total_sent;\n\n return ret;\n\n }\n\n\n\n qemu_put_be64(f, RAM_SAVE_FLAG_EOS);\n\n total_sent += 8;\n\n bytes_transferred += total_sent;\n\n\n\n return total_sent;\n\n}\n", + "output": "0", + "index": 5483 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vsink_query_formats(AVFilterContext *ctx)\n\n{\n\n BufferSinkContext *buf = ctx->priv;\n\n AVFilterFormats *formats = NULL;\n\n unsigned i;\n\n int ret;\n\n\n\n CHECK_LIST_SIZE(pixel_fmts)\n\n if (buf->pixel_fmts_size) {\n\n for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)\n\n if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0)\n\n return ret;\n\n ff_set_common_formats(ctx, formats);\n\n } else {\n\n ff_default_query_formats(ctx);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 1968 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data)\n\n{\n\n struct bdrv_iterate_context context = { mon, 0 };\n\n\n\n if (incoming_expected) {\n\n qerror_report(QERR_MIGRATION_EXPECTED);\n\n return -1;\n\n }\n\n bdrv_iterate(encrypted_bdrv_it, &context);\n\n /* only resume the vm if all keys are set and valid */\n\n if (!context.err) {\n\n vm_start();\n\n return 0;\n\n } else {\n\n return -1;\n\n }\n\n}\n", + "output": "0", + "index": 6073 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_rtc_hzupdate(PXA2xxRTCState *s)\n\n{\n\n int64_t rt = qemu_get_clock(rt_clock);\n\n s->last_rcnr += ((rt - s->last_hz) << 15) /\n\n (1000 * ((s->rttr & 0xffff) + 1));\n\n s->last_rdcr += ((rt - s->last_hz) << 15) /\n\n (1000 * ((s->rttr & 0xffff) + 1));\n\n s->last_hz = rt;\n\n}\n", + "output": "0", + "index": 15944 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *qemu_rdma_data_init(const char *host_port, Error **errp)\n\n{\n\n RDMAContext *rdma = NULL;\n\n InetSocketAddress *addr;\n\n\n\n if (host_port) {\n\n rdma = g_malloc0(sizeof(RDMAContext));\n\n memset(rdma, 0, sizeof(RDMAContext));\n\n rdma->current_index = -1;\n\n rdma->current_chunk = -1;\n\n\n\n addr = inet_parse(host_port, NULL);\n\n if (addr != NULL) {\n\n rdma->port = atoi(addr->port);\n\n rdma->host = g_strdup(addr->host);\n\n } else {\n\n ERROR(errp, \"bad RDMA migration address '%s'\", host_port);\n\n g_free(rdma);\n\n rdma = NULL;\n\n }\n\n\n\n qapi_free_InetSocketAddress(addr);\n\n }\n\n\n\n return rdma;\n\n}\n", + "output": "1", + "index": 19025 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,\n\n target_ulong opcode, target_ulong *args)\n\n{\n\n CPUState *cs;\n\n target_ulong mflags = args[0];\n\n target_ulong resource = args[1];\n\n target_ulong value1 = args[2];\n\n target_ulong value2 = args[3];\n\n target_ulong ret = H_P2;\n\n\n\n if (resource == H_SET_MODE_ENDIAN) {\n\n if (value1) {\n\n ret = H_P3;\n\n goto out;\n\n }\n\n if (value2) {\n\n ret = H_P4;\n\n goto out;\n\n }\n\n\n\n switch (mflags) {\n\n case H_SET_MODE_ENDIAN_BIG:\n\n CPU_FOREACH(cs) {\n\n PowerPCCPU *cp = POWERPC_CPU(cs);\n\n CPUPPCState *env = &cp->env;\n\n env->spr[SPR_LPCR] &= ~LPCR_ILE;\n\n }\n\n ret = H_SUCCESS;\n\n break;\n\n\n\n case H_SET_MODE_ENDIAN_LITTLE:\n\n CPU_FOREACH(cs) {\n\n PowerPCCPU *cp = POWERPC_CPU(cs);\n\n CPUPPCState *env = &cp->env;\n\n env->spr[SPR_LPCR] |= LPCR_ILE;\n\n }\n\n ret = H_SUCCESS;\n\n break;\n\n\n\n default:\n\n ret = H_UNSUPPORTED_FLAG;\n\n }\n\n }\n\n\n\nout:\n\n return ret;\n\n}\n", + "output": "1", + "index": 15683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ram_addr_t ram_save_remaining(void)\n\n{\n\n return ram_list.dirty_pages;\n\n}\n", + "output": "0", + "index": 11851 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int try_decode_frame(AVStream *st, AVPacket *avpkt)\n\n{\n\n int16_t *samples;\n\n AVCodec *codec;\n\n int got_picture, data_size, ret=0;\n\n AVFrame picture;\n\n\n\n if(!st->codec->codec){\n\n codec = avcodec_find_decoder(st->codec->codec_id);\n\n if (!codec)\n\n return -1;\n\n ret = avcodec_open(st->codec, codec);\n\n if (ret < 0)\n\n return ret;\n\n }\n\n\n\n if(!has_codec_parameters(st->codec)){\n\n switch(st->codec->codec_type) {\n\n case CODEC_TYPE_VIDEO:\n\n\n ret = avcodec_decode_video2(st->codec, &picture,\n\n &got_picture, avpkt);\n\n break;\n\n case CODEC_TYPE_AUDIO:\n\n data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE);\n\n samples = av_malloc(data_size);\n\n if (!samples)\n\n goto fail;\n\n ret = avcodec_decode_audio3(st->codec, samples,\n\n &data_size, avpkt);\n\n av_free(samples);\n\n break;\n\n default:\n\n break;\n\n }\n\n }\n\n fail:\n\n return ret;\n\n}", + "output": "1", + "index": 1995 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUFile *qemu_fopen_fd(int fd)\n\n{\n\n QEMUFileFD *s = qemu_mallocz(sizeof(QEMUFileFD));\n\n\n\n if (s == NULL)\n\n return NULL;\n\n\n\n s->fd = fd;\n\n s->file = qemu_fopen_ops(s, fd_put_buffer, fd_get_buffer, fd_close, NULL);\n\n return s->file;\n\n}\n", + "output": "0", + "index": 25223 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aiff_read_packet(AVFormatContext *s,\n\n AVPacket *pkt)\n\n{\n\n AVStream *st = s->streams[0];\n\n AIFFInputContext *aiff = s->priv_data;\n\n int64_t max_size;\n\n int res, size;\n\n\n\n /* calculate size of remaining data */\n\n max_size = aiff->data_end - avio_tell(s->pb);\n\n if (max_size <= 0)\n\n return AVERROR_EOF;\n\n\n\n /* Now for that packet */\n\n if (st->codec->block_align >= 33) // GSM, QCLP, IMA4\n\n size = st->codec->block_align;\n\n else\n\n size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;\n\n size = FFMIN(max_size, size);\n\n res = av_get_packet(s->pb, pkt, size);\n\n if (res < 0)\n\n return res;\n\n\n\n\n\n /* Only one stream in an AIFF file */\n\n pkt->stream_index = 0;\n\n pkt->duration = (res / st->codec->block_align) * aiff->block_duration;\n\n return 0;\n\n}", + "output": "1", + "index": 3735 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int write_l2_entries(BlockDriverState *bs, uint64_t *l2_table,\n\n uint64_t l2_offset, int l2_index, int num)\n\n{\n\n int l2_start_index = l2_index & ~(L1_ENTRIES_PER_SECTOR - 1);\n\n int start_offset = (8 * l2_index) & ~511;\n\n int end_offset = (8 * (l2_index + num) + 511) & ~511;\n\n size_t len = end_offset - start_offset;\n\n int ret;\n\n\n\n BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);\n\n ret = bdrv_pwrite(bs->file, l2_offset + start_offset,\n\n &l2_table[l2_start_index], len);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 17422 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *rndis_queue_response(USBNetState *s, unsigned int length)\n\n{\n\n struct rndis_response *r =\n\n qemu_mallocz(sizeof(struct rndis_response) + length);\n\n\n\n TAILQ_INSERT_TAIL(&s->rndis_resp, r, entries);\n\n r->length = length;\n\n\n\n return &r->buf[0];\n\n}\n", + "output": "0", + "index": 4270 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_net_cleanup(NetClientState *nc)\n\n{\n\n VirtIONet *n = qemu_get_nic_opaque(nc);\n\n\n\n n->nic = NULL;\n\n}\n", + "output": "0", + "index": 14081 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int file_close_dir(URLContext *h)\n\n{\n\n#if HAVE_DIRENT_H\n\n FileContext *c = h->priv_data;\n\n closedir(c->dir);\n\n return 0;\n\n#else\n\n return AVERROR(ENOSYS);\n\n#endif /* HAVE_DIRENT_H */\n\n}\n", + "output": "0", + "index": 10174 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int iscsi_refresh_limits(BlockDriverState *bs)\n\n{\n\n IscsiLun *iscsilun = bs->opaque;\n\n\n\n /* We don't actually refresh here, but just return data queried in\n\n * iscsi_open(): iscsi targets don't change their limits. */\n\n if (iscsilun->lbp.lbpu || iscsilun->lbp.lbpws) {\n\n if (iscsilun->bl.max_unmap < 0xffffffff) {\n\n bs->bl.max_discard = sector_lun2qemu(iscsilun->bl.max_unmap,\n\n iscsilun);\n\n }\n\n bs->bl.discard_alignment = sector_lun2qemu(iscsilun->bl.opt_unmap_gran,\n\n iscsilun);\n\n\n\n if (iscsilun->bl.max_ws_len < 0xffffffff) {\n\n bs->bl.max_write_zeroes = sector_lun2qemu(iscsilun->bl.max_ws_len,\n\n iscsilun);\n\n }\n\n bs->bl.write_zeroes_alignment = sector_lun2qemu(iscsilun->bl.opt_unmap_gran,\n\n iscsilun);\n\n\n\n bs->bl.opt_transfer_length = sector_lun2qemu(iscsilun->bl.opt_xfer_len,\n\n iscsilun);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 24755 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pxa2xx_pcmcia_initfn(Object *obj)\n\n{\n\n SysBusDevice *sbd = SYS_BUS_DEVICE(obj);\n\n PXA2xxPCMCIAState *s = PXA2XX_PCMCIA(obj);\n\n\n\n memory_region_init(&s->container_mem, obj, \"container\", 0x10000000);\n\n sysbus_init_mmio(sbd, &s->container_mem);\n\n\n\n /* Socket I/O Memory Space */\n\n memory_region_init_io(&s->iomem, NULL, &pxa2xx_pcmcia_io_ops, s,\n\n \"pxa2xx-pcmcia-io\", 0x04000000);\n\n memory_region_add_subregion(&s->container_mem, 0x00000000,\n\n &s->iomem);\n\n\n\n /* Then next 64 MB is reserved */\n\n\n\n /* Socket Attribute Memory Space */\n\n memory_region_init_io(&s->attr_iomem, NULL, &pxa2xx_pcmcia_attr_ops, s,\n\n \"pxa2xx-pcmcia-attribute\", 0x04000000);\n\n memory_region_add_subregion(&s->container_mem, 0x08000000,\n\n &s->attr_iomem);\n\n\n\n /* Socket Common Memory Space */\n\n memory_region_init_io(&s->common_iomem, NULL, &pxa2xx_pcmcia_common_ops, s,\n\n \"pxa2xx-pcmcia-common\", 0x04000000);\n\n memory_region_add_subregion(&s->container_mem, 0x0c000000,\n\n &s->common_iomem);\n\n\n\n s->slot.irq = qemu_allocate_irqs(pxa2xx_pcmcia_set_irq, s, 1)[0];\n\n\n\n object_property_add_link(obj, \"card\", TYPE_PCMCIA_CARD,\n\n (Object **)&s->card,\n\n NULL, /* read-only property */\n\n 0, NULL);\n\n}\n", + "output": "1", + "index": 24015 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t bonito_ldma_readl(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n uint32_t val;\n\n PCIBonitoState *s = opaque;\n\n\n\n val = ((uint32_t *)(&s->bonldma))[addr/sizeof(uint32_t)];\n\n\n\n return val;\n\n}\n", + "output": "0", + "index": 15878 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,\n\n const char *name, const char *tag,\n\n int len)\n\n{\n\n AVDictionaryEntry *t = NULL;\n\n uint8_t num;\n\n\n\n if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))\n\n return 0;\n\n num = t ? atoi(t->value) : 0;\n\n\n\n avio_wb32(pb, len+8);\n\n ffio_wfourcc(pb, name);\n\n if (len==4) avio_wb32(pb, num);\n\n else avio_w8 (pb, num);\n\n return len+8;\n\n}\n", + "output": "0", + "index": 3583 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tpm_passthrough_cancel_cmd(TPMBackend *tb)\n\n{\n\n /* cancelling an ongoing command is known not to work with some TPMs */\n\n}\n", + "output": "0", + "index": 3260 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t omap_os_timer_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque;\n\n int offset = addr & OMAP_MPUI_REG_MASK;\n\n\n\n if (size != 4) {\n\n return omap_badwidth_read32(opaque, addr);\n\n }\n\n\n\n switch (offset) {\n\n case 0x00:\t/* TVR */\n\n return s->timer.reset_val;\n\n\n\n case 0x04:\t/* TCR */\n\n return omap_timer_read(&s->timer);\n\n\n\n case 0x08:\t/* CR */\n\n return (s->timer.ar << 3) | (s->timer.it_ena << 2) | s->timer.st;\n\n\n\n default:\n\n break;\n\n }\n\n OMAP_BAD_REG(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 1203 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)\n\n{\n\n CPUState *cs;\n\n ICPState *ss;\n\n KVMXICSState *xicskvm = XICS_SPAPR_KVM(xics);\n\n\n\n cs = CPU(cpu);\n\n ss = &xics->ss[cs->cpu_index];\n\n\n\n assert(cs->cpu_index < xics->nr_servers);\n\n if (xicskvm->kernel_xics_fd == -1) {\n\n abort();\n\n }\n\n\n\n /*\n\n * If we are reusing a parked vCPU fd corresponding to the CPU\n\n * which was hot-removed earlier we don't have to renable\n\n * KVM_CAP_IRQ_XICS capability again.\n\n */\n\n if (ss->cap_irq_xics_enabled) {\n\n return;\n\n }\n\n\n\n if (xicskvm->kernel_xics_fd != -1) {\n\n int ret;\n\n\n\n ret = kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0,\n\n xicskvm->kernel_xics_fd,\n\n kvm_arch_vcpu_id(cs));\n\n if (ret < 0) {\n\n error_report(\"Unable to connect CPU%ld to kernel XICS: %s\",\n\n kvm_arch_vcpu_id(cs), strerror(errno));\n\n exit(1);\n\n }\n\n ss->cap_irq_xics_enabled = true;\n\n }\n\n}\n", + "output": "0", + "index": 5580 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_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 ff_rtsp_undo_setup(s);\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->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\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_free(rt->p);\n\n av_free(rt->recvbuf);\n\n}", + "output": "1", + "index": 15157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static OfDpaFlow *of_dpa_flow_alloc(uint64_t cookie)\n\n{\n\n OfDpaFlow *flow;\n\n int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) / 1000;\n\n\n\n flow = g_new0(OfDpaFlow, 1);\n\n if (!flow) {\n\n return NULL;\n\n }\n\n\n\n flow->cookie = cookie;\n\n flow->mask.tbl_id = 0xffffffff;\n\n\n\n flow->stats.install_time = flow->stats.refresh_time = now;\n\n\n\n return flow;\n\n}\n", + "output": "1", + "index": 5607 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int main()\n\n{\n\n int rt, rs;\n\n int achi, acli;\n\n int dsp;\n\n int acho, aclo;\n\n int resulth, resultl;\n\n int resdsp;\n\n\n\n achi = 0x05;\n\n acli = 0xB4CB;\n\n rs = 0xFF06;\n\n rt = 0xCB00;\n\n resulth = 0x04;\n\n resultl = 0x947438CB;\n\n\n\n __asm\n\n (\"mthi %2, $ac1\\n\\t\"\n\n \"mtlo %3, $ac1\\n\\t\"\n\n \"maq_s.w.phr $ac1, %4, %5\\n\\t\"\n\n \"mfhi %0, $ac1\\n\\t\"\n\n \"mflo %1, $ac1\\n\\t\"\n\n : \"=r\"(acho), \"=r\"(aclo)\n\n : \"r\"(achi), \"r\"(acli), \"r\"(rs), \"r\"(rt)\n\n );\n\n assert(resulth == acho);\n\n assert(resultl == aclo);\n\n\n\n achi = 0x06;\n\n acli = 0xB4CB;\n\n rs = 0x8000;\n\n rt = 0x8000;\n\n resulth = 0x6;\n\n resultl = 0x8000b4ca;\n\n resdsp = 1;\n\n\n\n __asm\n\n (\"mthi %3, $ac1\\n\\t\"\n\n \"mtlo %4, $ac1\\n\\t\"\n\n \"maq_s.w.phr $ac1, %5, %6\\n\\t\"\n\n \"mfhi %0, $ac1\\n\\t\"\n\n \"mflo %1, $ac1\\n\\t\"\n\n \"rddsp %2\\n\\t\"\n\n : \"=r\"(acho), \"=r\"(aclo), \"=r\"(dsp)\n\n : \"r\"(achi), \"r\"(acli), \"r\"(rs), \"r\"(rt)\n\n );\n\n assert(resulth == acho);\n\n assert(resultl == aclo);\n\n assert(((dsp >> 17) & 0x01) == resdsp);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 25760 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_slice_thread_free(AVCodecContext *avctx)\n\n{\n\n ThreadContext *c = avctx->thread_opaque;\n\n int i;\n\n\n\n pthread_mutex_lock(&c->current_job_lock);\n\n c->done = 1;\n\n pthread_cond_broadcast(&c->current_job_cond);\n\n pthread_mutex_unlock(&c->current_job_lock);\n\n\n\n for (i=0; ithread_count; i++)\n\n pthread_join(c->workers[i], NULL);\n\n\n\n pthread_mutex_destroy(&c->current_job_lock);\n\n pthread_cond_destroy(&c->current_job_cond);\n\n pthread_cond_destroy(&c->last_job_cond);\n\n av_free(c->workers);\n\n av_freep(&avctx->thread_opaque);\n\n}\n", + "output": "0", + "index": 18171 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void block_job_resume(BlockJob *job)\n\n{\n\n job->paused = false;\n\n block_job_iostatus_reset(job);\n\n if (job->co && !job->busy) {\n\n qemu_coroutine_enter(job->co, NULL);\n\n }\n\n}\n", + "output": "0", + "index": 14790 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_migrate_cancel(Error **errp)\n\n{\n\n migrate_fd_cancel(migrate_get_current());\n\n}\n", + "output": "1", + "index": 11449 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_write_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 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 n = r->qiov.size / 512;\n\n r->sector += n;\n\n r->sector_count -= n;\n\n if (r->sector_count == 0) {\n\n scsi_req_complete(&r->req, GOOD);\n\n } else {\n\n scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);\n\n DPRINTF(\"Write complete tag=0x%x more=%d\\n\", r->req.tag, r->qiov.size);\n\n scsi_req_data(&r->req, r->qiov.size);\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": "1", + "index": 22025 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qdist_add(struct qdist *dist, double x, long count)\n\n{\n\n struct qdist_entry *entry = NULL;\n\n\n\n if (dist->n) {\n\n struct qdist_entry e;\n\n\n\n e.x = x;\n\n entry = bsearch(&e, dist->entries, dist->n, sizeof(e), qdist_cmp);\n\n }\n\n\n\n if (entry) {\n\n entry->count += count;\n\n return;\n\n }\n\n\n\n if (unlikely(dist->n == dist->size)) {\n\n dist->size *= 2;\n\n dist->entries = g_realloc(dist->entries,\n\n sizeof(*dist->entries) * (dist->size));\n\n }\n\n dist->n++;\n\n entry = &dist->entries[dist->n - 1];\n\n entry->x = x;\n\n entry->count = count;\n\n qsort(dist->entries, dist->n, sizeof(*entry), qdist_cmp);\n\n}\n", + "output": "1", + "index": 10776 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "rdt_new_context (void)\n\n{\n\n PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));\n\n\n\n avformat_open_input(&rdt->rmctx, \"\", &ff_rdt_demuxer, NULL);\n\n\n\n return rdt;\n\n}\n", + "output": "1", + "index": 13878 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,\n\n const uint8_t *src, int width,\n\n int esc_count)\n\n{\n\n int i = 0;\n\n int count;\n\n uint8_t zero_run = 0;\n\n const uint8_t *start = src;\n\n uint8_t mask1 = -(esc_count < 2);\n\n uint8_t mask2 = -(esc_count < 3);\n\n uint8_t *end = dst + (width - 2);\n\n\n\noutput_zeros:\n\n if (l->zeros_rem) {\n\n count = FFMIN(l->zeros_rem, width - i);\n\n memset(dst, 0, count);\n\n l->zeros_rem -= count;\n\n dst += count;\n\n }\n\n\n\n while (dst < end) {\n\n i = 0;\n\n while (!zero_run && dst + i < end) {\n\n i++;\n\n zero_run =\n\n !(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));\n\n }\n\n if (zero_run) {\n\n zero_run = 0;\n\n i += esc_count;\n\n memcpy(dst, src, i);\n\n dst += i;\n\n l->zeros_rem = lag_calc_zero_run(src[i]);\n\n\n\n src += i + 1;\n\n goto output_zeros;\n\n } else {\n\n memcpy(dst, src, i);\n\n src += i;\n\n }\n\n }\n\n return start - src;\n\n}\n", + "output": "1", + "index": 6764 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void serial_xmit(void *opaque)\n\n{\n\n SerialState *s = opaque;\n\n uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock);\n\n\n\n if (s->tsr_retry <= 0) {\n\n if (s->fcr & UART_FCR_FE) {\n\n s->tsr = fifo_get(s,XMIT_FIFO);\n\n if (!s->xmit_fifo.count)\n\n s->lsr |= UART_LSR_THRE;\n\n } else {\n\n s->tsr = s->thr;\n\n s->lsr |= UART_LSR_THRE;\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 s->tsr_retry++;\n\n qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time);\n\n return;\n\n } else if (s->poll_msl < 0) {\n\n /* If we exceed MAX_XMIT_RETRY and the backend is not a real serial port, then\n\n drop any further failed writes instantly, until we get one that goes through.\n\n This is to prevent guests that log to unconnected pipes or pty's from stalling. */\n\n s->tsr_retry = -1;\n\n }\n\n }\n\n else {\n\n s->tsr_retry = 0;\n\n }\n\n\n\n s->last_xmit_ts = qemu_get_clock_ns(vm_clock);\n\n if (!(s->lsr & UART_LSR_THRE))\n\n qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time);\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", + "output": "0", + "index": 19104 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void calculate_code_lengths(uint8_t *lengths, uint32_t *counts)\n\n{\n\n uint32_t nr_nodes, nr_heap, node1, node2;\n\n int i, j;\n\n int32_t k;\n\n\n\n /* Heap and node entries start from 1 */\n\n uint32_t weights[512];\n\n uint32_t heap[512];\n\n int32_t parents[512];\n\n\n\n /* Set initial weights */\n\n for (i = 0; i < 256; i++)\n\n weights[i + 1] = (counts[i] ? counts[i] : 1) << 8;\n\n\n\n nr_nodes = 256;\n\n nr_heap = 0;\n\n\n\n heap[0] = 0;\n\n weights[0] = 0;\n\n parents[0] = -2;\n\n\n\n /* Create initial nodes */\n\n for (i = 1; i <= 256; i++) {\n\n parents[i] = -1;\n\n\n\n heap[++nr_heap] = i;\n\n up_heap(nr_heap, heap, weights);\n\n }\n\n\n\n /* Build the tree */\n\n while (nr_heap > 1) {\n\n node1 = heap[1];\n\n heap[1] = heap[nr_heap--];\n\n\n\n down_heap(nr_heap, heap, weights);\n\n\n\n node2 = heap[1];\n\n heap[1] = heap[nr_heap--];\n\n\n\n down_heap(nr_heap, heap, weights);\n\n\n\n nr_nodes++;\n\n\n\n parents[node1] = parents[node2] = nr_nodes;\n\n weights[nr_nodes] = add_weights(weights[node1], weights[node2]);\n\n parents[nr_nodes] = -1;\n\n\n\n heap[++nr_heap] = nr_nodes;\n\n\n\n up_heap(nr_heap, heap, weights);\n\n }\n\n\n\n /* Generate lengths */\n\n for (i = 1; i <= 256; i++) {\n\n j = 0;\n\n k = i;\n\n\n\n while (parents[k] >= 0) {\n\n k = parents[k];\n\n j++;\n\n }\n\n\n\n lengths[i - 1] = j;\n\n }\n\n}\n", + "output": "1", + "index": 12922 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_parse_invalid_path(void)\n\n{\n\n g_test_trap_subprocess (\"/logging/parse_invalid_path/subprocess\", 0, 0);\n\n g_test_trap_assert_passed();\n\n g_test_trap_assert_stdout(\"\");\n\n g_test_trap_assert_stderr(\"Bad logfile format: /tmp/qemu-%d%d.log\\n\");\n\n}\n", + "output": "1", + "index": 7279 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const char *addr2str(target_phys_addr_t addr)\n\n{\n\n return nr2str(ehci_mmio_names, ARRAY_SIZE(ehci_mmio_names), addr);\n\n}\n", + "output": "1", + "index": 14187 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t bonito_pciconf_readl(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n\n\n PCIBonitoState *s = opaque;\n\n PCIDevice *d = PCI_DEVICE(s);\n\n\n\n DPRINTF(\"bonito_pciconf_readl \"TARGET_FMT_plx\"\\n\", addr);\n\n return d->config_read(d, addr, 4);\n\n}\n", + "output": "0", + "index": 2521 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t pxa2xx_ssp_read(void *opaque, hwaddr addr,\n\n unsigned size)\n\n{\n\n PXA2xxSSPState *s = (PXA2xxSSPState *) opaque;\n\n uint32_t retval;\n\n\n\n switch (addr) {\n\n case SSCR0:\n\n return s->sscr[0];\n\n case SSCR1:\n\n return s->sscr[1];\n\n case SSPSP:\n\n return s->sspsp;\n\n case SSTO:\n\n return s->ssto;\n\n case SSITR:\n\n return s->ssitr;\n\n case SSSR:\n\n return s->sssr | s->ssitr;\n\n case SSDR:\n\n if (!s->enable)\n\n return 0xffffffff;\n\n if (s->rx_level < 1) {\n\n printf(\"%s: SSP Rx Underrun\\n\", __FUNCTION__);\n\n return 0xffffffff;\n\n }\n\n s->rx_level --;\n\n retval = s->rx_fifo[s->rx_start ++];\n\n s->rx_start &= 0xf;\n\n pxa2xx_ssp_fifo_update(s);\n\n return retval;\n\n case SSTSA:\n\n return s->sstsa;\n\n case SSRSA:\n\n return s->ssrsa;\n\n case SSTSS:\n\n return 0;\n\n case SSACD:\n\n return s->ssacd;\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": 11139 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void do_info_migrate(Monitor *mon, QObject **ret_data)\n\n{\n\n QDict *qdict;\n\n MigrationState *s = current_migration;\n\n\n\n if (s) {\n\n switch (s->get_status(s)) {\n\n case MIG_STATE_ACTIVE:\n\n qdict = qdict_new();\n\n qdict_put(qdict, \"status\", qstring_from_str(\"active\"));\n\n\n\n migrate_put_status(qdict, \"ram\", ram_bytes_transferred(),\n\n ram_bytes_remaining(), ram_bytes_total());\n\n\n\n if (blk_mig_active()) {\n\n migrate_put_status(qdict, \"disk\", blk_mig_bytes_transferred(),\n\n blk_mig_bytes_remaining(),\n\n blk_mig_bytes_total());\n\n }\n\n\n\n *ret_data = QOBJECT(qdict);\n\n break;\n\n case MIG_STATE_COMPLETED:\n\n *ret_data = qobject_from_jsonf(\"{ 'status': 'completed' }\");\n\n break;\n\n case MIG_STATE_ERROR:\n\n *ret_data = qobject_from_jsonf(\"{ 'status': 'failed' }\");\n\n break;\n\n case MIG_STATE_CANCELLED:\n\n *ret_data = qobject_from_jsonf(\"{ 'status': 'cancelled' }\");\n\n break;\n\n }\n\n assert(*ret_data != NULL);\n\n }\n\n}\n", + "output": "0", + "index": 3008 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int encrypt_sectors(BDRVQcowState *s, int64_t sector_num,\n\n uint8_t *buf, int nb_sectors, bool enc,\n\n Error **errp)\n\n{\n\n union {\n\n uint64_t ll[2];\n\n uint8_t b[16];\n\n } ivec;\n\n int i;\n\n int ret;\n\n\n\n for(i = 0; i < nb_sectors; i++) {\n\n ivec.ll[0] = cpu_to_le64(sector_num);\n\n ivec.ll[1] = 0;\n\n if (qcrypto_cipher_setiv(s->cipher,\n\n ivec.b, G_N_ELEMENTS(ivec.b),\n\n errp) < 0) {\n\n return -1;\n\n }\n\n if (enc) {\n\n ret = qcrypto_cipher_encrypt(s->cipher,\n\n buf, buf,\n\n 512,\n\n errp);\n\n } else {\n\n ret = qcrypto_cipher_decrypt(s->cipher,\n\n buf, buf,\n\n 512,\n\n errp);\n\n }\n\n if (ret < 0) {\n\n return -1;\n\n }\n\n sector_num++;\n\n buf += 512;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 26068 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ahci_write_fis_sdb(AHCIState *s, int port, uint32_t finished)\n\n{\n\n AHCIPortRegs *pr = &s->dev[port].port_regs;\n\n IDEState *ide_state;\n\n uint8_t *sdb_fis;\n\n\n\n if (!s->dev[port].res_fis ||\n\n !(pr->cmd & PORT_CMD_FIS_RX)) {\n\n return;\n\n }\n\n\n\n sdb_fis = &s->dev[port].res_fis[RES_FIS_SDBFIS];\n\n ide_state = &s->dev[port].port.ifs[0];\n\n\n\n /* clear memory */\n\n *(uint32_t*)sdb_fis = 0;\n\n\n\n /* write values */\n\n sdb_fis[0] = ide_state->error;\n\n sdb_fis[2] = ide_state->status & 0x77;\n\n s->dev[port].finished |= finished;\n\n *(uint32_t*)(sdb_fis + 4) = cpu_to_le32(s->dev[port].finished);\n\n\n\n ahci_trigger_irq(s, &s->dev[port], PORT_IRQ_SDB_FIS);\n\n}\n", + "output": "1", + "index": 26641 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mmu_translate_segment(CPUS390XState *env, target_ulong vaddr,\n\n uint64_t asc, uint64_t st_entry,\n\n target_ulong *raddr, int *flags, int rw)\n\n{\n\n CPUState *cs = CPU(s390_env_get_cpu(env));\n\n uint64_t origin, offs, pt_entry;\n\n\n\n if (st_entry & _SEGMENT_ENTRY_RO) {\n\n *flags &= ~PAGE_WRITE;\n\n }\n\n\n\n if ((st_entry & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) {\n\n /* Decode EDAT1 segment frame absolute address (1MB page) */\n\n *raddr = (st_entry & 0xfffffffffff00000ULL) | (vaddr & 0xfffff);\n\n PTE_DPRINTF(\"%s: SEG=0x%\" PRIx64 \"\\n\", __func__, st_entry);\n\n return 0;\n\n }\n\n\n\n /* Look up 4KB page entry */\n\n origin = st_entry & _SEGMENT_ENTRY_ORIGIN;\n\n offs = (vaddr & VADDR_PX) >> 9;\n\n pt_entry = ldq_phys(cs->as, origin + offs);\n\n PTE_DPRINTF(\"%s: 0x%\" PRIx64 \" + 0x%\" PRIx64 \" => 0x%016\" PRIx64 \"\\n\",\n\n __func__, origin, offs, pt_entry);\n\n return mmu_translate_pte(env, vaddr, asc, pt_entry, raddr, flags, rw);\n\n}\n", + "output": "0", + "index": 14238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int array_roll(array_t* array,int index_to,int index_from,int count)\n\n{\n\n char* buf;\n\n char* from;\n\n char* to;\n\n int is;\n\n\n\n if(!array ||\n\n\t index_to<0 || index_to>=array->next ||\n\n\t index_from<0 || index_from>=array->next)\n\n\treturn -1;\n\n\n\n if(index_to==index_from)\n\n\treturn 0;\n\n\n\n is=array->item_size;\n\n from=array->pointer+index_from*is;\n\n to=array->pointer+index_to*is;\n\n buf=g_malloc(is*count);\n\n memcpy(buf,from,is*count);\n\n\n\n if(index_toformats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count,\n\n b->format_count));\n\n for(i = 0; i < a->format_count; i ++)\n\n for(j = 0; j < b->format_count; j ++)\n\n if(a->formats[i] == b->formats[j])\n\n ret->formats[k++] = a->formats[i];\n\n\n\n /* check that there was at least one common format */\n\n if(!(ret->format_count = k)) {\n\n av_free(ret->formats);\n\n av_free(ret);\n\n return NULL;\n\n }\n\n\n\n /* merge and update all the references */\n\n ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));\n\n for(i = 0; i < a->refcount; i ++) {\n\n ret->refs[ret->refcount] = a->refs[i];\n\n *ret->refs[ret->refcount++] = ret;\n\n }\n\n for(i = 0; i < b->refcount; i ++) {\n\n ret->refs[ret->refcount] = b->refs[i];\n\n *ret->refs[ret->refcount++] = ret;\n\n }\n\n\n\n av_free(a->refs);\n\n av_free(a->formats);\n\n av_free(a);\n\n\n\n av_free(b->refs);\n\n av_free(b->formats);\n\n av_free(b);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 21710 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void run_block_job(BlockJob *job, Error **errp)\n\n{\n\n AioContext *aio_context = blk_get_aio_context(job->blk);\n\n\n\n /* FIXME In error cases, the job simply goes away and we access a dangling\n\n * pointer below. */\n\n aio_context_acquire(aio_context);\n\n do {\n\n aio_poll(aio_context, true);\n\n qemu_progress_print(job->len ?\n\n ((float)job->offset / job->len * 100.f) : 0.0f, 0);\n\n } while (!job->ready);\n\n\n\n block_job_complete_sync(job, errp);\n\n aio_context_release(aio_context);\n\n\n\n /* A block job may finish instantaneously without publishing any progress,\n\n * so just signal completion here */\n\n qemu_progress_print(100.f, 0);\n\n}\n", + "output": "1", + "index": 3402 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t uart_read(void *opaque, target_phys_addr_t offset,\n\n unsigned size)\n\n{\n\n UartState *s = (UartState *)opaque;\n\n uint32_t c = 0;\n\n\n\n offset >>= 2;\n\n if (offset > R_MAX) {\n\n return 0;\n\n } else if (offset == R_TX_RX) {\n\n uart_read_rx_fifo(s, &c);\n\n return c;\n\n }\n\n return s->r[offset];\n\n}\n", + "output": "1", + "index": 14246 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign,\n\n bool with_irqfd)\n\n{\n\n VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);\n\n VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);\n\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n\n VirtQueue *vq = virtio_get_queue(vdev, n);\n\n EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);\n\n\n\n if (assign) {\n\n int r = event_notifier_init(notifier, 0);\n\n if (r < 0) {\n\n return r;\n\n }\n\n virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);\n\n } else {\n\n virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);\n\n event_notifier_cleanup(notifier);\n\n }\n\n\n\n if (vdc->guest_notifier_mask) {\n\n vdc->guest_notifier_mask(vdev, n, !assign);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 18607 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,\n\n const char *model,\n\n const char *name,\n\n int fd, int is_connected)\n\n{\n\n struct sockaddr_in saddr;\n\n int newfd;\n\n socklen_t saddr_len;\n\n VLANClientState *nc;\n\n NetSocketState *s;\n\n\n\n /* fd passed: multicast: \"learn\" dgram_dst address from bound address and save it\n\n * Because this may be \"shared\" socket from a \"master\" process, datagrams would be recv()\n\n * by ONLY ONE process: we must \"clone\" this dgram socket --jjo\n\n */\n\n\n\n if (is_connected) {\n\n if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {\n\n /* must be bound */\n\n if (saddr.sin_addr.s_addr == 0) {\n\n fprintf(stderr, \"qemu: error: init_dgram: fd=%d unbound, \"\n\n \"cannot setup multicast dst addr\\n\", fd);\n\n return NULL;\n\n }\n\n /* clone dgram socket */\n\n newfd = net_socket_mcast_create(&saddr, NULL);\n\n if (newfd < 0) {\n\n /* error already reported by net_socket_mcast_create() */\n\n close(fd);\n\n return NULL;\n\n }\n\n /* clone newfd to fd, close newfd */\n\n dup2(newfd, fd);\n\n close(newfd);\n\n\n\n } else {\n\n fprintf(stderr,\n\n \"qemu: error: init_dgram: fd=%d failed getsockname(): %s\\n\",\n\n fd, strerror(errno));\n\n return NULL;\n\n }\n\n }\n\n\n\n nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name);\n\n\n\n snprintf(nc->info_str, sizeof(nc->info_str),\n\n \"socket: fd=%d (%s mcast=%s:%d)\",\n\n fd, is_connected ? \"cloned\" : \"\",\n\n inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));\n\n\n\n s = DO_UPCAST(NetSocketState, nc, nc);\n\n\n\n s->fd = fd;\n\n\n\n qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);\n\n\n\n /* mcast: save bound address as dst */\n\n if (is_connected) s->dgram_dst=saddr;\n\n\n\n return s;\n\n}\n", + "output": "1", + "index": 493 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "eth_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t val64, unsigned int size)\n\n{\n\n\tstruct fs_eth *eth = opaque;\n\n\tuint32_t value = val64;\n\n\n\n\taddr >>= 2;\n\n\tswitch (addr)\n\n\t{\n\n\t\tcase RW_MA0_LO:\n\n\t\tcase RW_MA0_HI:\n\n\t\t\teth->regs[addr] = value;\n\n\t\t\teth_update_ma(eth, 0);\n\n\t\t\tbreak;\n\n\t\tcase RW_MA1_LO:\n\n\t\tcase RW_MA1_HI:\n\n\t\t\teth->regs[addr] = value;\n\n\t\t\teth_update_ma(eth, 1);\n\n\t\t\tbreak;\n\n\n\n\t\tcase RW_MGM_CTRL:\n\n\t\t\t/* Attach an MDIO/PHY abstraction. */\n\n\t\t\tif (value & 2)\n\n\t\t\t\teth->mdio_bus.mdio = value & 1;\n\n\t\t\tif (eth->mdio_bus.mdc != (value & 4)) {\n\n\t\t\t\tmdio_cycle(ð->mdio_bus);\n\n\t\t\t\teth_validate_duplex(eth);\n\n\t\t\t}\n\n\t\t\teth->mdio_bus.mdc = !!(value & 4);\n\n\t\t\teth->regs[addr] = value;\n\n\t\t\tbreak;\n\n\n\n\t\tcase RW_REC_CTRL:\n\n\t\t\teth->regs[addr] = value;\n\n\t\t\teth_validate_duplex(eth);\n\n\t\t\tbreak;\n\n\n\n\t\tdefault:\n\n\t\t\teth->regs[addr] = value;\n\n\t\t\tD(printf (\"%s %x %x\\n\",\n\n\t\t\t\t __func__, addr, value));\n\n\t\t\tbreak;\n\n\t}\n\n}\n", + "output": "0", + "index": 20208 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static BlockAIOCB *inject_error(BlockDriverState *bs,\n\n BlockCompletionFunc *cb, void *opaque, BlkdebugRule *rule)\n\n{\n\n BDRVBlkdebugState *s = bs->opaque;\n\n int error = rule->options.inject.error;\n\n struct BlkdebugAIOCB *acb;\n\n QEMUBH *bh;\n\n\n\n if (rule->options.inject.once) {\n\n QSIMPLEQ_INIT(&s->active_rules);\n\n }\n\n\n\n if (rule->options.inject.immediately) {\n\n return NULL;\n\n }\n\n\n\n acb = qemu_aio_get(&blkdebug_aiocb_info, bs, cb, opaque);\n\n acb->ret = -error;\n\n\n\n bh = aio_bh_new(bdrv_get_aio_context(bs), error_callback_bh, acb);\n\n acb->bh = bh;\n\n qemu_bh_schedule(bh);\n\n\n\n return &acb->common;\n\n}\n", + "output": "1", + "index": 15561 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v210_read_header(AVFormatContext *ctx)\n\n{\n\n V210DemuxerContext *s = ctx->priv_data;\n\n AVStream *st;\n\n\n\n st = avformat_new_stream(ctx, NULL);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n st->codec->codec_type = AVMEDIA_TYPE_VIDEO;\n\n\n\n st->codec->codec_id = ctx->iformat->raw_codec_id;\n\n\n\n avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);\n\n\n\n st->codec->width = s->width;\n\n st->codec->height = s->height;\n\n st->codec->pix_fmt = ctx->iformat->raw_codec_id == AV_CODEC_ID_V210 ?\n\n AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV422P16;\n\n st->codec->bit_rate = av_rescale_q(GET_PACKET_SIZE(s->width, s->height),\n\n (AVRational){8,1}, st->time_base);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17841 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t expr_unary(Monitor *mon)\n\n{\n\n int64_t n;\n\n char *p;\n\n int ret;\n\n\n\n switch(*pch) {\n\n case '+':\n\n next();\n\n n = expr_unary(mon);\n\n break;\n\n case '-':\n\n next();\n\n n = -expr_unary(mon);\n\n break;\n\n case '~':\n\n next();\n\n n = ~expr_unary(mon);\n\n break;\n\n case '(':\n\n next();\n\n n = expr_sum(mon);\n\n if (*pch != ')') {\n\n expr_error(mon, \"')' expected\");\n\n }\n\n next();\n\n break;\n\n case '\\'':\n\n pch++;\n\n if (*pch == '\\0')\n\n expr_error(mon, \"character constant expected\");\n\n n = *pch;\n\n pch++;\n\n if (*pch != '\\'')\n\n expr_error(mon, \"missing terminating \\' character\");\n\n next();\n\n break;\n\n case '$':\n\n {\n\n char buf[128], *q;\n\n target_long reg=0;\n\n\n\n pch++;\n\n q = buf;\n\n while ((*pch >= 'a' && *pch <= 'z') ||\n\n (*pch >= 'A' && *pch <= 'Z') ||\n\n (*pch >= '0' && *pch <= '9') ||\n\n *pch == '_' || *pch == '.') {\n\n if ((q - buf) < sizeof(buf) - 1)\n\n *q++ = *pch;\n\n pch++;\n\n }\n\n while (qemu_isspace(*pch))\n\n pch++;\n\n *q = 0;\n\n ret = get_monitor_def(®, buf);\n\n if (ret < 0)\n\n expr_error(mon, \"unknown register\");\n\n n = reg;\n\n }\n\n break;\n\n case '\\0':\n\n expr_error(mon, \"unexpected end of expression\");\n\n n = 0;\n\n break;\n\n default:\n\n errno = 0;\n\n n = strtoull(pch, &p, 0);\n\n if (errno == ERANGE) {\n\n expr_error(mon, \"number too large\");\n\n }\n\n if (pch == p) {\n\n expr_error(mon, \"invalid char in expression\");\n\n }\n\n pch = p;\n\n while (qemu_isspace(*pch))\n\n pch++;\n\n break;\n\n }\n\n return n;\n\n}\n", + "output": "0", + "index": 27240 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static QObject *parse_object(JSONParserContext *ctxt, QList **tokens, va_list *ap)\n\n{\n\n QDict *dict = NULL;\n\n QObject *token, *peek;\n\n QList *working = qlist_copy(*tokens);\n\n\n\n token = qlist_pop(working);\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 qobject_decref(token);\n\n token = NULL;\n\n\n\n dict = qdict_new();\n\n\n\n peek = qlist_peek(working);\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, &working, ap) == -1) {\n\n goto out;\n\n }\n\n\n\n token = qlist_pop(working);\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 qobject_decref(token);\n\n token = NULL;\n\n\n\n if (parse_pair(ctxt, dict, &working, ap) == -1) {\n\n goto out;\n\n }\n\n\n\n token = qlist_pop(working);\n\n if (token == NULL) {\n\n parse_error(ctxt, NULL, \"premature EOI\");\n\n goto out;\n\n }\n\n }\n\n qobject_decref(token);\n\n token = NULL;\n\n } else {\n\n token = qlist_pop(working);\n\n qobject_decref(token);\n\n token = NULL;\n\n }\n\n\n\n QDECREF(*tokens);\n\n *tokens = working;\n\n\n\n return QOBJECT(dict);\n\n\n\nout:\n\n qobject_decref(token);\n\n QDECREF(working);\n\n QDECREF(dict);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 15643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void inner_add_yblock_bw_16_obmc_32_mmx(const uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,\n\n int src_x, int src_y, long src_stride, slice_buffer * sb, int add, uint8_t * dst8){\n\nsnow_inner_add_yblock_mmx_header\n\nsnow_inner_add_yblock_mmx_start(\"mm1\", \"mm5\", \"3\", \"0\", \"0\")\n\nsnow_inner_add_yblock_mmx_accum(\"2\", \"16\", \"0\")\n\nsnow_inner_add_yblock_mmx_accum(\"1\", \"512\", \"0\")\n\nsnow_inner_add_yblock_mmx_accum(\"0\", \"528\", \"0\")\n\nsnow_inner_add_yblock_mmx_mix(\"0\", \"0\")\n\n\n\nsnow_inner_add_yblock_mmx_start(\"mm1\", \"mm5\", \"3\", \"8\", \"8\")\n\nsnow_inner_add_yblock_mmx_accum(\"2\", \"24\", \"8\")\n\nsnow_inner_add_yblock_mmx_accum(\"1\", \"520\", \"8\")\n\nsnow_inner_add_yblock_mmx_accum(\"0\", \"536\", \"8\")\n\nsnow_inner_add_yblock_mmx_mix(\"32\", \"8\")\n\nsnow_inner_add_yblock_mmx_end(\"32\")\n\n}\n", + "output": "1", + "index": 21036 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_setup_guest_memory(void *start, size_t size)\n\n{\n\n if (!kvm_has_sync_mmu()) {\n\n#ifdef MADV_DONTFORK\n\n int ret = madvise(start, size, MADV_DONTFORK);\n\n\n\n if (ret) {\n\n perror(\"madvice\");\n\n exit(1);\n\n }\n\n#else\n\n fprintf(stderr,\n\n \"Need MADV_DONTFORK in absence of synchronous KVM MMU\\n\");\n\n exit(1);\n\n#endif\n\n }\n\n}\n", + "output": "1", + "index": 24774 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)\n\n{\n\n int fill_char = 0x00;\n\n if (sample_fmt == AV_SAMPLE_FMT_U8)\n\n fill_char = 0x80;\n\n memset(buf, fill_char, size);\n\n}\n", + "output": "1", + "index": 22164 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvmclock_pre_save(void *opaque)\n\n{\n\n KVMClockState *s = opaque;\n\n struct kvm_clock_data data;\n\n int ret;\n\n\n\n if (s->clock_valid) {\n\n return;\n\n }\n\n ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);\n\n if (ret < 0) {\n\n fprintf(stderr, \"KVM_GET_CLOCK failed: %s\\n\", strerror(ret));\n\n data.clock = 0;\n\n }\n\n s->clock = data.clock;\n\n /*\n\n * If the VM is stopped, declare the clock state valid to avoid re-reading\n\n * it on next vmsave (which would return a different value). Will be reset\n\n * when the VM is continued.\n\n */\n\n s->clock_valid = !runstate_is_running();\n\n}\n", + "output": "1", + "index": 1046 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_pixman_get_type(int rshift, int gshift, int bshift)\n\n{\n\n int type = PIXMAN_TYPE_OTHER;\n\n\n\n if (rshift > gshift && gshift > bshift) {\n\n if (bshift == 0) {\n\n type = PIXMAN_TYPE_ARGB;\n\n } else {\n\n\n type = PIXMAN_TYPE_RGBA;\n\n\n }\n\n } else if (rshift < gshift && gshift < bshift) {\n\n if (rshift == 0) {\n\n type = PIXMAN_TYPE_ABGR;\n\n } else {\n\n\n type = PIXMAN_TYPE_BGRA;\n\n\n }\n\n }\n\n return type;\n\n}", + "output": "1", + "index": 24274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint64_t vtd_get_slpte_addr(uint64_t slpte)\n\n{\n\n return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH);\n\n}\n", + "output": "0", + "index": 18237 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,\n\n VncBasicInfo *info,\n\n Error **errp)\n\n{\n\n SocketAddress *addr = NULL;\n\n\n\n if (!ioc) {\n\n error_setg(errp, \"No listener socket available\");\n\n return;\n\n }\n\n\n\n addr = qio_channel_socket_get_local_address(ioc, errp);\n\n if (!addr) {\n\n return;\n\n }\n\n\n\n vnc_init_basic_info(addr, info, errp);\n\n qapi_free_SocketAddress(addr);\n\n}\n", + "output": "0", + "index": 2541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void kvm_apic_mem_write(void *opaque, target_phys_addr_t addr,\n\n uint64_t data, unsigned size)\n\n{\n\n MSIMessage msg = { .address = addr, .data = data };\n\n int ret;\n\n\n\n ret = kvm_irqchip_send_msi(kvm_state, msg);\n\n if (ret < 0) {\n\n fprintf(stderr, \"KVM: injection failed, MSI lost (%s)\\n\",\n\n strerror(-ret));\n\n }\n\n}\n", + "output": "0", + "index": 15969 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void timerlistgroup_deinit(QEMUTimerListGroup *tlg)\n\n{\n\n QEMUClockType type;\n\n for (type = 0; type < QEMU_CLOCK_MAX; type++) {\n\n timerlist_free(tlg->tl[type]);\n\n }\n\n}\n", + "output": "0", + "index": 4957 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type, uint8_t port)\n\n{\n\n /* PCIe cap v2 init */\n\n int pos;\n\n uint8_t *exp_cap;\n\n\n\n assert(pci_is_express(dev));\n\n\n\n pos = pci_add_capability(dev, PCI_CAP_ID_EXP, offset, PCI_EXP_VER2_SIZEOF);\n\n if (pos < 0) {\n\n return pos;\n\n }\n\n dev->exp.exp_cap = pos;\n\n exp_cap = dev->config + pos;\n\n\n\n /* Filling values common with v1 */\n\n pcie_cap_v1_fill(exp_cap, port, type, PCI_EXP_FLAGS_VER2);\n\n\n\n /* Filling v2 specific values */\n\n pci_set_long(exp_cap + PCI_EXP_DEVCAP2,\n\n PCI_EXP_DEVCAP2_EFF | PCI_EXP_DEVCAP2_EETLPP);\n\n\n\n pci_set_word(dev->wmask + pos + PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_EETLPPB);\n\n return pos;\n\n}\n", + "output": "1", + "index": 3542 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void migrate_compress_threads_create(void)\n\n{\n\n int i, thread_count;\n\n\n\n if (!migrate_use_compression()) {\n\n return;\n\n }\n\n quit_comp_thread = false;\n\n compression_switch = true;\n\n thread_count = migrate_compress_threads();\n\n compress_threads = g_new0(QemuThread, thread_count);\n\n comp_param = g_new0(CompressParam, thread_count);\n\n comp_done_cond = g_new0(QemuCond, 1);\n\n comp_done_lock = g_new0(QemuMutex, 1);\n\n qemu_cond_init(comp_done_cond);\n\n qemu_mutex_init(comp_done_lock);\n\n for (i = 0; i < thread_count; i++) {\n\n /* com_param[i].file is just used as a dummy buffer to save data, set\n\n * it's ops to empty.\n\n */\n\n comp_param[i].file = qemu_fopen_ops(NULL, &empty_ops);\n\n comp_param[i].done = true;\n\n qemu_mutex_init(&comp_param[i].mutex);\n\n qemu_cond_init(&comp_param[i].cond);\n\n qemu_thread_create(compress_threads + i, \"compress\",\n\n do_data_compress, comp_param + i,\n\n QEMU_THREAD_JOINABLE);\n\n }\n\n}\n", + "output": "0", + "index": 21875 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qtest_add_func(const char *str, void (*fn))\n\n{\n\n gchar *path = g_strdup_printf(\"/%s/%s\", qtest_get_arch(), str);\n\n g_test_add_func(path, fn);\n\n\n}", + "output": "1", + "index": 2306 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pl061_register_devices(void)\n\n{\n\n sysbus_register_dev(\"pl061\", sizeof(pl061_state),\n\n pl061_init_arm);\n\n sysbus_register_dev(\"pl061_luminary\", sizeof(pl061_state),\n\n pl061_init_luminary);\n\n}\n", + "output": "0", + "index": 510 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void cris_cpu_class_init(ObjectClass *oc, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(oc);\n\n CPUClass *cc = CPU_CLASS(oc);\n\n CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);\n\n\n\n ccc->parent_realize = dc->realize;\n\n dc->realize = cris_cpu_realizefn;\n\n\n\n ccc->parent_reset = cc->reset;\n\n cc->reset = cris_cpu_reset;\n\n\n\n cc->class_by_name = cris_cpu_class_by_name;\n\n cc->has_work = cris_cpu_has_work;\n\n cc->do_interrupt = cris_cpu_do_interrupt;\n\n cc->cpu_exec_interrupt = cris_cpu_exec_interrupt;\n\n cc->dump_state = cris_cpu_dump_state;\n\n cc->set_pc = cris_cpu_set_pc;\n\n cc->gdb_read_register = cris_cpu_gdb_read_register;\n\n cc->gdb_write_register = cris_cpu_gdb_write_register;\n\n#ifdef CONFIG_USER_ONLY\n\n cc->handle_mmu_fault = cris_cpu_handle_mmu_fault;\n\n#else\n\n cc->get_phys_page_debug = cris_cpu_get_phys_page_debug;\n\n dc->vmsd = &vmstate_cris_cpu;\n\n#endif\n\n\n\n cc->gdb_num_core_regs = 49;\n\n cc->gdb_stop_before_watchpoint = true;\n\n\n\n cc->disas_set_info = cris_disas_set_info;\n\n\n\n /*\n\n * Reason: cris_cpu_initfn() calls cpu_exec_init(), which saves\n\n * the object in cpus -> dangling pointer after final\n\n * object_unref().\n\n */\n\n dc->cannot_destroy_with_object_finalize_yet = true;\n\n}\n", + "output": "1", + "index": 22441 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "qio_channel_socket_accept(QIOChannelSocket *ioc,\n\n Error **errp)\n\n{\n\n QIOChannelSocket *cioc;\n\n\n\n cioc = QIO_CHANNEL_SOCKET(object_new(TYPE_QIO_CHANNEL_SOCKET));\n\n cioc->fd = -1;\n\n cioc->remoteAddrLen = sizeof(ioc->remoteAddr);\n\n cioc->localAddrLen = sizeof(ioc->localAddr);\n\n\n\n#ifdef WIN32\n\n QIO_CHANNEL(cioc)->event = CreateEvent(NULL, FALSE, FALSE, NULL);\n\n#endif\n\n\n\n\n\n retry:\n\n trace_qio_channel_socket_accept(ioc);\n\n cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr,\n\n &cioc->remoteAddrLen);\n\n if (cioc->fd < 0) {\n\n trace_qio_channel_socket_accept_fail(ioc);\n\n if (errno == EINTR) {\n\n goto retry;\n\n }\n\n goto error;\n\n }\n\n\n\n if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr,\n\n &cioc->localAddrLen) < 0) {\n\n error_setg_errno(errp, errno,\n\n \"Unable to query local socket address\");\n\n goto error;\n\n }\n\n\n\n#ifndef WIN32\n\n if (cioc->localAddr.ss_family == AF_UNIX) {\n\n QIOChannel *ioc_local = QIO_CHANNEL(cioc);\n\n qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS);\n\n }\n\n#endif /* WIN32 */\n\n\n\n trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd);\n\n return cioc;\n\n\n\n error:\n\n object_unref(OBJECT(cioc));\n\n return NULL;\n\n}\n", + "output": "0", + "index": 7875 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int v9fs_do_mksock(V9fsState *s, V9fsString *path)\n\n{\n\n return s->ops->mksock(&s->ctx, path->data);\n\n}\n", + "output": "0", + "index": 3255 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,\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 > (UINT_MAX >> BDRV_SECTOR_BITS)) {\n\n return -EINVAL;\n\n }\n\n\n\n return bdrv_co_do_preadv(bs, sector_num << BDRV_SECTOR_BITS,\n\n nb_sectors << BDRV_SECTOR_BITS, qiov, flags);\n\n}\n", + "output": "0", + "index": 9263 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cow_read(BlockDriverState *bs, int64_t sector_num,\n\n uint8_t *buf, int nb_sectors)\n\n{\n\n BDRVCowState *s = bs->opaque;\n\n int ret, n;\n\n\n\n while (nb_sectors > 0) {\n\n if (cow_is_allocated(bs, sector_num, nb_sectors, &n)) {\n\n ret = bdrv_pread(bs->file,\n\n s->cow_sectors_offset + sector_num * 512,\n\n buf, n * 512);\n\n if (ret != n * 512)\n\n return -1;\n\n } else {\n\n if (bs->backing_hd) {\n\n /* read from the base image */\n\n ret = bdrv_read(bs->backing_hd, sector_num, buf, n);\n\n if (ret < 0)\n\n return -1;\n\n } else {\n\n memset(buf, 0, n * 512);\n\n }\n\n }\n\n nb_sectors -= n;\n\n sector_num += n;\n\n buf += n * 512;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 7540 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_tlbia(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 gen_helper_tlbia(cpu_env);\n\n#endif\n\n}\n", + "output": "1", + "index": 23995 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pc_cpu_plug(HotplugHandler *hotplug_dev,\n\n DeviceState *dev, Error **errp)\n\n{\n\n CPUArchId *found_cpu;\n\n HotplugHandlerClass *hhc;\n\n Error *local_err = NULL;\n\n PCMachineState *pcms = PC_MACHINE(hotplug_dev);\n\n\n\n if (pcms->acpi_dev) {\n\n hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);\n\n hhc->plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n }\n\n\n\n /* increment the number of CPUs */\n\n pcms->boot_cpus++;\n\n if (dev->hotplugged) {\n\n rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus);\n\n fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);\n\n }\n\n\n\n found_cpu = pc_find_cpu_slot(pcms, CPU(dev), NULL);\n\n found_cpu->cpu = CPU(dev);\n\nout:\n\n error_propagate(errp, local_err);\n\n}\n", + "output": "1", + "index": 14455 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static subpage_t *subpage_init(target_phys_addr_t base)\n\n{\n\n subpage_t *mmio;\n\n\n\n mmio = g_malloc0(sizeof(subpage_t));\n\n\n\n mmio->base = base;\n\n memory_region_init_io(&mmio->iomem, &subpage_ops, mmio,\n\n \"subpage\", TARGET_PAGE_SIZE);\n\n mmio->iomem.subpage = true;\n\n#if defined(DEBUG_SUBPAGE)\n\n printf(\"%s: %p base \" TARGET_FMT_plx \" len %08x %d\\n\", __func__,\n\n mmio, base, TARGET_PAGE_SIZE, subpage_memory);\n\n#endif\n\n subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, phys_section_unassigned);\n\n\n\n return mmio;\n\n}\n", + "output": "0", + "index": 16077 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_chr_open_pipe(QemuOpts *opts, CharDriverState **_chr)\n\n{\n\n int fd_in, fd_out;\n\n char filename_in[256], filename_out[256];\n\n const char *filename = qemu_opt_get(opts, \"path\");\n\n\n\n if (filename == NULL) {\n\n fprintf(stderr, \"chardev: pipe: no filename given\\n\");\n\n return -EINVAL;\n\n }\n\n\n\n snprintf(filename_in, 256, \"%s.in\", filename);\n\n snprintf(filename_out, 256, \"%s.out\", filename);\n\n TFR(fd_in = qemu_open(filename_in, O_RDWR | O_BINARY));\n\n TFR(fd_out = qemu_open(filename_out, O_RDWR | O_BINARY));\n\n if (fd_in < 0 || fd_out < 0) {\n\n\tif (fd_in >= 0)\n\n\t close(fd_in);\n\n\tif (fd_out >= 0)\n\n\t close(fd_out);\n\n TFR(fd_in = fd_out = qemu_open(filename, O_RDWR | O_BINARY));\n\n if (fd_in < 0) {\n\n return -errno;\n\n }\n\n }\n\n\n\n *_chr = qemu_chr_open_fd(fd_in, fd_out);\n\n return 0;\n\n}\n", + "output": "1", + "index": 12348 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint16_t mipsdsp_sub_i16(int16_t a, int16_t b, CPUMIPSState *env)\n\n{\n\n int16_t temp;\n\n\n\n temp = a - b;\n\n if (MIPSDSP_OVERFLOW(a, -b, temp, 0x8000)) {\n\n set_DSPControl_overflow_flag(1, 20, env);\n\n }\n\n\n\n return temp;\n\n}\n", + "output": "1", + "index": 14298 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void usbredir_iso_packet(void *priv, uint64_t id,\n\n struct usb_redir_iso_packet_header *iso_packet,\n\n uint8_t *data, int data_len)\n\n{\n\n USBRedirDevice *dev = priv;\n\n uint8_t ep = iso_packet->endpoint;\n\n\n\n DPRINTF2(\"iso-in status %d ep %02X len %d id %\"PRIu64\"\\n\",\n\n iso_packet->status, ep, data_len, id);\n\n\n\n if (dev->endpoint[EP2I(ep)].type != USB_ENDPOINT_XFER_ISOC) {\n\n ERROR(\"received iso packet for non iso endpoint %02X\\n\", ep);\n\n free(data);\n\n return;\n\n }\n\n\n\n if (dev->endpoint[EP2I(ep)].iso_started == 0) {\n\n DPRINTF(\"received iso packet for non started stream 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, iso_packet->status, ep);\n\n}\n", + "output": "1", + "index": 11756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint8_t get_tlm(Jpeg2000DecoderContext *s, int n)\n\n{\n\n uint8_t Stlm, ST, SP, tile_tlm, i;\n\n bytestream_get_byte(&s->buf); /* Ztlm: skipped */\n\n Stlm = bytestream_get_byte(&s->buf);\n\n\n\n // too complex ? ST = ((Stlm >> 4) & 0x01) + ((Stlm >> 4) & 0x02);\n\n ST = (Stlm >> 4) & 0x03;\n\n // TODO: Manage case of ST = 0b11 --> raise error\n\n SP = (Stlm >> 6) & 0x01;\n\n tile_tlm = (n - 4) / ((SP + 1) * 2 + ST);\n\n for (i = 0; i < tile_tlm; i++) {\n\n switch (ST) {\n\n case 0:\n\n break;\n\n case 1:\n\n bytestream_get_byte(&s->buf);\n\n break;\n\n case 2:\n\n bytestream_get_be16(&s->buf);\n\n break;\n\n case 3:\n\n bytestream_get_be32(&s->buf);\n\n break;\n\n }\n\n if (SP == 0) {\n\n bytestream_get_be16(&s->buf);\n\n } else {\n\n bytestream_get_be32(&s->buf);\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 8066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void put_uint8(QEMUFile *f, void *pv, size_t size)\n\n{\n\n uint8_t *v = pv;\n\n qemu_put_8s(f, v);\n\n}\n", + "output": "1", + "index": 8431 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos,\n\n int *end_pos2)\n\n{\n\n if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) {\n\n s->gb = s->in_gb;\n\n s->in_gb.buffer = NULL;\n\n assert((get_bits_count(&s->gb) & 7) == 0);\n\n skip_bits_long(&s->gb, *pos - *end_pos);\n\n *end_pos2 =\n\n *end_pos = *end_pos2 + get_bits_count(&s->gb) - *pos;\n\n *pos = get_bits_count(&s->gb);\n\n }\n\n}\n", + "output": "1", + "index": 25738 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)\n\n{\n\nPOWERPC_TBL_DECLARE(altivec_idct_put_num, 1);\n\n#ifdef ALTIVEC_USE_REFERENCE_C_CODE\n\nPOWERPC_TBL_START_COUNT(altivec_idct_put_num, 1);\n\n void simple_idct_put(uint8_t *dest, int line_size, int16_t *block);\n\n simple_idct_put(dest, stride, (int16_t*)block);\n\nPOWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1);\n\n#else /* ALTIVEC_USE_REFERENCE_C_CODE */\n\n vector_u8_t tmp;\n\n\n\nPOWERPC_TBL_START_COUNT(altivec_idct_put_num, 1);\n\n\n\n IDCT\n\n\n\n#define COPY(dest,src)\t\t\t\t\t\t\\\n\n tmp = vec_packsu (src, src);\t\t\t\t\\\n\n vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest);\t\\\n\n vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);\n\n\n\n COPY (dest, vx0)\tdest += stride;\n\n COPY (dest, vx1)\tdest += stride;\n\n COPY (dest, vx2)\tdest += stride;\n\n COPY (dest, vx3)\tdest += stride;\n\n COPY (dest, vx4)\tdest += stride;\n\n COPY (dest, vx5)\tdest += stride;\n\n COPY (dest, vx6)\tdest += stride;\n\n COPY (dest, vx7)\n\n\n\nPOWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1);\n\n#endif /* ALTIVEC_USE_REFERENCE_C_CODE */\n\n}\n", + "output": "0", + "index": 6450 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)\n\n{\n\n uint8_t *old_code_ptr = s->code_ptr;\n\n assert(ret != arg);\n\n#if TCG_TARGET_REG_BITS == 32\n\n tcg_out_op_t(s, INDEX_op_mov_i32);\n\n#else\n\n tcg_out_op_t(s, INDEX_op_mov_i64);\n\n#endif\n\n tcg_out_r(s, ret);\n\n tcg_out_r(s, arg);\n\n old_code_ptr[1] = s->code_ptr - old_code_ptr;\n\n}\n", + "output": "0", + "index": 19129 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void add_entry(TiffEncoderContext * s,\n\n enum TiffTags tag, enum TiffTypes type, int count,\n\n const void *ptr_val)\n\n{\n\n uint8_t *entries_ptr = s->entries + 12 * s->num_entries;\n\n\n\n av_assert0(s->num_entries < TIFF_MAX_ENTRY);\n\n\n\n bytestream_put_le16(&entries_ptr, tag);\n\n bytestream_put_le16(&entries_ptr, type);\n\n bytestream_put_le32(&entries_ptr, count);\n\n\n\n if (type_sizes[type] * count <= 4) {\n\n tnput(&entries_ptr, count, ptr_val, type, 0);\n\n } else {\n\n bytestream_put_le32(&entries_ptr, *s->buf - s->buf_start);\n\n check_size(s, count * type_sizes2[type]);\n\n tnput(s->buf, count, ptr_val, type, 0);\n\n }\n\n\n\n s->num_entries++;\n\n}\n", + "output": "1", + "index": 21992 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int bdrv_has_zero_init(BlockDriverState *bs)\n\n{\n\n assert(bs->drv);\n\n\n\n if (bs->drv->bdrv_has_zero_init) {\n\n return bs->drv->bdrv_has_zero_init(bs);\n\n }\n\n\n\n return 1;\n\n}\n", + "output": "1", + "index": 6153 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int find_dirty_height(VncState *vs, int y, int last_x, int x)\n\n{\n\n int h;\n\n\n\n for (h = 1; h < (vs->serverds.height - y); h++) {\n\n int tmp_x;\n\n if (!vnc_get_bit(vs->dirty_row[y + h], last_x))\n\n break;\n\n for (tmp_x = last_x; tmp_x < x; tmp_x++)\n\n vnc_clear_bit(vs->dirty_row[y + h], tmp_x);\n\n }\n\n\n\n return h;\n\n}\n", + "output": "1", + "index": 18194 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dec_sextb(DisasContext *dc)\n\n{\n\n LOG_DIS(\"sextb r%d, r%d\\n\", dc->r2, dc->r0);\n\n\n\n if (!(dc->env->features & LM32_FEATURE_SIGN_EXTEND)) {\n\n cpu_abort(dc->env, \"hardware sign extender is not available\\n\");\n\n }\n\n\n\n tcg_gen_ext8s_tl(cpu_R[dc->r2], cpu_R[dc->r0]);\n\n}\n", + "output": "1", + "index": 15092 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_chr_fe_write_buffer(CharDriverState *s, const uint8_t *buf, int len, int *offset)\n\n{\n\n int res = 0;\n\n *offset = 0;\n\n\n\n qemu_mutex_lock(&s->chr_write_lock);\n\n while (*offset < len) {\n\n do {\n\n res = s->chr_write(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 *offset += res;\n\n }\n\n if (*offset > 0) {\n\n qemu_chr_fe_write_log(s, buf, *offset);\n\n }\n\n qemu_mutex_unlock(&s->chr_write_lock);\n\n\n\n return res;\n\n}\n", + "output": "1", + "index": 5345 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int waveformat_from_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)\n\n{\n\n memset (wfx, 0, sizeof (*wfx));\n\n\n\n wfx->wFormatTag = WAVE_FORMAT_PCM;\n\n wfx->nChannels = as->nchannels;\n\n wfx->nSamplesPerSec = as->freq;\n\n wfx->nAvgBytesPerSec = as->freq << (as->nchannels == 2);\n\n wfx->nBlockAlign = 1 << (as->nchannels == 2);\n\n wfx->cbSize = 0;\n\n\n\n switch (as->fmt) {\n\n case AUD_FMT_S8:\n\n case AUD_FMT_U8:\n\n wfx->wBitsPerSample = 8;\n\n break;\n\n\n\n case AUD_FMT_S16:\n\n case AUD_FMT_U16:\n\n wfx->wBitsPerSample = 16;\n\n wfx->nAvgBytesPerSec <<= 1;\n\n wfx->nBlockAlign <<= 1;\n\n break;\n\n\n\n case AUD_FMT_S32:\n\n case AUD_FMT_U32:\n\n wfx->wBitsPerSample = 32;\n\n wfx->nAvgBytesPerSec <<= 2;\n\n wfx->nBlockAlign <<= 2;\n\n break;\n\n\n\n default:\n\n dolog (\"Internal logic error: Bad audio format %d\\n\", as->freq);\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 19945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockAIOCB *dma_bdrv_io(\n\n BlockDriverState *bs, QEMUSGList *sg, uint64_t sector_num,\n\n DMAIOFunc *io_func, BlockCompletionFunc *cb,\n\n void *opaque, DMADirection dir)\n\n{\n\n DMAAIOCB *dbs = qemu_aio_get(&dma_aiocb_info, bs, cb, opaque);\n\n\n\n trace_dma_bdrv_io(dbs, bs, sector_num, (dir == DMA_DIRECTION_TO_DEVICE));\n\n\n\n dbs->acb = NULL;\n\n dbs->bs = bs;\n\n dbs->sg = sg;\n\n dbs->sector_num = sector_num;\n\n dbs->sg_cur_index = 0;\n\n dbs->sg_cur_byte = 0;\n\n dbs->dir = dir;\n\n dbs->io_func = io_func;\n\n dbs->bh = NULL;\n\n qemu_iovec_init(&dbs->iov, sg->nsg);\n\n dma_bdrv_cb(dbs, 0);\n\n return &dbs->common;\n\n}\n", + "output": "0", + "index": 16898 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void child_handler(int sig)\n\n{\n\n int status;\n\n while (waitpid(-1, &status, WNOHANG) > 0) /* NOTHING */;\n\n}\n", + "output": "1", + "index": 23354 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_read_stsc(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\n\n get_byte(pb); /* version */\n\n get_be24(pb); /* flags */\n\n\n\n entries = get_be32(pb);\n\n\n\n dprintf(c->fc, \"track[%i].stsc.entries = %i\\n\", c->fc->nb_streams-1, entries);\n\n\n\n if(entries >= UINT_MAX / sizeof(*sc->stsc_data))\n\n return -1;\n\n sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));\n\n if (!sc->stsc_data)\n\n return AVERROR(ENOMEM);\n\n sc->stsc_count = entries;\n\n\n\n for(i=0; istsc_data[i].first = get_be32(pb);\n\n sc->stsc_data[i].count = get_be32(pb);\n\n sc->stsc_data[i].id = get_be32(pb);\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 9129 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen)\n\n{\n\n int ret;\n\n\n\n#ifdef CONFIG_ACCEPT4\n\n ret = accept4(s, addr, addrlen, SOCK_CLOEXEC);\n\n if (ret != -1 || errno != EINVAL) {\n\n return ret;\n\n }\n\n#endif\n\n ret = accept(s, addr, addrlen);\n\n if (ret >= 0) {\n\n qemu_set_cloexec(ret);\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 15351 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ppce500_prep_device_tree(MachineState *machine,\n\n PPCE500Params *params,\n\n hwaddr addr,\n\n hwaddr initrd_base,\n\n hwaddr initrd_size)\n\n{\n\n DeviceTreeParams *p = g_new(DeviceTreeParams, 1);\n\n p->machine = machine;\n\n p->params = *params;\n\n p->addr = addr;\n\n p->initrd_base = initrd_base;\n\n p->initrd_size = initrd_size;\n\n\n\n qemu_register_reset(ppce500_reset_device_tree, p);\n\n\n\n /* Issue the device tree loader once, so that we get the size of the blob */\n\n return ppce500_load_device_tree(machine, params, addr, initrd_base,\n\n initrd_size, true);\n\n}\n", + "output": "0", + "index": 27302 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_remove(FsContext *ctx, const char *path)\n\n{\n\n int err;\n\n struct stat stbuf;\n\n char buffer[PATH_MAX];\n\n\n\n if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n\n err = lstat(rpath(ctx, path, buffer), &stbuf);\n\n if (err) {\n\n goto err_out;\n\n }\n\n /*\n\n * If directory remove .virtfs_metadata contained in the\n\n * directory\n\n */\n\n if (S_ISDIR(stbuf.st_mode)) {\n\n snprintf(buffer, ARRAY_SIZE(buffer), \"%s/%s/%s\",\n\n ctx->fs_root, path, VIRTFS_META_DIR);\n\n err = remove(buffer);\n\n if (err < 0 && errno != ENOENT) {\n\n /*\n\n * We didn't had the .virtfs_metadata file. May be file created\n\n * in non-mapped mode ?. Ignore ENOENT.\n\n */\n\n goto err_out;\n\n }\n\n }\n\n /*\n\n * Now remove the name from parent directory\n\n * .virtfs_metadata directory\n\n */\n\n err = remove(local_mapped_attr_path(ctx, path, buffer));\n\n if (err < 0 && errno != ENOENT) {\n\n /*\n\n * We didn't had the .virtfs_metadata file. May be file created\n\n * in non-mapped mode ?. Ignore ENOENT.\n\n */\n\n goto err_out;\n\n }\n\n }\n\n return remove(rpath(ctx, path, buffer));\n\nerr_out:\n\n return err;\n\n}\n", + "output": "0", + "index": 16515 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "target_ulong helper_rdhwr_ccres(CPUMIPSState *env)\n\n{\n\n check_hwrena(env, 3);\n\n return env->CCRes;\n\n}\n", + "output": "1", + "index": 14148 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vnc_display_listen_addr(VncDisplay *vd,\n\n SocketAddressLegacy *addr,\n\n const char *name,\n\n QIOChannelSocket ***lsock,\n\n guint **lsock_tag,\n\n size_t *nlsock,\n\n Error **errp)\n\n{\n\n QIODNSResolver *resolver = qio_dns_resolver_get_instance();\n\n SocketAddressLegacy **rawaddrs = NULL;\n\n size_t nrawaddrs = 0;\n\n Error *listenerr = NULL;\n\n bool listening = false;\n\n size_t i;\n\n\n\n if (qio_dns_resolver_lookup_sync(resolver, addr, &nrawaddrs,\n\n &rawaddrs, errp) < 0) {\n\n return -1;\n\n }\n\n\n\n for (i = 0; i < nrawaddrs; i++) {\n\n QIOChannelSocket *sioc = qio_channel_socket_new();\n\n\n\n qio_channel_set_name(QIO_CHANNEL(sioc), name);\n\n if (qio_channel_socket_listen_sync(\n\n sioc, rawaddrs[i], listenerr == NULL ? &listenerr : NULL) < 0) {\n\n object_unref(OBJECT(sioc));\n\n continue;\n\n }\n\n listening = true;\n\n (*nlsock)++;\n\n *lsock = g_renew(QIOChannelSocket *, *lsock, *nlsock);\n\n *lsock_tag = g_renew(guint, *lsock_tag, *nlsock);\n\n\n\n (*lsock)[*nlsock - 1] = sioc;\n\n (*lsock_tag)[*nlsock - 1] = 0;\n\n }\n\n\n\n for (i = 0; i < nrawaddrs; i++) {\n\n qapi_free_SocketAddressLegacy(rawaddrs[i]);\n\n }\n\n g_free(rawaddrs);\n\n\n\n if (listenerr) {\n\n if (!listening) {\n\n error_propagate(errp, listenerr);\n\n return -1;\n\n } else {\n\n error_free(listenerr);\n\n }\n\n }\n\n\n\n for (i = 0; i < *nlsock; i++) {\n\n (*lsock_tag)[i] = qio_channel_add_watch(\n\n QIO_CHANNEL((*lsock)[i]),\n\n G_IO_IN, vnc_listen_io, vd, NULL);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 12745 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ram_addr_t last_ram_offset(void)\n\n{\n\n RAMBlock *block;\n\n ram_addr_t last = 0;\n\n\n\n QTAILQ_FOREACH(block, &ram_list.blocks, next)\n\n last = MAX(last, block->offset + block->length);\n\n\n\n return last;\n\n}\n", + "output": "0", + "index": 17303 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool st_change_trace_event_state(const char *tname, bool tstate)\n\n{\n\n TraceEvent *tp;\n\n\n\n tp = find_trace_event_by_name(tname);\n\n if (tp) {\n\n tp->state = tstate;\n\n return true;\n\n }\n\n return false;\n\n}\n", + "output": "1", + "index": 1951 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_h264_h_lpf_chroma_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_cb_or_cr_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,\n\n img_width);\n\n}\n", + "output": "0", + "index": 21168 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int packet_alloc(AVBufferRef **buf, int size)\n\n{\n\n int ret;\n\n if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE)\n\n return AVERROR(EINVAL);\n\n\n\n ret = av_buffer_realloc(buf, size + AV_INPUT_BUFFER_PADDING_SIZE);\n\n if (ret < 0)\n\n return ret;\n\n\n\n memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 1832 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)\n\n{\n\n BlockRequest *blkreq;\n\n uint64_t sector;\n\n\n\n sector = virtio_ldq_p(VIRTIO_DEVICE(req->dev), &req->out.sector);\n\n\n\n bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_WRITE);\n\n\n\n trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);\n\n\n\n if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {\n\n virtio_blk_rw_complete(req, -EIO);\n\n return;\n\n }\n\n\n\n if (mrb->num_writes == 32) {\n\n virtio_submit_multiwrite(req->dev->bs, mrb);\n\n }\n\n\n\n blkreq = &mrb->blkreq[mrb->num_writes];\n\n blkreq->sector = sector;\n\n blkreq->nb_sectors = req->qiov.size / BDRV_SECTOR_SIZE;\n\n blkreq->qiov = &req->qiov;\n\n blkreq->cb = virtio_blk_rw_complete;\n\n blkreq->opaque = req;\n\n blkreq->error = 0;\n\n\n\n mrb->num_writes++;\n\n}\n", + "output": "1", + "index": 25558 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_queue_guest_notifier_read(EventNotifier *n)\n\n{\n\n VirtQueue *vq = container_of(n, VirtQueue, guest_notifier);\n\n if (event_notifier_test_and_clear(n)) {\n\n virtio_irq(vq);\n\n }\n\n}\n", + "output": "1", + "index": 12388 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) {\n\n mlz->dict = av_malloc_array(TABLE_SIZE, sizeof(*mlz->dict));\n\n\n\n mlz->flush_code = FLUSH_CODE;\n\n mlz->current_dic_index_max = DIC_INDEX_INIT;\n\n mlz->dic_code_bit = CODE_BIT_INIT;\n\n mlz->bump_code = (DIC_INDEX_INIT - 1);\n\n mlz->next_code = FIRST_CODE;\n\n mlz->freeze_flag = 0;\n\n mlz->context = context;\n\n}\n", + "output": "1", + "index": 24011 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned tget(const uint8_t **p, int type, int le)\n\n{\n\n switch (type) {\n\n case TIFF_BYTE:\n\n return *(*p)++;\n\n case TIFF_SHORT:\n\n return tget_short(p, le);\n\n case TIFF_LONG:\n\n return tget_long(p, le);\n\n default:\n\n return UINT_MAX;\n\n }\n\n}\n", + "output": "1", + "index": 3158 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void os_set_proc_name(const char *s)\n\n{\n\n#if defined(PR_SET_NAME)\n\n char name[16];\n\n if (!s)\n\n return;\n\n name[sizeof(name) - 1] = 0;\n\n strncpy(name, s, sizeof(name));\n\n /* Could rewrite argv[0] too, but that's a bit more complicated.\n\n This simple way is enough for `top'. */\n\n if (prctl(PR_SET_NAME, name)) {\n\n perror(\"unable to change process name\");\n\n exit(1);\n\n }\n\n#else\n\n fprintf(stderr, \"Change of process name not supported by your OS\\n\");\n\n exit(1);\n\n#endif\n\n}\n", + "output": "1", + "index": 1575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dec_divu(DisasContext *dc)\n\n{\n\n int l1;\n\n\n\n LOG_DIS(\"divu r%d, r%d, r%d\\n\", dc->r2, dc->r0, dc->r1);\n\n\n\n if (!(dc->env->features & LM32_FEATURE_DIVIDE)) {\n\n cpu_abort(dc->env, \"hardware divider is not available\\n\");\n\n }\n\n\n\n l1 = gen_new_label();\n\n tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[dc->r1], 0, l1);\n\n tcg_gen_movi_tl(cpu_pc, dc->pc);\n\n t_gen_raise_exception(dc, EXCP_DIVIDE_BY_ZERO);\n\n gen_set_label(l1);\n\n tcg_gen_divu_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);\n\n}\n", + "output": "1", + "index": 3169 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_tag(AVFormatContext *s, const uint8_t *buf)\n\n{\n\n int genre;\n\n\n\n if (!(buf[0] == 'T' &&\n\n buf[1] == 'A' &&\n\n buf[2] == 'G'))\n\n return -1;\n\n get_string(s, \"title\", buf + 3, 30);\n\n get_string(s, \"artist\", buf + 33, 30);\n\n get_string(s, \"album\", buf + 63, 30);\n\n get_string(s, \"date\", buf + 93, 4);\n\n get_string(s, \"comment\", buf + 97, 30);\n\n if (buf[125] == 0 && buf[126] != 0)\n\n av_metadata_set2(&s->metadata, \"track\", av_d2str(buf[126]), AV_METADATA_DONT_STRDUP_VAL);\n\n genre = buf[127];\n\n if (genre <= ID3v1_GENRE_MAX)\n\n av_metadata_set2(&s->metadata, \"genre\", ff_id3v1_genre_str[genre], 0);\n\n return 0;\n\n}\n", + "output": "0", + "index": 18752 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dnxhd_decode_dct_block_10(const DNXHDContext *ctx,\n\n RowContext *row, int n)\n\n{\n\n dnxhd_decode_dct_block(ctx, row, n, 6, 8, 4);\n\n}\n", + "output": "1", + "index": 26755 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)\n\n{\n\n struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out;\n\n if (ep == 0) {\n\n return &dev->ep_ctl;\n\n }\n\n assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);\n\n assert(ep > 0 && ep <= USB_MAX_ENDPOINTS);\n\n return eps + ep - 1;\n\n}\n", + "output": "0", + "index": 8149 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_pivot(MSS1Context *ctx, ArithCoder *acoder, int base)\n\n{\n\n int val, inv;\n\n\n\n inv = arith_get_model_sym(acoder, &ctx->edge_mode);\n\n val = arith_get_model_sym(acoder, &ctx->pivot) + 1;\n\n\n\n if (val > 2) {\n\n if ((base + 1) / 2 - 2 <= 0) {\n\n ctx->corrupted = 1;\n\n return 0;\n\n }\n\n val = arith_get_number(acoder, (base + 1) / 2 - 2) + 3;\n\n }\n\n\n\n if (val == base) {\n\n ctx->corrupted = 1;\n\n return 0;\n\n }\n\n\n\n return inv ? base - val : val;\n\n}\n", + "output": "1", + "index": 1636 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gic_dist_writew(void *opaque, target_phys_addr_t offset,\n\n uint32_t value)\n\n{\n\n gic_dist_writeb(opaque, offset, value & 0xff);\n\n gic_dist_writeb(opaque, offset + 1, value >> 8);\n\n}\n", + "output": "0", + "index": 12468 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_dump_state (CPUCRISState *env, FILE *f, fprintf_function cpu_fprintf,\n\n int flags)\n\n{\n\n\tint i;\n\n\tuint32_t srs;\n\n\n\n\tif (!env || !f)\n\n\t\treturn;\n\n\n\n\tcpu_fprintf(f, \"PC=%x CCS=%x btaken=%d btarget=%x\\n\"\n\n\t\t \"cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\\n\",\n\n\t\t env->pc, env->pregs[PR_CCS], env->btaken, env->btarget,\n\n\t\t env->cc_op,\n\n\t\t env->cc_src, env->cc_dest, env->cc_result, env->cc_mask);\n\n\n\n\n\n\tfor (i = 0; i < 16; i++) {\n\n\t\tcpu_fprintf(f, \"%s=%8.8x \",regnames[i], env->regs[i]);\n\n\t\tif ((i + 1) % 4 == 0)\n\n\t\t\tcpu_fprintf(f, \"\\n\");\n\n\t}\n\n\tcpu_fprintf(f, \"\\nspecial regs:\\n\");\n\n\tfor (i = 0; i < 16; i++) {\n\n\t\tcpu_fprintf(f, \"%s=%8.8x \", pregnames[i], env->pregs[i]);\n\n\t\tif ((i + 1) % 4 == 0)\n\n\t\t\tcpu_fprintf(f, \"\\n\");\n\n\t}\n\n\tsrs = env->pregs[PR_SRS];\n\n\tcpu_fprintf(f, \"\\nsupport function regs bank %x:\\n\", srs);\n\n\tif (srs < 256) {\n\n\t\tfor (i = 0; i < 16; i++) {\n\n\t\t\tcpu_fprintf(f, \"s%2.2d=%8.8x \",\n\n\t\t\t\t i, env->sregs[srs][i]);\n\n\t\t\tif ((i + 1) % 4 == 0)\n\n\t\t\t\tcpu_fprintf(f, \"\\n\");\n\n\t\t}\n\n\t}\n\n\tcpu_fprintf(f, \"\\n\\n\");\n\n\n\n}\n", + "output": "1", + "index": 16209 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,\n\n const struct iovec *iov,\n\n size_t niov,\n\n uint8_t **result,\n\n size_t *resultlen,\n\n Error **errp)\n\n{\n\n#ifdef CONFIG_AF_ALG\n\n int ret;\n\n\n\n ret = qcrypto_hash_afalg_driver.hash_bytesv(alg, iov, niov,\n\n result, resultlen,\n\n errp);\n\n if (ret == 0) {\n\n return ret;\n\n }\n\n\n\n /*\n\n * TODO:\n\n * Maybe we should treat some afalg errors as fatal\n\n */\n\n error_free(*errp);\n\n#endif\n\n\n\n return qcrypto_hash_lib_driver.hash_bytesv(alg, iov, niov,\n\n result, resultlen,\n\n errp);\n\n}\n", + "output": "1", + "index": 19233 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int avio_check(const char *url, int flags)\n\n{\n\n URLContext *h;\n\n int ret = ffurl_alloc(&h, url, flags, NULL);\n\n if (ret)\n\n return ret;\n\n\n\n if (h->prot->url_check) {\n\n ret = h->prot->url_check(h, flags);\n\n } else {\n\n ret = ffurl_connect(h, NULL);\n\n if (ret >= 0)\n\n ret = flags;\n\n }\n\n\n\n ffurl_close(h);\n\n return ret;\n\n}\n", + "output": "0", + "index": 11416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)\n\n{\n\n /* Load dct coeffs */\n\n __asm__ volatile(\n\n \"movq (%0), %%mm0 \\n\\t\"\n\n \"movq 8(%0), %%mm1 \\n\\t\"\n\n \"movq 16(%0), %%mm2 \\n\\t\"\n\n \"movq 24(%0), %%mm3 \\n\\t\"\n\n :: \"r\"(block) );\n\n\n\n __asm__ volatile(\n\n /* mm1=s02+s13 mm2=s02-s13 mm4=d02+d13 mm0=d02-d13 */\n\n IDCT4_1D( %%mm2, %%mm1, %%mm0, %%mm3, %%mm4 )\n\n\n\n \"movq %0, %%mm6 \\n\\t\"\n\n /* in: 1,4,0,2 out: 1,2,3,0 */\n\n TRANSPOSE4( %%mm3, %%mm1, %%mm0, %%mm2, %%mm4 )\n\n\n\n \"paddw %%mm6, %%mm3 \\n\\t\"\n\n\n\n /* mm2=s02+s13 mm3=s02-s13 mm4=d02+d13 mm1=d02-d13 */\n\n IDCT4_1D( %%mm4, %%mm2, %%mm3, %%mm0, %%mm1 )\n\n\n\n \"pxor %%mm7, %%mm7 \\n\\t\"\n\n :: \"m\"(ff_pw_32));\n\n\n\n __asm__ volatile(\n\n STORE_DIFF_4P( %%mm0, %%mm1, %%mm7)\n\n \"add %1, %0 \\n\\t\"\n\n STORE_DIFF_4P( %%mm2, %%mm1, %%mm7)\n\n \"add %1, %0 \\n\\t\"\n\n STORE_DIFF_4P( %%mm3, %%mm1, %%mm7)\n\n \"add %1, %0 \\n\\t\"\n\n STORE_DIFF_4P( %%mm4, %%mm1, %%mm7)\n\n : \"+r\"(dst)\n\n : \"r\" ((x86_reg)stride)\n\n );\n\n}\n", + "output": "0", + "index": 5124 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int psy_3gpp_init(FFPsyContext *ctx) {\n\n AacPsyContext *pctx;\n\n float bark;\n\n int i, j, g, start;\n\n float prev, minscale, minath;\n\n\n\n ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext));\n\n pctx = (AacPsyContext*) ctx->model_priv_data;\n\n\n\n minath = ath(3410, ATH_ADD);\n\n for (j = 0; j < 2; j++) {\n\n AacPsyCoeffs *coeffs = &pctx->psy_coef[j];\n\n float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f);\n\n i = 0;\n\n prev = 0.0;\n\n for (g = 0; g < ctx->num_bands[j]; g++) {\n\n i += ctx->bands[j][g];\n\n bark = calc_bark((i-1) * line_to_frequency);\n\n coeffs->barks[g] = (bark + prev) / 2.0;\n\n prev = bark;\n\n }\n\n for (g = 0; g < ctx->num_bands[j] - 1; g++) {\n\n coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);\n\n coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI);\n\n }\n\n start = 0;\n\n for (g = 0; g < ctx->num_bands[j]; g++) {\n\n minscale = ath(start * line_to_frequency, ATH_ADD);\n\n for (i = 1; i < ctx->bands[j][g]; i++)\n\n minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD));\n\n coeffs->ath[g] = minscale - minath;\n\n start += ctx->bands[j][g];\n\n }\n\n }\n\n\n\n pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels);\n\n\n\n lame_window_init(pctx, ctx->avctx);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15238 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PCIDevice *pci_register_device(PCIBus *bus, const char *name,\n\n int instance_size, int devfn,\n\n PCIConfigReadFunc *config_read,\n\n PCIConfigWriteFunc *config_write)\n\n{\n\n PCIDevice *pci_dev;\n\n\n\n pci_dev = qemu_mallocz(instance_size);\n\n pci_dev = do_pci_register_device(pci_dev, bus, name, devfn,\n\n config_read, config_write);\n\n return pci_dev;\n\n}\n", + "output": "0", + "index": 309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_platform_realize(DeviceState *dev, Error **errp)\n\n{\n\n VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);\n\n SysBusDevice *sbdev = SYS_BUS_DEVICE(dev);\n\n VFIODevice *vbasedev = &vdev->vbasedev;\n\n VFIOINTp *intp;\n\n int i, ret;\n\n\n\n vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;\n\n vbasedev->ops = &vfio_platform_ops;\n\n\n\n trace_vfio_platform_realize(vbasedev->name, vdev->compat);\n\n\n\n ret = vfio_base_device_init(vbasedev);\n\n if (ret) {\n\n error_setg(errp, \"vfio: vfio_base_device_init failed for %s\",\n\n vbasedev->name);\n\n return;\n\n }\n\n\n\n for (i = 0; i < vbasedev->num_regions; i++) {\n\n vfio_map_region(vdev, i);\n\n sysbus_init_mmio(sbdev, &vdev->regions[i]->mem);\n\n }\n\n\n\n QLIST_FOREACH(intp, &vdev->intp_list, next) {\n\n vfio_start_eventfd_injection(intp);\n\n }\n\n}\n", + "output": "1", + "index": 17772 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void a9_scu_write(void *opaque, target_phys_addr_t offset,\n\n uint64_t value, unsigned size)\n\n{\n\n a9mp_priv_state *s = (a9mp_priv_state *)opaque;\n\n uint32_t mask;\n\n uint32_t shift;\n\n switch (size) {\n\n case 1:\n\n mask = 0xff;\n\n break;\n\n case 2:\n\n mask = 0xffff;\n\n break;\n\n case 4:\n\n mask = 0xffffffff;\n\n break;\n\n default:\n\n fprintf(stderr, \"Invalid size %u in write to a9 scu register %x\\n\",\n\n size, (unsigned)offset);\n\n return;\n\n }\n\n\n\n switch (offset) {\n\n case 0x00: /* Control */\n\n s->scu_control = value & 1;\n\n break;\n\n case 0x4: /* Configuration: RO */\n\n break;\n\n case 0x08: case 0x09: case 0x0A: case 0x0B: /* Power Control */\n\n shift = (offset - 0x8) * 8;\n\n s->scu_status &= ~(mask << shift);\n\n s->scu_status |= ((value & mask) << shift);\n\n break;\n\n case 0x0c: /* Invalidate All Registers In Secure State */\n\n /* no-op as we do not implement caches */\n\n break;\n\n case 0x40: /* Filtering Start Address Register */\n\n case 0x44: /* Filtering End Address Register */\n\n /* RAZ/WI, like an implementation with only one AXI master */\n\n break;\n\n case 0x50: /* SCU Access Control Register */\n\n case 0x54: /* SCU Non-secure Access Control Register */\n\n /* unimplemented, fall through */\n\n default:\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 6401 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n QCowSnapshot sn;\n\n int snapshot_index, ret;\n\n\n\n /* Search the snapshot */\n\n snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);\n\n if (snapshot_index < 0) {\n\n return -ENOENT;\n\n }\n\n sn = s->snapshots[snapshot_index];\n\n\n\n /* Remove it from the snapshot list */\n\n memmove(s->snapshots + snapshot_index,\n\n s->snapshots + snapshot_index + 1,\n\n (s->nb_snapshots - snapshot_index - 1) * sizeof(sn));\n\n s->nb_snapshots--;\n\n ret = qcow2_write_snapshots(bs);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n /*\n\n * The snapshot is now unused, clean up. If we fail after this point, we\n\n * won't recover but just leak clusters.\n\n */\n\n g_free(sn.id_str);\n\n g_free(sn.name);\n\n\n\n /*\n\n * Now decrease the refcounts of clusters referenced by the snapshot and\n\n * free the L1 table.\n\n */\n\n ret = qcow2_update_snapshot_refcount(bs, sn.l1_table_offset,\n\n sn.l1_size, -1);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * sizeof(uint64_t));\n\n\n\n /* must update the copied flag on the current cluster offsets */\n\n ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n#ifdef DEBUG_ALLOC\n\n {\n\n BdrvCheckResult result = {0};\n\n qcow2_check_refcounts(bs, &result);\n\n }\n\n#endif\n\n return 0;\n\n}\n", + "output": "1", + "index": 4230 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_audio_out(AVFormatContext *s, OutputStream *ost,\n\n AVFrame *frame)\n\n{\n\n AVCodecContext *enc = ost->enc_ctx;\n\n AVPacket pkt;\n\n int got_packet = 0;\n\n\n\n av_init_packet(&pkt);\n\n pkt.data = NULL;\n\n pkt.size = 0;\n\n\n\n if (!check_recording_time(ost))\n\n return;\n\n\n\n if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)\n\n frame->pts = ost->sync_opts;\n\n ost->sync_opts = frame->pts + frame->nb_samples;\n\n ost->samples_encoded += frame->nb_samples;\n\n ost->frames_encoded++;\n\n\n\n av_assert0(pkt.size || !pkt.data);\n\n update_benchmark(NULL);\n\n if (debug_ts) {\n\n av_log(NULL, AV_LOG_INFO, \"encoder <- type:audio \"\n\n \"frame_pts:%s frame_pts_time:%s time_base:%d/%d\\n\",\n\n av_ts2str(frame->pts), av_ts2timestr(frame->pts, &enc->time_base),\n\n enc->time_base.num, enc->time_base.den);\n\n }\n\n\n\n if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) {\n\n av_log(NULL, AV_LOG_FATAL, \"Audio encoding failed (avcodec_encode_audio2)\\n\");\n\n exit_program(1);\n\n }\n\n update_benchmark(\"encode_audio %d.%d\", ost->file_index, ost->index);\n\n\n\n if (got_packet) {\n\n av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);\n\n\n\n if (debug_ts) {\n\n av_log(NULL, AV_LOG_INFO, \"encoder -> type:audio \"\n\n \"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\\n\",\n\n av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),\n\n av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));\n\n }\n\n\n\n write_frame(s, &pkt, ost);\n\n }\n\n}\n", + "output": "1", + "index": 2257 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,\n\n const uint8_t *src, int size, int width, int lines)\n\n{\n\n int i, ret = 0;\n\n int line;\n\n uint8_t *src2 = av_malloc((unsigned)size +\n\n AV_INPUT_BUFFER_PADDING_SIZE);\n\n\n\n if (!src2) {\n\n av_log(s->avctx, AV_LOG_ERROR,\n\n \"Error allocating temporary buffer\\n\");\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n if (!s->fill_order) {\n\n memcpy(src2, src, size);\n\n } else {\n\n for (i = 0; i < size; i++)\n\n src2[i] = ff_reverse[src[i]];\n\n }\n\n memset(src2 + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);\n\n ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,\n\n s->compr, s->fax_opts);\n\n if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)\n\n for (line = 0; line < lines; line++) {\n\n horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);\n\n dst += stride;\n\n }\n\n av_free(src2);\n\n return ret;\n\n}\n", + "output": "1", + "index": 6669 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int encode_init_ls(AVCodecContext *ctx)\n\n{\n\n ctx->coded_frame = av_frame_alloc();\n\n if (!ctx->coded_frame)\n\n return AVERROR(ENOMEM);\n\n\n\n ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;\n\n ctx->coded_frame->key_frame = 1;\n\n\n\n if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&\n\n ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&\n\n ctx->pix_fmt != AV_PIX_FMT_RGB24 &&\n\n ctx->pix_fmt != AV_PIX_FMT_BGR24) {\n\n av_log(ctx, AV_LOG_ERROR,\n\n \"Only grayscale and RGB24/BGR24 images are supported\\n\");\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 7876 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bdrv_io_limits_intercept(BlockDriverState *bs,\n\n int nb_sectors,\n\n bool is_write)\n\n{\n\n /* does this io must wait */\n\n bool must_wait = throttle_schedule_timer(&bs->throttle_state, is_write);\n\n\n\n /* if must wait or any request of this type throttled queue the IO */\n\n if (must_wait ||\n\n !qemu_co_queue_empty(&bs->throttled_reqs[is_write])) {\n\n qemu_co_queue_wait(&bs->throttled_reqs[is_write]);\n\n }\n\n\n\n /* the IO will be executed, do the accounting */\n\n throttle_account(&bs->throttle_state,\n\n is_write,\n\n nb_sectors * BDRV_SECTOR_SIZE);\n\n\n\n /* if the next request must wait -> do nothing */\n\n if (throttle_schedule_timer(&bs->throttle_state, is_write)) {\n\n return;\n\n }\n\n\n\n /* else queue next request for execution */\n\n qemu_co_queue_next(&bs->throttled_reqs[is_write]);\n\n}\n", + "output": "0", + "index": 13575 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,\n\n uint16_t ipbh0)\n\n{\n\n CPUS390XState *env = &cpu->env;\n\n uint32_t sccb;\n\n uint64_t code;\n\n int r = 0;\n\n\n\n cpu_synchronize_state(CPU(cpu));\n\n if (env->psw.mask & PSW_MASK_PSTATE) {\n\n enter_pgmcheck(cpu, PGM_PRIVILEGED);\n\n return 0;\n\n }\n\n sccb = env->regs[ipbh0 & 0xf];\n\n code = env->regs[(ipbh0 & 0xf0) >> 4];\n\n\n\n r = sclp_service_call(sccb, code);\n\n if (r < 0) {\n\n enter_pgmcheck(cpu, -r);\n\n }\n\n setcc(cpu, r);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 24310 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t HELPER(popcnt)(uint64_t r2)\n\n{\n\n uint64_t ret = 0;\n\n int i;\n\n\n\n for (i = 0; i < 64; i += 8) {\n\n uint64_t t = ctpop32((r2 >> i) & 0xff);\n\n ret |= t << i;\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 24199 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void set_cfg_value(bool is_max, int index, int value)\n\n{\n\n if (is_max) {\n\n cfg.buckets[index].max = value;\n\n\n\n } else {\n\n cfg.buckets[index].avg = value;\n\n }\n\n}", + "output": "1", + "index": 15556 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void avformat_close_input(AVFormatContext **ps)\n\n{\n\n AVFormatContext *s = *ps;\n\n AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?\n\n NULL : s->pb;\n\n flush_packet_queue(s);\n\n if (s->iformat->read_close)\n\n s->iformat->read_close(s);\n\n avformat_free_context(s);\n\n *ps = NULL;\n\n if (pb)\n\n avio_close(pb);\n\n}\n", + "output": "0", + "index": 3145 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_cd_change_media_cb(void *opaque, bool load)\n\n{\n\n SCSIDiskState *s = opaque;\n\n\n\n /*\n\n * When a CD gets changed, we have to report an ejected state and\n\n * then a loaded state to guests so that they detect tray\n\n * open/close and media change events. Guests that do not use\n\n * GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close\n\n * states rely on this behavior.\n\n *\n\n * media_changed governs the state machine used for unit attention\n\n * report. media_event is used by GET EVENT STATUS NOTIFICATION.\n\n */\n\n s->media_changed = load;\n\n s->tray_open = !load;\n\n s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM);\n\n s->media_event = true;\n\n s->eject_request = false;\n\n}\n", + "output": "0", + "index": 25010 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req)\n\n{\n\n struct viosrp_adapter_info *sinfo;\n\n struct mad_adapter_info_data info;\n\n int rc;\n\n\n\n sinfo = &req->iu.mad.adapter_info;\n\n\n\n#if 0 /* What for ? */\n\n rc = spapr_tce_dma_read(&s->vdev, be64_to_cpu(sinfo->buffer),\n\n &info, be16_to_cpu(sinfo->common.length));\n\n if (rc) {\n\n fprintf(stderr, \"vscsi_send_adapter_info: DMA read failure !\\n\");\n\n }\n\n#endif\n\n memset(&info, 0, sizeof(info));\n\n strcpy(info.srp_version, SRP_VERSION);\n\n strncpy(info.partition_name, \"qemu\", sizeof(\"qemu\"));\n\n info.partition_number = cpu_to_be32(0);\n\n info.mad_version = cpu_to_be32(1);\n\n info.os_type = cpu_to_be32(2);\n\n info.port_max_txu[0] = cpu_to_be32(VSCSI_MAX_SECTORS << 9);\n\n\n\n rc = spapr_tce_dma_write(&s->vdev, be64_to_cpu(sinfo->buffer),\n\n &info, be16_to_cpu(sinfo->common.length));\n\n if (rc) {\n\n fprintf(stderr, \"vscsi_send_adapter_info: DMA write failure !\\n\");\n\n }\n\n\n\n sinfo->common.status = rc ? cpu_to_be32(1) : 0;\n\n\n\n return vscsi_send_iu(s, req, sizeof(*sinfo), VIOSRP_MAD_FORMAT);\n\n}\n", + "output": "1", + "index": 4869 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_rename(void *opaque)\n{\n int32_t fid;\n ssize_t err = 0;\n size_t offset = 7;\n V9fsString name;\n int32_t newdirfid;\n V9fsFidState *fidp;\n V9fsPDU *pdu = opaque;\n V9fsState *s = pdu->s;\n v9fs_string_init(&name);\n err = pdu_unmarshal(pdu, offset, \"dds\", &fid, &newdirfid, &name);\n if (err < 0) {\n fidp = get_fid(pdu, fid);\n if (fidp == NULL) {\n BUG_ON(fidp->fid_type != P9_FID_NONE);\n /* if fs driver is not path based, return EOPNOTSUPP */\n if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) {\n err = -EOPNOTSUPP;\n goto out;\n v9fs_path_write_lock(s);\n err = v9fs_complete_rename(pdu, fidp, newdirfid, &name);\n v9fs_path_unlock(s);\n if (!err) {\n err = offset;\nout:\n put_fid(pdu, fidp);\nout_nofid:\n pdu_complete(pdu, err);\n v9fs_string_free(&name);", + "output": "1", + "index": 24265 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,\n\n const char *name, void *opaque,\n\n Error **errp)\n\n{\n\n PCIHostState *h = PCI_HOST_BRIDGE(obj);\n\n Range w64;\n\n\n\n pci_bus_get_w64_range(h->bus, &w64);\n\n\n\n visit_type_uint64(v, name, &w64.end, errp);\n\n}\n", + "output": "0", + "index": 9861 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void * attribute_align_arg worker(void *v){\n\n AVCodecContext *avctx = v;\n\n ThreadContext *c = avctx->internal->frame_thread_encoder;\n\n AVPacket *pkt = NULL;\n\n\n\n while(!c->exit){\n\n int got_packet, ret;\n\n AVFrame *frame;\n\n Task task;\n\n\n\n if(!pkt) pkt= av_mallocz(sizeof(*pkt));\n\n if(!pkt) continue;\n\n av_init_packet(pkt);\n\n\n\n pthread_mutex_lock(&c->task_fifo_mutex);\n\n while (av_fifo_size(c->task_fifo) <= 0 || c->exit) {\n\n if(c->exit){\n\n pthread_mutex_unlock(&c->task_fifo_mutex);\n\n goto end;\n\n }\n\n pthread_cond_wait(&c->task_fifo_cond, &c->task_fifo_mutex);\n\n }\n\n av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL);\n\n pthread_mutex_unlock(&c->task_fifo_mutex);\n\n frame = task.indata;\n\n\n\n ret = avcodec_encode_video2(avctx, pkt, frame, &got_packet);\n\n pthread_mutex_lock(&c->buffer_mutex);\n\n av_frame_unref(frame);\n\n pthread_mutex_unlock(&c->buffer_mutex);\n\n av_frame_free(&frame);\n\n if(got_packet) {\n\n av_dup_packet(pkt);\n\n } else {\n\n pkt->data = NULL;\n\n pkt->size = 0;\n\n }\n\n pthread_mutex_lock(&c->finished_task_mutex);\n\n c->finished_tasks[task.index].outdata = pkt; pkt = NULL;\n\n c->finished_tasks[task.index].return_code = ret;\n\n pthread_cond_signal(&c->finished_task_cond);\n\n pthread_mutex_unlock(&c->finished_task_mutex);\n\n }\n\nend:\n\n av_free(pkt);\n\n pthread_mutex_lock(&c->buffer_mutex);\n\n avcodec_close(avctx);\n\n pthread_mutex_unlock(&c->buffer_mutex);\n\n av_freep(&avctx);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 14963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "start_xmit(E1000State *s)\n\n{\n\n PCIDevice *d = PCI_DEVICE(s);\n\n dma_addr_t base;\n\n struct e1000_tx_desc desc;\n\n uint32_t tdh_start = s->mac_reg[TDH], cause = E1000_ICS_TXQE;\n\n\n\n if (!(s->mac_reg[TCTL] & E1000_TCTL_EN)) {\n\n DBGOUT(TX, \"tx disabled\\n\");\n\n return;\n\n }\n\n\n\n while (s->mac_reg[TDH] != s->mac_reg[TDT]) {\n\n base = tx_desc_base(s) +\n\n sizeof(struct e1000_tx_desc) * s->mac_reg[TDH];\n\n pci_dma_read(d, base, &desc, sizeof(desc));\n\n\n\n DBGOUT(TX, \"index %d: %p : %x %x\\n\", s->mac_reg[TDH],\n\n (void *)(intptr_t)desc.buffer_addr, desc.lower.data,\n\n desc.upper.data);\n\n\n\n process_tx_desc(s, &desc);\n\n cause |= txdesc_writeback(s, base, &desc);\n\n\n\n if (++s->mac_reg[TDH] * sizeof(desc) >= s->mac_reg[TDLEN])\n\n s->mac_reg[TDH] = 0;\n\n /*\n\n * the following could happen only if guest sw assigns\n\n * bogus values to TDT/TDLEN.\n\n * there's nothing too intelligent we could do about this.\n\n */\n\n if (s->mac_reg[TDH] == tdh_start) {\n\n DBGOUT(TXERR, \"TDH wraparound @%x, TDT %x, TDLEN %x\\n\",\n\n tdh_start, s->mac_reg[TDT], s->mac_reg[TDLEN]);\n\n break;\n\n }\n\n }\n\n set_ics(s, 0, cause);\n\n}\n", + "output": "1", + "index": 3536 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pci_reg_write4(void *opaque, target_phys_addr_t addr,\n\n uint32_t value)\n\n{\n\n PPCE500PCIState *pci = opaque;\n\n unsigned long win;\n\n\n\n win = addr & 0xfe0;\n\n\n\n pci_debug(\"%s: value:%x -> win:%lx(addr:\" TARGET_FMT_plx \")\\n\",\n\n __func__, value, win, addr);\n\n\n\n switch (win) {\n\n case PPCE500_PCI_OW1:\n\n case PPCE500_PCI_OW2:\n\n case PPCE500_PCI_OW3:\n\n case PPCE500_PCI_OW4:\n\n switch (addr & 0xC) {\n\n case PCI_POTAR:\n\n pci->pob[(addr >> 5) & 0x7].potar = value;\n\n break;\n\n case PCI_POTEAR:\n\n pci->pob[(addr >> 5) & 0x7].potear = value;\n\n break;\n\n case PCI_POWBAR:\n\n pci->pob[(addr >> 5) & 0x7].powbar = value;\n\n break;\n\n case PCI_POWAR:\n\n pci->pob[(addr >> 5) & 0x7].powar = value;\n\n break;\n\n default:\n\n break;\n\n };\n\n break;\n\n\n\n case PPCE500_PCI_IW3:\n\n case PPCE500_PCI_IW2:\n\n case PPCE500_PCI_IW1:\n\n switch (addr & 0xC) {\n\n case PCI_PITAR:\n\n pci->pib[(addr >> 5) & 0x3].pitar = value;\n\n break;\n\n case PCI_PIWBAR:\n\n pci->pib[(addr >> 5) & 0x3].piwbar = value;\n\n break;\n\n case PCI_PIWBEAR:\n\n pci->pib[(addr >> 5) & 0x3].piwbear = value;\n\n break;\n\n case PCI_PIWAR:\n\n pci->pib[(addr >> 5) & 0x3].piwar = value;\n\n break;\n\n default:\n\n break;\n\n };\n\n break;\n\n\n\n case PPCE500_PCI_GASKET_TIMR:\n\n pci->gasket_time = value;\n\n break;\n\n\n\n default:\n\n break;\n\n };\n\n}\n", + "output": "1", + "index": 11372 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n PnvChipClass *k = PNV_CHIP_CLASS(klass);\n\n\n\n k->cpu_model = \"POWER8NVL\";\n\n k->chip_type = PNV_CHIP_POWER8NVL;\n\n k->chip_cfam_id = 0x120d304980000000ull; /* P8 Naples DD1.0 */\n\n k->cores_mask = POWER8_CORE_MASK;\n\n k->core_pir = pnv_chip_core_pir_p8;\n\n\n dc->desc = \"PowerNV Chip POWER8NVL\";\n\n}", + "output": "1", + "index": 16698 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_init_thread_copy(AVCodecContext *avctx)\n\n{\n\n H264Context *h = avctx->priv_data;\n\n int ret;\n\n\n\n if (!avctx->internal->is_copy)\n\n return 0;\n\n memset(h->sps_buffers, 0, sizeof(h->sps_buffers));\n\n memset(h->pps_buffers, 0, sizeof(h->pps_buffers));\n\n\n\n ret = h264_init_context(avctx, h);\n\n if (ret < 0)\n\n return ret;\n\n\n\n h->context_initialized = 0;\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 26629 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gen_stos(DisasContext *s, int ot)\n\n{\n\n gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);\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_EDI_T0();\n\n } else\n\n#endif\n\n if (s->aflag) {\n\n gen_op_addl_EDI_T0();\n\n } else {\n\n gen_op_addw_EDI_T0();\n\n }\n\n}\n", + "output": "0", + "index": 20295 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_desc_create_serial(USBDevice *dev)\n\n{\n\n DeviceState *hcd = dev->qdev.parent_bus->parent;\n\n const USBDesc *desc = usb_device_get_usb_desc(dev);\n\n int index = desc->id.iSerialNumber;\n\n char serial[64];\n\n char *path;\n\n int dst;\n\n\n\n if (dev->serial) {\n\n /* 'serial' usb bus property has priority if present */\n\n usb_desc_set_string(dev, index, dev->serial);\n\n return;\n\n }\n\n\n\n assert(index != 0 && desc->str[index] != NULL);\n\n dst = snprintf(serial, sizeof(serial), \"%s\", desc->str[index]);\n\n path = qdev_get_dev_path(hcd);\n\n if (path) {\n\n dst += snprintf(serial+dst, sizeof(serial)-dst, \"-%s\", path);\n\n }\n\n dst += snprintf(serial+dst, sizeof(serial)-dst, \"-%s\", dev->port->path);\n\n usb_desc_set_string(dev, index, serial);\n\n g_free(path);\n\n}\n", + "output": "0", + "index": 5579 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void bdrv_get_backing_filename(BlockDriverState *bs,\n\n char *filename, int filename_size)\n\n{\n\n pstrcpy(filename, filename_size, bs->backing_file);\n\n}\n", + "output": "0", + "index": 16555 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int handle_cpu_signal(unsigned long pc, unsigned long address,\n\n int is_write, sigset_t *old_set, \n\n void *puc)\n\n{\n\n TranslationBlock *tb;\n\n int ret;\n\n\n\n if (cpu_single_env)\n\n env = cpu_single_env; /* XXX: find a correct solution for multithread */\n\n#if defined(DEBUG_SIGNAL)\n\n qemu_printf(\"qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\\n\", \n\n pc, address, is_write, *(unsigned long *)old_set);\n\n#endif\n\n /* XXX: locking issue */\n\n if (is_write && page_unprotect(address, pc, puc)) {\n\n return 1;\n\n }\n\n\n\n /* see if it is an MMU fault */\n\n ret = cpu_x86_handle_mmu_fault(env, address, is_write, \n\n ((env->hflags & HF_CPL_MASK) == 3), 0);\n\n if (ret < 0)\n\n return 0; /* not an MMU fault */\n\n if (ret == 0)\n\n return 1; /* the MMU fault was handled without causing real CPU fault */\n\n /* now we have a real cpu fault */\n\n tb = tb_find_pc(pc);\n\n if (tb) {\n\n /* the PC is inside the translated code. It means that we have\n\n a virtual CPU fault */\n\n cpu_restore_state(tb, env, pc, puc);\n\n }\n\n if (ret == 1) {\n\n#if 0\n\n printf(\"PF exception: EIP=0x%08x CR2=0x%08x error=0x%x\\n\", \n\n env->eip, env->cr[2], env->error_code);\n\n#endif\n\n /* we restore the process signal mask as the sigreturn should\n\n do it (XXX: use sigsetjmp) */\n\n sigprocmask(SIG_SETMASK, old_set, NULL);\n\n raise_exception_err(EXCP0E_PAGE, env->error_code);\n\n } else {\n\n /* activate soft MMU for this block */\n\n env->hflags |= HF_SOFTMMU_MASK;\n\n cpu_resume_from_signal(env, puc);\n\n }\n\n /* never comes here */\n\n return 1;\n\n}\n", + "output": "0", + "index": 7561 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void arm926_initfn(Object *obj)\n\n{\n\n ARMCPU *cpu = ARM_CPU(obj);\n\n\n\n cpu->dtb_compatible = \"arm,arm926\";\n\n set_feature(&cpu->env, ARM_FEATURE_V5);\n\n set_feature(&cpu->env, ARM_FEATURE_VFP);\n\n set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);\n\n set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);\n\n\n cpu->midr = 0x41069265;\n\n cpu->reset_fpsid = 0x41011090;\n\n cpu->ctr = 0x1dd20d2;\n\n cpu->reset_sctlr = 0x00090078;\n\n}", + "output": "1", + "index": 13536 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_thread_create(QemuThread *thread, const char *name,\n\n void *(*start_routine)(void*),\n\n void *arg, int mode)\n\n{\n\n sigset_t set, oldset;\n\n int err;\n\n pthread_attr_t attr;\n\n\n\n err = pthread_attr_init(&attr);\n\n if (err) {\n\n error_exit(err, __func__);\n\n }\n\n if (mode == QEMU_THREAD_DETACHED) {\n\n err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n\n if (err) {\n\n error_exit(err, __func__);\n\n }\n\n }\n\n\n\n /* Leave signal handling to the iothread. */\n\n sigfillset(&set);\n\n pthread_sigmask(SIG_SETMASK, &set, &oldset);\n\n err = pthread_create(&thread->thread, &attr, start_routine, arg);\n\n if (err)\n\n error_exit(err, __func__);\n\n\n\n if (name_threads) {\n\n qemu_thread_set_name(thread, name);\n\n }\n\n\n\n pthread_sigmask(SIG_SETMASK, &oldset, NULL);\n\n\n\n pthread_attr_destroy(&attr);\n\n}\n", + "output": "1", + "index": 1999 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down)\n\n{\n\n KeyValue *key = g_new0(KeyValue, 1);\n\n key->type = KEY_VALUE_KIND_NUMBER;\n\n key->u.number = num;\n\n qemu_input_event_send_key(src, key, down);\n\n}\n", + "output": "0", + "index": 4401 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)\n\n{\n\n struct capture_callback *cb;\n\n\n\n for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {\n\n if (cb->opaque == cb_opaque) {\n\n cb->ops.destroy (cb_opaque);\n\n LIST_REMOVE (cb, entries);\n\n qemu_free (cb);\n\n\n\n if (!cap->cb_head.lh_first) {\n\n SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;\n\n\n\n while (sw) {\n\n SWVoiceCap *sc = (SWVoiceCap *) sw;\n\n#ifdef DEBUG_CAPTURE\n\n dolog (\"freeing %s\\n\", sw->name);\n\n#endif\n\n\n\n sw1 = sw->entries.le_next;\n\n if (sw->rate) {\n\n st_rate_stop (sw->rate);\n\n sw->rate = NULL;\n\n }\n\n LIST_REMOVE (sw, entries);\n\n LIST_REMOVE (sc, entries);\n\n qemu_free (sc);\n\n sw = sw1;\n\n }\n\n LIST_REMOVE (cap, entries);\n\n qemu_free (cap);\n\n }\n\n return;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 26604 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button,\n\n void *opaque)\n\n{\n\n VirtualConsole *vc = opaque;\n\n GtkDisplayState *s = vc->s;\n\n InputButton btn;\n\n\n\n /* implicitly grab the input at the first click in the relative mode */\n\n if (button->button == 1 && button->type == GDK_BUTTON_PRESS &&\n\n !qemu_input_is_absolute() && !gd_is_grab_active(s)) {\n\n gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),\n\n TRUE);\n\n return TRUE;\n\n }\n\n\n\n if (button->button == 1) {\n\n btn = INPUT_BUTTON_LEFT;\n\n } else if (button->button == 2) {\n\n btn = INPUT_BUTTON_MIDDLE;\n\n } else if (button->button == 3) {\n\n btn = INPUT_BUTTON_RIGHT;\n\n } else {\n\n return TRUE;\n\n }\n\n\n\n qemu_input_queue_btn(vc->gfx.dcl.con, btn,\n\n button->type == GDK_BUTTON_PRESS);\n\n qemu_input_event_sync();\n\n return TRUE;\n\n}\n", + "output": "0", + "index": 20434 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)\n\n{\n\n if (cpu_sh4_is_cached (env, address))\n\n {\n\n\tmemory_content *r = malloc (sizeof(memory_content));\n\n\tr->address = address;\n\n\tr->value = value;\n\n\tr->next = NULL;\n\n\n\n\t*(env->movcal_backup_tail) = r;\n\n\tenv->movcal_backup_tail = &(r->next);\n\n }\n\n}\n", + "output": "1", + "index": 6817 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)\n\n{\n\n VirtIOGPU *g = VIRTIO_GPU(vdev);\n\n struct virtio_gpu_ctrl_command *cmd;\n\n\n\n if (!virtio_queue_ready(vq)) {\n\n return;\n\n }\n\n\n\n#ifdef CONFIG_VIRGL\n\n if (!g->renderer_inited && g->use_virgl_renderer) {\n\n virtio_gpu_virgl_init(g);\n\n g->renderer_inited = true;\n\n }\n\n#endif\n\n\n\n cmd = g_new(struct virtio_gpu_ctrl_command, 1);\n\n while (virtqueue_pop(vq, &cmd->elem)) {\n\n cmd->vq = vq;\n\n cmd->error = 0;\n\n cmd->finished = false;\n\n cmd->waiting = false;\n\n QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);\n\n cmd = g_new(struct virtio_gpu_ctrl_command, 1);\n\n }\n\n g_free(cmd);\n\n\n\n virtio_gpu_process_cmdq(g);\n\n\n\n#ifdef CONFIG_VIRGL\n\n if (g->use_virgl_renderer) {\n\n virtio_gpu_virgl_fence_poll(g);\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 16963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_input_send_event(int64_t console, InputEventList *events,\n\n Error **errp)\n\n{\n\n InputEventList *e;\n\n QemuConsole *con;\n\n\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 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": 9672 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ppc970_irq_init (CPUState *env)\n\n{\n\n env->irq_inputs = (void **)qemu_allocate_irqs(&ppc970_set_irq, env, 7);\n\n}\n", + "output": "1", + "index": 26935 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CharDriverState *qemu_chr_open_win_con(const char *id,\n\n ChardevBackend *backend,\n\n ChardevReturn *ret,\n\n Error **errp)\n\n{\n\n return qemu_chr_open_win_file(GetStdHandle(STD_OUTPUT_HANDLE));\n\n}\n", + "output": "0", + "index": 1987 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t helper_cmpbge(uint64_t op1, uint64_t op2)\n\n{\n\n#if defined(__SSE2__)\n\n uint64_t r;\n\n\n\n /* The cmpbge instruction is heavily used in the implementation of\n\n every string function on Alpha. We can do much better than either\n\n the default loop below, or even an unrolled version by using the\n\n native vector support. */\n\n {\n\n typedef uint64_t Q __attribute__((vector_size(16)));\n\n typedef uint8_t B __attribute__((vector_size(16)));\n\n\n\n Q q1 = (Q){ op1, 0 };\n\n Q q2 = (Q){ op2, 0 };\n\n\n\n q1 = (Q)((B)q1 >= (B)q2);\n\n\n\n r = q1[0];\n\n }\n\n\n\n /* Select only one bit from each byte. */\n\n r &= 0x0101010101010101;\n\n\n\n /* Collect the bits into the bottom byte. */\n\n /* .......A.......B.......C.......D.......E.......F.......G.......H */\n\n r |= r >> (8 - 1);\n\n\n\n /* .......A......AB......BC......CD......DE......EF......FG......GH */\n\n r |= r >> (16 - 2);\n\n\n\n /* .......A......AB.....ABC....ABCD....BCDE....CDEF....DEFG....EFGH */\n\n r |= r >> (32 - 4);\n\n\n\n /* .......A......AB.....ABC....ABCD...ABCDE..ABCDEF.ABCDEFGABCDEFGH */\n\n /* Return only the low 8 bits. */\n\n return r & 0xff;\n\n#else\n\n uint8_t opa, opb, res;\n\n int i;\n\n\n\n res = 0;\n\n for (i = 0; i < 8; i++) {\n\n opa = op1 >> (i * 8);\n\n opb = op2 >> (i * 8);\n\n if (opa >= opb) {\n\n res |= 1 << i;\n\n }\n\n }\n\n return res;\n\n#endif\n\n}\n", + "output": "1", + "index": 2341 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void iter_func(QObject *obj, void *opaque)\n\n{\n\n QInt *qi;\n\n\n\n fail_unless(opaque == NULL);\n\n\n\n qi = qobject_to_qint(obj);\n\n fail_unless(qi != NULL);\n\n fail_unless((qint_get_int(qi) >= 0) && (qint_get_int(qi) <= iter_max));\n\n\n\n iter_called++;\n\n}\n", + "output": "0", + "index": 3806 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void aio_set_event_notifier(AioContext *ctx,\n\n EventNotifier *e,\n\n EventNotifierHandler *io_notify)\n\n{\n\n AioHandler *node;\n\n\n\n QLIST_FOREACH(node, &ctx->aio_handlers, node) {\n\n if (node->e == e && !node->deleted) {\n\n break;\n\n }\n\n }\n\n\n\n /* Are we deleting the fd handler? */\n\n if (!io_notify) {\n\n if (node) {\n\n g_source_remove_poll(&ctx->source, &node->pfd);\n\n\n\n /* If the lock is held, just mark the node as deleted */\n\n if (ctx->walking_handlers) {\n\n node->deleted = 1;\n\n node->pfd.revents = 0;\n\n } else {\n\n /* Otherwise, delete it for real. We can't just mark it as\n\n * deleted because deleted nodes are only cleaned up after\n\n * releasing the walking_handlers lock.\n\n */\n\n QLIST_REMOVE(node, node);\n\n g_free(node);\n\n }\n\n }\n\n } else {\n\n if (node == NULL) {\n\n /* Alloc and insert if it's not already there */\n\n node = g_malloc0(sizeof(AioHandler));\n\n node->e = e;\n\n node->pfd.fd = (uintptr_t)event_notifier_get_handle(e);\n\n node->pfd.events = G_IO_IN;\n\n QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);\n\n\n\n g_source_add_poll(&ctx->source, &node->pfd);\n\n }\n\n /* Update handler with latest information */\n\n node->io_notify = io_notify;\n\n }\n\n\n\n aio_notify(ctx);\n\n}\n", + "output": "0", + "index": 26787 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg,\n\n uint32_t ra, uint32_t rb)\n\n{\n\n if (likely(xer_bc != 0)) {\n\n if (unlikely((ra != 0 && reg < ra && (reg + xer_bc) > ra) ||\n\n (reg < rb && (reg + xer_bc) > rb))) {\n\n helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,\n\n POWERPC_EXCP_INVAL |\n\n POWERPC_EXCP_INVAL_LSWX);\n\n } else {\n\n helper_lsw(env, addr, xer_bc, reg);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 24276 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static unsigned tget_long(GetByteContext *gb, int le)\n\n{\n\n unsigned v = le ? bytestream2_get_le32u(gb) : bytestream2_get_be32u(gb);\n\n return v;\n\n}\n", + "output": "0", + "index": 3385 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,\n AVFrame *frame,\n int *got_frame_ptr,\n AVPacket *avpkt)\n{\n int planar, channels;\n int ret = 0;\n *got_frame_ptr = 0;\n avctx->pkt = avpkt;\n if (!avpkt->data && avpkt->size) {\n av_log(avctx, AV_LOG_ERROR, \"invalid packet: NULL data, size != 0\\n\");\n return AVERROR(EINVAL);\n }\n apply_param_change(avctx, avpkt);\n if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {\n ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);\n if (ret >= 0 && *got_frame_ptr) {\n avctx->frame_number++;\n frame->pkt_dts = avpkt->dts;\n if (frame->format == AV_SAMPLE_FMT_NONE)\n frame->format = avctx->sample_fmt;\n }\n }\n /* many decoders assign whole AVFrames, thus overwriting extended_data;\n * make sure it's set correctly; assume decoders that actually use\n * extended_data are doing it correctly */\n planar = av_sample_fmt_is_planar(frame->format);\n channels = av_get_channel_layout_nb_channels(frame->channel_layout);\n if (!(planar && channels > AV_NUM_DATA_POINTERS))\n frame->extended_data = frame->data;\n return ret;\n}", + "output": "1", + "index": 25649 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_remove(void *opaque)\n\n{\n\n int32_t fid;\n\n int err = 0;\n\n size_t offset = 7;\n\n V9fsFidState *fidp;\n\n V9fsPDU *pdu = opaque;\n\n\n\n pdu_unmarshal(pdu, offset, \"d\", &fid);\n\n\n\n\n fidp = get_fid(pdu, fid);\n\n if (fidp == NULL) {\n\n err = -EINVAL;\n\n goto out_nofid;\n\n }\n\n /* if fs driver is not path based, return EOPNOTSUPP */\n\n if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {\n\n err = -EOPNOTSUPP;\n\n goto out_err;\n\n }\n\n /*\n\n * IF the file is unlinked, we cannot reopen\n\n * the file later. So don't reclaim fd\n\n */\n\n err = v9fs_mark_fids_unreclaim(pdu, &fidp->path);\n\n if (err < 0) {\n\n goto out_err;\n\n }\n\n err = v9fs_co_remove(pdu, &fidp->path);\n\n if (!err) {\n\n err = offset;\n\n }\n\nout_err:\n\n /* For TREMOVE we need to clunk the fid even on failed remove */\n\n clunk_fid(pdu->s, fidp->fid);\n\n put_fid(pdu, fidp);\n\nout_nofid:\n\n complete_pdu(pdu->s, pdu, err);\n\n}", + "output": "1", + "index": 24979 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t taihu_cpld_readb (void *opaque, hwaddr addr)\n\n{\n\n taihu_cpld_t *cpld;\n\n uint32_t ret;\n\n\n\n cpld = opaque;\n\n switch (addr) {\n\n case 0x0:\n\n ret = cpld->reg0;\n\n break;\n\n case 0x1:\n\n ret = cpld->reg1;\n\n break;\n\n default:\n\n ret = 0;\n\n break;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 12829 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int css_do_ssch(SubchDev *sch, ORB *orb)\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_STCTL_STATUS_PEND) {\n\n ret = -EINPROGRESS;\n\n goto out;\n\n }\n\n\n\n if (s->ctrl & (SCSW_FCTL_START_FUNC |\n\n SCSW_FCTL_HALT_FUNC |\n\n SCSW_FCTL_CLEAR_FUNC)) {\n\n ret = -EBUSY;\n\n goto out;\n\n }\n\n\n\n /* If monitoring is active, update counter. */\n\n if (channel_subsys.chnmon_active) {\n\n css_update_chnmon(sch);\n\n }\n\n sch->channel_prog = orb->cpa;\n\n /* Trigger the start function. */\n\n s->ctrl |= (SCSW_FCTL_START_FUNC | SCSW_ACTL_START_PEND);\n\n s->flags &= ~SCSW_FLAGS_MASK_PNO;\n\n\n\n do_subchannel_work(sch, orb);\n\n ret = 0;\n\n\n\nout:\n\n return ret;\n\n}\n", + "output": "0", + "index": 10719 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,\n\n QEMUTimer *timer,\n\n void (*raise_excp)(PowerPCCPU *),\n\n uint32_t decr, uint32_t value,\n\n int is_excp)\n\n{\n\n CPUPPCState *env = &cpu->env;\n\n ppc_tb_t *tb_env = env->tb_env;\n\n uint64_t now, next;\n\n\n\n LOG_TB(\"%s: %08\" PRIx32 \" => %08\" PRIx32 \"\\n\", __func__,\n\n decr, value);\n\n\n\n if (kvm_enabled()) {\n\n /* KVM handles decrementer exceptions, we don't need our own timer */\n\n return;\n\n }\n\n\n\n now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);\n\n next = now + muldiv64(value, get_ticks_per_sec(), tb_env->decr_freq);\n\n if (is_excp) {\n\n next += *nextp - now;\n\n }\n\n if (next == now) {\n\n next++;\n\n }\n\n *nextp = next;\n\n /* Adjust timer */\n\n timer_mod(timer, next);\n\n\n\n /* If we set a negative value and the decrementer was positive, raise an\n\n * exception.\n\n */\n\n if ((tb_env->flags & PPC_DECR_UNDERFLOW_TRIGGERED)\n\n && (value & 0x80000000)\n\n && !(decr & 0x80000000)) {\n\n (*raise_excp)(cpu);\n\n }\n\n}\n", + "output": "0", + "index": 20978 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "envlist_setenv(envlist_t *envlist, const char *env)\n\n{\n\n\tstruct envlist_entry *entry = NULL;\n\n\tconst char *eq_sign;\n\n\tsize_t envname_len;\n\n\n\n\tif ((envlist == NULL) || (env == NULL))\n\n\t\treturn (EINVAL);\n\n\n\n\t/* find out first equals sign in given env */\n\n\tif ((eq_sign = strchr(env, '=')) == NULL)\n\n\t\treturn (EINVAL);\n\n\tenvname_len = eq_sign - env + 1;\n\n\n\n\t/*\n\n\t * If there already exists variable with given name\n\n\t * we remove and release it before allocating a whole\n\n\t * new entry.\n\n\t */\n\n\tfor (entry = envlist->el_entries.lh_first; entry != NULL;\n\n\t entry = entry->ev_link.le_next) {\n\n\t\tif (strncmp(entry->ev_var, env, envname_len) == 0)\n\n\t\t\tbreak;\n\n\t}\n\n\n\n\tif (entry != NULL) {\n\n\t\tLIST_REMOVE(entry, ev_link);\n\n\t\tfree((char *)entry->ev_var);\n\n\t\tfree(entry);\n\n\t} else {\n\n\t\tenvlist->el_count++;\n\n\t}\n\n\n\n\tif ((entry = malloc(sizeof (*entry))) == NULL)\n\n\t\treturn (errno);\n\n\tif ((entry->ev_var = strdup(env)) == NULL) {\n\n\t\tfree(entry);\n\n\t\treturn (errno);\n\n\t}\n\n\tLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);\n\n\n\n\treturn (0);\n\n}\n", + "output": "0", + "index": 15419 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int ape_decode_value(APEContext *ctx, APERice *rice)\n\n{\n\n int x, overflow;\n\n\n\n if (ctx->fileversion < 3990) {\n\n int tmpk;\n\n\n\n overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970);\n\n\n\n if (overflow == (MODEL_ELEMENTS - 1)) {\n\n tmpk = range_decode_bits(ctx, 5);\n\n overflow = 0;\n\n } else\n\n tmpk = (rice->k < 1) ? 0 : rice->k - 1;\n\n\n\n if (tmpk <= 16)\n\n x = range_decode_bits(ctx, tmpk);\n\n else {\n\n x = range_decode_bits(ctx, 16);\n\n x |= (range_decode_bits(ctx, tmpk - 16) << 16);\n\n }\n\n x += overflow << tmpk;\n\n } else {\n\n int base, pivot;\n\n\n\n pivot = rice->ksum >> 5;\n\n if (pivot == 0)\n\n pivot = 1;\n\n\n\n overflow = range_get_symbol(ctx, counts_3980, counts_diff_3980);\n\n\n\n if (overflow == (MODEL_ELEMENTS - 1)) {\n\n overflow = range_decode_bits(ctx, 16) << 16;\n\n overflow |= range_decode_bits(ctx, 16);\n\n }\n\n\n\n if (pivot < 0x10000) {\n\n base = range_decode_culfreq(ctx, pivot);\n\n range_decode_update(ctx, 1, base);\n\n } else {\n\n int base_hi = pivot, base_lo;\n\n int bbits = 0;\n\n\n\n while (base_hi & ~0xFFFF) {\n\n base_hi >>= 1;\n\n bbits++;\n\n }\n\n base_hi = range_decode_culfreq(ctx, base_hi + 1);\n\n range_decode_update(ctx, 1, base_hi);\n\n base_lo = range_decode_culfreq(ctx, 1 << bbits);\n\n range_decode_update(ctx, 1, base_lo);\n\n\n\n base = (base_hi << bbits) + base_lo;\n\n }\n\n\n\n x = base + overflow * pivot;\n\n }\n\n\n\n update_rice(rice, x);\n\n\n\n /* Convert to signed */\n\n if (x & 1)\n\n return (x >> 1) + 1;\n\n else\n\n return -(x >> 1);\n\n}\n", + "output": "0", + "index": 6618 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void virtio_save(VirtIODevice *vdev, QEMUFile *f)\n\n{\n\n BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));\n\n VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n\n uint32_t guest_features_lo = (vdev->guest_features & 0xffffffff);\n\n int i;\n\n\n\n if (k->save_config) {\n\n k->save_config(qbus->parent, f);\n\n }\n\n\n\n qemu_put_8s(f, &vdev->status);\n\n qemu_put_8s(f, &vdev->isr);\n\n qemu_put_be16s(f, &vdev->queue_sel);\n\n qemu_put_be32s(f, &guest_features_lo);\n\n qemu_put_be32(f, vdev->config_len);\n\n qemu_put_buffer(f, vdev->config, vdev->config_len);\n\n\n\n for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {\n\n if (vdev->vq[i].vring.num == 0)\n\n break;\n\n }\n\n\n\n qemu_put_be32(f, i);\n\n\n\n for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {\n\n if (vdev->vq[i].vring.num == 0)\n\n break;\n\n\n\n qemu_put_be32(f, vdev->vq[i].vring.num);\n\n if (k->has_variable_vring_alignment) {\n\n qemu_put_be32(f, vdev->vq[i].vring.align);\n\n }\n\n /* XXX virtio-1 devices */\n\n qemu_put_be64(f, vdev->vq[i].vring.desc);\n\n qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);\n\n if (k->save_queue) {\n\n k->save_queue(qbus->parent, i, f);\n\n }\n\n }\n\n\n\n if (vdc->save != NULL) {\n\n vdc->save(vdev, f);\n\n }\n\n\n\n if (vdc->vmsd) {\n\n vmstate_save_state(f, vdc->vmsd, vdev, NULL);\n\n }\n\n\n\n /* Subsections */\n\n vmstate_save_state(f, &vmstate_virtio, vdev, NULL);\n\n}\n", + "output": "1", + "index": 15214 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rv34_idct_add_c(uint8_t *dst, int 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": "1", + "index": 23568 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_store_fpcr (uint64_t val)\n\n{\n\n#ifdef CONFIG_SOFTFLOAT\n\n set_float_exception_flags((val >> 52) & 0x3F, &FP_STATUS);\n\n#endif\n\n switch ((val >> 58) & 3) {\n\n case 0:\n\n set_float_rounding_mode(float_round_to_zero, &FP_STATUS);\n\n break;\n\n case 1:\n\n set_float_rounding_mode(float_round_down, &FP_STATUS);\n\n break;\n\n case 2:\n\n set_float_rounding_mode(float_round_nearest_even, &FP_STATUS);\n\n break;\n\n case 3:\n\n set_float_rounding_mode(float_round_up, &FP_STATUS);\n\n break;\n\n }\n\n}\n", + "output": "0", + "index": 1905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mpeg4video_probe(AVProbeData *probe_packet)\n\n{\n\n uint32_t temp_buffer= -1;\n\n int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;\n\n int i;\n\n\n\n for(i=0; ibuf_size; i++){\n\n temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];\n\n if ((temp_buffer & 0xffffff00) != 0x100)\n\n continue;\n\n\n\n if (temp_buffer == VOP_START_CODE) VOP++;\n\n else if (temp_buffer == VISUAL_OBJECT_START_CODE) VISO++;\n\n else if (temp_buffer < 0x120) VO++;\n\n else if (temp_buffer < 0x130) VOL++;\n\n else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)\n\n && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;\n\n }\n\n\n\n if (VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)\n\n return VOP+VO > 4 ? AVPROBE_SCORE_EXTENSION : AVPROBE_SCORE_EXTENSION/2;\n\n return 0;\n\n}\n", + "output": "0", + "index": 20825 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void mcf_fec_init(MemoryRegion *sysmem, NICInfo *nd,\n\n target_phys_addr_t base, qemu_irq *irq)\n\n{\n\n mcf_fec_state *s;\n\n\n\n qemu_check_nic_model(nd, \"mcf_fec\");\n\n\n\n s = (mcf_fec_state *)g_malloc0(sizeof(mcf_fec_state));\n\n s->sysmem = sysmem;\n\n s->irq = irq;\n\n\n\n memory_region_init_io(&s->iomem, &mcf_fec_ops, s, \"fec\", 0x400);\n\n memory_region_add_subregion(sysmem, base, &s->iomem);\n\n\n\n s->conf.macaddr = nd->macaddr;\n\n s->conf.peer = nd->netdev;\n\n\n\n s->nic = qemu_new_nic(&net_mcf_fec_info, &s->conf, nd->model, nd->name, s);\n\n\n\n qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);\n\n}\n", + "output": "0", + "index": 10883 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sb16_realizefn (DeviceState *dev, Error **errp)\n\n{\n\n ISADevice *isadev = ISA_DEVICE (dev);\n\n SB16State *s = SB16 (dev);\n\n IsaDmaClass *k;\n\n\n\n isa_init_irq (isadev, &s->pic, s->irq);\n\n\n\n s->mixer_regs[0x80] = magic_of_irq (s->irq);\n\n s->mixer_regs[0x81] = (1 << s->dma) | (1 << s->hdma);\n\n s->mixer_regs[0x82] = 2 << 5;\n\n\n\n s->csp_regs[5] = 1;\n\n s->csp_regs[9] = 0xf8;\n\n\n\n reset_mixer (s);\n\n s->aux_ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, aux_timer, s);\n\n if (!s->aux_ts) {\n\n dolog (\"warning: Could not create auxiliary timer\\n\");\n\n }\n\n\n\n isa_register_portio_list (isadev, s->port, sb16_ioport_list, s, \"sb16\");\n\n\n\n s->isa_hdma = isa_get_dma(isa_bus_from_device(isadev), s->hdma);\n\n k = ISADMA_GET_CLASS(s->isa_hdma);\n\n k->register_channel(s->isa_hdma, s->hdma, SB_read_DMA, s);\n\n\n\n s->isa_dma = isa_get_dma(isa_bus_from_device(isadev), s->dma);\n\n k = ISADMA_GET_CLASS(s->isa_dma);\n\n k->register_channel(s->isa_dma, s->dma, SB_read_DMA, s);\n\n\n\n s->can_write = 1;\n\n\n\n AUD_register_card (\"sb16\", &s->card);\n\n}\n", + "output": "1", + "index": 24107 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hwmap_filter_frame(AVFilterLink *link, AVFrame *input)\n\n{\n\n AVFilterContext *avctx = link->dst;\n\n AVFilterLink *outlink = avctx->outputs[0];\n\n HWMapContext *ctx = avctx->priv;\n\n AVFrame *map = NULL;\n\n int err;\n\n\n\n av_log(ctx, AV_LOG_DEBUG, \"Filter input: %s, %ux%u (%\"PRId64\").\\n\",\n\n av_get_pix_fmt_name(input->format),\n\n input->width, input->height, input->pts);\n\n\n\n map = av_frame_alloc();\n\n if (!map) {\n\n err = AVERROR(ENOMEM);\n\n goto fail;\n\n }\n\n\n\n map->format = outlink->format;\n\n map->hw_frames_ctx = av_buffer_ref(ctx->hwframes_ref);\n\n if (!map->hw_frames_ctx) {\n\n err = AVERROR(ENOMEM);\n\n goto fail;\n\n }\n\n\n\n if (ctx->map_backwards && !input->hw_frames_ctx) {\n\n // If we mapped backwards from hardware to software, we need\n\n // to attach the hardware frame context to the input frame to\n\n // make the mapping visible to av_hwframe_map().\n\n input->hw_frames_ctx = av_buffer_ref(ctx->hwframes_ref);\n\n if (!input->hw_frames_ctx) {\n\n err = AVERROR(ENOMEM);\n\n goto fail;\n\n }\n\n }\n\n\n\n err = av_hwframe_map(map, input, ctx->mode);\n\n if (err < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Failed to map frame: %d.\\n\", err);\n\n goto fail;\n\n }\n\n\n\n err = av_frame_copy_props(map, input);\n\n if (err < 0)\n\n goto fail;\n\n\n\n av_frame_free(&input);\n\n\n\n av_log(ctx, AV_LOG_DEBUG, \"Filter output: %s, %ux%u (%\"PRId64\").\\n\",\n\n av_get_pix_fmt_name(map->format),\n\n map->width, map->height, map->pts);\n\n\n\n return ff_filter_frame(outlink, map);\n\n\n\nfail:\n\n av_frame_free(&input);\n\n av_frame_free(&map);\n\n return err;\n\n}\n", + "output": "1", + "index": 5176 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void palette8torgb15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)\n\n{\n\n\tlong i;\n\n\tfor(i=0; iports_map[i] &= ~(1U << (port_id % 32));\n\n\n\n port = find_port_by_id(vser, port_id);\n\n /*\n\n * This function is only called from qdev's unplug callback; if we\n\n * get a NULL port here, we're in trouble.\n\n */\n\n assert(port);\n\n\n\n /* Flush out any unconsumed buffers first */\n\n discard_vq_data(port->ovq, VIRTIO_DEVICE(port->vser));\n\n\n\n send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_REMOVE, 1);\n\n}\n", + "output": "1", + "index": 23430 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void imx_epit_reset(DeviceState *dev)\n\n{\n\n IMXEPITState *s = IMX_EPIT(dev);\n\n\n\n /*\n\n * Soft reset doesn't touch some bits; hard reset clears them\n\n */\n\n s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN);\n\n s->sr = 0;\n\n s->lr = TIMER_MAX;\n\n s->cmp = 0;\n\n s->cnt = 0;\n\n /* stop both timers */\n\n ptimer_stop(s->timer_cmp);\n\n ptimer_stop(s->timer_reload);\n\n /* compute new frequency */\n\n imx_epit_set_freq(s);\n\n /* init both timers to TIMER_MAX */\n\n ptimer_set_limit(s->timer_cmp, TIMER_MAX, 1);\n\n ptimer_set_limit(s->timer_reload, TIMER_MAX, 1);\n\n if (s->freq && (s->cr & CR_EN)) {\n\n /* if the timer is still enabled, restart it */\n\n ptimer_run(s->timer_reload, 0);\n\n }\n\n}\n", + "output": "0", + "index": 23371 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_bridge_dev_initfn(PCIDevice *dev)\n\n{\n\n PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);\n\n PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br);\n\n int err;\n\n pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn);\n\n err = pci_bridge_initfn(dev);\n\n if (err) {\n\n goto bridge_error;\n\n }\n\n memory_region_init(&bridge_dev->bar, \"shpc-bar\", shpc_bar_size(dev));\n\n err = shpc_init(dev, &br->sec_bus, &bridge_dev->bar, 0);\n\n if (err) {\n\n goto shpc_error;\n\n }\n\n err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0);\n\n if (err) {\n\n goto slotid_error;\n\n }\n\n if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) &&\n\n msi_supported) {\n\n err = msi_init(dev, 0, 1, true, true);\n\n if (err < 0) {\n\n goto msi_error;\n\n }\n\n }\n\n /* TODO: spec recommends using 64 bit prefetcheable BAR.\n\n * Check whether that works well. */\n\n pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |\n\n\t\t PCI_BASE_ADDRESS_MEM_TYPE_64, &bridge_dev->bar);\n\n dev->config[PCI_INTERRUPT_PIN] = 0x1;\n\n return 0;\n\nmsi_error:\n\n slotid_cap_cleanup(dev);\n\nslotid_error:\n\n shpc_cleanup(dev, &bridge_dev->bar);\n\nshpc_error:\n\n memory_region_destroy(&bridge_dev->bar);\n\nbridge_error:\n\n return err;\n\n}\n", + "output": "1", + "index": 656 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_x86_set_a20(CPUX86State *env, int a20_state)\n\n{\n\n a20_state = (a20_state != 0);\n\n if (a20_state != a20_enabled) {\n\n#if defined(DEBUG_MMU)\n\n printf(\"A20 update: a20=%d\\n\", a20_state);\n\n#endif\n\n /* if the cpu is currently executing code, we must unlink it and\n\n all the potentially executing TB */\n\n cpu_interrupt(env, 0);\n\n\n\n /* when a20 is changed, all the MMU mappings are invalid, so\n\n we must flush everything */\n\n tlb_flush(env);\n\n a20_enabled = a20_state;\n\n if (a20_enabled)\n\n a20_mask = 0xffffffff;\n\n else\n\n a20_mask = 0xffefffff;\n\n }\n\n}\n", + "output": "0", + "index": 3047 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int wv_read_header(AVFormatContext *s,\n\n AVFormatParameters *ap)\n\n{\n\n ByteIOContext *pb = s->pb;\n\n WVContext *wc = s->priv_data;\n\n AVStream *st;\n\n\n\n if(wv_read_block_header(s, pb) < 0)\n\n return -1;\n\n\n\n wc->block_parsed = 0;\n\n /* now we are ready: build format streams */\n\n st = av_new_stream(s, 0);\n\n if (!st)\n\n return -1;\n\n st->codec->codec_type = CODEC_TYPE_AUDIO;\n\n st->codec->codec_id = CODEC_ID_WAVPACK;\n\n st->codec->channels = wc->chan;\n\n st->codec->sample_rate = wc->rate;\n\n st->codec->bits_per_coded_sample = wc->bpp;\n\n av_set_pts_info(st, 64, 1, wc->rate);\n\n s->start_time = 0;\n\n s->duration = (int64_t)wc->samples * AV_TIME_BASE / st->codec->sample_rate;\n\n\n\n if(!url_is_streamed(s->pb)) {\n\n int64_t cur = url_ftell(s->pb);\n\n ff_ape_parse_tag(s);\n\n if(!av_metadata_get(s->metadata, \"\", NULL, AV_METADATA_IGNORE_SUFFIX))\n\n ff_id3v1_read(s);\n\n url_fseek(s->pb, cur, SEEK_SET);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15362 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int net_rx_ok(NetClientState *nc)\n\n{\n\n struct XenNetDev *netdev = qemu_get_nic_opaque(nc);\n\n RING_IDX rc, rp;\n\n\n\n if (netdev->xendev.be_state != XenbusStateConnected) {\n\n return 0;\n\n }\n\n\n\n rc = netdev->rx_ring.req_cons;\n\n rp = netdev->rx_ring.sring->req_prod;\n\n xen_rmb();\n\n\n\n if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {\n\n xen_be_printf(&netdev->xendev, 2, \"%s: no rx buffers (%d/%d)\\n\",\n\n __FUNCTION__, rc, rp);\n\n return 0;\n\n }\n\n return 1;\n\n}\n", + "output": "0", + "index": 18229 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,\n\n const char *child_name,\n\n const BdrvChildRole *child_role,\n\n void *opaque)\n\n{\n\n BdrvChild *child = g_new(BdrvChild, 1);\n\n *child = (BdrvChild) {\n\n .bs = NULL,\n\n .name = g_strdup(child_name),\n\n .role = child_role,\n\n .opaque = opaque,\n\n };\n\n\n\n bdrv_replace_child(child, child_bs);\n\n\n\n return child;\n\n}\n", + "output": "0", + "index": 16997 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void store_cpu_offset(TCGv var, int offset)\n\n{\n\n tcg_gen_st_i32(var, cpu_env, offset);\n\n dead_tmp(var);\n\n}\n", + "output": "1", + "index": 2333 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,\n\n int hotplugged, int add)\n\n{\n\n uint8_t guest_cssid;\n\n bool chain_crw;\n\n\n\n if (add && !hotplugged) {\n\n return;\n\n }\n\n if (channel_subsys.max_cssid == 0) {\n\n /* Default cssid shows up as 0. */\n\n guest_cssid = (cssid == channel_subsys.default_cssid) ? 0 : cssid;\n\n } else {\n\n /* Show real cssid to the guest. */\n\n guest_cssid = cssid;\n\n }\n\n /*\n\n * Only notify for higher subchannel sets/channel subsystems if the\n\n * guest has enabled it.\n\n */\n\n if ((ssid > channel_subsys.max_ssid) ||\n\n (guest_cssid > channel_subsys.max_cssid) ||\n\n ((channel_subsys.max_cssid == 0) &&\n\n (cssid != channel_subsys.default_cssid))) {\n\n return;\n\n }\n\n chain_crw = (channel_subsys.max_ssid > 0) ||\n\n (channel_subsys.max_cssid > 0);\n\n css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid);\n\n if (chain_crw) {\n\n css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,\n\n (guest_cssid << 8) | (ssid << 4));\n\n }\n\n /* RW_ERC_IPI --> clear pending interrupts */\n\n css_clear_io_interrupt(css_do_build_subchannel_id(cssid, ssid), schid);\n\n}\n", + "output": "0", + "index": 18352 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma)\n\n{\n\n int i;\n\n RDMALocalBlocks *local = &rdma->local_ram_blocks;\n\n\n\n for (i = 0; i < local->nb_blocks; i++) {\n\n local->block[i].mr =\n\n ibv_reg_mr(rdma->pd,\n\n local->block[i].local_host_addr,\n\n local->block[i].length,\n\n IBV_ACCESS_LOCAL_WRITE |\n\n IBV_ACCESS_REMOTE_WRITE\n\n );\n\n if (!local->block[i].mr) {\n\n perror(\"Failed to register local dest ram block!\\n\");\n\n break;\n\n }\n\n rdma->total_registrations++;\n\n }\n\n\n\n if (i >= local->nb_blocks) {\n\n return 0;\n\n }\n\n\n\n for (i--; i >= 0; i--) {\n\n ibv_dereg_mr(local->block[i].mr);\n\n rdma->total_registrations--;\n\n }\n\n\n\n return -1;\n\n\n\n}\n", + "output": "1", + "index": 17390 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline int ppcemb_tlb_check(CPUState *env, ppcemb_tlb_t *tlb,\n\n target_phys_addr_t *raddrp,\n\n target_ulong address, uint32_t pid, int ext,\n\n int i)\n\n{\n\n target_ulong mask;\n\n\n\n /* Check valid flag */\n\n if (!(tlb->prot & PAGE_VALID)) {\n\n qemu_log(\"%s: TLB %d not valid\\n\", __func__, i);\n\n return -1;\n\n }\n\n mask = ~(tlb->size - 1);\n\n LOG_SWTLB(\"%s: TLB %d address \" TARGET_FMT_lx \" PID %u <=> \" TARGET_FMT_lx\n\n \" \" TARGET_FMT_lx \" %u\\n\", __func__, i, address, pid, tlb->EPN,\n\n mask, (uint32_t)tlb->PID);\n\n /* Check PID */\n\n if (tlb->PID != 0 && tlb->PID != pid)\n\n return -1;\n\n /* Check effective address */\n\n if ((address & mask) != tlb->EPN)\n\n return -1;\n\n *raddrp = (tlb->RPN & mask) | (address & ~mask);\n\n#if (TARGET_PHYS_ADDR_BITS >= 36)\n\n if (ext) {\n\n /* Extend the physical address to 36 bits */\n\n *raddrp |= (target_phys_addr_t)(tlb->RPN & 0xF) << 32;\n\n }\n\n#endif\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 6528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,\n\n VirtQueue *vq,\n\n EventNotifierHandler *handler,\n\n 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 VirtIOSCSIVring *r = g_slice_new(VirtIOSCSIVring);\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 exit(1);\n\n }\n\n r->host_notifier = *virtio_queue_get_host_notifier(vq);\n\n r->guest_notifier = *virtio_queue_get_guest_notifier(vq);\n\n aio_set_event_notifier(s->ctx, &r->host_notifier, handler);\n\n\n\n r->parent = s;\n\n\n\n if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) {\n\n fprintf(stderr, \"virtio-scsi: VRing setup failed\\n\");\n\n exit(1);\n\n }\n\n return r;\n\n}\n", + "output": "1", + "index": 6946 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int r4k_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,\n\n target_ulong address, int rw, int access_type)\n\n{\n\n uint8_t ASID = env->CP0_EntryHi & 0xFF;\n\n int i;\n\n\n\n for (i = 0; i < env->tlb->tlb_in_use; i++) {\n\n r4k_tlb_t *tlb = &env->tlb->mmu.r4k.tlb[i];\n\n /* 1k pages are not supported. */\n\n target_ulong mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);\n\n target_ulong tag = address & ~mask;\n\n target_ulong VPN = tlb->VPN & ~mask;\n\n#if defined(TARGET_MIPS64)\n\n tag &= env->SEGMask;\n\n#endif\n\n\n\n /* Check ASID, virtual page number & size */\n\n if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) {\n\n /* TLB match */\n\n int n = !!(address & mask & ~(mask >> 1));\n\n /* Check access rights */\n\n if (!(n ? tlb->V1 : tlb->V0)) {\n\n return TLBRET_INVALID;\n\n }\n\n if (rw == MMU_INST_FETCH && (n ? tlb->XI1 : tlb->XI0)) {\n\n return TLBRET_XI;\n\n }\n\n if (rw == MMU_DATA_LOAD && (n ? tlb->RI1 : tlb->RI0)) {\n\n return TLBRET_RI;\n\n }\n\n if (rw != MMU_DATA_STORE || (n ? tlb->D1 : tlb->D0)) {\n\n *physical = tlb->PFN[n] | (address & (mask >> 1));\n\n *prot = PAGE_READ;\n\n if (n ? tlb->D1 : tlb->D0)\n\n *prot |= PAGE_WRITE;\n\n return TLBRET_MATCH;\n\n }\n\n return TLBRET_DIRTY;\n\n }\n\n }\n\n return TLBRET_NOMATCH;\n\n}\n", + "output": "0", + "index": 10990 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void blizzard_screen_dump(void *opaque, const char *filename,\n\n bool cswitch, Error **errp)\n\n{\n\n BlizzardState *s = (BlizzardState *) opaque;\n\n DisplaySurface *surface = qemu_console_surface(s->con);\n\n\n\n blizzard_update_display(opaque);\n\n if (s && surface_data(surface)) {\n\n ppm_save(filename, surface, errp);\n\n }\n\n}\n", + "output": "0", + "index": 16324 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void event_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->bus_type = TYPE_SCLP_EVENTS_BUS;\n\n dc->unplug = qdev_simple_unplug_cb;\n\n dc->init = event_qdev_init;\n\n dc->exit = event_qdev_exit;\n\n}\n", + "output": "1", + "index": 14134 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)\n\n{\n\n dprint(1, \"%s:\\n\", __FUNCTION__);\n\n\n\n qemu_mutex_unlock_iothread();\n\n ssd->worker->destroy_primary_surface(ssd->worker, 0);\n\n qemu_mutex_lock_iothread();\n\n}\n", + "output": "1", + "index": 13470 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void cris_update_result(DisasContext *dc, TCGv res)\n\n{\n\n\tif (dc->update_cc) {\n\n\t\tif (dc->cc_size == 4 && \n\n\t\t (dc->cc_op == CC_OP_SUB\n\n\t\t || dc->cc_op == CC_OP_ADD))\n\n\t\t\treturn;\n\n\t\ttcg_gen_mov_tl(cc_result, res);\n\n\t}\n\n}\n", + "output": "0", + "index": 6286 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void dealloc_helper(void *native_in, VisitorFunc visit, Error **errp)\n\n{\n\n QapiDeallocVisitor *qdv = qapi_dealloc_visitor_new();\n\n\n\n visit(qapi_dealloc_get_visitor(qdv), &native_in, errp);\n\n\n\n qapi_dealloc_visitor_cleanup(qdv);\n\n}\n", + "output": "0", + "index": 15032 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)\n\n{\n\n int cylinders, heads, secs;\n\n uint64_t nb_sectors;\n\n\n\n if (dinfo && dinfo->bdrv) {\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 strncpy(s->drive_serial_str, drive_get_serial(s->bs),\n\n sizeof(s->drive_serial_str));\n\n }\n\n if (strlen(s->drive_serial_str) == 0)\n\n snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),\n\n \"QM%05d\", s->drive_serial);\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": 5576 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1)\n\n{\n\n int cssid, ssid, schid, m;\n\n SubchDev *sch;\n\n int ret = -ENODEV;\n\n int cc;\n\n\n\n if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {\n\n program_interrupt(&cpu->env, PGM_OPERAND, 2);\n\n return;\n\n }\n\n trace_ioinst_sch_id(\"xsch\", 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_xsch(sch);\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": 25963 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vhost_iommu_region_add(MemoryListener *listener,\n\n MemoryRegionSection *section)\n\n{\n\n struct vhost_dev *dev = container_of(listener, struct vhost_dev,\n\n iommu_listener);\n\n struct vhost_iommu *iommu;\n\n\n\n if (!memory_region_is_iommu(section->mr)) {\n\n return;\n\n }\n\n\n\n iommu = g_malloc0(sizeof(*iommu));\n\n iommu->n.notify = vhost_iommu_unmap_notify;\n\n iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;\n\n iommu->mr = section->mr;\n\n iommu->iommu_offset = section->offset_within_address_space -\n\n section->offset_within_region;\n\n iommu->hdev = dev;\n\n memory_region_register_iommu_notifier(section->mr, &iommu->n);\n\n QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);\n\n /* TODO: can replay help performance here? */\n\n}\n", + "output": "0", + "index": 13005 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int mp_decode_init(AVCodecContext *avctx)\n\n{\n\n MotionPixelsContext *mp = avctx->priv_data;\n\n int w4 = (avctx->width + 3) & ~3;\n\n int h4 = (avctx->height + 3) & ~3;\n\n\n\n if(avctx->extradata_size < 2){\n\n av_log(avctx, AV_LOG_ERROR, \"extradata too small\\n\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n motionpixels_tableinit();\n\n mp->avctx = avctx;\n\n ff_dsputil_init(&mp->dsp, avctx);\n\n mp->changes_map = av_mallocz(avctx->width * h4);\n\n mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;\n\n mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel));\n\n mp->hpt = av_mallocz(h4 * w4 / 16 * sizeof(YuvPixel));\n\n\n\n avctx->pix_fmt = AV_PIX_FMT_RGB555;\n\n avcodec_get_frame_defaults(&mp->frame);\n\n return 0;\n\n}", + "output": "1", + "index": 20659 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int count)\n\n{\n\n IscsiLun *iscsilun = bs->opaque;\n\n struct IscsiTask iTask;\n\n struct unmap_list list;\n\n\n\n if (!is_byte_request_lun_aligned(offset, count, iscsilun)) {\n\n return -ENOTSUP;\n\n }\n\n\n\n if (!iscsilun->lbp.lbpu) {\n\n /* UNMAP is not supported by the target */\n\n return 0;\n\n }\n\n\n\n list.lba = offset / iscsilun->block_size;\n\n list.num = count / iscsilun->block_size;\n\n\n\n iscsi_co_init_iscsitask(iscsilun, &iTask);\n\nretry:\n\n if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,\n\n 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_CHECK_CONDITION) {\n\n /* the target might fail with a check condition if it\n\n is not happy with the alignment of the UNMAP request\n\n we silently fail in this case */\n\n return 0;\n\n }\n\n\n\n if (iTask.status != SCSI_STATUS_GOOD) {\n\n return iTask.err_code;\n\n }\n\n\n\n iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,\n\n count >> BDRV_SECTOR_BITS);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21554 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "rfc3986_parse_port(URI *uri, const char **str)\n\n{\n\n const char *cur = *str;\n\n\n\n if (ISA_DIGIT(cur)) {\n\n\tif (uri != NULL)\n\n\t uri->port = 0;\n\n\twhile (ISA_DIGIT(cur)) {\n\n\t if (uri != NULL)\n\n\t\turi->port = uri->port * 10 + (*cur - '0');\n\n\t cur++;\n\n\t}\n\n\t*str = cur;\n\n\treturn(0);\n\n }\n\n return(1);\n\n}\n", + "output": "1", + "index": 15265 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ebml_read_ascii(AVIOContext *pb, int size, char **str)\n\n{\n\n av_free(*str);\n\n /* EBML strings are usually not 0-terminated, so we allocate one\n\n * byte more, read the string and NULL-terminate it ourselves. */\n\n if (!(*str = av_malloc(size + 1)))\n\n return AVERROR(ENOMEM);\n\n if (avio_read(pb, (uint8_t *) *str, size) != size) {\n\n av_freep(str);\n\n return AVERROR(EIO);\n\n }\n\n (*str)[size] = '\\0';\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 18688 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void v9fs_string_init(V9fsString *str)\n\n{\n\n str->data = NULL;\n\n str->size = 0;\n\n}\n", + "output": "0", + "index": 7484 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static GenericList *qmp_input_next_list(Visitor *v, GenericList *tail,\n\n size_t size)\n\n{\n\n QmpInputVisitor *qiv = to_qiv(v);\n\n StackObject *so = &qiv->stack[qiv->nb_stack - 1];\n\n\n\n if (!so->entry) {\n\n return NULL;\n\n }\n\n tail->next = g_malloc0(size);\n\n return tail->next;\n\n}\n", + "output": "0", + "index": 15180 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {\n\n ByteIOContext *pb = s->pb;\n\n pkt_type_t pkt_type;\n\n int pkt_len;\n\n while (!url_feof(pb)) {\n\n int track_type, track_id, ret;\n\n int field_nr;\n\n if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {\n\n if (!url_feof(pb))\n\n av_log(s, AV_LOG_ERROR, \"GXF: sync lost\\n\");\n\n return -1;\n\n }\n\n if (pkt_type == PKT_FLT) {\n\n gxf_read_index(s, pkt_len);\n\n continue;\n\n }\n\n if (pkt_type != PKT_MEDIA) {\n\n url_fskip(pb, pkt_len);\n\n continue;\n\n }\n\n if (pkt_len < 16) {\n\n av_log(s, AV_LOG_ERROR, \"GXF: invalid media packet length\\n\");\n\n continue;\n\n }\n\n pkt_len -= 16;\n\n track_type = get_byte(pb);\n\n track_id = get_byte(pb);\n\n field_nr = get_be32(pb);\n\n get_be32(pb); // field information\n\n get_be32(pb); // \"timeline\" field number\n\n get_byte(pb); // flags\n\n get_byte(pb); // reserved\n\n // NOTE: there is also data length information in the\n\n // field information, it might be better to take this into account\n\n // as well.\n\n ret = av_get_packet(pb, pkt, pkt_len);\n\n pkt->stream_index = get_sindex(s, track_id, track_type);\n\n pkt->dts = field_nr;\n\n return ret;\n\n }\n\n return AVERROR(EIO);\n\n}\n", + "output": "1", + "index": 5796 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t timer_expire_time_ns(QEMUTimer *ts)\n\n{\n\n return timer_pending(ts) ? ts->expire_time : -1;\n\n}\n", + "output": "0", + "index": 1187 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t imx_serial_read(void *opaque, target_phys_addr_t offset,\n\n unsigned size)\n\n{\n\n IMXSerialState *s = (IMXSerialState *)opaque;\n\n uint32_t c;\n\n\n\n DPRINTF(\"read(offset=%x)\\n\", offset >> 2);\n\n switch (offset >> 2) {\n\n case 0x0: /* URXD */\n\n c = s->readbuff;\n\n if (!(s->uts1 & UTS1_RXEMPTY)) {\n\n /* Character is valid */\n\n c |= URXD_CHARRDY;\n\n s->usr1 &= ~USR1_RRDY;\n\n s->usr2 &= ~USR2_RDR;\n\n s->uts1 |= UTS1_RXEMPTY;\n\n imx_update(s);\n\n qemu_chr_accept_input(s->chr);\n\n }\n\n return c;\n\n\n\n case 0x20: /* UCR1 */\n\n return s->ucr1;\n\n\n\n case 0x21: /* UCR2 */\n\n return s->ucr2;\n\n\n\n case 0x25: /* USR1 */\n\n return s->usr1;\n\n\n\n case 0x26: /* USR2 */\n\n return s->usr2;\n\n\n\n case 0x2A: /* BRM Modulator */\n\n return s->ubmr;\n\n\n\n case 0x2B: /* Baud Rate Count */\n\n return s->ubrc;\n\n\n\n case 0x2d: /* Test register */\n\n return s->uts1;\n\n\n\n case 0x24: /* UFCR */\n\n return s->ufcr;\n\n\n\n case 0x2c:\n\n return s->onems;\n\n\n\n case 0x22: /* UCR3 */\n\n return s->ucr3;\n\n\n\n case 0x23: /* UCR4 */\n\n case 0x29: /* BRM Incremental */\n\n return 0x0; /* TODO */\n\n\n\n default:\n\n IPRINTF(\"imx_serial_read: bad offset: 0x%x\\n\", (int)offset);\n\n return 0;\n\n }\n\n}\n", + "output": "0", + "index": 2746 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_end_struct(Visitor *v, Error **errp)\n\n{\n\n assert(!error_is_set(errp));\n\n v->end_struct(v, errp);\n\n}\n", + "output": "1", + "index": 1935 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline abi_long do_semctl(int semid, int semnum, int cmd,\n\n union target_semun target_su)\n\n{\n\n union semun arg;\n\n struct semid_ds dsarg;\n\n unsigned short *array;\n\n struct seminfo seminfo;\n\n abi_long ret = -TARGET_EINVAL;\n\n abi_long err;\n\n cmd &= 0xff;\n\n\n\n switch( cmd ) {\n\n\tcase GETVAL:\n\n\tcase SETVAL:\n\n arg.val = tswapl(target_su.val);\n\n ret = get_errno(semctl(semid, semnum, cmd, arg));\n\n target_su.val = tswapl(arg.val);\n\n break;\n\n\tcase GETALL:\n\n\tcase SETALL:\n\n err = target_to_host_semarray(semid, &array, target_su.array);\n\n if (err)\n\n return err;\n\n arg.array = array;\n\n ret = get_errno(semctl(semid, semnum, cmd, arg));\n\n err = host_to_target_semarray(semid, target_su.array, &array);\n\n if (err)\n\n return err;\n\n break;\n\n\tcase IPC_STAT:\n\n\tcase IPC_SET:\n\n\tcase SEM_STAT:\n\n err = target_to_host_semid_ds(&dsarg, target_su.buf);\n\n if (err)\n\n return err;\n\n arg.buf = &dsarg;\n\n ret = get_errno(semctl(semid, semnum, cmd, arg));\n\n err = host_to_target_semid_ds(target_su.buf, &dsarg);\n\n if (err)\n\n return err;\n\n break;\n\n\tcase IPC_INFO:\n\n\tcase SEM_INFO:\n\n arg.__buf = &seminfo;\n\n ret = get_errno(semctl(semid, semnum, cmd, arg));\n\n err = host_to_target_seminfo(target_su.__buf, &seminfo);\n\n if (err)\n\n return err;\n\n break;\n\n\tcase IPC_RMID:\n\n\tcase GETPID:\n\n\tcase GETNCNT:\n\n\tcase GETZCNT:\n\n ret = get_errno(semctl(semid, semnum, cmd, NULL));\n\n break;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 14311 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void cpu_breakpoint_remove_all(CPUState *cpu, int mask)\n\n{\n\n#if defined(TARGET_HAS_ICE)\n\n CPUBreakpoint *bp, *next;\n\n\n\n QTAILQ_FOREACH_SAFE(bp, &cpu->breakpoints, entry, next) {\n\n if (bp->flags & mask) {\n\n cpu_breakpoint_remove_by_ref(cpu, bp);\n\n }\n\n }\n\n#endif\n\n}\n", + "output": "0", + "index": 14473 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int aio_read_f(BlockBackend *blk, int argc, char **argv)\n\n{\n\n int nr_iov, c;\n\n struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);\n\n\n\n ctx->blk = blk;\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 g_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 g_free(ctx);\n\n return qemuio_command_usage(&aio_read_cmd);\n\n }\n\n }\n\n\n\n if (optind > argc - 2) {\n\n g_free(ctx);\n\n return qemuio_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 g_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 g_free(ctx);\n\n return 0;\n\n }\n\n\n\n nr_iov = argc - optind;\n\n ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, 0xab);\n\n if (ctx->buf == NULL) {\n\n g_free(ctx);\n\n return 0;\n\n }\n\n\n\n gettimeofday(&ctx->t1, NULL);\n\n block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,\n\n BLOCK_ACCT_READ);\n\n blk_aio_readv(blk, 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": 14730 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd){\n\n const int b_stride= s->b_width << s->block_max_depth;\n\n BlockNode *block= &s->block[mb_x + mb_y * b_stride];\n\n BlockNode backup[4]= {block[0], block[1], block[b_stride], block[b_stride+1]};\n\n int rd, index, value;\n\n\n\n assert(mb_x>=0 && mb_y>=0);\n\n assert(mb_xme_cache_generation + (p0>>10) + (p1<<6) + (block->ref<<12);\n\n if(s->me_cache[index] == value)\n\n return 0;\n\n s->me_cache[index]= value;\n\n\n\n block->mx= p0;\n\n block->my= p1;\n\n block->ref= ref;\n\n block->type &= ~BLOCK_INTRA;\n\n block[1]= block[b_stride]= block[b_stride+1]= *block;\n\n\n\n rd= get_4block_rd(s, mb_x, mb_y, 0);\n\n\n\n//FIXME chroma\n\n if(rd < *best_rd){\n\n *best_rd= rd;\n\n return 1;\n\n }else{\n\n block[0]= backup[0];\n\n block[1]= backup[1];\n\n block[b_stride]= backup[2];\n\n block[b_stride+1]= backup[3];\n\n return 0;\n\n }\n\n}\n", + "output": "1", + "index": 15759 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void roq_encode_video(RoqContext *enc)\n\n{\n\n RoqTempdata *tempData = enc->tmpData;\n\n int i;\n\n\n\n memset(tempData, 0, sizeof(*tempData));\n\n\n\n create_cel_evals(enc, tempData);\n\n\n\n generate_new_codebooks(enc, tempData);\n\n\n\n if (enc->framesSinceKeyframe >= 1) {\n\n motion_search(enc, 8);\n\n motion_search(enc, 4);\n\n }\n\n\n\n retry_encode:\n\n for (i=0; iwidth*enc->height/64; i++)\n\n gather_data_for_cel(tempData->cel_evals + i, enc, tempData);\n\n\n\n /* Quake 3 can't handle chunks bigger than 65536 bytes */\n\n if (tempData->mainChunkSize/8 > 65536) {\n\n enc->lambda *= .8;\n\n goto retry_encode;\n\n }\n\n\n\n remap_codebooks(enc, tempData);\n\n\n\n write_codebooks(enc, tempData);\n\n\n\n reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,\n\n enc->width*enc->height/64);\n\n\n\n enc->avctx->coded_frame = enc->current_frame;\n\n\n\n /* Rotate frame history */\n\n FFSWAP(AVFrame *, enc->current_frame, enc->last_frame);\n\n FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);\n\n FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);\n\n\n\n av_free(tempData->cel_evals);\n\n av_free(tempData->closest_cb2);\n\n\n\n enc->framesSinceKeyframe++;\n\n}\n", + "output": "0", + "index": 1831 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fw_cfg_io_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->realize = fw_cfg_io_realize;\n\n dc->props = fw_cfg_io_properties;\n\n\n\n\n\n\n}", + "output": "1", + "index": 19217 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)\n\n{\n\n int fd = monitor_get_fd(cur_mon, fdname, errp);\n\n if (fd == -1) {\n\n return;\n\n }\n\n s->file = qemu_fdopen(fd, \"wb\");\n\n\n\n migrate_fd_connect(s);\n\n}\n", + "output": "1", + "index": 2309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t ffm_read_write_index(int fd)\n\n{\n\n uint8_t buf[8];\n\n\n\n lseek(fd, 8, SEEK_SET);\n\n if (read(fd, buf, 8) != 8)\n\n return AVERROR(EIO);\n\n return AV_RB64(buf);\n\n}\n", + "output": "0", + "index": 13152 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer)\n\n{\n\n int category_index[128];\n\n int quant_index_table[102];\n\n int category[128];\n\n int ret;\n\n\n\n memset(&category, 0, sizeof(category));\n\n memset(&category_index, 0, sizeof(category_index));\n\n\n\n if ((ret = decode_envelope(q, p, quant_index_table)) < 0)\n\n return ret;\n\n q->num_vectors = get_bits(&q->gb, p->log2_numvector_size);\n\n categorize(q, p, quant_index_table, category, category_index);\n\n expand_category(q, category, category_index);\n\n decode_vectors(q, p, category, quant_index_table, mlt_buffer);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 22193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void omap_pin_cfg_init(MemoryRegion *system_memory,\n\n target_phys_addr_t base,\n\n struct omap_mpu_state_s *mpu)\n\n{\n\n memory_region_init_io(&mpu->pin_cfg_iomem, &omap_pin_cfg_ops, mpu,\n\n \"omap-pin-cfg\", 0x800);\n\n memory_region_add_subregion(system_memory, base, &mpu->pin_cfg_iomem);\n\n omap_pin_cfg_reset(mpu);\n\n}\n", + "output": "0", + "index": 1198 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel4_mc23_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_midv_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 1);\n\n}\n", + "output": "0", + "index": 12416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)\n\n{\n\n struct tcphdr *ptcp, *stcp;\n\n int res;\n\n\n\n trace_colo_compare_main(\"compare tcp\");\n\n\n\n ptcp = (struct tcphdr *)ppkt->transport_header;\n\n stcp = (struct tcphdr *)spkt->transport_header;\n\n\n\n /*\n\n * The 'identification' field in the IP header is *very* random\n\n * it almost never matches. Fudge this by ignoring differences in\n\n * unfragmented packets; they'll normally sort themselves out if different\n\n * anyway, and it should recover at the TCP level.\n\n * An alternative would be to get both the primary and secondary to rewrite\n\n * somehow; but that would need some sync traffic to sync the state\n\n */\n\n if (ntohs(ppkt->ip->ip_off) & IP_DF) {\n\n spkt->ip->ip_id = ppkt->ip->ip_id;\n\n /* and the sum will be different if the IDs were different */\n\n spkt->ip->ip_sum = ppkt->ip->ip_sum;\n\n }\n\n\n\n if (ptcp->th_sum == stcp->th_sum) {\n\n res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);\n\n } else {\n\n res = -1;\n\n }\n\n\n\n if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {\n\n trace_colo_compare_pkt_info_src(inet_ntoa(ppkt->ip->ip_src),\n\n ntohl(stcp->th_seq),\n\n ntohl(stcp->th_ack),\n\n res, stcp->th_flags,\n\n spkt->size);\n\n\n\n trace_colo_compare_pkt_info_dst(inet_ntoa(ppkt->ip->ip_dst),\n\n ntohl(ptcp->th_seq),\n\n ntohl(ptcp->th_ack),\n\n res, ptcp->th_flags,\n\n ppkt->size);\n\n\n\n qemu_hexdump((char *)ppkt->data, stderr,\n\n \"colo-compare ppkt\", ppkt->size);\n\n qemu_hexdump((char *)spkt->data, stderr,\n\n \"colo-compare spkt\", spkt->size);\n\n }\n\n\n\n return res;\n\n}\n", + "output": "0", + "index": 15426 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int parse_adaptation_sets(AVFormatContext *s)\n\n{\n\n WebMDashMuxContext *w = s->priv_data;\n\n char *p = w->adaptation_sets;\n\n char *q;\n\n enum { new_set, parsed_id, parsing_streams } state;\n\n // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on\n\n state = new_set;\n\n while (p < w->adaptation_sets + strlen(w->adaptation_sets)) {\n\n if (*p == ' ')\n\n continue;\n\n else if (state == new_set && !strncmp(p, \"id=\", 3)) {\n\n w->as = av_realloc(w->as, sizeof(*w->as) * ++w->nb_as);\n\n if (w->as == NULL) return -1;\n\n w->as[w->nb_as - 1].nb_streams = 0;\n\n w->as[w->nb_as - 1].streams = NULL;\n\n p += 3; // consume \"id=\"\n\n q = w->as[w->nb_as - 1].id;\n\n while (*p != ',') *q++ = *p++;\n\n *q = 0;\n\n p++;\n\n state = parsed_id;\n\n } else if (state == parsed_id && !strncmp(p, \"streams=\", 8)) {\n\n p += 8; // consume \"streams=\"\n\n state = parsing_streams;\n\n } else if (state == parsing_streams) {\n\n struct AdaptationSet *as = &w->as[w->nb_as - 1];\n\n q = p;\n\n while (*q != '\\0' && *q != ',' && *q != ' ') q++;\n\n as->streams = av_realloc(as->streams, sizeof(*as->streams) * ++as->nb_streams);\n\n if (as->streams == NULL) return -1;\n\n as->streams[as->nb_streams - 1] = to_integer(p, q - p);\n\n if (as->streams[as->nb_streams - 1] < 0) return -1;\n\n if (*q == '\\0') break;\n\n if (*q == ' ') state = new_set;\n\n p = ++q;\n\n } else {\n\n return -1;\n\n }\n\n }\n\n return 0;\n\n}\n", + "output": "0", + "index": 4340 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline abi_ulong do_shmat(int shmid, abi_ulong shmaddr, int shmflg)\n\n{\n\n abi_long raddr;\n\n void *host_raddr;\n\n struct shmid_ds shm_info;\n\n int i,ret;\n\n\n\n /* find out the length of the shared memory segment */\n\n ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));\n\n if (is_error(ret)) {\n\n /* can't get length, bail out */\n\n return ret;\n\n }\n\n\n\n mmap_lock();\n\n\n\n if (shmaddr)\n\n host_raddr = shmat(shmid, (void *)g2h(shmaddr), shmflg);\n\n else {\n\n abi_ulong mmap_start;\n\n\n\n mmap_start = mmap_find_vma(0, shm_info.shm_segsz);\n\n\n\n if (mmap_start == -1) {\n\n errno = ENOMEM;\n\n host_raddr = (void *)-1;\n\n } else\n\n host_raddr = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP);\n\n }\n\n\n\n if (host_raddr == (void *)-1) {\n\n mmap_unlock();\n\n return get_errno((long)host_raddr);\n\n }\n\n raddr=h2g((unsigned long)host_raddr);\n\n\n\n page_set_flags(raddr, raddr + shm_info.shm_segsz,\n\n PAGE_VALID | PAGE_READ |\n\n ((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));\n\n\n\n for (i = 0; i < N_SHM_REGIONS; i++) {\n\n if (!shm_regions[i].in_use) {\n\n shm_regions[i].in_use = true;\n\n shm_regions[i].start = raddr;\n\n shm_regions[i].size = shm_info.shm_segsz;\n\n break;\n\n }\n\n }\n\n\n\n mmap_unlock();\n\n return raddr;\n\n\n\n}\n", + "output": "1", + "index": 13900 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vnc_listen_read(void *opaque)\n\n{\n\n VncDisplay *vs = opaque;\n\n struct sockaddr_in addr;\n\n socklen_t addrlen = sizeof(addr);\n\n\n\n /* Catch-up */\n\n vga_hw_update();\n\n\n\n int csock = qemu_accept(vs->lsock, (struct sockaddr *)&addr, &addrlen);\n\n if (csock != -1) {\n\n vnc_connect(vs, csock);\n\n }\n\n}\n", + "output": "0", + "index": 2900 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,\n\n ram_addr_t size, void *host)\n\n{\n\n RAMBlock *new_block, *block;\n\n\n\n size = TARGET_PAGE_ALIGN(size);\n\n new_block = qemu_mallocz(sizeof(*new_block));\n\n\n\n if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {\n\n char *id = dev->parent_bus->info->get_dev_path(dev);\n\n if (id) {\n\n snprintf(new_block->idstr, sizeof(new_block->idstr), \"%s/\", id);\n\n qemu_free(id);\n\n }\n\n }\n\n pstrcat(new_block->idstr, sizeof(new_block->idstr), name);\n\n\n\n QLIST_FOREACH(block, &ram_list.blocks, next) {\n\n if (!strcmp(block->idstr, new_block->idstr)) {\n\n fprintf(stderr, \"RAMBlock \\\"%s\\\" already registered, abort!\\n\",\n\n new_block->idstr);\n\n abort();\n\n }\n\n }\n\n\n\n new_block->host = host;\n\n\n\n new_block->offset = find_ram_offset(size);\n\n new_block->length = size;\n\n\n\n QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next);\n\n\n\n ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty,\n\n last_ram_offset() >> TARGET_PAGE_BITS);\n\n memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),\n\n 0xff, size >> TARGET_PAGE_BITS);\n\n\n\n if (kvm_enabled())\n\n kvm_setup_guest_memory(new_block->host, size);\n\n\n\n return new_block->offset;\n\n}\n", + "output": "0", + "index": 8287 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static TCGv neon_load_reg(int reg, int pass)\n\n{\n\n TCGv tmp = new_tmp();\n\n tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass));\n\n return tmp;\n\n}\n", + "output": "1", + "index": 9825 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)\n\n{\n\n int i;\n\n int dc = block[0];\n\n const uint8_t *cm;\n\n dc = (3 * dc + 1) >> 1;\n\n dc = (3 * dc + 16) >> 5;\n\n cm = ff_cropTbl + MAX_NEG_CROP + dc;\n\n for(i = 0; i < 8; i++){\n\n dest[0] = cm[dest[0]];\n\n dest[1] = cm[dest[1]];\n\n dest[2] = cm[dest[2]];\n\n dest[3] = cm[dest[3]];\n\n dest[4] = cm[dest[4]];\n\n dest[5] = cm[dest[5]];\n\n dest[6] = cm[dest[6]];\n\n dest[7] = cm[dest[7]];\n\n dest += linesize;\n\n }\n\n}\n", + "output": "1", + "index": 121 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_st_cond (DisasContext *ctx, uint32_t opc, int rt,\n\n int base, int16_t offset)\n\n{\n\n const char *opn = \"st_cond\";\n\n TCGv t0, t1;\n\n\n\n t0 = tcg_temp_local_new();\n\n\n\n gen_base_offset_addr(ctx, t0, base, offset);\n\n /* Don't do NOP if destination is zero: we must perform the actual\n\n memory access. */\n\n\n\n t1 = tcg_temp_local_new();\n\n gen_load_gpr(t1, rt);\n\n switch (opc) {\n\n#if defined(TARGET_MIPS64)\n\n case OPC_SCD:\n\n save_cpu_state(ctx, 0);\n\n op_st_scd(t1, t0, rt, ctx);\n\n opn = \"scd\";\n\n break;\n\n#endif\n\n case OPC_SC:\n\n save_cpu_state(ctx, 1);\n\n op_st_sc(t1, t0, rt, ctx);\n\n opn = \"sc\";\n\n break;\n\n }\n\n (void)opn; /* avoid a compiler warning */\n\n MIPS_DEBUG(\"%s %s, %d(%s)\", opn, regnames[rt], offset, regnames[base]);\n\n tcg_temp_free(t1);\n\n tcg_temp_free(t0);\n\n}\n", + "output": "1", + "index": 3960 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size)\n\n{\n\n AVIOContext *pb = s->pb;\n\n uint32_t layout_tag, bitmap, num_descr, label_mask;\n\n int i;\n\n\n\n if (size < 12)\n\n return AVERROR_INVALIDDATA;\n\n\n\n layout_tag = avio_rb32(pb);\n\n bitmap = avio_rb32(pb);\n\n num_descr = avio_rb32(pb);\n\n\n\n av_dlog(s, \"chan: layout=%u bitmap=%u num_descr=%u\\n\",\n\n layout_tag, bitmap, num_descr);\n\n\n\n if (size < 12ULL + num_descr * 20ULL)\n\n return 0;\n\n\n\n label_mask = 0;\n\n for (i = 0; i < num_descr; i++) {\n\n uint32_t label;\n\n label = avio_rb32(pb); // mChannelLabel\n\n avio_rb32(pb); // mChannelFlags\n\n avio_rl32(pb); // mCoordinates[0]\n\n avio_rl32(pb); // mCoordinates[1]\n\n avio_rl32(pb); // mCoordinates[2]\n\n if (layout_tag == 0) {\n\n uint32_t mask_incr = mov_get_channel_label(label);\n\n if (mask_incr == 0) {\n\n label_mask = 0;\n\n break;\n\n }\n\n label_mask |= mask_incr;\n\n }\n\n }\n\n if (layout_tag == 0)\n\n st->codec->channel_layout = label_mask;\n\n else\n\n st->codec->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap);\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 13264 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)\n\n{\n\n M68kCPU *cpu = M68K_CPU(dev);\n\n M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev);\n\n\n\n m68k_cpu_init_gdb(cpu);\n\n\n\n cpu_reset(CPU(cpu));\n\n\n\n mcc->parent_realize(dev, errp);\n\n}\n", + "output": "1", + "index": 18694 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint64_t bdrv_get_align(BlockDriverState *bs)\n\n{\n\n /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */\n\n return MAX(BDRV_SECTOR_SIZE, bs->request_alignment);\n\n}\n", + "output": "0", + "index": 15799 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool qemu_co_queue_do_restart(CoQueue *queue, bool single)\n\n{\n\n Coroutine *next;\n\n CoQueueNextData *data;\n\n\n\n if (QTAILQ_EMPTY(&queue->entries)) {\n\n return false;\n\n }\n\n\n\n data = g_slice_new(CoQueueNextData);\n\n data->bh = aio_bh_new(queue->ctx, qemu_co_queue_next_bh, data);\n\n QTAILQ_INIT(&data->entries);\n\n qemu_bh_schedule(data->bh);\n\n\n\n while ((next = QTAILQ_FIRST(&queue->entries)) != NULL) {\n\n QTAILQ_REMOVE(&queue->entries, next, co_queue_next);\n\n QTAILQ_INSERT_TAIL(&data->entries, next, co_queue_next);\n\n trace_qemu_co_queue_next(next);\n\n if (single) {\n\n break;\n\n }\n\n }\n\n return true;\n\n}\n", + "output": "0", + "index": 20236 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int tmv_read_seek(AVFormatContext *s, int stream_index,\n\n int64_t timestamp, int flags)\n\n{\n\n TMVContext *tmv = s->priv_data;\n\n int64_t pos;\n\n\n\n if (stream_index)\n\n return -1;\n\n\n\n pos = timestamp *\n\n (tmv->audio_chunk_size + tmv->video_chunk_size + tmv->padding);\n\n\n\n avio_seek(s->pb, pos + TMV_HEADER_SIZE, SEEK_SET);\n\n tmv->stream_index = 0;\n\n return 0;\n\n}\n", + "output": "1", + "index": 3551 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static struct omap_rtc_s *omap_rtc_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_rtc_s *s = (struct omap_rtc_s *)\n\n g_malloc0(sizeof(struct omap_rtc_s));\n\n\n\n s->irq = irq[0];\n\n s->alarm = irq[1];\n\n s->clk = qemu_new_timer_ms(rt_clock, omap_rtc_tick, s);\n\n\n\n omap_rtc_reset(s);\n\n\n\n memory_region_init_io(&s->iomem, &omap_rtc_ops, s,\n\n \"omap-rtc\", 0x800);\n\n memory_region_add_subregion(system_memory, base, &s->iomem);\n\n\n\n return s;\n\n}\n", + "output": "0", + "index": 15647 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bufp_free(USBRedirDevice *dev, struct buf_packet *bufp,\n\n uint8_t ep)\n\n{\n\n QTAILQ_REMOVE(&dev->endpoint[EP2I(ep)].bufpq, bufp, next);\n\n dev->endpoint[EP2I(ep)].bufpq_size--;\n\n free(bufp->data);\n\n g_free(bufp);\n\n}\n", + "output": "1", + "index": 23201 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qdev_print_devinfos(bool show_no_user)\n\n{\n\n static const char *cat_name[DEVICE_CATEGORY_MAX + 1] = {\n\n [DEVICE_CATEGORY_BRIDGE] = \"Controller/Bridge/Hub\",\n\n [DEVICE_CATEGORY_USB] = \"USB\",\n\n [DEVICE_CATEGORY_STORAGE] = \"Storage\",\n\n [DEVICE_CATEGORY_NETWORK] = \"Network\",\n\n [DEVICE_CATEGORY_INPUT] = \"Input\",\n\n [DEVICE_CATEGORY_DISPLAY] = \"Display\",\n\n [DEVICE_CATEGORY_SOUND] = \"Sound\",\n\n [DEVICE_CATEGORY_MISC] = \"Misc\",\n\n [DEVICE_CATEGORY_MAX] = \"Uncategorized\",\n\n };\n\n GSList *list, *elt;\n\n int i;\n\n bool cat_printed;\n\n\n\n list = g_slist_sort(object_class_get_list(TYPE_DEVICE, false),\n\n devinfo_cmp);\n\n\n\n for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {\n\n cat_printed = false;\n\n for (elt = list; elt; elt = elt->next) {\n\n DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,\n\n TYPE_DEVICE);\n\n if ((i < DEVICE_CATEGORY_MAX\n\n ? !test_bit(i, dc->categories)\n\n : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))\n\n || (!show_no_user && dc->no_user)) {\n\n continue;\n\n }\n\n if (!cat_printed) {\n\n error_printf(\"%s%s devices:\\n\", i ? \"\\n\" : \"\",\n\n cat_name[i]);\n\n cat_printed = true;\n\n }\n\n qdev_print_devinfo(dc);\n\n }\n\n }\n\n\n\n g_slist_free(list);\n\n}\n", + "output": "1", + "index": 21834 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)\n\n{\n\n uint8_t buf[4096];\n\n target_phys_addr_t dst_begin = dst_addr;\n\n size_t want, did;\n\n\n\n while (nbytes) {\n\n\twant = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;\n\n\tdid = fread(buf, 1, want, f);\n\n\n\n\tcpu_physical_memory_write_rom(dst_addr, buf, did);\n\n\tdst_addr += did;\n\n\tnbytes -= did;\n\n\tif (did != want)\n\n\t break;\n\n }\n\n return dst_addr - dst_begin;\n\n}\n", + "output": "0", + "index": 23941 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v)\n\n{\n\n TCGv_i64 tcg_zero = tcg_const_i64(0);\n\n\n\n tcg_gen_st_i64(v, cpu_env, fp_reg_offset(reg, MO_64));\n\n tcg_gen_st_i64(tcg_zero, cpu_env, fp_reg_hi_offset(reg));\n\n tcg_temp_free_i64(tcg_zero);\n\n}\n", + "output": "0", + "index": 15614 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int nbd_receive_reply(int csock, struct nbd_reply *reply)\n\n{\n\n uint8_t buf[NBD_REPLY_SIZE];\n\n uint32_t magic;\n\n\n\n memset(buf, 0xAA, sizeof(buf));\n\n\n\n if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {\n\n LOG(\"read failed\");\n\n errno = EINVAL;\n\n return -1;\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 = be32_to_cpup((uint32_t*)buf);\n\n reply->error = be32_to_cpup((uint32_t*)(buf + 4));\n\n reply->handle = be64_to_cpup((uint64_t*)(buf + 8));\n\n\n\n TRACE(\"Got reply: \"\n\n \"{ magic = 0x%x, .error = %d, 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%x)\", magic);\n\n errno = EINVAL;\n\n return -1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 11102 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void channel_load_d(struct fs_dma_ctrl *ctrl, int c)\n\n{\n\n\ttarget_phys_addr_t addr = channel_reg(ctrl, c, RW_SAVED_DATA);\n\n\n\n\t/* Load and decode. FIXME: handle endianness. */\n\n\tD(printf(\"%s ch=%d addr=\" TARGET_FMT_plx \"\\n\", __func__, c, addr));\n\n\tcpu_physical_memory_read (addr,\n\n\t\t\t\t (void *) &ctrl->channels[c].current_d, \n\n\t\t\t\t sizeof ctrl->channels[c].current_d);\n\n\n\n\tD(dump_d(c, &ctrl->channels[c].current_d));\n\n\tctrl->channels[c].regs[RW_DATA] = addr;\n\n}\n", + "output": "0", + "index": 12876 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void slirp_init_once(void)\n\n{\n\n static int initialized;\n\n struct hostent *he;\n\n char our_name[256];\n\n#ifdef _WIN32\n\n WSADATA Data;\n\n#endif\n\n\n\n if (initialized) {\n\n return;\n\n }\n\n initialized = 1;\n\n\n\n#ifdef _WIN32\n\n WSAStartup(MAKEWORD(2,0), &Data);\n\n atexit(winsock_cleanup);\n\n#endif\n\n\n\n loopback_addr.s_addr = htonl(INADDR_LOOPBACK);\n\n\n\n /* FIXME: This address may change during runtime */\n\n if (gethostname(our_name, sizeof(our_name)) == 0) {\n\n he = gethostbyname(our_name);\n\n if (he) {\n\n our_addr = *(struct in_addr *)he->h_addr;\n\n }\n\n }\n\n if (our_addr.s_addr == 0) {\n\n our_addr = loopback_addr;\n\n }\n\n\n\n /* FIXME: This address may change during runtime */\n\n if (get_dns_addr(&dns_addr) < 0) {\n\n dns_addr = loopback_addr;\n\n }\n\n}\n", + "output": "0", + "index": 1304 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s,\n\n\t\t\t\t\t const uint8_t * src)\n\n{\n\n uint8_t *dst;\n\n\n\n dst = s->vga.vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask);\n\n\n\n if (blit_is_unsafe(s, false))\n\n return 0;\n\n\n\n (*s->cirrus_rop) (s, dst, src,\n\n s->cirrus_blt_dstpitch, 0,\n\n s->cirrus_blt_width, s->cirrus_blt_height);\n\n cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,\n\n s->cirrus_blt_dstpitch, s->cirrus_blt_width,\n\n s->cirrus_blt_height);\n\n return 1;\n\n}\n", + "output": "0", + "index": 63 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void check(int a, int b, bool expected)\n\n{\n\n struct qht_stats stats;\n\n int i;\n\n\n\n\n for (i = a; i < b; i++) {\n\n void *p;\n\n uint32_t hash;\n\n int32_t val;\n\n\n\n val = i;\n\n hash = i;\n\n p = qht_lookup(&ht, is_equal, &val, hash);\n\n g_assert_true(!!p == expected);\n\n }\n\n rcu_read_unlock();\n\n\n\n qht_statistics_init(&ht, &stats);\n\n if (stats.used_head_buckets) {\n\n g_assert_cmpfloat(qdist_avg(&stats.chain), >=, 1.0);\n\n }\n\n g_assert_cmpuint(stats.head_buckets, >, 0);\n\n qht_statistics_destroy(&stats);\n\n}", + "output": "1", + "index": 4538 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t read_ts(const char *s)\n\n{\n\n int hh, mm, ss, ms;\n\n if (sscanf(s, \"%u:%u:%u.%u\", &hh, &mm, &ss, &ms) == 4) return (hh*3600 + mm*60 + ss) * 1000 + ms;\n\n if (sscanf(s, \"%u:%u.%u\", &mm, &ss, &ms) == 3) return ( mm*60 + ss) * 1000 + ms;\n\n return AV_NOPTS_VALUE;\n\n}\n", + "output": "1", + "index": 13321 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint64_t HELPER(neon_abdl_u64)(uint32_t a, uint32_t b)\n\n{\n\n uint64_t result;\n\n DO_ABD(result, a, b, uint32_t);\n\n return result;\n\n}\n", + "output": "1", + "index": 7356 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void icp_pit_init(uint32_t base, qemu_irq *pic, int irq)\n\n{\n\n int iomemtype;\n\n icp_pit_state *s;\n\n\n\n s = (icp_pit_state *)qemu_mallocz(sizeof(icp_pit_state));\n\n s->base = base;\n\n /* Timer 0 runs at the system clock speed (40MHz). */\n\n s->timer[0] = arm_timer_init(40000000, pic[irq]);\n\n /* The other two timers run at 1MHz. */\n\n s->timer[1] = arm_timer_init(1000000, pic[irq + 1]);\n\n s->timer[2] = arm_timer_init(1000000, pic[irq + 2]);\n\n\n\n iomemtype = cpu_register_io_memory(0, icp_pit_readfn,\n\n icp_pit_writefn, s);\n\n cpu_register_physical_memory(base, 0x00000fff, iomemtype);\n\n /* ??? Save/restore. */\n\n}\n", + "output": "1", + "index": 3534 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_put_h264_qpel4_mc11_msa(uint8_t *dst, const uint8_t *src,\n\n ptrdiff_t stride)\n\n{\n\n avc_luma_hv_qrt_4w_msa(src - 2, src - (stride * 2), stride, dst, stride, 4);\n\n}\n", + "output": "0", + "index": 11789 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)\n\n{\n\n Location loc;\n\n DriveInfo *dinfo;\n\n int unit;\n\n Error *err = NULL;\n\n\n\n loc_push_none(&loc);\n\n for (unit = 0; unit <= bus->info->max_target; 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 scsi_bus_legacy_add_drive(bus, blk_bs(blk_by_legacy_dinfo(dinfo)),\n\n unit, false, -1, NULL, &err);\n\n if (err != NULL) {\n\n error_report(\"%s\", error_get_pretty(err));\n\n error_propagate(errp, err);\n\n break;\n\n }\n\n }\n\n loc_pop(&loc);\n\n}\n", + "output": "0", + "index": 14489 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t rtmp_read_seek(URLContext *s, int stream_index,\n\n int64_t timestamp, int flags)\n\n{\n\n RTMP *r = s->priv_data;\n\n\n\n if (flags & AVSEEK_FLAG_BYTE)\n\n return AVERROR(ENOSYS);\n\n\n\n /* seeks are in milliseconds */\n\n timestamp = av_rescale(timestamp, AV_TIME_BASE, 1000);\n\n if (!RTMP_SendSeek(r, timestamp))\n\n return -1;\n\n return timestamp;\n\n}\n", + "output": "0", + "index": 14499 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void etsec_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n dc->realize = etsec_realize;\n\n dc->reset = etsec_reset;\n\n dc->props = etsec_properties;\n\n\n\n}", + "output": "1", + "index": 4522 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmxnet3_update_pm_state(VMXNET3State *s)\n\n{\n\n struct Vmxnet3_VariableLenConfDesc pm_descr;\n\n\n\n pm_descr.confLen =\n\n VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.pmConfDesc.confLen);\n\n pm_descr.confVer =\n\n VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.pmConfDesc.confVer);\n\n pm_descr.confPA =\n\n VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.pmConfDesc.confPA);\n\n\n\n vmxnet3_dump_conf_descr(\"PM State\", &pm_descr);\n\n}\n", + "output": "1", + "index": 9768 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "float32 float32_sqrt( float32 a STATUS_PARAM )\n\n{\n\n flag aSign;\n\n int16 aExp, zExp;\n\n bits32 aSig, zSig;\n\n bits64 rem, term;\n\n\n\n aSig = extractFloat32Frac( a );\n\n aExp = extractFloat32Exp( a );\n\n aSign = extractFloat32Sign( a );\n\n if ( aExp == 0xFF ) {\n\n if ( aSig ) return propagateFloat32NaN( a, 0 STATUS_VAR );\n\n if ( ! aSign ) return a;\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n return float32_default_nan;\n\n }\n\n if ( aSign ) {\n\n if ( ( aExp | aSig ) == 0 ) return a;\n\n float_raise( float_flag_invalid STATUS_VAR);\n\n return float32_default_nan;\n\n }\n\n if ( aExp == 0 ) {\n\n if ( aSig == 0 ) return 0;\n\n normalizeFloat32Subnormal( aSig, &aExp, &aSig );\n\n }\n\n zExp = ( ( aExp - 0x7F )>>1 ) + 0x7E;\n\n aSig = ( aSig | 0x00800000 )<<8;\n\n zSig = estimateSqrt32( aExp, aSig ) + 2;\n\n if ( ( zSig & 0x7F ) <= 5 ) {\n\n if ( zSig < 2 ) {\n\n zSig = 0x7FFFFFFF;\n\n goto roundAndPack;\n\n }\n\n aSig >>= aExp & 1;\n\n term = ( (bits64) zSig ) * zSig;\n\n rem = ( ( (bits64) aSig )<<32 ) - term;\n\n while ( (sbits64) rem < 0 ) {\n\n --zSig;\n\n rem += ( ( (bits64) zSig )<<1 ) | 1;\n\n }\n\n zSig |= ( rem != 0 );\n\n }\n\n shift32RightJamming( zSig, 1, &zSig );\n\n roundAndPack:\n\n return roundAndPackFloat32( 0, zExp, zSig STATUS_VAR );\n\n\n\n}\n", + "output": "0", + "index": 11771 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ide_issue_trim_cb(void *opaque, int ret)\n\n{\n\n TrimAIOCB *iocb = opaque;\n\n if (ret >= 0) {\n\n while (iocb->j < iocb->qiov->niov) {\n\n int j = iocb->j;\n\n while (++iocb->i < iocb->qiov->iov[j].iov_len / 8) {\n\n int i = iocb->i;\n\n uint64_t *buffer = iocb->qiov->iov[j].iov_base;\n\n\n\n /* 6-byte LBA + 2-byte range per entry */\n\n uint64_t entry = le64_to_cpu(buffer[i]);\n\n uint64_t sector = entry & 0x0000ffffffffffffULL;\n\n uint16_t count = entry >> 48;\n\n\n\n if (count == 0) {\n\n continue;\n\n }\n\n\n\n /* Got an entry! Submit and exit. */\n\n iocb->aiocb = blk_aio_pdiscard(iocb->blk,\n\n sector << BDRV_SECTOR_BITS,\n\n count << BDRV_SECTOR_BITS,\n\n ide_issue_trim_cb, opaque);\n\n return;\n\n }\n\n\n\n iocb->j++;\n\n iocb->i = -1;\n\n }\n\n } else {\n\n iocb->ret = ret;\n\n }\n\n\n\n iocb->aiocb = NULL;\n\n if (iocb->bh) {\n\n qemu_bh_schedule(iocb->bh);\n\n }\n\n}\n", + "output": "0", + "index": 20440 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool tcg_target_deposit_valid(int ofs, int len)\n\n{\n\n return (facilities & FACILITY_GEN_INST_EXT) != 0;\n\n}\n", + "output": "0", + "index": 19193 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen)\n\n{\n\n int ret;\n\n\n\n#ifdef CONFIG_ACCEPT4\n\n ret = accept4(s, addr, addrlen, SOCK_CLOEXEC);\n\n#else\n\n ret = accept(s, addr, addrlen);\n\n if (ret >= 0) {\n\n qemu_set_cloexec(ret);\n\n }\n\n#endif\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 20048 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_tcg_wait_io_event(CPUState *cpu)\n\n{\n\n while (all_cpu_threads_idle()) {\n\n stop_tcg_kick_timer();\n\n qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);\n\n }\n\n\n\n start_tcg_kick_timer();\n\n\n\n CPU_FOREACH(cpu) {\n\n qemu_wait_io_event_common(cpu);\n\n }\n\n}\n", + "output": "1", + "index": 21656 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rm_read_metadata(AVFormatContext *s, int wide)\n\n{\n\n char buf[1024];\n\n int i;\n\n for (i=0; ipb) : avio_r8(s->pb);\n\n get_strl(s->pb, buf, sizeof(buf), len);\n\n av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);\n\n }\n\n}\n", + "output": "1", + "index": 6435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)\n\n{\n\n BDRVVPCState *s = bs->opaque;\n\n int64_t bat_offset;\n\n uint32_t index, bat_value;\n\n int ret;\n\n uint8_t bitmap[s->bitmap_size];\n\n\n\n // Check if sector_num is valid\n\n if ((sector_num < 0) || (sector_num > bs->total_sectors))\n\n return -1;\n\n\n\n // Write entry into in-memory BAT\n\n index = (sector_num * 512) / s->block_size;\n\n if (s->pagetable[index] != 0xFFFFFFFF)\n\n return -1;\n\n\n\n s->pagetable[index] = s->free_data_block_offset / 512;\n\n\n\n // Initialize the block's bitmap\n\n memset(bitmap, 0xff, s->bitmap_size);\n\n bdrv_pwrite(bs->file, s->free_data_block_offset, bitmap, s->bitmap_size);\n\n\n\n // Write new footer (the old one will be overwritten)\n\n s->free_data_block_offset += s->block_size + s->bitmap_size;\n\n ret = rewrite_footer(bs);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n // Write BAT entry to disk\n\n bat_offset = s->bat_offset + (4 * index);\n\n bat_value = be32_to_cpu(s->pagetable[index]);\n\n ret = bdrv_pwrite(bs->file, bat_offset, &bat_value, 4);\n\n if (ret < 0)\n\n goto fail;\n\n\n\n return get_sector_offset(bs, sector_num, 0);\n\n\n\nfail:\n\n s->free_data_block_offset -= (s->block_size + s->bitmap_size);\n\n return -1;\n\n}\n", + "output": "1", + "index": 15672 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static float get_band_cost_NONE_mips(struct AACEncContext *s,\n\n PutBitContext *pb, const float *in,\n\n const float *scaled, int size, int scale_idx,\n\n int cb, const float lambda, const float uplim,\n\n int *bits)\n\n{\n\n av_assert0(0);\n\n return 0;\n\n}\n", + "output": "1", + "index": 20640 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void simple_whitespace(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 = \" [ 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 , { 'h' : 'b' }, [ ], 42 ]\",\n\n .decoded = QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QINT(43),\n\n QLIT_QDICT(((LiteralQDictEntry[]){\n\n { \"h\", QLIT_QSTR(\"b\") },\n\n { }})),\n\n QLIT_QLIST(((LiteralQObject[]){\n\n { }})),\n\n QLIT_QINT(42),\n\n { }\n\n })),\n\n },\n\n {\n\n .encoded = \" [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]\",\n\n .decoded = QLIT_QLIST(((LiteralQObject[]){\n\n QLIT_QINT(43),\n\n QLIT_QDICT(((LiteralQDictEntry[]){\n\n { \"h\", QLIT_QSTR(\"b\") },\n\n { \"a\", QLIT_QINT(32) },\n\n { }})),\n\n QLIT_QLIST(((LiteralQObject[]){\n\n { }})),\n\n QLIT_QINT(42),\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\n\n qobject_decref(obj);\n\n QDECREF(str);\n\n }\n\n}\n", + "output": "1", + "index": 3179 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_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 = virtio_blk_device_exit;\n\n dc->props = virtio_blk_properties;\n\n set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);\n\n vdc->init = virtio_blk_device_init;\n\n vdc->get_config = virtio_blk_update_config;\n\n vdc->set_config = virtio_blk_set_config;\n\n vdc->get_features = virtio_blk_get_features;\n\n vdc->set_status = virtio_blk_set_status;\n\n vdc->reset = virtio_blk_reset;\n\n}\n", + "output": "1", + "index": 14519 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void flush_queued_work(CPUState *cpu)\n\n{\n\n struct qemu_work_item *wi;\n\n\n\n if (cpu->queued_work_first == NULL) {\n\n return;\n\n }\n\n\n\n while ((wi = cpu->queued_work_first)) {\n\n cpu->queued_work_first = wi->next;\n\n wi->func(wi->data);\n\n wi->done = true;\n\n if (wi->free) {\n\n g_free(wi);\n\n }\n\n }\n\n cpu->queued_work_last = NULL;\n\n qemu_cond_broadcast(&qemu_work_cond);\n\n}\n", + "output": "0", + "index": 9707 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t mp_user_getxattr(FsContext *ctx, const char *path,\n\n const char *name, void *value, size_t size)\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 = ENOATTR;\n\n return -1;\n\n }\n\n return lgetxattr(rpath(ctx, path, buffer), name, value, size);\n\n}\n", + "output": "0", + "index": 14538 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ff_h261_resync(H261Context *h){\n\n MpegEncContext * const s = &h->s;\n\n int left, ret;\n\n\n\n if(show_bits(&s->gb, 15)==0){\n\n ret= h261_decode_gob_header(h);\n\n if(ret>=0)\n\n return 0;\n\n }\n\n //ok, its not where its supposed to be ...\n\n s->gb= s->last_resync_gb;\n\n align_get_bits(&s->gb);\n\n left= s->gb.size_in_bits - get_bits_count(&s->gb);\n\n\n\n for(;left>15+1+4+5; left-=8){\n\n if(show_bits(&s->gb, 15)==0){\n\n GetBitContext bak= s->gb;\n\n\n\n ret= h261_decode_gob_header(h);\n\n if(ret>=0)\n\n return 0;\n\n\n\n s->gb= bak;\n\n }\n\n skip_bits(&s->gb, 8);\n\n }\n\n\n\n return -1;\n\n}\n", + "output": "1", + "index": 20849 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg,\n\n DWORD_PTR dwUser, DWORD_PTR dw1,\n\n DWORD_PTR dw2)\n\n#else\n\nstatic void host_alarm_handler(int host_signum)\n\n#endif\n\n{\n\n#if 0\n\n#define DISP_FREQ 1000\n\n {\n\n static int64_t delta_min = INT64_MAX;\n\n static int64_t delta_max, delta_cum, last_clock, delta, ti;\n\n static int count;\n\n ti = qemu_get_clock(vm_clock);\n\n if (last_clock != 0) {\n\n delta = ti - last_clock;\n\n if (delta < delta_min)\n\n delta_min = delta;\n\n if (delta > delta_max)\n\n delta_max = delta;\n\n delta_cum += delta;\n\n if (++count == DISP_FREQ) {\n\n printf(\"timer: min=%\" PRId64 \" us max=%\" PRId64 \" us avg=%\" PRId64 \" us avg_freq=%0.3f Hz\\n\",\n\n muldiv64(delta_min, 1000000, ticks_per_sec),\n\n muldiv64(delta_max, 1000000, ticks_per_sec),\n\n muldiv64(delta_cum, 1000000 / DISP_FREQ, ticks_per_sec),\n\n (double)ticks_per_sec / ((double)delta_cum / DISP_FREQ));\n\n count = 0;\n\n delta_min = INT64_MAX;\n\n delta_max = 0;\n\n delta_cum = 0;\n\n }\n\n }\n\n last_clock = ti;\n\n }\n\n#endif\n\n if (alarm_has_dynticks(alarm_timer) ||\n\n (!use_icount &&\n\n qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL],\n\n qemu_get_clock(vm_clock))) ||\n\n qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME],\n\n qemu_get_clock(rt_clock))) {\n\n qemu_event_increment();\n\n alarm_timer->flags |= ALARM_FLAG_EXPIRED;\n\n\n\n#ifndef CONFIG_IOTHREAD\n\n if (next_cpu) {\n\n /* stop the currently executing cpu because a timer occured */\n\n cpu_exit(next_cpu);\n\n#ifdef CONFIG_KQEMU\n\n if (next_cpu->kqemu_enabled) {\n\n kqemu_cpu_interrupt(next_cpu);\n\n }\n\n#endif\n\n }\n\n#endif\n\n timer_alarm_pending = 1;\n\n qemu_notify_event();\n\n }\n\n}\n", + "output": "0", + "index": 1074 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qemu_chr_open_win_pipe(QemuOpts *opts, CharDriverState **_chr)\n\n{\n\n const char *filename = qemu_opt_get(opts, \"path\");\n\n CharDriverState *chr;\n\n WinCharState *s;\n\n\n\n chr = g_malloc0(sizeof(CharDriverState));\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 -EIO;\n\n }\n\n qemu_chr_generic_open(chr);\n\n\n\n *_chr = chr;\n\n return 0;\n\n}\n", + "output": "1", + "index": 2374 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,\n\n int buf_size)\n\n{\n\n int start_found, i;\n\n uint32_t state;\n\n ParseContext *pc = &pc1->pc;\n\n\n\n start_found = pc->frame_start_found;\n\n state = pc->state;\n\n\n\n i = 0;\n\n if (!start_found) {\n\n for (i = 0; i < buf_size; i++) {\n\n state = (state << 8) | buf[i];\n\n if (IS_MARKER(state, i, buf, buf_size)) {\n\n if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {\n\n start_found = 1;\n\n pc1->lastmarker = state;\n\n break;\n\n }\n\n }\n\n }\n\n }\n\n if (start_found) {\n\n for (; i < buf_size; i++) {\n\n pc1->size++;\n\n state = (state << 8) | buf[i];\n\n if (state == DCA_HD_MARKER && !pc1->hd_pos)\n\n pc1->hd_pos = pc1->size;\n\n if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {\n\n if(pc1->framesize > pc1->size)\n\n continue;\n\n if(!pc1->framesize){\n\n pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;\n\n }\n\n pc->frame_start_found = 0;\n\n pc->state = -1;\n\n pc1->size = 0;\n\n return i - 3;\n\n }\n\n }\n\n }\n\n pc->frame_start_found = start_found;\n\n pc->state = state;\n\n return END_NOT_FOUND;\n\n}\n", + "output": "1", + "index": 21157 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr index)\n\n{\n\n PhysPageEntry lp = d->phys_map;\n\n PhysPageEntry *p;\n\n int i;\n\n\n\n for (i = P_L2_LEVELS - 1; i >= 0 && !lp.is_leaf; i--) {\n\n if (lp.ptr == PHYS_MAP_NODE_NIL) {\n\n return &phys_sections[phys_section_unassigned];\n\n }\n\n p = phys_map_nodes[lp.ptr];\n\n lp = p[(index >> (i * L2_BITS)) & (L2_SIZE - 1)];\n\n }\n\n return &phys_sections[lp.ptr];\n\n}\n", + "output": "0", + "index": 14881 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void xen_be_evtchn_event(void *opaque)\n\n{\n\n struct XenDevice *xendev = opaque;\n\n evtchn_port_t port;\n\n\n\n port = xc_evtchn_pending(xendev->evtchndev);\n\n if (port != xendev->local_port) {\n\n xen_be_printf(xendev, 0, \"xc_evtchn_pending returned %d (expected %d)\\n\",\n\n port, xendev->local_port);\n\n return;\n\n }\n\n xc_evtchn_unmask(xendev->evtchndev, port);\n\n\n\n if (xendev->ops->event) {\n\n xendev->ops->event(xendev);\n\n }\n\n}\n", + "output": "0", + "index": 22336 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nbd_accept(void *opaque)\n\n{\n\n int server_fd = (uintptr_t) opaque;\n\n struct sockaddr_in addr;\n\n socklen_t addr_len = sizeof(addr);\n\n\n\n int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);\n\n nbd_started = true;\n\n if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {\n\n nb_fds++;\n\n }\n\n}\n", + "output": "0", + "index": 459 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_aio_wait_nonblocking(void)\n\n{\n\n qemu_notify_event();\n\n qemu_aio_wait();\n\n}\n", + "output": "0", + "index": 13493 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)\n\n{\n\n int arch = !!(key & FW_CFG_ARCH_LOCAL);\n\n\n\n key &= FW_CFG_ENTRY_MASK;\n\n\n\n assert(key < FW_CFG_MAX_ENTRY);\n\n\n\n s->entries[arch][key].data = data;\n\n s->entries[arch][key].len = len;\n\n}\n", + "output": "1", + "index": 2095 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx,\n\n const uint8_t **poutbuf, int *poutbuf_size,\n\n const uint8_t *buf, int buf_size)\n\n{\n\n G729ParseContext *s = s1->priv_data;\n\n ParseContext *pc = &s->pc;\n\n int next;\n\n\n\n if (!s->block_size) {\n\n switch (avctx->codec_id) {\n\n case AV_CODEC_ID_G729:\n\n /* FIXME: replace this heuristic block_size with more precise estimate */\n\n s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE : G729_8K_BLOCK_SIZE;\n\n s->duration = avctx->frame_size;\n\n break;\n\n default:\n\n *poutbuf = buf;\n\n *poutbuf_size = buf_size;\n\n av_log(avctx, AV_LOG_ERROR, \"Invalid codec_id\\n\");\n\n return buf_size;\n\n }\n\n }\n\n\n\n if (!s->remaining)\n\n s->remaining = s->block_size;\n\n if (s->remaining <= buf_size) {\n\n next = s->remaining;\n\n s->remaining = 0;\n\n } else {\n\n next = END_NOT_FOUND;\n\n s->remaining -= buf_size;\n\n }\n\n\n\n if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {\n\n *poutbuf = NULL;\n\n *poutbuf_size = 0;\n\n return buf_size;\n\n }\n\n\n\n s1->duration = s->duration;\n\n\n\n *poutbuf = buf;\n\n *poutbuf_size = buf_size;\n\n return next;\n\n}\n", + "output": "0", + "index": 14509 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint64_t hpet_calculate_diff(HPETTimer *t, uint64_t current)\n\n{\n\n\n\n if (t->config & HPET_TN_32BIT) {\n\n uint32_t diff, cmp;\n\n\n\n cmp = (uint32_t)t->cmp;\n\n diff = cmp - (uint32_t)current;\n\n diff = (int32_t)diff > 0 ? diff : (uint32_t)0;\n\n return (uint64_t)diff;\n\n } else {\n\n uint64_t diff, cmp;\n\n\n\n cmp = t->cmp;\n\n diff = cmp - current;\n\n diff = (int64_t)diff > 0 ? diff : (uint64_t)0;\n\n return diff;\n\n }\n\n}\n", + "output": "0", + "index": 18244 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void kvm_cpu_synchronize_state(CPUState *env)\n\n{\n\n if (!env->kvm_vcpu_dirty)\n\n run_on_cpu(env, do_kvm_cpu_synchronize_state, env);\n\n}\n", + "output": "0", + "index": 7034 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void rgba32_to_rgb24(AVPicture *dst, AVPicture *src,\n\n int width, int height)\n\n{\n\n const uint8_t *s;\n\n uint8_t *d;\n\n int src_wrap, dst_wrap, j, y;\n\n unsigned int v;\n\n\n\n s = src->data[0];\n\n src_wrap = src->linesize[0] - width * 4;\n\n\n\n d = dst->data[0];\n\n dst_wrap = dst->linesize[0] - width * 3;\n\n\n\n for(y=0;y> 16;\n\n d[1] = v >> 8;\n\n d[2] = v;\n\n d += 3;\n\n }\n\n s += src_wrap;\n\n d += dst_wrap;\n\n }\n\n}\n", + "output": "0", + "index": 20020 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,\n\n char *res, int res_len, int flags)\n\n{\n\n OverlayContext *over = ctx->priv;\n\n int ret;\n\n\n\n if (!strcmp(cmd, \"x\"))\n\n ret = set_expr(&over->x_pexpr, args, ctx);\n\n else if (!strcmp(cmd, \"y\"))\n\n ret = set_expr(&over->y_pexpr, args, ctx);\n\n else if (!strcmp(cmd, \"enable\"))\n\n ret = set_expr(&over->enable_pexpr, args, ctx);\n\n else\n\n ret = AVERROR(ENOSYS);\n\n\n\n if (ret < 0)\n\n return ret;\n\n\n\n if (over->eval_mode == EVAL_MODE_INIT) {\n\n eval_expr(ctx, EVAL_ALL);\n\n av_log(ctx, AV_LOG_VERBOSE, \"x:%f xi:%d y:%f yi:%d enable:%f\\n\",\n\n over->var_values[VAR_X], over->x,\n\n over->var_values[VAR_Y], over->y,\n\n over->enable);\n\n }\n\n return ret;\n\n}\n", + "output": "0", + "index": 10160 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static SocketAddressLegacy *sd_server_config(QDict *options, Error **errp)\n\n{\n\n QDict *server = NULL;\n\n QObject *crumpled_server = NULL;\n\n Visitor *iv = NULL;\n\n SocketAddress *saddr_flat = NULL;\n\n SocketAddressLegacy *saddr = NULL;\n\n Error *local_err = NULL;\n\n\n\n qdict_extract_subqdict(options, &server, \"server.\");\n\n\n\n crumpled_server = qdict_crumple(server, errp);\n\n if (!crumpled_server) {\n\n goto done;\n\n }\n\n\n\n /*\n\n * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive\n\n * server.type=inet. .to doesn't matter, it's ignored anyway.\n\n * That's because when @options come from -blockdev or\n\n * blockdev_add, members are typed according to the QAPI schema,\n\n * but when they come from -drive, they're all QString. The\n\n * visitor expects the former.\n\n */\n\n iv = qobject_input_visitor_new(crumpled_server);\n\n visit_type_SocketAddress(iv, NULL, &saddr_flat, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n goto done;\n\n }\n\n\n\n saddr = socket_address_crumple(saddr_flat);\n\n\n\ndone:\n\n qapi_free_SocketAddress(saddr_flat);\n\n visit_free(iv);\n\n qobject_decref(crumpled_server);\n\n QDECREF(server);\n\n return saddr;\n\n}\n", + "output": "0", + "index": 12737 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int hdev_get_max_segments(const struct stat *st)\n\n{\n\n#ifdef CONFIG_LINUX\n\n char buf[32];\n\n const char *end;\n\n char *sysfspath;\n\n int ret;\n\n int fd = -1;\n\n long max_segments;\n\n\n\n sysfspath = g_strdup_printf(\"/sys/dev/block/%u:%u/queue/max_segments\",\n\n major(st->st_rdev), minor(st->st_rdev));\n\n fd = open(sysfspath, O_RDONLY);\n\n if (fd == -1) {\n\n ret = -errno;\n\n goto out;\n\n }\n\n do {\n\n ret = read(fd, buf, sizeof(buf));\n\n } while (ret == -1 && errno == EINTR);\n\n if (ret < 0) {\n\n ret = -errno;\n\n goto out;\n\n } else if (ret == 0) {\n\n ret = -EIO;\n\n goto out;\n\n }\n\n buf[ret] = 0;\n\n /* The file is ended with '\\n', pass 'end' to accept that. */\n\n ret = qemu_strtol(buf, &end, 10, &max_segments);\n\n if (ret == 0 && end && *end == '\\n') {\n\n ret = max_segments;\n\n }\n\n\n\nout:\n\n g_free(sysfspath);\n\n return ret;\n\n#else\n\n return -ENOTSUP;\n\n#endif\n\n}\n", + "output": "1", + "index": 22167 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void vnc_flush(VncState *vs)\n\n{\n\n vnc_lock_output(vs);\n\n if (vs->csock != -1 && (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(vs);\n\n }\n\n vnc_unlock_output(vs);\n\n}\n", + "output": "0", + "index": 24190 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,\n\n uint8_t *properties)\n\n{\n\n int compno;\n\n\n\n if (s->buf_end - s->buf < 2)\n\n return AVERROR(EINVAL);\n\n\n\n compno = bytestream_get_byte(&s->buf);\n\n\n\n c += compno;\n\n c->csty = bytestream_get_byte(&s->buf);\n\n get_cox(s, c);\n\n\n\n properties[compno] |= HAD_COC;\n\n return 0;\n\n}\n", + "output": "0", + "index": 2665 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int yuv4_write_header(AVFormatContext *s)\n{\n int* first_pkt = s->priv_data;\n if (s->nb_streams != 1)\n return AVERROR(EIO);\n if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) {\n av_log(s, AV_LOG_ERROR, \"Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\\n\");\n else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) &&\n (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) &&\n (s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) &&\n (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) {\n av_log(s, AV_LOG_ERROR, \"ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\\n\");\n return AVERROR(EIO);\n *first_pkt = 1;\n return 0;", + "output": "1", + "index": 11290 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)\n\n{\n\n VirtIOBlock *s = VIRTIO_BLK(vdev);\n\n VirtIOBlockReq *req;\n\n MultiReqBuffer mrb = {};\n\n\n\n /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start\n\n * dataplane here instead of waiting for .set_status().\n\n */\n\n if (s->dataplane) {\n\n virtio_blk_data_plane_start(s->dataplane);\n\n return;\n\n }\n\n\n\n blk_io_plug(s->blk);\n\n\n\n while ((req = virtio_blk_get_request(s))) {\n\n virtio_blk_handle_request(req, &mrb);\n\n }\n\n\n\n if (mrb.num_reqs) {\n\n virtio_blk_submit_multireq(s->blk, &mrb);\n\n }\n\n\n\n blk_io_unplug(s->blk);\n\n}\n", + "output": "0", + "index": 15016 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mmu_translate_pte(CPUS390XState *env, target_ulong vaddr,\n\n uint64_t asc, uint64_t pt_entry,\n\n target_ulong *raddr, int *flags, int rw, bool exc)\n\n{\n\n if (pt_entry & _PAGE_INVALID) {\n\n DPRINTF(\"%s: PTE=0x%\" PRIx64 \" invalid\\n\", __func__, pt_entry);\n\n trigger_page_fault(env, vaddr, PGM_PAGE_TRANS, asc, rw, exc);\n\n return -1;\n\n }\n\n\n\n if (pt_entry & _PAGE_RO) {\n\n *flags &= ~PAGE_WRITE;\n\n }\n\n\n\n *raddr = pt_entry & _ASCE_ORIGIN;\n\n\n\n PTE_DPRINTF(\"%s: PTE=0x%\" PRIx64 \"\\n\", __func__, pt_entry);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21260 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static DeviceState *qbus_find_dev(BusState *bus, char *elem)\n\n{\n\n DeviceState *dev;\n\n\n\n /*\n\n * try to match in order:\n\n * (1) instance id, if present\n\n * (2) driver name\n\n * (3) driver alias, if present\n\n */\n\n LIST_FOREACH(dev, &bus->children, sibling) {\n\n if (dev->id && strcmp(dev->id, elem) == 0) {\n\n return dev;\n\n }\n\n }\n\n LIST_FOREACH(dev, &bus->children, sibling) {\n\n if (strcmp(dev->info->name, elem) == 0) {\n\n return dev;\n\n }\n\n }\n\n LIST_FOREACH(dev, &bus->children, sibling) {\n\n if (dev->info->alias && strcmp(dev->info->alias, elem) == 0) {\n\n return dev;\n\n }\n\n }\n\n return NULL;\n\n}\n", + "output": "0", + "index": 26674 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ivshmem_check_memdev_is_busy(const Object *obj, const char *name,\n\n Object *val, Error **errp)\n\n{\n\n if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {\n\n char *path = object_get_canonical_path_component(val);\n\n error_setg(errp, \"can't use already busy memdev: %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": 17038 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static VirtIOSerialBus *virtser_bus_new(DeviceState *dev)\n\n{\n\n VirtIOSerialBus *bus;\n\n\n\n bus = FROM_QBUS(VirtIOSerialBus, qbus_create(&virtser_bus_info, dev, NULL));\n\n bus->qbus.allow_hotplug = 1;\n\n\n\n return bus;\n\n}\n", + "output": "1", + "index": 18458 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void sr_1d97_float(float *p, int i0, int i1)\n\n{\n\n int i;\n\n\n\n if (i1 <= i0 + 1) {\n\n if (i0 == 1)\n\n p[1] *= F_LFTG_K/2;\n\n else\n\n p[0] *= F_LFTG_X/2;\n\n return;\n\n }\n\n\n\n extend97_float(p, i0, i1);\n\n\n\n for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)\n\n p[2 * i] -= F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]);\n\n /* step 4 */\n\n for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)\n\n p[2 * i + 1] -= F_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]);\n\n /*step 5*/\n\n for (i = i0 / 2; i < i1 / 2 + 1; i++)\n\n p[2 * i] += F_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]);\n\n /* step 6 */\n\n for (i = i0 / 2; i < i1 / 2; i++)\n\n p[2 * i + 1] += F_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]);\n\n}\n", + "output": "1", + "index": 21156 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool fw_cfg_ctl_mem_valid(void *opaque, target_phys_addr_t addr,\n\n unsigned size, bool is_write)\n\n{\n\n return is_write && size == 2;\n\n}\n", + "output": "0", + "index": 23416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx)\n\n{\n\n char val_str[128];\n\n AVStream *st = fmt_ctx->streams[pkt->stream_index];\n\n struct print_buf pbuf = {.s = NULL};\n\n\n\n print_section_header(\"packet\");\n\n print_str(\"codec_type\", av_x_if_null(av_get_media_type_string(st->codec->codec_type), \"unknown\"));\n\n print_int(\"stream_index\", pkt->stream_index);\n\n print_ts (\"pts\", pkt->pts);\n\n print_time(\"pts_time\", pkt->pts, &st->time_base);\n\n print_ts (\"dts\", pkt->dts);\n\n print_time(\"dts_time\", pkt->dts, &st->time_base);\n\n print_ts (\"duration\", pkt->duration);\n\n print_time(\"duration_time\", pkt->duration, &st->time_base);\n\n print_val(\"size\", pkt->size, unit_byte_str);\n\n print_fmt(\"pos\", \"%\"PRId64, pkt->pos);\n\n print_fmt(\"flags\", \"%c\", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');\n\n print_section_footer(\"packet\");\n\n\n\n av_free(pbuf.s);\n\n fflush(stdout);\n\n}\n", + "output": "0", + "index": 14547 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void ide_abort_command(IDEState *s)\n\n{\n\n ide_transfer_stop(s);\n\n s->status = READY_STAT | ERR_STAT;\n\n s->error = ABRT_ERR;\n\n}\n", + "output": "0", + "index": 19202 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const int16_t *_block,\n\n ptrdiff_t stride)\n\n{\n\n int i;\n\n pixel *pix = (pixel*)_pix;\n\n const dctcoef *block = (const dctcoef*)_block;\n\n stride >>= sizeof(pixel)-1;\n\n pix -= stride;\n\n for(i=0; i<4; i++){\n\n pixel v = pix[0];\n\n pix[1*stride]= v += block[0];\n\n pix[2*stride]= v += block[4];\n\n pix[3*stride]= v += block[8];\n\n pix[4*stride]= v + block[12];\n\n pix++;\n\n block++;\n\n }\n\n}\n", + "output": "0", + "index": 15309 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,\n\n BIOSLinker *linker, GArray *dsm_dma_arrea,\n\n uint32_t ram_slots)\n\n{\n\n GSList *device_list;\n\n\n\n device_list = nvdimm_get_plugged_device_list();\n\n\n\n /* NVDIMM device is plugged. */\n\n if (device_list) {\n\n nvdimm_build_nfit(device_list, table_offsets, table_data, linker);\n\n g_slist_free(device_list);\n\n }\n\n\n\n /*\n\n * NVDIMM device is allowed to be plugged only if there is available\n\n * slot.\n\n */\n\n if (ram_slots) {\n\n nvdimm_build_ssdt(table_offsets, table_data, linker, dsm_dma_arrea,\n\n ram_slots);\n\n }\n\n}\n", + "output": "1", + "index": 2938 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vnc_zlib_stop(VncState *vs)\n\n{\n\n z_streamp zstream = &vs->zlib_stream;\n\n int previous_out;\n\n\n\n // switch back to normal output/zlib buffers\n\n vs->zlib = vs->output;\n\n vs->output = vs->zlib_tmp;\n\n\n\n // compress the zlib buffer\n\n\n\n // initialize the stream\n\n // XXX need one stream per session\n\n if (zstream->opaque != vs) {\n\n int err;\n\n\n\n VNC_DEBUG(\"VNC: initializing zlib stream\\n\");\n\n VNC_DEBUG(\"VNC: opaque = %p | vs = %p\\n\", zstream->opaque, vs);\n\n zstream->zalloc = vnc_zlib_zalloc;\n\n zstream->zfree = vnc_zlib_zfree;\n\n\n\n err = deflateInit2(zstream, vs->tight_compression, Z_DEFLATED, MAX_WBITS,\n\n MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n\n\n\n if (err != Z_OK) {\n\n fprintf(stderr, \"VNC: error initializing zlib\\n\");\n\n return -1;\n\n }\n\n\n\n vs->zlib_level = vs->tight_compression;\n\n zstream->opaque = vs;\n\n }\n\n\n\n if (vs->tight_compression != vs->zlib_level) {\n\n if (deflateParams(zstream, vs->tight_compression,\n\n Z_DEFAULT_STRATEGY) != Z_OK) {\n\n return -1;\n\n }\n\n vs->zlib_level = vs->tight_compression;\n\n }\n\n\n\n // reserve memory in output buffer\n\n buffer_reserve(&vs->output, vs->zlib.offset + 64);\n\n\n\n // set pointers\n\n zstream->next_in = vs->zlib.buffer;\n\n zstream->avail_in = vs->zlib.offset;\n\n zstream->next_out = vs->output.buffer + vs->output.offset;\n\n zstream->avail_out = vs->output.capacity - vs->output.offset;\n\n zstream->data_type = Z_BINARY;\n\n previous_out = zstream->total_out;\n\n\n\n // start encoding\n\n if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {\n\n fprintf(stderr, \"VNC: error during zlib compression\\n\");\n\n return -1;\n\n }\n\n\n\n vs->output.offset = vs->output.capacity - zstream->avail_out;\n\n return zstream->total_out - previous_out;\n\n}\n", + "output": "0", + "index": 22423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t ehci_mem_readb(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];\n\n\n\n return val;\n\n}\n", + "output": "1", + "index": 7167 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int cris_mmu_segmented_addr(int seg, uint32_t rw_mm_cfg)\n\n{\n\n\treturn (1 << seg) & rw_mm_cfg;\n\n}\n", + "output": "0", + "index": 18274 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void fmod_write_sample (HWVoiceOut *hw, uint8_t *dst, int dst_len)\n\n{\n\n int src_len1 = dst_len;\n\n int src_len2 = 0;\n\n int pos = hw->rpos + dst_len;\n\n st_sample_t *src1 = hw->mix_buf + hw->rpos;\n\n st_sample_t *src2 = NULL;\n\n\n\n if (pos > hw->samples) {\n\n src_len1 = hw->samples - hw->rpos;\n\n src2 = hw->mix_buf;\n\n src_len2 = dst_len - src_len1;\n\n pos = src_len2;\n\n }\n\n\n\n if (src_len1) {\n\n hw->clip (dst, src1, src_len1);\n\n }\n\n\n\n if (src_len2) {\n\n dst = advance (dst, src_len1 << hw->info.shift);\n\n hw->clip (dst, src2, src_len2);\n\n }\n\n\n\n hw->rpos = pos % hw->samples;\n\n}\n", + "output": "0", + "index": 15031 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rtc_post_load(void *opaque, int version_id)\n\n{\n\n RTCState *s = opaque;\n\n\n\n if (version_id <= 2 || rtc_clock == QEMU_CLOCK_REALTIME) {\n\n rtc_set_time(s);\n\n s->offset = 0;\n\n check_update_timer(s);\n\n }\n\n\n\n uint64_t now = qemu_clock_get_ns(rtc_clock);\n\n if (now < s->next_periodic_time ||\n\n now > (s->next_periodic_time + get_max_clock_jump())) {\n\n periodic_timer_update(s, qemu_clock_get_ns(rtc_clock));\n\n }\n\n\n\n#ifdef TARGET_I386\n\n if (version_id >= 2) {\n\n if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {\n\n rtc_coalesced_timer_update(s);\n\n }\n\n }\n\n#endif\n\n return 0;\n\n}\n", + "output": "0", + "index": 6089 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_fdt_setprop_sized_cells_from_array(void *fdt,\n\n const char *node_path,\n\n const char *property,\n\n int numvalues,\n\n uint64_t *values)\n\n{\n\n uint32_t *propcells;\n\n uint64_t value;\n\n int cellnum, vnum, ncells;\n\n uint32_t hival;\n\n\n\n propcells = g_new0(uint32_t, numvalues * 2);\n\n\n\n cellnum = 0;\n\n for (vnum = 0; vnum < numvalues; vnum++) {\n\n ncells = values[vnum * 2];\n\n if (ncells != 1 && ncells != 2) {\n\n return -1;\n\n }\n\n value = values[vnum * 2 + 1];\n\n hival = cpu_to_be32(value >> 32);\n\n if (ncells > 1) {\n\n propcells[cellnum++] = hival;\n\n } else if (hival != 0) {\n\n return -1;\n\n }\n\n propcells[cellnum++] = cpu_to_be32(value);\n\n }\n\n\n\n return qemu_fdt_setprop(fdt, node_path, property, propcells,\n\n cellnum * sizeof(uint32_t));\n\n}\n", + "output": "1", + "index": 17521 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx)\n\n{\n\n uint16_t num_heads = vring_avail_idx(vq) - idx;\n\n\n\n /* Check it isn't doing very strange things with descriptor numbers. */\n\n if (num_heads > vq->vring.num) {\n\n error_report(\"Guest moved used index from %u to %u\",\n\n idx, vring_avail_idx(vq));\n\n exit(1);\n\n\n\n\n\n\n\n\n\n return num_heads;\n", + "output": "1", + "index": 3091 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void net_tx_pkt_reset(struct NetTxPkt *pkt)\n\n{\n\n int i;\n\n\n\n /* no assert, as reset can be called before tx_pkt_init */\n\n if (!pkt) {\n\n return;\n\n }\n\n\n\n memset(&pkt->virt_hdr, 0, sizeof(pkt->virt_hdr));\n\n\n\n g_free(pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base);\n\n pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;\n\n\n\n assert(pkt->vec);\n\n for (i = NET_TX_PKT_L2HDR_FRAG;\n\n i < pkt->payload_frags + NET_TX_PKT_PL_START_FRAG; i++) {\n\n pkt->vec[i].iov_len = 0;\n\n }\n\n pkt->payload_len = 0;\n\n pkt->payload_frags = 0;\n\n\n\n assert(pkt->raw);\n\n for (i = 0; i < pkt->raw_frags; i++) {\n\n assert(pkt->raw[i].iov_base);\n\n cpu_physical_memory_unmap(pkt->raw[i].iov_base, pkt->raw[i].iov_len,\n\n false, pkt->raw[i].iov_len);\n\n pkt->raw[i].iov_len = 0;\n\n }\n\n pkt->raw_frags = 0;\n\n\n\n pkt->hdr_len = 0;\n\n pkt->packet_type = 0;\n\n pkt->l4proto = 0;\n\n}\n", + "output": "0", + "index": 18137 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,\n\n int header_size)\n\n{\n\n int len;\n\n short wave_format;\n\n\n\n\n\n if (bytestream_get_le32(&header) != MKTAG('R','I','F','F')) {\n\n av_log(avctx, AV_LOG_ERROR, \"missing RIFF tag\\n\");\n\n return -1;\n\n }\n\n\n\n header += 4; /* chunk size */;\n\n\n\n if (bytestream_get_le32(&header) != MKTAG('W','A','V','E')) {\n\n av_log(avctx, AV_LOG_ERROR, \"missing WAVE tag\\n\");\n\n return -1;\n\n }\n\n\n\n while (bytestream_get_le32(&header) != MKTAG('f','m','t',' ')) {\n\n len = bytestream_get_le32(&header);\n\n header += len;\n\n }\n\n len = bytestream_get_le32(&header);\n\n\n\n if (len < 16) {\n\n av_log(avctx, AV_LOG_ERROR, \"fmt chunk was too short\\n\");\n\n return -1;\n\n }\n\n\n\n wave_format = bytestream_get_le16(&header);\n\n\n\n switch (wave_format) {\n\n case WAVE_FORMAT_PCM:\n\n break;\n\n default:\n\n av_log(avctx, AV_LOG_ERROR, \"unsupported wave format\\n\");\n\n return -1;\n\n }\n\n\n\n header += 2; // skip channels (already got from shorten header)\n\n avctx->sample_rate = bytestream_get_le32(&header);\n\n header += 4; // skip bit rate (represents original uncompressed bit rate)\n\n header += 2; // skip block align (not needed)\n\n avctx->bits_per_coded_sample = bytestream_get_le16(&header);\n\n\n\n if (avctx->bits_per_coded_sample != 16) {\n\n av_log(avctx, AV_LOG_ERROR, \"unsupported number of bits per sample\\n\");\n\n return -1;\n\n }\n\n\n\n len -= 16;\n\n if (len > 0)\n\n av_log(avctx, AV_LOG_INFO, \"%d header bytes unparsed\\n\", len);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 17622 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,\n\n hwaddr dsm_mem_addr)\n\n{\n\n NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm);\n\n NvdimmFuncSetLabelDataIn *set_label_data;\n\n uint32_t status;\n\n\n\n set_label_data = (NvdimmFuncSetLabelDataIn *)in->arg3;\n\n\n\n le32_to_cpus(&set_label_data->offset);\n\n le32_to_cpus(&set_label_data->length);\n\n\n\n nvdimm_debug(\"Write Label Data: offset %#x length %#x.\\n\",\n\n set_label_data->offset, set_label_data->length);\n\n\n\n status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset,\n\n set_label_data->length);\n\n if (status != 0 /* Success */) {\n\n nvdimm_dsm_no_payload(status, dsm_mem_addr);\n\n return;\n\n }\n\n\n\n assert(sizeof(*in) + sizeof(*set_label_data) + set_label_data->length <=\n\n 4096);\n\n\n\n nvc->write_label_data(nvdimm, set_label_data->in_buf,\n\n set_label_data->length, set_label_data->offset);\n\n nvdimm_dsm_no_payload(0 /* Success */, dsm_mem_addr);\n\n}\n", + "output": "1", + "index": 3724 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,\n\n int *duration)\n\n{\n\n int64_t out_pts = AV_NOPTS_VALUE;\n\n int removed_samples = 0;\n\n int i;\n\n\n\n if (afq->frame_count || afq->frame_alloc) {\n\n if (afq->frames->pts != AV_NOPTS_VALUE)\n\n out_pts = afq->frames->pts;\n\n }\n\n if(!afq->frame_count)\n\n av_log(afq->avctx, AV_LOG_WARNING, \"Trying to remove %d samples, but que empty\\n\", nb_samples);\n\n if (pts)\n\n *pts = ff_samples_to_time_base(afq->avctx, out_pts);\n\n\n\n for(i=0; nb_samples && iframe_count; i++){\n\n int n= FFMIN(afq->frames[i].duration, nb_samples);\n\n afq->frames[i].duration -= n;\n\n nb_samples -= n;\n\n removed_samples += n;\n\n if(afq->frames[i].pts != AV_NOPTS_VALUE)\n\n afq->frames[i].pts += n;\n\n }\n\n i -= i && afq->frames[i-1].duration;\n\n memmove(afq->frames, afq->frames + i, sizeof(*afq->frames) * (afq->frame_count - i));\n\n afq->frame_count -= i;\n\n\n\n if(nb_samples){\n\n av_assert0(!afq->frame_count);\n\n if(afq->frames[0].pts != AV_NOPTS_VALUE)\n\n afq->frames[0].pts += nb_samples;\n\n av_log(afq->avctx, AV_LOG_DEBUG, \"Trying to remove %d more samples than are in the que\\n\", nb_samples);\n\n }\n\n if (duration)\n\n *duration = ff_samples_to_time_base(afq->avctx, removed_samples);\n\n}\n", + "output": "1", + "index": 6712 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void i2c_end_transfer(I2CBus *bus)\n\n{\n\n I2CSlaveClass *sc;\n\n I2CNode *node, *next;\n\n\n\n if (QLIST_EMPTY(&bus->current_devs)) {\n\n return;\n\n }\n\n\n\n QLIST_FOREACH_SAFE(node, &bus->current_devs, next, next) {\n\n sc = I2C_SLAVE_GET_CLASS(node->elt);\n\n if (sc->event) {\n\n sc->event(node->elt, I2C_FINISH);\n\n }\n\n QLIST_REMOVE(node, next);\n\n g_free(node);\n\n }\n\n bus->broadcast = false;\n\n}\n", + "output": "0", + "index": 14083 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg,\n\n TCGMemOpIdx oi)\n\n{\n\n TCGMemOp opc = get_memop(oi);\n\n#ifdef CONFIG_SOFTMMU\n\n unsigned mem_index = get_mmuidx(oi);\n\n tcg_insn_unit *label_ptr;\n\n TCGReg base_reg;\n\n\n\n base_reg = tcg_out_tlb_read(s, addr_reg, opc, mem_index, 1);\n\n\n\n label_ptr = s->code_ptr + 1;\n\n tcg_out_insn(s, RI, BRC, S390_CC_NE, 0);\n\n\n\n tcg_out_qemu_ld_direct(s, opc, data_reg, base_reg, TCG_REG_R2, 0);\n\n\n\n add_qemu_ldst_label(s, 1, oi, data_reg, addr_reg, s->code_ptr, label_ptr);\n\n#else\n\n TCGReg index_reg;\n\n tcg_target_long disp;\n\n\n\n tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp);\n\n tcg_out_qemu_ld_direct(s, opc, data_reg, addr_reg, index_reg, disp);\n\n#endif\n\n}\n", + "output": "1", + "index": 1512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int av_base64_decode(uint8_t *out, const char *in, int out_size)\n\n{\n\n int i, v;\n\n uint8_t *dst = out;\n\n\n\n v = 0;\n\n for (i = 0; in[i] && in[i] != '='; i++) {\n\n unsigned int index= in[i]-43;\n\n if (index>=FF_ARRAY_ELEMS(map2) || map2[index] == 0xff)\n\n return -1;\n\n v = (v << 6) + map2[index];\n\n if (i & 3) {\n\n if (dst - out < out_size) {\n\n *dst++ = v >> (6 - 2 * (i & 3));\n\n }\n\n }\n\n }\n\n\n\n return dst - out;\n\n}\n", + "output": "1", + "index": 1827 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "_syscall4(int,sys_utimensat,int,dirfd,const char *,pathname,\n\n const struct timespec *,tsp,int,flags)\n\n#endif\n\n#endif /* CONFIG_UTIMENSAT */\n\n\n\n#ifdef CONFIG_INOTIFY\n\n#include \n\n\n\n#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)\n\nstatic int sys_inotify_init(void)\n\n{\n\n return (inotify_init());\n\n}\n", + "output": "0", + "index": 13589 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool gs_allowed(void)\n\n{\n\n if (kvm_enabled()) {\n\n MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());\n\n if (object_class_dynamic_cast(OBJECT_CLASS(mc),\n\n TYPE_S390_CCW_MACHINE)) {\n\n S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);\n\n\n\n return s390mc->gs_allowed;\n\n }\n\n /* Make sure the \"none\" machine can have gs */\n\n return true;\n\n }\n\n return false;\n\n}\n", + "output": "0", + "index": 9813 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean udp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)\n\n{\n\n CharDriverState *chr = opaque;\n\n NetCharDriver *s = chr->opaque;\n\n gsize bytes_read = 0;\n\n GIOStatus status;\n\n\n\n if (s->max_size == 0) {\n\n return TRUE;\n\n }\n\n status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),\n\n &bytes_read, NULL);\n\n s->bufcnt = bytes_read;\n\n s->bufptr = s->bufcnt;\n\n if (status != G_IO_STATUS_NORMAL) {\n\n if (s->tag) {\n\n g_source_remove(s->tag);\n\n s->tag = 0;\n\n }\n\n return FALSE;\n\n }\n\n\n\n s->bufptr = 0;\n\n while (s->max_size > 0 && s->bufptr < s->bufcnt) {\n\n qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);\n\n s->bufptr++;\n\n s->max_size = qemu_chr_be_can_write(chr);\n\n }\n\n\n\n return TRUE;\n\n}\n", + "output": "1", + "index": 3190 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,\n\n int buf_size, void *data)\n\n{\n\n ADXContext *c = avctx->priv_data;\n\n const int16_t *samples = data;\n\n uint8_t *dst = frame;\n\n int ch;\n\n\n\n if (!c->header_parsed) {\n\n int hdrsize = adx_encode_header(avctx, dst, buf_size);\n\n dst += hdrsize;\n\n c->header_parsed = 1;\n\n }\n\n\n\n for (ch = 0; ch < avctx->channels; ch++) {\n\n adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels);\n\n dst += BLOCK_SIZE;\n\n }\n\n return dst - frame;\n\n}\n", + "output": "0", + "index": 25639 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void laio_io_plug(BlockDriverState *bs, void *aio_ctx)\n\n{\n\n struct qemu_laio_state *s = aio_ctx;\n\n\n\n s->io_q.plugged++;\n\n}\n", + "output": "0", + "index": 5215 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_set_dfilter_ranges(const char *filter_spec)\n{\n gchar **ranges = g_strsplit(filter_spec, \",\", 0);\n if (ranges) {\n gchar **next = ranges;\n gchar *r = *next++;\n debug_regions = g_array_sized_new(FALSE, FALSE,\n sizeof(Range), g_strv_length(ranges));\n while (r) {\n char *range_op = strstr(r, \"-\");\n char *r2 = range_op ? range_op + 1 : NULL;\n if (!range_op) {\n range_op = strstr(r, \"+\");\n r2 = range_op ? range_op + 1 : NULL;\n if (!range_op) {\n range_op = strstr(r, \"..\");\n r2 = range_op ? range_op + 2 : NULL;\n if (range_op) {\n const char *e = NULL;\n uint64_t r1val, r2val;\n if ((qemu_strtoull(r, &e, 0, &r1val) == 0) &&\n (qemu_strtoull(r2, NULL, 0, &r2val) == 0) &&\n r2val > 0) {\n struct Range range;\n g_assert(e == range_op);\n switch (*range_op) {\n case '+':\n {\n range.begin = r1val;\n range.end = r1val + (r2val - 1);\n break;\n case '-':\n {\n range.end = r1val;\n range.begin = r1val - (r2val - 1);\n break;\n case '.':\n range.begin = r1val;\n range.end = r2val;\n break;\n default:\n g_assert_not_reached();\n g_array_append_val(debug_regions, range);\n } else {\n g_error(\"Failed to parse range in: %s\", r);\n } else {\n g_error(\"Bad range specifier in: %s\", r);\n r = *next++;\n g_strfreev(ranges);", + "output": "1", + "index": 642 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dump_cleanup(DumpState *s)\n\n{\n\n int ret = 0;\n\n\n\n guest_phys_blocks_free(&s->guest_phys_blocks);\n\n memory_mapping_list_free(&s->list);\n\n if (s->fd != -1) {\n\n close(s->fd);\n\n }\n\n if (s->resume) {\n\n vm_start();\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "1", + "index": 19740 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "sPAPROptionVector *spapr_ovec_new(void)\n\n{\n\n sPAPROptionVector *ov;\n\n\n\n ov = g_new0(sPAPROptionVector, 1);\n\n ov->bitmap = bitmap_new(OV_MAXBITS);\n\n\n\n\n return ov;\n\n}", + "output": "1", + "index": 14051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)\n\n{\n\n uint8_t *buf1;\n\n RMMuxContext *rm = s->priv_data;\n\n AVIOContext *pb = s->pb;\n\n StreamInfo *stream = rm->audio_stream;\n\n int i;\n\n\n\n /* XXX: suppress this malloc */\n\n buf1 = av_malloc(size * sizeof(uint8_t));\n\n\n\n\n\n write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));\n\n\n\n if (stream->enc->codec_id == AV_CODEC_ID_AC3) {\n\n /* for AC-3, the words seem to be reversed */\n\n for(i=0;inb_frames++;\n\n av_free(buf1);\n\n return 0;\n\n}", + "output": "1", + "index": 19040 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,\n\n const uint8_t *buf, int len)\n\n{\n\n KBDState *s = ADB_KEYBOARD(d);\n\n int cmd, reg, olen;\n\n\n\n if ((buf[0] & 0x0f) == ADB_FLUSH) {\n\n /* flush keyboard fifo */\n\n s->wptr = s->rptr = s->count = 0;\n\n return 0;\n\n }\n\n\n\n cmd = buf[0] & 0xc;\n\n reg = buf[0] & 0x3;\n\n olen = 0;\n\n switch(cmd) {\n\n case ADB_WRITEREG:\n\n switch(reg) {\n\n case 2:\n\n /* LED status */\n\n break;\n\n case 3:\n\n switch(buf[2]) {\n\n case ADB_CMD_SELF_TEST:\n\n break;\n\n case ADB_CMD_CHANGE_ID:\n\n case ADB_CMD_CHANGE_ID_AND_ACT:\n\n case ADB_CMD_CHANGE_ID_AND_ENABLE:\n\n d->devaddr = buf[1] & 0xf;\n\n break;\n\n default:\n\n d->devaddr = buf[1] & 0xf;\n\n /* we support handlers:\n\n * 1: Apple Standard Keyboard\n\n * 2: Apple Extended Keyboard (LShift = RShift)\n\n * 3: Apple Extended Keyboard (LShift != RShift)\n\n */\n\n if (buf[2] == 1 || buf[2] == 2 || buf[2] == 3) {\n\n d->handler = buf[2];\n\n }\n\n break;\n\n }\n\n }\n\n break;\n\n case ADB_READREG:\n\n switch(reg) {\n\n case 0:\n\n olen = adb_kbd_poll(d, obuf);\n\n break;\n\n case 1:\n\n break;\n\n case 2:\n\n obuf[0] = 0x00; /* XXX: check this */\n\n obuf[1] = 0x07; /* led status */\n\n olen = 2;\n\n break;\n\n case 3:\n\n obuf[0] = d->handler;\n\n obuf[1] = d->devaddr;\n\n olen = 2;\n\n break;\n\n }\n\n break;\n\n }\n\n return olen;\n\n}\n", + "output": "1", + "index": 19907 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)\n\n{\n\n VirtIOSCSI *s = (VirtIOSCSI *)vdev;\n\n VirtIOSCSIReq *req;\n\n\n\n if (s->ctx && !s->dataplane_started) {\n\n virtio_scsi_dataplane_start(s);\n\n return;\n\n }\n\n while ((req = virtio_scsi_pop_req(s, vq))) {\n\n virtio_scsi_handle_ctrl_req(s, req);\n\n }\n\n}\n", + "output": "1", + "index": 8178 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ppc_spapr_reset(void)\n\n{\n\n /* flush out the hash table */\n\n memset(spapr->htab, 0, spapr->htab_size);\n\n\n\n qemu_devices_reset();\n\n\n\n /* Load the fdt */\n\n spapr_finalize_fdt(spapr, spapr->fdt_addr, spapr->rtas_addr,\n\n spapr->rtas_size);\n\n\n\n /* Set up the entry state */\n\n first_cpu->gpr[3] = spapr->fdt_addr;\n\n first_cpu->gpr[5] = 0;\n\n first_cpu->halted = 0;\n\n first_cpu->nip = spapr->entry_point;\n\n\n\n}\n", + "output": "1", + "index": 6788 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)\n\n{\n\n /* use non-QOM casts in the data path */\n\n VirtIOSCSI *s = (VirtIOSCSI *)vdev;\n\n VirtIOSCSICommon *vs = &s->parent_obj;\n\n\n\n VirtIOSCSIReq *req;\n\n int n;\n\n\n\n while ((req = virtio_scsi_pop_req(s, vq))) {\n\n SCSIDevice *d;\n\n int out_size, in_size;\n\n if (req->elem.out_num < 1 || req->elem.in_num < 1) {\n\n virtio_scsi_bad_req();\n\n }\n\n\n\n out_size = req->elem.out_sg[0].iov_len;\n\n in_size = req->elem.in_sg[0].iov_len;\n\n if (out_size < sizeof(VirtIOSCSICmdReq) + vs->cdb_size ||\n\n in_size < sizeof(VirtIOSCSICmdResp) + vs->sense_size) {\n\n virtio_scsi_bad_req();\n\n }\n\n\n\n if (req->elem.out_num > 1 && req->elem.in_num > 1) {\n\n virtio_scsi_fail_cmd_req(req);\n\n continue;\n\n }\n\n\n\n d = virtio_scsi_device_find(s, req->req.cmd->lun);\n\n if (!d) {\n\n req->resp.cmd->response = VIRTIO_SCSI_S_BAD_TARGET;\n\n virtio_scsi_complete_req(req);\n\n continue;\n\n }\n\n req->sreq = scsi_req_new(d, req->req.cmd->tag,\n\n virtio_scsi_get_lun(req->req.cmd->lun),\n\n req->req.cmd->cdb, req);\n\n\n\n if (req->sreq->cmd.mode != SCSI_XFER_NONE) {\n\n int req_mode =\n\n (req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);\n\n\n\n if (req->sreq->cmd.mode != req_mode ||\n\n req->sreq->cmd.xfer > req->qsgl.size) {\n\n req->resp.cmd->response = VIRTIO_SCSI_S_OVERRUN;\n\n virtio_scsi_complete_req(req);\n\n continue;\n\n }\n\n }\n\n\n\n n = scsi_req_enqueue(req->sreq);\n\n if (n) {\n\n scsi_req_continue(req->sreq);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 13149 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "e1000_can_receive(void *opaque)\n\n{\n\n E1000State *s = opaque;\n\n\n\n return (!(s->mac_reg[RCTL] & E1000_RCTL_EN) ||\n\n s->mac_reg[RDH] != s->mac_reg[RDT]);\n\n}\n", + "output": "1", + "index": 3130 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int decoder_init(AVCodecContext * avctx)\n\n{\n\n G729Context* ctx = avctx->priv_data;\n\n int i,k;\n\n\n\n if (avctx->channels != 1) {\n\n av_log(avctx, AV_LOG_ERROR, \"Only mono sound is supported (requested channels: %d).\\n\", avctx->channels);\n\n return AVERROR(EINVAL);\n\n }\n\n avctx->sample_fmt = AV_SAMPLE_FMT_S16;\n\n\n\n /* Both 8kbit/s and 6.4kbit/s modes uses two subframes per frame. */\n\n avctx->frame_size = SUBFRAME_SIZE << 1;\n\n\n\n ctx->gain_coeff = 16384; // 1.0 in (1.14)\n\n\n\n for (k = 0; k < MA_NP + 1; k++) {\n\n ctx->past_quantizer_outputs[k] = ctx->past_quantizer_output_buf[k];\n\n for (i = 1; i < 11; i++)\n\n ctx->past_quantizer_outputs[k][i - 1] = (18717 * i) >> 3;\n\n }\n\n\n\n ctx->lsp[0] = ctx->lsp_buf[0];\n\n ctx->lsp[1] = ctx->lsp_buf[1];\n\n memcpy(ctx->lsp[0], lsp_init, 10 * sizeof(int16_t));\n\n\n\n ctx->exc = &ctx->exc_base[PITCH_DELAY_MAX+INTERPOL_LEN];\n\n\n\n /* random seed initialization */\n\n ctx->rand_value = 21845;\n\n\n\n /* quantized prediction error */\n\n for(i=0; i<4; i++)\n\n ctx->quant_energy[i] = -14336; // -14 in (5.10)\n\n\n\n avctx->dsp_mask= ~AV_CPU_FLAG_FORCE;\n\n dsputil_init(&ctx->dsp, avctx);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 13821 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void colored_fputs(int level, const char *str)\n\n{\n\n if (!*str)\n\n return;\n\n\n\n if (use_color < 0) {\n\n#if HAVE_SETCONSOLETEXTATTRIBUTE\n\n CONSOLE_SCREEN_BUFFER_INFO con_info;\n\n con = GetStdHandle(STD_ERROR_HANDLE);\n\n use_color = (con != INVALID_HANDLE_VALUE) && !getenv(\"NO_COLOR\") &&\n\n !getenv(\"AV_LOG_FORCE_NOCOLOR\");\n\n if (use_color) {\n\n GetConsoleScreenBufferInfo(con, &con_info);\n\n attr_orig = con_info.wAttributes;\n\n background = attr_orig & 0xF0;\n\n }\n\n#elif HAVE_ISATTY\n\n use_color = !getenv(\"NO_COLOR\") && !getenv(\"AV_LOG_FORCE_NOCOLOR\") &&\n\n (getenv(\"TERM\") && isatty(2) ||\n\n getenv(\"AV_LOG_FORCE_COLOR\"));\n\n if (getenv(\"AV_LOG_FORCE_256COLOR\"))\n\n use_color *= 256;\n\n#else\n\n use_color = getenv(\"AV_LOG_FORCE_COLOR\") && !getenv(\"NO_COLOR\") &&\n\n !getenv(\"AV_LOG_FORCE_NOCOLOR\");\n\n#endif\n\n }\n\n\n\n#if HAVE_SETCONSOLETEXTATTRIBUTE\n\n if (use_color && level != AV_LOG_INFO/8)\n\n SetConsoleTextAttribute(con, background | color[level]);\n\n fputs(str, stderr);\n\n if (use_color && level != AV_LOG_INFO/8)\n\n SetConsoleTextAttribute(con, attr_orig);\n\n#else\n\n if (use_color == 1 && level != AV_LOG_INFO/8) {\n\n fprintf(stderr,\n\n \"\\033[%d;3%dm%s\\033[0m\",\n\n (color[level] >> 4) & 15,\n\n color[level] & 15,\n\n str);\n\n } else if (use_color == 256 && level != AV_LOG_INFO/8) {\n\n fprintf(stderr,\n\n \"\\033[48;5;%dm\\033[38;5;%dm%s\\033[0m\",\n\n (color[level] >> 16) & 0xff,\n\n (color[level] >> 8) & 0xff,\n\n str);\n\n } else\n\n fputs(str, stderr);\n\n#endif\n\n\n\n}\n", + "output": "0", + "index": 24021 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int pci_set_default_subsystem_id(PCIDevice *pci_dev)\n\n{\n\n uint16_t *id;\n\n\n\n id = (void*)(&pci_dev->config[PCI_SUBSYSTEM_VENDOR_ID]);\n\n id[0] = cpu_to_le16(pci_default_sub_vendor_id);\n\n id[1] = cpu_to_le16(pci_default_sub_device_id);\n\n return 0;\n\n}\n", + "output": "0", + "index": 15440 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,\n\n uint8_t *vga_ram_base, unsigned long vga_ram_offset,\n\n int vga_ram_size)\n\n{\n\n s->ds = ds;\n\n s->vram = vga_ram_base;\n\n s->vram_size = vga_ram_size;\n\n s->vram_offset = vga_ram_offset;\n\n\n\n s->scratch_size = SVGA_SCRATCH_SIZE;\n\n s->scratch = (uint32_t *) qemu_malloc(s->scratch_size * 4);\n\n\n\n vmsvga_reset(s);\n\n\n\n s->console = graphic_console_init(ds, vmsvga_update_display,\n\n vmsvga_invalidate_display,\n\n vmsvga_screen_dump,\n\n vmsvga_text_update, s);\n\n\n\n#ifdef EMBED_STDVGA\n\n vga_common_init((VGAState *) s, ds,\n\n vga_ram_base, vga_ram_offset, vga_ram_size);\n\n vga_init((VGAState *) s);\n\n#endif\n\n}\n", + "output": "0", + "index": 16490 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void spapr_drc_release(sPAPRDRConnector *drc)\n\n{\n\n sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);\n\n\n\n drck->release(drc->dev);\n\n\n\n drc->awaiting_release = false;\n\n g_free(drc->fdt);\n\n drc->fdt = NULL;\n\n drc->fdt_start_offset = 0;\n\n object_property_del(OBJECT(drc), \"device\", &error_abort);\n\n drc->dev = NULL;\n\n}\n", + "output": "0", + "index": 9226 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint64_t grlib_irqmp_read(void *opaque, target_phys_addr_t addr,\n\n unsigned size)\n\n{\n\n IRQMP *irqmp = opaque;\n\n IRQMPState *state;\n\n\n\n assert(irqmp != NULL);\n\n state = irqmp->state;\n\n assert(state != NULL);\n\n\n\n addr &= 0xff;\n\n\n\n /* global registers */\n\n switch (addr) {\n\n case LEVEL_OFFSET:\n\n return state->level;\n\n\n\n case PENDING_OFFSET:\n\n return state->pending;\n\n\n\n case FORCE0_OFFSET:\n\n /* This register is an \"alias\" for the force register of CPU 0 */\n\n return state->force[0];\n\n\n\n case CLEAR_OFFSET:\n\n case MP_STATUS_OFFSET:\n\n /* Always read as 0 */\n\n return 0;\n\n\n\n case BROADCAST_OFFSET:\n\n return state->broadcast;\n\n\n\n default:\n\n break;\n\n }\n\n\n\n /* mask registers */\n\n if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) {\n\n int cpu = (addr - MASK_OFFSET) / 4;\n\n assert(cpu >= 0 && cpu < IRQMP_MAX_CPU);\n\n\n\n return state->mask[cpu];\n\n }\n\n\n\n /* force registers */\n\n if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) {\n\n int cpu = (addr - FORCE_OFFSET) / 4;\n\n assert(cpu >= 0 && cpu < IRQMP_MAX_CPU);\n\n\n\n return state->force[cpu];\n\n }\n\n\n\n /* extended (not supported) */\n\n if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) {\n\n int cpu = (addr - EXTENDED_OFFSET) / 4;\n\n assert(cpu >= 0 && cpu < IRQMP_MAX_CPU);\n\n\n\n return state->extended[cpu];\n\n }\n\n\n\n trace_grlib_irqmp_readl_unknown(addr);\n\n return 0;\n\n}\n", + "output": "0", + "index": 8921 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,\n\n AVFilterBufferRef **picref_ptr, AVRational *tb)\n\n{\n\n int ret;\n\n AVFilterBufferRef *picref;\n\n\n\n\n if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)\n\n return ret;\n\n if (!(picref = ctx->inputs[0]->cur_buf))\n\n return AVERROR(ENOENT);\n\n *picref_ptr = picref;\n\n ctx->inputs[0]->cur_buf = NULL;\n\n *tb = ctx->inputs[0]->time_base;\n\n\n\n memcpy(frame->data, picref->data, sizeof(frame->data));\n\n memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));\n\n frame->pkt_pos = picref->pos;\n\n frame->interlaced_frame = picref->video->interlaced;\n\n frame->top_field_first = picref->video->top_field_first;\n\n frame->key_frame = picref->video->key_frame;\n\n frame->pict_type = picref->video->pict_type;\n\n frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;\n\n\n\n return 1;\n\n}", + "output": "1", + "index": 23348 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ISADevice *isa_try_create(ISABus *bus, const char *name)\n\n{\n\n DeviceState *dev;\n\n\n\n if (!bus) {\n\n hw_error(\"Tried to create isa device %s with no isa bus present.\",\n\n name);\n\n }\n\n dev = qdev_try_create(BUS(bus), name);\n\n return ISA_DEVICE(dev);\n\n}\n", + "output": "1", + "index": 12584 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_slbmfee(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);\n\n#else\n\n if (unlikely(ctx->pr)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);\n\n return;\n\n }\n\n gen_helper_load_slb_esid(cpu_gpr[rS(ctx->opcode)], cpu_env,\n\n cpu_gpr[rB(ctx->opcode)]);\n\n#endif\n\n}\n", + "output": "1", + "index": 10685 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool block_job_user_paused(BlockJob *job)\n\n{\n\n return job ? job->user_paused : 0;\n\n}\n", + "output": "0", + "index": 26562 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void visit_type_uint32(Visitor *v, uint32_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_uint32) {\n\n v->type_uint32(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 > UINT32_MAX) {\n\n error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",\n\n \"uint32_t\");\n\n return;\n\n }\n\n *obj = value;\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 3495 + }, + { + "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 uint16_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": 24945 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void * attribute_align_arg worker(void *v){\n\n AVCodecContext *avctx = v;\n\n ThreadContext *c = avctx->internal->frame_thread_encoder;\n\n AVPacket *pkt = NULL;\n\n\n\n while(!c->exit){\n\n int got_packet, ret;\n\n AVFrame *frame;\n\n Task task;\n\n\n\n if(!pkt) pkt= av_mallocz(sizeof(*pkt));\n\n if(!pkt) continue;\n\n av_init_packet(pkt);\n\n\n\n pthread_mutex_lock(&c->task_fifo_mutex);\n\n while (av_fifo_size(c->task_fifo) <= 0 || c->exit) {\n\n if(c->exit){\n\n pthread_mutex_unlock(&c->task_fifo_mutex);\n\n goto end;\n\n }\n\n pthread_cond_wait(&c->task_fifo_cond, &c->task_fifo_mutex);\n\n }\n\n av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL);\n\n pthread_mutex_unlock(&c->task_fifo_mutex);\n\n frame = task.indata;\n\n\n\n ret = avcodec_encode_video2(avctx, pkt, frame, &got_packet);\n\n pthread_mutex_lock(&c->buffer_mutex);\n\n av_frame_unref(frame);\n\n pthread_mutex_unlock(&c->buffer_mutex);\n\n av_frame_free(&frame);\n\n if(got_packet) {\n\n int ret2 = av_dup_packet(pkt);\n\n if (ret >= 0 && ret2 < 0)\n\n ret = ret2;\n\n } else {\n\n pkt->data = NULL;\n\n pkt->size = 0;\n\n }\n\n pthread_mutex_lock(&c->finished_task_mutex);\n\n c->finished_tasks[task.index].outdata = pkt; pkt = NULL;\n\n c->finished_tasks[task.index].return_code = ret;\n\n pthread_cond_signal(&c->finished_task_cond);\n\n pthread_mutex_unlock(&c->finished_task_mutex);\n\n }\n\nend:\n\n av_free(pkt);\n\n pthread_mutex_lock(&c->buffer_mutex);\n\n avcodec_close(avctx);\n\n pthread_mutex_unlock(&c->buffer_mutex);\n\n av_freep(&avctx);\n\n return NULL;\n\n}\n", + "output": "1", + "index": 20457 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write,\n\n double elapsed_time, uint64_t *wait)\n\n{\n\n uint64_t iops_limit = 0;\n\n double ios_limit, ios_base;\n\n double slice_time, wait_time;\n\n\n\n if (bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]) {\n\n iops_limit = bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL];\n\n } else if (bs->io_limits.iops[is_write]) {\n\n iops_limit = bs->io_limits.iops[is_write];\n\n } else {\n\n if (wait) {\n\n *wait = 0;\n\n }\n\n\n\n return false;\n\n }\n\n\n\n slice_time = bs->slice_end - bs->slice_start;\n\n slice_time /= (NANOSECONDS_PER_SECOND);\n\n ios_limit = iops_limit * slice_time;\n\n ios_base = bs->nr_ops[is_write] - bs->io_base.ios[is_write];\n\n if (bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]) {\n\n ios_base += bs->nr_ops[!is_write] - bs->io_base.ios[!is_write];\n\n }\n\n\n\n if (ios_base + 1 <= ios_limit) {\n\n if (wait) {\n\n *wait = 0;\n\n }\n\n\n\n return false;\n\n }\n\n\n\n /* Calc approx time to dispatch */\n\n wait_time = (ios_base + 1) / iops_limit;\n\n if (wait_time > elapsed_time) {\n\n wait_time = wait_time - elapsed_time;\n\n } else {\n\n wait_time = 0;\n\n }\n\n\n\n bs->slice_time = wait_time * BLOCK_IO_SLICE_TIME * 10;\n\n bs->slice_end += bs->slice_time - 3 * BLOCK_IO_SLICE_TIME;\n\n if (wait) {\n\n *wait = wait_time * BLOCK_IO_SLICE_TIME * 10;\n\n }\n\n\n\n return true;\n\n}\n", + "output": "0", + "index": 15829 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int source_config_props(AVFilterLink *outlink)\n\n{\n\n AVFilterContext *ctx = outlink->src;\n\n Frei0rContext *s = ctx->priv;\n\n\n\n if (av_image_check_size(s->w, s->h, 0, ctx) < 0)\n\n return AVERROR(EINVAL);\n\n outlink->w = s->w;\n\n outlink->h = s->h;\n\n outlink->time_base = s->time_base;\n\n\n\n\n\n if (!(s->instance = s->construct(outlink->w, outlink->h))) {\n\n av_log(ctx, AV_LOG_ERROR, \"Impossible to load frei0r instance\");\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n return set_params(ctx, s->params);\n\n}", + "output": "1", + "index": 25528 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int usb_msd_initfn_storage(USBDevice *dev)\n\n{\n\n MSDState *s = DO_UPCAST(MSDState, dev, dev);\n\n BlockDriverState *bs = s->conf.bs;\n\n SCSIDevice *scsi_dev;\n\n Error *err = NULL;\n\n\n\n if (!bs) {\n\n error_report(\"drive property not set\");\n\n return -1;\n\n }\n\n\n\n blkconf_serial(&s->conf, &dev->serial);\n\n\n\n /*\n\n * Hack alert: this pretends to be a block device, but it's really\n\n * a SCSI bus that can serve only a single device, which it\n\n * creates automatically. But first it needs to detach from its\n\n * blockdev, or else scsi_bus_legacy_add_drive() dies when it\n\n * attaches again.\n\n *\n\n * The hack is probably a bad idea.\n\n */\n\n bdrv_detach_dev(bs, &s->dev.qdev);\n\n s->conf.bs = NULL;\n\n\n\n usb_desc_create_serial(dev);\n\n usb_desc_init(dev);\n\n scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),\n\n &usb_msd_scsi_info_storage, NULL);\n\n scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable,\n\n s->conf.bootindex, dev->serial,\n\n &err);\n\n if (!scsi_dev) {\n\n\n\n return -1;\n\n }\n\n s->bus.qbus.allow_hotplug = 0;\n\n usb_msd_handle_reset(dev);\n\n\n\n if (bdrv_key_required(bs)) {\n\n if (cur_mon) {\n\n monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s);\n\n s->dev.auto_attach = 0;\n\n } else {\n\n autostart = 0;\n\n }\n\n }\n\n\n\n return 0;\n\n}", + "output": "1", + "index": 6645 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,\n\n uint64_t oid, unsigned int data_len,\n\n uint64_t offset, uint8_t flags,\n\n uint64_t base_oid, unsigned int iov_offset)\n\n{\n\n AIOReq *aio_req;\n\n\n\n aio_req = g_malloc(sizeof(*aio_req));\n\n aio_req->aiocb = acb;\n\n aio_req->iov_offset = iov_offset;\n\n aio_req->oid = oid;\n\n aio_req->base_oid = base_oid;\n\n aio_req->offset = offset;\n\n aio_req->data_len = data_len;\n\n aio_req->flags = flags;\n\n aio_req->id = s->aioreq_seq_num++;\n\n\n\n acb->nr_pending++;\n\n return aio_req;\n\n}\n", + "output": "1", + "index": 19423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int dot_product(const int16_t *a, const int16_t *b, int length)\n\n{\n\n int i, sum = 0;\n\n\n\n for (i = 0; i < length; i++) {\n\n int64_t prod = av_clipl_int32(MUL64(a[i], b[i]) << 1);\n\n sum = av_clipl_int32(sum + prod);\n\n }\n\n return sum;\n\n}\n", + "output": "1", + "index": 9368 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ecc_init(target_phys_addr_t base, qemu_irq irq, uint32_t version)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n\n\n dev = qdev_create(NULL, \"eccmemctl\");\n\n qdev_prop_set_uint32(dev, \"version\", version);\n\n qdev_init(dev);\n\n s = sysbus_from_qdev(dev);\n\n sysbus_connect_irq(s, 0, irq);\n\n sysbus_mmio_map(s, 0, base);\n\n if (version == 0) { // SS-600MP only\n\n sysbus_mmio_map(s, 1, base + 0x1000);\n\n }\n\n}\n", + "output": "1", + "index": 20766 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result)\n\n{\n\n return qcow2_check_refcounts(bs, result);\n\n}\n", + "output": "0", + "index": 24313 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void helper_done(CPUSPARCState *env)\n\n{\n\n trap_state *tsptr = cpu_tsptr(env);\n\n\n\n env->pc = tsptr->tnpc;\n\n env->npc = tsptr->tnpc + 4;\n\n cpu_put_ccr(env, tsptr->tstate >> 32);\n\n env->asi = (tsptr->tstate >> 24) & 0xff;\n\n cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f);\n\n cpu_put_cwp64(env, tsptr->tstate & 0xff);\n\n if (cpu_has_hypervisor(env)) {\n\n uint32_t new_gl = (tsptr->tstate >> 40) & 7;\n\n env->hpstate = env->htstate[env->tl];\n\n cpu_gl_switch_gregs(env, new_gl);\n\n env->gl = new_gl;\n\n }\n\n env->tl--;\n\n\n\n trace_win_helper_done(env->tl);\n\n\n\n#if !defined(CONFIG_USER_ONLY)\n\n if (cpu_interrupts_enabled(env)) {\n\n\n cpu_check_irqs(env);\n\n\n }\n\n#endif\n\n}", + "output": "1", + "index": 6682 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)\n\n{\n\n int ret;\n\n GlusterAIOCB acb;\n\n BDRVGlusterState *s = bs->opaque;\n\n\n\n acb.size = 0;\n\n acb.ret = 0;\n\n acb.coroutine = qemu_coroutine_self();\n\n acb.aio_context = bdrv_get_aio_context(bs);\n\n\n\n ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);\n\n if (ret < 0) {\n\n return -errno;\n\n }\n\n\n\n qemu_coroutine_yield();\n\n return acb.ret;\n\n}\n", + "output": "1", + "index": 19530 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int process_frame(FFFrameSync *fs)\n\n{\n\n AVFilterContext *ctx = fs->parent;\n\n LUT2Context *s = fs->opaque;\n\n AVFilterLink *outlink = ctx->outputs[0];\n\n AVFrame *out, *srcx, *srcy;\n\n int ret;\n\n\n\n if ((ret = ff_framesync2_get_frame(&s->fs, 0, &srcx, 0)) < 0 ||\n\n (ret = ff_framesync2_get_frame(&s->fs, 1, &srcy, 0)) < 0)\n\n return ret;\n\n\n\n if (ctx->is_disabled) {\n\n out = av_frame_clone(srcx);\n\n if (!out)\n\n return AVERROR(ENOMEM);\n\n } else {\n\n out = ff_get_video_buffer(outlink, outlink->w, outlink->h);\n\n if (!out)\n\n return AVERROR(ENOMEM);\n\n av_frame_copy_props(out, srcx);\n\n\n\n s->lut2(s, out, srcx, srcy);\n\n }\n\n\n\n out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);\n\n\n\n return ff_filter_frame(outlink, out);\n\n}\n", + "output": "1", + "index": 435 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void intel_hda_corb_run(IntelHDAState *d)\n\n{\n\n hwaddr addr;\n\n uint32_t rp, verb;\n\n\n\n if (d->ics & ICH6_IRS_BUSY) {\n\n dprint(d, 2, \"%s: [icw] verb 0x%08x\\n\", __FUNCTION__, d->icw);\n\n intel_hda_send_command(d, d->icw);\n\n return;\n\n }\n\n\n\n for (;;) {\n\n if (!(d->corb_ctl & ICH6_CORBCTL_RUN)) {\n\n dprint(d, 2, \"%s: !run\\n\", __FUNCTION__);\n\n return;\n\n }\n\n if ((d->corb_rp & 0xff) == d->corb_wp) {\n\n dprint(d, 2, \"%s: corb ring empty\\n\", __FUNCTION__);\n\n return;\n\n }\n\n if (d->rirb_count == d->rirb_cnt) {\n\n dprint(d, 2, \"%s: rirb count reached\\n\", __FUNCTION__);\n\n return;\n\n }\n\n\n\n rp = (d->corb_rp + 1) & 0xff;\n\n addr = intel_hda_addr(d->corb_lbase, d->corb_ubase);\n\n verb = ldl_le_pci_dma(&d->pci, addr + 4*rp);\n\n d->corb_rp = rp;\n\n\n\n dprint(d, 2, \"%s: [rp 0x%x] verb 0x%08x\\n\", __FUNCTION__, rp, verb);\n\n intel_hda_send_command(d, verb);\n\n }\n\n}\n", + "output": "0", + "index": 15726 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_wrtee(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 t0;\n\n if (unlikely(ctx->pr)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n return;\n\n }\n\n t0 = tcg_temp_new();\n\n tcg_gen_andi_tl(t0, cpu_gpr[rD(ctx->opcode)], (1 << MSR_EE));\n\n tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));\n\n tcg_gen_or_tl(cpu_msr, cpu_msr, t0);\n\n tcg_temp_free(t0);\n\n /* Stop translation to have a chance to raise an exception\n\n * if we just set msr_ee to 1\n\n */\n\n gen_stop_exception(ctx);\n\n#endif\n\n}\n", + "output": "1", + "index": 19762 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pl110_class_init(ObjectClass *klass, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(klass);\n\n SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);\n\n\n\n k->init = pl110_initfn;\n\n set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);\n\n dc->no_user = 1;\n\n dc->vmsd = &vmstate_pl110;\n\n}\n", + "output": "1", + "index": 6454 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void bswap_phdr(struct elf_phdr *phdr)\n\n{\n\n bswap32s(&phdr->p_type); /* Segment type */\n\n bswaptls(&phdr->p_offset); /* Segment file offset */\n\n bswaptls(&phdr->p_vaddr); /* Segment virtual address */\n\n bswaptls(&phdr->p_paddr); /* Segment physical address */\n\n bswaptls(&phdr->p_filesz); /* Segment size in file */\n\n bswaptls(&phdr->p_memsz); /* Segment size in memory */\n\n bswap32s(&phdr->p_flags); /* Segment flags */\n\n bswaptls(&phdr->p_align); /* Segment alignment */\n\n}\n", + "output": "0", + "index": 23702 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void tcg_out_ri(TCGContext *s, int const_arg, TCGArg arg)\n\n{\n\n if (const_arg) {\n\n assert(const_arg == 1);\n\n tcg_out8(s, TCG_CONST);\n\n tcg_out_i(s, arg);\n\n } else {\n\n tcg_out_r(s, arg);\n\n }\n\n}\n", + "output": "0", + "index": 4176 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static gboolean gd_window_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)\n\n{\n\n GtkDisplayState *s = opaque;\n\n GtkAccelGroupEntry *entries;\n\n guint n_entries = 0;\n\n gboolean propagate_accel = TRUE;\n\n gboolean handled = FALSE;\n\n\n\n entries = gtk_accel_group_query(s->accel_group, key->keyval,\n\n key->state, &n_entries);\n\n if (n_entries) {\n\n const char *quark = g_quark_to_string(entries[0].accel_path_quark);\n\n\n\n if (gd_is_grab_active(s) && strstart(quark, \"/File/\", NULL)) {\n\n propagate_accel = FALSE;\n\n }\n\n }\n\n\n\n if (!handled && propagate_accel) {\n\n handled = gtk_window_activate_key(GTK_WINDOW(widget), key);\n\n }\n\n if (handled) {\n\n gtk_release_modifiers(s);\n\n } else {\n\n handled = gtk_window_propagate_key_event(GTK_WINDOW(widget), key);\n\n }\n\n\n\n return handled;\n\n}\n", + "output": "0", + "index": 1163 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gdb_vm_stopped(void *opaque, int reason)\n\n{\n\n GDBState *s = opaque;\n\n char buf[256];\n\n const char *type;\n\n int ret;\n\n\n\n if (s->state == RS_SYSCALL)\n\n return;\n\n\n\n /* disable single step if it was enable */\n\n cpu_single_step(s->env, 0);\n\n\n\n if (reason == EXCP_DEBUG) {\n\n if (s->env->watchpoint_hit) {\n\n switch (s->env->watchpoint_hit->flags & BP_MEM_ACCESS) {\n\n case BP_MEM_READ:\n\n type = \"r\";\n\n break;\n\n case BP_MEM_ACCESS:\n\n type = \"a\";\n\n break;\n\n default:\n\n type = \"\";\n\n break;\n\n }\n\n snprintf(buf, sizeof(buf), \"T%02x%swatch:\" TARGET_FMT_lx \";\",\n\n SIGTRAP, type, s->env->watchpoint_hit->vaddr);\n\n put_packet(s, buf);\n\n s->env->watchpoint_hit = NULL;\n\n return;\n\n }\n\n\ttb_flush(s->env);\n\n ret = SIGTRAP;\n\n } else if (reason == EXCP_INTERRUPT) {\n\n ret = SIGINT;\n\n } else {\n\n ret = 0;\n\n }\n\n snprintf(buf, sizeof(buf), \"S%02x\", ret);\n\n put_packet(s, buf);\n\n}\n", + "output": "0", + "index": 10013 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int blk_mig_active(void)\n\n{\n\n return !QSIMPLEQ_EMPTY(&block_mig_state.bmds_list);\n\n}\n", + "output": "1", + "index": 19366 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_logicq_cc(TCGv 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": "0", + "index": 16894 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "CPUMIPSState *cpu_mips_init (const char *cpu_model)\n\n{\n\n CPUMIPSState *env;\n\n const mips_def_t *def;\n\n\n\n def = cpu_mips_find_by_name(cpu_model);\n\n if (!def)\n\n return NULL;\n\n env = qemu_mallocz(sizeof(CPUMIPSState));\n\n env->cpu_model = def;\n\n\n\n cpu_exec_init(env);\n\n env->cpu_model_str = cpu_model;\n\n mips_tcg_init();\n\n cpu_reset(env);\n\n qemu_init_vcpu(env);\n\n return env;\n\n}\n", + "output": "1", + "index": 22260 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int check(AVIOContext *pb, int64_t pos, uint32_t *ret_header)\n\n{\n\n int64_t ret = avio_seek(pb, pos, SEEK_SET);\n\n uint8_t header_buf[4];\n\n unsigned header;\n\n MPADecodeHeader sd;\n\n if (ret < 0)\n\n return CHECK_SEEK_FAILED;\n\n\n\n ret = avio_read(pb, &header_buf[0], 4);\n\n if (ret < 0)\n\n return CHECK_SEEK_FAILED;\n\n\n\n header = AV_RB32(&header_buf[0]);\n\n if (ff_mpa_check_header(header) < 0)\n\n return CHECK_WRONG_HEADER;\n\n if (avpriv_mpegaudio_decode_header(&sd, header) == 1)\n\n return CHECK_WRONG_HEADER;\n\n\n\n if (ret_header)\n\n *ret_header = header;\n\n return sd.frame_size;\n\n}\n", + "output": "1", + "index": 13538 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void v9fs_getlock(void *opaque)\n\n{\n\n size_t offset = 7;\n\n struct stat stbuf;\n\n V9fsFidState *fidp;\n\n V9fsGetlock *glock;\n\n int32_t fid, err = 0;\n\n V9fsPDU *pdu = opaque;\n\n V9fsState *s = pdu->s;\n\n\n\n glock = g_malloc(sizeof(*glock));\n\n pdu_unmarshal(pdu, offset, \"dbqqds\", &fid, &glock->type,\n\n &glock->start, &glock->length, &glock->proc_id,\n\n &glock->client_id);\n\n\n\n trace_v9fs_getlock(pdu->tag, pdu->id, fid,\n\n glock->type, glock->start, glock->length);\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 glock->type = P9_LOCK_TYPE_UNLCK;\n\n offset += pdu_marshal(pdu, offset, \"bqqds\", glock->type,\n\n glock->start, glock->length, glock->proc_id,\n\n &glock->client_id);\n\n err = offset;\n\n trace_v9fs_getlock_return(pdu->tag, pdu->id, glock->type, glock->start,\n\n glock->length, glock->proc_id);\n\nout:\n\n put_fid(pdu, fidp);\n\nout_nofid:\n\n complete_pdu(s, pdu, err);\n\n v9fs_string_free(&glock->client_id);\n\n g_free(glock);\n\n}\n", + "output": "0", + "index": 19497 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ff_er_frame_start(ERContext *s)\n\n{\n\n if (!s->avctx->err_recognition)\n\n return;\n\n\n\n memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END,\n\n s->mb_stride * s->mb_height * sizeof(uint8_t));\n\n s->error_count = 3 * s->mb_num;\n\n s->error_occurred = 0;\n\n}\n", + "output": "0", + "index": 5353 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_savevm_state_header(QEMUFile *f)\n\n{\n\n trace_savevm_state_header();\n\n qemu_put_be32(f, QEMU_VM_FILE_MAGIC);\n\n qemu_put_be32(f, QEMU_VM_FILE_VERSION);\n\n\n\n if (migrate_get_current()->send_configuration ||\n\n enforce_config_section()) {\n\n qemu_put_byte(f, QEMU_VM_CONFIGURATION);\n\n vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);\n\n }\n\n}\n", + "output": "0", + "index": 23503 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_add_polling_cb(PollingFunc *func, void *opaque)\n\n{\n\n PollingEntry **ppe, *pe;\n\n pe = g_malloc0(sizeof(PollingEntry));\n\n pe->func = func;\n\n pe->opaque = opaque;\n\n for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);\n\n *ppe = pe;\n\n return 0;\n\n}\n", + "output": "0", + "index": 20907 + }, + { + "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 = get_surface(frame);\n\n unsigned i;\n\n\n\n for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {\n\n#if CONFIG_D3D11VA\n\n if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface)\n\n {\n\n D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;\n\n ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], &viewDesc);\n\n return viewDesc.Texture2D.ArraySlice;\n\n }\n\n#endif\n\n#if CONFIG_DXVA2\n\n if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface)\n\n return i;\n\n#endif\n\n }\n\n\n\n assert(0);\n\n return 0;\n\n}\n", + "output": "0", + "index": 23929 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void qemu_laio_completion_cb(void *opaque)\n\n{\n\n struct qemu_laio_state *s = opaque;\n\n\n\n while (1) {\n\n struct io_event events[MAX_EVENTS];\n\n uint64_t val;\n\n ssize_t ret;\n\n struct timespec ts = { 0 };\n\n int nevents, i;\n\n\n\n do {\n\n ret = read(s->efd, &val, sizeof(val));\n\n } while (ret == 1 && errno == EINTR);\n\n\n\n if (ret == -1 && errno == EAGAIN)\n\n break;\n\n\n\n if (ret != 8)\n\n break;\n\n\n\n do {\n\n nevents = io_getevents(s->ctx, val, MAX_EVENTS, events, &ts);\n\n } while (nevents == -EINTR);\n\n\n\n for (i = 0; i < nevents; i++) {\n\n struct iocb *iocb = events[i].obj;\n\n struct qemu_laiocb *laiocb =\n\n container_of(iocb, struct qemu_laiocb, iocb);\n\n\n\n laiocb->ret = io_event_ret(&events[i]);\n\n qemu_laio_enqueue_completed(s, laiocb);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 17143 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic)\n\n{\n\n DeviceState *dev;\n\n SysBusDevice *s;\n\n GrackleState *d;\n\n\n\n dev = qdev_create(NULL, \"grackle\");\n\n qdev_init(dev);\n\n s = sysbus_from_qdev(dev);\n\n d = FROM_SYSBUS(GrackleState, s);\n\n d->host_state.bus = pci_register_bus(&d->busdev.qdev, \"pci\",\n\n pci_grackle_set_irq,\n\n pci_grackle_map_irq,\n\n pic, 0, 4);\n\n\n\n pci_create_simple(d->host_state.bus, 0, \"grackle\");\n\n\n\n sysbus_mmio_map(s, 0, base);\n\n sysbus_mmio_map(s, 1, base + 0x00200000);\n\n\n\n return d->host_state.bus;\n\n}\n", + "output": "1", + "index": 1007 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qmp_cont(Error **errp)\n\n{\n\n Error *local_err = NULL;\n\n BlockBackend *blk;\n\n BlockDriverState *bs;\n\n BdrvNextIterator it;\n\n\n\n /* if there is a dump in background, we should wait until the dump\n\n * finished */\n\n if (dump_in_progress()) {\n\n error_setg(errp, \"There is a dump in process, please wait.\");\n\n return;\n\n }\n\n\n\n if (runstate_needs_reset()) {\n\n error_setg(errp, \"Resetting the Virtual Machine is required\");\n\n return;\n\n } else if (runstate_check(RUN_STATE_SUSPENDED)) {\n\n return;\n\n }\n\n\n\n for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {\n\n blk_iostatus_reset(blk);\n\n }\n\n\n\n for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {\n\n bdrv_add_key(bs, NULL, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n }\n\n\n\n /* Continuing after completed migration. Images have been inactivated to\n\n * allow the destination to take control. Need to get control back now.\n\n *\n\n * If there are no inactive block nodes (e.g. because the VM was just\n\n * paused rather than completing a migration), bdrv_inactivate_all() simply\n\n * doesn't do anything. */\n\n bdrv_invalidate_cache_all(&local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n blk_resume_after_migration(&local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n if (runstate_check(RUN_STATE_INMIGRATE)) {\n\n autostart = 1;\n\n } else {\n\n vm_start();\n\n }\n\n}\n", + "output": "0", + "index": 4722 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar)\n\n{\n\n int64_t d = acpi_pm_tmr_get_clock();\n\n if (d >= ar->tmr.overflow_time) {\n\n ar->pm1.evt.sts |= ACPI_BITMASK_TIMER_STATUS;\n\n }\n\n return ar->pm1.evt.sts;\n\n}\n", + "output": "1", + "index": 19351 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int writev_f(BlockBackend *blk, int argc, char **argv)\n\n{\n\n struct timeval t1, t2;\n\n bool Cflag = false, qflag = false;\n\n int flags = 0;\n\n int c, cnt;\n\n char *buf;\n\n int64_t offset;\n\n /* Some compilers get confused and warn if this is not initialized. */\n\n int total = 0;\n\n int nr_iov;\n\n int pattern = 0xcd;\n\n QEMUIOVector qiov;\n\n\n\n while ((c = getopt(argc, argv, \"CqP:\")) != -1) {\n\n switch (c) {\n\n case 'C':\n\n Cflag = true;\n\n break;\n\n case 'f':\n\n flags |= BDRV_REQ_FUA;\n\n break;\n\n case 'q':\n\n qflag = true;\n\n break;\n\n case 'P':\n\n pattern = parse_pattern(optarg);\n\n if (pattern < 0) {\n\n return 0;\n\n }\n\n break;\n\n default:\n\n return qemuio_command_usage(&writev_cmd);\n\n }\n\n }\n\n\n\n if (optind > argc - 2) {\n\n return qemuio_command_usage(&writev_cmd);\n\n }\n\n\n\n offset = cvtnum(argv[optind]);\n\n if (offset < 0) {\n\n print_cvtnum_err(offset, argv[optind]);\n\n return 0;\n\n }\n\n optind++;\n\n\n\n nr_iov = argc - optind;\n\n buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern);\n\n if (buf == NULL) {\n\n return 0;\n\n }\n\n\n\n gettimeofday(&t1, NULL);\n\n cnt = do_aio_writev(blk, &qiov, offset, flags, &total);\n\n gettimeofday(&t2, NULL);\n\n\n\n if (cnt < 0) {\n\n printf(\"writev failed: %s\\n\", strerror(-cnt));\n\n goto out;\n\n }\n\n\n\n if (qflag) {\n\n goto out;\n\n }\n\n\n\n /* Finally, report back -- -C gives a parsable format */\n\n t2 = tsub(t2, t1);\n\n print_report(\"wrote\", &t2, offset, qiov.size, total, cnt, Cflag);\n\nout:\n\n qemu_iovec_destroy(&qiov);\n\n qemu_io_free(buf);\n\n return 0;\n\n}\n", + "output": "1", + "index": 8498 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,\n\n void *opaque)\n\n{\n\n QEMUPutLEDEntry *s;\n\n\n\n s = g_malloc0(sizeof(QEMUPutLEDEntry));\n\n\n\n s->put_led = func;\n\n s->opaque = opaque;\n\n QTAILQ_INSERT_TAIL(&led_handlers, s, next);\n\n return s;\n\n}\n", + "output": "1", + "index": 16101 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qemu_announce_self(void)\n\n{\n\n\tstatic QEMUTimer *timer;\n\n\ttimer = qemu_new_timer(rt_clock, qemu_announce_self_once, &timer);\n\n\tqemu_announce_self_once(&timer);\n\n}\n", + "output": "0", + "index": 2877 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "pvscsi_cleanup_msi(PVSCSIState *s)\n\n{\n\n PCIDevice *d = PCI_DEVICE(s);\n\n\n\n if (s->msi_used) {\n\n msi_uninit(d);\n\n }\n\n}\n", + "output": "0", + "index": 12706 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void filter_channel(MLPDecodeContext *m, unsigned int substr,\n\n unsigned int channel)\n\n{\n\n SubStream *s = &m->substream[substr];\n\n int32_t firbuf[MAX_BLOCKSIZE + MAX_FIR_ORDER];\n\n int32_t iirbuf[MAX_BLOCKSIZE + MAX_IIR_ORDER];\n\n FilterParams *fir = &m->channel_params[channel].filter_params[FIR];\n\n FilterParams *iir = &m->channel_params[channel].filter_params[IIR];\n\n unsigned int filter_shift = fir->shift;\n\n int32_t mask = MSB_MASK(s->quant_step_size[channel]);\n\n int index = MAX_BLOCKSIZE;\n\n int i;\n\n\n\n memcpy(&firbuf[MAX_BLOCKSIZE], &fir->state[0],\n\n MAX_FIR_ORDER * sizeof(int32_t));\n\n memcpy(&iirbuf[MAX_BLOCKSIZE], &iir->state[0],\n\n MAX_IIR_ORDER * sizeof(int32_t));\n\n\n\n for (i = 0; i < s->blocksize; i++) {\n\n int32_t residual = m->sample_buffer[i + s->blockpos][channel];\n\n unsigned int order;\n\n int64_t accum = 0;\n\n int32_t result;\n\n\n\n /* TODO: Move this code to DSPContext? */\n\n\n\n for (order = 0; order < fir->order; order++)\n\n accum += (int64_t)firbuf[index + order] *\n\n fir->coeff[order];\n\n for (order = 0; order < iir->order; order++)\n\n accum += (int64_t)iirbuf[index + order] *\n\n iir->coeff[order];\n\n\n\n accum = accum >> filter_shift;\n\n result = (accum + residual) & mask;\n\n\n\n --index;\n\n\n\n firbuf[index] = result;\n\n iirbuf[index] = result - accum;\n\n\n\n m->sample_buffer[i + s->blockpos][channel] = result;\n\n }\n\n\n\n memcpy(&fir->state[0], &firbuf[index],\n\n MAX_FIR_ORDER * sizeof(int32_t));\n\n memcpy(&iir->state[0], &iirbuf[index],\n\n MAX_IIR_ORDER * sizeof(int32_t));\n\n}\n", + "output": "0", + "index": 2203 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static const char *exynos4210_uart_regname(target_phys_addr_t offset)\n\n{\n\n\n\n int regs_number = sizeof(exynos4210_uart_regs) / sizeof(Exynos4210UartReg);\n\n int i;\n\n\n\n for (i = 0; i < regs_number; i++) {\n\n if (offset == exynos4210_uart_regs[i].offset) {\n\n return exynos4210_uart_regs[i].name;\n\n }\n\n }\n\n\n\n return NULL;\n\n}\n", + "output": "0", + "index": 22103 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ssd0323_load(QEMUFile *f, void *opaque, int version_id)\n\n{\n\n SSISlave *ss = SSI_SLAVE(opaque);\n\n ssd0323_state *s = (ssd0323_state *)opaque;\n\n int i;\n\n\n\n if (version_id != 1)\n\n\n\n\n s->cmd_len = qemu_get_be32(f);\n\n\n\n\n s->cmd = qemu_get_be32(f);\n\n for (i = 0; i < 8; i++)\n\n s->cmd_data[i] = qemu_get_be32(f);\n\n s->row = qemu_get_be32(f);\n\n\n\n\n s->row_start = qemu_get_be32(f);\n\n\n\n\n s->row_end = qemu_get_be32(f);\n\n\n\n\n s->col = qemu_get_be32(f);\n\n\n\n\n s->col_start = qemu_get_be32(f);\n\n\n\n\n s->col_end = qemu_get_be32(f);\n\n\n\n\n s->redraw = qemu_get_be32(f);\n\n s->remap = qemu_get_be32(f);\n\n s->mode = qemu_get_be32(f);\n\n\n\n\n qemu_get_buffer(f, s->framebuffer, sizeof(s->framebuffer));\n\n\n\n ss->cs = qemu_get_be32(f);\n\n\n\n return 0;\n", + "output": "1", + "index": 19843 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int migrate_fd_cleanup(MigrationState *s)\n\n{\n\n int ret = 0;\n\n\n\n qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);\n\n\n\n if (s->file) {\n\n DPRINTF(\"closing file\\n\");\n\n if (qemu_fclose(s->file) != 0) {\n\n ret = -1;\n\n }\n\n s->file = NULL;\n\n } else {\n\n if (s->mon) {\n\n monitor_resume(s->mon);\n\n }\n\n }\n\n\n\n if (s->fd != -1) {\n\n close(s->fd);\n\n s->fd = -1;\n\n }\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 16611 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void *vring_map(MemoryRegion **mr, hwaddr phys, hwaddr len,\n\n bool is_write)\n\n{\n\n MemoryRegionSection section = memory_region_find(get_system_memory(), phys, len);\n\n\n\n if (!section.mr || int128_get64(section.size) < len) {\n\n goto out;\n\n }\n\n if (is_write && section.readonly) {\n\n goto out;\n\n }\n\n if (!memory_region_is_ram(section.mr)) {\n\n goto out;\n\n }\n\n\n\n /* Ignore regions with dirty logging, we cannot mark them dirty */\n\n if (memory_region_is_logging(section.mr)) {\n\n goto out;\n\n }\n\n\n\n *mr = section.mr;\n\n return memory_region_get_ram_ptr(section.mr) + section.offset_within_region;\n\n\n\nout:\n\n memory_region_unref(section.mr);\n\n *mr = NULL;\n\n return NULL;\n\n}\n", + "output": "0", + "index": 507 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static bool ga_open_pidfile(const char *pidfile)\n\n{\n\n int pidfd;\n\n char pidstr[32];\n\n\n\n pidfd = open(pidfile, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR);\n\n if (pidfd == -1 || lockf(pidfd, F_TLOCK, 0)) {\n\n g_critical(\"Cannot lock pid file, %s\", strerror(errno));\n\n if (pidfd != -1) {\n\n close(pidfd);\n\n }\n\n return false;\n\n }\n\n\n\n if (ftruncate(pidfd, 0) || lseek(pidfd, 0, SEEK_SET)) {\n\n g_critical(\"Failed to truncate pid file\");\n\n goto fail;\n\n }\n\n sprintf(pidstr, \"%d\", getpid());\n\n if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) {\n\n g_critical(\"Failed to write pid file\");\n\n goto fail;\n\n }\n\n\n\n return true;\n\n\n\nfail:\n\n unlink(pidfile);\n\n return false;\n\n}\n", + "output": "0", + "index": 9647 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int split_init(AVFilterContext *ctx)\n\n{\n\n SplitContext *s = ctx->priv;\n\n int i;\n\n\n\n for (i = 0; i < s->nb_outputs; i++) {\n\n char name[32];\n\n AVFilterPad pad = { 0 };\n\n\n\n snprintf(name, sizeof(name), \"output%d\", i);\n\n pad.type = ctx->filter->inputs[0].type;\n\n pad.name = av_strdup(name);\n\n if (!pad.name)\n\n return AVERROR(ENOMEM);\n\n\n\n ff_insert_outpad(ctx, i, &pad);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 42 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)\n\n{\n\n MigrationCapabilityStatusList *head = NULL;\n\n MigrationCapabilityStatusList *caps;\n\n MigrationState *s = migrate_get_current();\n\n int i;\n\n\n\n caps = NULL; /* silence compiler warning */\n\n for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {\n\n#ifndef CONFIG_LIVE_BLOCK_MIGRATION\n\n if (i == MIGRATION_CAPABILITY_BLOCK) {\n\n continue;\n\n }\n\n#endif\n\n if (i == MIGRATION_CAPABILITY_X_COLO && !colo_supported()) {\n\n continue;\n\n }\n\n if (head == NULL) {\n\n head = g_malloc0(sizeof(*caps));\n\n caps = head;\n\n } else {\n\n caps->next = g_malloc0(sizeof(*caps));\n\n caps = caps->next;\n\n }\n\n caps->value =\n\n g_malloc(sizeof(*caps->value));\n\n caps->value->capability = i;\n\n caps->value->state = s->enabled_capabilities[i];\n\n }\n\n\n\n return head;\n\n}\n", + "output": "0", + "index": 26391 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ppc_tlb_invalidate_all(CPUPPCState *env)\n\n{\n\n switch (env->mmu_model) {\n\n case POWERPC_MMU_SOFT_6xx:\n\n case POWERPC_MMU_SOFT_74xx:\n\n ppc6xx_tlb_invalidate_all(env);\n\n break;\n\n case POWERPC_MMU_SOFT_4xx:\n\n case POWERPC_MMU_SOFT_4xx_Z:\n\n ppc4xx_tlb_invalidate_all(env);\n\n break;\n\n case POWERPC_MMU_REAL:\n\n cpu_abort(env, \"No TLB for PowerPC 4xx in real mode\\n\");\n\n break;\n\n case POWERPC_MMU_MPC8xx:\n\n /* XXX: TODO */\n\n cpu_abort(env, \"MPC8xx MMU model is not implemented\\n\");\n\n break;\n\n case POWERPC_MMU_BOOKE:\n\n tlb_flush(env, 1);\n\n break;\n\n case POWERPC_MMU_BOOKE206:\n\n booke206_flush_tlb(env, -1, 0);\n\n break;\n\n case POWERPC_MMU_32B:\n\n case POWERPC_MMU_601:\n\n#if defined(TARGET_PPC64)\n\n case POWERPC_MMU_620:\n\n case POWERPC_MMU_64B:\n\n case POWERPC_MMU_2_06:\n\n\n#endif /* defined(TARGET_PPC64) */\n\n tlb_flush(env, 1);\n\n break;\n\n default:\n\n /* XXX: TODO */\n\n cpu_abort(env, \"Unknown MMU model\\n\");\n\n break;\n\n }\n\n}", + "output": "1", + "index": 26472 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp)\n\n{\n\n int err = -1;\n\n int serrno = 0;\n\n\n\n /* Determine the security model */\n\n if (fs_ctx->fs_sm == SM_MAPPED) {\n\n err = mkdir(rpath(fs_ctx, path), SM_LOCAL_DIR_MODE_BITS);\n\n if (err == -1) {\n\n return err;\n\n }\n\n credp->fc_mode = credp->fc_mode|S_IFDIR;\n\n err = local_set_xattr(rpath(fs_ctx, path), credp);\n\n if (err == -1) {\n\n serrno = errno;\n\n goto err_end;\n\n }\n\n } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {\n\n err = mkdir(rpath(fs_ctx, path), credp->fc_mode);\n\n if (err == -1) {\n\n return err;\n\n }\n\n err = local_post_create_passthrough(fs_ctx, path, credp);\n\n if (err == -1) {\n\n serrno = errno;\n\n goto err_end;\n\n }\n\n }\n\n return err;\n\n\n\nerr_end:\n\n remove(rpath(fs_ctx, path));\n\n errno = serrno;\n\n return err;\n\n}\n", + "output": "1", + "index": 10855 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,\n\n int *golden_frame)\n\n{\n\n VP56RangeCoder *c = &s->c;\n\n int rows, cols;\n\n\n\n ff_vp56_init_range_decoder(&s->c, buf, buf_size);\n\n s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c);\n\n vp56_rac_get(c);\n\n ff_vp56_init_dequant(s, vp56_rac_gets(c, 6));\n\n if (s->framep[VP56_FRAME_CURRENT]->key_frame)\n\n {\n\n vp56_rac_gets(c, 8);\n\n if(vp56_rac_gets(c, 5) > 5)\n\n\n vp56_rac_gets(c, 2);\n\n if (vp56_rac_get(c)) {\n\n av_log(s->avctx, AV_LOG_ERROR, \"interlacing not supported\\n\");\n\n\n\n rows = vp56_rac_gets(c, 8); /* number of stored macroblock rows */\n\n cols = vp56_rac_gets(c, 8); /* number of stored macroblock cols */\n\n\n\n\n\n\n vp56_rac_gets(c, 8); /* number of displayed macroblock rows */\n\n vp56_rac_gets(c, 8); /* number of displayed macroblock cols */\n\n vp56_rac_gets(c, 2);\n\n if (!s->macroblocks || /* first frame */\n\n 16*cols != s->avctx->coded_width ||\n\n 16*rows != s->avctx->coded_height) {\n\n avcodec_set_dimensions(s->avctx, 16*cols, 16*rows);\n\n return 2;\n\n\n } else if (!s->macroblocks)\n\n\n return 1;\n", + "output": "1", + "index": 12063 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_inject_mce(Monitor *mon, const QDict *qdict)\n\n{\n\n CPUState *cenv;\n\n int cpu_index = qdict_get_int(qdict, \"cpu_index\");\n\n int bank = qdict_get_int(qdict, \"bank\");\n\n uint64_t status = qdict_get_int(qdict, \"status\");\n\n uint64_t mcg_status = qdict_get_int(qdict, \"mcg_status\");\n\n uint64_t addr = qdict_get_int(qdict, \"addr\");\n\n uint64_t misc = qdict_get_int(qdict, \"misc\");\n\n int broadcast = qdict_get_try_bool(qdict, \"broadcast\", 0);\n\n\n\n for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {\n\n if (cenv->cpu_index == cpu_index && cenv->mcg_cap) {\n\n cpu_x86_inject_mce(cenv, bank, status, mcg_status, addr, misc,\n\n broadcast);\n\n break;\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 20805 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "uint32_t HELPER(lcdbr)(CPUS390XState *env, uint32_t f1, uint32_t f2)\n\n{\n\n env->fregs[f1].d = float64_chs(env->fregs[f2].d);\n\n\n\n return set_cc_nz_f64(env->fregs[f1].d);\n\n}\n", + "output": "0", + "index": 13509 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void av_opt_set_defaults2(void *s, int mask, int flags)\n\n{\n\n#endif\n\n const AVOption *opt = NULL;\n\n while ((opt = av_opt_next(s, opt)) != NULL) {\n\n#if FF_API_OLD_AVOPTIONS\n\n if ((opt->flags & mask) != flags)\n\n continue;\n\n#endif\n\n switch (opt->type) {\n\n case AV_OPT_TYPE_CONST:\n\n /* Nothing to be done here */\n\n break;\n\n case AV_OPT_TYPE_FLAGS:\n\n case AV_OPT_TYPE_INT:\n\n case AV_OPT_TYPE_INT64:\n\n av_opt_set_int(s, opt->name, opt->default_val.i64, 0);\n\n break;\n\n case AV_OPT_TYPE_DOUBLE:\n\n case AV_OPT_TYPE_FLOAT: {\n\n double val;\n\n val = opt->default_val.dbl;\n\n av_opt_set_double(s, opt->name, val, 0);\n\n }\n\n break;\n\n case AV_OPT_TYPE_RATIONAL: {\n\n AVRational val;\n\n val = av_d2q(opt->default_val.dbl, INT_MAX);\n\n av_opt_set_q(s, opt->name, val, 0);\n\n }\n\n break;\n\n case AV_OPT_TYPE_STRING:\n\n case AV_OPT_TYPE_IMAGE_SIZE:\n\n case AV_OPT_TYPE_PIXEL_FMT:\n\n case AV_OPT_TYPE_SAMPLE_FMT:\n\n av_opt_set(s, opt->name, opt->default_val.str, 0);\n\n break;\n\n case AV_OPT_TYPE_BINARY:\n\n /* Cannot set default for binary */\n\n break;\n\n default:\n\n av_log(s, AV_LOG_DEBUG, \"AVOption type %d of option %s not implemented yet\\n\", opt->type, opt->name);\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 27118 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,\n\n int64_t wanted_timestamp, int flags)\n\n{\n\n int a, b, m;\n\n int64_t timestamp;\n\n\n\n a = -1;\n\n b = nb_entries;\n\n\n\n // Optimize appending index entries at the end.\n\n if (b && entries[b - 1].timestamp < wanted_timestamp)\n\n a = b - 1;\n\n\n\n while (b - a > 1) {\n\n m = (a + b) >> 1;\n\n\n\n // Search for the next non-discarded packet.\n\n while ((entries[m].flags & AVINDEX_DISCARD_FRAME) && m < b) {\n\n m++;\n\n if (m == b && entries[m].timestamp >= wanted_timestamp) {\n\n m = b - 1;\n\n break;\n\n }\n\n }\n\n\n\n timestamp = entries[m].timestamp;\n\n if (timestamp >= wanted_timestamp)\n\n b = m;\n\n if (timestamp <= wanted_timestamp)\n\n a = m;\n\n }\n\n m = (flags & AVSEEK_FLAG_BACKWARD) ? a : b;\n\n\n\n if (!(flags & AVSEEK_FLAG_ANY))\n\n while (m >= 0 && m < nb_entries &&\n\n !(entries[m].flags & AVINDEX_KEYFRAME))\n\n m += (flags & AVSEEK_FLAG_BACKWARD) ? -1 : 1;\n\n\n\n if (m == nb_entries)\n\n return -1;\n\n return m;\n\n}\n", + "output": "0", + "index": 13462 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t qpci_spapr_io_readl(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 uint32_t v;\n\n if (port < s->pio.size) {\n\n v = readl(s->pio_cpu_base + port);\n\n } else {\n\n v = readl(s->mmio_cpu_base + port);\n\n }\n\n return bswap32(v);\n\n}\n", + "output": "0", + "index": 791 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int64_t qmp_guest_fsfreeze_thaw(Error **err)\n\n{\n\n int ret;\n\n GuestFsfreezeMountList mounts;\n\n GuestFsfreezeMount *mount;\n\n int fd, i = 0, logged;\n\n\n\n QTAILQ_INIT(&mounts);\n\n ret = guest_fsfreeze_build_mount_list(&mounts);\n\n if (ret) {\n\n error_set(err, QERR_QGA_COMMAND_FAILED,\n\n \"failed to enumerate filesystems\");\n\n return 0;\n\n }\n\n\n\n QTAILQ_FOREACH(mount, &mounts, next) {\n\n logged = false;\n\n fd = qemu_open(mount->dirname, O_RDONLY);\n\n if (fd == -1) {\n\n continue;\n\n }\n\n /* we have no way of knowing whether a filesystem was actually unfrozen\n\n * as a result of a successful call to FITHAW, only that if an error\n\n * was returned the filesystem was *not* unfrozen by that particular\n\n * call.\n\n *\n\n * since multiple preceeding FIFREEZEs require multiple calls to FITHAW\n\n * to unfreeze, continuing issuing FITHAW until an error is returned,\n\n * in which case either the filesystem is in an unfreezable state, or,\n\n * more likely, it was thawed previously (and remains so afterward).\n\n *\n\n * also, since the most recent successful call is the one that did\n\n * the actual unfreeze, we can use this to provide an accurate count\n\n * of the number of filesystems unfrozen by guest-fsfreeze-thaw, which\n\n * may * be useful for determining whether a filesystem was unfrozen\n\n * during the freeze/thaw phase by a process other than qemu-ga.\n\n */\n\n do {\n\n ret = ioctl(fd, FITHAW);\n\n if (ret == 0 && !logged) {\n\n i++;\n\n logged = true;\n\n }\n\n } while (ret == 0);\n\n close(fd);\n\n }\n\n\n\n guest_fsfreeze_state.status = GUEST_FSFREEZE_STATUS_THAWED;\n\n enable_logging();\n\n guest_fsfreeze_free_mount_list(&mounts);\n\n return i;\n\n}\n", + "output": "0", + "index": 7756 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static SocketAddressLegacy *unix_build_address(const char *path)\n\n{\n\n SocketAddressLegacy *saddr;\n\n\n\n saddr = g_new0(SocketAddressLegacy, 1);\n\n saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;\n\n saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);\n\n saddr->u.q_unix.data->path = g_strdup(path);\n\n\n\n return saddr;\n\n}\n", + "output": "0", + "index": 1300 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_load_exclusive(DisasContext *s, int rt, int rt2,\n\n TCGv_i32 addr, int size)\n\n{\n\n TCGv_i32 tmp = tcg_temp_new_i32();\n\n\n\n s->is_ldex = true;\n\n\n\n switch (size) {\n\n case 0:\n\n gen_aa32_ld8u(tmp, addr, get_mem_index(s));\n\n break;\n\n case 1:\n\n gen_aa32_ld16u(tmp, addr, get_mem_index(s));\n\n break;\n\n case 2:\n\n case 3:\n\n gen_aa32_ld32u(tmp, addr, get_mem_index(s));\n\n break;\n\n default:\n\n abort();\n\n }\n\n\n\n if (size == 3) {\n\n TCGv_i32 tmp2 = tcg_temp_new_i32();\n\n TCGv_i32 tmp3 = tcg_temp_new_i32();\n\n\n\n tcg_gen_addi_i32(tmp2, addr, 4);\n\n gen_aa32_ld32u(tmp3, tmp2, get_mem_index(s));\n\n tcg_temp_free_i32(tmp2);\n\n tcg_gen_concat_i32_i64(cpu_exclusive_val, tmp, tmp3);\n\n store_reg(s, rt2, tmp3);\n\n } else {\n\n tcg_gen_extu_i32_i64(cpu_exclusive_val, tmp);\n\n }\n\n\n\n store_reg(s, rt, tmp);\n\n tcg_gen_extu_i32_i64(cpu_exclusive_addr, addr);\n\n}\n", + "output": "0", + "index": 10201 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void s390_cpu_model_initfn(Object *obj)\n{", + "output": "1", + "index": 3891 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int qemu_file_rate_limit(QEMUFile *f)\n\n{\n\n if (qemu_file_get_error(f)) {\n\n return 1;\n\n }\n\n if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) {\n\n return 1;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 6416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void monitor_json_emitter(Monitor *mon, const QObject *data)\n\n{\n\n QString *json;\n\n\n\n json = qobject_to_json(data);\n\n assert(json != NULL);\n\n\n\n mon->mc->print_enabled = 1;\n\n monitor_printf(mon, \"%s\\n\", qstring_get_str(json));\n\n mon->mc->print_enabled = 0;\n\n\n\n QDECREF(json);\n\n}\n", + "output": "0", + "index": 7368 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void validate_seg(int seg_reg, int cpl)\n\n{\n\n int dpl;\n\n uint32_t e2;\n\n \n\n e2 = env->segs[seg_reg].flags;\n\n dpl = (e2 >> DESC_DPL_SHIFT) & 3;\n\n if (!(e2 & DESC_CS_MASK) || !(e2 & DESC_C_MASK)) {\n\n /* data or non conforming code segment */\n\n if (dpl < cpl) {\n\n cpu_x86_load_seg_cache(env, seg_reg, 0, 0, 0, 0);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 13658 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error)\n\n{\n\n BlockdevOnError on_err = is_read ? bs->on_read_error : bs->on_write_error;\n\n\n\n switch (on_err) {\n\n case BLOCKDEV_ON_ERROR_ENOSPC:\n\n return (error == ENOSPC) ?\n\n BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT;\n\n case BLOCKDEV_ON_ERROR_STOP:\n\n return BLOCK_ERROR_ACTION_STOP;\n\n case BLOCKDEV_ON_ERROR_REPORT:\n\n return BLOCK_ERROR_ACTION_REPORT;\n\n case BLOCKDEV_ON_ERROR_IGNORE:\n\n return BLOCK_ERROR_ACTION_IGNORE;\n\n default:\n\n abort();\n\n }\n\n}\n", + "output": "0", + "index": 7485 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface)\n{\n VABufferID va_buffers[3];\n unsigned int n_va_buffers = 0;\n vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id);\n va_buffers[n_va_buffers++] = vactx->pic_param_buf_id;\n if (vactx->iq_matrix_buf_id) {\n vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id);\n va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id;\n }\n if (vactx->bitplane_buf_id) {\n vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id);\n va_buffers[n_va_buffers++] = vactx->bitplane_buf_id;\n }\n if (vaBeginPicture(vactx->display, vactx->context_id,\n surface) != VA_STATUS_SUCCESS)\n return -1;\n if (vaRenderPicture(vactx->display, vactx->context_id,\n va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)\n return -1;\n if (vaRenderPicture(vactx->display, vactx->context_id,\n vactx->slice_buf_ids,\n vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS)\n return -1;\n if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)\n return -1;\n}", + "output": "1", + "index": 19905 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vfio_disable_interrupts(VFIOPCIDevice *vdev)\n\n{\n\n switch (vdev->interrupt) {\n\n case VFIO_INT_INTx:\n\n vfio_disable_intx(vdev);\n\n break;\n\n case VFIO_INT_MSI:\n\n vfio_disable_msi(vdev);\n\n break;\n\n case VFIO_INT_MSIX:\n\n vfio_disable_msix(vdev);\n\n break;\n\n }\n\n}\n", + "output": "1", + "index": 1392 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static ssize_t vnc_client_read_tls(gnutls_session_t *session, uint8_t *data,\n\n size_t datalen)\n\n{\n\n ssize_t ret = gnutls_read(*session, data, datalen);\n\n if (ret < 0) {\n\n if (ret == GNUTLS_E_AGAIN) {\n\n errno = EAGAIN;\n\n } else {\n\n errno = EIO;\n\n }\n\n ret = -1;\n\n }\n\n return ret;\n\n}\n", + "output": "1", + "index": 6953 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int check_codec_match(AVCodecContext *ccf, AVCodecContext *ccs, int stream)\n\n{\n\n int matches = 1;\n\n\n\n#define CHECK_CODEC(x) (ccf->x != ccs->x)\n\n if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {\n\n http_log(\"Codecs do not match for stream %d\\n\", stream);\n\n matches = 0;\n\n } else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {\n\n http_log(\"Codec bitrates do not match for stream %d\\n\", stream);\n\n matches = 0;\n\n } else if (ccf->codec_type == AVMEDIA_TYPE_VIDEO) {\n\n if (CHECK_CODEC(time_base.den) ||\n\n CHECK_CODEC(time_base.num) ||\n\n CHECK_CODEC(width) ||\n\n CHECK_CODEC(height)) {\n\n http_log(\"Codec width, height or framerate do not match for stream %d\\n\", stream);\n\n matches = 0;\n\n }\n\n } else if (ccf->codec_type == AVMEDIA_TYPE_AUDIO) {\n\n if (CHECK_CODEC(sample_rate) ||\n\n CHECK_CODEC(channels) ||\n\n CHECK_CODEC(frame_size)) {\n\n http_log(\"Codec sample_rate, channels, frame_size do not match for stream %d\\n\", stream);\n\n matches = 0;\n\n }\n\n } else {\n\n http_log(\"Unknown codec type for stream %d\\n\", stream);\n\n matches = 0;\n\n }\n\n\n\n return matches;\n\n}\n", + "output": "0", + "index": 22332 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void mdct512(int32_t *out, int16_t *in)\n\n{\n\n int i, re, im, re1, im1;\n\n int16_t rot[MDCT_SAMPLES];\n\n IComplex x[MDCT_SAMPLES/4];\n\n\n\n /* shift to simplify computations */\n\n for (i = 0; i < MDCT_SAMPLES/4; i++)\n\n rot[i] = -in[i + 3*MDCT_SAMPLES/4];\n\n for (;i < MDCT_SAMPLES; i++)\n\n rot[i] = in[i - MDCT_SAMPLES/4];\n\n\n\n /* pre rotation */\n\n for (i = 0; i < MDCT_SAMPLES/4; i++) {\n\n re = ((int)rot[ 2*i] - (int)rot[MDCT_SAMPLES -1-2*i]) >> 1;\n\n im = -((int)rot[MDCT_SAMPLES/2+2*i] - (int)rot[MDCT_SAMPLES/2-1-2*i]) >> 1;\n\n CMUL(x[i].re, x[i].im, re, im, -xcos1[i], xsin1[i]);\n\n }\n\n\n\n fft(x, MDCT_NBITS - 2);\n\n\n\n /* post rotation */\n\n for (i = 0; i < MDCT_SAMPLES/4; i++) {\n\n re = x[i].re;\n\n im = x[i].im;\n\n CMUL(re1, im1, re, im, xsin1[i], xcos1[i]);\n\n out[ 2*i] = im1;\n\n out[MDCT_SAMPLES/2-1-2*i] = re1;\n\n }\n\n}\n", + "output": "0", + "index": 24859 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void usb_packet_complete(USBDevice *dev, USBPacket *p)\n\n{\n\n USBEndpoint *ep = p->ep;\n\n int ret;\n\n\n\n assert(p->state == USB_PACKET_ASYNC);\n\n assert(QTAILQ_FIRST(&ep->queue) == p);\n\n usb_packet_set_state(p, USB_PACKET_COMPLETE);\n\n QTAILQ_REMOVE(&ep->queue, p, queue);\n\n dev->port->ops->complete(dev->port, p);\n\n\n\n while (!QTAILQ_EMPTY(&ep->queue)) {\n\n p = QTAILQ_FIRST(&ep->queue);\n\n if (p->state == USB_PACKET_ASYNC) {\n\n break;\n\n }\n\n assert(p->state == USB_PACKET_QUEUED);\n\n ret = usb_process_one(p);\n\n if (ret == USB_RET_ASYNC) {\n\n usb_packet_set_state(p, USB_PACKET_ASYNC);\n\n break;\n\n }\n\n p->result = ret;\n\n usb_packet_set_state(p, USB_PACKET_COMPLETE);\n\n QTAILQ_REMOVE(&ep->queue, p, queue);\n\n dev->port->ops->complete(dev->port, p);\n\n }\n\n}\n", + "output": "1", + "index": 18513 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int pci_parse_devaddr(const char *addr, int *domp, int *busp,\n\n unsigned int *slotp, unsigned int *funcp)\n\n{\n\n const char *p;\n\n char *e;\n\n unsigned long val;\n\n unsigned long dom = 0, bus = 0;\n\n unsigned int slot = 0;\n\n unsigned int func = 0;\n\n\n\n p = addr;\n\n val = strtoul(p, &e, 16);\n\n if (e == p)\n\n\treturn -1;\n\n if (*e == ':') {\n\n\tbus = val;\n\n\tp = e + 1;\n\n\tval = strtoul(p, &e, 16);\n\n\tif (e == p)\n\n\t return -1;\n\n\tif (*e == ':') {\n\n\t dom = bus;\n\n\t bus = val;\n\n\t p = e + 1;\n\n\t val = strtoul(p, &e, 16);\n\n\t if (e == p)\n\n\t\treturn -1;\n\n\t}\n\n }\n\n\n\n slot = val;\n\n\n\n if (funcp != NULL) {\n\n if (*e != '.')\n\n return -1;\n\n\n\n p = e + 1;\n\n val = strtoul(p, &e, 16);\n\n if (e == p)\n\n return -1;\n\n\n\n func = val;\n\n }\n\n\n\n /* if funcp == NULL func is 0 */\n\n if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)\n\n\treturn -1;\n\n\n\n if (*e)\n\n\treturn -1;\n\n\n\n /* Note: QEMU doesn't implement domains other than 0 */\n\n if (!pci_find_bus(pci_find_root_bus(dom), bus))\n\n\treturn -1;\n\n\n\n *domp = dom;\n\n *busp = bus;\n\n *slotp = slot;\n\n if (funcp != NULL)\n\n *funcp = func;\n\n return 0;\n\n}\n", + "output": "0", + "index": 4388 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "bool qemu_clock_has_timers(QEMUClockType type)\n\n{\n\n return timerlist_has_timers(\n\n main_loop_tlg.tl[type]);\n\n}\n", + "output": "0", + "index": 8050 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)\n\n{\n\n dst->x = av_clip(src->x, s->mv_min.x, s->mv_max.x);\n\n dst->y = av_clip(src->y, s->mv_min.y, s->mv_max.y);\n\n}\n", + "output": "1", + "index": 13307 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static target_long monitor_get_decr (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 cpu_ppc_load_decr(env);\n\n}\n", + "output": "1", + "index": 1683 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int rl2_decode_init(AVCodecContext *avctx)\n\n{\n\n Rl2Context *s = avctx->priv_data;\n\n int back_size;\n\n int i;\n\n s->avctx = avctx;\n\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n\n avcodec_get_frame_defaults(&s->frame);\n\n\n\n /** parse extra data */\n\n if(!avctx->extradata || avctx->extradata_size < EXTRADATA1_SIZE){\n\n av_log(avctx, AV_LOG_ERROR, \"invalid extradata size\\n\");\n\n return -1;\n\n }\n\n\n\n /** get frame_offset */\n\n s->video_base = AV_RL16(&avctx->extradata[0]);\n\n s->clr_count = AV_RL32(&avctx->extradata[2]);\n\n\n\n if(s->video_base >= avctx->width * avctx->height){\n\n av_log(avctx, AV_LOG_ERROR, \"invalid video_base\\n\");\n\n return -1;\n\n }\n\n\n\n /** initialize palette */\n\n for(i=0;ipalette[i] = 0xFF << 24 | AV_RB24(&avctx->extradata[6 + i * 3]);\n\n\n\n /** decode background frame if present */\n\n back_size = avctx->extradata_size - EXTRADATA1_SIZE;\n\n\n\n if(back_size > 0){\n\n unsigned char* back_frame = av_mallocz(avctx->width*avctx->height);\n\n if(!back_frame)\n\n return -1;\n\n rl2_rle_decode(s,avctx->extradata + EXTRADATA1_SIZE,back_size,\n\n back_frame,avctx->width,0);\n\n s->back_frame = back_frame;\n\n }\n\n return 0;\n\n}\n", + "output": "1", + "index": 14658 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "build_header(GArray *linker, GArray *table_data,\n\n AcpiTableHeader *h, const char *sig, int len, uint8_t rev,\n\n const char *oem_id, const char *oem_table_id)\n\n{\n\n memcpy(&h->signature, sig, 4);\n\n h->length = cpu_to_le32(len);\n\n h->revision = rev;\n\n\n\n if (oem_id) {\n\n strncpy((char *)h->oem_id, oem_id, sizeof h->oem_id);\n\n } else {\n\n memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);\n\n }\n\n\n\n if (oem_table_id) {\n\n strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table_id));\n\n } else {\n\n memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);\n\n memcpy(h->oem_table_id + 4, sig, 4);\n\n }\n\n\n\n h->oem_revision = cpu_to_le32(1);\n\n memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);\n\n h->asl_compiler_revision = cpu_to_le32(1);\n\n h->checksum = 0;\n\n /* Checksum to be filled in by Guest linker */\n\n bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,\n\n table_data, h, len, &h->checksum);\n\n}\n", + "output": "0", + "index": 17973 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_spr_ne_601 (CPUPPCState *env)\n\n{\n\n /* Exception processing */\n\n spr_register(env, SPR_DSISR, \"DSISR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n spr_register(env, SPR_DAR, \"DAR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_generic, &spr_write_generic,\n\n 0x00000000);\n\n /* Timer */\n\n spr_register(env, SPR_DECR, \"DECR\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_decr, &spr_write_decr,\n\n 0x00000000);\n\n /* Memory management */\n\n spr_register(env, SPR_SDR1, \"SDR1\",\n\n SPR_NOACCESS, SPR_NOACCESS,\n\n &spr_read_sdr1, &spr_write_sdr1,\n\n 0x00000000);\n\n}\n", + "output": "0", + "index": 23512 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void RENAME(yuv2yuyv422_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 YSCALEYUV2PACKED(%%REGBP, %5)\n\n WRITEYUY2(%%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": 109 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,\n\n DeviceState *dev, Error **errp)\n\n{\n\n PIIX4PMState *s = PIIX4_PM(hotplug_dev);\n\n\n\n if (s->acpi_memory_hotplug.is_enabled &&\n\n object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {\n\n acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,\n\n dev, errp);\n\n } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {\n\n acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,\n\n errp);\n\n } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&\n\n !s->cpu_hotplug_legacy) {\n\n acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);\n\n } else {\n\n error_setg(errp, \"acpi: device unplug request for not supported device\"\n\n \" type: %s\", object_get_typename(OBJECT(dev)));\n\n }\n\n}\n", + "output": "0", + "index": 23621 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,\n\n const char *default_devaddr)\n\n{\n\n const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;\n\n PCIBus *bus;\n\n int devfn;\n\n PCIDevice *pci_dev;\n\n DeviceState *dev;\n\n int i;\n\n\n\n i = qemu_find_nic_model(nd, pci_nic_models, default_model);\n\n if (i < 0)\n\n return NULL;\n\n\n\n bus = pci_get_bus_devfn(&devfn, devaddr);\n\n if (!bus) {\n\n error_report(\"Invalid PCI device address %s for device %s\",\n\n devaddr, pci_nic_names[i]);\n\n return NULL;\n\n }\n\n\n\n pci_dev = pci_create(bus, devfn, pci_nic_names[i]);\n\n dev = &pci_dev->qdev;\n\n if (nd->name)\n\n dev->id = qemu_strdup(nd->name);\n\n qdev_set_nic_properties(dev, nd);\n\n if (qdev_init(dev) < 0)\n\n return NULL;\n\n return pci_dev;\n\n}\n", + "output": "0", + "index": 10262 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_bh_delete_from_cb_many(void)\n\n{\n\n BHTestData data1 = { .n = 0, .max = 1 };\n\n BHTestData data2 = { .n = 0, .max = 3 };\n\n BHTestData data3 = { .n = 0, .max = 2 };\n\n BHTestData data4 = { .n = 0, .max = 4 };\n\n\n\n data1.bh = aio_bh_new(ctx, bh_delete_cb, &data1);\n\n data2.bh = aio_bh_new(ctx, bh_delete_cb, &data2);\n\n data3.bh = aio_bh_new(ctx, bh_delete_cb, &data3);\n\n data4.bh = aio_bh_new(ctx, bh_delete_cb, &data4);\n\n\n\n qemu_bh_schedule(data1.bh);\n\n qemu_bh_schedule(data2.bh);\n\n qemu_bh_schedule(data3.bh);\n\n qemu_bh_schedule(data4.bh);\n\n g_assert_cmpint(data1.n, ==, 0);\n\n g_assert_cmpint(data2.n, ==, 0);\n\n g_assert_cmpint(data3.n, ==, 0);\n\n g_assert_cmpint(data4.n, ==, 0);\n\n\n\n g_assert(aio_poll(ctx, false));\n\n g_assert_cmpint(data1.n, ==, 1);\n\n g_assert_cmpint(data2.n, ==, 1);\n\n g_assert_cmpint(data3.n, ==, 1);\n\n g_assert_cmpint(data4.n, ==, 1);\n\n g_assert(data1.bh == NULL);\n\n\n\n wait_for_aio();\n\n g_assert_cmpint(data1.n, ==, data1.max);\n\n g_assert_cmpint(data2.n, ==, data2.max);\n\n g_assert_cmpint(data3.n, ==, data3.max);\n\n g_assert_cmpint(data4.n, ==, data4.max);\n\n g_assert(data1.bh == NULL);\n\n g_assert(data2.bh == NULL);\n\n g_assert(data3.bh == NULL);\n\n g_assert(data4.bh == NULL);\n\n}\n", + "output": "0", + "index": 26544 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static uint32_t intel_hda_mmio_readl(void *opaque, target_phys_addr_t addr)\n\n{\n\n IntelHDAState *d = opaque;\n\n const IntelHDAReg *reg = intel_hda_reg_find(d, addr);\n\n\n\n return intel_hda_reg_read(d, reg, 0xffffffff);\n\n}\n", + "output": "0", + "index": 22735 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void do_commit(void)\n\n{\n\n int i;\n\n\n\n for (i = 0; i < MAX_DISKS; i++) {\n\n if (bs_table[i])\n\n bdrv_commit(bs_table[i]);\n\n }\n\n}\n", + "output": "0", + "index": 21624 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void pc_hot_add_cpu(const int64_t id, Error **errp)\n{\n DeviceState *icc_bridge;\n int64_t apic_id = x86_cpu_apic_id_from_index(id);\n if (cpu_exists(apic_id)) {\n error_setg(errp, \"Unable to add CPU: %\" PRIi64\n \", it already exists\", id);\n if (id >= max_cpus) {\n error_setg(errp, \"Unable to add CPU: %\" PRIi64\n \", max allowed: %d\", id, max_cpus - 1);\n icc_bridge = DEVICE(object_resolve_path_type(\"icc-bridge\",\n TYPE_ICC_BRIDGE, NULL));\n pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);", + "output": "1", + "index": 15260 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void scsi_read_data(SCSIDevice *d, uint32_t tag)\n\n{\n\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);\n\n SCSIDiskReq *r;\n\n\n\n r = scsi_find_request(s, tag);\n\n if (!r) {\n\n BADF(\"Bad read tag 0x%x\\n\", tag);\n\n /* ??? This is the wrong error. */\n\n scsi_command_complete(r, CHECK_CONDITION, HARDWARE_ERROR);\n\n return;\n\n }\n\n\n\n /* No data transfer may already be in progress */\n\n assert(r->req.aiocb == NULL);\n\n\n\n scsi_read_request(r);\n\n}\n", + "output": "0", + "index": 2471 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void openpic_update_irq(OpenPICState *opp, int n_IRQ)\n\n{\n\n IRQSource *src;\n\n bool active, was_active;\n\n int i;\n\n\n\n src = &opp->src[n_IRQ];\n\n active = src->pending;\n\n\n\n if ((src->ivpr & IVPR_MASK_MASK) && !src->nomask) {\n\n /* Interrupt source is disabled */\n\n DPRINTF(\"%s: IRQ %d is disabled\\n\", __func__, n_IRQ);\n\n active = false;\n\n }\n\n\n\n was_active = !!(src->ivpr & IVPR_ACTIVITY_MASK);\n\n\n\n /*\n\n * We don't have a similar check for already-active because\n\n * ctpr may have changed and we need to withdraw the interrupt.\n\n */\n\n if (!active && !was_active) {\n\n DPRINTF(\"%s: IRQ %d is already inactive\\n\", __func__, n_IRQ);\n\n return;\n\n }\n\n\n\n if (active) {\n\n src->ivpr |= IVPR_ACTIVITY_MASK;\n\n } else {\n\n src->ivpr &= ~IVPR_ACTIVITY_MASK;\n\n }\n\n\n\n if (src->idr == 0) {\n\n /* No target */\n\n DPRINTF(\"%s: IRQ %d has no target\\n\", __func__, n_IRQ);\n\n return;\n\n }\n\n\n\n if (src->idr == (1 << src->last_cpu)) {\n\n /* Only one CPU is allowed to receive this IRQ */\n\n IRQ_local_pipe(opp, src->last_cpu, n_IRQ, active, was_active);\n\n } else if (!(src->ivpr & IVPR_MODE_MASK)) {\n\n /* Directed delivery mode */\n\n for (i = 0; i < opp->nb_cpus; i++) {\n\n if (src->destmask & (1 << i)) {\n\n IRQ_local_pipe(opp, i, n_IRQ, active, was_active);\n\n }\n\n }\n\n } else {\n\n /* Distributed delivery mode */\n\n for (i = src->last_cpu + 1; i != src->last_cpu; i++) {\n\n if (i == opp->nb_cpus) {\n\n i = 0;\n\n }\n\n if (src->destmask & (1 << i)) {\n\n IRQ_local_pipe(opp, i, n_IRQ, active, was_active);\n\n src->last_cpu = i;\n\n break;\n\n }\n\n }\n\n }\n\n}\n", + "output": "0", + "index": 17589 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq)\n\n{\n\n int rc;\n\n uint8_t byte;\n\n\n\n if (!dev->crq.qsize) {\n\n fprintf(stderr, \"spapr_vio_send_creq on uninitialized queue\\n\");\n\n return -1;\n\n }\n\n\n\n /* Maybe do a fast path for KVM just writing to the pages */\n\n rc = spapr_vio_dma_read(dev, dev->crq.qladdr + dev->crq.qnext, &byte, 1);\n\n if (rc) {\n\n return rc;\n\n }\n\n if (byte != 0) {\n\n return 1;\n\n }\n\n\n\n rc = spapr_vio_dma_write(dev, dev->crq.qladdr + dev->crq.qnext + 8,\n\n &crq[8], 8);\n\n if (rc) {\n\n return rc;\n\n }\n\n\n\n kvmppc_eieio();\n\n\n\n rc = spapr_vio_dma_write(dev, dev->crq.qladdr + dev->crq.qnext, crq, 8);\n\n if (rc) {\n\n return rc;\n\n }\n\n\n\n dev->crq.qnext = (dev->crq.qnext + 16) % dev->crq.qsize;\n\n\n\n if (dev->signal_state & 1) {\n\n qemu_irq_pulse(dev->qirq);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 14541 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_rewrite_dvd_sub_extradata(AVStream *st)\n\n{\n\n char pal_s[256];\n\n char buf[256];\n\n int pal_s_pos = 0;\n\n uint8_t *src = st->codec->extradata;\n\n int i;\n\n\n\n if (st->codec->extradata_size != 64)\n\n return 0;\n\n\n\n for (i = 0; i < 16; i++) {\n\n uint32_t yuv = AV_RB32(src + i * 4);\n\n uint32_t rgba = yuv_to_rgba(yuv);\n\n\n\n snprintf(pal_s + pal_s_pos, sizeof(pal_s) - pal_s_pos, \"%06x%s\", rgba,\n\n i != 15 ? \", \" : \"\");\n\n pal_s_pos = strlen(pal_s);\n\n if (pal_s_pos >= sizeof(pal_s))\n\n return 0;\n\n }\n\n\n\n snprintf(buf, sizeof(buf), \"size: %dx%d\\npalette: %s\\n\",\n\n st->codec->width, st->codec->height, pal_s);\n\n\n\n av_freep(&st->codec->extradata);\n\n st->codec->extradata_size = 0;\n\n st->codec->extradata = av_mallocz(strlen(buf) + FF_INPUT_BUFFER_PADDING_SIZE);\n\n if (!st->codec->extradata)\n\n return AVERROR(ENOMEM);\n\n st->codec->extradata_size = strlen(buf);\n\n memcpy(st->codec->extradata, buf, st->codec->extradata_size);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 15994 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int paio_init(void)\n\n{\n\n struct sigaction act;\n\n PosixAioState *s;\n\n int fds[2];\n\n int ret;\n\n\n\n if (posix_aio_state)\n\n return 0;\n\n\n\n s = qemu_malloc(sizeof(PosixAioState));\n\n\n\n sigfillset(&act.sa_mask);\n\n act.sa_flags = 0; /* do not restart syscalls to interrupt select() */\n\n act.sa_handler = aio_signal_handler;\n\n sigaction(SIGUSR2, &act, NULL);\n\n\n\n s->first_aio = NULL;\n\n if (pipe(fds) == -1) {\n\n fprintf(stderr, \"failed to create pipe\\n\");\n\n return -1;\n\n }\n\n\n\n s->rfd = fds[0];\n\n s->wfd = fds[1];\n\n\n\n fcntl(s->rfd, F_SETFL, O_NONBLOCK);\n\n fcntl(s->wfd, F_SETFL, O_NONBLOCK);\n\n\n\n qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush,\n\n posix_aio_process_queue, s);\n\n\n\n ret = pthread_attr_init(&attr);\n\n if (ret)\n\n die2(ret, \"pthread_attr_init\");\n\n\n\n ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n\n if (ret)\n\n die2(ret, \"pthread_attr_setdetachstate\");\n\n\n\n QTAILQ_INIT(&request_list);\n\n\n\n posix_aio_state = s;\n\n return 0;\n\n}\n", + "output": "1", + "index": 14066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int url_open(URLContext **puc, const char *filename, int flags)\n\n{\n\n URLProtocol *up;\n\n const char *p;\n\n char proto_str[128], *q;\n\n\n\n p = filename;\n\n q = proto_str;\n\n while (*p != '\\0' && *p != ':') {\n\n /* protocols can only contain alphabetic chars */\n\n if (!isalpha(*p))\n\n goto file_proto;\n\n if ((q - proto_str) < sizeof(proto_str) - 1)\n\n *q++ = *p;\n\n p++;\n\n }\n\n /* if the protocol has length 1, we consider it is a dos drive */\n\n if (*p == '\\0' || (q - proto_str) <= 1) {\n\n file_proto:\n\n strcpy(proto_str, \"file\");\n\n } else {\n\n *q = '\\0';\n\n }\n\n\n\n up = first_protocol;\n\n while (up != NULL) {\n\n if (!strcmp(proto_str, up->name))\n\n return url_open_protocol (puc, up, filename, flags);\n\n up = up->next;\n\n }\n\n *puc = NULL;\n\n return AVERROR(ENOENT);\n\n}\n", + "output": "1", + "index": 25141 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result,\n\n BdrvCheckMode fix)\n\n{\n\n return qcow2_check_refcounts(bs, result, fix);\n\n}\n", + "output": "0", + "index": 7781 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ftp_open(URLContext *h, const char *url, int flags)\n\n{\n\n char proto[10], path[MAX_URL_SIZE];\n\n int err;\n\n FTPContext *s = h->priv_data;\n\n\n\n av_dlog(h, \"ftp protocol open\\n\");\n\n\n\n s->state = DISCONNECTED;\n\n s->filesize = -1;\n\n s->position = 0;\n\n\n\n av_url_split(proto, sizeof(proto),\n\n s->credencials, sizeof(s->credencials),\n\n s->hostname, sizeof(s->hostname),\n\n &s->server_control_port,\n\n path, sizeof(path),\n\n url);\n\n\n\n if (s->server_control_port < 0 || s->server_control_port > 65535)\n\n s->server_control_port = 21;\n\n\n\n if ((err = ftp_connect_control_connection(h)) < 0)\n\n goto fail;\n\n\n\n if ((err = ftp_current_dir(s)) < 0)\n\n goto fail;\n\n av_strlcat(s->path, path, sizeof(s->path));\n\n\n\n if (ftp_restart(s, 0) < 0) {\n\n h->is_streamed = 1;\n\n } else {\n\n if (ftp_file_size(s) < 0 && flags & AVIO_FLAG_READ)\n\n h->is_streamed = 1;\n\n if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)\n\n h->is_streamed = 1;\n\n }\n\n\n\n return 0;\n\n\n\n fail:\n\n av_log(h, AV_LOG_ERROR, \"FTP open failed\\n\");\n\n ffurl_closep(&s->conn_control);\n\n ffurl_closep(&s->conn_data);\n\n return err;\n\n}\n", + "output": "0", + "index": 12928 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void monitor_flush(Monitor *mon)\n\n{\n\n int rc;\n\n size_t len;\n\n const char *buf;\n\n\n\n if (mon->skip_flush) {\n\n return;\n\n }\n\n\n\n buf = qstring_get_str(mon->outbuf);\n\n len = qstring_get_length(mon->outbuf);\n\n\n\n if (len && !mon->mux_out) {\n\n rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len);\n\n if (rc == len) {\n\n /* all flushed */\n\n QDECREF(mon->outbuf);\n\n mon->outbuf = qstring_new();\n\n return;\n\n }\n\n if (rc > 0) {\n\n /* partinal write */\n\n QString *tmp = qstring_from_str(buf + rc);\n\n QDECREF(mon->outbuf);\n\n mon->outbuf = tmp;\n\n }\n\n if (mon->watch == 0) {\n\n mon->watch = qemu_chr_fe_add_watch(mon->chr, G_IO_OUT,\n\n monitor_unblocked, mon);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 8470 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_405_check_ov (void)\n\n{\n\n do_405_check_ov();\n\n RETURN();\n\n}\n", + "output": "1", + "index": 22525 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void unset_dirty_tracking(void)\n\n{\n\n BlkMigDevState *bmds;\n\n\n\n QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {\n\n aio_context_acquire(blk_get_aio_context(bmds->blk));\n\n bdrv_release_dirty_bitmap(blk_bs(bmds->blk), bmds->dirty_bitmap);\n\n aio_context_release(blk_get_aio_context(bmds->blk));\n\n }\n\n}\n", + "output": "0", + "index": 418 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int probe_file(WriterContext *wctx, const char *filename)\n\n{\n\n AVFormatContext *fmt_ctx;\n\n int ret, i;\n\n int section_id;\n\n\n\n do_read_frames = do_show_frames || do_count_frames;\n\n do_read_packets = do_show_packets || do_count_packets;\n\n\n\n ret = open_input_file(&fmt_ctx, filename);\n\n if (ret < 0)\n\n return ret;\n\n\n\n nb_streams_frames = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));\n\n nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));\n\n selected_streams = av_calloc(fmt_ctx->nb_streams, sizeof(*selected_streams));\n\n\n\n for (i = 0; i < fmt_ctx->nb_streams; i++) {\n\n if (stream_specifier) {\n\n ret = avformat_match_stream_specifier(fmt_ctx,\n\n fmt_ctx->streams[i],\n\n stream_specifier);\n\n if (ret < 0)\n\n goto end;\n\n else\n\n selected_streams[i] = ret;\n\n ret = 0;\n\n } else {\n\n selected_streams[i] = 1;\n\n }\n\n }\n\n\n\n if (do_read_frames || do_read_packets) {\n\n if (do_show_frames && do_show_packets &&\n\n wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER)\n\n section_id = SECTION_ID_PACKETS_AND_FRAMES;\n\n else if (do_show_packets && !do_show_frames)\n\n section_id = SECTION_ID_PACKETS;\n\n else // (!do_show_packets && do_show_frames)\n\n section_id = SECTION_ID_FRAMES;\n\n if (do_show_frames || do_show_packets)\n\n writer_print_section_header(wctx, section_id);\n\n read_packets(wctx, fmt_ctx);\n\n if (do_show_frames || do_show_packets)\n\n writer_print_section_footer(wctx);\n\n }\n\n if (do_show_programs)\n\n show_programs(wctx, fmt_ctx);\n\n if (do_show_streams)\n\n show_streams(wctx, fmt_ctx);\n\n if (do_show_chapters)\n\n show_chapters(wctx, fmt_ctx);\n\n if (do_show_format)\n\n show_format(wctx, fmt_ctx);\n\n\n\nend:\n\n close_input_file(&fmt_ctx);\n\n av_freep(&nb_streams_frames);\n\n av_freep(&nb_streams_packets);\n\n av_freep(&selected_streams);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 7256 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)\n\n{\n\n VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev);\n\n uint8_t *pci_conf;\n\n\n\n pci_conf = s->dev.config;\n\n pci_set_word(pci_conf + PCI_COMMAND, 0);\n\n pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK |\n\n PCI_STATUS_DEVSEL_MEDIUM);\n\n\n\n /* 0x48-0x4B is Power Management I/O Base */\n\n pci_set_long(pci_conf + 0x48, 0x00000001);\n\n\n\n /* SMB ports:0xeee0~0xeeef */\n\n s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0);\n\n pci_conf[0x90] = s->smb_io_base | 1;\n\n pci_conf[0x91] = s->smb_io_base >> 8;\n\n pci_conf[0xd2] = 0x90;\n\n pm_smbus_init(&s->dev.qdev, &s->smb);\n\n memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);\n\n\n\n apm_init(dev, &s->apm, NULL, s);\n\n\n\n memory_region_init(&s->io, OBJECT(dev), \"vt82c686-pm\", 64);\n\n memory_region_set_enabled(&s->io, false);\n\n memory_region_add_subregion(get_system_io(), 0, &s->io);\n\n\n\n acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);\n\n acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);\n\n acpi_pm1_cnt_init(&s->ar, &s->io, 2);\n\n}\n", + "output": "0", + "index": 19117 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr,\n\n int insn, int size, int sign)\n\n{\n\n TCGv_i32 r_asi, r_size, r_sign;\n\n\n\n r_asi = gen_get_asi(dc, insn);\n\n r_size = tcg_const_i32(size);\n\n r_sign = tcg_const_i32(sign);\n\n#ifdef TARGET_SPARC64\n\n gen_helper_ld_asi(dst, cpu_env, addr, r_asi, r_size, r_sign);\n\n#else\n\n {\n\n TCGv_i64 t64 = tcg_temp_new_i64();\n\n gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);\n\n tcg_gen_trunc_i64_tl(dst, t64);\n\n tcg_temp_free_i64(t64);\n\n }\n\n#endif\n\n tcg_temp_free_i32(r_sign);\n\n tcg_temp_free_i32(r_size);\n\n tcg_temp_free_i32(r_asi);\n\n}\n", + "output": "0", + "index": 15061 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void 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 fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));\n\n}\n", + "output": "1", + "index": 24423 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n __asm__ volatile(\n\n \"mov %0, %%\"REG_a\" \\n\\t\"\n\n \"1: \\n\\t\"\n\n \"movq (%1, %%\"REG_a\",2), %%mm0 \\n\\t\"\n\n \"movq 8(%1, %%\"REG_a\",2), %%mm1 \\n\\t\"\n\n \"psrlw $8, %%mm0 \\n\\t\"\n\n \"psrlw $8, %%mm1 \\n\\t\"\n\n \"packuswb %%mm1, %%mm0 \\n\\t\"\n\n \"movq %%mm0, (%2, %%\"REG_a\") \\n\\t\"\n\n \"add $8, %%\"REG_a\" \\n\\t\"\n\n \" js 1b \\n\\t\"\n\n : : \"g\" ((x86_reg)-width), \"r\" (src+width*2), \"r\" (dst+width)\n\n : \"%\"REG_a\n\n );\n\n#else\n\n int i;\n\n for (i=0; ipvr & pcc->pvr_mask) == (pvr & pcc->pvr_mask)) ? 0 : -1);\n\n\n\n return ret;\n\n}\n", + "output": "0", + "index": 12633 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_dozo(DisasContext *ctx)\n\n{\n\n int l1 = gen_new_label();\n\n int l2 = gen_new_label();\n\n TCGv t0 = tcg_temp_new();\n\n TCGv t1 = tcg_temp_new();\n\n TCGv t2 = tcg_temp_new();\n\n /* Start with XER OV disabled, the most likely case */\n\n tcg_gen_movi_tl(cpu_ov, 0);\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(t0, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);\n\n tcg_gen_xor_tl(t1, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);\n\n tcg_gen_xor_tl(t2, cpu_gpr[rA(ctx->opcode)], t0);\n\n tcg_gen_andc_tl(t1, t1, t2);\n\n tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);\n\n tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);\n\n tcg_gen_movi_tl(cpu_ov, 1);\n\n tcg_gen_movi_tl(cpu_so, 1);\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 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[rD(ctx->opcode)]);\n\n}\n", + "output": "0", + "index": 19517 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int file_write(URLContext *h, const unsigned char *buf, int size)\n\n{\n\n FileContext *c = h->priv_data;\n\n int r = write(c->fd, buf, size);\n\n return (-1 == r)?AVERROR(errno):r;\n\n}\n", + "output": "0", + "index": 11103 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n, uint64_t dma_addr,\n\n uint16_t sqid, uint16_t cqid, uint16_t size)\n\n{\n\n int i;\n\n NvmeCQueue *cq;\n\n\n\n sq->ctrl = n;\n\n sq->dma_addr = dma_addr;\n\n sq->sqid = sqid;\n\n sq->size = size;\n\n sq->cqid = cqid;\n\n sq->head = sq->tail = 0;\n\n sq->io_req = g_malloc(sq->size * sizeof(*sq->io_req));\n\n\n\n QTAILQ_INIT(&sq->req_list);\n\n QTAILQ_INIT(&sq->out_req_list);\n\n for (i = 0; i < sq->size; i++) {\n\n sq->io_req[i].sq = sq;\n\n QTAILQ_INSERT_TAIL(&(sq->req_list), &sq->io_req[i], entry);\n\n }\n\n sq->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, nvme_process_sq, sq);\n\n\n\n assert(n->cq[cqid]);\n\n cq = n->cq[cqid];\n\n QTAILQ_INSERT_TAIL(&(cq->sq_list), sq, entry);\n\n n->sq[sqid] = sq;\n\n}\n", + "output": "1", + "index": 18721 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)\n\n{\n\n unsupported_encoding(s, insn);\n\n}\n", + "output": "0", + "index": 16066 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int decode_interrupt_cb(void *ctx)\n\n{\n\n return received_nb_signals > transcode_init_done;\n\n}\n", + "output": "1", + "index": 25377 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "VncInfo *qmp_query_vnc(Error **errp)\n\n{\n\n VncInfo *info = g_malloc0(sizeof(*info));\n\n VncDisplay *vd = vnc_display_find(NULL);\n\n SocketAddressLegacy *addr = NULL;\n\n\n\n if (vd == NULL || !vd->nlsock) {\n\n info->enabled = false;\n\n } else {\n\n info->enabled = true;\n\n\n\n /* for compatibility with the original command */\n\n info->has_clients = true;\n\n info->clients = qmp_query_client_list(vd);\n\n\n\n if (vd->lsock == NULL) {\n\n return info;\n\n }\n\n\n\n addr = qio_channel_socket_get_local_address(vd->lsock[0], errp);\n\n if (!addr) {\n\n goto out_error;\n\n }\n\n\n\n switch (addr->type) {\n\n case SOCKET_ADDRESS_LEGACY_KIND_INET:\n\n info->host = g_strdup(addr->u.inet.data->host);\n\n info->service = g_strdup(addr->u.inet.data->port);\n\n if (addr->u.inet.data->ipv6) {\n\n info->family = NETWORK_ADDRESS_FAMILY_IPV6;\n\n } else {\n\n info->family = NETWORK_ADDRESS_FAMILY_IPV4;\n\n }\n\n break;\n\n\n\n case SOCKET_ADDRESS_LEGACY_KIND_UNIX:\n\n info->host = g_strdup(\"\");\n\n info->service = g_strdup(addr->u.q_unix.data->path);\n\n info->family = NETWORK_ADDRESS_FAMILY_UNIX;\n\n break;\n\n\n\n case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:\n\n case SOCKET_ADDRESS_LEGACY_KIND_FD:\n\n error_setg(errp, \"Unsupported socket address type %s\",\n\n SocketAddressLegacyKind_lookup[addr->type]);\n\n goto out_error;\n\n default:\n\n abort();\n\n }\n\n\n\n info->has_host = true;\n\n info->has_service = true;\n\n info->has_family = true;\n\n\n\n info->has_auth = true;\n\n info->auth = g_strdup(vnc_auth_name(vd));\n\n }\n\n\n\n qapi_free_SocketAddressLegacy(addr);\n\n return info;\n\n\n\nout_error:\n\n qapi_free_SocketAddressLegacy(addr);\n\n qapi_free_VncInfo(info);\n\n return NULL;\n\n}\n", + "output": "0", + "index": 21098 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int ftp_restart(FTPContext *s, int64_t pos)\n\n{\n\n char command[CONTROL_BUFFER_SIZE];\n\n const int rest_codes[] = {350, 0};\n\n\n\n snprintf(command, sizeof(command), \"REST %\"PRId64\"\\r\\n\", pos);\n\n if (!ftp_send_command(s, command, rest_codes, NULL))\n\n return AVERROR(EIO);\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 23136 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void gdb_continue(GDBState *s)\n\n{\n\n#ifdef CONFIG_USER_ONLY\n\n s->running_state = 1;\n\n#else\n\n vm_start();\n\n#endif\n\n}\n", + "output": "1", + "index": 6954 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i)\n\n{\n\n return shared_page->vcpu_iodata[i].vp_eport;\n\n}\n", + "output": "0", + "index": 14839 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void OPPROTO op_sti(void)\n\n{\n\n raise_exception(EXCP0D_GPF);\n\n}\n", + "output": "0", + "index": 21454 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int page_unprotect(target_ulong address, uintptr_t pc, void *puc)\n\n{\n\n unsigned int prot;\n\n PageDesc *p;\n\n target_ulong host_start, host_end, addr;\n\n\n\n /* Technically this isn't safe inside a signal handler. However we\n\n know this only ever happens in a synchronous SEGV handler, so in\n\n practice it seems to be ok. */\n\n mmap_lock();\n\n\n\n p = page_find(address >> TARGET_PAGE_BITS);\n\n if (!p) {\n\n mmap_unlock();\n\n return 0;\n\n }\n\n\n\n /* if the page was really writable, then we change its\n\n protection back to writable */\n\n if ((p->flags & PAGE_WRITE_ORG) && !(p->flags & PAGE_WRITE)) {\n\n host_start = address & qemu_host_page_mask;\n\n host_end = host_start + qemu_host_page_size;\n\n\n\n prot = 0;\n\n for (addr = host_start ; addr < host_end ; addr += TARGET_PAGE_SIZE) {\n\n p = page_find(addr >> TARGET_PAGE_BITS);\n\n p->flags |= PAGE_WRITE;\n\n prot |= p->flags;\n\n\n\n /* and since the content will be modified, we must invalidate\n\n the corresponding translated code. */\n\n tb_invalidate_phys_page(addr, pc, puc);\n\n#ifdef DEBUG_TB_CHECK\n\n tb_invalidate_check(addr);\n\n#endif\n\n }\n\n mprotect((void *)g2h(host_start), qemu_host_page_size,\n\n prot & PAGE_BITS);\n\n\n\n mmap_unlock();\n\n return 1;\n\n }\n\n mmap_unlock();\n\n return 0;\n\n}\n", + "output": "1", + "index": 10416 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline float32 ucf64_itos(uint32_t i)\n\n{\n\n union {\n\n uint32_t i;\n\n float32 s;\n\n } v;\n\n\n\n v.i = i;\n\n return v.s;\n\n}\n", + "output": "0", + "index": 2515 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void qpci_msix_disable(QPCIDevice *dev)\n\n{\n\n uint8_t addr;\n\n uint16_t val;\n\n\n\n g_assert(dev->msix_enabled);\n\n addr = qpci_find_capability(dev, PCI_CAP_ID_MSIX);\n\n g_assert_cmphex(addr, !=, 0);\n\n val = qpci_config_readw(dev, addr + PCI_MSIX_FLAGS);\n\n qpci_config_writew(dev, addr + PCI_MSIX_FLAGS,\n\n val & ~PCI_MSIX_FLAGS_ENABLE);\n\n\n\n qpci_iounmap(dev, dev->msix_table_bar);\n\n qpci_iounmap(dev, dev->msix_pba_bar);\n\n dev->msix_enabled = 0;\n\n dev->msix_table_off = 0;\n\n dev->msix_pba_off = 0;\n\n}\n", + "output": "0", + "index": 3049 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,\n\n DriveInfo *hd1, qemu_irq irq)\n\n{\n\n int i;\n\n DriveInfo *dinfo;\n\n\n\n for(i = 0; i < 2; i++) {\n\n dinfo = i == 0 ? hd0 : hd1;\n\n ide_init1(bus, i);\n\n if (dinfo) {\n\n if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,\n\n dinfo->media_cd ? IDE_CD : IDE_HD, NULL,\n\n *dinfo->serial ? dinfo->serial : NULL) < 0) {\n\n error_report(\"Can't set up IDE drive %s\", dinfo->id);\n\n exit(1);\n\n }\n\n bdrv_attach_dev_nofail(dinfo->bdrv, &bus->ifs[i]);\n\n } else {\n\n ide_reset(&bus->ifs[i]);\n\n }\n\n }\n\n bus->irq = irq;\n\n bus->dma = &ide_dma_nop;\n\n}\n", + "output": "0", + "index": 1168 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "AVFilterFormats *ff_make_format_list(const int *fmts)\n\n{\n\n AVFilterFormats *formats;\n\n int count;\n\n\n\n for (count = 0; fmts[count] != -1; count++)\n\n ;\n\n\n\n formats = av_mallocz(sizeof(*formats));\n\n if (count)\n\n formats->formats = av_malloc(sizeof(*formats->formats) * count);\n\n formats->nb_formats = count;\n\n memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);\n\n\n\n return formats;\n\n}\n", + "output": "0", + "index": 15498 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)\n\n{\n\n uint16_t *copy;\n\n\n\n copy = g_malloc(sizeof(value));\n\n *copy = cpu_to_le16(value);\n\n fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));\n\n}\n", + "output": "1", + "index": 2380 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov,\n\n MOVTrack *track, AVStream *st)\n\n{\n\n int64_t pos = avio_tell(pb);\n\n avio_wb32(pb, 0); /* size */\n\n ffio_wfourcc(pb, \"trak\");\n\n mov_write_tkhd_tag(pb, mov, track, st);\n\n if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS ||\n\n (track->entry && track->cluster[0].dts) ||\n\n is_clcp_track(track)) {\n\n if (mov->use_editlist)\n\n mov_write_edts_tag(pb, mov, track); // PSP Movies require edts box\n\n else if ((track->entry && track->cluster[0].dts) || track->mode == MODE_PSP || is_clcp_track(track))\n\n av_log(mov->fc, AV_LOG_WARNING,\n\n \"Not writing any edit list even though one would have been required\\n\");\n\n }\n\n if (track->tref_tag)\n\n mov_write_tref_tag(pb, track);\n\n mov_write_mdia_tag(pb, mov, track);\n\n if (track->mode == MODE_PSP)\n\n mov_write_uuid_tag_psp(pb, track); // PSP Movies require this uuid box\n\n if (track->tag == MKTAG('r','t','p',' '))\n\n mov_write_udta_sdp(pb, track);\n\n if (track->mode == MODE_MOV) {\n\n if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {\n\n double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);\n\n if ((0.0 != sample_aspect_ratio && 1.0 != sample_aspect_ratio)) {\n\n mov_write_tapt_tag(pb, track);\n\n }\n\n }\n\n if (is_clcp_track(track)) {\n\n mov_write_tapt_tag(pb, track);\n\n }\n\n }\n\n mov_write_track_udta_tag(pb, mov, st);\n\n return update_size(pb, pos);\n\n}\n", + "output": "1", + "index": 13678 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void ehci_trace_itd(EHCIState *s, target_phys_addr_t addr, EHCIitd *itd)\n\n{\n\n trace_usb_ehci_itd(addr, itd->next);\n\n}\n", + "output": "1", + "index": 11051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void av_build_index_raw(AVFormatContext *s)\n\n{\n\n AVPacket pkt1, *pkt = &pkt1;\n\n int ret;\n\n AVStream *st;\n\n\n\n st = s->streams[0];\n\n av_read_frame_flush(s);\n\n url_fseek(&s->pb, s->data_offset, SEEK_SET);\n\n\n\n for(;;) {\n\n ret = av_read_frame(s, pkt);\n\n if (ret < 0)\n\n break;\n\n if (pkt->stream_index == 0 && st->parser &&\n\n (pkt->flags & PKT_FLAG_KEY)) {\n\n add_index_entry(st, st->parser->frame_offset, pkt->dts, \n\n AVINDEX_KEYFRAME);\n\n }\n\n av_free_packet(pkt);\n\n }\n\n}\n", + "output": "0", + "index": 23161 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void matroska_add_index_entries(MatroskaDemuxContext *matroska)\n\n{\n\n EbmlList *index_list;\n\n MatroskaIndex *index;\n\n int index_scale = 1;\n\n int i, j;\n\n\n\n if (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)\n\n return;\n\n\n\n index_list = &matroska->index;\n\n index = index_list->elem;\n\n if (index_list->nb_elem &&\n\n index[0].time > 1E14 / matroska->time_scale) {\n\n av_log(matroska->ctx, AV_LOG_WARNING, \"Working around broken index.\\n\");\n\n index_scale = matroska->time_scale;\n\n }\n\n for (i = 0; i < index_list->nb_elem; i++) {\n\n EbmlList *pos_list = &index[i].pos;\n\n MatroskaIndexPos *pos = pos_list->elem;\n\n for (j = 0; j < pos_list->nb_elem; j++) {\n\n MatroskaTrack *track = matroska_find_track_by_num(matroska,\n\n pos[j].track);\n\n if (track && track->stream)\n\n av_add_index_entry(track->stream,\n\n pos[j].pos + matroska->segment_start,\n\n index[i].time / index_scale, 0, 0,\n\n AVINDEX_KEYFRAME);\n\n }\n\n }\n\n}\n", + "output": "1", + "index": 17353 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static CPUArchState *find_cpu(uint32_t thread_id)\n\n{\n\n CPUState *cpu;\n\n\n\n cpu = qemu_get_cpu(thread_id);\n\n if (cpu == NULL) {\n\n return NULL;\n\n }\n\n return cpu->env_ptr;\n\n}\n", + "output": "1", + "index": 3462 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void nbd_client_session_detach_aio_context(NbdClientSession *client)\n\n{\n\n aio_set_fd_handler(bdrv_get_aio_context(client->bs), client->sock,\n\n NULL, NULL, NULL);\n\n}\n", + "output": "0", + "index": 14907 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void av_noinline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {\n\n const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset;\n\n const int alpha = alpha_table[index_a];\n\n const int beta = (beta_table+52)[qp + h->slice_beta_offset];\n\n if (alpha ==0 || beta == 0) return;\n\n\n\n if( bS[0] < 4 ) {\n\n int8_t tc[4];\n\n tc[0] = tc0_table[index_a][bS[0]];\n\n tc[1] = tc0_table[index_a][bS[1]];\n\n tc[2] = tc0_table[index_a][bS[2]];\n\n tc[3] = tc0_table[index_a][bS[3]];\n\n h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);\n\n } else {\n\n h->s.dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);\n\n }\n\n}\n", + "output": "0", + "index": 15051 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "void block_job_enter(BlockJob *job)\n\n{\n\n if (job->co && !job->busy) {\n\n bdrv_coroutine_enter(blk_bs(job->blk), job->co);\n\n }\n\n}\n", + "output": "0", + "index": 4500 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void pmac_ide_transfer(DBDMA_io *io)\n\n{\n\n MACIOIDEState *m = io->opaque;\n\n IDEState *s = idebus_active_if(&m->bus);\n\n\n\n MACIO_DPRINTF(\"\\n\");\n\n\n\n s->io_buffer_size = 0;\n\n if (s->drive_kind == IDE_CD) {\n\n\n\n /* Handle non-block ATAPI DMA transfers */\n\n if (s->lba == -1) {\n\n s->io_buffer_size = MIN(io->len, s->packet_transfer_size);\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size,\n\n BLOCK_ACCT_READ);\n\n MACIO_DPRINTF(\"non-block ATAPI DMA transfer size: %d\\n\",\n\n s->io_buffer_size);\n\n\n\n /* Copy ATAPI buffer directly to RAM and finish */\n\n cpu_physical_memory_write(io->addr, s->io_buffer,\n\n s->io_buffer_size);\n\n ide_atapi_cmd_ok(s);\n\n m->dma_active = false;\n\n\n\n MACIO_DPRINTF(\"end of non-block ATAPI DMA transfer\\n\");\n\n block_acct_done(bdrv_get_stats(s->bs), &s->acct);\n\n io->dma_end(io);\n\n return;\n\n }\n\n\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,\n\n BLOCK_ACCT_READ);\n\n pmac_ide_atapi_transfer_cb(io, 0);\n\n return;\n\n }\n\n\n\n switch (s->dma_cmd) {\n\n case IDE_DMA_READ:\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,\n\n BLOCK_ACCT_READ);\n\n break;\n\n case IDE_DMA_WRITE:\n\n block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,\n\n BLOCK_ACCT_WRITE);\n\n break;\n\n default:\n\n break;\n\n }\n\n\n\n io->requests++;\n\n pmac_ide_transfer_cb(io, 0);\n\n}\n", + "output": "0", + "index": 25033 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static av_cold int png_dec_init(AVCodecContext *avctx)\n\n{\n\n PNGDecContext *s = avctx->priv_data;\n\n\n\n s->avctx = avctx;\n\n s->previous_picture.f = av_frame_alloc();\n\n s->last_picture.f = av_frame_alloc();\n\n s->picture.f = av_frame_alloc();\n\n if (!s->previous_picture.f || !s->last_picture.f || !s->picture.f)\n\n return AVERROR(ENOMEM);\n\n\n\n if (!avctx->internal->is_copy) {\n\n avctx->internal->allocate_progress = 1;\n\n ff_pngdsp_init(&s->dsp);\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "1", + "index": 6668 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp)\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_eof(ioc, buf, sizeof(buf), errp);\n\n if (ret <= 0) {\n\n return ret;\n\n }\n\n\n\n if (ret != sizeof(buf)) {\n\n error_setg(errp, \"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 error_setg(errp, \"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 error_setg(errp, \"invalid magic (got 0x%\" PRIx32 \")\", magic);\n\n return -EINVAL;\n\n }\n\n return sizeof(buf);\n\n}\n", + "output": "0", + "index": 2643 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int rtp_set_remote_url(URLContext *h, const char *uri)\n\n{\n\n RTPContext *s = h->priv_data;\n\n char hostname[256];\n\n int port;\n\n\n\n char buf[1024];\n\n char path[1024];\n\n \n\n url_split(NULL, 0, hostname, sizeof(hostname), &port, \n\n path, sizeof(path), uri);\n\n\n\n snprintf(buf, sizeof(buf), \"udp://%s:%d%s\", hostname, port, path);\n\n udp_set_remote_url(s->rtp_hd, buf);\n\n\n\n snprintf(buf, sizeof(buf), \"udp://%s:%d%s\", hostname, port + 1, path);\n\n udp_set_remote_url(s->rtcp_hd, buf);\n\n return 0;\n\n}\n", + "output": "0", + "index": 4303 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_tlbie(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 || !ctx->hv)) {\n\n gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n return;\n\n }\n\n if (NARROW_MODE(ctx)) {\n\n TCGv t0 = tcg_temp_new();\n\n tcg_gen_ext32u_tl(t0, cpu_gpr[rB(ctx->opcode)]);\n\n gen_helper_tlbie(cpu_env, t0);\n\n tcg_temp_free(t0);\n\n } else {\n\n gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);\n\n }\n\n#endif\n\n}\n", + "output": "1", + "index": 19615 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "int cpu_get_dump_info(ArchDumpInfo *info,\n\n const GuestPhysBlockList *guest_phys_blocks)\n\n{\n\n bool lma = false;\n\n GuestPhysBlock *block;\n\n\n\n#ifdef TARGET_X86_64\n\n X86CPU *first_x86_cpu = X86_CPU(first_cpu);\n\n\n\n lma = !!(first_x86_cpu->env.hflags & HF_LMA_MASK);\n\n#endif\n\n\n\n if (lma) {\n\n info->d_machine = EM_X86_64;\n\n } else {\n\n info->d_machine = EM_386;\n\n }\n\n info->d_endian = ELFDATA2LSB;\n\n\n\n if (lma) {\n\n info->d_class = ELFCLASS64;\n\n } else {\n\n info->d_class = ELFCLASS32;\n\n\n\n QTAILQ_FOREACH(block, &guest_phys_blocks->head, next) {\n\n if (block->target_end > UINT_MAX) {\n\n /* The memory size is greater than 4G */\n\n info->d_class = ELFCLASS64;\n\n break;\n\n }\n\n }\n\n }\n\n\n\n return 0;\n\n}\n", + "output": "0", + "index": 21491 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void uhci_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 UHCIPCIDeviceClass *u = container_of(k, UHCIPCIDeviceClass, parent_class);\n\n UHCIInfo *info = data;\n\n\n\n k->init = info->initfn ? info->initfn : usb_uhci_common_initfn;\n\n k->exit = info->unplug ? usb_uhci_exit : NULL;\n\n k->vendor_id = info->vendor_id;\n\n k->device_id = info->device_id;\n\n k->revision = info->revision;\n\n k->class_id = PCI_CLASS_SERIAL_USB;\n\n\n dc->vmsd = &vmstate_uhci;\n\n dc->props = uhci_properties;\n\n u->info = *info;\n\n}", + "output": "1", + "index": 21058 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void test_visitor_out_list_qapi_free(TestOutputVisitorData *data,\n\n const void *unused)\n\n{\n\n UserDefTwoList *p, *head = NULL;\n\n const char string[] = \"foo bar\";\n\n int i, max_count = 1024;\n\n\n\n for (i = 0; i < max_count; i++) {\n\n p = g_malloc0(sizeof(*p));\n\n p->value = g_malloc0(sizeof(*p->value));\n\n\n\n p->value->string0 = g_strdup(string);\n\n p->value->dict1 = g_new0(UserDefTwoDict, 1);\n\n p->value->dict1->string1 = g_strdup(string);\n\n p->value->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);\n\n p->value->dict1->dict2->userdef = g_new0(UserDefOne, 1);\n\n p->value->dict1->dict2->userdef->string = g_strdup(string);\n\n p->value->dict1->dict2->userdef->integer = 42;\n\n p->value->dict1->dict2->string = g_strdup(string);\n\n p->value->dict1->has_dict3 = false;\n\n\n\n p->next = head;\n\n head = p;\n\n }\n\n\n\n qapi_free_UserDefTwoList(head);\n\n}\n", + "output": "0", + "index": 26895 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "QEMUFile *qemu_popen_cmd(const char *command, const char *mode)\n\n{\n\n FILE *stdio_file;\n\n QEMUFileStdio *s;\n\n\n\n stdio_file = popen(command, mode);\n\n if (stdio_file == NULL) {\n\n return NULL;\n\n }\n\n\n\n if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {\n\n fprintf(stderr, \"qemu_popen: Argument validity check failed\\n\");\n\n return NULL;\n\n }\n\n\n\n s = g_malloc0(sizeof(QEMUFileStdio));\n\n\n\n s->stdio_file = stdio_file;\n\n\n\n if(mode[0] == 'r') {\n\n s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops);\n\n } else {\n\n s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops);\n\n }\n\n return s->file;\n\n}\n", + "output": "0", + "index": 16789 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static void gen_stx(DisasContext *dc, uint32_t code, uint32_t flags)\n\n{\n\n I_TYPE(instr, code);\n\n TCGv val = load_gpr(dc, instr.b);\n\n\n\n TCGv addr = tcg_temp_new();\n\n tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);\n\n tcg_gen_qemu_st_tl(val, addr, dc->mem_idx, flags);\n\n tcg_temp_free(addr);\n\n}\n", + "output": "1", + "index": 19076 + }, + { + "instruction": "Detect whether the following code contains vulnerabilities.", + "input": "static inline void tcg_out_movi_imm32(TCGContext *s, int ret, uint32_t arg)\n\n{\n\n if (check_fit_tl(arg, 12))\n\n tcg_out_movi_imm13(s, ret, arg);\n\n else {\n\n tcg_out_sethi(s, ret, arg);\n\n if (arg & 0x3ff)\n\n tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR);\n\n }\n\n}\n", + "output": "0", + "index": 20062 + } +] \ No newline at end of file