The following issues were found

src/mongo/util/concurrency/thread_pool_test.cpp
1 issues
syntax error
Error

Line: 99

                  boost::optional<ThreadPool> _pool;
};

TEST_F(ThreadPoolTest, MinPoolSize0) {
    ThreadPool::Options options;
    options.minThreads = 0;
    options.maxThreads = 1;
    options.maxIdleThreadAge = Milliseconds(100);
    auto& pool = makePool(options);

            

Reported by Cppcheck.

src/mongo/util/concurrency/ticketholder_test.cpp
1 issues
syntax error
Error

Line: 41

              namespace {
using namespace mongo;

TEST(TicketholderTest, BasicTimeout) {
    TicketHolder holder(1);
    ASSERT_EQ(holder.used(), 0);
    ASSERT_EQ(holder.available(), 1);
    ASSERT_EQ(holder.outof(), 1);


            

Reported by Cppcheck.

src/mongo/util/concurrency/with_lock_test.cpp
1 issues
syntax error
Error

Line: 72

                  Mutex _m = MONGO_MAKE_LATCH("Beerp::_m");
};

TEST(WithLockTest, OverloadSet) {
    Beerp b(0);
    ASSERT_EQ(1, b.bleep('1'));
    ASSERT_EQ(2, b.bleep(2));

    auto m = MONGO_MAKE_LATCH();

            

Reported by Cppcheck.

src/mongo/util/container_size_helper_test.cpp
1 issues
syntax error
Error

Line: 43

                  int size;
};

TEST(ContainerSizeHelper, TestEstimateObjectSizeInBytes) {
    std::vector<Mock> vect = {{1}, {2}, {3}, {4}};

    // Sum of 'size' of each element '1 + 2 + 3 + 4'.
    uint64_t expectedSize = 10;


            

Reported by Cppcheck.

src/mongo/util/ctype_test.cpp
1 issues
syntax error
Error

Line: 47

              
using namespace fmt::literals;

TEST(Ctype, MatchesCxxStdlib) {
    for (size_t i = 0; i < 256; ++i) {
        char c = i;
        unsigned char uc = i;
        const std::string msg = " i={:02x}"_format(i);
        ASSERT_EQ(isAlnum(c), (bool)std::isalnum(uc)) << msg;

            

Reported by Cppcheck.

src/mongo/util/decimal_counter_test.cpp
1 issues
syntax error
Error

Line: 43

              namespace {
using namespace mongo;

TEST(DecimalCounter, CountUntilWrapAround) {
    DecimalCounter<uint16_t> counter;
    uint16_t check = 0;
    do {
        StringData str = counter;
        ASSERT_EQ(std::to_string(check), str.toString());

            

Reported by Cppcheck.

src/mongo/util/dns_name.h
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 270 Column: 18 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      // All of _nameComponents must appear as a prefix of candidate._nameComponents,
        // and candidate must have name components beyond that prefix.
        return (_nameComponents.size() < candidate._nameComponents.size()) &&
            std::equal(
                   begin(_nameComponents), end(_nameComponents), begin(candidate._nameComponents));
    }

    /**
     * Returns a new `dns::HostName` which represents the larger (possibly canonical) name that

            

Reported by FlawFinder.

src/mongo/util/dns_name_test.cpp
1 issues
syntax error
Error

Line: 56

              };


TEST(DNSNameTest, CorrectParsing) {
    enum FQDNBool : bool { kIsFQDN = true, kNotFQDN = false };
    const struct {
        std::string input;
        std::vector<std::string> parsedDomains;
        Checked<FQDNBool> isFQDN;

            

Reported by Cppcheck.

src/mongo/util/dns_query_posix-impl.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 184 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                   * View this record as a DNS CName record
     */
    std::string cnameEntry() const {
        char buf[NS_MAXDNAME];
        int length = dn_expand(
            _answerStart, _answerEnd, ns_rr_rdata(this->_resource_record), &buf[0], sizeof(buf));
        if (length == -1) {
            uasserted(ErrorCodes::DNSProtocolError, "DNS CNAME record could not be decompressed");
        }

            

Reported by FlawFinder.

src/mongo/util/dns_query_test.cpp
1 issues
syntax error
Error

Line: 47

                  return res;
}

TEST(MongoDnsQuery, basic) {
    // We only require 50% of the records to pass, because it is possible that some large scale
    // outages could cause some of these records to fail.
    const double kPassingPercentage = 0.50;
    std::size_t resolution_count = 0;
    const struct {

            

Reported by Cppcheck.