id
stringlengths 23
25
| content
stringlengths 105
10.5k
|
|---|---|
vulnpatchpairs_data_9162
|
static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
}
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
mb->mv_x = mb->mv_y = 0;
if (band->inherit_mv){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
}
} else {
if (band->inherit_mv) {
mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits1(&ctx->gb);
}
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->qdelta_present) {
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
(ctx->frame_flags & 8))) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
}
if (!mb->type) {
mb->mv_x = mb->mv_y = 0;
} else {
if (band->inherit_mv){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
} else {
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
}
}
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
}
offs += row_offset;
}
align_get_bits(&ctx->gb);
return 0;
}
|
vulnpatchpairs_data_9109
|
static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size;
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
h_size= (c->dstW+7)&~7;
if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" );
for (y= 0; y<srcSliceH; y++ ) {
uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];
uint8_t *_py = src[0] + y*srcStride[0];
uint8_t *_pu = src[1] + (y>>1)*srcStride[1];
uint8_t *_pv = src[2] + (y>>1)*srcStride[2];
long index= -h_size/2;
b5Dither= dither8[y&1];
g6Dither= dither4[y&1];
g5Dither= dither8[y&1];
r5Dither= dither8[(y+1)&1];
__asm__ __volatile__ (
"movd (%2, %0), %%mm0;"
"movd (%3, %0), %%mm1;"
"movq (%5, %0, 2), %%mm6;"
"1: \n\t"
YUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm0;"
"paddusb "MANGLE(g6Dither)", %%mm2;"
"paddusb "MANGLE(r5Dither)", %%mm1;"
#endif
"pand "MANGLE(mmx_redmask)", %%mm0;"
"pand "MANGLE(mmx_grnmask)", %%mm2;"
"pand "MANGLE(mmx_redmask)", %%mm1;"
"psrlw $3,%%mm0;"
"pxor %%mm4, %%mm4;"
"movq %%mm0, %%mm5;"
"movq %%mm2, %%mm7;"
"punpcklbw %%mm4, %%mm2;"
"punpcklbw %%mm1, %%mm0;"
"psllw $3, %%mm2;"
"por %%mm2, %%mm0;"
"movq 8 (%5, %0, 2), %%mm6;"
MOVNTQ " %%mm0, (%1);"
"punpckhbw %%mm4, %%mm7;"
"punpckhbw %%mm1, %%mm5;"
"psllw $3, %%mm7;"
"movd 4 (%2, %0), %%mm0;"
"por %%mm7, %%mm5;"
"movd 4 (%3, %0), %%mm1;"
MOVNTQ " %%mm5, 8 (%1);"
"add $16, %1 \n\t"
"add $4, %0 \n\t"
" js 1b \n\t"
: "+r" (index), "+r" (_image)
: "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index)
);
}
__asm__ __volatile__ (EMMS);
return srcSliceH;
}
|
vulnpatchpairs_data_13035
|
static gboolean pty_chr_timer(gpointer opaque)
{
struct CharDriverState *chr = opaque;
PtyCharDriver *s = chr->opaque;
if (s->connected) {
goto out;
}
pty_chr_update_read_handler(chr);
out:
s->timer_tag = 0;
return FALSE;
}
|
vulnpatchpairs_data_22693
|
void trace_init_file(const char *file)
{
#ifdef CONFIG_TRACE_SIMPLE
st_set_trace_file(file);
#elif defined CONFIG_TRACE_LOG
if (file) {
qemu_set_log_filename(file);
}
#else
if (file) {
fprintf(stderr, "error: -trace file=...: "
"option not supported by the selected tracing backends\n");
exit(1);
}
#endif
}
|
vulnpatchpairs_data_10735
|
static void usb_msd_realize_bot(USBDevice *dev, Error **errp)
{
MSDState *s = DO_UPCAST(MSDState, dev, dev);
usb_desc_create_serial(dev);
usb_desc_init(dev);
scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
&usb_msd_scsi_info_bot, NULL);
s->bus.qbus.allow_hotplug = 0;
usb_msd_handle_reset(dev);
}
|
vulnpatchpairs_data_23386
|
static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
int64_t align, QEMUIOVector *qiov, int flags)
{
BlockDriverState *bs = child->bs;
BlockDriver *drv = bs->drv;
bool waited;
int ret;
int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
uint64_t bytes_remaining = bytes;
int max_transfer;
if (bdrv_has_readonly_bitmaps(bs)) {
return -EPERM;
assert(is_power_of_2(align));
assert((offset & (align - 1)) == 0);
assert((bytes & (align - 1)) == 0);
assert(!qiov || bytes == qiov->size);
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
assert(!(flags & ~BDRV_REQ_MASK));
max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
align);
waited = wait_serialising_requests(req);
assert(!waited || !req->serialising);
assert(req->overlap_offset <= offset);
assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
assert(child->perm & BLK_PERM_WRITE);
assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF &&
!(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes &&
qemu_iovec_is_zero(qiov)) {
flags |= BDRV_REQ_ZERO_WRITE;
if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
flags |= BDRV_REQ_MAY_UNMAP;
if (ret < 0) {
} else if (flags & BDRV_REQ_ZERO_WRITE) {
bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO);
ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags);
} else if (flags & BDRV_REQ_WRITE_COMPRESSED) {
ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov);
} else if (bytes <= max_transfer) {
bdrv_debug_event(bs, BLKDBG_PWRITEV);
ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, flags);
} else {
bdrv_debug_event(bs, BLKDBG_PWRITEV);
while (bytes_remaining) {
int num = MIN(bytes_remaining, max_transfer);
QEMUIOVector local_qiov;
int local_flags = flags;
assert(num);
if (num < bytes_remaining && (flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
local_flags &= ~BDRV_REQ_FUA;
qemu_iovec_init(&local_qiov, qiov->niov);
qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num);
ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining,
num, &local_qiov, local_flags);
qemu_iovec_destroy(&local_qiov);
if (ret < 0) {
break;
bytes_remaining -= num;
bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE);
atomic_inc(&bs->write_gen);
bdrv_set_dirty(bs, offset, bytes);
stat64_max(&bs->wr_highest_offset, offset + bytes);
if (ret >= 0) {
bs->total_sectors = MAX(bs->total_sectors, end_sector);
ret = 0;
return ret;
|
vulnpatchpairs_data_25859
|
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
{
AVFilterContext *ctx = inlink->dst;
SignatureContext *sic = ctx->priv;
StreamContext *sc = &(sic->streamcontexts[FF_INLINK_IDX(inlink)]);
FineSignature* fs;
static const uint8_t pot3[5] = { 3*3*3*3, 3*3*3, 3*3, 3, 1 };
static const unsigned int wordvec[25] = {44,57,70,100,101,102,103,111,175,210,217,219,233,237,269,270,273,274,275,285,295,296,334,337,354};
static const uint8_t s2usw[25] = { 5,10,11, 15, 20, 21, 12, 22, 6, 0, 1, 2, 7, 13, 14, 8, 9, 3, 23, 16, 17, 24, 4, 18, 19};
uint8_t wordt2b[5] = { 0, 0, 0, 0, 0 };
uint64_t intpic[32][32];
uint64_t rowcount;
uint8_t *p = picref->data[0];
int inti, intj;
int *intjlut;
uint64_t conflist[DIFFELEM_SIZE];
int f = 0, g = 0, w = 0;
int32_t dh1 = 1, dh2 = 1, dw1 = 1, dw2 = 1, a, b;
int64_t denom;
int i, j, k, ternary;
uint64_t blocksum;
int blocksize;
int64_t th;
int64_t sum;
int64_t precfactor = (sc->divide) ? 65536 : BLOCK_LCM;
if (sc->curfinesig) {
fs = av_mallocz(sizeof(FineSignature));
if (!fs)
return AVERROR(ENOMEM);
sc->curfinesig->next = fs;
fs->prev = sc->curfinesig;
sc->curfinesig = fs;
} else {
fs = sc->curfinesig = sc->finesiglist;
sc->curcoarsesig1->first = fs;
}
fs->pts = picref->pts;
fs->index = sc->lastindex++;
memset(intpic, 0, sizeof(uint64_t)*32*32);
intjlut = av_malloc_array(inlink->w, sizeof(int));
if (!intjlut)
return AVERROR(ENOMEM);
for (i = 0; i < inlink->w; i++) {
intjlut[i] = (i*32)/inlink->w;
}
for (i = 0; i < inlink->h; i++) {
inti = (i*32)/inlink->h;
for (j = 0; j < inlink->w; j++) {
intj = intjlut[j];
intpic[inti][intj] += p[j];
}
p += picref->linesize[0];
}
av_freep(&intjlut);
dh1 = inlink->h / 32;
if (inlink->h % 32)
dh2 = dh1 + 1;
dw1 = inlink->w / 32;
if (inlink->w % 32)
dw2 = dw1 + 1;
denom = (sc->divide) ? dh1 * dh2 * dw1 * dw2 : 1;
for (i = 0; i < 32; i++) {
rowcount = 0;
a = 1;
if (dh2 > 1) {
a = ((inlink->h*(i+1))%32 == 0) ? (inlink->h*(i+1))/32 - 1 : (inlink->h*(i+1))/32;
a -= ((inlink->h*i)%32 == 0) ? (inlink->h*i)/32 - 1 : (inlink->h*i)/32;
a = (a == dh1)? dh2 : dh1;
}
for (j = 0; j < 32; j++) {
b = 1;
if (dw2 > 1) {
b = ((inlink->w*(j+1))%32 == 0) ? (inlink->w*(j+1))/32 - 1 : (inlink->w*(j+1))/32;
b -= ((inlink->w*j)%32 == 0) ? (inlink->w*j)/32 - 1 : (inlink->w*j)/32;
b = (b == dw1)? dw2 : dw1;
}
rowcount += intpic[i][j] * a * b * precfactor / denom;
if (i > 0) {
intpic[i][j] = intpic[i-1][j] + rowcount;
} else {
intpic[i][j] = rowcount;
}
}
}
denom = (sc->divide) ? 1 : dh1 * dh2 * dw1 * dw2;
for (i = 0; i < ELEMENT_COUNT; i++) {
const ElemCat* elemcat = elements[i];
int64_t* elemsignature;
uint64_t* sortsignature;
elemsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
if (!elemsignature)
return AVERROR(ENOMEM);
sortsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
if (!sortsignature)
return AVERROR(ENOMEM);
for (j = 0; j < elemcat->elem_count; j++) {
blocksum = 0;
blocksize = 0;
for (k = 0; k < elemcat->left_count; k++) {
blocksum += get_block_sum(sc, intpic, &elemcat->blocks[j*elemcat->block_count+k]);
blocksize += get_block_size(&elemcat->blocks[j*elemcat->block_count+k]);
}
sum = blocksum / blocksize;
if (elemcat->av_elem) {
sum -= 128 * precfactor * denom;
} else {
blocksum = 0;
blocksize = 0;
for (; k < elemcat->block_count; k++) {
blocksum += get_block_sum(sc, intpic, &elemcat->blocks[j*elemcat->block_count+k]);
blocksize += get_block_size(&elemcat->blocks[j*elemcat->block_count+k]);
}
sum -= blocksum / blocksize;
conflist[g++] = FFABS(sum * 8 / (precfactor * denom));
}
elemsignature[j] = sum;
sortsignature[j] = FFABS(sum);
}
qsort(sortsignature, elemcat->elem_count, sizeof(uint64_t), (void*) cmp);
th = sortsignature[(int) (elemcat->elem_count*0.333)];
for (j = 0; j < elemcat->elem_count; j++) {
if (elemsignature[j] < -th) {
ternary = 0;
} else if (elemsignature[j] <= th) {
ternary = 1;
} else {
ternary = 2;
}
fs->framesig[f/5] += ternary * pot3[f%5];
if (f == wordvec[w]) {
fs->words[s2usw[w]/5] += ternary * pot3[wordt2b[s2usw[w]/5]++];
if (w < 24)
w++;
}
f++;
}
av_freep(&elemsignature);
av_freep(&sortsignature);
}
qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), (void*) cmp);
fs->confidence = FFMIN(conflist[DIFFELEM_SIZE/2], 255);
if (sc->coarsecount == 0) {
if (sc->curcoarsesig2) {
sc->curcoarsesig1 = av_mallocz(sizeof(CoarseSignature));
if (!sc->curcoarsesig1)
return AVERROR(ENOMEM);
sc->curcoarsesig1->first = fs;
sc->curcoarsesig2->next = sc->curcoarsesig1;
sc->coarseend = sc->curcoarsesig1;
}
}
if (sc->coarsecount == 45) {
sc->midcoarse = 1;
sc->curcoarsesig2 = av_mallocz(sizeof(CoarseSignature));
if (!sc->curcoarsesig2)
return AVERROR(ENOMEM);
sc->curcoarsesig2->first = fs;
sc->curcoarsesig1->next = sc->curcoarsesig2;
sc->coarseend = sc->curcoarsesig2;
}
for (i = 0; i < 5; i++) {
set_bit(sc->curcoarsesig1->data[i], fs->words[i]);
}
sc->curcoarsesig1->last = fs;
if (sc->midcoarse) {
for (i = 0; i < 5; i++) {
set_bit(sc->curcoarsesig2->data[i], fs->words[i]);
}
sc->curcoarsesig2->last = fs;
}
sc->coarsecount = (sc->coarsecount+1)%90;
if (av_log_get_level() == AV_LOG_DEBUG) {
av_log(ctx, AV_LOG_DEBUG, "input %d, confidence: %d\n", FF_INLINK_IDX(inlink), fs->confidence);
av_log(ctx, AV_LOG_DEBUG, "words:");
for (i = 0; i < 5; i++) {
av_log(ctx, AV_LOG_DEBUG, " %d:", fs->words[i] );
av_log(ctx, AV_LOG_DEBUG, " %d", fs->words[i] / pot3[0] );
for (j = 1; j < 5; j++)
av_log(ctx, AV_LOG_DEBUG, ",%d", fs->words[i] % pot3[j-1] / pot3[j] );
av_log(ctx, AV_LOG_DEBUG, ";");
}
av_log(ctx, AV_LOG_DEBUG, "\n");
av_log(ctx, AV_LOG_DEBUG, "framesignature:");
for (i = 0; i < SIGELEM_SIZE/5; i++) {
av_log(ctx, AV_LOG_DEBUG, " %d", fs->framesig[i] / pot3[0] );
for (j = 1; j < 5; j++)
av_log(ctx, AV_LOG_DEBUG, ",%d", fs->framesig[i] % pot3[j-1] / pot3[j] );
}
av_log(ctx, AV_LOG_DEBUG, "\n");
}
if (FF_INLINK_IDX(inlink) == 0)
return ff_filter_frame(inlink->dst->outputs[0], picref);
return 1;
}
|
vulnpatchpairs_data_24896
|
static int decode_frame_ilbm(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
IffContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL;
const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0;
const uint8_t *buf_end = buf+buf_size;
int y, plane, res;
if ((res = extract_header(avctx, avpkt)) < 0)
return res;
if (s->init) {
if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return res;
}
} else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return res;
} else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) {
if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
return res;
}
s->init = 1;
if (avctx->codec_tag == MKTAG('A','C','B','M')) {
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
memset(s->frame.data[0], 0, avctx->height * s->frame.linesize[0]);
for (plane = 0; plane < s->bpp; plane++) {
for(y = 0; y < avctx->height && buf < buf_end; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
buf += s->planesize;
}
}
} else if (s->ham) {
memset(s->frame.data[0], 0, avctx->height * s->frame.linesize[0]);
for(y = 0; y < avctx->height; y++) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memset(s->ham_buf, 0, s->planesize * 8);
for (plane = 0; plane < s->bpp; plane++) {
const uint8_t * start = buf + (plane * avctx->height + y) * s->planesize;
if (start >= buf_end)
break;
decodeplane8(s->ham_buf, start, FFMIN(s->planesize, buf_end - start), plane);
}
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
}
} else if (avctx->codec_tag == MKTAG('D','E','E','P')) {
int raw_width = avctx->width * (av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]) >> 3);
int x;
for(y = 0; y < avctx->height && buf < buf_end; y++ ) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memcpy(row, buf, FFMIN(raw_width, buf_end - buf));
buf += raw_width;
if (avctx->pix_fmt == PIX_FMT_BGR32) {
for(x = 0; x < avctx->width; x++)
row[4 * x + 3] = row[4 * x + 3] & 0xF0 | (row[4 * x + 3] >> 4);
}
}
} else if (avctx->codec_tag == MKTAG('I','L','B','M')) {
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memset(row, 0, avctx->width);
for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
buf += s->planesize;
}
}
} else if (s->ham) {
for (y = 0; y < avctx->height; y++) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memset(s->ham_buf, 0, s->planesize * 8);
for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
decodeplane8(s->ham_buf, buf, FFMIN(s->planesize, buf_end - buf), plane);
buf += s->planesize;
}
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else {
for(y = 0; y < avctx->height; y++ ) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
memset(row, 0, avctx->width << 2);
for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
decodeplane32((uint32_t *) row, buf, FFMIN(s->planesize, buf_end - buf), plane);
buf += s->planesize;
}
}
}
} else if (avctx->codec_tag == MKTAG('P','B','M',' ')) {
if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height; y++ ) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memcpy(row, buf, FFMIN(avctx->width, buf_end - buf));
buf += avctx->width + (avctx->width % 2);
}
} else if (s->ham) {
for (y = 0; y < avctx->height; y++) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf));
buf += avctx->width + (avctx->width & 1);
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else {
av_log_ask_for_sample(avctx, "unsupported bpp\n");
return AVERROR_INVALIDDATA;
}
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size;
}
|
vulnpatchpairs_data_6999
|
static void init_gain_table(COOKContext *q) {
int i;
q->gain_size_factor = q->samples_per_channel/8;
for (i=0 ; i<23 ; i++) {
q->gain_table[i] = pow((double)q->pow2tab[i+52] ,
(1.0/(double)q->gain_size_factor));
}
memset(&q->gain_copy, 0, sizeof(COOKgain));
memset(&q->gain_current, 0, sizeof(COOKgain));
memset(&q->gain_now, 0, sizeof(COOKgain));
memset(&q->gain_previous, 0, sizeof(COOKgain));
}
|
vulnpatchpairs_data_17280
|
static int read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
JVDemuxContext *jv = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *vst, *ast;
int64_t audio_pts = 0;
int64_t offset;
int i;
avio_skip(pb, 80);
ast = av_new_stream(s, 0);
vst = av_new_stream(s, 1);
if (!ast || !vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = CODEC_TYPE_VIDEO;
vst->codec->codec_id = CODEC_ID_JV;
vst->codec->codec_tag = 0;
vst->codec->width = avio_rl16(pb);
vst->codec->height = avio_rl16(pb);
vst->nb_frames =
ast->nb_index_entries = avio_rl16(pb);
av_set_pts_info(vst, 64, avio_rl16(pb), 1000);
avio_skip(pb, 4);
ast->codec->codec_type = CODEC_TYPE_AUDIO;
ast->codec->codec_id = CODEC_ID_PCM_U8;
ast->codec->codec_tag = 0;
ast->codec->sample_rate = avio_rl16(pb);
ast->codec->channels = 1;
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
avio_skip(pb, 10);
ast->index_entries = av_malloc(ast->nb_index_entries * sizeof(*ast->index_entries));
if (!ast->index_entries)
return AVERROR(ENOMEM);
jv->frames = av_malloc(ast->nb_index_entries * sizeof(JVFrame));
if (!jv->frames)
return AVERROR(ENOMEM);
offset = 0x68 + ast->nb_index_entries * 16;
for(i = 0; i < ast->nb_index_entries; i++) {
AVIndexEntry *e = ast->index_entries + i;
JVFrame *jvf = jv->frames + i;
e->size = avio_rl32(pb);
e->timestamp = i;
e->pos = offset;
offset += e->size;
jvf->audio_size = avio_rl32(pb);
jvf->video_size = avio_rl32(pb);
jvf->palette_size = avio_r8(pb) ? 768 : 0;
if (avio_r8(pb))
av_log(s, AV_LOG_WARNING, "unsupported audio codec\n");
jvf->video_type = avio_r8(pb);
avio_skip(pb, 1);
e->timestamp = jvf->audio_size ? audio_pts : AV_NOPTS_VALUE;
audio_pts += jvf->audio_size;
e->flags = jvf->video_type != 1 ? AVINDEX_KEYFRAME : 0;
}
jv->state = JV_AUDIO;
return 0;
}
|
vulnpatchpairs_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;
planes[0].width = cfg->pic_width;
planes[0].height = cfg->pic_height;
planes[0].num_bands = cfg->luma_bands;
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);
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;
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];
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);
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);
}
planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0;
}
}
return 0;
}
|
vulnpatchpairs_data_24292
|
void bdrv_drain(BlockDriverState *bs)
{
bool busy = true;
bdrv_drain_recurse(bs);
while (busy) {
bdrv_flush_io_queue(bs);
busy = bdrv_requests_pending(bs);
busy |= aio_poll(bdrv_get_aio_context(bs), busy);
|
vulnpatchpairs_data_22065
|
int32 float64_to_int32_round_to_zero( float64 a STATUS_PARAM )
{
flag aSign;
int16 aExp, shiftCount;
uint64_t aSig, savedASig;
int32 z;
a = float64_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( 0x41E < aExp ) {
if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
goto invalid;
}
else if ( aExp < 0x3FF ) {
if ( aExp || aSig ) STATUS(float_exception_flags) |= float_flag_inexact;
return 0;
}
aSig |= LIT64( 0x0010000000000000 );
shiftCount = 0x433 - aExp;
savedASig = aSig;
aSig >>= shiftCount;
z = aSig;
if ( aSign ) z = - z;
if ( ( z < 0 ) ^ aSign ) {
invalid:
float_raise( float_flag_invalid STATUS_VAR);
return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
}
if ( ( aSig<<shiftCount ) != savedASig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
}
return z;
}
|
vulnpatchpairs_data_9231
|
void object_property_allow_set_link(Object *obj, const char *name,
Object *val, Error **errp)
{
}
|
vulnpatchpairs_data_22034
|
static void dwt_encode97_int(DWTContext *s, int *t)
{
int lev,
w = s->linelen[s->ndeclevels-1][0];
int *line = s->i_linebuf;
line += 5;
for (lev = s->ndeclevels-1; lev >= 0; lev--){
int lh = s->linelen[lev][0],
lv = s->linelen[lev][1],
mh = s->mod[lev][0],
mv = s->mod[lev][1],
lp;
int *l;
l = line + mv;
for (lp = 0; lp < lh; lp++) {
int i, j = 0;
for (i = 0; i < lv; i++)
l[i] = t[w*i + lp];
sd_1d97_int(line, mv, mv + lv);
for (i = mv; i < lv; i+=2, j++)
t[w*j + lp] = ((l[i] * I_LFTG_X) + (1 << 16)) >> 17;
for (i = 1-mv; i < lv; i+=2, j++)
t[w*j + lp] = ((l[i] * I_LFTG_K) + (1 << 16)) >> 17;
}
l = line + mh;
for (lp = 0; lp < lv; lp++){
int i, j = 0;
for (i = 0; i < lh; i++)
l[i] = t[w*lp + i];
sd_1d97_int(line, mh, mh + lh);
for (i = mh; i < lh; i+=2, j++)
t[w*lp + j] = ((l[i] * I_LFTG_X) + (1 << 16)) >> 17;
for (i = 1-mh; i < lh; i+=2, j++)
t[w*lp + j] = ((l[i] * I_LFTG_K) + (1 << 16)) >> 17;
}
}
}
|
vulnpatchpairs_data_18329
|
static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QBool *qbool;
if (!qobj) {
return;
}
qbool = qobject_to_qbool(qobj);
if (!qbool) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"boolean");
return;
}
*obj = qbool_get_bool(qbool);
}
|
vulnpatchpairs_data_10962
|
int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilterBufferRef *picref)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterLink *outlink = buffer_filter->outputs[0];
int ret;
if (c->picref) {
av_log(buffer_filter, AV_LOG_ERROR,
"Buffering several frames is not supported. "
"Please consume all available frames before adding a new one.\n"
);
}
if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
AVFilterContext *scale = buffer_filter->outputs[0]->dst;
AVFilterLink *link;
char scale_param[1024];
av_log(buffer_filter, AV_LOG_INFO,
"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
picref->video->w, picref->video->h, av_pix_fmt_descriptors[picref->format].name);
if (!scale || strcmp(scale->filter->name, "scale")) {
AVFilter *f = avfilter_get_by_name("scale");
av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n");
if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
return ret;
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
avfilter_free(scale);
return ret;
}
if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
avfilter_free(scale);
return ret;
}
scale->outputs[0]->time_base = scale->inputs[0]->time_base;
scale->outputs[0]->format= c->pix_fmt;
} else if (!strcmp(scale->filter->name, "scale")) {
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s",
scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
scale->filter->init(scale, scale_param, NULL);
}
c->pix_fmt = scale->inputs[0]->format = picref->format;
c->w = scale->inputs[0]->w = picref->video->w;
c->h = scale->inputs[0]->h = picref->video->h;
link = scale->outputs[0];
if ((ret = link->srcpad->config_props(link)) < 0)
return ret;
}
c->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
picref->video->w, picref->video->h);
av_image_copy(c->picref->data, c->picref->linesize,
picref->data, picref->linesize,
picref->format, picref->video->w, picref->video->h);
avfilter_copy_buffer_ref_props(c->picref, picref);
return 0;
}
|
vulnpatchpairs_data_17885
|
static int emulated_exitfn(CCIDCardState *base)
{
EmulatedState *card = DO_UPCAST(EmulatedState, base, base);
VEvent *vevent = vevent_new(VEVENT_LAST, NULL, NULL);
vevent_queue_vevent(vevent);
qemu_mutex_lock(&card->apdu_thread_quit_mutex);
card->quit_apdu_thread = 1;
qemu_cond_signal(&card->handle_apdu_cond);
qemu_cond_wait(&card->apdu_thread_quit_cond,
&card->apdu_thread_quit_mutex);
qemu_cond_destroy(&card->handle_apdu_cond);
qemu_cond_destroy(&card->apdu_thread_quit_cond);
qemu_mutex_destroy(&card->apdu_thread_quit_mutex);
qemu_mutex_destroy(&card->handle_apdu_mutex);
qemu_mutex_destroy(&card->vreader_mutex);
qemu_mutex_destroy(&card->event_list_mutex);
return 0;
}
|
vulnpatchpairs_data_11070
|
void qmp_guest_file_flush(int64_t handle, Error **errp)
{
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
FILE *fh;
int ret;
if (!gfh) {
return;
}
fh = gfh->fh;
ret = fflush(fh);
if (ret == EOF) {
error_setg_errno(errp, errno, "failed to flush file");
}
}
|
vulnpatchpairs_data_18624
|
static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
{
long i;
for (i = 0; i <= w - sizeof(long); i += sizeof(long)) {
long a = *(long *)(src1 + i);
long b = *(long *)(src2 + i);
*(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80);
}
for (; i < w; i++)
dst[i] = src1[i] + src2[i];
}
|
vulnpatchpairs_data_15125
|
static int latm_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
PutBitContext bs;
int i, len;
uint8_t loas_header[] = "\x56\xe0\x00";
uint8_t *buf = NULL;
if (s->streams[0]->codec->codec_id == CODEC_ID_AAC_LATM)
return ff_raw_write_packet(s, pkt);
if (pkt->size > 2 && pkt->data[0] == 0xff && (pkt->data[1] >> 4) == 0xf) {
av_log(s, AV_LOG_ERROR, "ADTS header detected - ADTS will not be incorrectly muxed into LATM\n");
return AVERROR_INVALIDDATA;
}
if (pkt->size > 0x1fff)
goto too_large;
buf = av_malloc(pkt->size+1024);
if (!buf)
return AVERROR(ENOMEM);
init_put_bits(&bs, buf, pkt->size+1024);
latm_write_frame_header(s, &bs);
for (i = 0; i <= pkt->size-255; i+=255)
put_bits(&bs, 8, 255);
put_bits(&bs, 8, pkt->size-i);
if (pkt->size && (pkt->data[0] & 0xe1) == 0x81) {
put_bits(&bs, 8, pkt->data[0] & 0xfe);
avpriv_copy_bits(&bs, pkt->data + 1, 8*pkt->size - 8);
} else
avpriv_copy_bits(&bs, pkt->data, 8*pkt->size);
avpriv_align_put_bits(&bs);
flush_put_bits(&bs);
len = put_bits_count(&bs) >> 3;
if (len > 0x1fff)
goto too_large;
loas_header[1] |= (len >> 8) & 0x1f;
loas_header[2] |= len & 0xff;
avio_write(pb, loas_header, 3);
avio_write(pb, buf, len);
av_free(buf);
return 0;
too_large:
av_log(s, AV_LOG_ERROR, "LATM packet size larger than maximum size 0x1fff\n");
av_free(buf);
return AVERROR_INVALIDDATA;
}
|
vulnpatchpairs_data_16767
|
static int compare_int64(const void *a, const void *b)
{
int64_t va = *(int64_t *)a, vb = *(int64_t *)b;
return va < vb ? -1 : va > vb ? +1 : 0;
}
|
vulnpatchpairs_data_11334
|
static coroutine_fn int vmdk_co_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
int ret;
BDRVVmdkState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
ret = vmdk_write(bs, sector_num, buf, nb_sectors);
qemu_co_mutex_unlock(&s->lock);
return ret;
}
|
vulnpatchpairs_data_17553
|
static int write_target_commit(BlockDriverState *bs, int64_t sector_num,
const uint8_t* buffer, int nb_sectors) {
BDRVVVFATState* s = bs->opaque;
return try_commit(s);
}
|
vulnpatchpairs_data_12946
|
void HELPER(mvc)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src)
{
int i = 0;
int x = 0;
uint32_t l_64 = (l + 1) / 8;
HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
__func__, l, dest, src);
#ifndef CONFIG_USER_ONLY
if ((l > 32) &&
(src & TARGET_PAGE_MASK) == ((src + l) & TARGET_PAGE_MASK) &&
(dest & TARGET_PAGE_MASK) == ((dest + l) & TARGET_PAGE_MASK)) {
if (dest == (src + 1)) {
mvc_fast_memset(env, l + 1, dest, cpu_ldub_data(env, src));
return;
} else if ((src & TARGET_PAGE_MASK) != (dest & TARGET_PAGE_MASK)) {
mvc_fast_memmove(env, l + 1, dest, src);
return;
}
}
#else
if (dest == (src + 1)) {
memset(g2h(dest), cpu_ldub_data(env, src), l + 1);
return;
} else {
memmove(g2h(dest), g2h(src), l + 1);
return;
}
#endif
if (dest != (src + 1)) {
for (i = 0; i < l_64; i++) {
cpu_stq_data(env, dest + x, cpu_ldq_data(env, src + x));
x += 8;
}
}
for (i = x; i <= l; i++) {
cpu_stb_data(env, dest + i, cpu_ldub_data(env, src + i));
}
}
|
vulnpatchpairs_data_21794
|
static void kvm_hwpoison_page_add(ram_addr_t ram_addr)
{
HWPoisonPage *page;
QLIST_FOREACH(page, &hwpoison_page_list, list) {
if (page->ram_addr == ram_addr) {
return;
}
}
page = g_malloc(sizeof(HWPoisonPage));
page->ram_addr = ram_addr;
QLIST_INSERT_HEAD(&hwpoison_page_list, page, list);
}
|
vulnpatchpairs_data_12243
|
bool bdrv_is_first_non_filter(BlockDriverState *candidate)
{
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
while ((it = bdrv_next(it, &bs)) != NULL) {
bool perm;
perm = bdrv_recurse_is_first_non_filter(bs, candidate);
if (perm) {
return true;
}
}
return false;
}
|
vulnpatchpairs_data_9434
|
static int64_t nfs_client_open(NFSClient *client, const char *filename,
int flags, Error **errp)
{
int ret = -EINVAL, i;
struct stat st;
URI *uri;
QueryParams *qp = NULL;
char *file = NULL, *strp = NULL;
uri = uri_parse(filename);
if (!uri) {
error_setg(errp, "Invalid URL specified");
goto fail;
}
if (!uri->server) {
error_setg(errp, "Invalid URL specified");
goto fail;
}
strp = strrchr(uri->path, '/');
if (strp == NULL) {
error_setg(errp, "Invalid URL specified");
goto fail;
}
file = g_strdup(strp);
*strp = 0;
client->context = nfs_init_context();
if (client->context == NULL) {
error_setg(errp, "Failed to init NFS context");
goto fail;
}
qp = query_params_parse(uri->query);
for (i = 0; i < qp->n; i++) {
if (!qp->p[i].value) {
error_setg(errp, "Value for NFS parameter expected: %s",
qp->p[i].name);
goto fail;
}
if (!strncmp(qp->p[i].name, "uid", 3)) {
nfs_set_uid(client->context, atoi(qp->p[i].value));
} else if (!strncmp(qp->p[i].name, "gid", 3)) {
nfs_set_gid(client->context, atoi(qp->p[i].value));
} else if (!strncmp(qp->p[i].name, "tcp-syncnt", 10)) {
nfs_set_tcp_syncnt(client->context, atoi(qp->p[i].value));
} else {
error_setg(errp, "Unknown NFS parameter name: %s",
qp->p[i].name);
goto fail;
}
}
ret = nfs_mount(client->context, uri->server, uri->path);
if (ret < 0) {
error_setg(errp, "Failed to mount nfs share: %s",
nfs_get_error(client->context));
goto fail;
}
if (flags & O_CREAT) {
ret = nfs_creat(client->context, file, 0600, &client->fh);
if (ret < 0) {
error_setg(errp, "Failed to create file: %s",
nfs_get_error(client->context));
goto fail;
}
} else {
ret = nfs_open(client->context, file, flags, &client->fh);
if (ret < 0) {
error_setg(errp, "Failed to open file : %s",
nfs_get_error(client->context));
goto fail;
}
}
ret = nfs_fstat(client->context, client->fh, &st);
if (ret < 0) {
error_setg(errp, "Failed to fstat file: %s",
nfs_get_error(client->context));
goto fail;
}
ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE);
client->has_zero_init = S_ISREG(st.st_mode);
goto out;
fail:
nfs_client_close(client);
out:
if (qp) {
query_params_free(qp);
}
uri_free(uri);
g_free(file);
return ret;
}
|
vulnpatchpairs_data_1089
|
int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,
uint64_t iova, uint64_t len)
{
struct vhost_iotlb_msg imsg;
imsg.iova = iova;
imsg.size = len;
imsg.type = VHOST_IOTLB_INVALIDATE;
return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
}
|
vulnpatchpairs_data_14599
|
void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
{
int i;
for (i=0; i < in->n; i++) {
int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
do {
out[x] = 0.0;
x += in->pitch_lag;
} while (x < size && repeats);
}
}
|
vulnpatchpairs_data_1736
|
static void test_qemu_strtoll_whitespace(void)
{
const char *str = " \t ";
char f = 'X';
const char *endptr = &f;
int64_t res = 999;
int err;
err = qemu_strtoll(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
|
vulnpatchpairs_data_8431
|
static void put_uint8(QEMUFile *f, void *pv, size_t size)
{
uint8_t *v = pv;
qemu_put_8s(f, v);
}
|
vulnpatchpairs_data_21925
|
static int hls_read_header(AVFormatContext *s)
{
void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
HLSContext *c = s->priv_data;
int ret = 0, i;
int highest_cur_seq_no = 0;
c->ctx = s;
c->interrupt_callback = &s->interrupt_callback;
c->strict_std_compliance = s->strict_std_compliance;
c->first_packet = 1;
c->first_timestamp = AV_NOPTS_VALUE;
c->cur_timestamp = AV_NOPTS_VALUE;
if (u) {
update_options(&c->user_agent, "user-agent", u);
update_options(&c->cookies, "cookies", u);
update_options(&c->headers, "headers", u);
update_options(&c->http_proxy, "http_proxy", u);
}
if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0)
goto fail;
if ((ret = save_avio_options(s)) < 0)
goto fail;
av_dict_set(&c->avio_opts, "seekable", "0", 0);
if (c->n_variants == 0) {
av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
ret = AVERROR_EOF;
goto fail;
}
if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) {
for (i = 0; i < c->n_playlists; i++) {
struct playlist *pls = c->playlists[i];
if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0)
goto fail;
}
}
if (c->variants[0]->playlists[0]->n_segments == 0) {
av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
ret = AVERROR_EOF;
goto fail;
}
if (c->variants[0]->playlists[0]->finished) {
int64_t duration = 0;
for (i = 0; i < c->variants[0]->playlists[0]->n_segments; i++)
duration += c->variants[0]->playlists[0]->segments[i]->duration;
s->duration = duration;
}
for (i = 0; i < c->n_variants; i++) {
struct variant *var = c->variants[i];
if (var->audio_group[0])
add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO, var->audio_group);
if (var->video_group[0])
add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO, var->video_group);
if (var->subtitles_group[0])
add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE, var->subtitles_group);
}
for (i = 0; i < c->n_variants; i++) {
struct variant *v = c->variants[i];
AVProgram *program;
program = av_new_program(s, i);
if (!program)
goto fail;
av_dict_set_int(&program->metadata, "variant_bitrate", v->bandwidth, 0);
}
for (i = 0; i < c->n_playlists; i++) {
struct playlist *pls = c->playlists[i];
if (pls->n_segments == 0)
continue;
pls->cur_seq_no = select_cur_seq_no(c, pls);
highest_cur_seq_no = FFMAX(highest_cur_seq_no, pls->cur_seq_no);
}
for (i = 0; i < c->n_playlists; i++) {
struct playlist *pls = c->playlists[i];
AVInputFormat *in_fmt = NULL;
if (!(pls->ctx = avformat_alloc_context())) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (pls->n_segments == 0)
continue;
pls->index = i;
pls->needed = 1;
pls->parent = s;
if (!pls->finished && pls->cur_seq_no == highest_cur_seq_no - 1 &&
highest_cur_seq_no < pls->start_seq_no + pls->n_segments) {
pls->cur_seq_no = highest_cur_seq_no;
}
pls->read_buffer = av_malloc(INITIAL_BUFFER_SIZE);
if (!pls->read_buffer){
ret = AVERROR(ENOMEM);
avformat_free_context(pls->ctx);
pls->ctx = NULL;
goto fail;
}
ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls,
read_data, NULL, NULL);
pls->pb.seekable = 0;
ret = av_probe_input_buffer(&pls->pb, &in_fmt, pls->segments[0]->url,
NULL, 0, 0);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error when loading first segment '%s'\n", pls->segments[0]->url);
avformat_free_context(pls->ctx);
pls->ctx = NULL;
goto fail;
}
pls->ctx->pb = &pls->pb;
pls->ctx->io_open = nested_io_open;
if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0)
goto fail;
ret = avformat_open_input(&pls->ctx, pls->segments[0]->url, in_fmt, NULL);
if (ret < 0)
goto fail;
if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
ff_id3v2_parse_apic(pls->ctx, &pls->id3_deferred_extra);
avformat_queue_attached_pictures(pls->ctx);
ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);
pls->id3_deferred_extra = NULL;
}
if (pls->is_id3_timestamped == -1)
av_log(s, AV_LOG_WARNING, "No expected HTTP requests have been made\n");
if (pls->is_id3_timestamped) {
ret = avformat_find_stream_info(pls->ctx, NULL);
if (ret < 0)
goto fail;
}
pls->has_noheader_flag = !!(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER);
ret = update_streams_from_subdemuxer(s, pls);
if (ret < 0)
goto fail;
add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_AUDIO);
add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_VIDEO);
add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_SUBTITLE);
}
update_noheader_flag(s);
return 0;
fail:
free_playlist_list(c);
free_variant_list(c);
free_rendition_list(c);
return ret;
}
|
vulnpatchpairs_data_6025
|
void qemu_system_reset(void)
{
QEMUResetEntry *re, *nre;
QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
re->func(re->opaque);
}
}
|
vulnpatchpairs_data_24483
|
static void gen_pool16c_insn(DisasContext *ctx, int *is_branch)
{
int rd = mmreg((ctx->opcode >> 3) & 0x7);
int rs = mmreg(ctx->opcode & 0x7);
int opc;
switch (((ctx->opcode) >> 4) & 0x3f) {
case NOT16 + 0:
case NOT16 + 1:
case NOT16 + 2:
case NOT16 + 3:
gen_logic(ctx, OPC_NOR, rd, rs, 0);
break;
case XOR16 + 0:
case XOR16 + 1:
case XOR16 + 2:
case XOR16 + 3:
gen_logic(ctx, OPC_XOR, rd, rd, rs);
break;
case AND16 + 0:
case AND16 + 1:
case AND16 + 2:
case AND16 + 3:
gen_logic(ctx, OPC_AND, rd, rd, rs);
break;
case OR16 + 0:
case OR16 + 1:
case OR16 + 2:
case OR16 + 3:
gen_logic(ctx, OPC_OR, rd, rd, rs);
break;
case LWM16 + 0:
case LWM16 + 1:
case LWM16 + 2:
case LWM16 + 3:
{
static const int lwm_convert[] = { 0x11, 0x12, 0x13, 0x14 };
int offset = ZIMM(ctx->opcode, 0, 4);
gen_ldst_multiple(ctx, LWM32, lwm_convert[(ctx->opcode >> 4) & 0x3],
29, offset << 2);
}
break;
case SWM16 + 0:
case SWM16 + 1:
case SWM16 + 2:
case SWM16 + 3:
{
static const int swm_convert[] = { 0x11, 0x12, 0x13, 0x14 };
int offset = ZIMM(ctx->opcode, 0, 4);
gen_ldst_multiple(ctx, SWM32, swm_convert[(ctx->opcode >> 4) & 0x3],
29, offset << 2);
}
break;
case JR16 + 0:
case JR16 + 1:
{
int reg = ctx->opcode & 0x1f;
gen_compute_branch(ctx, OPC_JR, 2, reg, 0, 0);
}
*is_branch = 1;
break;
case JRC16 + 0:
case JRC16 + 1:
{
int reg = ctx->opcode & 0x1f;
gen_compute_branch(ctx, OPC_JR, 2, reg, 0, 0);
}
break;
case JALR16 + 0:
case JALR16 + 1:
opc = OPC_JALR;
goto do_jalr;
case JALR16S + 0:
case JALR16S + 1:
opc = OPC_JALRS;
do_jalr:
{
int reg = ctx->opcode & 0x1f;
gen_compute_branch(ctx, opc, 2, reg, 31, 0);
}
*is_branch = 1;
break;
case MFHI16 + 0:
case MFHI16 + 1:
gen_HILO(ctx, OPC_MFHI, 0, uMIPS_RS5(ctx->opcode));
break;
case MFLO16 + 0:
case MFLO16 + 1:
gen_HILO(ctx, OPC_MFLO, 0, uMIPS_RS5(ctx->opcode));
break;
case BREAK16:
generate_exception(ctx, EXCP_BREAK);
break;
case SDBBP16:
check_insn(ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case JRADDIUSP + 0:
case JRADDIUSP + 1:
{
int imm = ZIMM(ctx->opcode, 0, 5);
gen_compute_branch(ctx, OPC_JR, 2, 31, 0, 0);
gen_arith_imm(ctx, OPC_ADDIU, 29, 29, imm << 2);
}
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
|
vulnpatchpairs_data_18409
|
int64_t qmp_guest_fsfreeze_freeze(Error **err)
{
int ret = 0, i = 0;
FsMountList mounts;
struct FsMount *mount;
Error *local_err = NULL;
int fd;
slog("guest-fsfreeze called");
execute_fsfreeze_hook(FSFREEZE_HOOK_FREEZE, &local_err);
if (error_is_set(&local_err)) {
error_propagate(err, local_err);
return -1;
}
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (error_is_set(&local_err)) {
error_propagate(err, local_err);
return -1;
}
ga_set_frozen(ga_state);
QTAILQ_FOREACH(mount, &mounts, next) {
fd = qemu_open(mount->dirname, O_RDONLY);
if (fd == -1) {
error_setg_errno(err, errno, "failed to open %s", mount->dirname);
goto error;
}
ret = ioctl(fd, FIFREEZE);
if (ret == -1) {
if (errno != EOPNOTSUPP) {
error_setg_errno(err, errno, "failed to freeze %s",
mount->dirname);
close(fd);
goto error;
}
} else {
i++;
}
close(fd);
}
free_fs_mount_list(&mounts);
return i;
error:
free_fs_mount_list(&mounts);
qmp_guest_fsfreeze_thaw(NULL);
return 0;
}
|
vulnpatchpairs_data_7267
|
static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
uint64_t value;
MemoryRegion *mr;
PCDIMMDevice *dimm = PC_DIMM(obj);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
mr = ddc->get_memory_region(dimm);
value = memory_region_size(mr);
visit_type_uint64(v, name, &value, errp);
}
|
vulnpatchpairs_data_2620
|
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length)
{
CPUArchState *env;
int mmu_idx;
assert_cpu_is_self(cpu);
env = cpu->env_ptr;
for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
unsigned int i;
for (i = 0; i < CPU_TLB_SIZE; i++) {
tlb_reset_dirty_range(&env->tlb_table[mmu_idx][i],
start1, length);
}
for (i = 0; i < CPU_VTLB_SIZE; i++) {
tlb_reset_dirty_range(&env->tlb_v_table[mmu_idx][i],
start1, length);
}
}
}
|
vulnpatchpairs_data_13114
|
void pl011_init(uint32_t base, qemu_irq irq,
CharDriverState *chr)
{
int iomemtype;
pl011_state *s;
s = (pl011_state *)qemu_mallocz(sizeof(pl011_state));
iomemtype = cpu_register_io_memory(0, pl011_readfn,
pl011_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->irq = irq;
s->chr = chr;
s->read_trigger = 1;
s->ifl = 0x12;
s->cr = 0x300;
s->flags = 0x90;
if (chr){
qemu_chr_add_handlers(chr, pl011_can_recieve, pl011_recieve,
pl011_event, s);
}
}
|
vulnpatchpairs_data_22006
|
bool timerlist_expired(QEMUTimerList *timer_list)
{
int64_t expire_time;
if (!atomic_read(&timer_list->active_timers)) {
return false;
}
qemu_mutex_lock(&timer_list->active_timers_lock);
if (!timer_list->active_timers) {
qemu_mutex_unlock(&timer_list->active_timers_lock);
return false;
}
expire_time = timer_list->active_timers->expire_time;
qemu_mutex_unlock(&timer_list->active_timers_lock);
return expire_time < qemu_clock_get_ns(timer_list->clock->type);
}
|
vulnpatchpairs_data_21335
|
int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, int version_id)
{
VMStateField *field = vmsd->fields;
int ret = 0;
trace_vmstate_load_state(vmsd->name, version_id);
if (version_id > vmsd->version_id) {
error_report("%s: incoming version_id %d is too new "
"for local version_id %d",
vmsd->name, version_id, vmsd->version_id);
trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL);
return -EINVAL;
}
if (version_id < vmsd->minimum_version_id) {
if (vmsd->load_state_old &&
version_id >= vmsd->minimum_version_id_old) {
ret = vmsd->load_state_old(f, opaque, version_id);
trace_vmstate_load_state_end(vmsd->name, "old path", ret);
return ret;
}
error_report("%s: incoming version_id %d is too old "
"for local minimum version_id %d",
vmsd->name, version_id, vmsd->minimum_version_id);
trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL);
return -EINVAL;
}
if (vmsd->pre_load) {
int ret = vmsd->pre_load(opaque);
if (ret) {
return ret;
}
}
while (field->name) {
trace_vmstate_load_state_field(vmsd->name, field->name);
if ((field->field_exists &&
field->field_exists(opaque, version_id)) ||
(!field->field_exists &&
field->version_id <= version_id)) {
void *first_elem = opaque + field->offset;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
vmstate_handle_alloc(first_elem, field, opaque);
if (field->flags & VMS_POINTER) {
first_elem = *(void **)first_elem;
assert(first_elem || !n_elems);
}
for (i = 0; i < n_elems; i++) {
void *curr_elem = first_elem + size * i;
if (field->flags & VMS_ARRAY_OF_POINTER) {
curr_elem = *(void **)curr_elem;
}
if (field->flags & VMS_STRUCT) {
ret = vmstate_load_state(f, field->vmsd, curr_elem,
field->vmsd->version_id);
} else {
ret = field->info->get(f, curr_elem, size, field);
}
if (ret >= 0) {
ret = qemu_file_get_error(f);
}
if (ret < 0) {
qemu_file_set_error(f, ret);
error_report("Failed to load %s:%s", vmsd->name,
field->name);
trace_vmstate_load_field_error(field->name, ret);
return ret;
}
}
} else if (field->flags & VMS_MUST_EXIST) {
error_report("Input validation failed: %s/%s",
vmsd->name, field->name);
return -1;
}
field++;
}
ret = vmstate_subsection_load(f, vmsd, opaque);
if (ret != 0) {
return ret;
}
if (vmsd->post_load) {
ret = vmsd->post_load(opaque, version_id);
}
trace_vmstate_load_state_end(vmsd->name, "end", ret);
return ret;
}
|
vulnpatchpairs_data_369
|
void stream_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *base, const char *backing_file_str,
int64_t speed, BlockdevOnError on_error,
BlockCompletionFunc *cb, void *opaque, Error **errp)
{
StreamBlockJob *s;
s = block_job_create(job_id, &stream_job_driver, bs, speed,
cb, opaque, errp);
if (!s) {
return;
}
s->base = base;
s->backing_file_str = g_strdup(backing_file_str);
s->on_error = on_error;
s->common.co = qemu_coroutine_create(stream_run);
trace_stream_start(bs, base, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
}
|
vulnpatchpairs_data_164
|
void OPPROTO op_udiv_T1_T0(void)
{
uint64_t x0;
uint32_t x1;
x0 = T0 | ((uint64_t) (env->y) << 32);
x1 = T1;
x0 = x0 / x1;
if (x0 > 0xffffffff) {
T0 = 0xffffffff;
T1 = 1;
} else {
T0 = x0;
T1 = 0;
FORCE_RET();
|
vulnpatchpairs_data_7048
|
static int get_buffer_sao(HEVCContext *s, AVFrame *frame, const HEVCSPS *sps)
{
int ret, i;
frame->width = s->avctx->width + 2;
frame->height = s->avctx->height + 2;
if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
for (i = 0; frame->data[i]; i++) {
int offset = frame->linesize[i] + (1 << sps->pixel_shift);
frame->data[i] += offset;
}
frame->width = s->avctx->width;
frame->height = s->avctx->height;
return 0;
}
|
vulnpatchpairs_data_21007
|
static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len,
int append)
{
int buflen;
if (!append) {
s->frame_offset = get_bits_count(gb) & 7;
s->num_saved_bits = s->frame_offset;
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
buflen = (s->num_saved_bits + len + 8) >> 3;
if (len <= 0 || buflen > MAX_FRAMESIZE) {
avpriv_request_sample(s->avctx, "Too small input buffer");
s->num_saved_bits += len;
if (!append) {
avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3),
s->num_saved_bits);
} else {
int align = 8 - (get_bits_count(gb) & 7);
align = FFMIN(align, len);
put_bits(&s->pb, align, get_bits(gb, align));
len -= align;
avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len);
skip_bits_long(gb, len);
{
PutBitContext tmp = s->pb;
flush_put_bits(&tmp);
init_get_bits(&s->gb, s->frame_data, s->num_saved_bits);
skip_bits(&s->gb, s->frame_offset);
|
vulnpatchpairs_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) {
ret = GetOverlappedResult(c->handle, &ov, &written, TRUE);
if (!ret) {
if (!GetLastError()) {
status = G_IO_STATUS_AGAIN;
} else {
status = G_IO_STATUS_ERROR;
} else {
status = G_IO_STATUS_NORMAL;
*count = written;
} else {
status = G_IO_STATUS_ERROR;
} else {
status = G_IO_STATUS_NORMAL;
*count = written;
return status;
|
vulnpatchpairs_data_20613
|
static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
const uint8_t *src_in[4], int srcW, int xInc,
const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize,
uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
const uint8_t *src = src_in[isAlpha ? 3 : 0];
if (toYV12) {
toYV12(formatConvBuffer, src, srcW, pal);
src= formatConvBuffer;
} else if (c->readLumPlanar && !isAlpha) {
c->readLumPlanar(formatConvBuffer, src_in, srcW);
src = formatConvBuffer;
}
if (!c->hyscale_fast) {
c->hyScale(c, dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize);
} else {
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
}
if (convertRange)
convertRange(dst, dstWidth);
}
|
vulnpatchpairs_data_9509
|
static void vga_draw_graphic(VGAState *s, int full_update)
{
int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask, depth;
int width, height, shift_control, line_offset, page0, page1, bwidth, bits;
int disp_width, multi_scan, multi_run;
uint8_t *d;
uint32_t v, addr1, addr;
vga_draw_line_func *vga_draw_line;
full_update |= update_basic_params(s);
if (!full_update)
vga_sync_dirty_bitmap(s);
s->get_resolution(s, &width, &height);
disp_width = width;
shift_control = (s->gr[0x05] >> 5) & 3;
double_scan = (s->cr[0x09] >> 7);
if (shift_control != 1) {
multi_scan = (((s->cr[0x09] & 0x1f) + 1) << double_scan) - 1;
} else {
multi_scan = double_scan;
}
multi_run = multi_scan;
if (shift_control != s->shift_control ||
double_scan != s->double_scan) {
full_update = 1;
s->shift_control = shift_control;
s->double_scan = double_scan;
}
if (shift_control == 0) {
full_update |= update_palette16(s);
if (s->sr[0x01] & 8) {
v = VGA_DRAW_LINE4D2;
disp_width <<= 1;
} else {
v = VGA_DRAW_LINE4;
}
bits = 4;
} else if (shift_control == 1) {
full_update |= update_palette16(s);
if (s->sr[0x01] & 8) {
v = VGA_DRAW_LINE2D2;
disp_width <<= 1;
} else {
v = VGA_DRAW_LINE2;
}
bits = 4;
} else {
switch(s->get_bpp(s)) {
default:
case 0:
full_update |= update_palette256(s);
v = VGA_DRAW_LINE8D2;
bits = 4;
break;
case 8:
full_update |= update_palette256(s);
v = VGA_DRAW_LINE8;
bits = 8;
break;
case 15:
v = VGA_DRAW_LINE15;
bits = 16;
break;
case 16:
v = VGA_DRAW_LINE16;
bits = 16;
break;
case 24:
v = VGA_DRAW_LINE24;
bits = 24;
break;
case 32:
v = VGA_DRAW_LINE32;
bits = 32;
break;
}
}
vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
depth = s->get_bpp(s);
if (s->line_offset != s->last_line_offset ||
disp_width != s->last_width ||
height != s->last_height ||
s->last_depth != depth) {
if (depth == 16 || depth == 32) {
if (is_graphic_console()) {
qemu_free_displaysurface(s->ds->surface);
s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,
s->line_offset,
s->vram_ptr + (s->start_addr * 4));
dpy_resize(s->ds);
} else {
qemu_console_resize(s->ds, disp_width, height);
}
} else {
qemu_console_resize(s->ds, disp_width, height);
}
s->last_scr_width = disp_width;
s->last_scr_height = height;
s->last_width = disp_width;
s->last_height = height;
s->last_line_offset = s->line_offset;
s->last_depth = depth;
full_update = 1;
} else if (is_graphic_console() && is_buffer_shared(s->ds->surface) &&
(full_update || s->ds->surface->data != s->vram_ptr + (s->start_addr * 4))) {
s->ds->surface->data = s->vram_ptr + (s->start_addr * 4);
dpy_setdata(s->ds);
}
s->rgb_to_pixel =
rgb_to_pixel_dup_table[get_depth_index(s->ds)];
if (!is_buffer_shared(s->ds->surface) && s->cursor_invalidate)
s->cursor_invalidate(s);
line_offset = s->line_offset;
#if 0
printf("w=%d h=%d v=%d line_offset=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n",
width, height, v, line_offset, s->cr[9], s->cr[0x17], s->line_compare, s->sr[0x01]);
#endif
addr1 = (s->start_addr * 4);
bwidth = (width * bits + 7) / 8;
y_start = -1;
page_min = 0x7fffffff;
page_max = -1;
d = ds_get_data(s->ds);
linesize = ds_get_linesize(s->ds);
y1 = 0;
for(y = 0; y < height; y++) {
addr = addr1;
if (!(s->cr[0x17] & 1)) {
int shift;
shift = 14 + ((s->cr[0x17] >> 6) & 1);
addr = (addr & ~(1 << shift)) | ((y1 & 1) << shift);
}
if (!(s->cr[0x17] & 2)) {
addr = (addr & ~0x8000) | ((y1 & 2) << 14);
}
page0 = s->vram_offset + (addr & TARGET_PAGE_MASK);
page1 = s->vram_offset + ((addr + bwidth - 1) & TARGET_PAGE_MASK);
update = full_update |
cpu_physical_memory_get_dirty(page0, VGA_DIRTY_FLAG) |
cpu_physical_memory_get_dirty(page1, VGA_DIRTY_FLAG);
if ((page1 - page0) > TARGET_PAGE_SIZE) {
update |= cpu_physical_memory_get_dirty(page0 + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG);
}
update |= (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1;
if (update) {
if (y_start < 0)
y_start = y;
if (page0 < page_min)
page_min = page0;
if (page1 > page_max)
page_max = page1;
if (!(is_buffer_shared(s->ds->surface))) {
vga_draw_line(s, d, s->vram_ptr + addr, width);
if (s->cursor_draw_line)
s->cursor_draw_line(s, d, y);
}
} else {
if (y_start >= 0) {
dpy_update(s->ds, 0, y_start,
disp_width, y - y_start);
y_start = -1;
}
}
if (!multi_run) {
mask = (s->cr[0x17] & 3) ^ 3;
if ((y1 & mask) == mask)
addr1 += line_offset;
y1++;
multi_run = multi_scan;
} else {
multi_run--;
}
if (y == s->line_compare)
addr1 = 0;
d += linesize;
}
if (y_start >= 0) {
dpy_update(s->ds, 0, y_start,
disp_width, y - y_start);
}
if (page_max != -1) {
cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG);
}
memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);
}
|
vulnpatchpairs_data_7521
|
static void monitor_find_completion(const char *cmdline)
{
const char *cmdname;
char *args[MAX_ARGS];
int nb_args, i, len;
const char *ptype, *str;
const mon_cmd_t *cmd;
const KeyDef *key;
parse_cmdline(cmdline, &nb_args, args);
#ifdef DEBUG_COMPLETION
for(i = 0; i < nb_args; i++) {
monitor_printf(cur_mon, "arg%d = '%s'\n", i, (char *)args[i]);
}
#endif
len = strlen(cmdline);
if (len > 0 && qemu_isspace(cmdline[len - 1])) {
if (nb_args >= MAX_ARGS)
return;
args[nb_args++] = qemu_strdup("");
}
if (nb_args <= 1) {
if (nb_args == 0)
cmdname = "";
else
cmdname = args[0];
readline_set_completion_index(cur_mon->rs, strlen(cmdname));
for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
cmd_completion(cmdname, cmd->name);
}
} else {
for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(args[0], cmd->name))
goto found;
}
return;
found:
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
ptype = next_arg_type(ptype);
while (*ptype == '?')
ptype = next_arg_type(ptype);
}
}
str = args[nb_args - 1];
if (*ptype == '-' && ptype[1] != '\0') {
ptype += 2;
}
switch(*ptype) {
case 'F':
readline_set_completion_index(cur_mon->rs, strlen(str));
file_completion(str);
break;
case 'B':
readline_set_completion_index(cur_mon->rs, strlen(str));
bdrv_iterate(block_completion_it, (void *)str);
break;
case 's':
if (!strcmp(cmd->name, "info")) {
readline_set_completion_index(cur_mon->rs, strlen(str));
for(cmd = info_cmds; cmd->name != NULL; cmd++) {
cmd_completion(str, cmd->name);
}
} else if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
readline_set_completion_index(cur_mon->rs, strlen(str));
for(key = key_defs; key->name != NULL; key++) {
cmd_completion(str, key->name);
}
} else if (!strcmp(cmd->name, "help|?")) {
readline_set_completion_index(cur_mon->rs, strlen(str));
for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
cmd_completion(str, cmd->name);
}
}
break;
default:
break;
}
}
for(i = 0; i < nb_args; i++)
qemu_free(args[i]);
}
|
vulnpatchpairs_data_23786
|
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt) {
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PCXContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p = &s->picture;
int compressed, xmin, ymin, xmax, ymax;
unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,
bytes_per_scanline;
uint8_t *ptr;
uint8_t const *bufstart = buf;
uint8_t *scanline;
int ret = -1;
if (buf[0] != 0x0a || buf[1] > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;
}
compressed = buf[2];
xmin = AV_RL16(buf+ 4);
ymin = AV_RL16(buf+ 6);
xmax = AV_RL16(buf+ 8);
ymax = AV_RL16(buf+10);
if (xmax < xmin || ymax < ymin) {
av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
w = xmax - xmin + 1;
h = ymax - ymin + 1;
bits_per_pixel = buf[3];
bytes_per_line = AV_RL16(buf+66);
nplanes = buf[65];
bytes_per_scanline = nplanes * bytes_per_line;
if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8) {
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((nplanes<<8) + bits_per_pixel) {
case 0x0308:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
buf += 128;
if (p->data[0])
avctx->release_buffer(avctx, p);
if (av_image_check_size(w, h, 0, avctx))
return AVERROR_INVALIDDATA;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if ((ret = avctx->get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
scanline = av_malloc(bytes_per_scanline);
if (!scanline)
return AVERROR(ENOMEM);
if (nplanes == 3 && bits_per_pixel == 8) {
for (y=0; y<h; y++) {
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++) {
ptr[3*x ] = scanline[x ];
ptr[3*x+1] = scanline[x+ bytes_per_line ];
ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
}
ptr += stride;
}
} else if (nplanes == 1 && bits_per_pixel == 8) {
const uint8_t *palstart = bufstart + buf_size - 769;
for (y=0; y<h; y++, ptr+=stride) {
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
memcpy(ptr, scanline, w);
}
if (buf != palstart) {
av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");
buf = palstart;
}
if (*buf++ != 12) {
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
ret = AVERROR_INVALIDDATA;
goto end;
}
} else if (nplanes == 1) {
GetBitContext s;
for (y=0; y<h; y++) {
init_get_bits(&s, scanline, bytes_per_scanline<<3);
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
ptr += stride;
}
} else {
int i;
for (y=0; y<h; y++) {
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++) {
int m = 0x80 >> (x&7), v = 0;
for (i=nplanes - 1; i>=0; i--) {
v <<= 1;
v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
}
ptr[x] = v;
}
ptr += stride;
}
}
if (nplanes == 1 && bits_per_pixel == 8) {
pcx_palette(&buf, (uint32_t *) p->data[1], 256);
} else if (bits_per_pixel * nplanes == 1) {
AV_WN32A(p->data[1] , 0xFF000000);
AV_WN32A(p->data[1]+4, 0xFFFFFFFF);
} else if (bits_per_pixel < 8) {
const uint8_t *palette = bufstart+16;
pcx_palette(&palette, (uint32_t *) p->data[1], 16);
}
*picture = s->picture;
*data_size = sizeof(AVFrame);
ret = buf - bufstart;
end:
av_free(scanline);
return ret;
}
|
vulnpatchpairs_data_21919
|
void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
c->bytestream_start=
c->bytestream= buf;
c->bytestream_end= buf + buf_size;
#if CABAC_BITS == 16
c->low = (*c->bytestream++)<<18;
c->low+= (*c->bytestream++)<<10;
#else
c->low = (*c->bytestream++)<<10;
#endif
c->low+= ((*c->bytestream++)<<2) + 2;
c->range= 0x1FE;
}
|
vulnpatchpairs_data_3824
|
static int cow_create(const char *filename, QemuOpts *opts, Error **errp)
{
struct cow_header_v2 cow_header;
struct stat st;
int64_t image_sectors = 0;
char *image_filename = NULL;
Error *local_err = NULL;
int ret;
BlockDriverState *cow_bs;
image_sectors = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / 512;
image_filename = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
ret = bdrv_create_file(filename, opts, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
cow_bs = NULL;
ret = bdrv_open(&cow_bs, filename, NULL, NULL,
BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
memset(&cow_header, 0, sizeof(cow_header));
cow_header.magic = cpu_to_be32(COW_MAGIC);
cow_header.version = cpu_to_be32(COW_VERSION);
if (image_filename) {
cow_header.mtime = cpu_to_be32(0);
if (stat(image_filename, &st) != 0) {
goto mtime_fail;
}
cow_header.mtime = cpu_to_be32(st.st_mtime);
mtime_fail:
pstrcpy(cow_header.backing_file, sizeof(cow_header.backing_file),
image_filename);
}
cow_header.sectorsize = cpu_to_be32(512);
cow_header.size = cpu_to_be64(image_sectors * 512);
ret = bdrv_pwrite(cow_bs, 0, &cow_header, sizeof(cow_header));
if (ret < 0) {
goto exit;
}
ret = bdrv_truncate(cow_bs,
sizeof(cow_header) + ((image_sectors + 7) >> 3));
if (ret < 0) {
goto exit;
}
exit:
g_free(image_filename);
bdrv_unref(cow_bs);
return ret;
}
|
vulnpatchpairs_data_16933
|
static void quorum_copy_qiov(QEMUIOVector *dest, QEMUIOVector *source)
{
int i;
assert(dest->niov == source->niov);
assert(dest->size == source->size);
for (i = 0; i < source->niov; i++) {
assert(dest->iov[i].iov_len == source->iov[i].iov_len);
memcpy(dest->iov[i].iov_base,
source->iov[i].iov_base,
source->iov[i].iov_len);
}
}
|
vulnpatchpairs_data_14366
|
const AVOption *av_opt_next(void *obj, const AVOption *last)
{
AVClass *class = *(AVClass**)obj;
if (!last && class->option[0].name) return class->option;
if (last && last[1].name) return ++last;
return NULL;
}
|
vulnpatchpairs_data_16370
|
static int ftp_abort(URLContext *h)
{
static const char *command = "ABOR\r\n";
int err;
static const int abor_codes[] = {225, 226, 0};
FTPContext *s = h->priv_data;
if (ftp_send_command(s, command, NULL, NULL) < 0) {
ftp_close_both_connections(s);
if ((err = ftp_connect_control_connection(h)) < 0) {
av_log(h, AV_LOG_ERROR, "Reconnect failed.\n");
return err;
}
} else {
ftp_close_data_connection(s);
}
if (ftp_status(s, NULL, abor_codes) < 225) {
ffurl_closep(&s->conn_control);
if ((err = ftp_connect_control_connection(h)) < 0) {
av_log(h, AV_LOG_ERROR, "Reconnect failed.\n");
return err;
}
}
return 0;
}
|
vulnpatchpairs_data_10801
|
static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
uint64_t prdt_addr = le64_to_cpu(cmd->tbl_addr) + 0x80;
int sglist_alloc_hint = opts >> AHCI_CMD_HDR_PRDT_LEN;
dma_addr_t prdt_len = (sglist_alloc_hint * sizeof(AHCI_SG));
dma_addr_t real_prdt_len = prdt_len;
uint8_t *prdt;
int i;
int r = 0;
int sum = 0;
int off_idx = -1;
int off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
}
if (!(prdt = dma_memory_map(ad->hba->as, prdt_addr, &prdt_len,
DMA_DIRECTION_TO_DEVICE))){
DPRINTF(ad->port_no, "map failed\n");
return -1;
}
if (prdt_len < real_prdt_len) {
DPRINTF(ad->port_no, "mapped less than expected\n");
r = -1;
goto out;
}
if (sglist_alloc_hint > 0) {
AHCI_SG *tbl = (AHCI_SG *)prdt;
sum = 0;
for (i = 0; i < sglist_alloc_hint; i++) {
tbl_entry_size = (le32_to_cpu(tbl[i].flags_size) + 1);
if (offset <= (sum + tbl_entry_size)) {
off_idx = i;
off_pos = offset - sum;
break;
}
sum += tbl_entry_size;
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
"off_idx: %d, off_pos: %d\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
}
qemu_sglist_init(sglist, qbus->parent, (sglist_alloc_hint - off_idx),
ad->hba->as);
qemu_sglist_add(sglist, le64_to_cpu(tbl[off_idx].addr + off_pos),
le32_to_cpu(tbl[off_idx].flags_size) + 1 - off_pos);
for (i = off_idx + 1; i < sglist_alloc_hint; i++) {
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
le32_to_cpu(tbl[i].flags_size) + 1);
}
}
out:
dma_memory_unmap(ad->hba->as, prdt, prdt_len,
DMA_DIRECTION_TO_DEVICE, prdt_len);
return r;
}
|
vulnpatchpairs_data_20600
|
static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
GetBitContext *gb)
{
int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
int comment_len;
skip_bits(gb, 2);
sampling_index = get_bits(gb, 4);
if (m4ac->sampling_index != sampling_index)
av_log(avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
num_front = get_bits(gb, 4);
num_side = get_bits(gb, 4);
num_back = get_bits(gb, 4);
num_lfe = get_bits(gb, 2);
num_assoc_data = get_bits(gb, 3);
num_cc = get_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 4);
if (get_bits1(gb))
skip_bits(gb, 3);
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front);
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side );
decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back );
decode_channel_map(NULL, new_che_pos[TYPE_LFE], AAC_CHANNEL_LFE, gb, num_lfe );
skip_bits_long(gb, 4 * num_assoc_data);
decode_channel_map(new_che_pos[TYPE_CCE], new_che_pos[TYPE_CCE], AAC_CHANNEL_CC, gb, num_cc );
align_get_bits(gb);
comment_len = get_bits(gb, 8) * 8;
if (get_bits_left(gb) < comment_len) {
skip_bits_long(gb, comment_len);
return 0;
|
vulnpatchpairs_data_17353
|
static void matroska_add_index_entries(MatroskaDemuxContext *matroska)
{
EbmlList *index_list;
MatroskaIndex *index;
int index_scale = 1;
int i, j;
if (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)
return;
index_list = &matroska->index;
index = index_list->elem;
if (index_list->nb_elem &&
index[0].time > 1E14 / matroska->time_scale) {
av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n");
index_scale = matroska->time_scale;
}
for (i = 0; i < index_list->nb_elem; i++) {
EbmlList *pos_list = &index[i].pos;
MatroskaIndexPos *pos = pos_list->elem;
for (j = 0; j < pos_list->nb_elem; j++) {
MatroskaTrack *track = matroska_find_track_by_num(matroska,
pos[j].track);
if (track && track->stream)
av_add_index_entry(track->stream,
pos[j].pos + matroska->segment_start,
index[i].time / index_scale, 0, 0,
AVINDEX_KEYFRAME);
}
}
}
|
vulnpatchpairs_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;
}
|
vulnpatchpairs_data_4009
|
static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
const uint8_t *src, const uint8_t *src_end,
int width, int esc_count)
{
int i = 0;
int count;
uint8_t zero_run = 0;
const uint8_t *src_start = src;
uint8_t mask1 = -(esc_count < 2);
uint8_t mask2 = -(esc_count < 3);
uint8_t *end = dst + (width - 2);
avpriv_request_sample(l->avctx, "zero_run_line");
return AVERROR_PATCHWELCOME;
output_zeros:
if (l->zeros_rem) {
count = FFMIN(l->zeros_rem, width - i);
if (end - dst < count) {
av_log(l->avctx, AV_LOG_ERROR, "Too many zeros remaining.\n");
return AVERROR_INVALIDDATA;
}
memset(dst, 0, count);
l->zeros_rem -= count;
dst += count;
}
while (dst < end) {
i = 0;
while (!zero_run && dst + i < end) {
i++;
if (i+2 >= src_end - src)
return AVERROR_INVALIDDATA;
zero_run =
!(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));
}
if (zero_run) {
zero_run = 0;
i += esc_count;
memcpy(dst, src, i);
dst += i;
l->zeros_rem = lag_calc_zero_run(src[i]);
src += i + 1;
goto output_zeros;
} else {
memcpy(dst, src, i);
src += i;
dst += i;
}
}
return src - src_start;
}
|
vulnpatchpairs_data_6543
|
static int asf_read_ext_content(AVFormatContext *s, const GUIDParseTable *g)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t size = avio_rl64(pb);
uint16_t nb_desc = avio_rl16(pb);
int i, ret;
for (i = 0; i < nb_desc; i++) {
uint16_t name_len, type, val_len;
uint8_t *name = NULL;
name_len = avio_rl16(pb);
if (!name_len)
return AVERROR_INVALIDDATA;
name = av_malloc(name_len);
if (!name)
return AVERROR(ENOMEM);
avio_get_str16le(pb, name_len, name,
name_len);
type = avio_rl16(pb);
val_len = avio_rl16(pb);
if ((ret = process_metadata(s, name, name_len, val_len, type, &s->metadata)) < 0)
return ret;
}
align_position(pb, asf->offset, size);
return 0;
}
|
vulnpatchpairs_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;
}
|
vulnpatchpairs_data_26100
|
int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y)
{
if (!mb_x) {
return mb_y ? VERT_VP8_PRED : DC_129_PRED;
} else {
return mb_y ? mode : HOR_VP8_PRED;
}
}
|
vulnpatchpairs_data_19912
|
av_cold int ff_ivi_decode_close(AVCodecContext *avctx)
{
IVI45DecContext *ctx = avctx->priv_data;
ivi_free_buffers(&ctx->planes[0]);
if (ctx->mb_vlc.cust_tab.table)
ff_free_vlc(&ctx->mb_vlc.cust_tab);
av_frame_free(&ctx->p_frame);
return 0;
}
|
vulnpatchpairs_data_9934
|
int ff_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
{
int i;
for (i = 0; i < 256; i++) {
int r, g, b;
switch (pix_fmt) {
case AV_PIX_FMT_RGB8:
r = (i>>5 )*36;
g = ((i>>2)&7)*36;
b = (i&3 )*85;
break;
case AV_PIX_FMT_BGR8:
b = (i>>6 )*85;
g = ((i>>3)&7)*36;
r = (i&7 )*36;
break;
case AV_PIX_FMT_RGB4_BYTE:
r = (i>>3 )*255;
g = ((i>>1)&3)*85;
b = (i&1 )*255;
break;
case AV_PIX_FMT_BGR4_BYTE:
b = (i>>3 )*255;
g = ((i>>1)&3)*85;
r = (i&1 )*255;
break;
case AV_PIX_FMT_GRAY8:
r = b = g = i;
break;
default:
return AVERROR(EINVAL);
}
pal[i] = b + (g<<8) + (r<<16) + (0xFF<<24);
}
return 0;
}
|
vulnpatchpairs_data_26315
|
static void bdrv_co_drain_bh_cb(void *opaque)
{
BdrvCoDrainData *data = opaque;
Coroutine *co = data->co;
qemu_bh_delete(data->bh);
bdrv_drain_poll(data->bs);
data->done = true;
qemu_coroutine_enter(co, NULL);
}
|
vulnpatchpairs_data_7191
|
static bool qht_insert__locked(struct qht *ht, struct qht_map *map,
struct qht_bucket *head, void *p, uint32_t hash,
bool *needs_resize)
{
struct qht_bucket *b = head;
struct qht_bucket *prev = NULL;
struct qht_bucket *new = NULL;
int i;
do {
for (i = 0; i < QHT_BUCKET_ENTRIES; i++) {
if (b->pointers[i]) {
if (unlikely(b->pointers[i] == p)) {
return false;
}
} else {
goto found;
}
}
prev = b;
b = b->next;
} while (b);
b = qemu_memalign(QHT_BUCKET_ALIGN, sizeof(*b));
memset(b, 0, sizeof(*b));
new = b;
i = 0;
atomic_inc(&map->n_added_buckets);
if (unlikely(qht_map_needs_resize(map)) && needs_resize) {
*needs_resize = true;
}
found:
seqlock_write_begin(&head->sequence);
if (new) {
atomic_rcu_set(&prev->next, b);
}
b->hashes[i] = hash;
atomic_set(&b->pointers[i], p);
seqlock_write_end(&head->sequence);
return true;
}
|
vulnpatchpairs_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:
*poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
|
vulnpatchpairs_data_10773
|
static av_cold int svq1_encode_init(AVCodecContext *avctx)
{
SVQ1Context * const s = avctx->priv_data;
dsputil_init(&s->dsp, avctx);
avctx->coded_frame= (AVFrame*)&s->picture;
s->frame_width = avctx->width;
s->frame_height = avctx->height;
s->y_block_width = (s->frame_width + 15) / 16;
s->y_block_height = (s->frame_height + 15) / 16;
s->c_block_width = (s->frame_width / 4 + 15) / 16;
s->c_block_height = (s->frame_height / 4 + 15) / 16;
s->avctx= avctx;
s->m.avctx= avctx;
s->m.me.scratchpad= av_mallocz((avctx->width+64)*2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->mb_type = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int16_t));
s->dummy = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int32_t));
h263_encode_init(&s->m);
return 0;
}
|
vulnpatchpairs_data_25738
|
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos,
int *end_pos2)
{
if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) {
s->gb = s->in_gb;
s->in_gb.buffer = NULL;
assert((get_bits_count(&s->gb) & 7) == 0);
skip_bits_long(&s->gb, *pos - *end_pos);
*end_pos2 =
*end_pos = *end_pos2 + get_bits_count(&s->gb) - *pos;
*pos = get_bits_count(&s->gb);
}
}
|
vulnpatchpairs_data_14639
|
static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
{
int16_t *block = ctx->dct_block;
unsigned int pos;
ctx->bdsp.clear_block(block);
block[0] = get_bits(&ctx->gb, 8) << 3;
for (pos = 1; pos < num_coeffs; pos++) {
uint32_t vlc, num_bits;
int value;
int coeff;
vlc = get_vlc2(&ctx->gb, ctx->vlc.table, ctx->vlc.bits, 3);
if (!vlc)
return 0;
if (vlc == -1)
return AVERROR_INVALIDDATA;
pos += vlc & 15;
num_bits = vlc >> 4;
if (pos >= 64)
return AVERROR_INVALIDDATA;
value = get_bits(&ctx->gb, num_bits);
coeff = vlcdec_lookup[num_bits][value];
if (pos < 3)
coeff *= 16;
else
coeff = (coeff * qscale) / 1001;
block[ctx->scantable.permutated[pos]] = coeff;
}
return 0;
}
|
vulnpatchpairs_data_25737
|
static BufferPoolEntry *get_pool(AVBufferPool *pool)
{
BufferPoolEntry *cur = NULL, *last = NULL;
do {
FFSWAP(BufferPoolEntry*, cur, last);
cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, last, NULL);
if (!cur)
return NULL;
} while (cur != last);
return cur;
}
|
vulnpatchpairs_data_24655
|
static void test_function(const TestStruct test_sample)
{
int ret, i;
void **output_data = NULL;
AVAudioFifo *afifo = av_audio_fifo_alloc(test_sample.format, test_sample.nb_ch,
test_sample.nb_samples_pch);
if (!afifo) {
ERROR("ERROR: av_audio_fifo_alloc returned NULL!");
}
ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0);
if (ret < 0){
ERROR("ERROR: av_audio_fifo_write failed!");
}
printf("written: %d\n", ret);
ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0);
if (ret < 0){
ERROR("ERROR: av_audio_fifo_write failed!");
}
printf("written: %d\n", ret);
printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));
ret = read_samples_from_audio_fifo(afifo, &output_data, test_sample.nb_samples_pch);
if (ret < 0){
ERROR("ERROR: av_audio_fifo_read failed!");
}
printf("read: %d\n", ret);
print_audio_bytes(&test_sample, output_data, ret);
printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));
ret = av_audio_fifo_peek(afifo, output_data, afifo->nb_samples);
if (ret < 0){
ERROR("ERROR: av_audio_fifo_peek failed!");
}
printf("peek:\n");
print_audio_bytes(&test_sample, output_data, ret);
printf("\n");
printf("peek_at:\n");
for (i = 0; i < afifo->nb_samples; ++i){
ret = av_audio_fifo_peek_at(afifo, output_data, 1, i);
if (ret < 0){
ERROR("ERROR: av_audio_fifo_peek_at failed!");
}
printf("%d:\n", i);
print_audio_bytes(&test_sample, output_data, ret);
}
printf("\n");
ret = av_audio_fifo_drain(afifo, afifo->nb_samples);
if (ret < 0){
ERROR("ERROR: av_audio_fifo_drain failed!");
}
if (afifo->nb_samples){
ERROR("drain failed to flush all samples in audio_fifo!");
}
for (i = 0; i < afifo->nb_buffers; ++i){
av_freep(&output_data[i]);
}
av_freep(&output_data);
av_audio_fifo_free(afifo);
}
|
vulnpatchpairs_data_24424
|
static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias)
{
IndividualChannelStream *ics = &sce->ics;
float *in = sce->coeffs;
float *out = sce->ret;
float *saved = sce->saved;
const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
float *buf = ac->buf_mdct;
float *temp = ac->temp;
int i;
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
if (ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE)
av_log(ac->avctx, AV_LOG_WARNING,
"Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. "
"If you heard an audible artifact, please submit the sample to the FFmpeg developers.\n");
for (i = 0; i < 1024; i += 128)
ff_imdct_half(&ac->mdct_small, buf + i, in + i);
} else
ff_imdct_half(&ac->mdct, buf, in);
if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
(ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, bias, 512);
} else {
for (i = 0; i < 448; i++)
out[i] = saved[i] + bias;
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, bias, 64);
ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, bias, 64);
ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, bias, 64);
ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, bias, 64);
ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, bias, 64);
memcpy( out + 448 + 4*128, temp, 64 * sizeof(float));
} else {
ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, bias, 64);
for (i = 576; i < 1024; i++)
out[i] = buf[i-512] + bias;
}
}
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
for (i = 0; i < 64; i++)
saved[i] = temp[64 + i] - bias;
ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
} else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
memcpy( saved, buf + 512, 448 * sizeof(float));
memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
} else {
memcpy( saved, buf + 512, 512 * sizeof(float));
}
}
|
vulnpatchpairs_data_17932
|
static inline void pred_direct_motion(H264Context * const h, int *mb_type){
MpegEncContext * const s = &h->s;
const int mb_xy = s->mb_x + s->mb_y*s->mb_stride;
const int b8_xy = 2*s->mb_x + 2*s->mb_y*h->b8_stride;
const int b4_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
const int mb_type_col = h->ref_list[1][0].mb_type[mb_xy];
const int16_t (*l1mv0)[2] = (const int16_t (*)[2]) &h->ref_list[1][0].motion_val[0][b4_xy];
const int16_t (*l1mv1)[2] = (const int16_t (*)[2]) &h->ref_list[1][0].motion_val[1][b4_xy];
const int8_t *l1ref0 = &h->ref_list[1][0].ref_index[0][b8_xy];
const int8_t *l1ref1 = &h->ref_list[1][0].ref_index[1][b8_xy];
const int is_b8x8 = IS_8X8(*mb_type);
int sub_mb_type;
int i8, i4;
if(IS_8X8(mb_type_col) && !h->sps.direct_8x8_inference_flag){
sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type = MB_TYPE_8x8|MB_TYPE_L0L1;
}else if(!is_b8x8 && (IS_16X16(mb_type_col) || IS_INTRA(mb_type_col))){
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
}else{
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type = MB_TYPE_8x8|MB_TYPE_L0L1;
}
if(!is_b8x8)
*mb_type |= MB_TYPE_DIRECT2;
tprintf("mb_type = %08x, sub_mb_type = %08x, is_b8x8 = %d, mb_type_col = %08x\n", *mb_type, sub_mb_type, is_b8x8, mb_type_col);
if(h->direct_spatial_mv_pred){
int ref[2];
int mv[2][2];
int list;
for(list=0; list<2; list++){
int refa = h->ref_cache[list][scan8[0] - 1];
int refb = h->ref_cache[list][scan8[0] - 8];
int refc = h->ref_cache[list][scan8[0] - 8 + 4];
if(refc == -2)
refc = h->ref_cache[list][scan8[0] - 8 - 1];
ref[list] = refa;
if(ref[list] < 0 || (refb < ref[list] && refb >= 0))
ref[list] = refb;
if(ref[list] < 0 || (refc < ref[list] && refc >= 0))
ref[list] = refc;
if(ref[list] < 0)
ref[list] = -1;
}
if(ref[0] < 0 && ref[1] < 0){
ref[0] = ref[1] = 0;
mv[0][0] = mv[0][1] =
mv[1][0] = mv[1][1] = 0;
}else{
for(list=0; list<2; list++){
if(ref[list] >= 0)
pred_motion(h, 0, 4, list, ref[list], &mv[list][0], &mv[list][1]);
else
mv[list][0] = mv[list][1] = 0;
}
}
if(ref[1] < 0){
*mb_type &= ~MB_TYPE_P0L1;
sub_mb_type &= ~MB_TYPE_P0L1;
}else if(ref[0] < 0){
*mb_type &= ~MB_TYPE_P0L0;
sub_mb_type &= ~MB_TYPE_P0L0;
}
if(IS_16X16(*mb_type)){
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, ref[1], 1);
if(!IS_INTRA(mb_type_col)
&& ( (l1ref0[0] == 0 && ABS(l1mv0[0][0]) <= 1 && ABS(l1mv0[0][1]) <= 1)
|| (l1ref0[0] < 0 && l1ref1[0] == 0 && ABS(l1mv1[0][0]) <= 1 && ABS(l1mv1[0][1]) <= 1
&& (h->x264_build>33 || !h->x264_build)))){
if(ref[0] > 0)
fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv[0][0],mv[0][1]), 4);
else
fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
if(ref[1] > 0)
fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, pack16to32(mv[1][0],mv[1][1]), 4);
else
fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
}else{
fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv[0][0],mv[0][1]), 4);
fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, pack16to32(mv[1][0],mv[1][1]), 4);
}
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mv[0][0],mv[0][1]), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mv[1][0],mv[1][1]), 4);
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, ref[1], 1);
if(!IS_INTRA(mb_type_col) && ( l1ref0[x8 + y8*h->b8_stride] == 0
|| (l1ref0[x8 + y8*h->b8_stride] < 0 && l1ref1[x8 + y8*h->b8_stride] == 0
&& (h->x264_build>33 || !h->x264_build)))){
const int16_t (*l1mv)[2]= l1ref0[x8 + y8*h->b8_stride] == 0 ? l1mv0 : l1mv1;
for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*h->b_stride];
if(ABS(mv_col[0]) <= 1 && ABS(mv_col[1]) <= 1){
if(ref[0] == 0)
*(uint32_t*)h->mv_cache[0][scan8[i8*4+i4]] = 0;
if(ref[1] == 0)
*(uint32_t*)h->mv_cache[1][scan8[i8*4+i4]] = 0;
}
}
}
}
}
}else{
if(IS_16X16(*mb_type)){
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if(IS_INTRA(mb_type_col)){
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
}else{
const int ref0 = l1ref0[0] >= 0 ? h->map_col_to_list0[0][l1ref0[0]]
: h->map_col_to_list0[1][l1ref1[0]];
const int dist_scale_factor = h->dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (dist_scale_factor * mv_col[0] + 128) >> 8;
mv_l0[1] = (dist_scale_factor * mv_col[1] + 128) >> 8;
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv_l0[0],mv_l0[1]), 4);
fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]), 4);
}
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, dist_scale_factor;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
if(IS_INTRA(mb_type_col)){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
}
ref0 = l1ref0[x8 + y8*h->b8_stride];
if(ref0 >= 0)
ref0 = h->map_col_to_list0[0][ref0];
else{
ref0 = h->map_col_to_list0[1][l1ref1[x8 + y8*h->b8_stride]];
l1mv= l1mv1;
}
dist_scale_factor = h->dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*h->b_stride];
int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]];
mv_l0[0] = (dist_scale_factor * mv_col[0] + 128) >> 8;
mv_l0[1] = (dist_scale_factor * mv_col[1] + 128) >> 8;
*(uint32_t*)h->mv_cache[1][scan8[i8*4+i4]] =
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
}
}
}
}
}
|
vulnpatchpairs_data_26435
|
static inline void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
const uint8_t *src, int srcW, int xInc)
{
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
}
|
vulnpatchpairs_data_15115
|
bool aio_poll(AioContext *ctx, bool blocking)
{
AioHandler *node;
int i, ret;
bool progress;
int64_t timeout;
aio_context_acquire(ctx);
progress = false;
if (blocking) {
atomic_add(&ctx->notify_me, 2);
}
ctx->walking_handlers++;
assert(npfd == 0);
if (!aio_epoll_enabled(ctx)) {
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->pfd.events
&& aio_node_check(ctx, node->is_external)) {
add_pollfd(node);
}
}
}
timeout = blocking ? aio_compute_timeout(ctx) : 0;
if (timeout) {
aio_context_release(ctx);
}
if (aio_epoll_check_poll(ctx, pollfds, npfd, timeout)) {
AioHandler epoll_handler;
epoll_handler.pfd.fd = ctx->epollfd;
epoll_handler.pfd.events = G_IO_IN | G_IO_OUT | G_IO_HUP | G_IO_ERR;
npfd = 0;
add_pollfd(&epoll_handler);
ret = aio_epoll(ctx, pollfds, npfd, timeout);
} else {
ret = qemu_poll_ns(pollfds, npfd, timeout);
}
if (blocking) {
atomic_sub(&ctx->notify_me, 2);
}
if (timeout) {
aio_context_acquire(ctx);
}
aio_notify_accept(ctx);
if (ret > 0) {
for (i = 0; i < npfd; i++) {
nodes[i]->pfd.revents = pollfds[i].revents;
}
}
npfd = 0;
ctx->walking_handlers--;
if (aio_dispatch(ctx, ret > 0)) {
progress = true;
}
aio_context_release(ctx);
return progress;
}
|
vulnpatchpairs_data_15999
|
int hvf_vcpu_exec(CPUState *cpu)
{
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = &x86_cpu->env;
int ret = 0;
uint64_t rip = 0;
cpu->halted = 0;
if (hvf_process_events(cpu)) {
return EXCP_HLT;
}
do {
if (cpu->vcpu_dirty) {
hvf_put_registers(cpu);
cpu->vcpu_dirty = false;
}
if (hvf_inject_interrupts(cpu)) {
return EXCP_INTERRUPT;
}
vmx_update_tpr(cpu);
qemu_mutex_unlock_iothread();
if (!cpu_is_bsp(X86_CPU(cpu)) && cpu->halted) {
qemu_mutex_lock_iothread();
return EXCP_HLT;
}
hv_return_t r = hv_vcpu_run(cpu->hvf_fd);
assert_hvf_ok(r);
uint64_t exit_reason = rvmcs(cpu->hvf_fd, VMCS_EXIT_REASON);
uint64_t exit_qual = rvmcs(cpu->hvf_fd, VMCS_EXIT_QUALIFICATION);
uint32_t ins_len = (uint32_t)rvmcs(cpu->hvf_fd,
VMCS_EXIT_INSTRUCTION_LENGTH);
uint64_t idtvec_info = rvmcs(cpu->hvf_fd, VMCS_IDT_VECTORING_INFO);
hvf_store_events(cpu, ins_len, idtvec_info);
rip = rreg(cpu->hvf_fd, HV_X86_RIP);
RFLAGS(env) = rreg(cpu->hvf_fd, HV_X86_RFLAGS);
env->eflags = RFLAGS(env);
qemu_mutex_lock_iothread();
update_apic_tpr(cpu);
current_cpu = cpu;
ret = 0;
switch (exit_reason) {
case EXIT_REASON_HLT: {
macvm_set_rip(cpu, rip + ins_len);
if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
(EFLAGS(env) & IF_MASK))
&& !(cpu->interrupt_request & CPU_INTERRUPT_NMI) &&
!(idtvec_info & VMCS_IDT_VEC_VALID)) {
cpu->halted = 1;
ret = EXCP_HLT;
}
ret = EXCP_INTERRUPT;
break;
}
case EXIT_REASON_MWAIT: {
ret = EXCP_INTERRUPT;
break;
}
case EXIT_REASON_EPT_FAULT:
{
hvf_slot *slot;
addr_t gpa = rvmcs(cpu->hvf_fd, VMCS_GUEST_PHYSICAL_ADDRESS);
if (((idtvec_info & VMCS_IDT_VEC_VALID) == 0) &&
((exit_qual & EXIT_QUAL_NMIUDTI) != 0)) {
vmx_set_nmi_blocking(cpu);
}
slot = hvf_find_overlap_slot(gpa, gpa);
if (ept_emulation_fault(slot, gpa, exit_qual)) {
struct x86_decode decode;
load_regs(cpu);
env->hvf_emul->fetch_rip = rip;
decode_instruction(env, &decode);
exec_instruction(env, &decode);
store_regs(cpu);
break;
}
break;
}
case EXIT_REASON_INOUT:
{
uint32_t in = (exit_qual & 8) != 0;
uint32_t size = (exit_qual & 7) + 1;
uint32_t string = (exit_qual & 16) != 0;
uint32_t port = exit_qual >> 16;
#if 1
if (!string && in) {
uint64_t val = 0;
load_regs(cpu);
hvf_handle_io(env, port, &val, 0, size, 1);
if (size == 1) {
AL(env) = val;
} else if (size == 2) {
AX(env) = val;
} else if (size == 4) {
RAX(env) = (uint32_t)val;
} else {
VM_PANIC("size");
}
RIP(env) += ins_len;
store_regs(cpu);
break;
} else if (!string && !in) {
RAX(env) = rreg(cpu->hvf_fd, HV_X86_RAX);
hvf_handle_io(env, port, &RAX(env), 1, size, 1);
macvm_set_rip(cpu, rip + ins_len);
break;
}
#endif
struct x86_decode decode;
load_regs(cpu);
env->hvf_emul->fetch_rip = rip;
decode_instruction(env, &decode);
VM_PANIC_ON(ins_len != decode.len);
exec_instruction(env, &decode);
store_regs(cpu);
break;
}
case EXIT_REASON_CPUID: {
uint32_t rax = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RAX);
uint32_t rbx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RBX);
uint32_t rcx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX);
uint32_t rdx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX);
cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx);
wreg(cpu->hvf_fd, HV_X86_RAX, rax);
wreg(cpu->hvf_fd, HV_X86_RBX, rbx);
wreg(cpu->hvf_fd, HV_X86_RCX, rcx);
wreg(cpu->hvf_fd, HV_X86_RDX, rdx);
macvm_set_rip(cpu, rip + ins_len);
break;
}
case EXIT_REASON_XSETBV: {
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = &x86_cpu->env;
uint32_t eax = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RAX);
uint32_t ecx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX);
uint32_t edx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX);
if (ecx) {
macvm_set_rip(cpu, rip + ins_len);
break;
}
env->xcr0 = ((uint64_t)edx << 32) | eax;
wreg(cpu->hvf_fd, HV_X86_XCR0, env->xcr0 | 1);
macvm_set_rip(cpu, rip + ins_len);
break;
}
case EXIT_REASON_INTR_WINDOW:
vmx_clear_int_window_exiting(cpu);
ret = EXCP_INTERRUPT;
break;
case EXIT_REASON_NMI_WINDOW:
vmx_clear_nmi_window_exiting(cpu);
ret = EXCP_INTERRUPT;
break;
case EXIT_REASON_EXT_INTR:
ret = EXCP_INTERRUPT;
break;
case EXIT_REASON_RDMSR:
case EXIT_REASON_WRMSR:
{
load_regs(cpu);
if (exit_reason == EXIT_REASON_RDMSR) {
simulate_rdmsr(cpu);
} else {
simulate_wrmsr(cpu);
}
RIP(env) += rvmcs(cpu->hvf_fd, VMCS_EXIT_INSTRUCTION_LENGTH);
store_regs(cpu);
break;
}
case EXIT_REASON_CR_ACCESS: {
int cr;
int reg;
load_regs(cpu);
cr = exit_qual & 15;
reg = (exit_qual >> 8) & 15;
switch (cr) {
case 0x0: {
macvm_set_cr0(cpu->hvf_fd, RRX(env, reg));
break;
}
case 4: {
macvm_set_cr4(cpu->hvf_fd, RRX(env, reg));
break;
}
case 8: {
X86CPU *x86_cpu = X86_CPU(cpu);
if (exit_qual & 0x10) {
RRX(env, reg) = cpu_get_apic_tpr(x86_cpu->apic_state);
} else {
int tpr = RRX(env, reg);
cpu_set_apic_tpr(x86_cpu->apic_state, tpr);
ret = EXCP_INTERRUPT;
}
break;
}
default:
error_report("Unrecognized CR %d\n", cr);
abort();
}
RIP(env) += ins_len;
store_regs(cpu);
break;
}
case EXIT_REASON_APIC_ACCESS: {
struct x86_decode decode;
load_regs(cpu);
env->hvf_emul->fetch_rip = rip;
decode_instruction(env, &decode);
exec_instruction(env, &decode);
store_regs(cpu);
break;
}
case EXIT_REASON_TPR: {
ret = 1;
break;
}
case EXIT_REASON_TASK_SWITCH: {
uint64_t vinfo = rvmcs(cpu->hvf_fd, VMCS_IDT_VECTORING_INFO);
x68_segment_selector sel = {.sel = exit_qual & 0xffff};
vmx_handle_task_switch(cpu, sel, (exit_qual >> 30) & 0x3,
vinfo & VMCS_INTR_VALID, vinfo & VECTORING_INFO_VECTOR_MASK, vinfo
& VMCS_INTR_T_MASK);
break;
}
case EXIT_REASON_TRIPLE_FAULT: {
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
ret = EXCP_INTERRUPT;
break;
}
case EXIT_REASON_RDPMC:
wreg(cpu->hvf_fd, HV_X86_RAX, 0);
wreg(cpu->hvf_fd, HV_X86_RDX, 0);
macvm_set_rip(cpu, rip + ins_len);
break;
case VMX_REASON_VMCALL:
break;
default:
error_report("%llx: unhandled exit %llx\n", rip, exit_reason);
}
} while (ret == 0);
return ret;
}
|
vulnpatchpairs_data_18175
|
static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr,
AVPacket *avpkt)
{
const char *ptr = avpkt->data;
int len, size = avpkt->size;
while (size > 0) {
ASSDialog *dialog = ff_ass_split_dialog(avctx->priv_data, ptr, 0, NULL);
int duration = dialog->end - dialog->start;
len = ff_ass_add_rect(data, ptr, 0, duration, 1);
if (len < 0)
return len;
ptr += len;
size -= len;
}
*got_sub_ptr = avpkt->size > 0;
return avpkt->size;
}
|
vulnpatchpairs_data_21050
|
void show_help(void)
{
const char *prog;
const OptionDef *po;
int i, expert;
prog = do_play ? "ffplay" : "ffmpeg";
printf("%s version " FFMPEG_VERSION ", Copyright (c) 2000, 2001, 2002 Gerard Lantau\n",
prog);
if (!do_play) {
printf("usage: ffmpeg [[options] -i input_file]... {[options] outfile}...\n"
"Hyper fast MPEG1/MPEG4/H263/RV and AC3/MPEG audio encoder\n");
} else {
printf("usage: ffplay [options] input_file...\n"
"Simple audio player\n");
}
printf("\n"
"Main options are:\n");
for(i=0;i<2;i++) {
if (i == 1)
printf("\nAdvanced options are:\n");
for(po = options; po->name != NULL; po++) {
char buf[64];
expert = (po->flags & OPT_EXPERT) != 0;
if (expert == i) {
strcpy(buf, po->name);
if (po->flags & HAS_ARG) {
strcat(buf, " ");
strcat(buf, po->argname);
}
printf("-%-17s %s\n", buf, po->help);
}
}
}
exit(1);
}
|
vulnpatchpairs_data_8130
|
static void device_unparent(Object *obj)
{
DeviceState *dev = DEVICE(obj);
BusState *bus;
if (dev->realized) {
object_property_set_bool(obj, false, "realized", NULL);
}
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
object_unparent(OBJECT(bus));
}
if (dev->parent_bus) {
bus_remove_child(dev->parent_bus, dev);
object_unref(OBJECT(dev->parent_bus));
dev->parent_bus = NULL;
}
if (dev->pending_deleted_event) {
g_assert(dev->canonical_path);
qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_path,
&error_abort);
g_free(dev->canonical_path);
dev->canonical_path = NULL;
}
}
|
vulnpatchpairs_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;
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);
}
}
}
|
vulnpatchpairs_data_5508
|
static int connect_namedsocket(const char *path)
{
int sockfd, size;
struct sockaddr_un helper;
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
fprintf(stderr, "socket %s\n", strerror(errno));
return -1;
}
strcpy(helper.sun_path, path);
helper.sun_family = AF_UNIX;
size = strlen(helper.sun_path) + sizeof(helper.sun_family);
if (connect(sockfd, (struct sockaddr *)&helper, size) < 0) {
fprintf(stderr, "socket error\n");
return -1;
}
unlink(path);
return sockfd;
}
|
vulnpatchpairs_data_4362
|
static int vmdk_open_vmdk4(BlockDriverState *bs,
BlockDriverState *file,
int flags)
{
int ret;
uint32_t magic;
uint32_t l1_size, l1_entry_sectors;
VMDK4Header header;
VmdkExtent *extent;
int64_t l1_backup_offset = 0;
ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));
if (ret < 0) {
return ret;
}
if (header.capacity == 0) {
int64_t desc_offset = le64_to_cpu(header.desc_offset);
if (desc_offset) {
return vmdk_open_desc_file(bs, flags, desc_offset << 9);
}
}
if (le64_to_cpu(header.gd_offset) == VMDK4_GD_AT_END) {
struct {
struct {
uint64_t val;
uint32_t size;
uint32_t type;
uint8_t pad[512 - 16];
} QEMU_PACKED footer_marker;
uint32_t magic;
VMDK4Header header;
uint8_t pad[512 - 4 - sizeof(VMDK4Header)];
struct {
uint64_t val;
uint32_t size;
uint32_t type;
uint8_t pad[512 - 16];
} QEMU_PACKED eos_marker;
} QEMU_PACKED footer;
ret = bdrv_pread(file,
bs->file->total_sectors * 512 - 1536,
&footer, sizeof(footer));
if (ret < 0) {
return ret;
}
if (be32_to_cpu(footer.magic) != VMDK4_MAGIC ||
le32_to_cpu(footer.footer_marker.size) != 0 ||
le32_to_cpu(footer.footer_marker.type) != MARKER_FOOTER ||
le64_to_cpu(footer.eos_marker.val) != 0 ||
le32_to_cpu(footer.eos_marker.size) != 0 ||
le32_to_cpu(footer.eos_marker.type) != MARKER_END_OF_STREAM)
{
return -EINVAL;
}
header = footer.header;
}
if (le32_to_cpu(header.version) >= 3) {
char buf[64];
snprintf(buf, sizeof(buf), "VMDK version %d",
le32_to_cpu(header.version));
qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bs->device_name, "vmdk", buf);
return -ENOTSUP;
}
l1_entry_sectors = le32_to_cpu(header.num_gtes_per_gte)
* le64_to_cpu(header.granularity);
if (l1_entry_sectors == 0) {
return -EINVAL;
}
l1_size = (le64_to_cpu(header.capacity) + l1_entry_sectors - 1)
/ l1_entry_sectors;
if (le32_to_cpu(header.flags) & VMDK4_FLAG_RGD) {
l1_backup_offset = le64_to_cpu(header.rgd_offset) << 9;
}
extent = vmdk_add_extent(bs, file, false,
le64_to_cpu(header.capacity),
le64_to_cpu(header.gd_offset) << 9,
l1_backup_offset,
l1_size,
le32_to_cpu(header.num_gtes_per_gte),
le64_to_cpu(header.granularity));
extent->compressed =
le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE;
extent->has_marker = le32_to_cpu(header.flags) & VMDK4_FLAG_MARKER;
extent->version = le32_to_cpu(header.version);
extent->has_zero_grain = le32_to_cpu(header.flags) & VMDK4_FLAG_ZERO_GRAIN;
ret = vmdk_init_tables(bs, extent);
if (ret) {
vmdk_free_last_extent(bs);
}
return ret;
}
|
vulnpatchpairs_data_2329
|
static void stellaris_init(const char *kernel_filename, const char *cpu_model,
stellaris_board_info *board)
{
static const int uart_irq[] = {5, 6, 33, 34};
static const int timer_irq[] = {19, 21, 23, 35};
static const uint32_t gpio_addr[7] =
{ 0x40004000, 0x40005000, 0x40006000, 0x40007000,
0x40024000, 0x40025000, 0x40026000};
static const int gpio_irq[7] = {0, 1, 2, 3, 4, 30, 31};
qemu_irq *pic;
DeviceState *gpio_dev[7];
qemu_irq gpio_in[7][8];
qemu_irq gpio_out[7][8];
qemu_irq adc;
int sram_size;
int flash_size;
I2CBus *i2c;
DeviceState *dev;
int i;
int j;
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *system_memory = get_system_memory();
flash_size = (((board->dc0 & 0xffff) + 1) << 1) * 1024;
sram_size = ((board->dc0 >> 18) + 1) * 1024;
memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size,
&error_abort);
vmstate_register_ram_global(flash);
memory_region_set_readonly(flash, true);
memory_region_add_subregion(system_memory, 0, flash);
memory_region_init_ram(sram, NULL, "stellaris.sram", sram_size,
&error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(system_memory, 0x20000000, sram);
pic = armv7m_init(system_memory, flash_size, NUM_IRQ_LINES,
kernel_filename, cpu_model);
if (board->dc1 & (1 << 16)) {
dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000,
pic[14], pic[15], pic[16], pic[17], NULL);
adc = qdev_get_gpio_in(dev, 0);
} else {
adc = NULL;
}
for (i = 0; i < 4; i++) {
if (board->dc2 & (0x10000 << i)) {
dev = sysbus_create_simple(TYPE_STELLARIS_GPTM,
0x40030000 + i * 0x1000,
pic[timer_irq[i]]);
qdev_connect_gpio_out(dev, 0, adc);
}
}
stellaris_sys_init(0x400fe000, pic[28], board, nd_table[0].macaddr.a);
for (i = 0; i < 7; i++) {
if (board->dc4 & (1 << i)) {
gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i],
pic[gpio_irq[i]]);
for (j = 0; j < 8; j++) {
gpio_in[i][j] = qdev_get_gpio_in(gpio_dev[i], j);
gpio_out[i][j] = NULL;
}
}
}
if (board->dc2 & (1 << 12)) {
dev = sysbus_create_simple(TYPE_STELLARIS_I2C, 0x40020000, pic[8]);
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
if (board->peripherals & BP_OLED_I2C) {
i2c_create_slave(i2c, "ssd0303", 0x3d);
}
}
for (i = 0; i < 4; i++) {
if (board->dc2 & (1 << i)) {
sysbus_create_simple("pl011_luminary", 0x4000c000 + i * 0x1000,
pic[uart_irq[i]]);
}
}
if (board->dc2 & (1 << 4)) {
dev = sysbus_create_simple("pl022", 0x40008000, pic[7]);
if (board->peripherals & BP_OLED_SSI) {
void *bus;
DeviceState *sddev;
DeviceState *ssddev;
bus = qdev_get_child_bus(dev, "ssi");
sddev = ssi_create_slave(bus, "ssi-sd");
ssddev = ssi_create_slave(bus, "ssd0323");
gpio_out[GPIO_D][0] = qemu_irq_split(
qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0),
qdev_get_gpio_in_named(ssddev, SSI_GPIO_CS, 0));
gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0);
qemu_irq_raise(gpio_out[GPIO_D][0]);
}
}
if (board->dc4 & (1 << 28)) {
DeviceState *enet;
qemu_check_nic_model(&nd_table[0], "stellaris");
enet = qdev_create(NULL, "stellaris_enet");
qdev_set_nic_properties(enet, &nd_table[0]);
qdev_init_nofail(enet);
sysbus_mmio_map(SYS_BUS_DEVICE(enet), 0, 0x40048000);
sysbus_connect_irq(SYS_BUS_DEVICE(enet), 0, pic[42]);
}
if (board->peripherals & BP_GAMEPAD) {
qemu_irq gpad_irq[5];
static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };
gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]);
gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]);
gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]);
gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]);
gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]);
stellaris_gamepad_init(5, gpad_irq, gpad_keycode);
}
for (i = 0; i < 7; i++) {
if (board->dc4 & (1 << i)) {
for (j = 0; j < 8; j++) {
if (gpio_out[i][j]) {
qdev_connect_gpio_out(gpio_dev[i], j, gpio_out[i][j]);
}
}
}
}
}
|
vulnpatchpairs_data_4006
|
static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
bool query_backing)
{
BlockStats *s = NULL;
s = g_malloc0(sizeof(*s));
s->stats = g_malloc0(sizeof(*s->stats));
if (!bs) {
return s;
}
if (bdrv_get_node_name(bs)[0]) {
s->has_node_name = true;
s->node_name = g_strdup(bdrv_get_node_name(bs));
}
s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset);
if (bs->file) {
s->has_parent = true;
s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing);
}
if (query_backing && bs->backing) {
s->has_backing = true;
s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);
}
return s;
}
|
vulnpatchpairs_data_1338
|
static void sd_1d97_int(int *p, int i0, int i1)
{
int i;
if (i1 <= i0 + 1) {
if (i0 == 1)
p[1] = (p[1] * I_LFTG_X + (1<<15)) >> 16;
else
p[0] = (p[0] * I_LFTG_K + (1<<15)) >> 16;
return;
}
extend97_int(p, i0, i1);
i0++; i1++;
for (i = i0/2 - 2; i < i1/2 + 1; i++)
p[2 * i + 1] -= (I_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
for (i = i0/2 - 1; i < i1/2 + 1; i++)
p[2 * i] -= (I_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
for (i = i0/2 - 1; i < i1/2; i++)
p[2 * i + 1] += (I_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
for (i = i0/2; i < i1/2; i++)
p[2 * i] += (I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
}
|
vulnpatchpairs_data_14814
|
static inline TCGv iwmmxt_load_creg(int reg)
{
TCGv var = new_tmp();
tcg_gen_ld_i32(var, cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));
return var;
}
|
vulnpatchpairs_data_25602
|
static int usb_bt_handle_data(USBDevice *dev, USBPacket *p)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret = 0;
if (!s->config)
goto fail;
switch (p->pid) {
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case USB_EVT_EP:
ret = usb_bt_fifo_dequeue(&s->evt, p);
break;
case USB_ACL_EP:
ret = usb_bt_fifo_dequeue(&s->acl, p);
break;
case USB_SCO_EP:
ret = usb_bt_fifo_dequeue(&s->sco, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep & 0xf) {
case USB_ACL_EP:
usb_bt_fifo_out_enqueue(s, &s->outacl, s->hci->acl_send,
usb_bt_hci_acl_complete, p->data, p->len);
break;
case USB_SCO_EP:
usb_bt_fifo_out_enqueue(s, &s->outsco, s->hci->sco_send,
usb_bt_hci_sco_complete, p->data, p->len);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
|
vulnpatchpairs_data_27148
|
static void pci_hotplug(void)
{
QVirtioPCIDevice *dev;
QOSState *qs;
const char *arch = qtest_get_arch();
qs = pci_test_start();
qpci_plug_device_test("virtio-blk-pci", "drv1", PCI_SLOT_HP,
"'drive': 'drive1'");
dev = virtio_blk_pci_init(qs->pcibus, PCI_SLOT_HP);
g_assert(dev);
qvirtio_pci_device_disable(dev);
g_free(dev);
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
qpci_unplug_acpi_device_test("drv1", PCI_SLOT_HP);
}
qtest_shutdown(qs);
}
|
vulnpatchpairs_data_19908
|
int ff_wma_init(AVCodecContext *avctx, int flags2)
{
WMACodecContext *s = avctx->priv_data;
int i;
float bps1, high_freq;
volatile float bps;
int sample_rate1;
int coef_vlc_table;
if ( avctx->sample_rate <= 0 || avctx->sample_rate > 50000
|| avctx->channels <= 0 || avctx->channels > 2
|| avctx->bit_rate <= 0)
return -1;
ff_fmt_convert_init(&s->fmt_conv, avctx);
avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
if (avctx->codec->id == AV_CODEC_ID_WMAV1) {
s->version = 1;
} else {
s->version = 2;
s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,
s->version, 0);
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
int nb_max, nb;
nb = ((flags2 >> 3) & 3) + 1;
if ((avctx->bit_rate / avctx->channels) >= 32000)
nb += 2;
nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
if (nb > nb_max)
nb = nb_max;
s->nb_block_sizes = nb + 1;
} else {
s->nb_block_sizes = 1;
s->use_noise_coding = 1;
high_freq = avctx->sample_rate * 0.5;
sample_rate1 = avctx->sample_rate;
if (s->version == 2) {
if (sample_rate1 >= 44100) {
sample_rate1 = 44100;
} else if (sample_rate1 >= 22050) {
sample_rate1 = 22050;
} else if (sample_rate1 >= 16000) {
sample_rate1 = 16000;
} else if (sample_rate1 >= 11025) {
sample_rate1 = 11025;
} else if (sample_rate1 >= 8000) {
sample_rate1 = 8000;
bps = (float)avctx->bit_rate / (float)(avctx->channels * avctx->sample_rate);
s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2;
bps1 = bps;
if (avctx->channels == 2)
bps1 = bps * 1.6;
if (sample_rate1 == 44100) {
if (bps1 >= 0.61) {
s->use_noise_coding = 0;
} else {
high_freq = high_freq * 0.4;
} else if (sample_rate1 == 22050) {
if (bps1 >= 1.16) {
s->use_noise_coding = 0;
} else if (bps1 >= 0.72) {
high_freq = high_freq * 0.7;
} else {
high_freq = high_freq * 0.6;
} else if (sample_rate1 == 16000) {
if (bps > 0.5) {
high_freq = high_freq * 0.5;
} else {
high_freq = high_freq * 0.3;
} else if (sample_rate1 == 11025) {
high_freq = high_freq * 0.7;
} else if (sample_rate1 == 8000) {
if (bps <= 0.625) {
high_freq = high_freq * 0.5;
} else if (bps > 0.75) {
s->use_noise_coding = 0;
} else {
high_freq = high_freq * 0.65;
} else {
if (bps >= 0.8) {
high_freq = high_freq * 0.75;
} else if (bps >= 0.6) {
high_freq = high_freq * 0.6;
} else {
high_freq = high_freq * 0.5;
av_dlog(s->avctx, "flags2=0x%x\n", flags2);
av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
avctx->block_align);
av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
{
int a, b, pos, lpos, k, block_len, i, j, n;
const uint8_t *table;
if (s->version == 1) {
s->coefs_start = 3;
} else {
s->coefs_start = 0;
for (k = 0; k < s->nb_block_sizes; k++) {
block_len = s->frame_len >> k;
if (s->version == 1) {
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
s->exponent_bands[0][i] = pos - lpos;
if (pos >= block_len) {
i++;
break;
lpos = pos;
s->exponent_sizes[0] = i;
} else {
table = NULL;
a = s->frame_len_bits - BLOCK_MIN_BITS - k;
if (a < 3) {
if (avctx->sample_rate >= 44100) {
table = exponent_band_44100[a];
} else if (avctx->sample_rate >= 32000) {
table = exponent_band_32000[a];
} else if (avctx->sample_rate >= 22050) {
table = exponent_band_22050[a];
if (table) {
n = *table++;
for (i = 0; i < n; i++)
s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n;
} else {
j = 0;
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
pos = block_len;
if (pos > lpos)
s->exponent_bands[k][j++] = pos - lpos;
if (pos >= block_len)
break;
lpos = pos;
s->exponent_sizes[k] = j;
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
avctx->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
for (i = 0; i < n; i++) {
int start, end;
start = pos;
pos += s->exponent_bands[k][i];
end = pos;
if (start < s->high_band_start[k])
start = s->high_band_start[k];
if (end > s->coefs_end[k])
end = s->coefs_end[k];
if (end > start)
s->exponent_high_bands[k][j++] = end - start;
s->exponent_high_sizes[k] = j;
#if 0
tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> k,
s->coefs_end[k],
s->high_band_start[k],
s->exponent_high_sizes[k]);
for (j = 0; j < s->exponent_high_sizes[k]; j++)
tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
tprintf(s->avctx, "\n");
#endif
#ifdef TRACE
{
int i, j;
for (i = 0; i < s->nb_block_sizes; i++) {
tprintf(s->avctx, "%5d: n=%2d:",
s->frame_len >> i,
s->exponent_sizes[i]);
for (j = 0; j < s->exponent_sizes[i]; j++)
tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
tprintf(s->avctx, "\n");
#endif
for (i = 0; i < s->nb_block_sizes; i++) {
ff_init_ff_sine_windows(s->frame_len_bits - i);
s->windows[i] = ff_sine_windows[s->frame_len_bits - i];
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
if (s->use_exp_vlc) {
s->noise_mult = 0.02;
} else {
s->noise_mult = 0.04;
#ifdef TRACE
for (i = 0; i < NOISE_TAB_SIZE; i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
{
unsigned int seed;
float norm;
seed = 1;
norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
for (i = 0; i < NOISE_TAB_SIZE; i++) {
seed = seed * 314159 + 1;
s->noise_table[i] = (float)((int)seed) * norm;
#endif
coef_vlc_table = 2;
if (avctx->sample_rate >= 32000) {
if (bps1 < 0.72) {
coef_vlc_table = 0;
} else if (bps1 < 1.16) {
coef_vlc_table = 1;
s->coef_vlcs[0]= &coef_vlcs[coef_vlc_table * 2 ];
s->coef_vlcs[1]= &coef_vlcs[coef_vlc_table * 2 + 1];
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0], &s->int_table[0],
s->coef_vlcs[0]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1], &s->int_table[1],
s->coef_vlcs[1]);
return 0;
|
vulnpatchpairs_data_22976
|
static av_cold int vp3_decode_end(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i;
if (avctx->is_copy && !s->current_frame.data[0])
return 0;
av_free(s->superblock_coding);
av_free(s->all_fragments);
av_free(s->coded_fragment_list[0]);
av_free(s->dct_tokens_base);
av_free(s->superblock_fragments);
av_free(s->macroblock_coding);
av_free(s->motion_val[0]);
av_free(s->motion_val[1]);
av_free(s->edge_emu_buffer);
if (avctx->is_copy) return 0;
for (i = 0; i < 16; i++) {
free_vlc(&s->dc_vlc[i]);
free_vlc(&s->ac_vlc_1[i]);
free_vlc(&s->ac_vlc_2[i]);
free_vlc(&s->ac_vlc_3[i]);
free_vlc(&s->ac_vlc_4[i]);
}
free_vlc(&s->superblock_run_length_vlc);
free_vlc(&s->fragment_run_length_vlc);
free_vlc(&s->mode_code_vlc);
free_vlc(&s->motion_vector_vlc);
if (s->golden_frame.data[0])
ff_thread_release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
ff_thread_release_buffer(avctx, &s->last_frame);
return 0;
}
|
vulnpatchpairs_data_18640
|
static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
NE2000State *s = opaque;
int offset, page;
addr &= 0xf;
#ifdef DEBUG_NE2000
printf("NE2000: write addr=0x%x val=0x%02x\n", addr, val);
#endif
if (addr == E8390_CMD) {
s->cmd = val;
if (val & E8390_START) {
s->isr &= ~ENISR_RESET;
if ((val & (E8390_RREAD | E8390_RWRITE)) &&
s->rcnt == 0) {
s->isr |= ENISR_RDC;
ne2000_update_irq(s);
}
if (val & E8390_TRANS) {
qemu_send_packet(s->nd, s->mem + (s->tpsr << 8), s->tcnt);
s->tsr = ENTSR_PTX;
s->isr |= ENISR_TX;
ne2000_update_irq(s);
}
}
} else {
page = s->cmd >> 6;
offset = addr | (page << 4);
switch(offset) {
case EN0_STARTPG:
s->start = val << 8;
break;
case EN0_STOPPG:
s->stop = val << 8;
break;
case EN0_BOUNDARY:
s->boundary = val;
break;
case EN0_IMR:
s->imr = val;
ne2000_update_irq(s);
break;
case EN0_TPSR:
s->tpsr = val;
break;
case EN0_TCNTLO:
s->tcnt = (s->tcnt & 0xff00) | val;
break;
case EN0_TCNTHI:
s->tcnt = (s->tcnt & 0x00ff) | (val << 8);
break;
case EN0_RSARLO:
s->rsar = (s->rsar & 0xff00) | val;
break;
case EN0_RSARHI:
s->rsar = (s->rsar & 0x00ff) | (val << 8);
break;
case EN0_RCNTLO:
s->rcnt = (s->rcnt & 0xff00) | val;
break;
case EN0_RCNTHI:
s->rcnt = (s->rcnt & 0x00ff) | (val << 8);
break;
case EN0_DCFG:
s->dcfg = val;
break;
case EN0_ISR:
s->isr &= ~(val & 0x7f);
ne2000_update_irq(s);
break;
case EN1_PHYS ... EN1_PHYS + 5:
s->phys[offset - EN1_PHYS] = val;
break;
case EN1_CURPAG:
s->curpag = val;
break;
case EN1_MULT ... EN1_MULT + 7:
s->mult[offset - EN1_MULT] = val;
break;
}
}
}
|
vulnpatchpairs_data_22955
|
static void lumRangeToJpeg16_c(int16_t *_dst, int width)
{
int i;
int32_t *dst = (int32_t *) _dst;
for (i = 0; i < width; i++)
dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14;
}
|
vulnpatchpairs_data_17737
|
int swr_init(struct SwrContext *s){
s->in_buffer_index= 0;
s->in_buffer_count= 0;
s->resample_in_constraint= 0;
free_temp(&s->postin);
free_temp(&s->midbuf);
free_temp(&s->preout);
free_temp(&s->in_buffer);
swri_audio_convert_free(&s-> in_convert);
swri_audio_convert_free(&s->out_convert);
swri_audio_convert_free(&s->full_convert);
s-> in.planar= av_sample_fmt_is_planar(s-> in_sample_fmt);
s->out.planar= av_sample_fmt_is_planar(s->out_sample_fmt);
s-> in_sample_fmt= av_get_alt_sample_fmt(s-> in_sample_fmt, 0);
s->out_sample_fmt= av_get_alt_sample_fmt(s->out_sample_fmt, 0);
if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is invalid\n", av_get_sample_fmt_name(s->in_sample_fmt));
return AVERROR(EINVAL);
}
if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is invalid\n", av_get_sample_fmt_name(s->out_sample_fmt));
return AVERROR(EINVAL);
}
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16
&&s->int_sample_fmt != AV_SAMPLE_FMT_FLT){
av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, only float & S16 is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
return AVERROR(EINVAL);
}
if(s->in_sample_fmt <= AV_SAMPLE_FMT_S16 || s->int_sample_fmt==AV_SAMPLE_FMT_S16){
s->int_sample_fmt= AV_SAMPLE_FMT_S16;
}else
s->int_sample_fmt= AV_SAMPLE_FMT_FLT;
if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
s->resample = swri_resample_init(s->resample, s->out_sample_rate, s->in_sample_rate, 16, 10, 0, 0.8);
}else
swri_resample_free(&s->resample);
if(s->int_sample_fmt != AV_SAMPLE_FMT_S16 && s->resample){
av_log(s, AV_LOG_ERROR, "Resampling only supported with internal s16 currently\n");
return -1;
}
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){
av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n");
s-> in_ch_layout= 0;
}
if(!s-> in_ch_layout)
s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count);
if(!s->out_ch_layout)
s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);
s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0;
#define RSC 1
if(!s-> in.ch_count)
s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if(!s->out.ch_count)
s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
av_assert0(s-> in.ch_count);
av_assert0(s->used_ch_count);
av_assert0(s->out.ch_count);
s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s-> in.bps= av_get_bytes_per_sample(s-> in_sample_fmt);
s->int_bps= av_get_bytes_per_sample(s->int_sample_fmt);
s->out.bps= av_get_bytes_per_sample(s->out_sample_fmt);
if(!s->resample && !s->rematrix && !s->channel_map){
s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
return 0;
}
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
s->int_sample_fmt, s->out.ch_count, NULL, 0);
s->postin= s->in;
s->preout= s->out;
s->midbuf= s->in;
s->in_buffer= s->in;
if(s->channel_map){
s->postin.ch_count=
s->midbuf.ch_count=
s->in_buffer.ch_count= s->used_ch_count;
}
if(!s->resample_first){
s->midbuf.ch_count= s->out.ch_count;
s->in_buffer.ch_count = s->out.ch_count;
}
s->in_buffer.bps = s->postin.bps = s->midbuf.bps = s->preout.bps = s->int_bps;
s->in_buffer.planar = s->postin.planar = s->midbuf.planar = s->preout.planar = 1;
if(s->rematrix)
return swri_rematrix_init(s);
return 0;
}
|
vulnpatchpairs_data_1937
|
static int rtsp_listen(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
char proto[128], host[128], path[512], auth[128];
char uri[500];
int port;
int default_port = RTSP_DEFAULT_PORT;
char tcpname[500];
const char *lower_proto = "tcp";
unsigned char rbuf[4096];
unsigned char method[10];
int rbuflen = 0;
int ret;
enum RTSPMethod methodcode;
if (!rt->protocols) {
rt->protocols = ffurl_get_protocols(NULL, NULL);
if (!rt->protocols)
return AVERROR(ENOMEM);
}
av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host),
&port, path, sizeof(path), s->filename);
ff_url_join(rt->control_uri, sizeof(rt->control_uri), proto, NULL, host,
port, "%s", path);
if (!strcmp(proto, "rtsps")) {
lower_proto = "tls";
default_port = RTSPS_DEFAULT_PORT;
}
if (port < 0)
port = default_port;
ff_url_join(tcpname, sizeof(tcpname), lower_proto, NULL, host, port,
"?listen&listen_timeout=%d", rt->initial_timeout * 1000);
if (ret = ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, NULL, rt->protocols)) {
av_log(s, AV_LOG_ERROR, "Unable to open RTSP for listening\n");
return ret;
}
rt->state = RTSP_STATE_IDLE;
rt->rtsp_hd_out = rt->rtsp_hd;
for (;;) {
ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
if (ret < 0)
return ret;
ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
sizeof(method), &methodcode);
if (ret) {
av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
return ret;
}
if (methodcode == ANNOUNCE) {
ret = rtsp_read_announce(s);
rt->state = RTSP_STATE_PAUSED;
} else if (methodcode == OPTIONS) {
ret = rtsp_read_options(s);
} else if (methodcode == RECORD) {
ret = rtsp_read_record(s);
if (!ret)
return 0;
} else if (methodcode == SETUP)
ret = rtsp_read_setup(s, host, uri);
if (ret) {
ffurl_close(rt->rtsp_hd);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
|
vulnpatchpairs_data_2451
|
static int net_vhost_user_init(NetClientState *peer, const char *device,
const char *name, CharDriverState *chr,
int queues)
{
NetClientState *nc;
VhostUserState *s;
int i;
for (i = 0; i < queues; i++) {
nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s",
i, chr->label);
nc->queue_index = i;
s = DO_UPCAST(VhostUserState, nc, nc);
s->chr = chr;
}
qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, (void*)name);
return 0;
}
|
vulnpatchpairs_data_21750
|
static int swf_write_trailer(AVFormatContext *s)
{
SWFContext *swf = s->priv_data;
ByteIOContext *pb = &s->pb;
AVCodecContext *enc, *video_enc;
int file_size, i;
video_enc = NULL;
for(i=0;i<s->nb_streams;i++) {
enc = &s->streams[i]->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO)
video_enc = enc;
}
put_swf_tag(s, TAG_END);
put_swf_end_tag(s);
put_flush_packet(&s->pb);
if (!url_is_streamed(&s->pb) && video_enc) {
file_size = url_ftell(pb);
url_fseek(pb, 4, SEEK_SET);
put_le32(pb, file_size);
url_fseek(pb, swf->duration_pos, SEEK_SET);
put_le16(pb, video_enc->frame_number);
}
av_free(swf);
return 0;
}
|
vulnpatchpairs_data_5630
|
static int init_directories(BDRVVVFATState* s,
const char *dirname, int heads, int secs,
Error **errp)
{
bootsector_t* bootsector;
mapping_t* mapping;
unsigned int i;
unsigned int cluster;
memset(&(s->first_sectors[0]),0,0x40*0x200);
s->cluster_size=s->sectors_per_cluster*0x200;
s->cluster_buffer=g_malloc(s->cluster_size);
i = 1+s->sectors_per_cluster*0x200*8/s->fat_type;
s->sectors_per_fat=(s->sector_count+i)/i;
s->offset_to_fat = s->offset_to_bootsector + 1;
s->offset_to_root_dir = s->offset_to_fat + s->sectors_per_fat * 2;
array_init(&(s->mapping),sizeof(mapping_t));
array_init(&(s->directory),sizeof(direntry_t));
{
direntry_t* entry=array_get_next(&(s->directory));
entry->attributes=0x28;
memcpy(entry->name, s->volume_label, sizeof(entry->name));
}
init_fat(s);
s->cluster_count=sector2cluster(s, s->sector_count);
mapping = array_get_next(&(s->mapping));
mapping->begin = 0;
mapping->dir_index = 0;
mapping->info.dir.parent_mapping_index = -1;
mapping->first_mapping_index = -1;
mapping->path = g_strdup(dirname);
i = strlen(mapping->path);
if (i > 0 && mapping->path[i - 1] == '/')
mapping->path[i - 1] = '\0';
mapping->mode = MODE_DIRECTORY;
mapping->read_only = 0;
s->path = mapping->path;
for (i = 0, cluster = 0; i < s->mapping.next; i++) {
int fix_fat = (i != 0);
mapping = array_get(&(s->mapping), i);
if (mapping->mode & MODE_DIRECTORY) {
mapping->begin = cluster;
if(read_directory(s, i)) {
error_setg(errp, "Could not read directory %s",
mapping->path);
return -1;
}
mapping = array_get(&(s->mapping), i);
} else {
assert(mapping->mode == MODE_UNDEFINED);
mapping->mode=MODE_NORMAL;
mapping->begin = cluster;
if (mapping->end > 0) {
direntry_t* direntry = array_get(&(s->directory),
mapping->dir_index);
mapping->end = cluster + 1 + (mapping->end-1)/s->cluster_size;
set_begin_of_direntry(direntry, mapping->begin);
} else {
mapping->end = cluster + 1;
fix_fat = 0;
}
}
assert(mapping->begin < mapping->end);
cluster = mapping->end;
if(cluster > s->cluster_count) {
error_setg(errp,
"Directory does not fit in FAT%d (capacity %.2f MB)",
s->fat_type, s->sector_count / 2000.0);
return -1;
}
if (fix_fat) {
int j;
for(j = mapping->begin; j < mapping->end - 1; j++)
fat_set(s, j, j+1);
fat_set(s, mapping->end - 1, s->max_fat_value);
}
}
mapping = array_get(&(s->mapping), 0);
s->sectors_of_root_directory = mapping->end * s->sectors_per_cluster;
s->last_cluster_of_root_directory = mapping->end;
fat_set(s,0,s->max_fat_value);
fat_set(s,1,s->max_fat_value);
s->current_mapping = NULL;
bootsector = (bootsector_t *)(s->first_sectors
+ s->offset_to_bootsector * 0x200);
bootsector->jump[0]=0xeb;
bootsector->jump[1]=0x3e;
bootsector->jump[2]=0x90;
memcpy(bootsector->name,"QEMU ",8);
bootsector->sector_size=cpu_to_le16(0x200);
bootsector->sectors_per_cluster=s->sectors_per_cluster;
bootsector->reserved_sectors=cpu_to_le16(1);
bootsector->number_of_fats=0x2;
bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10);
bootsector->total_sectors16=s->sector_count>0xffff?0:cpu_to_le16(s->sector_count);
bootsector->media_type = (s->offset_to_bootsector > 0 ? 0xf8 : 0xf0);
s->fat.pointer[0] = bootsector->media_type;
bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat);
bootsector->sectors_per_track = cpu_to_le16(secs);
bootsector->number_of_heads = cpu_to_le16(heads);
bootsector->hidden_sectors = cpu_to_le32(s->offset_to_bootsector);
bootsector->total_sectors=cpu_to_le32(s->sector_count>0xffff?s->sector_count:0);
bootsector->u.fat16.drive_number = s->offset_to_bootsector == 0 ? 0 : 0x80;
bootsector->u.fat16.signature=0x29;
bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
memcpy(bootsector->u.fat16.volume_label, s->volume_label,
sizeof(bootsector->u.fat16.volume_label));
memcpy(bootsector->u.fat16.fat_type,
s->fat_type == 12 ? "FAT12 " : "FAT16 ", 8);
bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
return 0;
}
|
vulnpatchpairs_data_22801
|
DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType block_default_type)
{
const char *buf;
const char *file = NULL;
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
BlockIOLimit io_limits;
int snapshot = 0;
bool copy_on_read;
int ret;
Error *error = NULL;
translation = BIOS_ATA_TRANSLATION_AUTO;
media = MEDIA_DISK;
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++)
;
if (type == IF_COUNT) {
error_report("unsupported bus type '%s'", buf);
return NULL;
}
} else {
type = block_default_type;
}
max_devs = if_max_devs[type];
if (cyls || heads || secs) {
if (cyls < 1) {
error_report("invalid physical cyls number");
return NULL;
}
if (heads < 1) {
error_report("invalid physical heads number");
return NULL;
}
if (secs < 1) {
error_report("invalid physical secs number");
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
error_report("'%s' trans must be used with cyls, heads and secs",
buf);
return NULL;
}
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 {
error_report("'%s' invalid translation type", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
error_report("CHS can't be set with media=%s", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
error_report("'%s' invalid media", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "discard")) != NULL) {
if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) {
error_report("invalid discard option");
return NULL;
}
}
bdrv_flags |= BDRV_O_CACHE_WB;
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) {
error_report("invalid cache option");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
} else {
error_report("invalid aio option");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(buf)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
error_report("'%s' invalid format", buf);
return NULL;
}
}
io_limits.bps[BLOCK_IO_LIMIT_TOTAL] =
qemu_opt_get_number(opts, "bps", 0);
io_limits.bps[BLOCK_IO_LIMIT_READ] =
qemu_opt_get_number(opts, "bps_rd", 0);
io_limits.bps[BLOCK_IO_LIMIT_WRITE] =
qemu_opt_get_number(opts, "bps_wr", 0);
io_limits.iops[BLOCK_IO_LIMIT_TOTAL] =
qemu_opt_get_number(opts, "iops", 0);
io_limits.iops[BLOCK_IO_LIMIT_READ] =
qemu_opt_get_number(opts, "iops_rd", 0);
io_limits.iops[BLOCK_IO_LIMIT_WRITE] =
qemu_opt_get_number(opts, "iops_wr", 0);
if (!do_check_io_limits(&io_limits, &error)) {
error_report("%s", error_get_pretty(error));
error_free(error);
return NULL;
}
if (qemu_opt_get(opts, "boot") != NULL) {
fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be "
"ignored. Future versions will reject this parameter. Please "
"update your scripts.\n");
}
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
return NULL;
}
}
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
error_report("index cannot be used with bus and unit");
return NULL;
}
bus_id = drive_index_to_bus_id(type, index);
unit_id = drive_index_to_unit_id(type, index);
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
error_report("unit %d too big (max is %d)",
unit_id, max_devs - 1);
return NULL;
}
if (drive_get(type, bus_id, unit_id) != NULL) {
error_report("drive with bus=%d, unit=%d (index=%d) exists",
bus_id, unit_id, index);
return NULL;
}
dinfo = g_malloc0(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = g_strdup(buf);
} else {
dinfo->id = g_malloc0(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
if_name[type], bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
if_name[type], mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
dinfo->bdrv->read_only = ro;
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->cyls = cyls;
dinfo->heads = heads;
dinfo->secs = secs;
dinfo->trans = translation;
dinfo->opts = opts;
dinfo->refcount = 1;
dinfo->serial = serial;
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
bdrv_set_io_limits(dinfo->bdrv, &io_limits);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
dinfo->media_cd = media == MEDIA_CDROM;
break;
case IF_SD:
case IF_FLOPPY:
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create_nofail(qemu_find_opts("device"));
if (arch_type == QEMU_ARCH_S390X) {
qemu_opt_set(opts, "driver", "virtio-blk-s390");
} else {
qemu_opt_set(opts, "driver", "virtio-blk-pci");
}
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
default:
abort();
}
if (!file || !*file) {
return dinfo;
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (copy_on_read) {
bdrv_flags |= BDRV_O_COPY_ON_READ;
}
if (runstate_check(RUN_STATE_INMIGRATE)) {
bdrv_flags |= BDRV_O_INCOMING;
}
if (media == MEDIA_CDROM) {
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY &&
type != IF_NONE && type != IF_PFLASH) {
error_report("readonly not supported by this bus type");
goto err;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
if (ro && copy_on_read) {
error_report("warning: disabling copy_on_read on readonly drive");
}
ret = bdrv_open(dinfo->bdrv, file, NULL, bdrv_flags, drv);
if (ret < 0) {
if (ret == -EMEDIUMTYPE) {
error_report("could not open disk image %s: not in %s format",
file, drv->format_name);
} else {
error_report("could not open disk image %s: %s",
file, strerror(-ret));
}
goto err;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
return dinfo;
err:
bdrv_delete(dinfo->bdrv);
g_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
g_free(dinfo);
return NULL;
}
|
README.md exists but content is empty.
- Downloads last month
- 1