Merge pull request #7035 from sfc-gh-jshim/fix-token-sign-arena

Fix TokenSign copying and using uninitialized arena
This commit is contained in:
Markus Pilman 2022-05-02 08:52:19 -06:00 committed by GitHub
commit f5570ba49e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -114,7 +114,7 @@ Standalone<KeyPairRef> generateEcdsaKeyPair() {
Standalone<SignedAuthTokenRef> signToken(AuthTokenRef token, StringRef keyName, StringRef privateKeyDer) {
auto ret = Standalone<SignedAuthTokenRef>{};
auto arena = ret.arena();
auto& arena = ret.arena();
auto writer = ObjectWriter([&arena](size_t len) { return new (arena) uint8_t[len]; }, IncludeVersion());
writer.serialize(token);
auto tokenStr = writer.toStringRef();
@ -181,7 +181,7 @@ TEST_CASE("/fdbrpc/TokenSign") {
for (auto i = 0; i < numIters; i++) {
auto keyPair = generateEcdsaKeyPair();
auto token = Standalone<AuthTokenRef>{};
auto arena = token.arena();
auto& arena = token.arena();
auto& rng = *deterministicRandom();
token.expiresAt = timer_monotonic() * (0.5 + rng.random01());
if (auto setIp = rng.randomInt(0, 3)) {