The following issues were found

src/crypto/ctaes/test.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 64 Column: 18 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

                  int i;
    int fail = 0;
    for (i = 0; i < sizeof(ctaes_tests) / sizeof(ctaes_tests[0]); i++) {
        unsigned char key[32], plain[16], cipher[16], ciphered[16], deciphered[16];
        const ctaes_test* test = &ctaes_tests[i];
        assert(test->keysize == 128 || test->keysize == 192 || test->keysize == 256);
        from_hex(plain, 16, test->plain);
        from_hex(cipher, 16, test->cipher);
        switch (test->keysize) {

            

Reported by FlawFinder.

src/secp256k1/src/gen_context.c
1 issues
fopen - 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: 51 Column: 10 CWE codes: 362

                  (void)argc;
    (void)argv;

    fp = fopen("src/ecmult_static_context.h","w");
    if (fp == NULL) {
        fprintf(stderr, "Could not open src/ecmult_static_context.h for writing!\n");
        return -1;
    }


            

Reported by FlawFinder.

src/crypto/chacha_poly_aead.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

              private:
    ChaCha20 m_chacha_main;                                      // payload and poly1305 key-derivation cipher instance
    ChaCha20 m_chacha_header;                                    // AAD cipher instance (encrypted length)
    unsigned char m_aad_keystream_buffer[CHACHA20_ROUND_OUTPUT]; // aad keystream cache
    uint64_t m_cached_aad_seqnr;                                 // aad keystream cache hint

public:
    ChaCha20Poly1305AEAD(const unsigned char* K_1, size_t K_1_len, const unsigned char* K_2, size_t K_2_len);


            

Reported by FlawFinder.

src/crypto/chacha_poly_aead.cpp
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

                      return false;
    }

    unsigned char expected_tag[POLY1305_TAGLEN], poly_key[POLY1305_KEYLEN];
    memset(poly_key, 0, sizeof(poly_key));
    m_chacha_main.SetIV(seqnr_payload);

    // block counter 0 for the poly1305 key
    // use lower 32bytes for the poly1305 key

            

Reported by FlawFinder.

src/crc32c/src/crc32c_unittest.cc
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

              }  // namespace crc32c

TEST(CRC32CTest, Crc32cCharPointer) {
  char buf[32];

  std::memset(buf, 0, sizeof(buf));
  EXPECT_EQ(static_cast<uint32_t>(0x8a9136aa),
            crc32c::Crc32c(buf, sizeof(buf)));


            

Reported by FlawFinder.

src/crc32c/src/crc32c_round_up_unittest.cc
1 issues
syntax error
Error

Line: 58

                ASSERT_EQ(~static_cast<uintptr_t>(7), RoundUp<4>(~static_cast<uintptr_t>(9)));
}

TEST(CRC32CRoundUpTest, RoundUpPointer) {
  uintptr_t zero = 0, three = 3, four = 4, seven = 7, eight = 8;

  const uint8_t* zero_ptr = reinterpret_cast<const uint8_t*>(zero);
  const uint8_t* three_ptr = reinterpret_cast<const uint8_t*>(three);
  const uint8_t* four_ptr = reinterpret_cast<const uint8_t*>(four);

            

Reported by Cppcheck.

src/crc32c/src/crc32c_read_le_unittest.cc
1 issues
syntax error
Error

Line: 24

                EXPECT_EQ(static_cast<uint32_t>(0x12345678), ReadUint32LE(bytes));
}

TEST(Crc32CReadLETest, ReadUint64LE) {
  // little-endian 0x123456789ABCDEF0
  alignas(8) uint8_t bytes[] = {0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12};

  ASSERT_EQ(RoundUp<8>(bytes), bytes) << "Stack array is not aligned";
  EXPECT_EQ(static_cast<uint64_t>(0x123456789ABCDEF0), ReadUint64LE(bytes));

            

Reported by Cppcheck.

src/qt/bantablemodel.cpp
1 issues
system - This causes a new program to execute and is difficult to use safely
Security

Line: 128 Column: 29 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                      case Bantime:
            QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
            date = date.addSecs(rec->banEntry.nBanUntil);
            return QLocale::system().toString(date, QLocale::LongFormat);
        } // no default case, so the compiler can warn about missing cases
        assert(false);
    }

    return QVariant();

            

Reported by FlawFinder.

src/secp256k1/include/secp256k1_schnorrsig.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

               *             pointer to 32-byte auxiliary randomness as per BIP-340.
 */
typedef struct {
    unsigned char magic[4];
    secp256k1_nonce_function_hardened noncefp;
    void* ndata;
} secp256k1_schnorrsig_extraparams;

#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_MAGIC { 0xda, 0x6f, 0xb3, 0x8c }

            

Reported by FlawFinder.

src/secp256k1/include/secp256k1_recovery.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

               *  memcmp'ed.
 */
typedef struct {
    unsigned char data[65];
} secp256k1_ecdsa_recoverable_signature;

/** Parse a compact ECDSA signature (64 bytes + recovery id).
 *
 *  Returns: 1 when the signature could be parsed, 0 otherwise

            

Reported by FlawFinder.