diff mbox

block: vmdk - fixed sizeof() error

Message ID 46d873261433f4527e88885582f96942d61758d6.1423592487.git.jcody@redhat.com
State New
Headers show

Commit Message

Jeff Cody Feb. 10, 2015, 6:22 p.m. UTC
The size compared should be PATH_MAX, rather than sizeof(char *).

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/vmdk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Eric Blake Feb. 10, 2015, 9:10 p.m. UTC | #1
On 02/10/2015 11:22 AM, Jeff Cody wrote:
> The size compared should be PATH_MAX, rather than sizeof(char *).
> 
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/vmdk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 7d079ad..8410a15 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -843,8 +843,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
>          }
>  
>          extent_path = g_malloc0(PATH_MAX);
> -        path_combine(extent_path, sizeof(extent_path),
> -                desc_file_path, fname);
> +        path_combine(extent_path, PATH_MAX, desc_file_path, fname);
>          extent_file = NULL;
>          ret = bdrv_open(&extent_file, extent_path, NULL, NULL,
>                          bs->open_flags | BDRV_O_PROTOCOL, NULL, errp);
>
Max Reitz Feb. 10, 2015, 9:42 p.m. UTC | #2
On 2015-02-10 at 13:22, Jeff Cody wrote:
> The size compared should be PATH_MAX, rather than sizeof(char *).
>
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>   block/vmdk.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

I just noticed iotest 059 failing, bisected it and the changeset of the 
commit in question looked strangely related to a patch I seemed to 
recall having seen on qemu-devel today... :-)

Reviewed-by: Max Reitz <mreitz@redhat.com>

> diff --git a/block/vmdk.c b/block/vmdk.c
> index 7d079ad..8410a15 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -843,8 +843,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
>           }
>   
>           extent_path = g_malloc0(PATH_MAX);
> -        path_combine(extent_path, sizeof(extent_path),
> -                desc_file_path, fname);
> +        path_combine(extent_path, PATH_MAX, desc_file_path, fname);
>           extent_file = NULL;
>           ret = bdrv_open(&extent_file, extent_path, NULL, NULL,
>                           bs->open_flags | BDRV_O_PROTOCOL, NULL, errp);
Stefan Hajnoczi Feb. 12, 2015, 5:15 p.m. UTC | #3
On Tue, Feb 10, 2015 at 01:22:56PM -0500, Jeff Cody wrote:
> The size compared should be PATH_MAX, rather than sizeof(char *).
> 
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/vmdk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index 7d079ad..8410a15 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -843,8 +843,7 @@  static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         }
 
         extent_path = g_malloc0(PATH_MAX);
-        path_combine(extent_path, sizeof(extent_path),
-                desc_file_path, fname);
+        path_combine(extent_path, PATH_MAX, desc_file_path, fname);
         extent_file = NULL;
         ret = bdrv_open(&extent_file, extent_path, NULL, NULL,
                         bs->open_flags | BDRV_O_PROTOCOL, NULL, errp);