The following issues were found

src/third_party/IntelRDFPMathLib20U1/LIBRARY/float128/dpml_ux_exp.c
2 issues
Uninitialized variable: reduced_argument
Error

Line: 72 CWE codes: 908

                      { /* Either no reduction is necessary, or exponent > 17 */

        scale = 0;
        UX_COPY(orig_argument, reduced_argument);
        if (exponent > 0)
            { /* exponent > 17, force underflow or overflow */
            P_UX_EXPONENT(reduced_argument, -128);
            scale = sign ? UX_UNDERFLOW_EXPONENT : UX_OVERFLOW_EXPONENT;
            }

            

Reported by Cppcheck.

Uninitialized variable: reduced_argument
Error

Line: 75 CWE codes: 908

                      UX_COPY(orig_argument, reduced_argument);
        if (exponent > 0)
            { /* exponent > 17, force underflow or overflow */
            P_UX_EXPONENT(reduced_argument, -128);
            scale = sign ? UX_UNDERFLOW_EXPONENT : UX_OVERFLOW_EXPONENT;
            }
        return scale;
        }
                

            

Reported by Cppcheck.

src/third_party/abseil-cpp-master/abseil-cpp/absl/types/variant_test.cc
2 issues
syntax error
Error

Line: 279

                NonDefaultConstructible() = delete;
};

