qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field
@ 2015-04-27 14:23 Fam Zheng
  2015-04-27 17:07 ` John Snow
  0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2015-04-27 14:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Fam Zheng, armbru, Stefan Hajnoczi

Coverity spotted this.

The field is 32 bits, but if it's possible to overflow in 32 bit
left shift.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 8410a15..d72a6e8 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -523,7 +523,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
     }
     ret = vmdk_add_extent(bs, file, false,
                           le32_to_cpu(header.disk_sectors),
-                          le32_to_cpu(header.l1dir_offset) << 9,
+                          (int64_t)le32_to_cpu(header.l1dir_offset) << 9,
                           0,
                           le32_to_cpu(header.l1dir_size),
                           4096,
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field
  2015-04-27 14:23 [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field Fam Zheng
@ 2015-04-27 17:07 ` John Snow
  2015-04-28 12:54   ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: John Snow @ 2015-04-27 17:07 UTC (permalink / raw)
  To: Fam Zheng, qemu-devel; +Cc: Kevin Wolf, armbru, Stefan Hajnoczi



On 04/27/2015 10:23 AM, Fam Zheng wrote:
> Coverity spotted this.
>
> The field is 32 bits, but if it's possible to overflow in 32 bit
> left shift.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>   block/vmdk.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 8410a15..d72a6e8 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -523,7 +523,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
>       }
>       ret = vmdk_add_extent(bs, file, false,
>                             le32_to_cpu(header.disk_sectors),
> -                          le32_to_cpu(header.l1dir_offset) << 9,
> +                          (int64_t)le32_to_cpu(header.l1dir_offset) << 9,
>                             0,
>                             le32_to_cpu(header.l1dir_size),
>                             4096,
>

Reviewed-by: John Snow <jsnow@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field
  2015-04-27 17:07 ` John Snow
@ 2015-04-28 12:54   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2015-04-28 12:54 UTC (permalink / raw)
  To: John Snow; +Cc: Fam Zheng, qemu-devel, Stefan Hajnoczi, armbru

Am 27.04.2015 um 19:07 hat John Snow geschrieben:
> 
> 
> On 04/27/2015 10:23 AM, Fam Zheng wrote:
> >Coverity spotted this.
> >
> >The field is 32 bits, but if it's possible to overflow in 32 bit
> >left shift.
> >
> >Signed-off-by: Fam Zheng <famz@redhat.com>
> >---
> >  block/vmdk.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/block/vmdk.c b/block/vmdk.c
> >index 8410a15..d72a6e8 100644
> >--- a/block/vmdk.c
> >+++ b/block/vmdk.c
> >@@ -523,7 +523,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
> >      }
> >      ret = vmdk_add_extent(bs, file, false,
> >                            le32_to_cpu(header.disk_sectors),
> >-                          le32_to_cpu(header.l1dir_offset) << 9,
> >+                          (int64_t)le32_to_cpu(header.l1dir_offset) << 9,
> >                            0,
> >                            le32_to_cpu(header.l1dir_size),
> >                            4096,
> >
> 
> Reviewed-by: John Snow <jsnow@redhat.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-28 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-27 14:23 [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field Fam Zheng
2015-04-27 17:07 ` John Snow
2015-04-28 12:54   ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).