[PATCH 1/2] erofs-utils: lib: fix s3erofs_prepare_url()

Gao Xiang hsiangkao at linux.alibaba.com
Mon Oct 27 20:21:30 AEDT 2025


`mkfs.erofs` failed to generate image from Huawei OBS with the following
command:
  $ mkfs.erofs --s3=<endpoint>,urlstyle=vhost,sig=2 s3.erofs test-bucket

because it mistakenly generated a url with repeated '/':
  "https://test-bucket.<endpoint>//<keyname>"

Fix the corresponding logic now.

Reported-by: Yifan Zhao <zhaoyifan28 at huawei.com>
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/remotes/s3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
index 2e7763e..3675ab6 100644
--- a/lib/remotes/s3.c
+++ b/lib/remotes/s3.c
@@ -47,6 +47,7 @@ static int s3erofs_prepare_url(struct s3erofs_curl_request *req,
 {
 	static const char https[] = "https://";
 	const char *schema, *host;
+	/* an additional slash is added, which wasn't specified by user inputs */
 	bool slash = false;
 	char *url = req->url;
 	int pos, i;
@@ -82,8 +83,10 @@ static int s3erofs_prepare_url(struct s3erofs_curl_request *req,
 		}
 	}
 	if (key) {
-		slash |= url[pos - 1] != '/';
-		pos -= !slash;
+		if (url[pos - 1] == '/')
+			--pos;
+		else
+			slash = true;
 		pos += snprintf(url + pos, S3EROFS_URL_LEN - pos, "/%s", key);
 	}
 
-- 
2.43.5



More information about the Linux-erofs mailing list