Details
Description
There are four cases of using std::snprintf in db/storage that check the return code for some errors (a partial write), but not for the -1 error value. E.g:
auto size = std::snprintf(oldestTSConfigString,
|
sizeof(oldestTSConfigString),
|
"oldest_timestamp=%llx",
|
static_cast<unsigned long long>(timestampToSet.asU64()));
|
invariant(static_cast<std::size_t>(size) < sizeof(oldestTSConfigString));
|
This work should include checking the return value for -1 and translating the errno.
Grep:
https://github.com/mongodb/mongo/blob/0b23e5ab80c96a8c5b001a1a33c5d6099c48ef2b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp#L1045-L1049
https://github.com/mongodb/mongo/blob/0b23e5ab80c96a8c5b001a1a33c5d6099c48ef2b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp#L1669-L1674
https://github.com/mongodb/mongo/blob/0b23e5ab80c96a8c5b001a1a33c5d6099c48ef2b/src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp#L85-L89
https://github.com/mongodb/mongo/blob/0b23e5ab80c96a8c5b001a1a33c5d6099c48ef2b/src/mongo/db/storage/wiredtiger/wiredtiger_snapshot_manager.cpp#L112-L116