From: zhaoyifan <[email protected]>
Interdiff against v3:
diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
index 5638057..dd682a4 100644
--- a/lib/remotes/s3.c
+++ b/lib/remotes/s3.c
@@ -30,18 +30,17 @@ struct s3erofs_query_params {
const char *value[S3EROFS_MAX_QUERY_PARAMS];
};
-static void s3erofs_prepare_url(const char *endpoint, const char *bucket,
const char *object,
- struct s3erofs_query_params *params, char *url,
- enum s3erofs_url_style url_style)
+static int s3erofs_prepare_url(const char *endpoint, const char *bucket, const
char *object,
+ struct s3erofs_query_params *params, char *url,
+ enum s3erofs_url_style url_style)
{
const char *schema = NULL;
const char *host = NULL;
size_t pos = 0;
int i;
- if (!endpoint || !bucket || !url) {
- return;
- }
+ if (!endpoint || !bucket || !url)
+ return -EINVAL;
if (strncmp(endpoint, "https://", 8) == 0) {
schema = "https://";
@@ -50,8 +49,8 @@ static void s3erofs_prepare_url(const char *endpoint, const
char *bucket, const
schema = "http://";
host = endpoint + 7;
} else {
- schema = "http://";
- host = endpoint;
+ erofs_err("endpoint has invalid format, missing http/https
protocol");
+ return -EINVAL;
}
if (url_style == S3EROFS_URL_STYLE_VIRTUAL_HOST) {
@@ -68,6 +67,8 @@ static void s3erofs_prepare_url(const char *endpoint, const
char *bucket, const
pos += snprintf(url + pos, S3EROFS_URL_LEN - pos, "%c%s=%s", (i
== 0 ? '?' : '&'),
params->key[i], params->value[i]);
}
+
+ return 0;
}
static char *get_canonical_headers(const struct curl_slist *list) { return "";
}
@@ -432,8 +433,11 @@ static int s3erofs_list_objects(struct
s3erofs_object_iterator *it)
++params.num;
req.method = "GET";
- s3erofs_prepare_url(s3cfg->endpoint, s3cfg->bucket, NULL, ¶ms,
- req.url, s3cfg->url_style);
+ ret = s3erofs_prepare_url(s3cfg->endpoint, s3cfg->bucket, NULL, ¶ms,
+ req.url, s3cfg->url_style);
+ if (ret < 0)
+ return ret;
+
snprintf(req.canonical_query, S3EROFS_CANONICAL_QUERY_LEN, "/%s",
s3cfg->bucket);
ret = s3erofs_request_perform(s3cfg, &req, &resp);
@@ -515,7 +519,6 @@ static int s3erofs_global_init(void)
curl_easy_setopt(easy_curl, CURLOPT_WRITEFUNCTION,
s3erofs_request_write_memory_cb);
curl_easy_setopt(easy_curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(easy_curl, CURLOPT_TIMEOUT, 30L);
- curl_easy_setopt(easy_curl, CURLOPT_SSL_VERIFYPEER, 0);
xmlInitParser();
--
2.46.0