The following issues were found

src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java
7 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

              import java.nio.ByteBuffer;

class MongoEmbeddedClientImpl implements MongoEmbeddedClient {
    private final CAPI.mongo_embedded_v1_status status;
    private final CAPI.mongo_embedded_v1_client client;

    MongoEmbeddedClientImpl(final CAPI.mongo_embedded_v1_instance instance) {
        status = CAPIHelper.createStatusPointer();


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

              
class MongoEmbeddedClientImpl implements MongoEmbeddedClient {
    private final CAPI.mongo_embedded_v1_status status;
    private final CAPI.mongo_embedded_v1_client client;

    MongoEmbeddedClientImpl(final CAPI.mongo_embedded_v1_instance instance) {
        status = CAPIHelper.createStatusPointer();

        try {

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 51

              
        try {
            client = CAPI.mongo_embedded_v1_client_create(instance, status);
        } catch (Throwable t) {
            throw CAPIHelper.createError("instance_create", t);
        }

        if (client == null) {
            CAPIHelper.createErrorFromStatus(status);

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 66

                      try {
            CAPIHelper.validateErrorCode(status,
                    CAPI.mongo_embedded_v1_client_destroy(client, status));
        } catch (Throwable t) {
            throw CAPIHelper.createError("instance_destroy", t);
        }
    }

    @Override

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 85

                          CAPIHelper.validateErrorCode(status,
                    CAPI.mongo_embedded_v1_client_invoke(client, messagePointer, new NativeLong(message.length), outputBufferReference,
                            outputSize, status));
        } catch (Throwable t) {
            throw CAPIHelper.createError("client_invoke", t);
        }
        return outputBufferReference.getValue().getByteBuffer(0, outputSize.getValue().longValue());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 88

                      } catch (Throwable t) {
            throw CAPIHelper.createError("client_invoke", t);
        }
        return outputBufferReference.getValue().getByteBuffer(0, outputSize.getValue().longValue());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 88

                      } catch (Throwable t) {
            throw CAPIHelper.createError("client_invoke", t);
        }
        return outputBufferReference.getValue().getByteBuffer(0, outputSize.getValue().longValue());
    }
}

            

Reported by PMD.

