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/libdkim-1.0.21/src/resource.h Examining data/libdkim-1.0.21/src/dns.h Examining data/libdkim-1.0.21/src/dns.cpp Examining data/libdkim-1.0.21/src/dnsresolv.cpp Examining data/libdkim-1.0.21/src/dnsresolv.h Examining data/libdkim-1.0.21/src/dkim.cpp Examining data/libdkim-1.0.21/src/dkim.h Examining data/libdkim-1.0.21/src/dkimbase.cpp Examining data/libdkim-1.0.21/src/dkimbase.h Examining data/libdkim-1.0.21/src/libdkimtest.cpp Examining data/libdkim-1.0.21/src/dkimsign.cpp Examining data/libdkim-1.0.21/src/dkimsign.h Examining data/libdkim-1.0.21/src/dkimverify.cpp Examining data/libdkim-1.0.21/src/dkimverify.h FINAL RESULTS: data/libdkim-1.0.21/src/dkim.cpp:209:3: [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(szPractices, pVerify->GetPractices()); data/libdkim-1.0.21/src/dkimsign.cpp:713:3: [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( szSignature, m_sReturnedSig.c_str() ); data/libdkim-1.0.21/src/dnsresolv.cpp:332: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, ip->IpAddress.String); data/libdkim-1.0.21/src/libdkimtest.cpp:84: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( opts.szSelector, MYSELECTOR ); data/libdkim-1.0.21/src/libdkimtest.cpp:85: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( opts.szDomain, MYDOMAIN ); data/libdkim-1.0.21/src/libdkimtest.cpp:86: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( opts.szIdentity, MYIDENTITY ); data/libdkim-1.0.21/src/libdkimtest.cpp:141:6: [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( opts.szIdentity, argv[n] + 2 ); data/libdkim-1.0.21/src/libdkimtest.cpp:247:3: [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( szSignature, pSig ); data/libdkim-1.0.21/src/dns.cpp:76:16: [3] (misc) LoadLibrary: Ensure that the full path to the library is specified, or current directory may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to find library path, if you aren't already. s_hDNSAPI = LoadLibrary( "dnsapi.dll" ); data/libdkim-1.0.21/src/dnsresolv.cpp:311:18: [3] (misc) LoadLibrary: Ensure that the full path to the library is specified, or current directory may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to find library path, if you aren't already. hIpHelperDll = LoadLibrary("iphlpapi.dll"); data/libdkim-1.0.21/src/dkim.h:113: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 szSelector[80]; // selector - required data/libdkim-1.0.21/src/dkim.h:114: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 szDomain[256]; // domain - optional - if empty, domain is computed from sender data/libdkim-1.0.21/src/dkim.h:115: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 szIdentity[256]; // for i= tag, if empty tag will not be included in sig data/libdkim-1.0.21/src/dkim.h:118: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 szRequiredHeaders[256]; // colon-separated list of headers that must be signed data/libdkim-1.0.21/src/dkimbase.cpp:90:5: [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( newp, szBuffer, nBufferSize ); data/libdkim-1.0.21/src/dkimsign.cpp:217:18: [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 unsigned char hexchars[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; data/libdkim-1.0.21/src/dkimsign.cpp:593: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 szValue[64]; data/libdkim-1.0.21/src/dkimsign.cpp:594:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf( szValue, "%lu", nValue ); data/libdkim-1.0.21/src/dkimsign.cpp:869:12: [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 Hash[EVP_MAX_MD_SIZE]; data/libdkim-1.0.21/src/dkimverify.cpp:228:22: [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 const signed char base64_table[256] = { data/libdkim-1.0.21/src/dkimverify.cpp:474:14: [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 md[EVP_MAX_MD_SIZE]; data/libdkim-1.0.21/src/dkimverify.cpp:510:4: [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 *values[sizeof(tags)/sizeof(tags[0])] = {NULL}; data/libdkim-1.0.21/src/dkimverify.cpp:910: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 *values[sizeof(tags)/sizeof(tags[0])] = {NULL}; data/libdkim-1.0.21/src/dkimverify.cpp:1247: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 *values[sizeof(tags)/sizeof(tags[0])] = {NULL}; data/libdkim-1.0.21/src/dkimverify.cpp:1354:50: [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 unsigned char *PublicKeyData = (unsigned char *)values[4]; data/libdkim-1.0.21/src/dkimverify.cpp:1399: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 Buffer[1024]; data/libdkim-1.0.21/src/dkimverify.cpp:1443: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 Buffer[1024]; data/libdkim-1.0.21/src/dkimverify.cpp:1471:4: [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 *values[sizeof(tags)/sizeof(tags[0])] = {NULL}; data/libdkim-1.0.21/src/dns.cpp:150:6: [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( BufPtr, prr->Data.Txt.pStringArray[i], Len ); data/libdkim-1.0.21/src/dns.cpp:271: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( bufptr, cp, cnt); data/libdkim-1.0.21/src/dnsresolv.cpp:44: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 Data[DNSMSG_MAX_DATA_SIZE]; data/libdkim-1.0.21/src/dnsresolv.cpp:158: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 szLabel[DNSMSG_MAX_LABEL]; data/libdkim-1.0.21/src/dnsresolv.cpp:236: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( p, szLabel, nLabelLen); data/libdkim-1.0.21/src/dnsresolv.cpp:276: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( p, szLabel, nLabelLen); data/libdkim-1.0.21/src/dnsresolv.cpp:300: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[256]; data/libdkim-1.0.21/src/dnsresolv.cpp:301: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 buffer[256]; data/libdkim-1.0.21/src/dnsresolv.cpp:321: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 fibuffer[2048]; data/libdkim-1.0.21/src/dnsresolv.cpp:363:13: [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 binbuffer[1024]; data/libdkim-1.0.21/src/dnsresolv.cpp:377:8: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buffer+strlen(buffer), "%d.%d.%d.%d ", ptr[0], ptr[1], ptr[2], ptr[3]); data/libdkim-1.0.21/src/dnsresolv.cpp:584:14: [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 nPktLen[2]; data/libdkim-1.0.21/src/libdkimtest.cpp:67: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 PrivKey[2048]; data/libdkim-1.0.21/src/libdkimtest.cpp:68: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 Buffer[1024]; data/libdkim-1.0.21/src/libdkimtest.cpp:70: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 szSignature[10024]; data/libdkim-1.0.21/src/libdkimtest.cpp:88:2: [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( opts.szRequiredHeaders, "NonExistant" ); data/libdkim-1.0.21/src/libdkimtest.cpp:102:29: [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). opts.nIncludeBodyHash = atoi( &argv[n][2] ); data/libdkim-1.0.21/src/libdkimtest.cpp:168:28: [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). opts.expireTime = t + atoi( argv[n] + 2 ); data/libdkim-1.0.21/src/libdkimtest.cpp:174: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). opts.nHash = atoi( &argv[n][2] ); data/libdkim-1.0.21/src/libdkimtest.cpp:199:21: [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* PrivKeyFP = fopen( PrivKeyFile, "r" ); data/libdkim-1.0.21/src/libdkimtest.cpp:215:17: [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* MsgFP = fopen( MsgFile, "rb" ); data/libdkim-1.0.21/src/libdkimtest.cpp:251:14: [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* in = fopen( MsgFile, "rb" ); data/libdkim-1.0.21/src/libdkimtest.cpp:252: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). FILE* out = fopen( OutFile, "wb+" ); data/libdkim-1.0.21/src/libdkimtest.cpp:275:14: [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* in = fopen( MsgFile, "rb" ); data/libdkim-1.0.21/src/libdkimtest.cpp:300: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 szPolicy[512]; data/libdkim-1.0.21/src/dkimbase.cpp:254: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). *remove_if( szBuffer, szBuffer+strlen(szBuffer), isswsp() ) = '\0'; data/libdkim-1.0.21/src/dkimsign.cpp:565: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). int nTagLen = strlen(Tag); data/libdkim-1.0.21/src/dkimverify.cpp:281: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). unsigned afterwildcardlen = strlen(wildcard+1); data/libdkim-1.0.21/src/dkimverify.cpp:282: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). unsigned slen = strlen(s); data/libdkim-1.0.21/src/dkimverify.cpp:515:47: [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). sSignedSig.erase( 15+values[0]-pSigValue, strlen(values[0]) ); data/libdkim-1.0.21/src/dkimverify.cpp:654:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( szDbg, szBuffer, nBufLength ); data/libdkim-1.0.21/src/dkimverify.cpp:1050: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). int idomainlen = strlen(idomain); data/libdkim-1.0.21/src/dkimverify.cpp:1051: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). int ddomainlen = strlen(values[3]); data/libdkim-1.0.21/src/dns.cpp:143: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). int Len = strlen( prr->Data.Txt.pStringArray[i] ); data/libdkim-1.0.21/src/dns.cpp:294: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(szFQDN) > MAX_DOMAIN) data/libdkim-1.0.21/src/dnsresolv.cpp:333:6: [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/libdkim-1.0.21/src/dnsresolv.cpp:377: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). sprintf(buffer+strlen(buffer), "%d.%d.%d.%d ", ptr[0], ptr[1], ptr[2], ptr[3]); data/libdkim-1.0.21/src/dnsresolv.cpp:415:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(IP, start, IPSize-1); data/libdkim-1.0.21/src/libdkimtest.cpp:97: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). if( argv[n][0] == '-' && strlen(argv[n]) > 1 ) data/libdkim-1.0.21/src/libdkimtest.cpp:254: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). fwrite( szSignature, 1, strlen(szSignature), out ); ANALYSIS SUMMARY: Hits = 68 Lines analyzed = 5232 in approximately 0.12 seconds (44752 lines/second) Physical Source Lines of Code (SLOC) = 3615 Hits@level = [0] 16 [1] 15 [2] 43 [3] 2 [4] 8 [5] 0 Hits@level+ = [0+] 84 [1+] 68 [2+] 53 [3+] 10 [4+] 8 [5+] 0 Hits/KSLOC@level+ = [0+] 23.2365 [1+] 18.8105 [2+] 14.6611 [3+] 2.76625 [4+] 2.213 [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.