Skip to content

Commit 18e1e70

Browse files
authored
Merge pull request ceph#64959 from edwinzrodriguez/ceph-wip-72442
rgw: Update buffer size for HMAC signature Reviewed-by: Casey Bodley <[email protected]>
2 parents ddc8323 + 75ad316 commit 18e1e70

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/rgw/rgw_auth_s3.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,13 @@ get_v2_signature(CephContext* const cct,
10241024

10251025
const auto digest = calc_hmac_sha1(secret_key, string_to_sign);
10261026

1027-
/* 64 is really enough */;
1028-
char buf[64];
1029-
const int ret = ceph_armor(std::begin(buf),
1030-
std::begin(buf) + 64,
1031-
reinterpret_cast<const char *>(digest.v),
1032-
reinterpret_cast<const char *>(digest.v + digest.SIZE));
1027+
/* Sized for signature */;
1028+
char buf[AWSEngine::VersionAbstractor::SIGNATURE_MAX_SIZE];
1029+
const int ret = ceph_armor(
1030+
std::begin(buf),
1031+
std::begin(buf) + AWSEngine::VersionAbstractor::SIGNATURE_MAX_SIZE,
1032+
reinterpret_cast<const char*>(digest.v),
1033+
reinterpret_cast<const char*>(digest.v + digest.SIZE));
10331034
if (ret < 0) {
10341035
ldout(cct, 10) << "ceph_armor failed" << dendl;
10351036
throw ret;

src/rgw/rgw_rest_s3.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,13 +958,14 @@ class AWSEngine : public rgw::auth::Engine {
958958
static constexpr size_t DIGEST_SIZE_V2 = CEPH_CRYPTO_HMACSHA1_DIGESTSIZE;
959959
static constexpr size_t DIGEST_SIZE_V4 = CEPH_CRYPTO_HMACSHA256_DIGESTSIZE;
960960

961+
public:
962+
961963
/* Knowing the signature max size allows us to employ the sstring, and thus
962964
* avoid dynamic allocations. The multiplier comes from representing digest
963965
* in the base64-encoded form. */
964966
static constexpr size_t SIGNATURE_MAX_SIZE = \
965967
std::max(DIGEST_SIZE_V2, DIGEST_SIZE_V4) * 2 + sizeof('\0');
966968

967-
public:
968969
virtual ~VersionAbstractor() {};
969970

970971
using access_key_id_t = std::string_view;

0 commit comments

Comments
 (0)