Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/bctoolbox-0.6.0/include/bctoolbox/crypto.h Examining data/bctoolbox-0.6.0/include/bctoolbox/defs.h Examining data/bctoolbox-0.6.0/include/bctoolbox/list.h Examining data/bctoolbox-0.6.0/include/bctoolbox/logging.h Examining data/bctoolbox-0.6.0/include/bctoolbox/map.h Examining data/bctoolbox-0.6.0/include/bctoolbox/parser.h Examining data/bctoolbox-0.6.0/include/bctoolbox/port.h Examining data/bctoolbox-0.6.0/include/bctoolbox/tester.h Examining data/bctoolbox-0.6.0/include/bctoolbox/vconnect.h Examining data/bctoolbox-0.6.0/include/bctoolbox/vfs.h Examining data/bctoolbox-0.6.0/src/containers/list.c Examining data/bctoolbox-0.6.0/src/containers/map.cc Examining data/bctoolbox-0.6.0/src/crypto/polarssl.c Examining data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c Examining data/bctoolbox-0.6.0/src/crypto/mbedtls.c Examining data/bctoolbox-0.6.0/src/logging/logging.c Examining data/bctoolbox-0.6.0/src/parser.c Examining data/bctoolbox-0.6.0/src/tester.c Examining data/bctoolbox-0.6.0/src/utils.h Examining data/bctoolbox-0.6.0/src/utils/exception.cc Examining data/bctoolbox-0.6.0/src/utils/port.c Examining data/bctoolbox-0.6.0/src/vconnect.c Examining data/bctoolbox-0.6.0/src/vfs.c Examining data/bctoolbox-0.6.0/tester/bctoolbox_tester.c Examining data/bctoolbox-0.6.0/tester/bctoolbox_tester.h Examining data/bctoolbox-0.6.0/tester/containers.cc Examining data/bctoolbox-0.6.0/tester/parser.c Examining data/bctoolbox-0.6.0/tester/port.c FINAL RESULTS: data/bctoolbox-0.6.0/include/bctoolbox/logging.h:128:54: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define CHECK_FORMAT_ARGS(m,n) __attribute__((format(printf,m,n))) data/bctoolbox-0.6.0/include/bctoolbox/port.h:192:9: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define vsnprintf _vsnprintf data/bctoolbox-0.6.0/include/bctoolbox/port.h:287:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #ifndef snprintf data/bctoolbox-0.6.0/include/bctoolbox/port.h:288:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/bctoolbox-0.6.0/include/bctoolbox/port.h:288:18: [4] (format) _snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/bctoolbox-0.6.0/include/bctoolbox/tester.h:141:3: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf(format, 4096, name "(" #actual ", " #expected ") - " __VA_ARGS__); \ data/bctoolbox-0.6.0/src/crypto/polarssl.c:44:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/bctoolbox-0.6.0/src/crypto/polarssl.c:44:18: [4] (format) _snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:44:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:44:18: [4] (format) _snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/bctoolbox-0.6.0/src/logging/logging.c:32:9: [4] (race) 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 (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #ifndef access data/bctoolbox-0.6.0/src/logging/logging.c:33:9: [4] (race) 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 (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #define access _access data/bctoolbox-0.6.0/src/logging/logging.c:274:7: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. n = vsnprintf (p, size, fmt, cap); data/bctoolbox-0.6.0/src/logging/logging.c:278:7: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. n = vsnprintf (p, size, fmt, ap); data/bctoolbox-0.6.0/src/logging/logging.c:503:2: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(std,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i %s-%s-%s" ENDLINE data/bctoolbox-0.6.0/src/logging/logging.c:548:8: [4] (race) 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 (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. while(access(log_filename, F_OK) != -1) { data/bctoolbox-0.6.0/src/logging/logging.c:665:8: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. ret = fprintf(f,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i %s-%s-%s" ENDLINE data/bctoolbox-0.6.0/src/tester.c:107:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, format, args); data/bctoolbox-0.6.0/src/tester.c:738:7: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. n = vsnprintf (p, size, format, cap); data/bctoolbox-0.6.0/src/tester.c:742:7: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. n = vsnprintf (p, size, format, args); data/bctoolbox-0.6.0/src/utils/port.c:36:9: [4] (race) 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 (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #ifndef access data/bctoolbox-0.6.0/src/utils/port.c:37:9: [4] (race) 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 (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #define access _access data/bctoolbox-0.6.0/src/utils/port.c:105:2: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(ret,tmp); data/bctoolbox-0.6.0/src/utils/port.c:158:9: [4] (race) 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 (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. return access(pathname,F_OK); data/bctoolbox-0.6.0/tester/bctoolbox_tester.c:30:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(lev == BCTBX_LOG_ERROR ? stderr : stdout, fmt, args); data/bctoolbox-0.6.0/tester/bctoolbox_tester.c:35:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(lev == BCTBX_LOG_ERROR ? stderr : stdout, fmt, cap); data/bctoolbox-0.6.0/include/bctoolbox/logging.h:248:9: [3] (random) setstate: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. strm.setstate(std::ios_base::failbit); data/bctoolbox-0.6.0/src/utils/port.c:996:3: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand((unsigned int)tv.tv_sec+tv.tv_usec); data/bctoolbox-0.6.0/src/utils/port.c:1004:24: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. return (unsigned int) random(); data/bctoolbox-0.6.0/include/bctoolbox/parser.h:32:19: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. typedef unsigned char bctbx_noescape_rules_t[256+1]; /*last entry (BCTBX_NOESCAPE_RULES_USER_INDEX) is reserved for user purpose. Might be usefull to set if array was initialed of not */ data/bctoolbox-0.6.0/include/bctoolbox/tester.h:40:8: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. const char *tags[2]; data/bctoolbox-0.6.0/include/bctoolbox/tester.h:138:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char format[4096] = {0}; \ data/bctoolbox-0.6.0/include/bctoolbox/vfs.h:51:9: [2] (misc) 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? (CWE-362). #define open _open data/bctoolbox-0.6.0/src/crypto/mbedtls.c:152:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tmp[128]; data/bctoolbox-0.6.0/src/crypto/mbedtls.c:167:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tmp[128]; data/bctoolbox-0.6.0/src/crypto/mbedtls.c:229:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(buffer, ((mbedtls_x509_crt *)cert)->raw.p, ((mbedtls_x509_crt *)cert)->raw.len); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:249:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char file_buffer[8192]; data/bctoolbox-0.6.0/src/crypto/mbedtls.c:251:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char formatted_subject[512]; data/bctoolbox-0.6.0/src/crypto/mbedtls.c:254:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(formatted_subject, "CN=", 3); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:255:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(formatted_subject+3, subject, strlen(subject)+1); /* +1 to get the \0 termination */ data/bctoolbox-0.6.0/src/crypto/mbedtls.c:386:11: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char buffer[64]={0}; /* buffer is max length of returned hash, which is 64 in case we use sha-512 */ data/bctoolbox-0.6.0/src/crypto/mbedtls.c:480:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char outputString[BCTBX_MAX_CERTIFICATE_FLAGS_STRING_LENGTH]; data/bctoolbox-0.6.0/src/crypto/mbedtls.c:756:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(context->key+(context->primeLength-keyLength), sharedSecretBuffer, keyLength); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1336:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, 32); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1338:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, hmacLength); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1360:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hashOutput, 32); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1362:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hashOutput, hashLength); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1389:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, 20); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1391:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, hmacLength); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1596:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1628:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1658:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:1687:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl.c:150:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tmp[128]; data/bctoolbox-0.6.0/src/crypto/polarssl.c:165:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tmp[128]; data/bctoolbox-0.6.0/src/crypto/polarssl.c:227:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(buffer, ((x509_crt *)cert)->raw.p, ((x509_crt *)cert)->raw.len); data/bctoolbox-0.6.0/src/crypto/polarssl.c:247:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char file_buffer[8192]; data/bctoolbox-0.6.0/src/crypto/polarssl.c:249:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char formatted_subject[512]; data/bctoolbox-0.6.0/src/crypto/polarssl.c:252:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(formatted_subject, "CN=", 3); data/bctoolbox-0.6.0/src/crypto/polarssl.c:253:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(formatted_subject+3, subject, strlen(subject)+1); /* +1 to get the \0 termination */ data/bctoolbox-0.6.0/src/crypto/polarssl.c:385:11: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char buffer[64]={0}; /* buffer is max length of returned hash, which is 64 in case we use sha-512 */ data/bctoolbox-0.6.0/src/crypto/polarssl.c:479:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char outputString[BCTBX_MAX_CERTIFICATE_FLAGS_STRING_LENGTH]; data/bctoolbox-0.6.0/src/crypto/polarssl.c:643:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(context->key+(context->primeLength-keyLength), sharedSecretBuffer, keyLength); data/bctoolbox-0.6.0/src/crypto/polarssl.c:878:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, ssl_ctx->ssl_ctx.dtls_srtp_keys, ssl_ctx->ssl_ctx.dtls_srtp_keys_len); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1189:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, 32); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1191:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, hmacLength); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1213:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hashOutput, 32); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1215:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hashOutput, hashLength); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1241:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, 20); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1243:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, hmacLength); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1445:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1477:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1507:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl.c:1536:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:138:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tmp[128]; data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:150:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tmp[128]; data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:206:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(buffer, ((x509_cert *)cert)->raw.p, ((x509_cert *)cert)->raw.len); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:239:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char outputString[BCTBX_MAX_CERTIFICATE_FLAGS_STRING_LENGTH]; data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:403:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(context->key+(context->primeLength-keyLength), sharedSecretBuffer, keyLength); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:836:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, 32); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:838:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, hmacLength); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:860:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hashOutput, 32); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:862:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hashOutput, hashLength); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:888:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, 20); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:890:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(output, hmacOutput, hmacLength); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:1058:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:1090:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:1120:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:1149:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(IVbuffer, IV, 16*sizeof(uint8_t)); data/bctoolbox-0.6.0/src/logging/logging.c:521:22: [2] (misc) 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? (CWE-362). filehandler->file = fopen(log_filename, "a"); data/bctoolbox-0.6.0/src/tester.c:495:19: [2] (misc) 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? (CWE-362). writable_file = fopen(writable_file_path, "w"); data/bctoolbox-0.6.0/src/tester.c:596:15: [2] (integer) atol: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). max_vm_kb = atol(argv[i]); data/bctoolbox-0.6.0/src/utils/port.c:347:9: [2] (buffer) TCHAR: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static TCHAR msgBuf[256]; data/bctoolbox-0.6.0/src/utils/port.c:390:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char buf[256]; data/bctoolbox-0.6.0/src/utils/port.c:644:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char name[64]; data/bctoolbox-0.6.0/src/utils/port.c:971:17: [2] (misc) 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? (CWE-362). if (fd==-1) fd=open("/dev/urandom",O_RDONLY); data/bctoolbox-0.6.0/src/utils/port.c:1075:8: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char allocated_by_bctbx_magic[10] = "bctbx"; data/bctoolbox-0.6.0/src/utils/port.c:1104:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(((uint8_t*)&sin6->sin6_addr)+12,&sin->sin_addr,4); data/bctoolbox-0.6.0/src/utils/port.c:1180:24: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). int possible_port = atoi(service); data/bctoolbox-0.6.0/src/utils/port.c:1220:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char serv[16]; data/bctoolbox-0.6.0/src/utils/port.c:1223:18: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (port) *port=atoi(serv); data/bctoolbox-0.6.0/src/utils/port.c:1228:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char ip[64]; data/bctoolbox-0.6.0/src/utils/port.c:1229:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char serv[16]; data/bctoolbox-0.6.0/src/utils/port.c:1263:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char serv[10]; data/bctoolbox-0.6.0/src/utils/port.c:1318:22: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (v6 != result) memcpy(result, v6, sizeof(struct sockaddr_in6)); data/bctoolbox-0.6.0/src/utils/port.c:1323:21: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (v6 != result) memcpy(result, v6, sizeof(struct sockaddr_in)); data/bctoolbox-0.6.0/src/utils/port.c:1348:21: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (v6 != result) memcpy(result, v6, sizeof(struct sockaddr_in)); data/bctoolbox-0.6.0/src/utils/port.c:1366:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(v6, v4m->ai_addr, *result_len); data/bctoolbox-0.6.0/src/utils/port.c:1401:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (wp, s, len); data/bctoolbox-0.6.0/src/utils/port.c:1459:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char port_str[6] = { 0 }; data/bctoolbox-0.6.0/src/utils/port.c:1514:3: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(result, "::1"); data/bctoolbox-0.6.0/src/vfs.c:276:14: [2] (misc) 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? (CWE-362). pFile->fd = open(fName, openFlags, S_IRUSR | S_IWUSR); data/bctoolbox-0.6.0/tester/bctoolbox_tester.c:66:13: [2] (misc) 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? (CWE-362). log_file = fopen(filename, "a"); data/bctoolbox-0.6.0/tester/containers.cc:122:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char str[32]; data/bctoolbox-0.6.0/tester/containers.cc:131:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char str[32]; data/bctoolbox-0.6.0/tester/containers.cc:154:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char str[32]; data/bctoolbox-0.6.0/tester/containers.cc:187:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char str[32]; data/bctoolbox-0.6.0/tester/port.c:94:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&testTs, &y2k, sizeof(bctoolboxTimeSpec)); data/bctoolbox-0.6.0/tester/port.c:101:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&testTs, &y2k, sizeof(bctoolboxTimeSpec)); data/bctoolbox-0.6.0/tester/port.c:107:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&testTs, &y2k, sizeof(bctoolboxTimeSpec)); data/bctoolbox-0.6.0/include/bctoolbox/vfs.h:52:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define read _read data/bctoolbox-0.6.0/src/crypto/mbedtls.c:255:39: [1] (buffer) 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) (CWE-126). memcpy(formatted_subject+3, subject, strlen(subject)+1); /* +1 to get the \0 termination */ data/bctoolbox-0.6.0/src/crypto/mbedtls.c:279:21: [1] (buffer) 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) (CWE-126). file_buffer_len = strlen(file_buffer); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:329:7: [1] (buffer) 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) (CWE-126). if (strlen(file_buffer)+1>pem_length) { data/bctoolbox-0.6.0/src/crypto/mbedtls.c:330:145: [1] (buffer) 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) (CWE-126). bctbx_error("Certificate generation can't copy the certificate to pem buffer: too short [%ld] but need [%ld] bytes", (long)pem_length, (long)strlen(file_buffer)); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:333:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pem, file_buffer, pem_length); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:337:100: [1] (buffer) 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) (CWE-126). if ( (ret = mbedtls_x509_crt_parse((mbedtls_x509_crt *)certificate, (unsigned char *)file_buffer, strlen(file_buffer)+1) ) != 0) { data/bctoolbox-0.6.0/src/crypto/mbedtls.c:457:30: [1] (buffer) 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) (CWE-126). size_t fingerprint_index = strlen(hash_alg_string); data/bctoolbox-0.6.0/src/crypto/mbedtls.c:531:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buffer, outputString, buffer_size); data/bctoolbox-0.6.0/src/crypto/polarssl.c:253:39: [1] (buffer) 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) (CWE-126). memcpy(formatted_subject+3, subject, strlen(subject)+1); /* +1 to get the \0 termination */ data/bctoolbox-0.6.0/src/crypto/polarssl.c:276:21: [1] (buffer) 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) (CWE-126). file_buffer_len = strlen(file_buffer); data/bctoolbox-0.6.0/src/crypto/polarssl.c:329:7: [1] (buffer) 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) (CWE-126). if (strlen(file_buffer)+1>pem_length) { data/bctoolbox-0.6.0/src/crypto/polarssl.c:330:145: [1] (buffer) 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) (CWE-126). bctbx_error("Certificate generation can't copy the certificate to pem buffer: too short [%ld] but need [%ld] bytes", (long)pem_length, (long)strlen(file_buffer)); data/bctoolbox-0.6.0/src/crypto/polarssl.c:333:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pem, file_buffer, pem_length); data/bctoolbox-0.6.0/src/crypto/polarssl.c:336:84: [1] (buffer) 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) (CWE-126). if ( (ret = x509_crt_parse((x509_crt *)certificate, (unsigned char *)file_buffer, strlen(file_buffer)) ) != 0) { data/bctoolbox-0.6.0/src/crypto/polarssl.c:456:27: [1] (buffer) 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) (CWE-126). int fingerprint_index = strlen(hash_alg_string); data/bctoolbox-0.6.0/src/crypto/polarssl.c:502:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buffer, outputString, buffer_size); data/bctoolbox-0.6.0/src/crypto/polarssl1.2.c:262:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buffer, outputString, buffer_size); data/bctoolbox-0.6.0/src/logging/logging.c:315:11: [1] (buffer) 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) (CWE-126). dstlen = strlen(dst); data/bctoolbox-0.6.0/src/logging/logging.c:316:11: [1] (buffer) 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) (CWE-126). retlen = strlen(ret); data/bctoolbox-0.6.0/src/logging/logging.c:319:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(dst,ret,retlen); data/bctoolbox-0.6.0/src/logging/logging.c:494:14: [1] (buffer) 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) (CWE-126). size_t len=strlen(msg); data/bctoolbox-0.6.0/src/logging/logging.c:656:14: [1] (buffer) 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) (CWE-126). size_t len=strlen(msg); data/bctoolbox-0.6.0/src/parser.c:28:21: [1] (buffer) 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) (CWE-126). size_t outbuf_size=strlen(buff); data/bctoolbox-0.6.0/src/parser.c:86:33: [1] (buffer) 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) (CWE-126). char *output_buff=bctbx_malloc(strlen(buff)+1); data/bctoolbox-0.6.0/src/utils/port.c:103:5: [1] (buffer) 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) (CWE-126). sz=strlen(tmp)+1; data/bctoolbox-0.6.0/src/utils/port.c:183:19: [1] (buffer) 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) (CWE-126). int min=MIN((int)strlen(str),n)+1; data/bctoolbox-0.6.0/src/utils/port.c:185:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ret,str,min); data/bctoolbox-0.6.0/src/utils/port.c:421:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sa.sun_path,pipename,sizeof(sa.sun_path)-1); data/bctoolbox-0.6.0/src/utils/port.c:471:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sa.sun_path,pipename,sizeof(sa.sun_path)-1); data/bctoolbox-0.6.0/src/utils/port.c:481:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return read(p,buf,len); data/bctoolbox-0.6.0/src/utils/port.c:974:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd,&tmp,4)!=4){ data/bctoolbox-0.6.0/src/utils/port.c:1066:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return read(fd, buf, nbytes); data/bctoolbox-0.6.0/src/utils/port.c:1216:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(ip, "<bug!!>", ip_size); data/bctoolbox-0.6.0/src/utils/port.c:1386:17: [1] (buffer) 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) (CWE-126). size_t len = strlen (s); data/bctoolbox-0.6.0/src/utils/port.c:1523:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(result, (type == AF_INET) ? "127.0.0.1" : "::1", result_len); data/bctoolbox-0.6.0/src/vfs.c:403:11: [1] (buffer) 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) (CWE-126). count = strlen(ret); ANALYSIS SUMMARY: Hits = 157 Lines analyzed = 12399 in approximately 0.37 seconds (33083 lines/second) Physical Source Lines of Code (SLOC) = 8332 Hits@level = [0] 67 [1] 37 [2] 91 [3] 3 [4] 26 [5] 0 Hits@level+ = [0+] 224 [1+] 157 [2+] 120 [3+] 29 [4+] 26 [5+] 0 Hits/KSLOC@level+ = [0+] 26.8843 [1+] 18.843 [2+] 14.4023 [3+] 3.48056 [4+] 3.1205 [5+] 0 Dot directories skipped = 1 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.