lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 16 Feb 2012 16:35:11 -0500
From:	Phillip Susi <psusi@...ntu.com>
To:	tytso@....edu
Cc:	linux-ext4@...r.kernel.org, Phillip Susi <psusi@...ntu.com>
Subject: [PATCH 1/2] e2image: truncate raw image file to correct size

At the end of writing the raw image file, output_meta_data_blocks()
wrote a single zero byte.  Not only does this cause the last block
of the image file to be non sparse, but this was being skipped if
there were no leftover sparse bytes from the main loop.  This would
happen if the source fs happened to have an even multiple of 1MiB
of free blocks at the end, leaving the sparse image file shorter
than it should be.

Instead of writing a null byte, just truncate() the file instead,
whether or not there are any leftover sparse bytes.

Signed-off-by: Phillip Susi <psusi@...ntu.com>
---
 misc/e2image.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/misc/e2image.c b/misc/e2image.c
index d888e5a..722737c 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -511,8 +511,7 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd)
 			}
 		}
 	}
-	if (sparse)
-		write_block(fd, zero_buf, sparse-1, 1, -1);
+	ftruncate(fd, lseek(fd, sparse, SEEK_CUR));
 	ext2fs_free_mem(&zero_buf);
 	ext2fs_free_mem(&buf);
 }
-- 
1.7.5.4

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