qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] qemu-file: fix flaws of qemu_put_compressio


From: Li, Liang Z
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-file: fix flaws of qemu_put_compression_data
Date: Sun, 6 Dec 2015 14:29:53 +0000

> >> - blen could still be smaller that compressBound(size), you need to
> >>   recheck
> >> - blen could have changed, but you don't take that in account for the
> >>   following caller.
> >>
> >> So, I think code has a bug?
> >
> > Yes, there is a bug, I should consider the case QEMUFile with empty ops.
> > The right code should be like:
> >
> > if (blen < compressBound(size)) {
> >         if (f->ops->writev_buffer || f->ops->put_buffer) {
> >             qemu_fflush(f);
> >         } else {
> >             return 0;
> >         }
> > }
> > ....
> >
> > It is enough?
> 
> No.  We need something like:
> 
>     if (blen < compressBound(size)) {
>          if (!f->ops->writev_buffer && !f->ops->put_buffer) {
>              return 0;
>          }
>          qemu_fflush(f);
>          blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t);
>          if (blen < compressBound(size)) {
>              return 0;
>          }
> }
> 
> 
> No?
> 

I got it.  You mean we should not only consider the 'f' is not writable, but 
also  the case where 'size'  is a big value.  
You are right.  I will change it. Thanks.

Liang






reply via email to

[Prev in Thread] Current Thread [Next in Thread]