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/astyle-3.1/src/ASBeautifier.cpp Examining data/astyle-3.1/src/ASEnhancer.cpp Examining data/astyle-3.1/src/ASFormatter.cpp Examining data/astyle-3.1/src/ASLocalizer.cpp Examining data/astyle-3.1/src/ASLocalizer.h Examining data/astyle-3.1/src/ASResource.cpp Examining data/astyle-3.1/src/astyle.h Examining data/astyle-3.1/src/astyle_main.cpp Examining data/astyle-3.1/src/astyle_main.h FINAL RESULTS: data/astyle-3.1/src/astyle_main.cpp:1522: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(paths, envPaths); data/astyle-3.1/src/astyle_main.cpp:1551:3: [4] (shell) execlp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execlp(fileOpen, fileOpen, htmlFilePath.c_str(), nullptr); data/astyle-3.1/src/astyle_main.cpp:2598: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(sess, path.c_str()); data/astyle-3.1/src/astyle_main.cpp:2647:2: [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. printf(msg, data.c_str()); data/astyle-3.1/src/astyle_main.cpp:4266: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(pTextOut, out.str().c_str()); data/astyle-3.1/src/astyle_main.cpp:1198:14: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("USERPROFILE"); data/astyle-3.1/src/astyle_main.cpp:1222:25: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* envPath = getenv(envPaths[i]); data/astyle-3.1/src/astyle_main.cpp:1281:18: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* currdir = getenv("PWD"); data/astyle-3.1/src/astyle_main.cpp:1386:2: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. realpath(relativePath.c_str(), fullPath); data/astyle-3.1/src/astyle_main.cpp:1473:14: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("HOME"); data/astyle-3.1/src/astyle_main.cpp:1517:25: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* envPaths = getenv("PATH"); data/astyle-3.1/src/astyle_main.cpp:2414:16: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("ARTISTIC_STYLE_OPTIONS"); data/astyle-3.1/src/astyle_main.cpp:2425:16: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("HOME"); data/astyle-3.1/src/astyle_main.cpp:2436:16: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("APPDATA"); data/astyle-3.1/src/astyle_main.cpp:2449:16: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("USERPROFILE"); data/astyle-3.1/src/astyle_main.cpp:2470:15: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("ARTISTIC_STYLE_PROJECT_OPTIONS"); data/astyle-3.1/src/astyle_main.cpp:2683:15: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env = getenv("USERPROFILE"); data/astyle-3.1/src/ASLocalizer.cpp:123: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 canonicalLang[3]; data/astyle-3.1/src/astyle_main.cpp:1043: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 currdir[MAX_PATH]; data/astyle-3.1/src/astyle_main.cpp:1135: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 fullPath[MAX_PATH]; data/astyle-3.1/src/astyle_main.cpp:1385: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 fullPath[PATH_MAX]; data/astyle-3.1/src/astyle_main.cpp:2489: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 buf[4]; data/astyle-3.1/src/astyle_main.cpp:2516: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 buf[4]; data/astyle-3.1/src/astyle_main.cpp:2587: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 less[NAML$C_MAXRSS]; data/astyle-3.1/src/astyle_main.cpp:2588: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 sess[NAM$C_MAXRSS]; data/astyle-3.1/src/astyle_main.cpp:2665: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 str[20]; data/astyle-3.1/src/astyle_main.cpp:3163: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). spaceNum = atoi(spaceNumParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3180: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). spaceNum = atoi(spaceNumParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3197:13: [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). tabNum = atoi(tabNumParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3214: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). spaceNum = atoi(spaceNumParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3231:17: [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). contIndent = atoi(contIndentParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3244:16: [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). minIndent = atoi(minIndentParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3255:16: [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). maxIndent = atoi(maxIndentParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3414:12: [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). align = atoi(styleParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3445:12: [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). align = atoi(styleParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3462:16: [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). maxLength = atoi(maxLengthParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3475:16: [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). maxLength = atoi(maxLengthParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3602:16: [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). maxIndent = atoi(maxIndentParam.c_str()); data/astyle-3.1/src/astyle_main.cpp:3688: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). lineendType = atoi(lineendParam.c_str()); data/astyle-3.1/src/astyle.h:1061: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). { return currentLine.compare(charNum, strlen(sequence), sequence) == 0; } data/astyle-3.1/src/astyle_main.cpp:844: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). return arg.substr(strlen(op)); data/astyle-3.1/src/astyle_main.cpp:910:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fin.read(data, blockSize); data/astyle-3.1/src/astyle_main.cpp:935:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fin.read(data, blockSize); data/astyle-3.1/src/astyle_main.cpp:1205:25: [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 (absPath.compare(0, strlen(env), env) != 0) data/astyle-3.1/src/astyle_main.cpp:1480:25: [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 (absPath.compare(0, strlen(env), env) != 0) data/astyle-3.1/src/astyle_main.cpp:1520: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 envlen = strlen(envPaths); data/astyle-3.1/src/astyle_main.cpp:1730: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). bool retVal = arg.compare(0, strlen(option), option) == 0; data/astyle-3.1/src/astyle_main.cpp:1732: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 (retVal && strlen(option) == 1 && arg.length() > 1) data/astyle-3.1/src/astyle_main.cpp:2672:44: [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 numSpaces = 60 - header.length() - strlen(str); data/astyle-3.1/src/astyle_main.cpp:2967: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). size_t dataSize = strlen(utf8In); data/astyle-3.1/src/astyle_main.cpp:3007: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). assert(utf8Size == strlen(utf8Out) + 1); data/astyle-3.1/src/astyle_main.cpp:3759: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). return arg.substr(strlen(op)); data/astyle-3.1/src/astyle_main.cpp:3786: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). bool retVal = arg.compare(0, strlen(option), option) == 0; data/astyle-3.1/src/astyle_main.cpp:3788: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 (retVal && strlen(option) == 1 && arg.length() > 1) ANALYSIS SUMMARY: Hits = 54 Lines analyzed = 20802 in approximately 0.45 seconds (46685 lines/second) Physical Source Lines of Code (SLOC) = 16120 Hits@level = [0] 29 [1] 15 [2] 22 [3] 12 [4] 5 [5] 0 Hits@level+ = [0+] 83 [1+] 54 [2+] 39 [3+] 17 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 5.14888 [1+] 3.34988 [2+] 2.41935 [3+] 1.05459 [4+] 0.310174 [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.