All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hou Tao <houtao1@huawei.com>
To: fstests@vger.kernel.org
Subject: [PATCH] log-writes: fix possible infinite loop in zero_range()
Date: Tue, 17 Oct 2017 11:20:45 +0800	[thread overview]
Message-ID: <1508210445-27135-1-git-send-email-houtao1@huawei.com> (raw)

Found it when trying to remove the limitation of log->max_zero_size.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 src/log-writes/log-writes.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/log-writes/log-writes.c b/src/log-writes/log-writes.c
index fab447a..0939157 100644
--- a/src/log-writes/log-writes.c
+++ b/src/log-writes/log-writes.c
@@ -65,6 +65,9 @@ static int zero_range(struct log *log, u64 start, u64 len)
 
 	memset(buf, 0, bufsize);
 	while (len) {
+		if (len < bufsize)
+			bufsize = len;
+
 		ret = pwrite(log->replayfd, buf, bufsize, start);
 		if (ret != bufsize) {
 			fprintf(stderr, "Error zeroing file: %d\n", errno);
-- 
2.5.0


             reply	other threads:[~2017-10-17  3:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17  3:20 Hou Tao [this message]
2017-10-17 11:54 ` [PATCH] log-writes: fix possible infinite loop in zero_range() Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508210445-27135-1-git-send-email-houtao1@huawei.com \
    --to=houtao1@huawei.com \
    --cc=fstests@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.