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/tpm-tools-1.3.9.1/include/tpm_seal.h Examining data/tpm-tools-1.3.9.1/include/tpm_utils.h Examining data/tpm-tools-1.3.9.1/include/tpm_unseal.h Examining data/tpm-tools-1.3.9.1/include/tpm_tspi.h Examining data/tpm-tools-1.3.9.1/include/tpm_pkcs11.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_common.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_object.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_object.c Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.h Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.c Examining data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c Examining data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c Examining data/tpm-tools-1.3.9.1/src/cmds/tpm_unsealdata.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_clearable.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_clear.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_restrictsrk.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_startup.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_restrictpubek.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_getpubek.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_changeauth.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.h Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_setoperatorauth.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_revokeek.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_reset.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_version.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_selftest.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvread.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_enable.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvrelease.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_activate.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvinfo.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_resetdalock.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_ownable.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_present.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_takeownership.c Examining data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c Examining data/tpm-tools-1.3.9.1/lib/tpm_utils.c Examining data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c Examining data/tpm-tools-1.3.9.1/lib/tpm_log.c Examining data/tpm-tools-1.3.9.1/lib/tpm_tspi.c Examining data/tpm-tools-1.3.9.1/lib/tpm_unseal.c FINAL RESULTS: data/tpm-tools-1.3.9.1/lib/tpm_log.c:121:9: [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. return vfprintf(a_sStream, a_szFormat, a_vaArgs); data/tpm-tools-1.3.9.1/lib/tpm_log.c:141:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf( lOpt, "-l, --log [%s|%s|%s|%s]", LOG_NONE, LOG_ERROR, LOG_INFO, LOG_DEBUG ); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:68: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( szShortOpts, pszGenShortOpts); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:70:3: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat( szShortOpts, a_pszShortOpts ); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:181:15: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. pszPasswd = getpass( pszPrompt ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:258:5: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf( szPrompt, TOKEN_ID_PROMPT, a_pszObject ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:161:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf( szSoNewPinPrompt, TOKEN_SO_NEW_PIN_PROMPT, getMinPinLen( ), getMaxPinLen( ) ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:193:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf( szUserNewPinPrompt, TOKEN_USER_NEW_PIN_PROMPT, getMinPinLen( ), getMaxPinLen( ) ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c:163:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf( szSoNewPinPrompt, TOKEN_SO_NEW_PIN_PROMPT, getMinPinLen( ), getMaxPinLen( ) ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c:167:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf( szUserNewPinPrompt, TOKEN_USER_NEW_PIN_PROMPT, getMinPinLen( ), getMaxPinLen( ) ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:218:6: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(buffer, svals[i].name); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:240:4: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(buffer, printbuf); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:182:7: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. n = fscanf(f, "%c %u %s\n", &rw, &pcr, hash_ascii); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:80:19: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ( ( iOpt = getopt_long( a_iNumArgs, a_pszArgs, data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:84: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 szSlotDesc[ sizeof( a_ptSlotInfo->slotDescription ) + 1 ]; data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:85: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 szSlotMfr[ sizeof( a_ptSlotInfo->manufacturerID ) + 1 ]; data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:110: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 szTokenLabel[ sizeof( a_ptTokenInfo->label ) + 1 ]; data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:111: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 szTokenMfr[ sizeof( a_ptTokenInfo->manufacturerID ) + 1 ]; data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:112: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 szTokenModel[ sizeof( a_ptTokenInfo->model ) + 1 ]; data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:153: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 szTokenLabel[ sizeof( tTokenInfo.label ) ]; data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:563: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( phObjList, phTemp, ulCurCount * sizeof( CK_OBJECT_HANDLE ) ); data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:73: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 data[EVP_CIPHER_block_size(EVP_aes_256_cbc()) * 16]; data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:181: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(tssKeyData + tssLen, data, rcLen); data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:253: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(evpKeyData + evpLen, data, rcLen); data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:474:1: [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 tpm_error_buf[512]; data/tpm-tools-1.3.9.1/lib/tpm_utils.c:58: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 szShortOpts[strlen( pszGenShortOpts ) data/tpm-tools-1.3.9.1/lib/tpm_utils.c:73: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( sLongOpts, sGenLongOpts, sizeof( sGenLongOpts ) ); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:75: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( sLongOpts + iNumGenLongOpts, data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:44: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 in_filename[PATH_MAX] = "", out_filename[PATH_MAX] = ""; data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:72:38: [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). selectedPcrs[selectedPcrsLen++] = atoi(aArg); data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:105: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 line[EVP_CIPHER_block_size(EVP_aes_256_cbc()) * 16]; data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:107: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 encData[sizeof(line) + EVP_CIPHER_block_size(EVP_aes_256_cbc())]; data/tpm-tools-1.3.9.1/src/cmds/tpm_unsealdata.c: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. static char in_filename[PATH_MAX] = "", out_filename[PATH_MAX] = ""; data/tpm-tools-1.3.9.1/src/cmds/tpm_unsealdata.c:94: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). } else if ((fp = fopen(out_filename, "w")) == NULL) { data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:128: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 *pszArgs[2]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:129: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 *pszArgsDesc[2]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:220: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( tAttr, tDefaultAttr, ulDefaultAttrCount * sizeof( CK_ATTRIBUTE ) ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:222: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( tAttr + ulDefaultAttrCount, a_tAttr, a_ulAttrCount * sizeof( CK_ATTRIBUTE ) ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:246: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 szPrompt[ strlen( TOKEN_ID_PROMPT ) + strlen( a_pszObject ) + 1 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:335:11: [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). pFile = fopen( a_pszFile, "r" ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:574:11: [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). pFile = fopen( a_pszFile, "r" ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:103: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 szSoNewPinPrompt[ strlen( TOKEN_SO_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:104: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 szUserNewPinPrompt[ strlen( TOKEN_USER_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c:109: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 szSoNewPinPrompt[ strlen( TOKEN_SO_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c:110: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 szUserNewPinPrompt[ strlen( TOKEN_USER_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.c:283:15: [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). g_pInFile = fopen( g_pszInFile, "r" ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.c:354:16: [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). g_pOutFile = fopen( g_pszOutFile, "w" ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.c:407: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( g_pbOutData, a_pbData, a_ulDataLen ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c:31: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 in_filename[PATH_MAX] = "", out_filename[PATH_MAX] = ""; data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c:97:11: [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). infile = fopen(in_filename, "r"); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c:131:12: [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). outfile = fopen(out_filename, "w"); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c:217: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). FILE *outfile = fopen(out_filename, "w"); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:198: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 printbuf[30]; data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:112:15: [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 (aArg && atoi(aArg) >= 0 && atoi(aArg) < 24) { data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:112:34: [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 (aArg && atoi(aArg) >= 0 && atoi(aArg) < 24) { data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:113:46: [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). selectedPcrsRead[selectedPcrsReadLen++] = atoi(aArg); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:119:15: [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 (aArg && atoi(aArg) >= 0 && atoi(aArg) < 24) { data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:119:34: [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 (aArg && atoi(aArg) >= 0 && atoi(aArg) < 24) { data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:120:48: [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). selectedPcrsWrite[selectedPcrsWriteLen++] = atoi(aArg); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:177: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 hash_ascii[65], hash_bin[32], save; data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:443:7: [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). f = fopen(filename, "r"); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvread.c:100: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 buf[17] = { 0, }; data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvread.c:274:8: [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). fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c:209:8: [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). fd = open(filename, O_RDONLY); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_present.c:171: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 rsp[5]; data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_reset.c:42:7: [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). fd = open( "/dev/tpm0", O_RDWR ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_revokeek.c:27: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 in_filename[PATH_MAX] = ""; data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_revokeek.c:70:11: [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). infile = fopen(in_filename, "r"); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_startup.c:49:7: [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). fd = open( "/dev/tpm0", O_RDWR ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_version.c:43:13: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). FILE* f = tmpfile(); data/tpm-tools-1.3.9.1/lib/tpm_log.c:138: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). lOpt = malloc(16+strlen(LOG_NONE)+strlen(LOG_ERROR)+ data/tpm-tools-1.3.9.1/lib/tpm_log.c:138:36: [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). lOpt = malloc(16+strlen(LOG_NONE)+strlen(LOG_ERROR)+ data/tpm-tools-1.3.9.1/lib/tpm_log.c:139:4: [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). strlen(LOG_INFO)+strlen(LOG_DEBUG)); data/tpm-tools-1.3.9.1/lib/tpm_log.c:139: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). strlen(LOG_INFO)+strlen(LOG_DEBUG)); data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:90:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szSlotDesc, (char *)a_ptSlotInfo->slotDescription, data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:92:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szSlotMfr, (char *)a_ptSlotInfo->manufacturerID, data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:118:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szTokenLabel, (char *)a_ptTokenInfo->label, data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:120:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szTokenMfr, (char *)a_ptTokenInfo->manufacturerID, data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:122:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szTokenModel, (char *)a_ptTokenInfo->model, data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:177:8: [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( a_pszTokenLabel ) > sizeof( szTokenLabel ) ) { data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:186:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szTokenLabel, pszTokenLabel, strlen( pszTokenLabel ) ); data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:186:40: [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). strncpy( szTokenLabel, pszTokenLabel, strlen( pszTokenLabel ) ); data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:311:64: [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). rv = g_pFcnList->C_InitToken( g_tSlotId, (CK_CHAR *)a_pszPin, strlen( a_pszPin ), g_tToken.label ); data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:387:70: [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). rv = g_pFcnList->C_Login( a_hSession, a_tType, (CK_CHAR *)a_pszPin, strlen( a_pszPin ) ); data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:405:63: [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). rv = g_pFcnList->C_InitPIN( a_hSession, (CK_CHAR *)a_pszPin, strlen( a_pszPin ) ); data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:425:65: [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). rv = g_pFcnList->C_SetPIN( a_hSession, (CK_CHAR *)a_pszOldPin, strlen( a_pszOldPin ), data/tpm-tools-1.3.9.1/lib/tpm_pkcs11.c:426:28: [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). (CK_CHAR *)a_pszNewPin, strlen( a_pszNewPin ) ); data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:118:4: [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). strlen(TPMSEAL_HDR_STRING)) != 0) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:127:4: [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). strlen(TPMSEAL_TSS_STRING)) != 0) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:145: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). strlen(TPMSEAL_EVP_STRING)) == 0) data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:155:4: [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). strlen(TPMSEAL_EVP_STRING)) != 0 ) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:197:4: [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). strlen(TPMSEAL_KEYTYPE_SYM)) != 0 ) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:205: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). if (strncmp(data + strlen(TPMSEAL_KEYTYPE_SYM), data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:207:4: [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). strlen(TPMSEAL_CIPHER_AES256CBC)) != 0) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:217: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). strlen(TPMSEAL_ENC_STRING)) == 0) data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:227:4: [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). strlen(TPMSEAL_ENC_STRING)) != 0 ) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:270: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). strlen(TPMSEAL_FTR_STRING)) == 0) data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:280:4: [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). strlen(TPMSEAL_FTR_STRING)) != 0 ) { data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:328:6: [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). strlen(TPMSEAL_SECRET), data/tpm-tools-1.3.9.1/lib/tpm_unseal.c:383:6: [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). strlen(TPMSEAL_SECRET), data/tpm-tools-1.3.9.1/lib/tpm_utils.c:58:20: [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 szShortOpts[strlen( pszGenShortOpts ) data/tpm-tools-1.3.9.1/lib/tpm_utils.c:59:43: [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). + ( ( a_pszShortOpts == NULL ) ? 0 : strlen( a_pszShortOpts ) ) data/tpm-tools-1.3.9.1/lib/tpm_utils.c:150:29: [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). __memset( a_pszPasswd, 0, strlen( a_pszPasswd ) ); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:212:13: [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). *a_iLen = strlen(pszRetPasswd); data/tpm-tools-1.3.9.1/lib/tpm_utils.c:222: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). __memset( pszPasswd, 0, strlen( pszPasswd ) ); data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:60:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(in_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:66:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(out_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:147:6: [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(in_filename) == 0) data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:246:31: [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 (policySetSecret(hPolicy, strlen(TPMSEAL_SECRET), (BYTE *)TPMSEAL_SECRET) data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:273:31: [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 (policySetSecret(hPolicy, strlen(TPMSEAL_SECRET), (BYTE *)TPMSEAL_SECRET) data/tpm-tools-1.3.9.1/src/cmds/tpm_sealdata.c:309:6: [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(out_filename) == 0) data/tpm-tools-1.3.9.1/src/cmds/tpm_unsealdata.c:50:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(in_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/cmds/tpm_unsealdata.c:56:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(out_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/cmds/tpm_unsealdata.c:90:6: [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(out_filename) == 0) { data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:92:18: [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). g_ulNameLen = strlen( a_pszOptArg ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:246:18: [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 szPrompt[ strlen( TOKEN_ID_PROMPT ) + strlen( a_pszObject ) + 1 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:246:46: [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 szPrompt[ strlen( TOKEN_ID_PROMPT ) + strlen( a_pszObject ) + 1 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:261:8: [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). ( strlen( pszReply ) == 0 ) || data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:975: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). ( strlen( pszReply ) == 0 ) || data/tpm-tools-1.3.9.1/src/data_mgmt/data_import.c:1016: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). g_ulIdLen = strlen( (char *)g_pchId ); data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:103:26: [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 szSoNewPinPrompt[ strlen( TOKEN_SO_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:104:28: [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 szUserNewPinPrompt[ strlen( TOKEN_USER_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_init.c:132: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). ( strlen( pszReply ) == 0 ) || data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c:109:26: [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 szSoNewPinPrompt[ strlen( TOKEN_SO_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_passwd.c:110:28: [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 szUserNewPinPrompt[ strlen( TOKEN_USER_NEW_PIN_PROMPT ) + 16 ]; data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.c:184:42: [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). { CKA_LABEL, TOKEN_PROTECT_KEY_LABEL, strlen( TOKEN_PROTECT_KEY_LABEL ) }, data/tpm-tools-1.3.9.1/src/data_mgmt/data_protect.c:225:42: [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). { CKA_LABEL, TOKEN_PROTECT_KEY_LABEL, strlen( TOKEN_PROTECT_KEY_LABEL ) }, data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c:63:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(in_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_createek.c:69:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(out_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:113:18: [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 totlen = strlen(aArg); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:123: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(svals[i].name); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:207:12: [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). len = strlen(svals[i].name); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:208:16: [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 (len + strlen(buffer) + 1 > data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:217:7: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(buffer, "|"); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:231:23: [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). len = strlen(printbuf); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvcommon.c:232:13: [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 (len + strlen(buffer) + 1 > buffer_size) { data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:201: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). for (n = 0; n < strlen(hash_ascii); n += 2) { data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:323: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). opswd_len = strlen(ownerpass); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvdefine.c:351: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). dpswd_len = strlen(datapass); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvread.c:213:16: [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). pswd_len = strlen(password); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvrelease.c:135:16: [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). pswd_len = strlen(ownerpass); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c:186:18: [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). ulDataLength = strlen(data); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c:214:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read_bytes = read(fd, rgbDataToWrite, ulDataLength); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c:270:16: [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). pswd_len = strlen(password); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c:271:36: [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 (policySetSecret(hTpmPolicy, strlen(password), data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_nvwrite.c:286:37: [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 (policySetSecret(hDataPolicy, strlen(password), data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_present.c:228:14: [1] (buffer) scanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. scanCount = scanf("%5s", rsp); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_reset.c:55:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). err = read( fd, reset, sizeof(reset) ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_revokeek.c:45:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(in_filename, aArg, PATH_MAX); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_startup.c:62:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). err = read( fd, startup, sizeof(startup) ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_startup.c:90:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). err = read( fd, selftest, sizeof(selftest) ); data/tpm-tools-1.3.9.1/src/tpm_mgmt/tpm_version.c:98:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (st.st_size != read(STDERR_FILENO, buf, st.st_size)) { ANALYSIS SUMMARY: Hits = 152 Lines analyzed = 11601 in approximately 0.32 seconds (36567 lines/second) Physical Source Lines of Code (SLOC) = 8007 Hits@level = [0] 36 [1] 82 [2] 56 [3] 1 [4] 13 [5] 0 Hits@level+ = [0+] 188 [1+] 152 [2+] 70 [3+] 14 [4+] 13 [5+] 0 Hits/KSLOC@level+ = [0+] 23.4795 [1+] 18.9834 [2+] 8.74235 [3+] 1.74847 [4+] 1.62358 [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.