The following issues were found

src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c
2 issues
strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 196 Column: 9 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

                          cache = CACHE_SHARED;
        else if (WT_PREFIX_MATCH(p, ",cache_size"))
            cache = CACHE_SET;
        strcpy(config, p);

        for (j = (__wt_random(&rnd) % WT_ELEMENTS(list)) + 1; j > 0; --j) {
            p = list[__wt_random(&rnd) % WT_ELEMENTS(list)];
            if (WT_PREFIX_MATCH(p, ",shared_cache")) {
                if (cache == CACHE_SET)

            

Reported by FlawFinder.

strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 209 Column: 13 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                                  continue;
                cache = CACHE_SET;
            }
            strcat(config, p);
        }
        reconfig(opts, session, config);
    }

    /*

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/csuite/wt3184_dup_index_collator/main.c
2 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 73 Column: 9 CWE codes: 134
Suggestion: Use a constant for the format specification

              print_int_item(const char *str, const WT_ITEM *item)
{
    if (item->size > 0)
        printf("%s%" PRId32, str, item_to_int(item));
    else
        printf("%s<empty>", str);
}

static int

            

Reported by FlawFinder.

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

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

                   * Using memcpy instead of direct type cast to avoid undefined behavior sanitizer complaining
     * about misaligned address.
     */
    memcpy(&ret, item->data, sizeof(int32_t));
    return ret;
}

static int
compare_int_items(WT_ITEM *itema, WT_ITEM *itemb)

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/csuite/wt3874_pad_byte_collator/main.c
2 issues
srand - This function is not sufficiently random for security-related functions such as key and nonce creation
Security

Line: 67 Column: 5 CWE codes: 327
Suggestion: Use a more secure technique for acquiring random values

              
    opts = &_opts;
    memset(opts, 0, sizeof(*opts));
    srand(123);

    testutil_check(testutil_parse_opts(argc, argv, opts));
    testutil_make_work_dir(opts->home);

    testutil_check(wiredtiger_open(opts->home, NULL, "create,log=(enabled)", &opts->conn));

            

Reported by FlawFinder.

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

Line: 63 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_ITEM key;
    WT_SESSION *session;
    char buf[KEY_SIZE];

    opts = &_opts;
    memset(opts, 0, sizeof(*opts));
    srand(123);


            

Reported by FlawFinder.

src/third_party/wiredtiger/test/cursor_order/cursor_order_file.c
2 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 37 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_CONNECTION *conn;
    WT_SESSION *session;
    int ret;
    char config[128];

    conn = cfg->conn;

    testutil_check(conn->open_session(conn, NULL, NULL, &session));


            

Reported by FlawFinder.

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

Line: 68 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_SESSION *session;
    size_t len;
    uint64_t keyno;
    char keybuf[64], valuebuf[64];

    conn = cfg->conn;

    file_create(cfg, name);


            

Reported by FlawFinder.

src/third_party/wiredtiger/test/fops/file.c
2 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 78 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 *c;
    WT_SESSION *session;
    int ret;
    char new_uri[64];

    testutil_check(conn->open_session(conn, NULL, NULL, &session));

    /* Generate a unique object name. */
    testutil_check(pthread_rwlock_wrlock(&single));

            

Reported by FlawFinder.

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

