[SERVER-38888] Remove the null terminator check in IndexCatalogImpl::_isSpecOk() for the 'name' field Created: 08/Jan/19  Updated: 27/Oct/23  Resolved: 08/Jan/19

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Gregory Wlodarek Assignee: Backlog - Storage Execution Team
Resolution: Works as Designed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Participants:

 Description   

Right now if we pass an index spec with the 'name' field set to "f\0o", for example, then getting the string representation from the BSON element, using valueStringData(), returns "f". After this, we check if the string representation contains '\0', which could be safely removed since we should never encounter this scenario.

const StringData name = nameElem.valueStringData();
if (name.find('\0') != std::string::npos)
    return Status(ErrorCodes::CannotCreateIndex, "index name cannot contain NUL bytes");

See here



 Comments   
Comment by Gregory Wlodarek [ 08/Jan/19 ]

Turns out that simply passing "f\0o" to the BSON is incorrect, the correct way is to pass in "f\0o"_sd.

Generated at Thu Feb 08 04:50:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.