提交 f6a592e8 编写于 作者: C Chris Malley 提交者: Linus Torvalds

lguest example launcher truncates block device file to 0 length on problems

The function should also use ftruncate64() rather than ftruncate() to prevent
files over 4GB (not uncommon for a root filesystem) being zeroed.
Signed-off-by: NChris Malley <mail@chrismalley.co.uk>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 78bd8fbb
...@@ -882,7 +882,7 @@ static u32 handle_block_output(int fd, const struct iovec *iov, ...@@ -882,7 +882,7 @@ static u32 handle_block_output(int fd, const struct iovec *iov,
* of the block file (possibly extending it). */ * of the block file (possibly extending it). */
if (off + len > device_len) { if (off + len > device_len) {
/* Trim it back to the correct length */ /* Trim it back to the correct length */
ftruncate(dev->fd, device_len); ftruncate64(dev->fd, device_len);
/* Die, bad Guest, die. */ /* Die, bad Guest, die. */
errx(1, "Write past end %llu+%u", off, len); errx(1, "Write past end %llu+%u", off, len);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册