Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yifan Zhao <stopire@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, Yifan Zhao <stopire@gmail.com>
Subject: [PATCH 2/4] erofs-utils: mkfs: validate chunksize before computing chunkbits
Date: Thu, 17 Sep 2026 11:53:47 +0800	[thread overview]
Message-ID: <20260917035349.1339521-2-stopire@gmail.com> (raw)
In-Reply-To: <20260917035349.1339521-1-stopire@gmail.com>

Assisted-by: Codex:gpt-6-astra
Signed-off-by: Yifan Zhao <stopire@gmail.com>
---
 mkfs/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index d9b4e22..f0d3d8c 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1262,8 +1262,9 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 		}
 
 		case 11:
+			errno = 0;
 			i = strtol(optarg, &endptr, 0);
-			if (*endptr != '\0') {
+			if (errno || *endptr != '\0' || i <= 0 || i > INT_MAX) {
 				erofs_err("invalid chunksize %s", optarg);
 				return -EINVAL;
 			}
-- 
2.55.0



  reply	other threads:[~2026-09-17  3:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  3:53 [PATCH 1/4] erofs-utils: fsck: fix hole handling during extraction Yifan Zhao
2026-09-17  3:53 ` Yifan Zhao [this message]
2026-09-17  3:53 ` [PATCH 3/4] erofs-utils: lib: fix rebuilding empty chunk-based files Yifan Zhao
2026-09-17  3:53 ` [PATCH 4/4] erofs-utils: fsck: avoid truncating lseek() return values Yifan Zhao

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=20260917035349.1339521-2-stopire@gmail.com \
    --to=stopire@gmail.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox