Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-31616

Check return value of std::snprintf for errors

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.0-rc3
    • Component/s: Storage
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Storage 2017-11-13
    • Linked BF Score:
      0

      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

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: