Patchwork e2image: fix invalid lseek error detection

login
register
mail settings
Submitter Lukas Czerner
Date Aug. 24, 2011, 8 a.m.
Message ID <1314172834-18424-1-git-send-email-lczerner@redhat.com>
Download mbox | patch
Permalink /patch/111270/
State Accepted
Headers show

Comments

Lukas Czerner - Aug. 24, 2011, 8 a.m.
In flush_l2_cache() we are using ext2fs_llseek() however we do not
properly detect the error code returned from the function, because we
are assigning it into ULL variable, hence we will not see negative
values.

Fix this by changing the type of the variable to ext2_loff_t which is
signed and hence will store negative values.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 misc/e2image.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Eric Sandeen - Aug. 24, 2011, 4:02 p.m.
On 8/24/11 3:00 AM, Lukas Czerner wrote:
> In flush_l2_cache() we are using ext2fs_llseek() however we do not
> properly detect the error code returned from the function, because we
> are assigning it into ULL variable, hence we will not see negative
> values.
> 
> Fix this by changing the type of the variable to ext2_loff_t which is
> signed and hence will store negative values.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

Yup!

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  misc/e2image.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/misc/e2image.c b/misc/e2image.c
> index 83a9d02..bf0c0d4 100644
> --- a/misc/e2image.c
> +++ b/misc/e2image.c
> @@ -759,7 +759,8 @@ static void put_used_table(struct ext2_qcow2_image *img,
>  
>  static void flush_l2_cache(struct ext2_qcow2_image *image)
>  {
> -	blk64_t offset, seek = 0;
> +	blk64_t seek = 0;
> +	ext2_loff_t offset;
>  	struct ext2_qcow2_l2_cache *cache = image->l2_cache;
>  	struct ext2_qcow2_l2_table *table = cache->used_head;
>  	int fd = image->fd;

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukas Czerner - Sept. 14, 2011, 4 p.m.
On Wed, 24 Aug 2011, Eric Sandeen wrote:

> On 8/24/11 3:00 AM, Lukas Czerner wrote:
> > In flush_l2_cache() we are using ext2fs_llseek() however we do not
> > properly detect the error code returned from the function, because we
> > are assigning it into ULL variable, hence we will not see negative
> > values.
> > 
> > Fix this by changing the type of the variable to ext2_loff_t which is
> > signed and hence will store negative values.
> > 
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> 
> Yup!
> 
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>

ping

> 
> > ---
> >  misc/e2image.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/misc/e2image.c b/misc/e2image.c
> > index 83a9d02..bf0c0d4 100644
> > --- a/misc/e2image.c
> > +++ b/misc/e2image.c
> > @@ -759,7 +759,8 @@ static void put_used_table(struct ext2_qcow2_image *img,
> >  
> >  static void flush_l2_cache(struct ext2_qcow2_image *image)
> >  {
> > -	blk64_t offset, seek = 0;
> > +	blk64_t seek = 0;
> > +	ext2_loff_t offset;
> >  	struct ext2_qcow2_l2_cache *cache = image->l2_cache;
> >  	struct ext2_qcow2_l2_table *table = cache->used_head;
> >  	int fd = image->fd;
> 
>
Theodore Ts'o - Sept. 14, 2011, 5:28 p.m.
On Wed, Aug 24, 2011 at 10:00:34AM +0200, Lukas Czerner wrote:
> In flush_l2_cache() we are using ext2fs_llseek() however we do not
> properly detect the error code returned from the function, because we
> are assigning it into ULL variable, hence we will not see negative
> values.
> 
> Fix this by changing the type of the variable to ext2_loff_t which is
> signed and hence will store negative values.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

Thanks, applied.

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/misc/e2image.c b/misc/e2image.c
index 83a9d02..bf0c0d4 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -759,7 +759,8 @@  static void put_used_table(struct ext2_qcow2_image *img,
 
 static void flush_l2_cache(struct ext2_qcow2_image *image)
 {
-	blk64_t offset, seek = 0;
+	blk64_t seek = 0;
+	ext2_loff_t offset;
 	struct ext2_qcow2_l2_cache *cache = image->l2_cache;
 	struct ext2_qcow2_l2_table *table = cache->used_head;
 	int fd = image->fd;