summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Broadstone <mbroadst@mongodb.com>2023-05-05 13:34:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-05 15:51:29 +0000
commitd66daf618a9005eaba4a8c9fa3746ef27ab80427 (patch)
treebe2f0c8872879d40fb0cb5df980068037d05fe02 /src
parent0e9c7bec876dcb32d5429b9d973dc220a9727172 (diff)
downloadmongo-d66daf618a9005eaba4a8c9fa3746ef27ab80427.tar.gz
SERVER-76823 Report accurate dbname length in NSS length assertion
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/namespace_string.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h
index 68323b5fad9..1277cb56d7a 100644
--- a/src/mongo/db/namespace_string.h
+++ b/src/mongo/db/namespace_string.h
@@ -839,15 +839,14 @@ private:
ns.find('\0') == std::string::npos);
auto dotIndex = ns.find('.');
+ uint8_t dbNameSize = dotIndex != std::string::npos ? dotIndex : ns.size();
uassert(ErrorCodes::InvalidNamespace,
fmt::format("db name must be at most {} characters, found: {}",
DatabaseName::kMaxDatabaseNameLength,
- dotIndex),
- (dotIndex != std::string::npos ? dotIndex : ns.size()) <=
- DatabaseName::kMaxDatabaseNameLength);
+ dbNameSize),
+ dbNameSize <= DatabaseName::kMaxDatabaseNameLength);
- uint8_t details =
- (dotIndex != std::string::npos ? dotIndex : ns.size()) & kDatabaseNameOffsetEndMask;
+ uint8_t details = dbNameSize & kDatabaseNameOffsetEndMask;
size_t dbStartIndex = kDataOffset;
if (tenantId) {
dbStartIndex += OID::kOIDSize;