Skip to contentSkip to conversation

e2image: fix invalid lseek error detection

PATCH Applied Lukas Czerner 3 participants 4 messages Aug 24, 2011 – Sep 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2image: fix invalid lseek error detection

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.

---
 misc/e2image.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
misc/e2image.c +2 -1
index 83a9d02..bf0c0d4 100644
@@ -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;
Signature · 1 line
1.7.4.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Lukas Czerner

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.

Yup!

Quoted 18 lines
---
 misc/e2image.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
misc/e2image.c +2 -1
index 83a9d02..bf0c0d4 100644
@@ -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;
#2 lore raw
Quoted 6 lines · Eric Sandeen
Quoted 5 lines · Lukas Czerner

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.

Quoted 8 lines
Quoted 4 lines

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

Yup!

ping

Quoted 21 lines
Quoted 19 lines
---
 misc/e2image.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
misc/e2image.c +2 -1
index 83a9d02..bf0c0d4 100644
@@ -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;
Applied
#3 lore raw
In reply to Lukas Czerner
Quoted 9 lines · Lukas Czerner

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.

Thanks, applied.

- Ted