TEST(VariantTest, TestDefaultConstructor) {
  {
    using X = variant<int>;
    constexpr variant<int> x{};
    ASSERT_FALSE(x.valueless_by_exception());
    ASSERT_EQ(0, x.index());

            

Reported by Cppcheck.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 1802 Column: 50 CWE codes: 126

                EXPECT_EQ("B", piece);

  struct StrLen {
    int operator()(const char* s) const { return strlen(s); }
    int operator()(const std::string& s) const { return s.size(); }
  };

  v = "SomeStr";
  EXPECT_EQ(7, absl::visit(StrLen{}, v));

            

Reported by FlawFinder.

src/mongo/transport/message_compressor_manager_test.cpp
2 issues
syntax error
Error

Line: 184

                  return Message{buf};
}

TEST(MessageCompressorManager, NoCompressionRequested) {
    auto input = BSON("isMaster" << 1);
    checkServerNegotiation(boost::none, {});
}

TEST(MessageCompressorManager, NormalCompressionRequested) {

            

Reported by Cppcheck.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 180 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  testView.setResponseToMsgId(654321);
    testView.setOperation(dbQuery);
    testView.setLen(bufferSize);
    memcpy(testView.data(), data.data(), data.size());
    return Message{buf};
}

TEST(MessageCompressorManager, NoCompressionRequested) {
    auto input = BSON("isMaster" << 1);

            

Reported by FlawFinder.

src/third_party/abseil-cpp-master/abseil-cpp/absl/base/internal/scoped_set_env.cc
2 issues
getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 64 Column: 23 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

              
  SetEnvironmentVariableA(var_name_.c_str(), new_value);
#else
  const char* val = ::getenv(var_name_.c_str());
  if (val == nullptr) {
    was_unset_ = true;
  } else {
    old_value_ = val;
  }

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 52 Column: 3 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

              ScopedSetEnv::ScopedSetEnv(const char* var_name, const char* new_value)
    : var_name_(var_name), was_unset_(false) {
#ifdef _WIN32
  char buf[kMaxEnvVarValueSize];
  auto get_res = GetEnvironmentVariableA(var_name_.c_str(), buf, sizeof(buf));
  ABSL_INTERNAL_CHECK(get_res < sizeof(buf), "value exceeds buffer size");

  if (get_res == 0) {
    was_unset_ = (GetLastError() == ERROR_ENVVAR_NOT_FOUND);

            

Reported by FlawFinder.

src/mongo/db/storage/key_string_bm.cpp
2 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 112 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      result.bsons[i] = bson;

        result.keystrings[i] = SharedBuffer::allocate(ks.getSize());
        memcpy(result.keystrings[i].get(), ks.getBuffer(), ks.getSize());
        result.keystringLens[i] = ks.getSize();

        result.typebits[i] = SharedBuffer::allocate(ks.getTypeBits().getSize());
        memcpy(result.typebits[i].get(), ks.getTypeBits().getBuffer(), ks.getTypeBits().getSize());
        result.typebitsLens[i] = ks.getSize();

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 116 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      result.keystringLens[i] = ks.getSize();

        result.typebits[i] = SharedBuffer::allocate(ks.getTypeBits().getSize());
        memcpy(result.typebits[i].get(), ks.getTypeBits().getBuffer(), ks.getTypeBits().getSize());
        result.typebitsLens[i] = ks.getSize();
    }
    return result;
}


            

Reported by FlawFinder.

buildscripts/libdeps/libdeps/graph.py
2 issues
Unable to import 'networkx'
Error

Line: 33 Column: 1

              from pathlib import Path
import json

import networkx

try:
    import progressbar
except ImportError:
    pass

            

Reported by Pylint.

Unused Path imported from pathlib
Error

Line: 30 Column: 1

              These are used for attributing data across the build scripts and analyzer scripts.
"""
from enum import Enum, auto
from pathlib import Path
import json

import networkx

try:

            

Reported by Pylint.

src/mongo/db/exec/sbe/sbe_spool_test.cpp
2 issues
syntax error
Error

Line: 102

                  sbe::value::SpoolIdGenerator _spoolIdGenerator;
};

TEST_F(SbeSpoolTest, SpoolEagerProducerBasic) {
    auto inputArray = BSON_ARRAY("a"
                                 << "b"
                                 << "c");
    auto [inputTag, inputVal] = stage_builder::makeValue(inputArray);
    value::ValueGuard inputGuard{inputTag, inputVal};

            

Reported by Cppcheck.

open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 288 Column: 16 CWE codes: 362

              
    // Before the plan reaches EOF, close and re-open it.
    rootStage->close();
    rootStage->open(false);

    // This time, execute the plan until it reaches EOF. It should return the results as expected
    // after being closed and re-opened.
    auto [resultsTag, resultsVal] = getAllResults(rootStage.get(), accessor);
    value::ValueGuard resultGuard{resultsTag, resultsVal};

            

Reported by FlawFinder.

src/mongo/db/logical_time_test.cpp
2 issues
syntax error
Error

Line: 62

                  ASSERT_FALSE(LogicalTime(tX) != LogicalTime(tX));
}

TEST(LogicalTime, roundtrip) {
    Timestamp tX(1);
    auto tY = LogicalTime(tX).asTimestamp();

    ASSERT_TRUE(tX == tY);
}

            

Reported by Cppcheck.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 100 Column: 14 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

                  Timestamp tX(123456789);
    auto lT = LogicalTime(tX);

    unsigned char expectedBytes[sizeof(uint64_t)] = {
        0x15, 0xCD, 0x5B, 0x07, 0x00, 0x00, 0x00, 0x00};

    auto unsignedTimeArray = lT.toUnsignedArray();
    for (size_t i = 0; i < sizeof(uint64_t); ++i) {
        ASSERT_EQUALS(unsignedTimeArray[i], expectedBytes[i]);

            

Reported by FlawFinder.

src/mongo/db/exec/sbe/sbe_unique_test.cpp
2 issues
syntax error
Error

Line: 63

                  runTest(inputTag, inputVal, expectedTag, expectedVal, makeStageFn);
}

TEST_F(UniqueStageTest, DeduplicatesMultipleSlotsInKey) {
    auto [tag, val] = stage_builder::makeValue(BSON_ARRAY(
        BSON_ARRAY(1 << 1) << BSON_ARRAY(2 << 2) << BSON_ARRAY(1 << 1) << BSON_ARRAY(3 << 3)));
    auto [scanSlots, scan] = generateVirtualScanMulti(2,  // numSlots
                                                      tag,
                                                      val);

            

Reported by Cppcheck.

open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 106 Column: 13 CWE codes: 362

                  // Closing and opening the plan should have the effect of clearing the values that 'unique'
    // has seen.
    unique->close();
    unique->open(false);

    auto [resetResultsTag, resetResultsVal] = getAllResults(unique.get(), resultAccessor);
    value::ValueGuard resetResultGuard{resetResultsTag, resetResultsVal};

    // The same result is seen again after closing and re-opening the plan tree.

            

Reported by FlawFinder.

src/mongo/bson/mutable/algorithm.h
2 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 156 Column: 61 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

               *  must be compatible with the comparator used for the sort.
 */
template <typename EqualityComparator>
void deduplicateChildren(Element parent, EqualityComparator equal) {
    Element current = parent.leftChild();
    while (current.ok()) {
        Element next = current.rightSibling();
        if (next.ok() && equal(current, next)) {
            next.remove().transitional_ignore();

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 160 Column: 26 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

                  Element current = parent.leftChild();
    while (current.ok()) {
        Element next = current.rightSibling();
        if (next.ok() && equal(current, next)) {
            next.remove().transitional_ignore();
        } else {
            current = next;
        }
    }

            

Reported by FlawFinder.