Line: 156 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_SESSION *session;
    int ret;
    char new_uri[64];

    testutil_check(conn->open_session(conn, NULL, NULL, &session));

    /* Generate a unique object name. */
    testutil_check(pthread_rwlock_wrlock(&single));

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/format/bulk.c
2 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 39 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

              bulk_begin_transaction(WT_SESSION *session)
{
    uint64_t ts;
    char buf[64];

    /* Writes require snapshot isolation. */
    wiredtiger_begin_transaction(session, NULL);
    ts = __wt_atomic_addv64(&g.timestamp, 1);
    testutil_check(__wt_snprintf(buf, sizeof(buf), "read_timestamp=%" PRIx64, ts));

            

Reported by FlawFinder.

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

Line: 56 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

              bulk_commit_transaction(WT_SESSION *session)
{
    uint64_t ts;
    char buf[64];

    ts = __wt_atomic_addv64(&g.timestamp, 1);
    testutil_check(__wt_snprintf(buf, sizeof(buf), "commit_timestamp=%" PRIx64, ts));
    testutil_check(session->commit_transaction(session, buf));


            

Reported by FlawFinder.

src/third_party/wiredtiger/test/format/checkpoint.c
2 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 38 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

              void
wts_checkpoints(void)
{
    char config[1024];

    /*
     * Configuring WiredTiger library checkpoints is done separately, rather than as part of the
     * original database open because format tests small caches and you can get into cache stuck
     * trouble during the initial load (where bulk load isn't configured). There's a single thread

            

Reported by FlawFinder.

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

Line: 68 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_DECL_RET;
    WT_SESSION *session;
    u_int secs;
    char config_buf[64];
    const char *ckpt_config;
    bool backup_locked;

    (void)arg;
    conn = g.wts_conn;

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/format/format.h
2 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 109 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

              #define LOCK_INITIALIZED(lock) ((lock)->lock_type != LOCK_NONE)

typedef struct {
    char tidbuf[128]; /* thread ID in printable form */

    WT_CONNECTION *wts_conn;
    WT_CONNECTION *wts_conn_inmemory;
    WT_SESSION *wts_session;


            

Reported by FlawFinder.

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

Line: 356 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

              typedef struct {
    int id;           /* simple thread ID */
    wt_thread_t tid;  /* thread ID */
    char tidbuf[128]; /* thread ID in printable form */

    WT_RAND_STATE rnd; /* thread RNG state */

    volatile bool quit; /* thread should quit */


            

Reported by FlawFinder.

src/third_party/wiredtiger/test/format/t.c
2 issues
access - This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition
Security

Line: 221 Column: 13 CWE codes: 362/367!
Suggestion: Set up the correct permissions (e.g., using setuid()) and try to open the file directly

                   * file, used when running checks.
     */
    if (g.reopen) {
        if (access(g.home_config, R_OK) != 0)
            testutil_die(ENOENT, "%s", g.home_config);
        config = g.home_config;
    }
    if (config == NULL && access("CONFIG", R_OK) == 0)
        config = "CONFIG";

            

Reported by FlawFinder.

access - This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition
Security

Line: 225 Column: 27 CWE codes: 362/367!
Suggestion: Set up the correct permissions (e.g., using setuid()) and try to open the file directly

                          testutil_die(ENOENT, "%s", g.home_config);
        config = g.home_config;
    }
    if (config == NULL && access("CONFIG", R_OK) == 0)
        config = "CONFIG";
    if (config != NULL && strcmp(config, ".") != 0)
        config_file(config);

    /*

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/huge/huge.c
2 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 87 Column: 5 CWE codes: 134
Suggestion: Use a constant for the format specification

              
    big[bytes - 1] = '\0';

    printf(SIZET_FMT "%s%s: %s %s big %s\n",
      bytes < MEGABYTE ? bytes : (bytes < GIGABYTE ? bytes / MEGABYTE : bytes / GIGABYTE),
      bytes < MEGABYTE ? "" :
                         (bytes < GIGABYTE ? (bytes % MEGABYTE == 0 ? "" : "+") :
                                             (bytes % GIGABYTE == 0 ? "" : "+")),
      bytes < MEGABYTE ? "B" : (bytes < GIGABYTE ? "MB" : "GB"), cp->uri, cp->config,

            

Reported by FlawFinder.

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

Line: 31 Column: 8 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

              
#include "test_util.h"

static char home[512]; /* Program working dir */
static uint8_t *big;   /* Big key/value buffer */

#define GIGABYTE (1073741824)
#define MEGABYTE (1048576)


            

Reported by FlawFinder.