linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libext2fs: clamp block-map punch range end to 2^32 blocks
@ 2013-12-12 21:13 Darrick J. Wong
  2013-12-15  0:48 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2013-12-12 21:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

In the ^extent case, passing ~0ULL as the 'end' parameter to
ext2fs_punch() causes the (end - start + 1) calculation to overflow to
zero.  Since the old-style mapped block files cannot have more than
2^32 blocks, just clamp it to ~0U.

This fixes a regression in t_quota_2off with the patch "libext2fs: use
ext2fs_punch() to truncate quota file" applied.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 lib/ext2fs/punch.c |    2 ++
 1 file changed, 2 insertions(+)


diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c
index f138297..9fff704 100644
--- a/lib/ext2fs/punch.c
+++ b/lib/ext2fs/punch.c
@@ -435,6 +435,8 @@ extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
 
 		if (start > ~0U)
 			return 0;
+		if (end > ~0U)
+			end = ~0U;
 		count = ((end - start + 1) < ~0U) ? (end - start + 1) : ~0U;
 		retval = ext2fs_punch_ind(fs, inode, block_buf, 
 					  (blk_t) start, count);


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

* Re: [PATCH] libext2fs: clamp block-map punch range end to 2^32 blocks
  2013-12-12 21:13 [PATCH] libext2fs: clamp block-map punch range end to 2^32 blocks Darrick J. Wong
@ 2013-12-15  0:48 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-12-15  0:48 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Thu, Dec 12, 2013 at 01:13:25PM -0800, Darrick J. Wong wrote:
> In the ^extent case, passing ~0ULL as the 'end' parameter to
> ext2fs_punch() causes the (end - start + 1) calculation to overflow to
> zero.  Since the old-style mapped block files cannot have more than
> 2^32 blocks, just clamp it to ~0U.
> 
> This fixes a regression in t_quota_2off with the patch "libext2fs: use
> ext2fs_punch() to truncate quota file" applied.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2013-12-15  1:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-12 21:13 [PATCH] libext2fs: clamp block-map punch range end to 2^32 blocks Darrick J. Wong
2013-12-15  0:48 ` Theodore Ts'o

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).