src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid64_noncomp.c
7 issues
Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 115 CWE codes: 758

                  // if exponent is less than -383, the number may be subnormal
    // if (exp_x - 398 = -383) the number may be subnormal
    if (exp_x < 15) {
      __mul_64x64_to_128MACH (sig_x_prime, sig_x, bid_mult_factor[exp_x]);
      if (sig_x_prime.w[1] == 0
	  && sig_x_prime.w[0] < 1000000000000000ull) {
	res = 0;	// subnormal
      } else {
	res = 1;	// normal

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 168 CWE codes: 758

                  // if exponent is less than -383, the number may be subnormal
    // if (exp_x - 398 = -383) the number may be subnormal
    if (exp_x < 15) {
      __mul_64x64_to_128MACH (sig_x_prime, sig_x, bid_mult_factor[exp_x]);
      if (sig_x_prime.w[1] == 0
	  && sig_x_prime.w[0] < 1000000000000000ull) {
	res = 1;	// subnormal
      } else {
	res = 0;	// normal

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 432 CWE codes: 758

                // if exponent is less than -383, number may be subnormal
  //  if (exp_x - 398 < -383)
  if (exp_x < 15) {	// sig_x *10^exp_x
    __mul_64x64_to_128MACH (sig_x_prime, sig_x, bid_mult_factor[exp_x]);
    if (sig_x_prime.w[1] == 0
	&& (sig_x_prime.w[0] < 1000000000000000ull)) {
      res =
	((x & MASK_SIGN) ==
	 MASK_SIGN) ? negativeSubnormal : positiveSubnormal;

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 723 CWE codes: 758

                // to the compensated significand
  if (exp_x > exp_y) {
    // otherwise adjust the x significand upwards
    __mul_64x64_to_128MACH (sig_n_prime, sig_x,
			    bid_mult_factor[exp_x - exp_y]);
    // if x and y represent the same entities, 
    // and both are negative, return true iff exp_x <= exp_y
    if (sig_n_prime.w[1] == 0 && (sig_n_prime.w[0] == sig_y)) {
      // case cannot occure, because all bits must 

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 740 CWE codes: 758

                  BID_RETURN (res);
  }
  // adjust the y significand upwards
  __mul_64x64_to_128MACH (sig_n_prime, sig_y,
			  bid_mult_factor[exp_y - exp_x]);

  // if x and y represent the same entities, 
  // and both are negative, return true iff exp_x <= exp_y
  if (sig_n_prime.w[1] == 0 && (sig_n_prime.w[0] == sig_x)) {

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 931 CWE codes: 758

                if (exp_x > exp_y) {

    // otherwise adjust the x significand upwards
    __mul_64x64_to_128MACH (sig_n_prime, sig_x,
			    bid_mult_factor[exp_x - exp_y]);

    // if x and y represent the same entities, 
    // and both are negative, return true iff exp_x <= exp_y
    if (sig_n_prime.w[1] == 0 && (sig_n_prime.w[0] == sig_y)) {

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 947 CWE codes: 758

                  BID_RETURN (res);
  } // from this point on -15 <= exp_x - exp_y <= 0
  // adjust the y significand upwards
  __mul_64x64_to_128MACH (sig_n_prime, sig_y,
			  bid_mult_factor[exp_y - exp_x]);

  // if x and y represent the same entities, 
  // and both are negative, return true iff exp_x <= exp_y
  if (sig_n_prime.w[1] == 0 && (sig_n_prime.w[0] == sig_x)) {

            

Reported by Cppcheck.

site_scons/site_tools/mongo_integrationtest.py
7 issues
Unable to import 'SCons.Script'
Error

Line: 26 Column: 1

              """
Pseudo-builders for building and registering integration tests.
"""
from SCons.Script import Action

from site_scons.mongo import insort_wrapper

def exists(env):
    return True

            

Reported by Pylint.

Unable to import 'site_scons.mongo'
Error

Line: 28 Column: 1

              """
from SCons.Script import Action

from site_scons.mongo import insort_wrapper

def exists(env):
    return True



            

Reported by Pylint.

Unused Action imported from SCons.Script
Error

Line: 26 Column: 1

              """
Pseudo-builders for building and registering integration tests.
"""
from SCons.Script import Action

from site_scons.mongo import insort_wrapper

def exists(env):
    return True

            

Reported by Pylint.

Unused argument 'env'
Error

Line: 30 Column: 12

              
from site_scons.mongo import insort_wrapper

def exists(env):
    return True


def build_cpp_integration_test(env, target, source, **kwargs):
    libdeps = kwargs.get("LIBDEPS", env.get("LIBDEPS", [])).copy()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

              
from site_scons.mongo import insort_wrapper

def exists(env):
    return True


def build_cpp_integration_test(env, target, source, **kwargs):
    libdeps = kwargs.get("LIBDEPS", env.get("LIBDEPS", [])).copy()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

                  return True


def build_cpp_integration_test(env, target, source, **kwargs):
    libdeps = kwargs.get("LIBDEPS", env.get("LIBDEPS", [])).copy()
    insort_wrapper(libdeps, "$BUILD_DIR/mongo/unittest/integration_test_main")

    kwargs["LIBDEPS"] = libdeps
    integration_test_components = {"tests", "integration-tests"}

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 70 Column: 1

                  return result


def generate(env):
    env.TestList("$INTEGRATION_TEST_LIST", source=[])
    env.AddMethod(build_cpp_integration_test, "CppIntegrationTest")
    env.Alias("$INTEGRATION_TEST_ALIAS", "$INTEGRATION_TEST_LIST")

            

Reported by Pylint.

src/third_party/wiredtiger/src/utilities/util_load.c
7 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 558 Column: 13 CWE codes: 134
Suggestion: Use a constant for the format specification

              
        /* Report on progress every 100 inserts. */
        if (verbose && ++insert_count % 100 == 0) {
            printf("\r\t%s: %" PRIu64, name, insert_count);
            fflush(stdout);
        }
    }

    if (verbose)

            

Reported by FlawFinder.

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

Line: 107 Column: 5 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

                  WT_CURSOR *cursor;
    WT_DECL_RET;
    int tret;
    char **list, **tlist, *uri, config[64];
    bool hex;

    cursor = NULL;
    list = NULL; /* -Wuninitialized */
    hex = false; /* -Wuninitialized */

            

Reported by FlawFinder.

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: 246 Column: 27 CWE codes: 126

                  if ((ret = util_read_line(session, &l, false, &eof)) != 0)
        goto err;
    s = "WiredTiger Dump ";
    if (strncmp(l.mem, s, strlen(s)) != 0) {
        ret = format(session);
        goto err;
    }

    /* Header line #2: "Format={hex,print}". */

            

Reported by FlawFinder.

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: 416 Column: 45 CWE codes: 126

                   */
    for (configp = cmdconfig; configp != NULL && *configp != NULL; configp += 2) {
        for (found = 0, listp = list; *listp != NULL; listp += 2)
            if (strncmp(*configp, listp[0], strlen(*configp)) == 0)
                ++found;
        switch (found) {
        case 0:
            return (util_err(session, 0,
              "the command line object name %s was not matched by any loaded object name",

            

Reported by FlawFinder.

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: 454 Column: 45 CWE codes: 126

                      cnt = 0;
        cfg[cnt++] = listp[1];
        for (configp = cmdconfig; cmdconfig != NULL && *configp != NULL; configp += 2)
            if (strncmp(*configp, listp[0], strlen(*configp)) == 0)
                cfg[cnt++] = configp[1];
        cfg[cnt++] = NULL;

        if ((ret = __wt_config_merge((WT_SESSION_IMPL *)session, cfg,
               "filename=,id=,checkpoint=,checkpoint_backup_info=,checkpoint_lsn=,version=,source="

            

Reported by FlawFinder.

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: 483 Column: 27 CWE codes: 126

                  char *buf, *p;

    /* Allocate room. */
    len = strlen(*urip) + strlen(name) + 10;
    if ((buf = malloc(len)) == NULL)
        return (util_err(session, errno, NULL));

    /*
     * Find the separating colon characters, but note the trailing one may not be there.

            

Reported by FlawFinder.

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: 483 Column: 11 CWE codes: 126

                  char *buf, *p;

    /* Allocate room. */
    len = strlen(*urip) + strlen(name) + 10;
    if ((buf = malloc(len)) == NULL)
        return (util_err(session, errno, NULL));

    /*
     * Find the separating colon characters, but note the trailing one may not be there.

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/suite/test_bug015.py
7 issues
Unable to import 'wiredtiger'
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import wiredtiger, wttest

# test_bug015.py
#    JIRA WT-2162: index drop in a certain order triggers NULL pointer deref
class test_bug015(wttest.WiredTigerTestCase):
    def test_bug015(self):

            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import wiredtiger, wttest

# test_bug015.py
#    JIRA WT-2162: index drop in a certain order triggers NULL pointer deref
class test_bug015(wttest.WiredTigerTestCase):
    def test_bug015(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import wiredtiger, wttest

# test_bug015.py
#    JIRA WT-2162: index drop in a certain order triggers NULL pointer deref
class test_bug015(wttest.WiredTigerTestCase):
    def test_bug015(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

              
# test_bug015.py
#    JIRA WT-2162: index drop in a certain order triggers NULL pointer deref
class test_bug015(wttest.WiredTigerTestCase):
    def test_bug015(self):
        table = 'table:test_bug015'
        idx1 = 'index:test_bug015:aab'
        idx2 = 'index:test_bug015:aaa'
        self.session.create(table, "columns=(k,v)")

            

Reported by Pylint.

Class name "test_bug015" doesn't conform to PascalCase naming style
Error

Line: 33 Column: 1

              
# test_bug015.py
#    JIRA WT-2162: index drop in a certain order triggers NULL pointer deref
class test_bug015(wttest.WiredTigerTestCase):
    def test_bug015(self):
        table = 'table:test_bug015'
        idx1 = 'index:test_bug015:aab'
        idx2 = 'index:test_bug015:aaa'
        self.session.create(table, "columns=(k,v)")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 5

              # test_bug015.py
#    JIRA WT-2162: index drop in a certain order triggers NULL pointer deref
class test_bug015(wttest.WiredTigerTestCase):
    def test_bug015(self):
        table = 'table:test_bug015'
        idx1 = 'index:test_bug015:aab'
        idx2 = 'index:test_bug015:aaa'
        self.session.create(table, "columns=(k,v)")
        self.session.create(idx1, "columns=(v)")

            

Reported by Pylint.

src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid64_mul.c
7 issues
Shifting 32-bit value by 51 bits is undefined behaviour
Error

Line: 109 CWE codes: 758

                  // x is 0
    if (((y & INFINITY_MASK64) != INFINITY_MASK64)) {
      if ((y & SPECIAL_ENCODING_MASK64) == SPECIAL_ENCODING_MASK64)
	exponent_y = ((BID_UINT32) (y >> 51)) & 0x3ff;
      else
	exponent_y = ((BID_UINT32) (y >> 53)) & 0x3ff;
      sign_y = y & 0x8000000000000000ull;

      exponent_x += exponent_y - DECIMAL_EXPONENT_BIAS;

            

Reported by Cppcheck.

Shifting 32-bit value by 53 bits is undefined behaviour
Error

Line: 111 CWE codes: 758

                    if ((y & SPECIAL_ENCODING_MASK64) == SPECIAL_ENCODING_MASK64)
	exponent_y = ((BID_UINT32) (y >> 51)) & 0x3ff;
      else
	exponent_y = ((BID_UINT32) (y >> 53)) & 0x3ff;
      sign_y = y & 0x8000000000000000ull;

      exponent_x += exponent_y - DECIMAL_EXPONENT_BIAS;
      if (exponent_x > DECIMAL_MAX_EXPON_64)
	exponent_x = DECIMAL_MAX_EXPON_64;

            

Reported by Cppcheck.

Shifting 32-bit value by 53 bits is undefined behaviour
Error

Line: 119 CWE codes: 758

              	exponent_x = DECIMAL_MAX_EXPON_64;
      else if (exponent_x < 0)
	exponent_x = 0;
      BID_RETURN ((sign_x ^ sign_y) | (((BID_UINT64) exponent_x) << 53));
    }
  }
  if (!valid_y) {
    // y is Inf. or NaN


            

Reported by Cppcheck.

Shifting 32-bit value by 53 bits is undefined behaviour
Error

Line: 150 CWE codes: 758

                    exponent_x = DECIMAL_MAX_EXPON_64;
    else if (exponent_x < 0)
      exponent_x = 0;
    BID_RETURN ((sign_x ^ sign_y) | (((BID_UINT64) exponent_x) << 53));
  }
  //--- get number of bits in the coefficients of x and y ---
  // version 2 (original)
  tempx.d = (double) coefficient_x;
  bin_expon_cx = ((tempx.i & MASK_BINARY_EXPONENT) >> 52);

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 178 CWE codes: 758

                } else {
    uf_status = 0;
    // get 128-bit product: coefficient_x*coefficient_y
    __mul_64x64_to_128 (P, coefficient_x, coefficient_y);

    // tighten binary range of P:  leading bit is 2^bp
    // unbiased_bin_expon_product <= bp <= unbiased_bin_expon_product+1
    bin_expon_product -= 2 * BINARY_EXPONENT_BIAS;


            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 234 CWE codes: 758

              	final_exponent = 0;

	if (extra_digits > 17) {
	  __mul_128x128_full (Q_high, Q_low, P, bid_reciprocals10_128[16]);

	  amount = bid_recip_scale[16];
	  __shr_128 (P, Q_high, amount);

	  // get sticky bits

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 279 CWE codes: 758

                    __add_128_64 (P, P, bid_round_const_table[rmode][extra_digits]);

      // get P*(2^M[extra_digits])/10^extra_digits
      __mul_128x128_full (Q_high, Q_low, P,
			  bid_reciprocals10_128[extra_digits]);

      // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
      amount = bid_recip_scale[extra_digits];
      __shr_128 (C128, Q_high, amount);

            

Reported by Cppcheck.

buildscripts/idl/checkout_idl_files_from_past_releases.py
7 issues
Consider possible security implications associated with check_output module.
Security blacklist

Line: 33
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import logging
import os
import shutil
from subprocess import check_output
from typing import List

from packaging.version import Version

FIRST_API_V1_RELEASE = '5.0.0-rc3'

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 49
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                  min_version = Version(FIRST_API_V1_RELEASE)

    def gen_versions_and_tags():
        for tag in check_output(['git', 'tag']).decode().split():
            # Releases are like "r5.6.7". Older ones aren't r-prefixed but we don't care about them.
            if not tag.startswith('r'):
                continue

            try:

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 49
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  min_version = Version(FIRST_API_V1_RELEASE)

    def gen_versions_and_tags():
        for tag in check_output(['git', 'tag']).decode().split():
            # Releases are like "r5.6.7". Older ones aren't r-prefixed but we don't care about them.
            if not tag.startswith('r'):
                continue

            try:

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 84
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  for tag in release_tags:
        LOGGER.info("Checking out IDL files in %s", tag)
        directory = os.path.join(destination, tag)
        for path in check_output(['git', 'ls-tree', '--name-only', '-r', tag]).decode().split():
            if not path.endswith('.idl'):
                continue

            contents = check_output(['git', 'show', f'{tag}:{path}']).decode()
            output_path = os.path.join(directory, path)

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 84
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                  for tag in release_tags:
        LOGGER.info("Checking out IDL files in %s", tag)
        directory = os.path.join(destination, tag)
        for path in check_output(['git', 'ls-tree', '--name-only', '-r', tag]).decode().split():
            if not path.endswith('.idl'):
                continue

            contents = check_output(['git', 'show', f'{tag}:{path}']).decode()
            output_path = os.path.join(directory, path)

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 88
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                          if not path.endswith('.idl'):
                continue

            contents = check_output(['git', 'show', f'{tag}:{path}']).decode()
            output_path = os.path.join(directory, path)
            os.makedirs(os.path.dirname(output_path), exist_ok=True)
            with open(output_path, 'w+') as fd:
                fd.write(contents)


            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 88
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                          if not path.endswith('.idl'):
                continue

            contents = check_output(['git', 'show', f'{tag}:{path}']).decode()
            output_path = os.path.join(directory, path)
            os.makedirs(os.path.dirname(output_path), exist_ok=True)
            with open(output_path, 'w+') as fd:
                fd.write(contents)


            

Reported by Bandit.

src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid64_nearbyintd.c
7 issues
Shifting 32-bit value by 53 bits is undefined behaviour
Error

Line: 90 CWE codes: 758

                if (C1 == 0) {
    if (exp < 0)
      exp = 0;
    res = x_sign | (((BID_UINT64) exp + 398) << 53);
    BID_RETURN (res);
  }
  // x is a finite non-zero number (not 0, non-canonical, or special)

  switch (rnd_mode) {

            

Reported by Cppcheck.

Shifting 32-bit value by 52 bits is undefined behaviour
Error

Line: 142 CWE codes: 758

                } else {	// if x < 2^53
    tmp1.d = (double) C1;	// exact conversion
    x_nr_bits =
      1 + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff);
    q = bid_nr_digits[x_nr_bits - 1].digits;
    if (q == 0) {
      q = bid_nr_digits[x_nr_bits - 1].digits1;
      if (C1 >= bid_nr_digits[x_nr_bits - 1].threshold_lo)
	q++;

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 174 CWE codes: 758

                    // kx = 10^(-x) = bid_ten2mk64[ind - 1]
      // C* = (C1 + 1/2 * 10^x) * 10^(-x)
      // the approximation of 10^(-x) was rounded up to 64 bits
      __mul_64x64_to_128 (P128, C1, bid_ten2mk64[ind - 1]);

      // if (0 < f* < 10^(-x)) then the result is a midpoint
      //   if floor(C*) is even then C* = floor(C*) - logical right
      //       shift; C* has p decimal digits, correct by Prop. 1)
      //   else if floor(C*) is odd C* = floor(C*)-1 (logical right

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 227 CWE codes: 758

                    // kx = 10^(-x) = bid_ten2mk64[ind - 1]
      // C* = (C1 + 1/2 * 10^x) * 10^(-x)
      // the approximation of 10^(-x) was rounded up to 64 bits
      __mul_64x64_to_128 (P128, C1, bid_ten2mk64[ind - 1]);

      // if (0 < f* < 10^(-x)) then the result is a midpoint
      //   C* = floor(C*) - logical right shift; C* has p decimal digits, 
      //       correct by Prop. 1)
      // else

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 265 CWE codes: 758

                    // kx = 10^(-x) = bid_ten2mk64[ind - 1]
      // C* = C1 * 10^(-x)
      // the approximation of 10^(-x) was rounded up to 64 bits
      __mul_64x64_to_128 (P128, C1, bid_ten2mk64[ind - 1]);

      // C* = floor(C*) (logical right shift; C has p decimal digits,
      //       correct by Property 1)
      // if (0 < f* < 10^(-x)) then the result is exact
      // n = C* * 10^(e+x)  

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 316 CWE codes: 758

                    // kx = 10^(-x) = bid_ten2mk64[ind - 1]
      // C* = C1 * 10^(-x)
      // the approximation of 10^(-x) was rounded up to 64 bits
      __mul_64x64_to_128 (P128, C1, bid_ten2mk64[ind - 1]);

      // C* = floor(C*) (logical right shift; C has p decimal digits,
      //       correct by Property 1)
      // if (0 < f* < 10^(-x)) then the result is exact
      // n = C* * 10^(e+x)  

            

Reported by Cppcheck.

Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 367 CWE codes: 758

                    // kx = 10^(-x) = bid_ten2mk64[ind - 1]
      // C* = C1 * 10^(-x)
      // the approximation of 10^(-x) was rounded up to 64 bits
      __mul_64x64_to_128 (P128, C1, bid_ten2mk64[ind - 1]);

      // C* = floor(C*) (logical right shift; C has p decimal digits,
      //       correct by Property 1)
      // if (0 < f* < 10^(-x)) then the result is exact
      // n = C* * 10^(e+x)  

            

Reported by Cppcheck.

src/third_party/wiredtiger/test/suite/test_truncate05.py
7 issues
Unable to import 'wiredtiger'
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import wiredtiger, wttest

# test_truncate05.py
# Test various fast truncate visibility scenarios
class test_truncate05(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=2MB'

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import wiredtiger, wttest

# test_truncate05.py
# Test various fast truncate visibility scenarios
class test_truncate05(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=2MB'

            

Reported by Pylint.

Class name "test_truncate05" doesn't conform to PascalCase naming style
Error

Line: 33 Column: 1

              
# test_truncate05.py
# Test various fast truncate visibility scenarios
class test_truncate05(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=2MB'
    session_config = 'isolation=snapshot'

    def test_truncate_read_older_than_newest(self):
        uri = 'table:test_truncate05'

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

              
# test_truncate05.py
# Test various fast truncate visibility scenarios
class test_truncate05(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=2MB'
    session_config = 'isolation=snapshot'

    def test_truncate_read_older_than_newest(self):
        uri = 'table:test_truncate05'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                  conn_config = 'cache_size=2MB'
    session_config = 'isolation=snapshot'

    def test_truncate_read_older_than_newest(self):
        uri = 'table:test_truncate05'
        self.session.create(uri, 'key_format=i,value_format=S')
        cursor = self.session.open_cursor(uri)

        value1 = 'a' * 500

            

Reported by Pylint.

Line too long (105/100)
Error

Line: 59 Column: 1

                      # Insert a single update at a later timestamp.
        self.session.begin_transaction()
        cursor[500] = value2
        self.assertEqual(self.session.commit_transaction('commit_timestamp=' + self.timestamp_str(3)), 0)

        # Insert a bunch of other content to fill the database and evict the committed update.
        for i in range(1000, 20000):
            self.session.begin_transaction()
            cursor[i] = value1

            

Reported by Pylint.

src/third_party/wiredtiger/src/conn/conn_dhandle.c
7 issues
There is an unknown macro here somewhere. Configuration is required. If WT_TAILQ_SAFE_REMOVE_END is a macro then please configure it.
Error

Line: 969

                      WT_WITH_DHANDLE(session, dhandle,
          WT_TRET(__wt_conn_dhandle_discard_single(session, true, F_ISSET(conn, WT_CONN_PANIC))));
    }
    WT_TAILQ_SAFE_REMOVE_END

    return (ret);
}

/*

            

Reported by Cppcheck.

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

Line: 44 Column: 11 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

                  WT_DATA_HANDLE *dhandle;
    WT_DECL_RET;
    char *metaconf, *tmp;
    const char *base, *cfg[4], *strip;

    dhandle = session->dhandle;
    base = NULL;
    tmp = NULL;


            

Reported by FlawFinder.

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: 118 Column: 52 CWE codes: 126

                  }
    dhandle->cfg[1] = metaconf;
    dhandle->meta_base = base;
    dhandle->meta_base_length = base == NULL ? 0 : strlen(base);
#ifdef HAVE_DIAGNOSTIC
    /*  Save the original metadata value for further check to avoid writing corrupted data. */
    if (base == NULL)
        dhandle->orig_meta_base = NULL;
    else

            

Reported by FlawFinder.

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: 219 Column: 48 CWE codes: 126

                      F_SET(dhandle, WT_DHANDLE_IS_METADATA);

    WT_ERR(__wt_rwlock_init(session, &dhandle->rwlock));
    dhandle->name_hash = __wt_hash_city64(uri, strlen(uri));
    WT_ERR(__wt_strdup(session, uri, &dhandle->name));
    WT_ERR(__wt_strdup(session, checkpoint, &dhandle->checkpoint));

    WT_ERR(__wt_spin_init(session, &dhandle->close_lock, "data handle close"));


            

Reported by FlawFinder.

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: 265 Column: 36 CWE codes: 126

                  /* We must be holding the handle list lock at a higher level. */
    WT_ASSERT(session, FLD_ISSET(session->lock_flags, WT_SESSION_LOCKED_HANDLE_LIST));

    bucket = __wt_hash_city64(uri, strlen(uri)) & (conn->dh_hash_size - 1);
    if (checkpoint == NULL) {
        TAILQ_FOREACH (dhandle, &conn->dhhash[bucket], hashq) {
            if (F_ISSET(dhandle, WT_DHANDLE_DEAD))
                continue;
            if (dhandle->checkpoint == NULL && strcmp(uri, dhandle->name) == 0) {

            

Reported by FlawFinder.

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: 702 Column: 40 CWE codes: 126

                   * we walk the entire dhandle list.
     */
    if (uri != NULL) {
        bucket = __wt_hash_city64(uri, strlen(uri)) & (conn->dh_hash_size - 1);

        for (dhandle = NULL;;) {
            WT_WITH_HANDLE_LIST_READ_LOCK(
              session, WT_DHANDLE_NEXT(session, dhandle, &conn->dhhash[bucket], hashq));
            if (dhandle == NULL)

            

Reported by FlawFinder.

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: 820 Column: 36 CWE codes: 126

                   */
    WT_ERR(__conn_dhandle_close_one(session, uri, NULL, removed, mark_dead));

    bucket = __wt_hash_city64(uri, strlen(uri)) & (conn->dh_hash_size - 1);
    TAILQ_FOREACH (dhandle, &conn->dhhash[bucket], hashq) {
        if (strcmp(dhandle->name, uri) != 0 || dhandle->checkpoint == NULL ||
          F_ISSET(dhandle, WT_DHANDLE_DEAD))
            continue;


            

Reported by FlawFinder.