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/qtchooser-66/src/qtchooser/main.cpp Examining data/qtchooser-66/tests/auto/qtchooser/tst_qtchooser.cpp FINAL RESULTS: data/qtchooser-66/src/qtchooser/main.cpp:225:17: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. int count = readlink(link, buf, sizeof(buf) - 1); data/qtchooser-66/src/qtchooser/main.cpp:67:11: [4] (shell) execv: 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. # define execv _execv data/qtchooser-66/src/qtchooser/main.cpp:303:5: [4] (shell) execv: 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. execv(argv[0], argv); data/qtchooser-66/src/qtchooser/main.cpp:310:9: [4] (shell) execv: 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. execv(appPath, argv); data/qtchooser-66/src/qtchooser/main.cpp:345:11: [4] (shell) popen: 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. bin = popen(("'" + qmake + "' -query QT_INSTALL_BINS").c_str(), "r"); data/qtchooser-66/src/qtchooser/main.cpp:346:11: [4] (shell) popen: 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. lib = popen(("'" + qmake + "' -query QT_INSTALL_LIBS").c_str(), "r"); data/qtchooser-66/src/qtchooser/main.cpp:191: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 *value = getenv("HOME"); data/qtchooser-66/src/qtchooser/main.cpp:445: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 *value = getenv(env); data/qtchooser-66/src/qtchooser/main.cpp:600:29: [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 *targetSdk = getenv("QT_SELECT"); data/qtchooser-66/src/qtchooser/main.cpp:607:22: [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. targetTool = getenv("QTCHOOSER_RUNTOOL"); data/qtchooser-66/src/qtchooser/main.cpp:224:5: [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[512]; data/qtchooser-66/src/qtchooser/main.cpp:253:5: [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[PATH_MAX]; data/qtchooser-66/src/qtchooser/main.cpp:307: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. char appPath[PATH_MAX]; data/qtchooser-66/src/qtchooser/main.cpp:322: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. static char buffer[sizeof "2147483647"]; data/qtchooser-66/src/qtchooser/main.cpp:381:20: [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(tempname.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0666); data/qtchooser-66/src/qtchooser/main.cpp:572: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 *f = fopen(sdk.configFile.c_str(), "r"); data/qtchooser-66/tests/auto/qtchooser/tst_qtchooser.cpp:214:21: [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). QVERIFY(tmp.open(QIODevice::ReadWrite)); data/qtchooser-66/tests/auto/qtchooser/tst_qtchooser.cpp:215:24: [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). QVERIFY(source.open(QIODevice::ReadOnly)); data/qtchooser-66/tests/auto/qtchooser/tst_qtchooser.cpp:446:20: [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). QVERIFY(!f.open(QIODevice::ReadWrite)); data/qtchooser-66/tests/auto/qtchooser/tst_qtchooser.cpp:476:20: [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). QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString())); data/qtchooser-66/tests/auto/qtchooser/tst_qtchooser.cpp:490:20: [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). QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString())); data/qtchooser-66/src/qtchooser/main.cpp:209:38: [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 strncmp(haystack, needle, strlen(needle)) == 0; data/qtchooser-66/src/qtchooser/main.cpp:214: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). size_t haystackLen = strlen(haystack); data/qtchooser-66/src/qtchooser/main.cpp:215:24: [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 needleLen = strlen(needle); data/qtchooser-66/src/qtchooser/main.cpp:244:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read < 0) { data/qtchooser-66/src/qtchooser/main.cpp:249:10: [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). line[strlen(line) - 1] = '\0'; data/qtchooser-66/src/qtchooser/main.cpp:258:9: [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). buf[strlen(buf) - 1] = '\0'; data/qtchooser-66/src/qtchooser/main.cpp:493: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). size_t fnamelen = strlen(d->d_name); data/qtchooser-66/src/qtchooser/main.cpp:630: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). targetTool = arg + strlen("run-tool="); data/qtchooser-66/src/qtchooser/main.cpp:693: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). sdkName = strlen(arg) ? arg : "default"; ANALYSIS SUMMARY: Hits = 30 Lines analyzed = 1218 in approximately 0.05 seconds (22614 lines/second) Physical Source Lines of Code (SLOC) = 900 Hits@level = [0] 20 [1] 9 [2] 11 [3] 4 [4] 5 [5] 1 Hits@level+ = [0+] 50 [1+] 30 [2+] 21 [3+] 10 [4+] 6 [5+] 1 Hits/KSLOC@level+ = [0+] 55.5556 [1+] 33.3333 [2+] 23.3333 [3+] 11.1111 [4+] 6.66667 [5+] 1.11111 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.