minio-cpp
minio-cpp copied to clipboard
The GetPresignedObjectUrl() function has an error and does not return the correct value.
The expected signature generation is incomplete.
Duplicate of https://github.com/minio/minio-cpp/issues/110
You can use an example to test it; the returned URL is incomplete. The function utils::Multimap PresignV4(http::Method method, the std::string& host, the std::string& uri, the std::string& region, utils::Multimap query_params, the std::string& access_key, the std::string& secret_key, the utils::UtcTime& date, unsigned int expires) is erroneous.
Found the bug. query_params
needs to be passed by reference into PreSignV4
, otherwise the query params are lost with the stack frame when it returns.
diff --git a/include/miniocpp/signer.h b/include/miniocpp/signer.h
index b8c912b..670a93d 100644
--- a/include/miniocpp/signer.h
+++ b/include/miniocpp/signer.h
@@ -69,7 +69,7 @@ utils::Multimap SignV4STS(http::Method method, const std::string& uri,
const utils::UtcTime& date);
utils::Multimap PresignV4(http::Method method, const std::string& host,
const std::string& uri, const std::string& region,
- utils::Multimap query_params,
+ utils::Multimap& query_params,
const std::string& access_key,
const std::string& secret_key,
const utils::UtcTime& date, unsigned int expires);
diff --git a/src/signer.cc b/src/signer.cc
index c3ffb59..067f6b0 100644
--- a/src/signer.cc
+++ b/src/signer.cc
@@ -165,7 +165,7 @@ utils::Multimap SignV4STS(http::Method method, const std::string& uri,
utils::Multimap PresignV4(http::Method method, const std::string& host,
const std::string& uri, const std::string& region,
- utils::Multimap query_params,
+ utils::Multimap& query_params,
const std::string& access_key,
const std::string& secret_key,
const utils::UtcTime& date, unsigned int expires) {
Before the above fix, we just get a bare URL with no query params whatsoever.