From 71dc92ed09e0332c5a92a7216495c7e0b0dcc947 Mon Sep 17 00:00:00 2001 From: Martin Prikryl Date: Wed, 1 Sep 2021 10:33:31 +0200 Subject: [PATCH] Cannot access S3 bucket root when the access policy checks for empty prefix When accessing bucket root, AWS tools send empty prefix (prefix=), contrary to libs3 that sends no prefix. But some AWS policy examples suggest conditions like: "Condition":{"StringEquals":{"s3:prefix":["","home/"],"s3:delimiter":["/"]}} With such conditions libs3 will fail to access the root. Reported for WinSCP: https://winscp.net/forum/viewtopic.php?t=31359 The same problem for Cyberduck: https://trac.cyberduck.io/ticket/11549 --- src/bucket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bucket.c b/src/bucket.c index 6d30674..1c2f762 100644 --- a/src/bucket.c +++ b/src/bucket.c @@ -708,7 +708,7 @@ void S3_list_bucket(const S3BucketContext *bucketContext, const char *prefix, int amp = 0; - if (prefix && *prefix) { + if (prefix) { safe_append("prefix", prefix); } if (marker && *marker) {