id stringlengths 22 26 | content stringlengths 72 142k |
|---|---|
devign_test_set_data_13149 | static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
{
/* use non-QOM casts in the data path */
VirtIOSCSI *s = (VirtIOSCSI *)vdev;
VirtIOSCSICommon *vs = &s->parent_obj;
VirtIOSCSIReq *req;
int n;
while ((req = virtio_scsi_pop_req(s, vq))) {
SCSIDevice *d;
int out_size, in_size;
if (req->elem.out_num < 1 || req->elem.in_num < 1) {
virtio_scsi_bad_req();
}
out_size = req->elem.out_sg[0].iov_len;
in_size = req->elem.in_sg[0].iov_len;
if (out_size < sizeof(VirtIOSCSICmdReq) + vs->cdb_size ||
in_size < sizeof(VirtIOSCSICmdResp) + vs->sense_size) {
virtio_scsi_bad_req();
}
if (req->elem.out_num > 1 && req->elem.in_num > 1) {
virtio_scsi_fail_cmd_req(req);
continue;
}
d = virtio_scsi_device_find(s, req->req.cmd->lun);
if (!d) {
req->resp.cmd->response = VIRTIO_SCSI_S_BAD_TARGET;
virtio_scsi_complete_req(req);
continue;
}
req->sreq = scsi_req_new(d, req->req.cmd->tag,
virtio_scsi_get_lun(req->req.cmd->lun),
req->req.cmd->cdb, req);
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
int req_mode =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
if (req->sreq->cmd.mode != req_mode ||
req->sreq->cmd.xfer > req->qsgl.size) {
req->resp.cmd->response = VIRTIO_SCSI_S_OVERRUN;
virtio_scsi_complete_req(req);
continue;
}
}
n = scsi_req_enqueue(req->sreq);
if (n) {
scsi_req_continue(req->sreq);
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13154 | CharDriverState *text_console_init(QemuOpts *opts)
{
CharDriverState *chr;
QemuConsole *s;
unsigned width;
unsigned height;
chr = g_malloc0(sizeof(CharDriverState));
width = qemu_opt_get_number(opts, "width", 0);
if (width == 0)
width = qemu_opt_get_number(opts, "cols", 0) * FONT_WIDTH;
height = qemu_opt_get_number(opts, "height", 0);
if (height == 0)
height = qemu_opt_get_number(opts, "rows", 0) * FONT_HEIGHT;
if (width == 0 || height == 0) {
s = new_console(NULL, TEXT_CONSOLE);
} else {
s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE);
}
if (!s) {
g_free(chr);
return NULL;
}
s->chr = chr;
s->g_width = width;
s->g_height = height;
chr->opaque = s;
chr->chr_set_echo = text_console_set_echo;
return chr;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13155 | static uint64_t eepro100_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
EEPRO100State *s = opaque;
switch (size) {
case 1: return eepro100_read1(s, addr);
case 2: return eepro100_read2(s, addr);
case 4: return eepro100_read4(s, addr);
default: abort();
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13156 | bool vring_should_notify(VirtIODevice *vdev, Vring *vring)
{
uint16_t old, new;
bool v;
/* Flush out used index updates. This is paired
* with the barrier that the Guest executes when enabling
* interrupts. */
smp_mb();
if ((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) &&
unlikely(!vring_more_avail(vdev, vring))) {
return true;
}
if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
return !(vring_get_avail_flags(vdev, vring) &
VRING_AVAIL_F_NO_INTERRUPT);
}
old = vring->signalled_used;
v = vring->signalled_used_valid;
new = vring->signalled_used = vring->last_used_idx;
vring->signalled_used_valid = true;
if (unlikely(!v)) {
return true;
}
return vring_need_event(vring_used_event(&vring->vr), new, old);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13163 | static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
AMRContext *s = avctx->priv_data;
int written, ret;
int16_t *flush_buf = NULL;
const int16_t *samples = frame ? (const int16_t *)frame->data[0] : NULL;
if (s->enc_bitrate != avctx->bit_rate) {
s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);
s->enc_bitrate = avctx->bit_rate;
}
if ((ret = ff_alloc_packet(avpkt, 32))) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
return ret;
}
if (frame) {
if (frame->nb_samples < avctx->frame_size) {
flush_buf = av_mallocz(avctx->frame_size * sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
memcpy(flush_buf, samples, frame->nb_samples * sizeof(*flush_buf));
samples = flush_buf;
if (frame->nb_samples < avctx->frame_size - avctx->delay)
s->enc_last_frame = -1;
}
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) {
av_freep(&flush_buf);
return ret;
}
} else {
if (s->enc_last_frame < 0)
return 0;
flush_buf = av_mallocz(avctx->frame_size * sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
samples = flush_buf;
s->enc_last_frame = -1;
}
written = Encoder_Interface_Encode(s->enc_state, s->enc_mode, samples,
avpkt->data, 0);
av_dlog(avctx, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",
written, s->enc_mode, frame[0]);
/* Get the next frame pts/duration */
ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
&avpkt->duration);
avpkt->size = written;
*got_packet_ptr = 1;
av_freep(&flush_buf);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13172 | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
int is_asi, int size)
{
CPUState *saved_env;
/* XXX: hack to restore env in all cases, even if not called from
generated code */
saved_env = env;
env = cpu_single_env;
qemu_log("Unassigned " TARGET_FMT_plx " wr=%d exe=%d\n",
addr, is_write, is_exec);
if (!(env->sregs[SR_MSR] & MSR_EE)) {
return;
}
if (is_exec) {
if (!(env->pvr.regs[2] & PVR2_IOPB_BUS_EXC_MASK)) {
env->sregs[SR_ESR] = ESR_EC_INSN_BUS;
helper_raise_exception(EXCP_HW_EXCP);
}
} else {
if (!(env->pvr.regs[2] & PVR2_DOPB_BUS_EXC_MASK)) {
env->sregs[SR_ESR] = ESR_EC_DATA_BUS;
helper_raise_exception(EXCP_HW_EXCP);
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13204 | static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
/* load a few things into local vars to make the code more readable? and faster */
const int srcW= c->srcW;
const int dstW= c->dstW;
const int dstH= c->dstH;
const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc;
const int dstFormat= c->dstFormat;
const int srcFormat= c->srcFormat;
const int flags= c->flags;
const int canMMX2BeUsed= c->canMMX2BeUsed;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *hLumFilterPos= c->hLumFilterPos;
int16_t *hChrFilterPos= c->hChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int hLumFilterSize= c->hLumFilterSize;
const int hChrFilterSize= c->hChrFilterSize;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrPixBuf= c->chrPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
uint8_t *funnyYCode= c->funnyYCode;
uint8_t *funnyUVCode= c->funnyUVCode;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
uint8_t *pal=NULL;
/* vars whch will change and which we need to storw back in the context */
int dstY= c->dstY;
int lumBufIndex= c->lumBufIndex;
int chrBufIndex= c->chrBufIndex;
int lastInLumBuf= c->lastInLumBuf;
int lastInChrBuf= c->lastInChrBuf;
if(isPacked(c->srcFormat)){
pal= src[1];
src[0]=
src[1]=
src[2]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
// printf("swscale %X %X %X -> %X %X %X\n", (int)src[0], (int)src[1], (int)src[2],
// (int)dst[0], (int)dst[1], (int)dst[2]);
#if 0 //self test FIXME move to a vfilter or something
{
static volatile int i=0;
i++;
if(srcFormat==PIX_FMT_YUV420P && i==1 && srcSliceH>= c->srcH)
selfTest(src, srcStride, c->srcW, c->srcH);
i--;
}
#endif
//printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2],
//dstStride[0],dstStride[1],dstStride[2]);
if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)
{
static int firstTime=1; //FIXME move this into the context perhaps
if(flags & SWS_PRINT_INFO && firstTime)
{
av_log(c, AV_LOG_WARNING, "SwScaler: Warning: dstStride is not aligned!\n"
"SwScaler: ->cannot do aligned memory acesses anymore\n");
firstTime=0;
}
}
/* Note the user might start scaling the picture in the middle so this will not get executed
this is not really intended but works currently, so ppl might do it */
if(srcSliceY ==0){
lumBufIndex=0;
chrBufIndex=0;
dstY=0;
lastInLumBuf= -1;
lastInChrBuf= -1;
}
lastDstY= dstY;
for(;dstY < dstH; dstY++){
unsigned char *dest =dst[0]+dstStride[0]*dstY;
const int chrDstY= dstY>>c->chrDstVSubSample;
unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
//printf("dstY:%d dstH:%d firstLumSrcY:%d lastInLumBuf:%d vLumBufSize: %d vChrBufSize: %d slice: %d %d vLumFilterSize: %d firstChrSrcY: %d vChrFilterSize: %d c->chrSrcVSubSample: %d\n",
// dstY, dstH, firstLumSrcY, lastInLumBuf, vLumBufSize, vChrBufSize, srcSliceY, srcSliceH, vLumFilterSize, firstChrSrcY, vChrFilterSize, c->chrSrcVSubSample);
//handle holes (FAST_BILINEAR & weird filters)
if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
//printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize);
ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
// Do we have enough lines in this slice to output the dstY line
if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample))
{
//Do horizontal scaling
while(lastInLumBuf < lastLumSrcY)
{
uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
lumBufIndex++;
// printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY);
ASSERT(lumBufIndex < 2*vLumBufSize)
ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
// printf("%d %d\n", lumBufIndex, vLumBufSize);
RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
funnyYCode, c->srcFormat, formatConvBuffer,
c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
lastInLumBuf++;
}
while(lastInChrBuf < lastChrSrcY)
{
uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++;
ASSERT(chrBufIndex < 2*vChrBufSize)
ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH))
ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
//FIXME replace parameters through context struct (some at least)
if(!(isGray(srcFormat) || isGray(dstFormat)))
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
funnyUVCode, c->srcFormat, formatConvBuffer,
c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
lastInChrBuf++;
}
//wrap buf index around to stay inside the ring buffer
if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
}
else // not enough lines left in this slice -> load the rest in the buffer
{
/* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
vChrBufSize, vLumBufSize);*/
//Do horizontal scaling
while(lastInLumBuf+1 < srcSliceY + srcSliceH)
{
uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
lumBufIndex++;
ASSERT(lumBufIndex < 2*vLumBufSize)
ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
funnyYCode, c->srcFormat, formatConvBuffer,
c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
lastInLumBuf++;
}
while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
{
uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++;
ASSERT(chrBufIndex < 2*vChrBufSize)
ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH)
ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
if(!(isGray(srcFormat) || isGray(dstFormat)))
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
funnyUVCode, c->srcFormat, formatConvBuffer,
c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
lastInChrBuf++;
}
//wrap buf index around to stay inside the ring buffer
if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
break; //we can't output a dstY line so let's try with the next slice
}
#ifdef HAVE_MMX
b5Dither= dither8[dstY&1];
g6Dither= dither4[dstY&1];
g5Dither= dither8[dstY&1];
r5Dither= dither8[(dstY+1)&1];
#endif
if(dstY < dstH-2)
{
int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
#ifdef HAVE_MMX
int i;
if(flags & SWS_ACCURATE_RND){
for(i=0; i<vLumFilterSize; i+=2){
lumMmxFilter[2*i+0]= (int32_t)lumSrcPtr[i ];
lumMmxFilter[2*i+1]= (int32_t)lumSrcPtr[i+(vLumFilterSize>1)];
lumMmxFilter[2*i+2]=
lumMmxFilter[2*i+3]= vLumFilter[dstY*vLumFilterSize + i ]
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
}
for(i=0; i<vChrFilterSize; i+=2){
chrMmxFilter[2*i+0]= (int32_t)chrSrcPtr[i ];
chrMmxFilter[2*i+1]= (int32_t)chrSrcPtr[i+(vChrFilterSize>1)];
chrMmxFilter[2*i+2]=
chrMmxFilter[2*i+3]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
}
}else{
for(i=0; i<vLumFilterSize; i++)
{
lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i];
lumMmxFilter[4*i+1]= (uint64_t)lumSrcPtr[i] >> 32;
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
}
for(i=0; i<vChrFilterSize; i++)
{
chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i];
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
}
#endif
if(dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
RENAME(yuv2nv12X)(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like
{
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12
{
int16_t *lumBuf = lumPixBuf[0];
int16_t *chrBuf= chrPixBuf[0];
RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW);
}
else //General YV12
{
RENAME(yuv2yuvX)(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
}
}
else
{
ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB
{
int chrAlpha= vChrFilter[2*dstY+1];
RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
dest, dstW, chrAlpha, dstFormat, flags, dstY);
}
else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB
{
int lumAlpha= vLumFilter[2*dstY+1];
int chrAlpha= vChrFilter[2*dstY+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
dest, dstW, lumAlpha, chrAlpha, dstY);
}
else //General RGB
{
RENAME(yuv2packedX)(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, dstW, dstY);
}
}
}
else // hmm looks like we can't use MMX here without overwriting this array's tail
{
int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
if(dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
yuv2nv12XinC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12
{
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
yuv2yuvXinC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
}
else
{
ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
yuv2packedXinC(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, dstW, dstY);
}
}
}
#ifdef HAVE_MMX
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
/* store changed local vars back in the context */
c->dstY= dstY;
c->lumBufIndex= lumBufIndex;
c->chrBufIndex= chrBufIndex;
c->lastInLumBuf= lastInLumBuf;
c->lastInChrBuf= lastInChrBuf;
return dstY - lastDstY;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13205 | static inline void RENAME(bgr24ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_BGR24);
#else
int i;
for (i=0; i<width; i++) {
int b= src[i*3+0];
int g= src[i*3+1];
int r= src[i*3+2];
dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
}
#endif /* COMPILE_TEMPLATE_MMX */
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13230 | void FUNC(ff_simple_idct)(DCTELEM *block)
{
int i;
for (i = 0; i < 8; i++)
FUNC(idctRowCondDC)(block + i*8);
for (i = 0; i < 8; i++)
FUNC(idctSparseCol)(block + i);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13236 | static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev)
{
if (ohci->async_td &&
ohci->usb_packet.owner != NULL &&
ohci->usb_packet.owner->dev == dev) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13268 | static int av_encode(AVFormatContext **output_files,
int nb_output_files,
AVFormatContext **input_files,
int nb_input_files,
AVStreamMap *stream_maps, int nb_stream_maps)
{
int ret, i, j, k, n, nb_istreams = 0, nb_ostreams = 0;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
AVOutputStream *ost, **ost_table = NULL;
AVInputStream *ist, **ist_table = NULL;
AVInputFile *file_table;
AVFormatContext *stream_no_data;
int key;
file_table= (AVInputFile*) av_mallocz(nb_input_files * sizeof(AVInputFile));
if (!file_table)
goto fail;
/* input stream init */
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
file_table[i].ist_index = j;
file_table[i].nb_streams = is->nb_streams;
j += is->nb_streams;
}
nb_istreams = j;
ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *));
if (!ist_table)
goto fail;
for(i=0;i<nb_istreams;i++) {
ist = av_mallocz(sizeof(AVInputStream));
if (!ist)
goto fail;
ist_table[i] = ist;
}
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
for(k=0;k<is->nb_streams;k++) {
ist = ist_table[j++];
ist->st = is->streams[k];
ist->file_index = i;
ist->index = k;
ist->discard = 1; /* the stream is discarded by default
(changed later) */
if (ist->st->codec.rate_emu) {
ist->start = av_gettime();
ist->frame = 0;
}
}
}
/* output stream init */
nb_ostreams = 0;
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
nb_ostreams += os->nb_streams;
}
if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) {
fprintf(stderr, "Number of stream maps must match number of output streams\n");
exit(1);
}
/* Sanity check the mapping args -- do the input files & streams exist? */
for(i=0;i<nb_stream_maps;i++) {
int fi = stream_maps[i].file_index;
int si = stream_maps[i].stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si);
exit(1);
}
}
ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams);
if (!ost_table)
goto fail;
for(i=0;i<nb_ostreams;i++) {
ost = av_mallocz(sizeof(AVOutputStream));
if (!ost)
goto fail;
ost_table[i] = ost;
}
n = 0;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++) {
int found;
ost = ost_table[n++];
ost->file_index = k;
ost->index = i;
ost->st = os->streams[i];
if (nb_stream_maps > 0) {
ost->source_index = file_table[stream_maps[n-1].file_index].ist_index +
stream_maps[n-1].stream_index;
/* Sanity check that the stream types match */
if (ist_table[ost->source_index]->st->codec.codec_type != ost->st->codec.codec_type) {
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
stream_maps[n-1].file_index, stream_maps[n-1].stream_index,
ost->file_index, ost->index);
exit(1);
}
} else {
/* get corresponding input stream index : we select the first one with the right type */
found = 0;
for(j=0;j<nb_istreams;j++) {
ist = ist_table[j];
if (ist->discard &&
ist->st->codec.codec_type == ost->st->codec.codec_type) {
ost->source_index = j;
found = 1;
}
}
if (!found) {
/* try again and reuse existing stream */
for(j=0;j<nb_istreams;j++) {
ist = ist_table[j];
if (ist->st->codec.codec_type == ost->st->codec.codec_type) {
ost->source_index = j;
found = 1;
}
}
if (!found) {
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n",
ost->file_index, ost->index);
exit(1);
}
}
}
ist = ist_table[ost->source_index];
ist->discard = 0;
}
}
/* for each output stream, we compute the right encoding parameters */
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
ist = ist_table[ost->source_index];
codec = &ost->st->codec;
icodec = &ist->st->codec;
if (ost->st->stream_copy) {
/* if stream_copy is selected, no need to decode or encode */
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
codec->codec_tag = icodec->codec_tag;
codec->bit_rate = icodec->bit_rate;
switch(codec->codec_type) {
case CODEC_TYPE_AUDIO:
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
break;
case CODEC_TYPE_VIDEO:
codec->frame_rate = icodec->frame_rate;
codec->frame_rate_base = icodec->frame_rate_base;
codec->width = icodec->width;
codec->height = icodec->height;
break;
default:
av_abort();
}
} else {
switch(codec->codec_type) {
case CODEC_TYPE_AUDIO:
if (fifo_init(&ost->fifo, 2 * MAX_AUDIO_PACKET_SIZE))
goto fail;
if (codec->channels == icodec->channels &&
codec->sample_rate == icodec->sample_rate) {
ost->audio_resample = 0;
} else {
if (codec->channels != icodec->channels &&
icodec->codec_id == CODEC_ID_AC3) {
/* Special case for 5:1 AC3 input */
/* and mono or stereo output */
/* Request specific number of channels */
icodec->channels = codec->channels;
if (codec->sample_rate == icodec->sample_rate)
ost->audio_resample = 0;
else {
ost->audio_resample = 1;
ost->resample = audio_resample_init(codec->channels, icodec->channels,
codec->sample_rate,
icodec->sample_rate);
if(!ost->resample)
{
printf("Can't resample. Aborting.\n");
av_abort();
}
}
/* Request specific number of channels */
icodec->channels = codec->channels;
} else {
ost->audio_resample = 1;
ost->resample = audio_resample_init(codec->channels, icodec->channels,
codec->sample_rate,
icodec->sample_rate);
if(!ost->resample)
{
printf("Can't resample. Aborting.\n");
av_abort();
}
}
}
ist->decoding_needed = 1;
ost->encoding_needed = 1;
break;
case CODEC_TYPE_VIDEO:
if (codec->width == icodec->width &&
codec->height == icodec->height &&
frame_topBand == 0 &&
frame_bottomBand == 0 &&
frame_leftBand == 0 &&
frame_rightBand == 0)
{
ost->video_resample = 0;
ost->video_crop = 0;
} else if ((codec->width == icodec->width -
(frame_leftBand + frame_rightBand)) &&
(codec->height == icodec->height -
(frame_topBand + frame_bottomBand)))
{
ost->video_resample = 0;
ost->video_crop = 1;
ost->topBand = frame_topBand;
ost->leftBand = frame_leftBand;
} else {
uint8_t *buf;
ost->video_resample = 1;
ost->video_crop = 0; // cropping is handled as part of resample
buf = av_malloc((codec->width * codec->height * 3) / 2);
if (!buf)
goto fail;
ost->pict_tmp.data[0] = buf;
ost->pict_tmp.data[1] = ost->pict_tmp.data[0] + (codec->width * codec->height);
ost->pict_tmp.data[2] = ost->pict_tmp.data[1] + (codec->width * codec->height) / 4;
ost->pict_tmp.linesize[0] = codec->width;
ost->pict_tmp.linesize[1] = codec->width / 2;
ost->pict_tmp.linesize[2] = codec->width / 2;
ost->img_resample_ctx = img_resample_full_init(
ost->st->codec.width, ost->st->codec.height,
ist->st->codec.width, ist->st->codec.height,
frame_topBand, frame_bottomBand,
frame_leftBand, frame_rightBand);
}
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
av_abort();
}
/* two pass mode */
if (ost->encoding_needed &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
int size;
char *logbuffer;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename ?
pass_logfilename : DEFAULT_PASS_LOGFILENAME, i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "w");
if (!f) {
perror(logfilename);
exit(1);
}
ost->logfile = f;
} else {
/* read the log file */
f = fopen(logfilename, "r");
if (!f) {
perror(logfilename);
exit(1);
}
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);
logbuffer = av_malloc(size + 1);
if (!logbuffer) {
fprintf(stderr, "Could not allocate log buffer\n");
exit(1);
}
fread(logbuffer, 1, size, f);
fclose(f);
logbuffer[size] = '\0';
codec->stats_in = logbuffer;
}
}
}
}
/* dump the file output parameters - cannot be done before in case
of stream copy */
for(i=0;i<nb_output_files;i++) {
dump_format(output_files[i], i, output_files[i]->filename, 1);
}
/* dump the stream mapping */
fprintf(stderr, "Stream mapping:\n");
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d\n",
ist_table[ost->source_index]->file_index,
ist_table[ost->source_index]->index,
ost->file_index,
ost->index);
}
/* open each encoder */
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
AVCodec *codec;
codec = avcodec_find_encoder(ost->st->codec.codec_id);
if (!codec) {
fprintf(stderr, "Unsupported codec for output stream #%d.%d\n",
ost->file_index, ost->index);
exit(1);
}
if (avcodec_open(&ost->st->codec, codec) < 0) {
fprintf(stderr, "Error while opening codec for stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\n",
ost->file_index, ost->index);
exit(1);
}
}
}
/* open each decoder */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
AVCodec *codec;
codec = avcodec_find_decoder(ist->st->codec.codec_id);
if (!codec) {
fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n",
ist->st->codec.codec_id, ist->file_index, ist->index);
exit(1);
}
if (avcodec_open(&ist->st->codec, codec) < 0) {
fprintf(stderr, "Error while opening codec for input stream #%d.%d\n",
ist->file_index, ist->index);
exit(1);
}
//if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO)
// ist->st->codec.flags |= CODEC_FLAG_REPEAT_FIELD;
ist->frame_decoded = 1;
}
}
/* init pts */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
is = input_files[ist->file_index];
ist->pts = 0;
if (ist->decoding_needed) {
switch (ist->st->codec.codec_type) {
case CODEC_TYPE_AUDIO:
av_frac_init(&ist->next_pts,
0, 0, is->pts_num * ist->st->codec.sample_rate);
break;
case CODEC_TYPE_VIDEO:
av_frac_init(&ist->next_pts,
0, 0, is->pts_num * ist->st->codec.frame_rate);
break;
default:
break;
}
}
}
/* compute buffer size max (should use a complete heuristic) */
for(i=0;i<nb_input_files;i++) {
file_table[i].buffer_size_max = 2048;
}
/* open files and write file headers */
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (av_write_header(os) < 0) {
fprintf(stderr, "Could not write header for output file #%d (incorrect codec paramters ?)\n", i);
ret = -EINVAL;
goto fail;
}
}
#ifndef CONFIG_WIN32
if ( !using_stdin )
fprintf(stderr, "Press [q] to stop encoding\n");
#endif
term_init();
stream_no_data = 0;
key = -1;
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
uint8_t *ptr;
int len;
uint8_t *data_buf;
int data_size, got_picture;
AVPicture picture;
short samples[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2];
void *buffer_to_free;
double pts_min;
redo:
/* if 'q' pressed, exits */
if (!using_stdin) {
/* read_key() returns 0 on EOF */
key = read_key();
if (key == 'q')
break;
}
/* select the stream that we must read now by looking at the
smallest output pts */
file_index = -1;
pts_min = 1e10;
for(i=0;i<nb_ostreams;i++) {
double pts;
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
pts = (double)ost->st->pts.val * os->pts_num / os->pts_den;
if (!file_table[ist->file_index].eof_reached &&
pts < pts_min) {
pts_min = pts;
file_index = ist->file_index;
}
}
/* if none, if is finished */
if (file_index < 0) {
break;
}
/* finish if recording time exhausted */
if (recording_time > 0 && pts_min >= (recording_time / 1000000.0))
break;
/* read a packet from it and output it in the fifo */
is = input_files[file_index];
if (av_read_packet(is, &pkt) < 0) {
file_table[file_index].eof_reached = 1;
continue;
}
if (!pkt.size) {
stream_no_data = is;
} else {
stream_no_data = 0;
}
if (do_hex_dump) {
printf("stream #%d, size=%d:\n", pkt.stream_index, pkt.size);
av_hex_dump(pkt.data, pkt.size);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
if (pkt.stream_index >= file_table[file_index].nb_streams)
goto discard_packet;
ist_index = file_table[file_index].ist_index + pkt.stream_index;
ist = ist_table[ist_index];
if (ist->discard)
goto discard_packet;
// printf("read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);
len = pkt.size;
ptr = pkt.data;
while (len > 0) {
/* decode the packet if needed */
data_buf = NULL; /* fail safe */
data_size = 0;
if (ist->decoding_needed) {
/* NOTE1: we only take into account the PTS if a new
frame has begun (MPEG semantics) */
/* NOTE2: even if the fraction is not initialized,
av_frac_set can be used to set the integer part */
if (ist->frame_decoded) {
/* If pts is unavailable -- we have to use synthetic one */
if( pkt.pts != AV_NOPTS_VALUE )
{
ist->pts = ist->next_pts.val = pkt.pts;
}
else
{
ist->pts = ist->next_pts.val;
}
ist->frame_decoded = 0;
}
switch(ist->st->codec.codec_type) {
case CODEC_TYPE_AUDIO:
/* XXX: could avoid copy if PCM 16 bits with same
endianness as CPU */
ret = avcodec_decode_audio(&ist->st->codec, samples, &data_size,
ptr, len);
if (ret < 0)
goto fail_decode;
/* Some bug in mpeg audio decoder gives */
/* data_size < 0, it seems they are overflows */
if (data_size <= 0) {
/* no audio frame */
ptr += ret;
len -= ret;
continue;
}
data_buf = (uint8_t *)samples;
av_frac_add(&ist->next_pts,
is->pts_den * data_size / (2 * ist->st->codec.channels));
break;
case CODEC_TYPE_VIDEO:
{
AVFrame big_picture;
data_size = (ist->st->codec.width * ist->st->codec.height * 3) / 2;
ret = avcodec_decode_video(&ist->st->codec,
&big_picture, &got_picture, ptr, len);
picture= *(AVPicture*)&big_picture;
ist->st->quality= big_picture.quality;
if (ret < 0) {
fail_decode:
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->index);
av_free_packet(&pkt);
goto redo;
}
if (!got_picture) {
/* no picture yet */
ptr += ret;
len -= ret;
continue;
}
av_frac_add(&ist->next_pts,
is->pts_den * ist->st->codec.frame_rate_base);
}
break;
default:
goto fail_decode;
}
} else {
data_buf = ptr;
data_size = len;
ret = len;
}
ptr += ret;
len -= ret;
buffer_to_free = 0;
if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO) {
pre_process_video_frame(ist, &picture, &buffer_to_free);
}
ist->frame_decoded = 1;
/* frame rate emulation */
if (ist->st->codec.rate_emu) {
int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec.frame_rate_base, 1000000, ist->st->codec.frame_rate);
int64_t now = av_gettime() - ist->start;
if (pts > now)
usleep(pts - now);
ist->frame++;
}
#if 0
/* mpeg PTS deordering : if it is a P or I frame, the PTS
is the one of the next displayed one */
/* XXX: add mpeg4 too ? */
if (ist->st->codec.codec_id == CODEC_ID_MPEG1VIDEO) {
if (ist->st->codec.pict_type != B_TYPE) {
int64_t tmp;
tmp = ist->last_ip_pts;
ist->last_ip_pts = ist->frac_pts.val;
ist->frac_pts.val = tmp;
}
}
#endif
/* transcode raw format, encode packets and output them */
for(i=0;i<nb_ostreams;i++) {
int frame_size;
ost = ost_table[i];
if (ost->source_index == ist_index) {
os = output_files[ost->file_index];
#if 0
printf("%d: got pts=%f %f\n", i, pkt.pts / 90000.0,
(ist->pts - ost->st->pts.val) / 90000.0);
#endif
/* set the input output pts pairs */
ost->sync_ipts = (double)ist->pts * is->pts_num /
is->pts_den;
/* XXX: take into account the various fifos,
in particular for audio */
ost->sync_opts = ost->st->pts.val;
//printf("ipts=%lld sync_ipts=%f sync_opts=%lld pts.val=%lld pkt.pts=%lld\n", ist->pts, ost->sync_ipts, ost->sync_opts, ost->st->pts.val, pkt.pts);
if (ost->encoding_needed) {
switch(ost->st->codec.codec_type) {
case CODEC_TYPE_AUDIO:
do_audio_out(os, ost, ist, data_buf, data_size);
break;
case CODEC_TYPE_VIDEO:
/* find an audio stream for synchro */
{
int i;
AVOutputStream *audio_sync, *ost1;
audio_sync = NULL;
for(i=0;i<nb_ostreams;i++) {
ost1 = ost_table[i];
if (ost1->file_index == ost->file_index &&
ost1->st->codec.codec_type == CODEC_TYPE_AUDIO) {
audio_sync = ost1;
break;
}
}
do_video_out(os, ost, ist, &picture, &frame_size, audio_sync);
if (do_vstats && frame_size)
do_video_stats(os, ost, frame_size);
}
break;
default:
av_abort();
}
} else {
AVFrame avframe;
/* no reencoding needed : output the packet directly */
/* force the input stream PTS */
memset(&avframe, 0, sizeof(AVFrame));
ost->st->codec.coded_frame= &avframe;
avframe.key_frame = pkt.flags & PKT_FLAG_KEY;
av_write_frame(os, ost->index, data_buf, data_size);
ost->st->codec.frame_number++;
ost->frame_number++;
}
}
}
av_free(buffer_to_free);
}
discard_packet:
av_free_packet(&pkt);
/* dump report by using the output first video and audio streams */
print_report(output_files, ost_table, nb_ostreams, 0);
}
term_exit();
/* dump report by using the first video and audio streams */
print_report(output_files, ost_table, nb_ostreams, 1);
/* close each encoder */
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec.stats_in);
avcodec_close(&ost->st->codec);
}
}
/* close each decoder */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
avcodec_close(&ist->st->codec);
}
}
/* write the trailer if needed and close file */
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
av_write_trailer(os);
}
/* finished ! */
ret = 0;
fail1:
av_free(file_table);
if (ist_table) {
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
av_free(ist);
}
av_free(ist_table);
}
if (ost_table) {
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost) {
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
fifo_free(&ost->fifo); /* works even if fifo is not
initialized but set to zero */
av_free(ost->pict_tmp.data[0]);
if (ost->video_resample)
img_resample_close(ost->img_resample_ctx);
if (ost->audio_resample)
audio_resample_close(ost->resample);
av_free(ost);
}
}
av_free(ost_table);
}
return ret;
fail:
ret = -ENOMEM;
goto fail1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13273 | int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
int bit_size, int sync_extension)
{
GetBitContext gb;
int specific_config_bitindex;
init_get_bits(&gb, buf, bit_size);
c->object_type = get_object_type(&gb);
c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
c->chan_config = get_bits(&gb, 4);
if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
c->channels = ff_mpeg4audio_channels[c->chan_config];
c->sbr = -1;
c->ps = -1;
if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
// check for W6132 Annex YYYY draft MP3onMP4
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
if (c->object_type == AOT_PS)
c->ps = 1;
c->ext_object_type = AOT_SBR;
c->sbr = 1;
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
c->object_type = get_object_type(&gb);
if (c->object_type == AOT_ER_BSAC)
c->ext_chan_config = get_bits(&gb, 4);
} else {
c->ext_object_type = AOT_NULL;
c->ext_sample_rate = 0;
}
specific_config_bitindex = get_bits_count(&gb);
if (c->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
specific_config_bitindex = get_bits_count(&gb);
if (parse_config_ALS(&gb, c))
return -1;
}
if (c->ext_object_type != AOT_SBR && sync_extension) {
while (get_bits_left(&gb) > 15) {
if (show_bits(&gb, 11) == 0x2b7) { // sync extension
get_bits(&gb, 11);
c->ext_object_type = get_object_type(&gb);
if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1)
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)
c->ps = get_bits1(&gb);
break;
} else
get_bits1(&gb); // skip 1 bit
}
}
//PS requires SBR
if (!c->sbr)
c->ps = 0;
//Limit implicit PS to the HE-AACv2 Profile
if ((c->ps == -1 && c->object_type != AOT_AAC_LC) || c->channels & ~0x01)
c->ps = 0;
return specific_config_bitindex;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13311 | static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_num)
{
MpegEncContext *s = &v->s;
int mb_cbp = v->cbp[s->mb_x - 1 - s->mb_stride],
block_cbp = mb_cbp >> (block_num * 4), right_cbp,
mb_is_intra = v->is_intra[s->mb_x - 1 - s->mb_stride],
block_is_intra = mb_is_intra >> (block_num * 4), right_is_intra;
int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
uint8_t *dst;
if (block_num > 3) {
dst = s->dest[block_num - 3] - 8 * linesize;
} else {
dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 16) * linesize - 8;
}
if (s->mb_x != s->mb_width || !(block_num & 5)) {
int16_t (*mv)[2];
if (block_num > 3) {
right_cbp = v->cbp[s->mb_x - s->mb_stride] >> (block_num * 4);
right_is_intra = v->is_intra[s->mb_x - s->mb_stride] >> (block_num * 4);
mv = &v->luma_mv[s->mb_x - s->mb_stride - 1];
} else {
right_cbp = (block_num & 1) ? (v->cbp[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4))
: (mb_cbp >> ((block_num + 1) * 4));
right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4))
: (mb_is_intra >> ((block_num + 1) * 4));
mv = &s->current_picture.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2];
}
if (block_is_intra & 1 || right_is_intra & 1 || mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1]) {
v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
} else {
idx = ((right_cbp >> 1) | block_cbp) & 5; // FIXME check
if (idx == 5) {
v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
} else if (idx) {
if (idx == 1)
v->vc1dsp.vc1_h_loop_filter4(dst + 4 * linesize, linesize, v->pq);
else
v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq);
}
}
}
dst -= 4;
ttblk = (v->ttblk[s->mb_x - s->mb_stride - 1] >> (block_num * 4)) & 0xf;
if (ttblk == TT_4X4 || ttblk == TT_4X8) {
idx = (block_cbp | (block_cbp >> 1)) & 5;
if (idx == 5) {
v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
} else if (idx) {
if (idx == 1)
v->vc1dsp.vc1_h_loop_filter4(dst + linesize * 4, linesize, v->pq);
else
v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq);
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13316 | static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size, uint8_t **data)
{
AVIOContext *pb = s->pb;
int len;
for(;;) {
len = ffio_read_indirect(pb, buf, TS_PACKET_SIZE, data);
if (len != TS_PACKET_SIZE)
return len < 0 ? len : AVERROR_EOF;
/* check packet sync byte */
if ((*data)[0] != 0x47) {
/* find a new packet start */
avio_seek(pb, -TS_PACKET_SIZE, SEEK_CUR);
if (mpegts_resync(s) < 0)
return AVERROR(EAGAIN);
else
continue;
} else {
break;
}
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13339 | int ff_parse_sample_rate(unsigned *ret, const char *arg, void *log_ctx)
{
char *tail;
double srate = av_strtod(arg, &tail);
if (*tail || srate < 1 || (int)srate != srate) {
av_log(log_ctx, AV_LOG_ERROR, "Invalid sample rate '%s'\n", arg);
return AVERROR(EINVAL);
}
*ret = srate;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13347 | static void decode_abs_store(CPUTriCoreState *env, DisasContext *ctx)
{
int32_t op2;
int32_t r1;
uint32_t address;
TCGv temp;
r1 = MASK_OP_ABS_S1D(ctx->opcode);
address = MASK_OP_ABS_OFF18(ctx->opcode);
op2 = MASK_OP_ABS_OP2(ctx->opcode);
temp = tcg_const_i32(EA_ABS_FORMAT(address));
switch (op2) {
case OPC2_32_ABS_ST_A:
tcg_gen_qemu_st_tl(cpu_gpr_a[r1], temp, ctx->mem_idx, MO_LESL);
break;
case OPC2_32_ABS_ST_D:
gen_st_2regs_64(cpu_gpr_d[r1+1], cpu_gpr_d[r1], temp, ctx);
break;
case OPC2_32_ABS_ST_DA:
gen_st_2regs_64(cpu_gpr_a[r1+1], cpu_gpr_a[r1], temp, ctx);
break;
case OPC2_32_ABS_ST_W:
tcg_gen_qemu_st_tl(cpu_gpr_d[r1], temp, ctx->mem_idx, MO_LESL);
break;
}
tcg_temp_free(temp);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13357 | static void v9fs_readdir(void *opaque)
{
int32_t fid;
V9fsFidState *fidp;
ssize_t retval = 0;
size_t offset = 7;
uint64_t initial_offset;
int32_t count;
uint32_t max_count;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dqd", &fid, &initial_offset, &max_count);
trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
retval = -EINVAL;
goto out_nofid;
}
if (!fidp->fs.dir) {
retval = -EINVAL;
goto out;
}
if (initial_offset == 0) {
v9fs_co_rewinddir(pdu, fidp);
} else {
v9fs_co_seekdir(pdu, fidp, initial_offset);
}
count = v9fs_do_readdir(pdu, fidp, max_count);
if (count < 0) {
retval = count;
goto out;
}
retval = offset;
retval += pdu_marshal(pdu, offset, "d", count);
retval += count;
trace_v9fs_readdir_return(pdu->tag, pdu->id, count, retval);
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(s, pdu, retval);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13363 | uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint32_t cc = 0;
int old_exc = cs->exception_index;
uint64_t asc = env->psw.mask & PSW_MASK_ASC;
uint64_t ret;
int flags;
/* XXX incomplete - has more corner cases */
if (!(env->psw.mask & PSW_MASK_64) && (addr >> 32)) {
program_interrupt(env, PGM_SPECIAL_OP, 2);
}
cs->exception_index = old_exc;
if (mmu_translate(env, addr, 0, asc, &ret, &flags)) {
cc = 3;
}
if (cs->exception_index == EXCP_PGM) {
ret = env->int_pgm_code | 0x80000000;
} else {
ret |= addr & ~TARGET_PAGE_MASK;
}
cs->exception_index = old_exc;
env->cc_op = cc;
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13365 | static int bdrv_check_update_perm(BlockDriverState *bs, uint64_t new_used_perm,
uint64_t new_shared_perm,
BdrvChild *ignore_child, Error **errp)
{
BdrvChild *c;
uint64_t cumulative_perms = new_used_perm;
uint64_t cumulative_shared_perms = new_shared_perm;
/* There is no reason why anyone couldn't tolerate write_unchanged */
assert(new_shared_perm & BLK_PERM_WRITE_UNCHANGED);
QLIST_FOREACH(c, &bs->parents, next_parent) {
if (c == ignore_child) {
continue;
}
if ((new_used_perm & c->shared_perm) != new_used_perm) {
char *user = bdrv_child_user_desc(c);
char *perm_names = bdrv_perm_names(new_used_perm & ~c->shared_perm);
error_setg(errp, "Conflicts with use by %s as '%s', which does not "
"allow '%s' on %s",
user, c->name, perm_names, bdrv_get_node_name(c->bs));
g_free(user);
g_free(perm_names);
return -EPERM;
}
if ((c->perm & new_shared_perm) != c->perm) {
char *user = bdrv_child_user_desc(c);
char *perm_names = bdrv_perm_names(c->perm & ~new_shared_perm);
error_setg(errp, "Conflicts with use by %s as '%s', which uses "
"'%s' on %s",
user, c->name, perm_names, bdrv_get_node_name(c->bs));
g_free(user);
g_free(perm_names);
return -EPERM;
}
cumulative_perms |= c->perm;
cumulative_shared_perms &= c->shared_perm;
}
return bdrv_check_perm(bs, cumulative_perms, cumulative_shared_perms, errp);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13366 | static void monitor_protocol_emitter(Monitor *mon, QObject *data)
{
QDict *qmp;
qmp = qdict_new();
if (!monitor_has_error(mon)) {
/* success response */
if (data) {
assert(qobject_type(data) == QTYPE_QDICT);
qobject_incref(data);
qdict_put_obj(qmp, "return", data);
} else {
/* return an empty QDict by default */
qdict_put(qmp, "return", qdict_new());
}
} else {
/* error response */
qdict_put(mon->error->error, "desc", qerror_human(mon->error));
qdict_put(qmp, "error", mon->error->error);
QINCREF(mon->error->error);
QDECREF(mon->error);
mon->error = NULL;
}
if (mon->mc->id) {
qdict_put_obj(qmp, "id", mon->mc->id);
mon->mc->id = NULL;
}
monitor_json_emitter(mon, QOBJECT(qmp));
QDECREF(qmp);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13388 | static inline int decode_vui_parameters(H264Context *h, SPS *sps)
{
int aspect_ratio_info_present_flag;
unsigned int aspect_ratio_idc;
aspect_ratio_info_present_flag = get_bits1(&h->gb);
if (aspect_ratio_info_present_flag) {
aspect_ratio_idc = get_bits(&h->gb, 8);
if (aspect_ratio_idc == EXTENDED_SAR) {
sps->sar.num = get_bits(&h->gb, 16);
sps->sar.den = get_bits(&h->gb, 16);
} else if (aspect_ratio_idc < FF_ARRAY_ELEMS(pixel_aspect)) {
sps->sar = pixel_aspect[aspect_ratio_idc];
} else {
av_log(h->avctx, AV_LOG_ERROR, "illegal aspect ratio\n");
return AVERROR_INVALIDDATA;
}
} else {
sps->sar.num =
sps->sar.den = 0;
}
if (get_bits1(&h->gb)) /* overscan_info_present_flag */
get_bits1(&h->gb); /* overscan_appropriate_flag */
sps->video_signal_type_present_flag = get_bits1(&h->gb);
if (sps->video_signal_type_present_flag) {
get_bits(&h->gb, 3); /* video_format */
sps->full_range = get_bits1(&h->gb); /* video_full_range_flag */
sps->colour_description_present_flag = get_bits1(&h->gb);
if (sps->colour_description_present_flag) {
sps->color_primaries = get_bits(&h->gb, 8); /* colour_primaries */
sps->color_trc = get_bits(&h->gb, 8); /* transfer_characteristics */
sps->colorspace = get_bits(&h->gb, 8); /* matrix_coefficients */
if (sps->color_primaries >= AVCOL_PRI_NB)
sps->color_primaries = AVCOL_PRI_UNSPECIFIED;
if (sps->color_trc >= AVCOL_TRC_NB)
sps->color_trc = AVCOL_TRC_UNSPECIFIED;
if (sps->colorspace >= AVCOL_SPC_NB)
sps->colorspace = AVCOL_SPC_UNSPECIFIED;
}
}
/* chroma_location_info_present_flag */
if (get_bits1(&h->gb)) {
/* chroma_sample_location_type_top_field */
h->avctx->chroma_sample_location = get_ue_golomb(&h->gb) + 1;
get_ue_golomb(&h->gb); /* chroma_sample_location_type_bottom_field */
}
sps->timing_info_present_flag = get_bits1(&h->gb);
if (sps->timing_info_present_flag) {
sps->num_units_in_tick = get_bits_long(&h->gb, 32);
sps->time_scale = get_bits_long(&h->gb, 32);
if (!sps->num_units_in_tick || !sps->time_scale) {
av_log(h->avctx, AV_LOG_ERROR,
"time_scale/num_units_in_tick invalid or unsupported (%"PRIu32"/%"PRIu32")\n",
sps->time_scale, sps->num_units_in_tick);
return AVERROR_INVALIDDATA;
}
sps->fixed_frame_rate_flag = get_bits1(&h->gb);
}
sps->nal_hrd_parameters_present_flag = get_bits1(&h->gb);
if (sps->nal_hrd_parameters_present_flag)
if (decode_hrd_parameters(h, sps) < 0)
return AVERROR_INVALIDDATA;
sps->vcl_hrd_parameters_present_flag = get_bits1(&h->gb);
if (sps->vcl_hrd_parameters_present_flag)
if (decode_hrd_parameters(h, sps) < 0)
return AVERROR_INVALIDDATA;
if (sps->nal_hrd_parameters_present_flag ||
sps->vcl_hrd_parameters_present_flag)
get_bits1(&h->gb); /* low_delay_hrd_flag */
sps->pic_struct_present_flag = get_bits1(&h->gb);
sps->bitstream_restriction_flag = get_bits1(&h->gb);
if (sps->bitstream_restriction_flag) {
get_bits1(&h->gb); /* motion_vectors_over_pic_boundaries_flag */
get_ue_golomb(&h->gb); /* max_bytes_per_pic_denom */
get_ue_golomb(&h->gb); /* max_bits_per_mb_denom */
get_ue_golomb(&h->gb); /* log2_max_mv_length_horizontal */
get_ue_golomb(&h->gb); /* log2_max_mv_length_vertical */
sps->num_reorder_frames = get_ue_golomb(&h->gb);
get_ue_golomb(&h->gb); /*max_dec_frame_buffering*/
if (get_bits_left(&h->gb) < 0) {
sps->num_reorder_frames = 0;
sps->bitstream_restriction_flag = 0;
}
if (sps->num_reorder_frames > 16U
/* max_dec_frame_buffering || max_dec_frame_buffering > 16 */) {
av_log(h->avctx, AV_LOG_ERROR,
"Clipping illegal num_reorder_frames %d\n",
sps->num_reorder_frames);
sps->num_reorder_frames = 16;
return AVERROR_INVALIDDATA;
}
}
if (get_bits_left(&h->gb) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"Overread VUI by %d bits\n", -get_bits_left(&h->gb));
return AVERROR_INVALIDDATA;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13415 | int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
BlockDriver *drv = bs->drv;
int ret;
if (!drv) {
return -ENOMEDIUM;
}
if (!drv->bdrv_write_compressed) {
return -ENOTSUP;
}
ret = bdrv_check_request(bs, sector_num, nb_sectors);
if (ret < 0) {
return ret;
}
assert(QLIST_EMPTY(&bs->dirty_bitmaps));
return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13426 | static int usb_host_handle_control(USBDevice *dev, USBPacket *p,
int request, int value, int index, int length, uint8_t *data)
{
USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
struct usbdevfs_urb *urb;
AsyncURB *aurb;
int ret;
/*
* Process certain standard device requests.
* These are infrequent and are processed synchronously.
*/
/* Note request is (bRequestType << 8) | bRequest */
trace_usb_host_req_control(s->bus_num, s->addr, request, value, index);
switch (request) {
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
return usb_host_set_address(s, value);
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
return usb_host_set_config(s, value & 0xff);
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
return usb_host_set_interface(s, index, value);
}
/* The rest are asynchronous */
if (length > sizeof(dev->data_buf)) {
fprintf(stderr, "husb: ctrl buffer too small (%d > %zu)\n",
length, sizeof(dev->data_buf));
return USB_RET_STALL;
}
aurb = async_alloc(s);
aurb->packet = p;
/*
* Setup ctrl transfer.
*
* s->ctrl is laid out such that data buffer immediately follows
* 'req' struct which is exactly what usbdevfs expects.
*/
urb = &aurb->urb;
urb->type = USBDEVFS_URB_TYPE_CONTROL;
urb->endpoint = p->devep;
urb->buffer = &dev->setup_buf;
urb->buffer_length = length + 8;
urb->usercontext = s;
trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,
urb->buffer_length, aurb->more);
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
DPRINTF("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
if (ret < 0) {
DPRINTF("husb: submit failed. errno %d\n", errno);
async_free(aurb);
switch(errno) {
case ETIMEDOUT:
return USB_RET_NAK;
case EPIPE:
default:
return USB_RET_STALL;
}
}
return USB_RET_ASYNC;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13429 | static int dshow_read_header(AVFormatContext *avctx)
{
struct dshow_ctx *ctx = avctx->priv_data;
IGraphBuilder *graph = NULL;
ICreateDevEnum *devenum = NULL;
IMediaControl *control = NULL;
IMediaEvent *media_event = NULL;
HANDLE media_event_handle;
HANDLE proc;
int ret = AVERROR(EIO);
int r;
CoInitialize(0);
if (!ctx->list_devices && !parse_device_name(avctx)) {
av_log(avctx, AV_LOG_ERROR, "Malformed dshow input string.\n");
goto error;
}
ctx->video_codec_id = avctx->video_codec_id ? avctx->video_codec_id
: AV_CODEC_ID_RAWVIDEO;
if (ctx->pixel_format != AV_PIX_FMT_NONE) {
if (ctx->video_codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(avctx, AV_LOG_ERROR, "Pixel format may only be set when "
"video codec is not set or set to rawvideo\n");
ret = AVERROR(EINVAL);
goto error;
}
}
if (ctx->framerate) {
r = av_parse_video_rate(&ctx->requested_framerate, ctx->framerate);
if (r < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", ctx->framerate);
goto error;
}
}
r = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
&IID_IGraphBuilder, (void **) &graph);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not create capture graph.\n");
goto error;
}
ctx->graph = graph;
r = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
&IID_ICreateDevEnum, (void **) &devenum);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not enumerate system devices.\n");
goto error;
}
if (ctx->list_devices) {
av_log(avctx, AV_LOG_INFO, "DirectShow video devices\n");
dshow_cycle_devices(avctx, devenum, VideoDevice, NULL);
av_log(avctx, AV_LOG_INFO, "DirectShow audio devices\n");
dshow_cycle_devices(avctx, devenum, AudioDevice, NULL);
ret = AVERROR_EXIT;
goto error;
}
if (ctx->list_options) {
if (ctx->device_name[VideoDevice])
dshow_list_device_options(avctx, devenum, VideoDevice);
if (ctx->device_name[AudioDevice])
dshow_list_device_options(avctx, devenum, AudioDevice);
ret = AVERROR_EXIT;
goto error;
}
if (ctx->device_name[VideoDevice]) {
if ((r = dshow_open_device(avctx, devenum, VideoDevice)) < 0 ||
(r = dshow_add_device(avctx, VideoDevice)) < 0) {
ret = r;
goto error;
}
}
if (ctx->device_name[AudioDevice]) {
if ((r = dshow_open_device(avctx, devenum, AudioDevice)) < 0 ||
(r = dshow_add_device(avctx, AudioDevice)) < 0) {
ret = r;
goto error;
}
}
ctx->mutex = CreateMutex(NULL, 0, NULL);
if (!ctx->mutex) {
av_log(avctx, AV_LOG_ERROR, "Could not create Mutex\n");
goto error;
}
ctx->event[1] = CreateEvent(NULL, 1, 0, NULL);
if (!ctx->event[1]) {
av_log(avctx, AV_LOG_ERROR, "Could not create Event\n");
goto error;
}
r = IGraphBuilder_QueryInterface(graph, &IID_IMediaControl, (void **) &control);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not get media control.\n");
goto error;
}
ctx->control = control;
r = IGraphBuilder_QueryInterface(graph, &IID_IMediaEvent, (void **) &media_event);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not get media event.\n");
goto error;
}
ctx->media_event = media_event;
r = IMediaEvent_GetEventHandle(media_event, (void *) &media_event_handle);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not get media event handle.\n");
goto error;
}
proc = GetCurrentProcess();
r = DuplicateHandle(proc, media_event_handle, proc, &ctx->event[0],
0, 0, DUPLICATE_SAME_ACCESS);
if (!r) {
av_log(avctx, AV_LOG_ERROR, "Could not duplicate media event handle.\n");
goto error;
}
r = IMediaControl_Run(control);
if (r == S_FALSE) {
OAFilterState pfs;
r = IMediaControl_GetState(control, 0, &pfs);
}
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not run filter\n");
goto error;
}
ret = 0;
error:
if (devenum)
ICreateDevEnum_Release(devenum);
if (ret < 0)
dshow_read_close(avctx);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13437 | static inline void s390_machine_initfn(Object *obj)
{
object_property_add_bool(obj, "aes-key-wrap",
machine_get_aes_key_wrap,
machine_set_aes_key_wrap, NULL);
object_property_set_description(obj, "aes-key-wrap",
"enable/disable AES key wrapping using the CPACF wrapping key",
object_property_set_bool(obj, true, "aes-key-wrap", NULL);
object_property_add_bool(obj, "dea-key-wrap",
machine_get_dea_key_wrap,
machine_set_dea_key_wrap, NULL);
object_property_set_description(obj, "dea-key-wrap",
"enable/disable DEA key wrapping using the CPACF wrapping key",
object_property_set_bool(obj, true, "dea-key-wrap", NULL);
object_property_add_str(obj, "loadparm",
machine_get_loadparm, machine_set_loadparm, NULL);
object_property_set_description(obj, "loadparm",
"Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
" to upper case) to pass to machine loader, boot manager,"
" and guest kernel",
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13442 | static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int predictor, int point_transform)
{
int i, mb_x, mb_y;
uint16_t (*buffer)[4];
int left[4], top[4], topleft[4];
const int linesize = s->linesize[0];
const int mask = ((1 << s->bits) - 1) << point_transform;
int resync_mb_y = 0;
int resync_mb_x = 0;
if (s->nb_components != 3 && s->nb_components != 4)
return AVERROR_INVALIDDATA;
if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
return AVERROR_INVALIDDATA;
s->restart_count = s->restart_interval;
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
(unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
buffer = s->ljpeg_buffer;
for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (s->bits - 1);
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
uint8_t *ptr = s->picture_ptr->data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for (i = 0; i < 4; i++)
top[i] = left[i] = topleft[i] = buffer[0][i];
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int modified_predictor = predictor;
if (s->restart_interval && !s->restart_count){
s->restart_count = s->restart_interval;
resync_mb_x = mb_x;
resync_mb_y = mb_y;
for(i=0; i<4; i++)
top[i] = left[i]= topleft[i]= 1 << (s->bits - 1);
}
if (mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || !mb_x)
modified_predictor = 1;
for (i=0;i<nb_components;i++) {
int pred, dc;
topleft[i] = top[i];
top[i] = buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
dc = mjpeg_decode_dc(s, s->dc_index[i]);
if(dc == 0xFFFFF)
return -1;
left[i] = buffer[mb_x][i] =
mask & (pred + (dc << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
}
}
if (s->rct && s->nb_components == 4) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x + 2] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
ptr[4*mb_x + 1] = buffer[mb_x][1] + ptr[4*mb_x + 2];
ptr[4*mb_x + 3] = buffer[mb_x][2] + ptr[4*mb_x + 2];
ptr[4*mb_x + 0] = buffer[mb_x][3];
}
} else if (s->nb_components == 4) {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
if (s->bits <= 8) {
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+3-c] = buffer[mb_x][i];
}
} else if(s->bits == 9) {
return AVERROR_PATCHWELCOME;
} else {
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
((uint16_t*)ptr)[4*mb_x+c] = buffer[mb_x][i];
}
}
}
} else if (s->rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else if (s->pegasus_rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2]) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
if (s->bits <= 8) {
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x+2-c] = buffer[mb_x][i];
}
} else if(s->bits == 9) {
return AVERROR_PATCHWELCOME;
} else {
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
((uint16_t*)ptr)[3*mb_x+2-c] = buffer[mb_x][i];
}
}
}
}
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13448 | static void qemu_spice_display_init_one(QemuConsole *con)
{
SimpleSpiceDisplay *ssd = g_new0(SimpleSpiceDisplay, 1);
qemu_spice_display_init_common(ssd);
ssd->qxl.base.sif = &dpy_interface.base;
qemu_spice_add_display_interface(&ssd->qxl, con);
assert(ssd->worker);
qemu_spice_create_host_memslot(ssd);
ssd->dcl.ops = &display_listener_ops;
ssd->dcl.con = con;
register_displaychangelistener(&ssd->dcl);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13462 | int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
int64_t wanted_timestamp, int flags)
{
int a, b, m;
int64_t timestamp;
a = -1;
b = nb_entries;
// Optimize appending index entries at the end.
if (b && entries[b - 1].timestamp < wanted_timestamp)
a = b - 1;
while (b - a > 1) {
m = (a + b) >> 1;
// Search for the next non-discarded packet.
while ((entries[m].flags & AVINDEX_DISCARD_FRAME) && m < b) {
m++;
if (m == b && entries[m].timestamp >= wanted_timestamp) {
m = b - 1;
break;
}
}
timestamp = entries[m].timestamp;
if (timestamp >= wanted_timestamp)
b = m;
if (timestamp <= wanted_timestamp)
a = m;
}
m = (flags & AVSEEK_FLAG_BACKWARD) ? a : b;
if (!(flags & AVSEEK_FLAG_ANY))
while (m >= 0 && m < nb_entries &&
!(entries[m].flags & AVINDEX_KEYFRAME))
m += (flags & AVSEEK_FLAG_BACKWARD) ? -1 : 1;
if (m == nb_entries)
return -1;
return m;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13468 | static int codec_get_buffer(AVCodecContext *s, AVFrame *frame)
{
InputStream *ist = s->opaque;
FrameBuffer *buf;
int ret, i;
if (!ist->buffer_pool && (ret = alloc_buffer(s, ist, &ist->buffer_pool)) < 0)
return ret;
buf = ist->buffer_pool;
ist->buffer_pool = buf->next;
buf->next = NULL;
if (buf->w != s->width || buf->h != s->height || buf->pix_fmt != s->pix_fmt) {
av_freep(&buf->base[0]);
av_free(buf);
ist->dr1 = 0;
if ((ret = alloc_buffer(s, ist, &buf)) < 0)
return ret;
}
buf->refcount++;
frame->opaque = buf;
frame->type = FF_BUFFER_TYPE_USER;
frame->extended_data = frame->data;
frame->pkt_pts = s->pkt ? s->pkt->pts : AV_NOPTS_VALUE;
for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
frame->base[i] = buf->base[i]; // XXX h264.c uses base though it shouldn't
frame->data[i] = buf->data[i];
frame->linesize[i] = buf->linesize[i];
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13488 | static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
{
AVFilterContext *ctx = inlink->dst;
HisteqContext *histeq = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int strength = histeq->strength * 1000;
int intensity = histeq->intensity * 1000;
int x, y, i, luthi, lutlo, lut, luma, oluma, m;
AVFrame *outpic;
unsigned int r, g, b, jran;
uint8_t *src, *dst;
outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!outpic) {
av_frame_free(&inpic);
return AVERROR(ENOMEM);
}
av_frame_copy_props(outpic, inpic);
/* Seed random generator for antibanding. */
jran = LCG_SEED;
/* Calculate and store the luminance and calculate the global histogram
based on the luminance. */
memset(histeq->in_histogram, 0, sizeof(histeq->in_histogram));
src = inpic->data[0];
dst = outpic->data[0];
for (y = 0; y < inlink->h; y++) {
for (x = 0; x < inlink->w * histeq->bpp; x += histeq->bpp) {
GET_RGB_VALUES(r, g, b, src, histeq->rgba_map);
luma = (55 * r + 182 * g + 19 * b) >> 8;
dst[x + histeq->rgba_map[A]] = luma;
histeq->in_histogram[luma]++;
}
src += inpic->linesize[0];
dst += outpic->linesize[0];
}
#ifdef DEBUG
for (x = 0; x < 256; x++)
av_dlog(ctx, "in[%d]: %u\n", x, histeq->in_histogram[x]);
#endif
/* Calculate the lookup table. */
histeq->LUT[0] = histeq->in_histogram[0];
/* Accumulate */
for (x = 1; x < 256; x++)
histeq->LUT[x] = histeq->LUT[x-1] + histeq->in_histogram[x];
/* Normalize */
for (x = 0; x < 256; x++)
histeq->LUT[x] = (histeq->LUT[x] * intensity) / (inlink->h * inlink->w);
/* Adjust the LUT based on the selected strength. This is an alpha
mix of the calculated LUT and a linear LUT with gain 1. */
for (x = 0; x < 256; x++)
histeq->LUT[x] = (strength * histeq->LUT[x]) / 255 +
((255 - strength) * x) / 255;
/* Output the equalized frame. */
memset(histeq->out_histogram, 0, sizeof(histeq->out_histogram));
src = inpic->data[0];
dst = outpic->data[0];
for (y = 0; y < inlink->h; y++) {
for (x = 0; x < inlink->w * histeq->bpp; x += histeq->bpp) {
luma = dst[x + histeq->rgba_map[A]];
if (luma == 0) {
for (i = 0; i < histeq->bpp; ++i)
dst[x + i] = 0;
histeq->out_histogram[0]++;
} else {
lut = histeq->LUT[luma];
if (histeq->antibanding != HISTEQ_ANTIBANDING_NONE) {
if (luma > 0) {
lutlo = histeq->antibanding == HISTEQ_ANTIBANDING_WEAK ?
(histeq->LUT[luma] + histeq->LUT[luma - 1]) / 2 :
histeq->LUT[luma - 1];
} else
lutlo = lut;
if (luma < 255) {
luthi = (histeq->antibanding == HISTEQ_ANTIBANDING_WEAK) ?
(histeq->LUT[luma] + histeq->LUT[luma + 1]) / 2 :
histeq->LUT[luma + 1];
} else
luthi = lut;
if (lutlo != luthi) {
jran = LCG(jran);
lut = lutlo + ((luthi - lutlo + 1) * jran) / LCG_M;
}
}
GET_RGB_VALUES(r, g, b, src, histeq->rgba_map);
if (((m = FFMAX3(r, g, b)) * lut) / luma > 255) {
r = (r * 255) / m;
g = (g * 255) / m;
b = (b * 255) / m;
} else {
r = (r * lut) / luma;
g = (g * lut) / luma;
b = (b * lut) / luma;
}
dst[x + histeq->rgba_map[R]] = r;
dst[x + histeq->rgba_map[G]] = g;
dst[x + histeq->rgba_map[B]] = b;
oluma = (55 * r + 182 * g + 19 * b) >> 8;
histeq->out_histogram[oluma]++;
}
}
src += inpic->linesize[0];
dst += outpic->linesize[0];
}
#ifdef DEBUG
for (x = 0; x < 256; x++)
av_dlog(ctx, "out[%d]: %u\n", x, histeq->out_histogram[x]);
#endif
av_frame_free(&inpic);
return ff_filter_frame(outlink, outpic);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13494 | static void test_visitor_in_native_list_int32(TestInputVisitorData *data,
const void *unused)
{
test_native_list_integer_helper(data, unused,
USER_DEF_NATIVE_LIST_UNION_KIND_S32);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13504 | static void nbd_trip(void *opaque)
{
NBDClient *client = opaque;
NBDExport *exp = client->exp;
NBDRequest *req;
struct nbd_request request;
struct nbd_reply reply;
ssize_t ret;
uint32_t command;
TRACE("Reading request.");
if (client->closing) {
return;
}
req = nbd_request_get(client);
ret = nbd_co_receive_request(req, &request);
if (ret == -EAGAIN) {
goto done;
}
if (ret == -EIO) {
goto out;
}
reply.handle = request.handle;
reply.error = 0;
if (ret < 0) {
reply.error = -ret;
goto error_reply;
}
command = request.type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_DISC && (request.from + request.len) > exp->size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len,
(uint64_t)exp->size, (uint64_t)exp->dev_offset);
LOG("requested operation past EOF--bad client?");
goto invalid_request;
}
if (client->closing) {
/*
* The client may be closed when we are blocked in
* nbd_co_receive_request()
*/
goto done;
}
switch (command) {
case NBD_CMD_READ:
TRACE("Request type is READ");
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
ret = blk_pread(exp->blk, request.from + exp->dev_offset,
req->data, request.len);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
goto error_reply;
}
TRACE("Read %u byte(s)", request.len);
if (nbd_co_send_reply(req, &reply, request.len) < 0)
goto out;
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = EROFS;
goto error_reply;
}
TRACE("Writing to device");
ret = blk_pwrite(exp->blk, request.from + exp->dev_offset,
req->data, request.len, 0);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
goto error_reply;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
goto error_reply;
}
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
goto out;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = blk_co_flush(exp->blk);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = blk_co_discard(exp->blk, (request.from + exp->dev_offset)
/ BDRV_SECTOR_SIZE,
request.len / BDRV_SECTOR_SIZE);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
default:
LOG("invalid request type (%u) received", request.type);
invalid_request:
reply.error = EINVAL;
error_reply:
if (nbd_co_send_reply(req, &reply, 0) < 0) {
goto out;
}
break;
}
TRACE("Request/Reply complete");
done:
nbd_request_put(req);
return;
out:
nbd_request_put(req);
client_close(client);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13513 | void qemu_register_reset(QEMUResetHandler *func, void *opaque)
{
QEMUResetEntry *re = qemu_mallocz(sizeof(QEMUResetEntry));
re->func = func;
re->opaque = opaque;
TAILQ_INSERT_TAIL(&reset_handlers, re, entry);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13517 | void stl_phys_notdirty(hwaddr addr, uint32_t val)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
io_mem_write(section->mr, addr, val, 4);
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
if (unlikely(in_migration)) {
if (!cpu_physical_memory_is_dirty(addr1)) {
/* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
/* set dirty bit */
cpu_physical_memory_set_dirty_flags(
addr1, (0xff & ~CODE_DIRTY_FLAG));
}
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13524 | static void compute_antialias_float(MPADecodeContext *s,
GranuleDef *g)
{
float *ptr;
int n, i;
/* we antialias only "long" bands */
if (g->block_type == 2) {
if (!g->switch_point)
return;
/* XXX: check this for 8000Hz case */
n = 1;
} else {
n = SBLIMIT - 1;
}
ptr = g->sb_hybrid + 18;
for(i = n;i > 0;i--) {
float tmp0, tmp1;
float *csa = &csa_table_float[0][0];
#define FLOAT_AA(j)\
tmp0= ptr[-1-j];\
tmp1= ptr[ j];\
ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\
ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j];
FLOAT_AA(0)
FLOAT_AA(1)
FLOAT_AA(2)
FLOAT_AA(3)
FLOAT_AA(4)
FLOAT_AA(5)
FLOAT_AA(6)
FLOAT_AA(7)
ptr += 18;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13548 | PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *pic, int ram_size)
{
DeviceState *dev;
PCIBus *b;
PCIDevice *d;
I440FXState *s;
PIIX3State *piix3;
dev = qdev_create(NULL, "i440FX-pcihost");
s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
b = pci_bus_new(&s->busdev.qdev, NULL, 0);
s->bus = b;
qdev_init_nofail(dev);
d = pci_create_simple(b, 0, "i440FX");
*pi440fx_state = DO_UPCAST(PCII440FXState, dev, d);
piix3 = DO_UPCAST(PIIX3State, dev,
pci_create_simple(b, -1, "PIIX3"));
piix3->pic = pic;
pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
(*pi440fx_state)->piix3 = piix3;
*piix3_devfn = piix3->dev.devfn;
ram_size = ram_size / 8 / 1024 / 1024;
if (ram_size > 255)
ram_size = 255;
(*pi440fx_state)->dev.config[0x57]=ram_size;
return b;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13554 | uint64_t helper_cvttq_c(CPUAlphaState *env, uint64_t a)
{
return inline_cvttq(env, a, float_round_to_zero, 0);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13555 | int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
{
int ret;
s->ext_audio_mask = 0;
s->xch_pos = s->xxch_pos = s->x96_pos = 0;
if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
return ret;
s->gb_in = s->gb;
if ((ret = parse_frame_header(s)) < 0)
return ret;
if ((ret = alloc_sample_buffer(s)) < 0)
return ret;
if ((ret = parse_frame_data(s, HEADER_CORE, 0)) < 0)
return ret;
if ((ret = parse_optional_info(s)) < 0)
return ret;
// Workaround for DTS in WAV
if (s->frame_size > size && s->frame_size < size + 4)
s->frame_size = size;
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of core frame\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13556 | static void gen_mulu(DisasContext *dc, TCGv dest, TCGv srca, TCGv srcb)
{
TCGv sr_cy = tcg_temp_new();
tcg_gen_muls2_tl(dest, sr_cy, srca, srcb);
tcg_gen_setcondi_tl(TCG_COND_NE, sr_cy, sr_cy, 0);
tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_cy, ctz32(SR_CY), 1);
gen_ove_cy(dc, sr_cy);
tcg_temp_free(sr_cy);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13571 | static int decode_init_mp3on4(AVCodecContext * avctx)
{
MP3On4DecodeContext *s = avctx->priv_data;
int i;
if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {
av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
return -1;
}
s->chan_cfg = (((unsigned char *)avctx->extradata)[1] >> 3) & 0x0f;
s->frames = mp3Frames[s->chan_cfg];
if(!s->frames) {
av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
return -1;
}
avctx->channels = mp3Channels[s->chan_cfg];
/* Init the first mp3 decoder in standard way, so that all tables get builded
* We replace avctx->priv_data with the context of the first decoder so that
* decode_init() does not have to be changed.
* Other decoders will be inited here copying data from the first context
*/
// Allocate zeroed memory for the first decoder context
s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
// Put decoder context in place to make init_decode() happy
avctx->priv_data = s->mp3decctx[0];
decode_init(avctx);
// Restore mp3on4 context pointer
avctx->priv_data = s;
s->mp3decctx[0]->adu_mode = 1; // Set adu mode
/* Create a separate codec/context for each frame (first is already ok).
* Each frame is 1 or 2 channels - up to 5 frames allowed
*/
for (i = 1; i < s->frames; i++) {
s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias;
s->mp3decctx[i]->adu_mode = 1;
s->mp3decctx[i]->avctx = avctx;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13589 | _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname,
const struct timespec *,tsp,int,flags)
#endif
#endif /* CONFIG_UTIMENSAT */
#ifdef CONFIG_INOTIFY
#include <sys/inotify.h>
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
static int sys_inotify_init(void)
{
return (inotify_init());
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13604 | static void curl_readv_bh_cb(void *p)
{
CURLState *state;
int running;
CURLAIOCB *acb = p;
BDRVCURLState *s = acb->common.bs->opaque;
qemu_bh_delete(acb->bh);
acb->bh = NULL;
size_t start = acb->sector_num * SECTOR_SIZE;
size_t end;
// In case we have the requested data already (e.g. read-ahead),
// we can just call the callback and be done.
switch (curl_find_buf(s, start, acb->nb_sectors * SECTOR_SIZE, acb)) {
case FIND_RET_OK:
qemu_aio_release(acb);
// fall through
case FIND_RET_WAIT:
return;
default:
break;
}
// No cache found, so let's start a new request
state = curl_init_state(s);
if (!state) {
acb->common.cb(acb->common.opaque, -EIO);
qemu_aio_release(acb);
return;
}
acb->start = 0;
acb->end = (acb->nb_sectors * SECTOR_SIZE);
state->buf_off = 0;
g_free(state->orig_buf);
state->buf_start = start;
state->buf_len = acb->end + s->readahead_size;
end = MIN(start + state->buf_len, s->len) - 1;
state->orig_buf = g_malloc(state->buf_len);
state->acb[0] = acb;
snprintf(state->range, 127, "%zd-%zd", start, end);
DPRINTF("CURL (AIO): Reading %d at %zd (%s)\n",
(acb->nb_sectors * SECTOR_SIZE), start, state->range);
curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
curl_multi_add_handle(s->multi, state->curl);
/* Tell curl it needs to kick things off */
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13635 | static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
{
int lambda, up_step, down_step;
int last_lower = INT_MAX, last_higher = 0;
int x, y, q;
for (q = 1; q < avctx->qmax; q++) {
ctx->qscale = q;
avctx->execute2(avctx, dnxhd_calc_bits_thread, NULL, NULL, ctx->m.mb_height);
}
up_step = down_step = 2<<LAMBDA_FRAC_BITS;
lambda = ctx->lambda;
for (;;) {
int bits = 0;
int end = 0;
if (lambda == last_higher) {
lambda++;
end = 1; // need to set final qscales/bits
}
for (y = 0; y < ctx->m.mb_height; y++) {
for (x = 0; x < ctx->m.mb_width; x++) {
unsigned min = UINT_MAX;
int qscale = 1;
int mb = y*ctx->m.mb_width+x;
for (q = 1; q < avctx->qmax; q++) {
unsigned score = ctx->mb_rc[q][mb].bits*lambda+(ctx->mb_rc[q][mb].ssd<<LAMBDA_FRAC_BITS);
if (score < min) {
min = score;
qscale = q;
}
}
bits += ctx->mb_rc[qscale][mb].bits;
ctx->mb_qscale[mb] = qscale;
ctx->mb_bits[mb] = ctx->mb_rc[qscale][mb].bits;
}
bits = (bits+31)&~31; // padding
if (bits > ctx->frame_bits)
break;
}
//av_dlog(ctx->m.avctx, "lambda %d, up %u, down %u, bits %d, frame %d\n",
// lambda, last_higher, last_lower, bits, ctx->frame_bits);
if (end) {
if (bits > ctx->frame_bits)
return -1;
break;
}
if (bits < ctx->frame_bits) {
last_lower = FFMIN(lambda, last_lower);
if (last_higher != 0)
lambda = (lambda+last_higher)>>1;
else
lambda -= down_step;
down_step *= 5; // XXX tune ?
up_step = 1<<LAMBDA_FRAC_BITS;
lambda = FFMAX(1, lambda);
if (lambda == last_lower)
break;
} else {
last_higher = FFMAX(lambda, last_higher);
if (last_lower != INT_MAX)
lambda = (lambda+last_lower)>>1;
else if ((int64_t)lambda + up_step > INT_MAX)
return -1;
else
lambda += up_step;
up_step = FFMIN((int64_t)up_step*5, INT_MAX);
down_step = 1<<LAMBDA_FRAC_BITS;
}
}
//av_dlog(ctx->m.avctx, "out lambda %d\n", lambda);
ctx->lambda = lambda;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13636 | static int find_and_decode_index(NUTContext *nut)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
uint64_t tmp, end;
int i, j, syncpoint_count;
int64_t filesize = avio_size(bc);
int64_t *syncpoints;
int8_t *has_keyframe;
int ret = AVERROR_INVALIDDATA;
avio_seek(bc, filesize - 12, SEEK_SET);
avio_seek(bc, filesize - avio_rb64(bc), SEEK_SET);
if (avio_rb64(bc) != INDEX_STARTCODE) {
av_log(s, AV_LOG_ERROR, "no index at the end\n");
return ret;
}
end = get_packetheader(nut, bc, 1, INDEX_STARTCODE);
end += avio_tell(bc);
ffio_read_varlen(bc); // max_pts
GET_V(syncpoint_count, tmp < INT_MAX / 8 && tmp > 0);
syncpoints = av_malloc(sizeof(int64_t) * syncpoint_count);
has_keyframe = av_malloc(sizeof(int8_t) * (syncpoint_count + 1));
if (!syncpoints || !has_keyframe)
return AVERROR(ENOMEM);
for (i = 0; i < syncpoint_count; i++) {
syncpoints[i] = ffio_read_varlen(bc);
if (syncpoints[i] <= 0)
goto fail;
if (i)
syncpoints[i] += syncpoints[i - 1];
}
for (i = 0; i < s->nb_streams; i++) {
int64_t last_pts = -1;
for (j = 0; j < syncpoint_count;) {
uint64_t x = ffio_read_varlen(bc);
int type = x & 1;
int n = j;
x >>= 1;
if (type) {
int flag = x & 1;
x >>= 1;
if (n + x >= syncpoint_count + 1) {
av_log(s, AV_LOG_ERROR, "index overflow A\n");
goto fail;
}
while (x--)
has_keyframe[n++] = flag;
has_keyframe[n++] = !flag;
} else {
while (x != 1) {
if (n >= syncpoint_count + 1) {
av_log(s, AV_LOG_ERROR, "index overflow B\n");
goto fail;
}
has_keyframe[n++] = x & 1;
x >>= 1;
}
}
if (has_keyframe[0]) {
av_log(s, AV_LOG_ERROR, "keyframe before first syncpoint in index\n");
goto fail;
}
assert(n <= syncpoint_count + 1);
for (; j < n && j < syncpoint_count; j++) {
if (has_keyframe[j]) {
uint64_t B, A = ffio_read_varlen(bc);
if (!A) {
A = ffio_read_varlen(bc);
B = ffio_read_varlen(bc);
// eor_pts[j][i] = last_pts + A + B
} else
B = 0;
av_add_index_entry(s->streams[i], 16 * syncpoints[j - 1],
last_pts + A, 0, 0, AVINDEX_KEYFRAME);
last_pts += A + B;
}
}
}
}
if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
goto fail;
}
ret = 0;
fail:
av_free(syncpoints);
av_free(has_keyframe);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13667 | static inline void menelaus_rtc_stop(struct menelaus_s *s)
{
qemu_del_timer(s->rtc.hz);
s->rtc.next =- qemu_get_clock(rt_clock);
if (s->rtc.next < 1)
s->rtc.next = 1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13672 | int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
{
char buf[128];
char file[1024];
char devname[128];
char serial[21];
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
QEMUMachine *machine = opaque;
int max_devs;
int index;
int cache;
int bdrv_flags, onerror;
int drives_table_idx;
char *str = arg->opt;
static const char * const params[] = { "bus", "unit", "if", "index",
"cyls", "heads", "secs", "trans",
"media", "snapshot", "file",
"cache", "format", "serial", "werror",
NULL };
if (check_params(params, str) < 0) {
fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",
buf, str);
return -1;
}
file[0] = 0;
cyls = heads = secs = 0;
bus_id = 0;
unit_id = -1;
translation = BIOS_ATA_TRANSLATION_AUTO;
index = -1;
cache = 3;
if (machine->use_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
/* extract parameters */
if (get_param_value(buf, sizeof(buf), "bus", str)) {
bus_id = strtol(buf, NULL, 0);
if (bus_id < 0) {
fprintf(stderr, "qemu: '%s' invalid bus id\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "unit", str)) {
unit_id = strtol(buf, NULL, 0);
if (unit_id < 0) {
fprintf(stderr, "qemu: '%s' invalid unit id\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "if", str)) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else if (!strcmp(buf, "xen")) {
type = IF_XEN;
max_devs = 0;
} else {
fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "index", str)) {
index = strtol(buf, NULL, 0);
if (index < 0) {
fprintf(stderr, "qemu: '%s' invalid index\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "cyls", str)) {
cyls = strtol(buf, NULL, 0);
}
if (get_param_value(buf, sizeof(buf), "heads", str)) {
heads = strtol(buf, NULL, 0);
}
if (get_param_value(buf, sizeof(buf), "secs", str)) {
secs = strtol(buf, NULL, 0);
}
if (cyls || heads || secs) {
if (cyls < 1 || cyls > 16383) {
fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", str);
return -1;
}
if (heads < 1 || heads > 16) {
fprintf(stderr, "qemu: '%s' invalid physical heads number\n", str);
return -1;
}
if (secs < 1 || secs > 63) {
fprintf(stderr, "qemu: '%s' invalid physical secs number\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "trans", str)) {
if (!cyls) {
fprintf(stderr,
"qemu: '%s' trans must be used with cyls,heads and secs\n",
str);
return -1;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
fprintf(stderr, "qemu: '%s' invalid translation type\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "media", str)) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
fprintf(stderr,
"qemu: '%s' invalid physical CHS format\n", str);
return -1;
}
media = MEDIA_CDROM;
} else {
fprintf(stderr, "qemu: '%s' invalid media\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "snapshot", str)) {
if (!strcmp(buf, "on"))
snapshot = 1;
else if (!strcmp(buf, "off"))
snapshot = 0;
else {
fprintf(stderr, "qemu: '%s' invalid snapshot option\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "cache", str)) {
if (!strcmp(buf, "off") || !strcmp(buf, "none"))
cache = 0;
else if (!strcmp(buf, "writethrough"))
cache = 1;
else if (!strcmp(buf, "writeback"))
cache = 2;
else {
fprintf(stderr, "qemu: invalid cache option\n");
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "format", str)) {
if (strcmp(buf, "?") == 0) {
fprintf(stderr, "qemu: Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
fprintf(stderr, "\n");
return -1;
}
drv = bdrv_find_format(buf);
if (!drv) {
fprintf(stderr, "qemu: '%s' invalid format\n", buf);
return -1;
}
}
if (arg->file == NULL)
get_param_value(file, sizeof(file), "file", str);
else
pstrcpy(file, sizeof(file), arg->file);
if (!get_param_value(serial, sizeof(serial), "serial", str))
memset(serial, 0, sizeof(serial));
onerror = BLOCK_ERR_STOP_ENOSPC;
if (get_param_value(buf, sizeof(serial), "werror", str)) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
fprintf(stderr, "werror is no supported by this format\n");
return -1;
}
if (!strcmp(buf, "ignore"))
onerror = BLOCK_ERR_IGNORE;
else if (!strcmp(buf, "enospc"))
onerror = BLOCK_ERR_STOP_ENOSPC;
else if (!strcmp(buf, "stop"))
onerror = BLOCK_ERR_STOP_ANY;
else if (!strcmp(buf, "report"))
onerror = BLOCK_ERR_REPORT;
else {
fprintf(stderr, "qemu: '%s' invalid write error action\n", buf);
return -1;
}
}
/* compute bus and unit according index */
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
fprintf(stderr,
"qemu: '%s' index cannot be used with bus and unit\n", str);
return -1;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
/* if user doesn't specify a unit_id,
* try to find the first free
*/
if (unit_id == -1) {
unit_id = 0;
while (drive_get_index(type, bus_id, unit_id) != -1) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
/* check unit id */
if (max_devs && unit_id >= max_devs) {
fprintf(stderr, "qemu: '%s' unit %d too big (max is %d)\n",
str, unit_id, max_devs - 1);
return -1;
}
/*
* ignore multiple definitions
*/
if (drive_get_index(type, bus_id, unit_id) != -1)
return -2;
/* init */
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(buf, sizeof(buf), "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(buf, sizeof(buf), "%s%s%i",
devname, mediastr, unit_id);
bdrv = bdrv_new(buf);
drives_table_idx = drive_get_free_idx();
drives_table[drives_table_idx].bdrv = bdrv;
drives_table[drives_table_idx].type = type;
drives_table[drives_table_idx].bus = bus_id;
drives_table[drives_table_idx].unit = unit_id;
drives_table[drives_table_idx].onerror = onerror;
drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt;
strncpy(drives_table[drives_table_idx].serial, serial, sizeof(serial));
nb_drives++;
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(bdrv, cyls, heads, secs);
bdrv_set_translation_hint(bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
/* FIXME: This isn't really a floppy, but it's a reasonable
approximation. */
case IF_FLOPPY:
bdrv_set_type_hint(bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
case IF_VIRTIO:
break;
case IF_COUNT:
abort();
}
if (!file[0])
return -2;
bdrv_flags = 0;
if (snapshot) {
bdrv_flags |= BDRV_O_SNAPSHOT;
cache = 2; /* always use write-back with snapshot */
}
if (cache == 0) /* no caching */
bdrv_flags |= BDRV_O_NOCACHE;
else if (cache == 2) /* write-back */
bdrv_flags |= BDRV_O_CACHE_WB;
else if (cache == 3) /* not specified */
bdrv_flags |= BDRV_O_CACHE_DEF;
if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s\n",
file);
return -1;
}
if (bdrv_key_required(bdrv))
autostart = 0;
return drives_table_idx;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13706 | static void gic_complete_irq(gic_state * s, int cpu, int irq)
{
int update = 0;
int cm = 1 << cpu;
DPRINTF("EOI %d\n", irq);
if (s->running_irq[cpu] == 1023)
return; /* No active IRQ. */
if (irq != 1023) {
/* Mark level triggered interrupts as pending if they are still
raised. */
if (!GIC_TEST_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)
&& GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {
DPRINTF("Set %d pending mask %x\n", irq, cm);
GIC_SET_PENDING(irq, cm);
update = 1;
}
}
if (irq != s->running_irq[cpu]) {
/* Complete an IRQ that is not currently running. */
int tmp = s->running_irq[cpu];
while (s->last_active[tmp][cpu] != 1023) {
if (s->last_active[tmp][cpu] == irq) {
s->last_active[tmp][cpu] = s->last_active[irq][cpu];
break;
}
tmp = s->last_active[tmp][cpu];
}
if (update) {
gic_update(s);
}
} else {
/* Complete the current running IRQ. */
gic_set_running_irq(s, cpu, s->last_active[s->running_irq[cpu]][cpu]);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13712 | static void init_dequant8_coeff_table(H264Context *h){
int i,q,x;
const int transpose = (h->h264dsp.h264_idct8_add != ff_h264_idct8_add_c); //FIXME ugly
h->dequant8_coeff[0] = h->dequant8_buffer[0];
h->dequant8_coeff[1] = h->dequant8_buffer[1];
for(i=0; i<2; i++ ){
if(i && !memcmp(h->pps.scaling_matrix8[0], h->pps.scaling_matrix8[1], 64*sizeof(uint8_t))){
h->dequant8_coeff[1] = h->dequant8_buffer[0];
break;
}
for(q=0; q<52; q++){
int shift = div6[q];
int idx = rem6[q];
for(x=0; x<64; x++)
h->dequant8_coeff[i][q][transpose ? (x>>3)|((x&7)<<3) : x] =
((uint32_t)dequant8_coeff_init[idx][ dequant8_coeff_init_scan[((x>>1)&12) | (x&3)] ] *
h->pps.scaling_matrix8[i][x]) << shift;
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13726 | char *vnc_display_local_addr(const char *id)
{
VncDisplay *vs = vnc_display_find(id);
return vnc_socket_local_addr("%s:%s", vs->lsock);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13728 | PPC_OP(set_T0)
{
T0 = PARAM(1);
RETURN();
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13734 | static void test_validate_fail_struct_nested(TestInputVisitorData *data,
const void *unused)
{
UserDefTwo *udp = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}");
visit_type_UserDefTwo(v, NULL, &udp, &err);
error_free_or_abort(&err);
qapi_free_UserDefTwo(udp);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13736 | static int socket_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
QEMUFileSocket *s = opaque;
ssize_t len;
do {
len = qemu_recv(s->fd, buf, size, 0);
} while (len == -1 && socket_error() == EINTR);
if (len == -1)
len = -socket_error();
return len;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13739 | static GIOStatus ga_channel_write(GAChannel *c, const char *buf, size_t size,
size_t *count)
{
GIOStatus status;
OVERLAPPED ov = {0};
BOOL ret;
DWORD written;
ov.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
ret = WriteFile(c->handle, buf, size, &written, &ov);
if (!ret) {
if (GetLastError() == ERROR_IO_PENDING) {
/* write is pending */
ret = GetOverlappedResult(c->handle, &ov, &written, TRUE);
if (!ret) {
if (!GetLastError()) {
status = G_IO_STATUS_AGAIN;
} else {
status = G_IO_STATUS_ERROR;
} else {
/* write is complete */
status = G_IO_STATUS_NORMAL;
*count = written;
} else {
status = G_IO_STATUS_ERROR;
} else {
/* write returned immediately */
status = G_IO_STATUS_NORMAL;
*count = written;
return status;
The vulnerability label is: Vulnerable |
devign_test_set_data_13740 | int ff_jni_exception_get_summary(JNIEnv *env, jthrowable exception, char **error, void *log_ctx)
{
int ret = 0;
AVBPrint bp;
char *name = NULL;
char *message = NULL;
jclass class_class = NULL;
jmethodID get_name_id = NULL;
jclass exception_class = NULL;
jmethodID get_message_id = NULL;
jstring string;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
exception_class = (*env)->GetObjectClass(env, exception);
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
av_log(log_ctx, AV_LOG_ERROR, "Could not find Throwable class\n");
ret = AVERROR_EXTERNAL;
goto done;
}
class_class = (*env)->GetObjectClass(env, exception_class);
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
av_log(log_ctx, AV_LOG_ERROR, "Could not find Throwable class's class\n");
ret = AVERROR_EXTERNAL;
goto done;
}
get_name_id = (*env)->GetMethodID(env, class_class, "getName", "()Ljava/lang/String;");
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
av_log(log_ctx, AV_LOG_ERROR, "Could not find method Class.getName()\n");
ret = AVERROR_EXTERNAL;
goto done;
}
string = (*env)->CallObjectMethod(env, exception_class, get_name_id);
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
av_log(log_ctx, AV_LOG_ERROR, "Class.getName() threw an exception\n");
ret = AVERROR_EXTERNAL;
goto done;
}
if (string) {
name = ff_jni_jstring_to_utf_chars(env, string, log_ctx);
(*env)->DeleteLocalRef(env, string);
string = NULL;
}
get_message_id = (*env)->GetMethodID(env, exception_class, "getMessage", "()Ljava/lang/String;");
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
av_log(log_ctx, AV_LOG_ERROR, "Could not find method java/lang/Throwable.getMessage()\n");
ret = AVERROR_EXTERNAL;
goto done;
}
string = (*env)->CallObjectMethod(env, exception, get_message_id);
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
av_log(log_ctx, AV_LOG_ERROR, "Throwable.getMessage() threw an exception\n");
ret = AVERROR_EXTERNAL;
goto done;
}
if (string) {
message = ff_jni_jstring_to_utf_chars(env, string, log_ctx);
(*env)->DeleteLocalRef(env, string);
string = NULL;
}
if (name && message) {
av_bprintf(&bp, "%s: %s", name, message);
} else if (name && !message) {
av_bprintf(&bp, "%s occurred", name);
} else if (!name && message) {
av_bprintf(&bp, "Exception: %s", message);
} else {
av_log(log_ctx, AV_LOG_WARNING, "Could not retreive exception name and message\n");
av_bprintf(&bp, "Exception occurred");
}
ret = av_bprint_finalize(&bp, error);
done:
av_free(name);
av_free(message);
if (class_class) {
(*env)->DeleteLocalRef(env, class_class);
}
if (exception_class) {
(*env)->DeleteLocalRef(env, exception_class);
}
if (string) {
(*env)->DeleteLocalRef(env, string);
}
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13748 | static void vscsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, bus->qbus.parent);
vscsi_req *req = vscsi_find_req(s, tag);
SCSIDevice *sdev;
uint8_t *buf;
int32_t res_in = 0, res_out = 0;
int len, rc = 0;
dprintf("VSCSI: SCSI cmd complete, r=0x%x tag=0x%x arg=0x%x, req=%p\n",
reason, tag, arg, req);
if (req == NULL) {
fprintf(stderr, "VSCSI: Can't find request for tag 0x%x\n", tag);
return;
}
sdev = req->sdev;
if (req->sensing) {
if (reason == SCSI_REASON_DONE) {
dprintf("VSCSI: Sense done !\n");
vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0);
vscsi_put_req(s, req);
} else {
uint8_t *buf = sdev->info->get_buf(sdev, tag);
len = MIN(arg, SCSI_SENSE_BUF_SIZE);
dprintf("VSCSI: Sense data, %d bytes:\n", len);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5], buf[6], buf[7]);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);
memcpy(req->sense, buf, len);
req->senselen = len;
sdev->info->read_data(sdev, req->qtag);
}
return;
}
if (reason == SCSI_REASON_DONE) {
dprintf("VSCSI: Command complete err=%d\n", arg);
if (arg == 0) {
/* We handle overflows, not underflows for normal commands,
* but hopefully nobody cares
*/
if (req->writing) {
res_out = req->data_len;
} else {
res_in = req->data_len;
}
vscsi_send_rsp(s, req, 0, res_in, res_out);
} else if (arg == CHECK_CONDITION) {
dprintf("VSCSI: Got CHECK_CONDITION, requesting sense...\n");
vscsi_send_request_sense(s, req);
return;
} else {
vscsi_send_rsp(s, req, arg, 0, 0);
}
vscsi_put_req(s, req);
return;
}
/* "arg" is how much we have read for reads and how much we want
* to write for writes (ie, how much is to be DMA'd)
*/
if (arg) {
buf = sdev->info->get_buf(sdev, tag);
rc = vscsi_srp_transfer_data(s, req, req->writing, buf, arg);
}
if (rc < 0) {
fprintf(stderr, "VSCSI: RDMA error rc=%d!\n", rc);
sdev->info->cancel_io(sdev, req->qtag);
vscsi_makeup_sense(s, req, HARDWARE_ERROR, 0, 0);
vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0);
vscsi_put_req(s, req);
return;
}
/* Start next chunk */
req->data_len -= rc;
if (req->writing) {
sdev->info->write_data(sdev, req->qtag);
} else {
sdev->info->read_data(sdev, req->qtag);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13754 | void helper_store_sdr1(CPUPPCState *env, target_ulong val)
{
PowerPCCPU *cpu = ppc_env_get_cpu(env);
if (!env->external_htab) {
if (env->spr[SPR_SDR1] != val) {
ppc_store_sdr1(env, val);
tlb_flush(CPU(cpu));
}
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13768 | static bool fw_cfg_comb_valid(void *opaque, target_phys_addr_t addr,
unsigned size, bool is_write)
{
return (size == 1) || (is_write && size == 2);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13772 | sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
uint64_t bus_offset,
uint32_t page_shift,
uint32_t nb_table,
bool vfio_accel)
{
sPAPRTCETable *tcet;
char tmp[64];
if (spapr_tce_find_by_liobn(liobn)) {
fprintf(stderr, "Attempted to create TCE table with duplicate"
" LIOBN 0x%x\n", liobn);
return NULL;
}
if (!nb_table) {
return NULL;
}
tcet = SPAPR_TCE_TABLE(object_new(TYPE_SPAPR_TCE_TABLE));
tcet->liobn = liobn;
tcet->bus_offset = bus_offset;
tcet->page_shift = page_shift;
tcet->nb_table = nb_table;
tcet->vfio_accel = vfio_accel;
snprintf(tmp, sizeof(tmp), "tce-table-%x", liobn);
object_property_add_child(OBJECT(owner), tmp, OBJECT(tcet), NULL);
object_property_set_bool(OBJECT(tcet), true, "realized", NULL);
return tcet;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13784 | static void debug_print_fis(uint8_t *fis, int cmd_len)
{
#ifdef DEBUG_AHCI
int i;
fprintf(stderr, "fis:");
for (i = 0; i < cmd_len; i++) {
if ((i & 0xf) == 0) {
fprintf(stderr, "\n%02x:",i);
}
fprintf(stderr, "%02x ",fis[i]);
}
fprintf(stderr, "\n");
#endif
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13809 | static av_cold int svc_encode_init(AVCodecContext *avctx)
{
SVCContext *s = avctx->priv_data;
SEncParamExt param = { 0 };
int err = AVERROR_UNKNOWN;
int log_level;
WelsTraceCallback callback_function;
AVCPBProperties *props;
// Mingw GCC < 4.7 on x86_32 uses an incorrect/buggy ABI for the WelsGetCodecVersion
// function (for functions returning larger structs), thus skip the check in those
// configurations.
#if !defined(_WIN32) || !defined(__GNUC__) || !ARCH_X86_32 || AV_GCC_VERSION_AT_LEAST(4, 7)
OpenH264Version libver = WelsGetCodecVersion();
if (memcmp(&libver, &g_stCodecVersion, sizeof(libver))) {
av_log(avctx, AV_LOG_ERROR, "Incorrect library version loaded\n");
return AVERROR(EINVAL);
}
#endif
if (WelsCreateSVCEncoder(&s->encoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
return AVERROR_UNKNOWN;
}
// Pass all libopenh264 messages to our callback, to allow ourselves to filter them.
log_level = WELS_LOG_DETAIL;
(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_LEVEL, &log_level);
// Set the logging callback function to one that uses av_log() (see implementation above).
callback_function = (WelsTraceCallback) libopenh264_trace_callback;
(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_CALLBACK, (void *)&callback_function);
// Set the AVCodecContext as the libopenh264 callback context so that it can be passed to av_log().
(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, (void *)&avctx);
(*s->encoder)->GetDefaultParams(s->encoder, ¶m);
param.fMaxFrameRate = avctx->time_base.den / avctx->time_base.num;
param.iPicWidth = avctx->width;
param.iPicHeight = avctx->height;
param.iTargetBitrate = avctx->bit_rate;
param.iMaxBitrate = FFMAX(avctx->rc_max_rate, avctx->bit_rate);
param.iRCMode = RC_QUALITY_MODE;
param.iTemporalLayerNum = 1;
param.iSpatialLayerNum = 1;
param.bEnableDenoise = 0;
param.bEnableBackgroundDetection = 1;
param.bEnableAdaptiveQuant = 1;
param.bEnableFrameSkip = s->skip_frames;
param.bEnableLongTermReference = 0;
param.iLtrMarkPeriod = 30;
param.uiIntraPeriod = avctx->gop_size;
#if OPENH264_VER_AT_LEAST(1, 4)
param.eSpsPpsIdStrategy = CONSTANT_ID;
#else
param.bEnableSpsPpsIdAddition = 0;
#endif
param.bPrefixNalAddingCtrl = 0;
param.iLoopFilterDisableIdc = !s->loopfilter;
param.iEntropyCodingModeFlag = 0;
param.iMultipleThreadIdc = avctx->thread_count;
if (s->profile && !strcmp(s->profile, "main"))
param.iEntropyCodingModeFlag = 1;
else if (!s->profile && avctx->coder_type == FF_CODER_TYPE_AC)
param.iEntropyCodingModeFlag = 1;
param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
param.sSpatialLayers[0].iVideoHeight = param.iPicHeight;
param.sSpatialLayers[0].fFrameRate = param.fMaxFrameRate;
param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
param.sSpatialLayers[0].iMaxSpatialBitrate = param.iMaxBitrate;
if ((avctx->slices > 1) && (s->max_nal_size)){
av_log(avctx,AV_LOG_ERROR,"Invalid combination -slices %d and -max_nal_size %d.\n",avctx->slices,s->max_nal_size);
goto fail;
}
if (avctx->slices > 1)
s->slice_mode = SM_FIXEDSLCNUM_SLICE;
if (s->max_nal_size)
s->slice_mode = SM_DYN_SLICE;
param.sSpatialLayers[0].sSliceCfg.uiSliceMode = s->slice_mode;
param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = avctx->slices;
if (s->slice_mode == SM_DYN_SLICE) {
if (s->max_nal_size){
param.uiMaxNalSize = s->max_nal_size;
param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = s->max_nal_size;
} else {
if (avctx->rtp_payload_size) {
av_log(avctx,AV_LOG_DEBUG,"Using RTP Payload size for uiMaxNalSize");
param.uiMaxNalSize = avctx->rtp_payload_size;
param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = avctx->rtp_payload_size;
} else {
av_log(avctx,AV_LOG_ERROR,"Invalid -max_nal_size, specify a valid max_nal_size to use -slice_mode dyn\n");
goto fail;
}
}
}
if ((*s->encoder)->InitializeExt(s->encoder, ¶m) != cmResultSuccess) {
av_log(avctx, AV_LOG_ERROR, "Initialize failed\n");
goto fail;
}
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
SFrameBSInfo fbi = { 0 };
int i, size = 0;
(*s->encoder)->EncodeParameterSets(s->encoder, &fbi);
for (i = 0; i < fbi.sLayerInfo[0].iNalCount; i++)
size += fbi.sLayerInfo[0].pNalLengthInByte[i];
avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
err = AVERROR(ENOMEM);
goto fail;
}
avctx->extradata_size = size;
memcpy(avctx->extradata, fbi.sLayerInfo[0].pBsBuf, size);
}
props = ff_add_cpb_side_data(avctx);
if (!props) {
err = AVERROR(ENOMEM);
goto fail;
}
props->max_bitrate = param.iMaxBitrate;
props->avg_bitrate = param.iTargetBitrate;
return 0;
fail:
svc_encode_close(avctx);
return err;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13829 | static void sm501_disp_ctrl_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
SM501State *s = (SM501State *)opaque;
SM501_DPRINTF("sm501 disp ctrl regs : write addr=%x, val=%x\n",
(unsigned)addr, (unsigned)value);
switch (addr) {
case SM501_DC_PANEL_CONTROL:
s->dc_panel_control = value & 0x0FFF73FF;
break;
case SM501_DC_PANEL_PANNING_CONTROL:
s->dc_panel_panning_control = value & 0xFF3FFF3F;
break;
case SM501_DC_PANEL_FB_ADDR:
s->dc_panel_fb_addr = value & 0x8FFFFFF0;
break;
case SM501_DC_PANEL_FB_OFFSET:
s->dc_panel_fb_offset = value & 0x3FF03FF0;
break;
case SM501_DC_PANEL_FB_WIDTH:
s->dc_panel_fb_width = value & 0x0FFF0FFF;
break;
case SM501_DC_PANEL_FB_HEIGHT:
s->dc_panel_fb_height = value & 0x0FFF0FFF;
break;
case SM501_DC_PANEL_TL_LOC:
s->dc_panel_tl_location = value & 0x07FF07FF;
break;
case SM501_DC_PANEL_BR_LOC:
s->dc_panel_br_location = value & 0x07FF07FF;
break;
case SM501_DC_PANEL_H_TOT:
s->dc_panel_h_total = value & 0x0FFF0FFF;
break;
case SM501_DC_PANEL_H_SYNC:
s->dc_panel_h_sync = value & 0x00FF0FFF;
break;
case SM501_DC_PANEL_V_TOT:
s->dc_panel_v_total = value & 0x0FFF0FFF;
break;
case SM501_DC_PANEL_V_SYNC:
s->dc_panel_v_sync = value & 0x003F0FFF;
break;
case SM501_DC_PANEL_HWC_ADDR:
s->dc_panel_hwc_addr = value & 0x8FFFFFF0;
break;
case SM501_DC_PANEL_HWC_LOC:
s->dc_panel_hwc_location = value & 0x0FFF0FFF;
break;
case SM501_DC_PANEL_HWC_COLOR_1_2:
s->dc_panel_hwc_color_1_2 = value;
break;
case SM501_DC_PANEL_HWC_COLOR_3:
s->dc_panel_hwc_color_3 = value & 0x0000FFFF;
break;
case SM501_DC_CRT_CONTROL:
s->dc_crt_control = value & 0x0003FFFF;
break;
case SM501_DC_CRT_FB_ADDR:
s->dc_crt_fb_addr = value & 0x8FFFFFF0;
break;
case SM501_DC_CRT_FB_OFFSET:
s->dc_crt_fb_offset = value & 0x3FF03FF0;
break;
case SM501_DC_CRT_H_TOT:
s->dc_crt_h_total = value & 0x0FFF0FFF;
break;
case SM501_DC_CRT_H_SYNC:
s->dc_crt_h_sync = value & 0x00FF0FFF;
break;
case SM501_DC_CRT_V_TOT:
s->dc_crt_v_total = value & 0x0FFF0FFF;
break;
case SM501_DC_CRT_V_SYNC:
s->dc_crt_v_sync = value & 0x003F0FFF;
break;
case SM501_DC_CRT_HWC_ADDR:
s->dc_crt_hwc_addr = value & 0x8FFFFFF0;
break;
case SM501_DC_CRT_HWC_LOC:
s->dc_crt_hwc_location = value & 0x0FFF0FFF;
break;
case SM501_DC_CRT_HWC_COLOR_1_2:
s->dc_crt_hwc_color_1_2 = value;
break;
case SM501_DC_CRT_HWC_COLOR_3:
s->dc_crt_hwc_color_3 = value & 0x0000FFFF;
break;
case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400 * 3 - 4:
sm501_palette_write(opaque, addr - SM501_DC_PANEL_PALETTE, value);
break;
default:
printf("sm501 disp ctrl : not implemented register write."
" addr=%x, val=%x\n", (int)addr, (unsigned)value);
abort();
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13855 | void rgb15to16(const uint8_t *src,uint8_t *dst,uint32_t src_size)
{
#ifdef HAVE_MMX
register const char* s=src+src_size;
register char* d=dst+src_size;
register int offs=-src_size;
__asm __volatile(PREFETCH" %0"::"m"(*(s+offs)):"memory");
__asm __volatile(
"movq %0, %%mm4\n\t"
"movq %1, %%mm5"
::"m"(mask15b), "m"(mask15rg):"memory");
while(offs<0)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm2\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm2, %%mm3\n\t"
"pand %%mm4, %%mm0\n\t"
"pand %%mm5, %%mm1\n\t"
"pand %%mm4, %%mm2\n\t"
"pand %%mm5, %%mm3\n\t"
"psllq $1, %%mm1\n\t"
"psllq $1, %%mm3\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm3, %%mm2\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*(d+offs))
:"m"(*(s+offs))
:"memory");
offs+=16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#else
const uint16_t *s1=( uint16_t * )src;
uint16_t *d1=( uint16_t * )dst;
uint16_t *e=((uint8_t *)s1)+src_size;
while( s1<e ){
register int x=*( s1++ );
/* rrrrrggggggbbbbb
0rrrrrgggggbbbbb
0111 1111 1110 0000=0x7FE0
00000000000001 1111=0x001F */
*( d1++ )=( x&0x001F )|( ( x&0x7FE0 )<<1 );
}
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13859 | static int rle_unpack(const unsigned char *src, unsigned char *dest,
int src_len, int dest_len)
{
const unsigned char *ps;
unsigned char *pd;
int i, l;
unsigned char *dest_end = dest + dest_len;
ps = src;
pd = dest;
if (src_len & 1)
*pd++ = *ps++;
src_len >>= 1;
i = 0;
do {
l = *ps++;
if (l & 0x80) {
l = (l & 0x7F) * 2;
if (pd + l > dest_end)
return ps - src;
memcpy(pd, ps, l);
ps += l;
pd += l;
} else {
if (pd + i > dest_end)
return ps - src;
for (i = 0; i < l; i++) {
*pd++ = ps[0];
*pd++ = ps[1];
}
ps += 2;
}
i += l;
} while (i < src_len);
return ps - src;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13867 | void ff_avg_h264_qpel16_mc33_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_and_aver_dst_16x16_msa(src + stride - 2,
src - (stride * 2) +
sizeof(uint8_t), stride,
dst, stride);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13888 | static int vorbis_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
VorbisParseContext *s = s1->priv_data;
int duration;
if (!s->vp && avctx->extradata && avctx->extradata_size) {
s->vp = av_vorbis_parse_init(avctx->extradata, avctx->extradata_size);
if (!s->vp)
goto end;
}
if ((duration = av_vorbis_parse_frame(s->vp, buf, buf_size)) >= 0)
s1->duration = duration;
end:
/* always return the full packet. this parser isn't doing any splitting or
combining, only packet analysis */
*poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13890 | static void xen_ram_init(PCMachineState *pcms,
ram_addr_t ram_size, MemoryRegion **ram_memory_p)
{
MemoryRegion *sysmem = get_system_memory();
ram_addr_t block_len;
uint64_t user_lowmem = object_property_get_int(qdev_get_machine(),
PC_MACHINE_MAX_RAM_BELOW_4G,
&error_abort);
/* Handle the machine opt max-ram-below-4g. It is basically doing
* min(xen limit, user limit).
*/
if (HVM_BELOW_4G_RAM_END <= user_lowmem) {
user_lowmem = HVM_BELOW_4G_RAM_END;
}
if (ram_size >= user_lowmem) {
pcms->above_4g_mem_size = ram_size - user_lowmem;
pcms->below_4g_mem_size = user_lowmem;
} else {
pcms->above_4g_mem_size = 0;
pcms->below_4g_mem_size = ram_size;
}
if (!pcms->above_4g_mem_size) {
block_len = ram_size;
} else {
/*
* Xen does not allocate the memory continuously, it keeps a
* hole of the size computed above or passed in.
*/
block_len = (1ULL << 32) + pcms->above_4g_mem_size;
}
memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len,
&error_abort);
*ram_memory_p = &ram_memory;
vmstate_register_ram_global(&ram_memory);
memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
&ram_memory, 0, 0xa0000);
memory_region_add_subregion(sysmem, 0, &ram_640k);
/* Skip of the VGA IO memory space, it will be registered later by the VGA
* emulated device.
*
* The area between 0xc0000 and 0x100000 will be used by SeaBIOS to load
* the Options ROM, so it is registered here as RAM.
*/
memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo",
&ram_memory, 0xc0000,
pcms->below_4g_mem_size - 0xc0000);
memory_region_add_subregion(sysmem, 0xc0000, &ram_lo);
if (pcms->above_4g_mem_size > 0) {
memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi",
&ram_memory, 0x100000000ULL,
pcms->above_4g_mem_size);
memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13897 | static void pci_spapr_set_irq(void *opaque, int irq_num, int level)
{
/*
* Here we use the number returned by pci_spapr_map_irq to find a
* corresponding qemu_irq.
*/
sPAPRPHBState *phb = opaque;
trace_spapr_pci_lsi_set(phb->busname, irq_num, phb->lsi_table[irq_num].irq);
qemu_set_irq(spapr_phb_lsi_qirq(phb, irq_num), level);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13899 | static int alloc_sequence_buffers(DiracContext *s)
{
int sbwidth = DIVRNDUP(s->source.width, 4);
int sbheight = DIVRNDUP(s->source.height, 4);
int i, w, h, top_padding;
/* todo: think more about this / use or set Plane here */
for (i = 0; i < 3; i++) {
int max_xblen = MAX_BLOCKSIZE >> (i ? s->chroma_x_shift : 0);
int max_yblen = MAX_BLOCKSIZE >> (i ? s->chroma_y_shift : 0);
w = s->source.width >> (i ? s->chroma_x_shift : 0);
h = s->source.height >> (i ? s->chroma_y_shift : 0);
/* we allocate the max we support here since num decompositions can
* change from frame to frame. Stride is aligned to 16 for SIMD, and
* 1<<MAX_DWT_LEVELS top padding to avoid if(y>0) in arith decoding
* MAX_BLOCKSIZE padding for MC: blocks can spill up to half of that
* on each side */
top_padding = FFMAX(1<<MAX_DWT_LEVELS, max_yblen/2);
w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
s->plane[i].idwt_buf_base = av_mallocz((w+max_xblen)*h * sizeof(IDWTELEM));
s->plane[i].idwt_tmp = av_malloc((w+16) * sizeof(IDWTELEM));
s->plane[i].idwt_buf = s->plane[i].idwt_buf_base + top_padding*w;
if (!s->plane[i].idwt_buf_base || !s->plane[i].idwt_tmp)
return AVERROR(ENOMEM);
}
w = s->source.width;
h = s->source.height;
/* fixme: allocate using real stride here */
s->sbsplit = av_malloc(sbwidth * sbheight);
s->blmotion = av_malloc(sbwidth * sbheight * 16 * sizeof(*s->blmotion));
s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h*MAX_BLOCKSIZE) * sizeof(*s->mctmp));
s->mcscratch = av_malloc((w+64)*MAX_BLOCKSIZE);
if (!s->sbsplit || !s->blmotion)
return AVERROR(ENOMEM);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13905 | static int hevc_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_hevc_ctx,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
const uint8_t *rtp_pl = buf;
int tid, lid, nal_type;
int first_fragment, last_fragment, fu_type;
uint8_t new_nal_header[2];
int res = 0;
/* sanity check for size of input packet: 1 byte payload at least */
if (len < RTP_HEVC_PAYLOAD_HEADER_SIZE + 1) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/HEVC packet, got %d bytes\n", len);
return AVERROR_INVALIDDATA;
}
/*
* decode the HEVC payload header according to section 4 of draft version 6:
*
* 0 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |F| Type | LayerId | TID |
* +-------------+-----------------+
*
* Forbidden zero (F): 1 bit
* NAL unit type (Type): 6 bits
* NUH layer ID (LayerId): 6 bits
* NUH temporal ID plus 1 (TID): 3 bits
*/
nal_type = (buf[0] >> 1) & 0x3f;
lid = ((buf[0] << 5) & 0x20) | ((buf[1] >> 3) & 0x1f);
tid = buf[1] & 0x07;
/* sanity check for correct layer ID */
if (lid) {
/* future scalable or 3D video coding extensions */
avpriv_report_missing_feature(ctx, "Multi-layer HEVC coding\n");
return AVERROR_PATCHWELCOME;
}
/* sanity check for correct temporal ID */
if (!tid) {
av_log(ctx, AV_LOG_ERROR, "Illegal temporal ID in RTP/HEVC packet\n");
return AVERROR_INVALIDDATA;
}
/* sanity check for correct NAL unit type */
if (nal_type > 50) {
av_log(ctx, AV_LOG_ERROR, "Unsupported (HEVC) NAL type (%d)\n", nal_type);
return AVERROR_INVALIDDATA;
}
switch (nal_type) {
/* video parameter set (VPS) */
case 32:
/* sequence parameter set (SPS) */
case 33:
/* picture parameter set (PPS) */
case 34:
/* supplemental enhancement information (SEI) */
case 39:
/* single NAL unit packet */
default:
/* sanity check for size of input packet: 1 byte payload at least */
if (len < 1) {
av_log(ctx, AV_LOG_ERROR,
"Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",
len, nal_type);
return AVERROR_INVALIDDATA;
}
/* create A/V packet */
if ((res = av_new_packet(pkt, sizeof(start_sequence) + len)) < 0)
return res;
/* A/V packet: copy start sequence */
memcpy(pkt->data, start_sequence, sizeof(start_sequence));
/* A/V packet: copy NAL unit data */
memcpy(pkt->data + sizeof(start_sequence), buf, len);
break;
/* aggregated packet (AP) - with two or more NAL units */
case 48:
/* pass the HEVC payload header */
buf += RTP_HEVC_PAYLOAD_HEADER_SIZE;
len -= RTP_HEVC_PAYLOAD_HEADER_SIZE;
/* pass the HEVC DONL field */
if (rtp_hevc_ctx->using_donl_field) {
buf += RTP_HEVC_DONL_FIELD_SIZE;
len -= RTP_HEVC_DONL_FIELD_SIZE;
}
res = ff_h264_handle_aggregated_packet(ctx, pkt, buf, len,
rtp_hevc_ctx->using_donl_field ?
RTP_HEVC_DOND_FIELD_SIZE : 0,
NULL, 0);
if (res < 0)
return res;
break;
/* fragmentation unit (FU) */
case 49:
/* pass the HEVC payload header */
buf += RTP_HEVC_PAYLOAD_HEADER_SIZE;
len -= RTP_HEVC_PAYLOAD_HEADER_SIZE;
/*
* decode the FU header
*
* 0 1 2 3 4 5 6 7
* +-+-+-+-+-+-+-+-+
* |S|E| FuType |
* +---------------+
*
* Start fragment (S): 1 bit
* End fragment (E): 1 bit
* FuType: 6 bits
*/
first_fragment = buf[0] & 0x80;
last_fragment = buf[0] & 0x40;
fu_type = buf[0] & 0x3f;
/* pass the HEVC FU header */
buf += RTP_HEVC_FU_HEADER_SIZE;
len -= RTP_HEVC_FU_HEADER_SIZE;
/* pass the HEVC DONL field */
if (rtp_hevc_ctx->using_donl_field) {
buf += RTP_HEVC_DONL_FIELD_SIZE;
len -= RTP_HEVC_DONL_FIELD_SIZE;
}
av_dlog(ctx, " FU type %d with %d bytes\n", fu_type, len);
if (len <= 0) {
/* sanity check for size of input packet: 1 byte payload at least */
av_log(ctx, AV_LOG_ERROR,
"Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",
len, nal_type);
return AVERROR_INVALIDDATA;
}
if (first_fragment && last_fragment) {
av_log(ctx, AV_LOG_ERROR, "Illegal combination of S and E bit in RTP/HEVC packet\n");
return AVERROR_INVALIDDATA;
}
new_nal_header[0] = (rtp_pl[0] & 0x81) | (fu_type << 1);
new_nal_header[1] = rtp_pl[1];
res = ff_h264_handle_frag_packet(pkt, buf, len, first_fragment,
new_nal_header, sizeof(new_nal_header));
break;
/* PACI packet */
case 50:
/* Temporal scalability control information (TSCI) */
avpriv_report_missing_feature(ctx, "PACI packets for RTP/HEVC\n");
res = AVERROR_PATCHWELCOME;
break;
}
pkt->stream_index = st->index;
return res;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13906 | int avpriv_lock_avformat(void)
{
if (lockmgr_cb) {
if ((*lockmgr_cb)(&avformat_mutex, AV_LOCK_OBTAIN))
return -1;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13915 | static int libschroedinger_encode_close(AVCodecContext *avctx)
{
SchroEncoderParams *p_schro_params = avctx->priv_data;
/* Close the encoder. */
schro_encoder_free(p_schro_params->encoder);
/* Free data in the output frame queue. */
ff_schro_queue_free(&p_schro_params->enc_frame_queue,
libschroedinger_free_frame);
/* Free the encoder buffer. */
if (p_schro_params->enc_buf_size)
av_freep(&p_schro_params->enc_buf);
/* Free the video format structure. */
av_freep(&p_schro_params->format);
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13943 | static int cinepak_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int ret = 0, buf_size = avpkt->size;
CinepakContext *s = avctx->priv_data;
s->data = buf;
s->size = buf_size;
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (s->palette_video) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
}
if ((ret = cinepak_decode(s)) < 0) {
av_log(avctx, AV_LOG_ERROR, "cinepak_decode failed\n");
}
if (s->palette_video)
memcpy (s->frame->data[1], s->pal, AVPALETTE_SIZE);
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
/* report that the buffer was completely consumed */
return buf_size;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13951 | static void taihu_405ep_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
char *filename;
qemu_irq *pic;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *bios;
MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories));
MemoryRegion *ram = g_malloc0(sizeof(*ram));
hwaddr ram_bases[2], ram_sizes[2];
long bios_size;
target_ulong kernel_base, initrd_base;
long kernel_size, initrd_size;
int linux_boot;
int fl_idx, fl_sectors;
DriveInfo *dinfo;
/* RAM is soldered to the board so the size cannot be changed */
ram_size = 0x08000000;
memory_region_allocate_system_memory(ram, NULL, "taihu_405ep.ram",
ram_size);
ram_bases[0] = 0;
ram_sizes[0] = 0x04000000;
memory_region_init_alias(&ram_memories[0], NULL,
"taihu_405ep.ram-0", ram, ram_bases[0],
ram_sizes[0]);
ram_bases[1] = 0x04000000;
ram_sizes[1] = 0x04000000;
memory_region_init_alias(&ram_memories[1], NULL,
"taihu_405ep.ram-1", ram, ram_bases[1],
ram_sizes[1]);
#ifdef DEBUG_BOARD_INIT
printf("%s: register cpu\n", __func__);
#endif
ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes,
33333333, &pic, kernel_filename == NULL ? 0 : 1);
/* allocate and load BIOS */
#ifdef DEBUG_BOARD_INIT
printf("%s: register BIOS\n", __func__);
#endif
fl_idx = 0;
#if defined(USE_FLASH_BIOS)
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
BlockDriverState *bs = blk_bs(blk_by_legacy_dinfo(dinfo));
bios_size = bdrv_getlength(bs);
/* XXX: should check that size is 2MB */
// bios_size = 2 * 1024 * 1024;
fl_sectors = (bios_size + 65535) >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at addr %lx '%s' %d\n",
fl_idx, bios_size, -bios_size,
bdrv_get_device_name(bs), fl_sectors);
#endif
pflash_cfi02_register((uint32_t)(-bios_size),
NULL, "taihu_405ep.bios", bios_size,
bs, 65536, fl_sectors, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
} else
#endif
{
#ifdef DEBUG_BOARD_INIT
printf("Load BIOS from file\n");
#endif
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
bios = g_new(MemoryRegion, 1);
memory_region_init_ram(bios, NULL, "taihu_405ep.bios", BIOS_SIZE,
&error_abort);
vmstate_register_ram_global(bios);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
g_free(filename);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
error_report("Could not load PowerPC BIOS '%s'", bios_name);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
} else if (!qtest_enabled()) {
error_report("Could not load PowerPC BIOS '%s'", bios_name);
exit(1);
}
memory_region_set_readonly(bios, true);
}
/* Register Linux flash */
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
BlockDriverState *bs = blk_bs(blk_by_legacy_dinfo(dinfo));
bios_size = bdrv_getlength(bs);
/* XXX: should check that size is 32MB */
bios_size = 32 * 1024 * 1024;
fl_sectors = (bios_size + 65535) >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at addr " TARGET_FMT_lx " '%s'\n",
fl_idx, bios_size, (target_ulong)0xfc000000,
bdrv_get_device_name(bs));
#endif
pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size,
bs, 65536, fl_sectors, 1,
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
}
/* Register CLPD & LCD display */
#ifdef DEBUG_BOARD_INIT
printf("%s: register CPLD\n", __func__);
#endif
taihu_cpld_init(sysmem, 0x50100000);
/* Load kernel */
linux_boot = (kernel_filename != NULL);
if (linux_boot) {
#ifdef DEBUG_BOARD_INIT
printf("%s: load kernel\n", __func__);
#endif
kernel_base = KERNEL_LOAD_ADDR;
/* now we can load the kernel */
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
/* load initrd */
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr,
"qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
#ifdef DEBUG_BOARD_INIT
printf("%s: Done\n", __func__);
#endif
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_13969 | static void *ff_avio_child_next(void *obj, void *prev)
{
AVIOContext *s = obj;
AVIOInternal *internal = s->opaque;
return prev ? NULL : internal->h;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_13988 | static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,
uint64_t *data)
{
PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);
uint32_t val;
switch(addr) {
case 0x00:
val = acpi_pm1_evt_get_sts(&s->ar, s->ar.tmr.overflow_time);
break;
case 0x02:
val = s->ar.pm1.evt.en;
break;
case 0x04:
val = s->ar.pm1.cnt.cnt;
break;
case 0x08:
val = acpi_pm_tmr_get(&s->ar);
break;
default:
val = 0;
break;
}
PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", (unsigned int)addr, val);
*data = val;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14014 | static int update_dimensions(VP8Context *s, int width, int height)
{
if (width != s->avctx->width ||
height != s->avctx->height) {
if (av_image_check_size(width, height, 0, s->avctx))
return AVERROR_INVALIDDATA;
vp8_decode_flush_impl(s->avctx, 1, 0, 1);
avcodec_set_dimensions(s->avctx, width, height);
}
s->mb_width = (s->avctx->coded_width +15) / 16;
s->mb_height = (s->avctx->coded_height+15) / 16;
s->macroblocks_base = av_mallocz((s->mb_width+s->mb_height*2+1)*sizeof(*s->macroblocks));
s->filter_strength = av_mallocz(s->mb_width*sizeof(*s->filter_strength));
s->intra4x4_pred_mode_top = av_mallocz(s->mb_width*4);
s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz));
s->top_border = av_mallocz((s->mb_width+1)*sizeof(*s->top_border));
if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_top ||
!s->top_nnz || !s->top_border)
return AVERROR(ENOMEM);
s->macroblocks = s->macroblocks_base + 1;
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14022 | int nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp)
{
int ret;
const char *type;
ret = nbd_read_eof(ioc, &reply->magic, sizeof(reply->magic), errp);
if (ret <= 0) {
return ret;
}
be32_to_cpus(&reply->magic);
switch (reply->magic) {
case NBD_SIMPLE_REPLY_MAGIC:
ret = nbd_receive_simple_reply(ioc, &reply->simple, errp);
if (ret < 0) {
break;
}
trace_nbd_receive_simple_reply(reply->simple.error,
nbd_err_lookup(reply->simple.error),
reply->handle);
if (reply->simple.error == NBD_ESHUTDOWN) {
/* This works even on mingw which lacks a native ESHUTDOWN */
error_setg(errp, "server shutting down");
return -EINVAL;
}
break;
case NBD_STRUCTURED_REPLY_MAGIC:
ret = nbd_receive_structured_reply_chunk(ioc, &reply->structured, errp);
if (ret < 0) {
break;
}
type = nbd_reply_type_lookup(reply->structured.type);
trace_nbd_receive_structured_reply_chunk(reply->structured.flags,
reply->structured.type, type,
reply->structured.handle,
reply->structured.length);
break;
default:
error_setg(errp, "invalid magic (got 0x%" PRIx32 ")", reply->magic);
return -EINVAL;
}
if (ret < 0) {
return ret;
}
return 1;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14023 | static void ne2000_receive(void *opaque, const uint8_t *buf, int size)
{
NE2000State *s = opaque;
uint8_t *p;
int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received len=%d\n", size);
#endif
if (!ne2000_can_receive(s))
return;
/* XXX: check this */
if (s->rxcr & 0x10) {
/* promiscuous: receive all */
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
/* broadcast address */
if (!(s->rxcr & 0x04))
return;
} else if (buf[0] & 0x01) {
/* multicast */
if (!(s->rxcr & 0x08))
return;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
return;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
/* match */
} else {
return;
}
}
/* if too small buffer, then expand it */
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
index = s->curpag << 8;
/* 4 bytes for header */
total_len = size + 4;
/* address for next packet (4 bytes for CRC) */
next = index + ((total_len + 4 + 255) & ~0xff);
if (next >= s->stop)
next -= (s->stop - s->start);
/* prepare packet header */
p = s->mem + index;
s->rsr = ENRSR_RXOK; /* receive status */
/* XXX: check this */
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = next >> 8;
p[2] = total_len;
p[3] = total_len >> 8;
index += 4;
/* write packet data */
while (size > 0) {
avail = s->stop - index;
len = size;
if (len > avail)
len = avail;
memcpy(s->mem + index, buf, len);
buf += len;
index += len;
if (index == s->stop)
index = s->start;
size -= len;
}
s->curpag = next >> 8;
/* now we can signal we have receive something */
s->isr |= ENISR_RX;
ne2000_update_irq(s);
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14024 | static void truespeech_apply_twopoint_filter(TSContext *dec, int quart)
{
int16_t tmp[146 + 60], *ptr0, *ptr1;
const int16_t *filter;
int i, t, off;
t = dec->offset2[quart];
if(t == 127){
memset(dec->newvec, 0, 60 * sizeof(*dec->newvec));
return;
}
for(i = 0; i < 146; i++)
tmp[i] = dec->filtbuf[i];
off = (t / 25) + dec->offset1[quart >> 1] + 18;
ptr0 = tmp + 145 - off;
ptr1 = tmp + 146;
filter = (const int16_t*)ts_order2_coeffs + (t % 25) * 2;
for(i = 0; i < 60; i++){
t = (ptr0[0] * filter[0] + ptr0[1] * filter[1] + 0x2000) >> 14;
ptr0++;
dec->newvec[i] = t;
ptr1[i] = t;
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14025 | static void scsi_disk_purge_requests(SCSIDiskState *s)
{
SCSIDiskReq *r;
while (!QTAILQ_EMPTY(&s->qdev.requests)) {
r = DO_UPCAST(SCSIDiskReq, req, QTAILQ_FIRST(&s->qdev.requests));
if (r->req.aiocb) {
bdrv_aio_cancel(r->req.aiocb);
}
scsi_remove_request(r);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14031 | static int net_slirp_init(VLANState *vlan)
{
if (!slirp_inited) {
slirp_inited = 1;
slirp_init();
}
slirp_vc = qemu_new_vlan_client(vlan,
slirp_receive, NULL);
snprintf(slirp_vc->info_str, sizeof(slirp_vc->info_str), "user redirector");
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14056 | static int pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
char buf1[32], tuple_type[32];
int h, w, depth, maxval;;
pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "P4")) {
avctx->pix_fmt = PIX_FMT_MONOWHITE;
} else if (!strcmp(buf1, "P5")) {
if (avctx->codec_id == CODEC_ID_PGMYUV)
avctx->pix_fmt = PIX_FMT_YUV420P;
else
avctx->pix_fmt = PIX_FMT_GRAY8;
} else if (!strcmp(buf1, "P6")) {
avctx->pix_fmt = PIX_FMT_RGB24;
} else if (!strcmp(buf1, "P7")) {
w = -1;
h = -1;
maxval = -1;
depth = -1;
tuple_type[0] = '\0';
for(;;) {
pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "WIDTH")) {
pnm_get(s, buf1, sizeof(buf1));
w = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "HEIGHT")) {
pnm_get(s, buf1, sizeof(buf1));
h = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "DEPTH")) {
pnm_get(s, buf1, sizeof(buf1));
depth = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "MAXVAL")) {
pnm_get(s, buf1, sizeof(buf1));
maxval = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "TUPLETYPE")) {
pnm_get(s, tuple_type, sizeof(tuple_type));
} else if (!strcmp(buf1, "ENDHDR")) {
break;
} else {
return -1;
}
}
/* check that all tags are present */
if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0')
return -1;
avctx->width = w;
avctx->height = h;
if (depth == 1) {
if (maxval == 1)
avctx->pix_fmt = PIX_FMT_MONOWHITE;
else
avctx->pix_fmt = PIX_FMT_GRAY8;
} else if (depth == 3) {
avctx->pix_fmt = PIX_FMT_RGB24;
} else if (depth == 4) {
avctx->pix_fmt = PIX_FMT_RGBA32;
} else {
return -1;
}
return 0;
} else {
return -1;
}
pnm_get(s, buf1, sizeof(buf1));
avctx->width = atoi(buf1);
if (avctx->width <= 0)
return -1;
pnm_get(s, buf1, sizeof(buf1));
avctx->height = atoi(buf1);
if (avctx->height <= 0)
return -1;
if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
pnm_get(s, buf1, sizeof(buf1));
}
/* more check if YUV420 */
if (avctx->pix_fmt == PIX_FMT_YUV420P) {
if ((avctx->width & 1) != 0)
return -1;
h = (avctx->height * 2);
if ((h % 3) != 0)
return -1;
h /= 3;
avctx->height = h;
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14076 | void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
int len, int is_write)
{
return address_space_rw(&address_space_memory, addr, buf, len, is_write);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14090 | static void v9fs_link(void *opaque)
{
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
int32_t dfid, oldfid;
V9fsFidState *dfidp, *oldfidp;
V9fsString name;
size_t offset = 7;
int err = 0;
pdu_unmarshal(pdu, offset, "dds", &dfid, &oldfid, &name);
trace_v9fs_link(pdu->tag, pdu->id, dfid, oldfid, name.data);
dfidp = get_fid(pdu, dfid);
if (dfidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
oldfidp = get_fid(pdu, oldfid);
if (oldfidp == NULL) {
err = -ENOENT;
goto out;
}
err = v9fs_co_link(pdu, oldfidp, dfidp, &name);
if (!err) {
err = offset;
}
out:
put_fid(pdu, dfidp);
out_nofid:
v9fs_string_free(&name);
complete_pdu(s, pdu, err);
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14108 | int dxva2_init(AVCodecContext *s)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx;
int ret;
if (!ist->hwaccel_ctx) {
ret = dxva2_alloc(s);
if (ret < 0)
return ret;
}
ctx = ist->hwaccel_ctx;
if (s->codec_id == AV_CODEC_ID_H264 &&
(s->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) {
av_log(NULL, loglevel, "Unsupported H.264 profile for DXVA2 HWAccel: %d\n", s->profile);
return AVERROR(EINVAL);
}
if (s->codec_id == AV_CODEC_ID_HEVC &&
s->profile != FF_PROFILE_HEVC_MAIN && s->profile != FF_PROFILE_HEVC_MAIN_10) {
av_log(NULL, loglevel, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", s->profile);
return AVERROR(EINVAL);
}
av_buffer_unref(&ctx->hw_frames_ctx);
ret = dxva2_create_decoder(s);
if (ret < 0) {
av_log(NULL, loglevel, "Error creating the DXVA2 decoder\n");
return ret;
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14126 | static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
XenPTRegInfo *reg)
{
PCIDevice *d = &s->dev;
XenPTRegion *region = NULL;
PCIIORegion *r;
int index = 0;
/* check 64bit BAR */
index = xen_pt_bar_offset_to_index(reg->offset);
if ((0 < index) && (index < PCI_ROM_SLOT)) {
int type = s->real_device.io_regions[index - 1].type;
if ((type & XEN_HOST_PCI_REGION_TYPE_MEM)
&& (type & XEN_HOST_PCI_REGION_TYPE_MEM_64)) {
region = &s->bases[index - 1];
if (region->bar_flag != XEN_PT_BAR_FLAG_UPPER) {
return XEN_PT_BAR_FLAG_UPPER;
}
}
}
/* check unused BAR */
r = &d->io_regions[index];
if (!xen_pt_get_bar_size(r)) {
return XEN_PT_BAR_FLAG_UNUSED;
}
/* for ExpROM BAR */
if (index == PCI_ROM_SLOT) {
return XEN_PT_BAR_FLAG_MEM;
}
/* check BAR I/O indicator */
if (s->real_device.io_regions[index].type & XEN_HOST_PCI_REGION_TYPE_IO) {
return XEN_PT_BAR_FLAG_IO;
} else {
return XEN_PT_BAR_FLAG_MEM;
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14141 | static av_cold int g726_encode_init(AVCodecContext *avctx)
{
G726Context* c = avctx->priv_data;
if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rates other than 8kHz are not "
"allowed when the compliance level is higher than unofficial. "
"Resample or reduce the compliance level.\n");
return AVERROR(EINVAL);
}
if (avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR, "Samplerate is invalid\n");
return -1;
}
if(avctx->channels != 1){
av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
return -1;
}
if (avctx->bit_rate % avctx->sample_rate) {
av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");
return AVERROR(EINVAL);
}
c->code_size = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate;
if (c->code_size < 2 || c->code_size > 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", c->code_size);
return AVERROR(EINVAL);
}
avctx->bits_per_coded_sample = c->code_size;
g726_reset(c, c->code_size - 2);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
/* select a frame size that will end on a byte boundary and have a size of
approximately 1024 bytes */
avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2];
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14144 | static int dv_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
RawDVContext *r = s->priv_data;
DVDemuxContext *c = r->dv_demux;
int64_t offset = dv_frame_offset(s, c, timestamp, flags);
dv_offset_reset(c, offset / c->sys->frame_size);
offset = avio_seek(s->pb, offset, SEEK_SET);
return (offset < 0) ? offset : 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14162 | static void spapr_phb_hot_plug_child(HotplugHandler *plug_handler,
DeviceState *plugged_dev, Error **errp)
{
sPAPRPHBState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
PCIDevice *pdev = PCI_DEVICE(plugged_dev);
sPAPRDRConnector *drc = spapr_phb_get_pci_drc(phb, pdev);
Error *local_err = NULL;
/* if DR is disabled we don't need to do anything in the case of
* hotplug or coldplug callbacks
*/
if (!phb->dr_enabled) {
/* if this is a hotplug operation initiated by the user
* we need to let them know it's not enabled
*/
if (plugged_dev->hotplugged) {
error_setg(errp, QERR_BUS_NO_HOTPLUG,
object_get_typename(OBJECT(phb)));
}
return;
}
g_assert(drc);
spapr_phb_add_pci_device(drc, phb, pdev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (plugged_dev->hotplugged) {
spapr_hotplug_req_add_by_index(drc);
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14168 | av_cold int ff_dvvideo_init(AVCodecContext *avctx)
{
DVVideoContext *s = avctx->priv_data;
DSPContext dsp;
static int done = 0;
int i, j;
if (!done) {
VLC dv_vlc;
uint16_t new_dv_vlc_bits[NB_DV_VLC*2];
uint8_t new_dv_vlc_len[NB_DV_VLC*2];
uint8_t new_dv_vlc_run[NB_DV_VLC*2];
int16_t new_dv_vlc_level[NB_DV_VLC*2];
done = 1;
/* it's faster to include sign bit in a generic VLC parsing scheme */
for (i = 0, j = 0; i < NB_DV_VLC; i++, j++) {
new_dv_vlc_bits[j] = dv_vlc_bits[i];
new_dv_vlc_len[j] = dv_vlc_len[i];
new_dv_vlc_run[j] = dv_vlc_run[i];
new_dv_vlc_level[j] = dv_vlc_level[i];
if (dv_vlc_level[i]) {
new_dv_vlc_bits[j] <<= 1;
new_dv_vlc_len[j]++;
j++;
new_dv_vlc_bits[j] = (dv_vlc_bits[i] << 1) | 1;
new_dv_vlc_len[j] = dv_vlc_len[i] + 1;
new_dv_vlc_run[j] = dv_vlc_run[i];
new_dv_vlc_level[j] = -dv_vlc_level[i];
}
}
/* NOTE: as a trick, we use the fact the no codes are unused
to accelerate the parsing of partial codes */
init_vlc(&dv_vlc, TEX_VLC_BITS, j,
new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0);
assert(dv_vlc.table_size == 1184);
for (i = 0; i < dv_vlc.table_size; i++){
int code = dv_vlc.table[i][0];
int len = dv_vlc.table[i][1];
int level, run;
if (len < 0){ //more bits needed
run = 0;
level = code;
} else {
run = new_dv_vlc_run [code] + 1;
level = new_dv_vlc_level[code];
}
ff_dv_rl_vlc[i].len = len;
ff_dv_rl_vlc[i].level = level;
ff_dv_rl_vlc[i].run = run;
}
ff_free_vlc(&dv_vlc);
}
/* Generic DSP setup */
ff_dsputil_init(&dsp, avctx);
ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp);
s->get_pixels = dsp.get_pixels;
s->ildct_cmp = dsp.ildct_cmp[5];
/* 88DCT setup */
s->fdct[0] = dsp.fdct;
s->idct_put[0] = dsp.idct_put;
for (i = 0; i < 64; i++)
s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]];
/* 248DCT setup */
s->fdct[1] = dsp.fdct248;
s->idct_put[1] = ff_simple_idct248_put; // FIXME: need to add it to DSP
memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64);
avctx->coded_frame = &s->picture;
s->avctx = avctx;
avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14199 | static int libquvi_read_header(AVFormatContext *s)
{
int i, ret;
quvi_t q;
quvi_media_t m;
QUVIcode rc;
LibQuviContext *qc = s->priv_data;
char *media_url, *pagetitle;
rc = quvi_init(&q);
if (rc != QUVI_OK)
goto quvi_fail;
quvi_setopt(q, QUVIOPT_FORMAT, qc->format);
rc = quvi_parse(q, s->filename, &m);
if (rc != QUVI_OK)
goto quvi_fail;
rc = quvi_getprop(m, QUVIPROP_MEDIAURL, &media_url);
if (rc != QUVI_OK)
goto quvi_fail;
av_assert0(!qc->fmtctx->codec_whitelist && !qc->fmtctx->format_whitelist);
qc->fmtctx-> codec_whitelist = av_strdup(s->codec_whitelist);
qc->fmtctx->format_whitelist = av_strdup(s->format_whitelist);
ret = avformat_open_input(&qc->fmtctx, media_url, NULL, NULL);
if (ret < 0)
goto end;
rc = quvi_getprop(m, QUVIPROP_PAGETITLE, &pagetitle);
if (rc == QUVI_OK)
av_dict_set(&s->metadata, "title", pagetitle, 0);
for (i = 0; i < qc->fmtctx->nb_streams; i++) {
AVStream *st = avformat_new_stream(s, NULL);
AVStream *ist = qc->fmtctx->streams[i];
if (!st) {
ret = AVERROR(ENOMEM);
goto end;
}
avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
avcodec_copy_context(st->codec, qc->fmtctx->streams[i]->codec);
}
return 0;
quvi_fail:
av_log(s, AV_LOG_ERROR, "%s\n", quvi_strerror(q, rc));
ret = AVERROR_EXTERNAL;
end:
quvi_parse_close(&m);
quvi_close(&q);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14220 | static int add_old_style_options(const char *fmt, QemuOpts *opts,
const char *base_filename,
const char *base_fmt)
{
if (base_filename) {
if (qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename)) {
error_report("Backing file not supported for file format '%s'",
fmt);
return -1;
}
}
if (base_fmt) {
if (qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt)) {
error_report("Backing file format not supported for file "
"format '%s'", fmt);
return -1;
}
}
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14228 | void qemu_flush_queued_packets(VLANClientState *vc)
{
while (!TAILQ_EMPTY(&vc->vlan->send_queue)) {
VLANPacket *packet;
int ret;
packet = TAILQ_FIRST(&vc->vlan->send_queue);
TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);
ret = qemu_deliver_packet(packet->sender, packet->data, packet->size);
if (ret == 0 && packet->sent_cb != NULL) {
TAILQ_INSERT_HEAD(&vc->vlan->send_queue, packet, entry);
break;
}
if (packet->sent_cb)
packet->sent_cb(packet->sender, ret);
qemu_free(packet);
}
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14248 | LF_FUNC (h, luma, sse2)
LF_IFUNC(h, luma_intra, sse2)
LF_FUNC (v, luma, sse2)
LF_IFUNC(v, luma_intra, sse2)
/***********************************/
/* weighted prediction */
#define H264_WEIGHT(W, H, OPT) \
void ff_h264_weight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \
int stride, int log2_denom, int weight, int offset);
#define H264_BIWEIGHT(W, H, OPT) \
void ff_h264_biweight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \
uint8_t *src, int stride, int log2_denom, int weightd, \
int weights, int offset);
#define H264_BIWEIGHT_MMX(W,H) \
H264_WEIGHT (W, H, mmx2) \
H264_BIWEIGHT(W, H, mmx2)
#define H264_BIWEIGHT_MMX_SSE(W,H) \
H264_BIWEIGHT_MMX(W, H) \
H264_WEIGHT (W, H, sse2) \
H264_BIWEIGHT (W, H, sse2) \
H264_BIWEIGHT (W, H, ssse3)
H264_BIWEIGHT_MMX_SSE(16, 16)
H264_BIWEIGHT_MMX_SSE(16, 8)
H264_BIWEIGHT_MMX_SSE( 8, 16)
H264_BIWEIGHT_MMX_SSE( 8, 8)
H264_BIWEIGHT_MMX_SSE( 8, 4)
H264_BIWEIGHT_MMX ( 4, 8)
H264_BIWEIGHT_MMX ( 4, 4)
H264_BIWEIGHT_MMX ( 4, 2)
void ff_h264dsp_init_x86(H264DSPContext *c)
{
int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX2) {
c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
}
#if HAVE_YASM
if (mm_flags & AV_CPU_FLAG_MMX) {
c->h264_idct_dc_add=
c->h264_idct_add= ff_h264_idct_add_mmx;
c->h264_idct8_dc_add=
c->h264_idct8_add= ff_h264_idct8_add_mmx;
c->h264_idct_add16 = ff_h264_idct_add16_mmx;
c->h264_idct8_add4 = ff_h264_idct8_add4_mmx;
c->h264_idct_add8 = ff_h264_idct_add8_mmx;
c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
if (mm_flags & AV_CPU_FLAG_MMX2) {
c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
c->h264_idct_add16 = ff_h264_idct_add16_mmx2;
c->h264_idct8_add4 = ff_h264_idct8_add4_mmx2;
c->h264_idct_add8 = ff_h264_idct_add8_mmx2;
c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2;
c->h264_v_loop_filter_chroma= ff_x264_deblock_v_chroma_mmxext;
c->h264_h_loop_filter_chroma= ff_x264_deblock_h_chroma_mmxext;
c->h264_v_loop_filter_chroma_intra= ff_x264_deblock_v_chroma_intra_mmxext;
c->h264_h_loop_filter_chroma_intra= ff_x264_deblock_h_chroma_intra_mmxext;
#if ARCH_X86_32
c->h264_v_loop_filter_luma= ff_x264_deblock_v_luma_mmxext;
c->h264_h_loop_filter_luma= ff_x264_deblock_h_luma_mmxext;
c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_mmxext;
c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_mmxext;
c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
if (mm_flags&AV_CPU_FLAG_SSE2) {
c->h264_idct8_add = ff_h264_idct8_add_sse2;
c->h264_idct8_add4= ff_h264_idct8_add4_sse2;
c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_sse2;
c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_sse2;
c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_sse2;
c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_sse2;
c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_sse2;
c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_sse2;
c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_sse2;
c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_sse2;
c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_sse2;
c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_sse2;
c->h264_v_loop_filter_luma = ff_x264_deblock_v_luma_sse2;
c->h264_h_loop_filter_luma = ff_x264_deblock_h_luma_sse2;
c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_sse2;
c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_sse2;
c->h264_idct_add16 = ff_h264_idct_add16_sse2;
c->h264_idct_add8 = ff_h264_idct_add8_sse2;
c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
}
if (mm_flags&AV_CPU_FLAG_SSSE3) {
c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_ssse3;
c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_ssse3;
c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_ssse3;
c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_ssse3;
}
}
}
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14263 | static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
AVCodecContext *avctx)
{
int plane, band_num, indx, transform_id, scan_indx;
int i;
plane = get_bits(&ctx->gb, 2);
band_num = get_bits(&ctx->gb, 4);
if (band->plane != plane || band->band_num != band_num) {
av_log(avctx, AV_LOG_ERROR, "Invalid band header sequence!\n");
return AVERROR_INVALIDDATA;
}
band->is_empty = get_bits1(&ctx->gb);
if (!band->is_empty) {
int old_blk_size = band->blk_size;
/* skip header size
* If header size is not given, header size is 4 bytes. */
if (get_bits1(&ctx->gb))
skip_bits(&ctx->gb, 16);
band->is_halfpel = get_bits(&ctx->gb, 2);
if (band->is_halfpel >= 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported mv resolution: %d!\n",
band->is_halfpel);
return AVERROR_INVALIDDATA;
}
#if IVI4_STREAM_ANALYSER
if (!band->is_halfpel)
ctx->uses_fullpel = 1;
#endif
band->checksum_present = get_bits1(&ctx->gb);
if (band->checksum_present)
band->checksum = get_bits(&ctx->gb, 16);
indx = get_bits(&ctx->gb, 2);
if (indx == 3) {
av_log(avctx, AV_LOG_ERROR, "Invalid block size!\n");
return AVERROR_INVALIDDATA;
}
band->mb_size = 16 >> indx;
band->blk_size = 8 >> (indx >> 1);
band->inherit_mv = get_bits1(&ctx->gb);
band->inherit_qdelta = get_bits1(&ctx->gb);
band->glob_quant = get_bits(&ctx->gb, 5);
if (!get_bits1(&ctx->gb) || ctx->frame_type == IVI4_FRAMETYPE_INTRA) {
transform_id = get_bits(&ctx->gb, 5);
if (transform_id >= FF_ARRAY_ELEMS(transforms) ||
!transforms[transform_id].inv_trans) {
avpriv_request_sample(avctx, "Transform %d", transform_id);
return AVERROR_PATCHWELCOME;
}
if ((transform_id >= 7 && transform_id <= 9) ||
transform_id == 17) {
avpriv_request_sample(avctx, "DCT transform");
return AVERROR_PATCHWELCOME;
}
#if IVI4_STREAM_ANALYSER
if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10)
ctx->uses_haar = 1;
#endif
band->inv_transform = transforms[transform_id].inv_trans;
band->dc_transform = transforms[transform_id].dc_trans;
band->is_2d_trans = transforms[transform_id].is_2d_trans;
if (transform_id < 10)
band->transform_size = 8;
else
band->transform_size = 4;
if (band->blk_size != band->transform_size)
return AVERROR_INVALIDDATA;
scan_indx = get_bits(&ctx->gb, 4);
if (scan_indx == 15) {
av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n");
return AVERROR_INVALIDDATA;
}
if (scan_indx > 4 && scan_indx < 10) {
if (band->blk_size != 4)
return AVERROR_INVALIDDATA;
} else if (band->blk_size != 8)
return AVERROR_INVALIDDATA;
band->scan = scan_index_to_tab[scan_indx];
band->quant_mat = get_bits(&ctx->gb, 5);
if (band->quant_mat >= FF_ARRAY_ELEMS(quant_index_to_tab)) {
if (band->quant_mat == 31)
av_log(avctx, AV_LOG_ERROR,
"Custom quant matrix encountered!\n");
else
avpriv_request_sample(avctx, "Quantization matrix %d",
band->quant_mat);
band->quant_mat = -1;
return AVERROR_INVALIDDATA;
}
} else {
if (old_blk_size != band->blk_size) {
av_log(avctx, AV_LOG_ERROR,
"The band block size does not match the configuration "
"inherited\n");
return AVERROR_INVALIDDATA;
}
if (band->quant_mat < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid quant_mat inherited\n");
return AVERROR_INVALIDDATA;
}
}
/* decode block huffman codebook */
if (!get_bits1(&ctx->gb))
band->blk_vlc.tab = ctx->blk_vlc.tab;
else
if (ff_ivi_dec_huff_desc(&ctx->gb, 1, IVI_BLK_HUFF,
&band->blk_vlc, avctx))
return AVERROR_INVALIDDATA;
/* select appropriate rvmap table for this band */
band->rvmap_sel = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 3) : 8;
/* decode rvmap probability corrections if any */
band->num_corr = 0; /* there is no corrections */
if (get_bits1(&ctx->gb)) {
band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
if (band->num_corr > 61) {
av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
band->num_corr);
return AVERROR_INVALIDDATA;
}
/* read correction pairs */
for (i = 0; i < band->num_corr * 2; i++)
band->corr[i] = get_bits(&ctx->gb, 8);
}
}
if (band->blk_size == 8) {
band->intra_base = &ivi4_quant_8x8_intra[quant_index_to_tab[band->quant_mat]][0];
band->inter_base = &ivi4_quant_8x8_inter[quant_index_to_tab[band->quant_mat]][0];
} else {
band->intra_base = &ivi4_quant_4x4_intra[quant_index_to_tab[band->quant_mat]][0];
band->inter_base = &ivi4_quant_4x4_inter[quant_index_to_tab[band->quant_mat]][0];
}
/* Indeo 4 doesn't use scale tables */
band->intra_scale = NULL;
band->inter_scale = NULL;
align_get_bits(&ctx->gb);
return 0;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14289 | long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6)
{
long ret;
struct stat st;
struct kernel_statfs *stfs;
#ifdef DEBUG
gemu_log("syscall %d\n", num);
#endif
switch(num) {
case TARGET_NR_exit:
#ifdef HAVE_GPROF
_mcleanup();
#endif
_exit(arg1);
ret = 0; /* avoid warning */
break;
case TARGET_NR_read:
ret = get_errno(read(arg1, (void *)arg2, arg3));
break;
case TARGET_NR_write:
ret = get_errno(write(arg1, (void *)arg2, arg3));
break;
case TARGET_NR_open:
ret = get_errno(open((const char *)arg1, arg2, arg3));
break;
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
case TARGET_NR_brk:
ret = do_brk((char *)arg1);
break;
case TARGET_NR_fork:
ret = get_errno(fork());
break;
case TARGET_NR_waitpid:
{
int *status = (int *)arg2;
ret = get_errno(waitpid(arg1, status, arg3));
if (!is_error(ret) && status)
tswapls((long *)&status);
}
break;
case TARGET_NR_creat:
ret = get_errno(creat((const char *)arg1, arg2));
break;
case TARGET_NR_link:
ret = get_errno(link((const char *)arg1, (const char *)arg2));
break;
case TARGET_NR_unlink:
ret = get_errno(unlink((const char *)arg1));
break;
case TARGET_NR_execve:
ret = get_errno(execve((const char *)arg1, (void *)arg2, (void *)arg3));
break;
case TARGET_NR_chdir:
ret = get_errno(chdir((const char *)arg1));
break;
case TARGET_NR_time:
{
int *time_ptr = (int *)arg1;
ret = get_errno(time((time_t *)time_ptr));
if (!is_error(ret) && time_ptr)
tswap32s(time_ptr);
}
break;
case TARGET_NR_mknod:
ret = get_errno(mknod((const char *)arg1, arg2, arg3));
break;
case TARGET_NR_chmod:
ret = get_errno(chmod((const char *)arg1, arg2));
break;
case TARGET_NR_lchown:
ret = get_errno(chown((const char *)arg1, arg2, arg3));
break;
case TARGET_NR_break:
goto unimplemented;
case TARGET_NR_oldstat:
goto unimplemented;
case TARGET_NR_lseek:
ret = get_errno(lseek(arg1, arg2, arg3));
break;
case TARGET_NR_getpid:
ret = get_errno(getpid());
break;
case TARGET_NR_mount:
/* need to look at the data field */
goto unimplemented;
case TARGET_NR_umount:
ret = get_errno(umount((const char *)arg1));
break;
case TARGET_NR_setuid:
ret = get_errno(setuid(arg1));
break;
case TARGET_NR_getuid:
ret = get_errno(getuid());
break;
case TARGET_NR_stime:
{
int *time_ptr = (int *)arg1;
if (time_ptr)
tswap32s(time_ptr);
ret = get_errno(stime((time_t *)time_ptr));
}
break;
case TARGET_NR_ptrace:
goto unimplemented;
case TARGET_NR_alarm:
ret = alarm(arg1);
break;
case TARGET_NR_oldfstat:
goto unimplemented;
case TARGET_NR_pause:
ret = get_errno(pause());
break;
case TARGET_NR_utime:
goto unimplemented;
case TARGET_NR_stty:
goto unimplemented;
case TARGET_NR_gtty:
goto unimplemented;
case TARGET_NR_access:
ret = get_errno(access((const char *)arg1, arg2));
break;
case TARGET_NR_nice:
ret = get_errno(nice(arg1));
break;
case TARGET_NR_ftime:
goto unimplemented;
case TARGET_NR_sync:
ret = get_errno(sync());
break;
case TARGET_NR_kill:
ret = get_errno(kill(arg1, arg2));
break;
case TARGET_NR_rename:
ret = get_errno(rename((const char *)arg1, (const char *)arg2));
break;
case TARGET_NR_mkdir:
ret = get_errno(mkdir((const char *)arg1, arg2));
break;
case TARGET_NR_rmdir:
ret = get_errno(rmdir((const char *)arg1));
break;
case TARGET_NR_dup:
ret = get_errno(dup(arg1));
break;
case TARGET_NR_pipe:
{
int *pipe_ptr = (int *)arg1;
ret = get_errno(pipe(pipe_ptr));
if (!is_error(ret)) {
tswap32s(&pipe_ptr[0]);
tswap32s(&pipe_ptr[1]);
}
}
break;
case TARGET_NR_times:
goto unimplemented;
case TARGET_NR_prof:
goto unimplemented;
case TARGET_NR_setgid:
ret = get_errno(setgid(arg1));
break;
case TARGET_NR_getgid:
ret = get_errno(getgid());
break;
case TARGET_NR_signal:
goto unimplemented;
case TARGET_NR_geteuid:
ret = get_errno(geteuid());
break;
case TARGET_NR_getegid:
ret = get_errno(getegid());
break;
case TARGET_NR_acct:
goto unimplemented;
case TARGET_NR_umount2:
ret = get_errno(umount2((const char *)arg1, arg2));
break;
case TARGET_NR_lock:
goto unimplemented;
case TARGET_NR_ioctl:
ret = do_ioctl(arg1, arg2, arg3);
break;
case TARGET_NR_fcntl:
switch(arg2) {
case F_GETLK:
case F_SETLK:
case F_SETLKW:
goto unimplemented;
default:
ret = get_errno(fcntl(arg1, arg2, arg3));
break;
}
break;
case TARGET_NR_mpx:
goto unimplemented;
case TARGET_NR_setpgid:
ret = get_errno(setpgid(arg1, arg2));
break;
case TARGET_NR_ulimit:
goto unimplemented;
case TARGET_NR_oldolduname:
goto unimplemented;
case TARGET_NR_umask:
ret = get_errno(umask(arg1));
break;
case TARGET_NR_chroot:
ret = get_errno(chroot((const char *)arg1));
break;
case TARGET_NR_ustat:
goto unimplemented;
case TARGET_NR_dup2:
ret = get_errno(dup2(arg1, arg2));
break;
case TARGET_NR_getppid:
ret = get_errno(getppid());
break;
case TARGET_NR_getpgrp:
ret = get_errno(getpgrp());
break;
case TARGET_NR_setsid:
ret = get_errno(setsid());
break;
case TARGET_NR_sigaction:
#if 0
{
int signum = arg1;
struct target_old_sigaction *tact = arg2, *toldact = arg3;
ret = get_errno(setsid());
}
break;
#else
goto unimplemented;
#endif
case TARGET_NR_sgetmask:
goto unimplemented;
case TARGET_NR_ssetmask:
goto unimplemented;
case TARGET_NR_setreuid:
ret = get_errno(setreuid(arg1, arg2));
break;
case TARGET_NR_setregid:
ret = get_errno(setregid(arg1, arg2));
break;
case TARGET_NR_sigsuspend:
goto unimplemented;
case TARGET_NR_sigpending:
goto unimplemented;
case TARGET_NR_sethostname:
ret = get_errno(sethostname((const char *)arg1, arg2));
break;
case TARGET_NR_setrlimit:
goto unimplemented;
case TARGET_NR_getrlimit:
goto unimplemented;
case TARGET_NR_getrusage:
goto unimplemented;
case TARGET_NR_gettimeofday:
{
struct target_timeval *target_tv = (void *)arg1;
struct timeval tv;
ret = get_errno(gettimeofday(&tv, NULL));
if (!is_error(ret)) {
target_tv->tv_sec = tswapl(tv.tv_sec);
target_tv->tv_usec = tswapl(tv.tv_usec);
}
}
break;
case TARGET_NR_settimeofday:
{
struct target_timeval *target_tv = (void *)arg1;
struct timeval tv;
tv.tv_sec = tswapl(target_tv->tv_sec);
tv.tv_usec = tswapl(target_tv->tv_usec);
ret = get_errno(settimeofday(&tv, NULL));
}
break;
case TARGET_NR_getgroups:
goto unimplemented;
case TARGET_NR_setgroups:
goto unimplemented;
case TARGET_NR_select:
goto unimplemented;
case TARGET_NR_symlink:
ret = get_errno(symlink((const char *)arg1, (const char *)arg2));
break;
case TARGET_NR_oldlstat:
goto unimplemented;
case TARGET_NR_readlink:
ret = get_errno(readlink((const char *)arg1, (char *)arg2, arg3));
break;
case TARGET_NR_uselib:
goto unimplemented;
case TARGET_NR_swapon:
ret = get_errno(swapon((const char *)arg1, arg2));
break;
case TARGET_NR_reboot:
goto unimplemented;
case TARGET_NR_readdir:
goto unimplemented;
#ifdef TARGET_I386
case TARGET_NR_mmap:
{
uint32_t v1, v2, v3, v4, v5, v6, *vptr;
vptr = (uint32_t *)arg1;
v1 = tswap32(vptr[0]);
v2 = tswap32(vptr[1]);
v3 = tswap32(vptr[2]);
v4 = tswap32(vptr[3]);
v5 = tswap32(vptr[4]);
v6 = tswap32(vptr[5]);
ret = get_errno((long)mmap((void *)v1, v2, v3, v4, v5, v6));
}
break;
#endif
#ifdef TARGET_I386
case TARGET_NR_mmap2:
#else
case TARGET_NR_mmap:
#endif
ret = get_errno((long)mmap((void *)arg1, arg2, arg3, arg4, arg5, arg6));
break;
case TARGET_NR_munmap:
ret = get_errno(munmap((void *)arg1, arg2));
break;
case TARGET_NR_truncate:
ret = get_errno(truncate((const char *)arg1, arg2));
break;
case TARGET_NR_ftruncate:
ret = get_errno(ftruncate(arg1, arg2));
break;
case TARGET_NR_fchmod:
ret = get_errno(fchmod(arg1, arg2));
break;
case TARGET_NR_fchown:
ret = get_errno(fchown(arg1, arg2, arg3));
break;
case TARGET_NR_getpriority:
ret = get_errno(getpriority(arg1, arg2));
break;
case TARGET_NR_setpriority:
ret = get_errno(setpriority(arg1, arg2, arg3));
break;
case TARGET_NR_profil:
goto unimplemented;
case TARGET_NR_statfs:
stfs = (void *)arg2;
ret = get_errno(sys_statfs((const char *)arg1, stfs));
convert_statfs:
if (!is_error(ret)) {
tswap32s(&stfs->f_type);
tswap32s(&stfs->f_bsize);
tswap32s(&stfs->f_blocks);
tswap32s(&stfs->f_bfree);
tswap32s(&stfs->f_bavail);
tswap32s(&stfs->f_files);
tswap32s(&stfs->f_ffree);
tswap32s(&stfs->f_fsid.val[0]);
tswap32s(&stfs->f_fsid.val[1]);
tswap32s(&stfs->f_namelen);
}
break;
case TARGET_NR_fstatfs:
stfs = (void *)arg2;
ret = get_errno(sys_fstatfs(arg1, stfs));
goto convert_statfs;
case TARGET_NR_ioperm:
goto unimplemented;
case TARGET_NR_socketcall:
ret = do_socketcall(arg1, (long *)arg2);
break;
case TARGET_NR_syslog:
goto unimplemented;
case TARGET_NR_setitimer:
goto unimplemented;
case TARGET_NR_getitimer:
goto unimplemented;
case TARGET_NR_stat:
ret = get_errno(stat((const char *)arg1, &st));
goto do_stat;
case TARGET_NR_lstat:
ret = get_errno(lstat((const char *)arg1, &st));
goto do_stat;
case TARGET_NR_fstat:
{
ret = get_errno(fstat(arg1, &st));
do_stat:
if (!is_error(ret)) {
struct target_stat *target_st = (void *)arg2;
target_st->st_dev = tswap16(st.st_dev);
target_st->st_ino = tswapl(st.st_ino);
target_st->st_mode = tswap16(st.st_mode);
target_st->st_nlink = tswap16(st.st_nlink);
target_st->st_uid = tswap16(st.st_uid);
target_st->st_gid = tswap16(st.st_gid);
target_st->st_rdev = tswap16(st.st_rdev);
target_st->st_size = tswapl(st.st_size);
target_st->st_blksize = tswapl(st.st_blksize);
target_st->st_blocks = tswapl(st.st_blocks);
target_st->st_atime = tswapl(st.st_atime);
target_st->st_mtime = tswapl(st.st_mtime);
target_st->st_ctime = tswapl(st.st_ctime);
}
}
break;
case TARGET_NR_olduname:
goto unimplemented;
case TARGET_NR_iopl:
goto unimplemented;
case TARGET_NR_vhangup:
ret = get_errno(vhangup());
break;
case TARGET_NR_idle:
goto unimplemented;
case TARGET_NR_vm86old:
goto unimplemented;
case TARGET_NR_wait4:
{
int status;
target_long *status_ptr = (void *)arg2;
struct rusage rusage, *rusage_ptr;
struct target_rusage *target_rusage = (void *)arg4;
if (target_rusage)
rusage_ptr = &rusage;
else
rusage_ptr = NULL;
ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr));
if (!is_error(ret)) {
if (status_ptr)
*status_ptr = tswap32(status);
if (target_rusage) {
target_rusage->ru_utime.tv_sec = tswapl(rusage.ru_utime.tv_sec);
target_rusage->ru_utime.tv_usec = tswapl(rusage.ru_utime.tv_usec);
target_rusage->ru_stime.tv_sec = tswapl(rusage.ru_stime.tv_sec);
target_rusage->ru_stime.tv_usec = tswapl(rusage.ru_stime.tv_usec);
target_rusage->ru_maxrss = tswapl(rusage.ru_maxrss);
target_rusage->ru_ixrss = tswapl(rusage.ru_ixrss);
target_rusage->ru_idrss = tswapl(rusage.ru_idrss);
target_rusage->ru_isrss = tswapl(rusage.ru_isrss);
target_rusage->ru_minflt = tswapl(rusage.ru_minflt);
target_rusage->ru_majflt = tswapl(rusage.ru_majflt);
target_rusage->ru_nswap = tswapl(rusage.ru_nswap);
target_rusage->ru_inblock = tswapl(rusage.ru_inblock);
target_rusage->ru_oublock = tswapl(rusage.ru_oublock);
target_rusage->ru_msgsnd = tswapl(rusage.ru_msgsnd);
target_rusage->ru_msgrcv = tswapl(rusage.ru_msgrcv);
target_rusage->ru_nsignals = tswapl(rusage.ru_nsignals);
target_rusage->ru_nvcsw = tswapl(rusage.ru_nvcsw);
target_rusage->ru_nivcsw = tswapl(rusage.ru_nivcsw);
}
}
}
break;
case TARGET_NR_swapoff:
ret = get_errno(swapoff((const char *)arg1));
break;
case TARGET_NR_sysinfo:
goto unimplemented;
case TARGET_NR_ipc:
goto unimplemented;
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
case TARGET_NR_sigreturn:
goto unimplemented;
case TARGET_NR_clone:
goto unimplemented;
case TARGET_NR_setdomainname:
ret = get_errno(setdomainname((const char *)arg1, arg2));
break;
case TARGET_NR_uname:
/* no need to transcode because we use the linux syscall */
ret = get_errno(sys_uname((struct new_utsname *)arg1));
break;
#ifdef TARGET_I386
case TARGET_NR_modify_ldt:
ret = get_errno(gemu_modify_ldt(cpu_env, arg1, (void *)arg2, arg3));
break;
#endif
case TARGET_NR_adjtimex:
goto unimplemented;
case TARGET_NR_mprotect:
ret = get_errno(mprotect((void *)arg1, arg2, arg3));
break;
case TARGET_NR_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
target_ulong *pset = (void *)arg2, *poldset = (void *)arg3;
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -EINVAL;
goto fail;
}
if (pset) {
target_to_host_old_sigset(&set, pset);
set_ptr = &set;
} else {
set_ptr = NULL;
}
ret = get_errno(sigprocmask(arg1, set_ptr, &oldset));
if (!is_error(ret) && poldset) {
host_to_target_old_sigset(poldset, &oldset);
}
}
break;
case TARGET_NR_create_module:
case TARGET_NR_init_module:
case TARGET_NR_delete_module:
case TARGET_NR_get_kernel_syms:
goto unimplemented;
case TARGET_NR_quotactl:
goto unimplemented;
case TARGET_NR_getpgid:
ret = get_errno(getpgid(arg1));
break;
case TARGET_NR_fchdir:
ret = get_errno(fchdir(arg1));
break;
case TARGET_NR_bdflush:
goto unimplemented;
case TARGET_NR_sysfs:
goto unimplemented;
case TARGET_NR_personality:
ret = get_errno(mprotect((void *)arg1, arg2, arg3));
break;
case TARGET_NR_afs_syscall:
goto unimplemented;
case TARGET_NR_setfsuid:
goto unimplemented;
case TARGET_NR_setfsgid:
goto unimplemented;
case TARGET_NR__llseek:
{
int64_t res;
ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
*(int64_t *)arg4 = tswap64(res);
}
break;
case TARGET_NR_getdents:
#if TARGET_LONG_SIZE != 4
#error not supported
#endif
{
struct dirent *dirp = (void *)arg2;
long count = arg3;
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct dirent *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = tswap16(de->d_reclen);
if (reclen > len)
break;
de->d_reclen = reclen;
tswapls(&de->d_ino);
tswapls(&de->d_off);
de = (struct dirent *)((char *)de + reclen);
len -= reclen;
}
}
}
break;
case TARGET_NR__newselect:
ret = do_select(arg1, (void *)arg2, (void *)arg3, (void *)arg4,
(void *)arg5);
break;
case TARGET_NR_flock:
goto unimplemented;
case TARGET_NR_msync:
ret = get_errno(msync((void *)arg1, arg2, arg3));
break;
case TARGET_NR_readv:
{
int count = arg3;
int i;
struct iovec *vec;
struct target_iovec *target_vec = (void *)arg2;
vec = alloca(count * sizeof(struct iovec));
for(i = 0;i < count; i++) {
vec[i].iov_base = (void *)tswapl(target_vec[i].iov_base);
vec[i].iov_len = tswapl(target_vec[i].iov_len);
}
ret = get_errno(readv(arg1, vec, count));
}
break;
case TARGET_NR_writev:
{
int count = arg3;
int i;
struct iovec *vec;
struct target_iovec *target_vec = (void *)arg2;
vec = alloca(count * sizeof(struct iovec));
for(i = 0;i < count; i++) {
vec[i].iov_base = (void *)tswapl(target_vec[i].iov_base);
vec[i].iov_len = tswapl(target_vec[i].iov_len);
}
ret = get_errno(writev(arg1, vec, count));
}
break;
case TARGET_NR_getsid:
ret = get_errno(getsid(arg1));
break;
case TARGET_NR_fdatasync:
goto unimplemented;
case TARGET_NR__sysctl:
goto unimplemented;
case TARGET_NR_mlock:
ret = get_errno(mlock((void *)arg1, arg2));
break;
case TARGET_NR_munlock:
ret = get_errno(munlock((void *)arg1, arg2));
break;
case TARGET_NR_mlockall:
ret = get_errno(mlockall(arg1));
break;
case TARGET_NR_munlockall:
ret = get_errno(munlockall());
break;
case TARGET_NR_sched_setparam:
goto unimplemented;
case TARGET_NR_sched_getparam:
goto unimplemented;
case TARGET_NR_sched_setscheduler:
goto unimplemented;
case TARGET_NR_sched_getscheduler:
goto unimplemented;
case TARGET_NR_sched_yield:
ret = get_errno(sched_yield());
break;
case TARGET_NR_sched_get_priority_max:
case TARGET_NR_sched_get_priority_min:
case TARGET_NR_sched_rr_get_interval:
case TARGET_NR_nanosleep:
case TARGET_NR_mremap:
case TARGET_NR_setresuid:
case TARGET_NR_getresuid:
case TARGET_NR_vm86:
case TARGET_NR_query_module:
case TARGET_NR_poll:
case TARGET_NR_nfsservctl:
case TARGET_NR_setresgid:
case TARGET_NR_getresgid:
case TARGET_NR_prctl:
case TARGET_NR_rt_sigreturn:
case TARGET_NR_rt_sigaction:
case TARGET_NR_rt_sigprocmask:
case TARGET_NR_rt_sigpending:
case TARGET_NR_rt_sigtimedwait:
case TARGET_NR_rt_sigqueueinfo:
case TARGET_NR_rt_sigsuspend:
case TARGET_NR_pread:
case TARGET_NR_pwrite:
goto unimplemented;
case TARGET_NR_chown:
ret = get_errno(chown((const char *)arg1, arg2, arg3));
break;
case TARGET_NR_getcwd:
ret = get_errno(sys_getcwd1((char *)arg1, arg2));
break;
case TARGET_NR_capget:
case TARGET_NR_capset:
case TARGET_NR_sigaltstack:
case TARGET_NR_sendfile:
case TARGET_NR_getpmsg:
case TARGET_NR_putpmsg:
case TARGET_NR_vfork:
ret = get_errno(vfork());
break;
case TARGET_NR_ugetrlimit:
case TARGET_NR_truncate64:
case TARGET_NR_ftruncate64:
case TARGET_NR_stat64:
case TARGET_NR_lstat64:
case TARGET_NR_fstat64:
case TARGET_NR_lchown32:
case TARGET_NR_getuid32:
case TARGET_NR_getgid32:
case TARGET_NR_geteuid32:
case TARGET_NR_getegid32:
case TARGET_NR_setreuid32:
case TARGET_NR_setregid32:
case TARGET_NR_getgroups32:
case TARGET_NR_setgroups32:
case TARGET_NR_fchown32:
case TARGET_NR_setresuid32:
case TARGET_NR_getresuid32:
case TARGET_NR_setresgid32:
case TARGET_NR_getresgid32:
case TARGET_NR_chown32:
case TARGET_NR_setuid32:
case TARGET_NR_setgid32:
case TARGET_NR_setfsuid32:
case TARGET_NR_setfsgid32:
case TARGET_NR_pivot_root:
case TARGET_NR_mincore:
case TARGET_NR_madvise:
case TARGET_NR_getdents64:
case TARGET_NR_fcntl64:
case TARGET_NR_security:
goto unimplemented;
case TARGET_NR_gettid:
ret = get_errno(gettid());
break;
case TARGET_NR_readahead:
case TARGET_NR_setxattr:
case TARGET_NR_lsetxattr:
case TARGET_NR_fsetxattr:
case TARGET_NR_getxattr:
case TARGET_NR_lgetxattr:
case TARGET_NR_fgetxattr:
case TARGET_NR_listxattr:
case TARGET_NR_llistxattr:
case TARGET_NR_flistxattr:
case TARGET_NR_removexattr:
case TARGET_NR_lremovexattr:
case TARGET_NR_fremovexattr:
goto unimplemented;
default:
unimplemented:
gemu_log("Unsupported syscall: %d\n", num);
ret = -ENOSYS;
break;
}
fail:
return ret;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14300 | static int rebuild_refcount_structure(BlockDriverState *bs,
BdrvCheckResult *res,
void **refcount_table,
int64_t *nb_clusters)
{
BDRVQcow2State *s = bs->opaque;
int64_t first_free_cluster = 0, reftable_offset = -1, cluster = 0;
int64_t refblock_offset, refblock_start, refblock_index;
uint32_t reftable_size = 0;
uint64_t *on_disk_reftable = NULL;
void *on_disk_refblock;
int ret = 0;
struct {
uint64_t reftable_offset;
uint32_t reftable_clusters;
} QEMU_PACKED reftable_offset_and_clusters;
qcow2_cache_empty(bs, s->refcount_block_cache);
write_refblocks:
for (; cluster < *nb_clusters; cluster++) {
if (!s->get_refcount(*refcount_table, cluster)) {
continue;
}
refblock_index = cluster >> s->refcount_block_bits;
refblock_start = refblock_index << s->refcount_block_bits;
/* Don't allocate a cluster in a refblock already written to disk */
if (first_free_cluster < refblock_start) {
first_free_cluster = refblock_start;
}
refblock_offset = alloc_clusters_imrt(bs, 1, refcount_table,
nb_clusters, &first_free_cluster);
if (refblock_offset < 0) {
fprintf(stderr, "ERROR allocating refblock: %s\n",
strerror(-refblock_offset));
res->check_errors++;
ret = refblock_offset;
goto fail;
}
if (reftable_size <= refblock_index) {
uint32_t old_reftable_size = reftable_size;
uint64_t *new_on_disk_reftable;
reftable_size = ROUND_UP((refblock_index + 1) * sizeof(uint64_t),
s->cluster_size) / sizeof(uint64_t);
new_on_disk_reftable = g_try_realloc(on_disk_reftable,
reftable_size *
sizeof(uint64_t));
if (!new_on_disk_reftable) {
res->check_errors++;
ret = -ENOMEM;
goto fail;
}
on_disk_reftable = new_on_disk_reftable;
memset(on_disk_reftable + old_reftable_size, 0,
(reftable_size - old_reftable_size) * sizeof(uint64_t));
/* The offset we have for the reftable is now no longer valid;
* this will leak that range, but we can easily fix that by running
* a leak-fixing check after this rebuild operation */
reftable_offset = -1;
}
on_disk_reftable[refblock_index] = refblock_offset;
/* If this is apparently the last refblock (for now), try to squeeze the
* reftable in */
if (refblock_index == (*nb_clusters - 1) >> s->refcount_block_bits &&
reftable_offset < 0)
{
uint64_t reftable_clusters = size_to_clusters(s, reftable_size *
sizeof(uint64_t));
reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
refcount_table, nb_clusters,
&first_free_cluster);
if (reftable_offset < 0) {
fprintf(stderr, "ERROR allocating reftable: %s\n",
strerror(-reftable_offset));
res->check_errors++;
ret = reftable_offset;
goto fail;
}
}
ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
s->cluster_size);
if (ret < 0) {
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
goto fail;
}
/* The size of *refcount_table is always cluster-aligned, therefore the
* write operation will not overflow */
on_disk_refblock = (void *)((char *) *refcount_table +
refblock_index * s->cluster_size);
ret = bdrv_write(bs->file, refblock_offset / BDRV_SECTOR_SIZE,
on_disk_refblock, s->cluster_sectors);
if (ret < 0) {
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
goto fail;
}
/* Go to the end of this refblock */
cluster = refblock_start + s->refcount_block_size - 1;
}
if (reftable_offset < 0) {
uint64_t post_refblock_start, reftable_clusters;
post_refblock_start = ROUND_UP(*nb_clusters, s->refcount_block_size);
reftable_clusters = size_to_clusters(s,
reftable_size * sizeof(uint64_t));
/* Not pretty but simple */
if (first_free_cluster < post_refblock_start) {
first_free_cluster = post_refblock_start;
}
reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
refcount_table, nb_clusters,
&first_free_cluster);
if (reftable_offset < 0) {
fprintf(stderr, "ERROR allocating reftable: %s\n",
strerror(-reftable_offset));
res->check_errors++;
ret = reftable_offset;
goto fail;
}
goto write_refblocks;
}
assert(on_disk_reftable);
for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
cpu_to_be64s(&on_disk_reftable[refblock_index]);
}
ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset,
reftable_size * sizeof(uint64_t));
if (ret < 0) {
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
goto fail;
}
assert(reftable_size < INT_MAX / sizeof(uint64_t));
ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable,
reftable_size * sizeof(uint64_t));
if (ret < 0) {
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
goto fail;
}
/* Enter new reftable into the image header */
reftable_offset_and_clusters.reftable_offset = cpu_to_be64(reftable_offset);
reftable_offset_and_clusters.reftable_clusters =
cpu_to_be32(size_to_clusters(s, reftable_size * sizeof(uint64_t)));
ret = bdrv_pwrite_sync(bs->file,
offsetof(QCowHeader, refcount_table_offset),
&reftable_offset_and_clusters,
sizeof(reftable_offset_and_clusters));
if (ret < 0) {
fprintf(stderr, "ERROR setting reftable: %s\n", strerror(-ret));
goto fail;
}
for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
be64_to_cpus(&on_disk_reftable[refblock_index]);
}
s->refcount_table = on_disk_reftable;
s->refcount_table_offset = reftable_offset;
s->refcount_table_size = reftable_size;
update_max_refcount_table_index(s);
return 0;
fail:
g_free(on_disk_reftable);
return ret;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14306 | static int synchronize_audio(VideoState *is, short *samples,
int samples_size1, double pts)
{
int n, samples_size;
double ref_clock;
n = 2 * is->audio_st->codec->channels;
samples_size = samples_size1;
/* if not master, then we try to remove or add samples to correct the clock */
if (((is->av_sync_type == AV_SYNC_VIDEO_MASTER && is->video_st) ||
is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {
double diff, avg_diff;
int wanted_size, min_size, max_size, nb_samples;
ref_clock = get_master_clock(is);
diff = get_audio_clock(is) - ref_clock;
if (diff < AV_NOSYNC_THRESHOLD) {
is->audio_diff_cum = diff + is->audio_diff_avg_coef * is->audio_diff_cum;
if (is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {
/* not enough measures to have a correct estimate */
is->audio_diff_avg_count++;
} else {
/* estimate the A-V difference */
avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
if (fabs(avg_diff) >= is->audio_diff_threshold) {
wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
nb_samples = samples_size / n;
min_size = ((nb_samples * (100 - SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n;
max_size = ((nb_samples * (100 + SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n;
if (wanted_size < min_size)
wanted_size = min_size;
else if (wanted_size > max_size)
wanted_size = max_size;
/* add or remove samples to correction the synchro */
if (wanted_size < samples_size) {
/* remove samples */
samples_size = wanted_size;
} else if (wanted_size > samples_size) {
uint8_t *samples_end, *q;
int nb;
/* add samples */
nb = (samples_size - wanted_size);
samples_end = (uint8_t *)samples + samples_size - n;
q = samples_end + n;
while (nb > 0) {
memcpy(q, samples_end, n);
q += n;
nb -= n;
}
samples_size = wanted_size;
}
}
av_dlog(NULL, "diff=%f adiff=%f sample_diff=%d apts=%0.3f vpts=%0.3f %f\n",
diff, avg_diff, samples_size - samples_size1,
is->audio_clock, is->video_clock, is->audio_diff_threshold);
}
} else {
/* too big difference : may be initial PTS errors, so
reset A-V filter */
is->audio_diff_avg_count = 0;
is->audio_diff_cum = 0;
}
}
return samples_size;
}
The vulnerability label is: Non-vulnerable |
devign_test_set_data_14308 | av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg,
int is_indeo4)
{
int p, b;
uint32_t b_width, b_height, align_fac, width_aligned,
height_aligned, buf_size;
IVIBandDesc *band;
ivi_free_buffers(planes);
if (av_image_check_size(cfg->pic_width, cfg->pic_height, 0, NULL) < 0 ||
cfg->luma_bands < 1 || cfg->chroma_bands < 1)
return AVERROR_INVALIDDATA;
/* fill in the descriptor of the luminance plane */
planes[0].width = cfg->pic_width;
planes[0].height = cfg->pic_height;
planes[0].num_bands = cfg->luma_bands;
/* fill in the descriptors of the chrominance planes */
planes[1].width = planes[2].width = (cfg->pic_width + 3) >> 2;
planes[1].height = planes[2].height = (cfg->pic_height + 3) >> 2;
planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands;
for (p = 0; p < 3; p++) {
planes[p].bands = av_mallocz_array(planes[p].num_bands, sizeof(IVIBandDesc));
if (!planes[p].bands)
return AVERROR(ENOMEM);
/* select band dimensions: if there is only one band then it
* has the full size, if there are several bands each of them
* has only half size */
b_width = planes[p].num_bands == 1 ? planes[p].width
: (planes[p].width + 1) >> 1;
b_height = planes[p].num_bands == 1 ? planes[p].height
: (planes[p].height + 1) >> 1;
/* luma band buffers will be aligned on 16x16 (max macroblock size) */
/* chroma band buffers will be aligned on 8x8 (max macroblock size) */
align_fac = p ? 8 : 16;
width_aligned = FFALIGN(b_width , align_fac);
height_aligned = FFALIGN(b_height, align_fac);
buf_size = width_aligned * height_aligned * sizeof(int16_t);
for (b = 0; b < planes[p].num_bands; b++) {
band = &planes[p].bands[b]; /* select appropriate plane/band */
band->plane = p;
band->band_num = b;
band->width = b_width;
band->height = b_height;
band->pitch = width_aligned;
band->aheight = height_aligned;
band->bufs[0] = av_mallocz(buf_size);
band->bufs[1] = av_mallocz(buf_size);
band->bufsize = buf_size/2;
if (!band->bufs[0] || !band->bufs[1])
return AVERROR(ENOMEM);
/* allocate the 3rd band buffer for scalability mode */
if (cfg->luma_bands > 1) {
band->bufs[2] = av_mallocz(buf_size);
if (!band->bufs[2])
return AVERROR(ENOMEM);
}
if (is_indeo4) {
band->bufs[3] = av_mallocz(buf_size);
if (!band->bufs[3])
return AVERROR(ENOMEM);
}
/* reset custom vlc */
planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0;
}
}
return 0;
}
The vulnerability label is: Vulnerable |
devign_test_set_data_14309 | static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
{
SeqVideoContext *seq = avctx->priv_data;
seq->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
seq->frame = av_frame_alloc();
if (!seq->frame)
return AVERROR(ENOMEM);
return 0;
}
The vulnerability label is: Vulnerable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.