[SERVER-75668] IDL generates use-after-move initialization for nss and nssOrUUID parameters Created: 04/Apr/23  Updated: 29/Oct/23  Resolved: 06/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Matt Broadstone Assignee: Matt Broadstone
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Server Serverless 2023-04-17
Participants:

 Description   

The IDL compiler generates initializer statements for the _dbName member using variables that have already been moved into local members. Here are a few examples:

build/debug/mongo/db/modules/enterprise/src/search/search_index_commands_gen.cpp
519:CreateSearchIndexesCommand::CreateSearchIndexesCommand(const NamespaceString nss, boost::optional<SerializationContext> serializationContext) : _serializationContext(serializationContext.value_or(SerializationContext::stateCommandRequest())), _nss(std::move(nss)), _dbName(nss.dbName()), _hasIndexes(false), _hasDbName(true) {

build/debug/mongo/idl/unittest_gen.cpp:BasicConcatenateWithDbOrUUIDCommand::BasicConcatenateWithDbOrUUIDCommand(const NamespaceStringOrUUID nssOrUUID, std::int32_t field1, std::string field2, boost::optional<SerializationContext> serializationContext) : _serializationContext(serializationContext.value_or(SerializationContext::stateCommandRequest())), _nssOrUUID(nssOrUUID), _field1(std::move(field1)), _field2(std::move(field2)), _dbName(nssOrUUID.uuid() ? nssOrUUID.dbName().value() : nssOrUUID.nss()->dbName()), _hasField1(true), _hasField2(true), _hasDbName(true) {



 Comments   
Comment by Githook User [ 06/Apr/23 ]

Author:

{'name': 'Matt Broadstone', 'email': 'mbroadst@mongodb.com', 'username': 'mbroadst'}

Message: SERVER-75668 Prevent use-after-move for nss or nssOrUUID parameters
Branch: master
https://github.com/mongodb/mongo/commit/a7f004beb44ddcf1d61810599d50aca288ad4e3d

Generated at Thu Feb 08 06:30:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.