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/tasksh-1.2.0/cmake.h Examining data/tasksh-1.2.0/commit.h Examining data/tasksh-1.2.0/src/diag.cpp Examining data/tasksh-1.2.0/src/help.cpp Examining data/tasksh-1.2.0/src/libshared/src/Args.cpp Examining data/tasksh-1.2.0/src/libshared/src/Args.h Examining data/tasksh-1.2.0/src/libshared/src/Color.cpp Examining data/tasksh-1.2.0/src/libshared/src/Color.h Examining data/tasksh-1.2.0/src/libshared/src/Composite.cpp Examining data/tasksh-1.2.0/src/libshared/src/Composite.h Examining data/tasksh-1.2.0/src/libshared/src/Configuration.cpp Examining data/tasksh-1.2.0/src/libshared/src/Configuration.h Examining data/tasksh-1.2.0/src/libshared/src/Datetime.cpp Examining data/tasksh-1.2.0/src/libshared/src/Datetime.h Examining data/tasksh-1.2.0/src/libshared/src/Duration.cpp Examining data/tasksh-1.2.0/src/libshared/src/Duration.h Examining data/tasksh-1.2.0/src/libshared/src/format.cpp Examining data/tasksh-1.2.0/src/libshared/src/format.h Examining data/tasksh-1.2.0/src/libshared/src/FS.cpp Examining data/tasksh-1.2.0/src/libshared/src/ip.cpp Examining data/tasksh-1.2.0/src/libshared/src/JSON.cpp Examining data/tasksh-1.2.0/src/libshared/src/JSON.h Examining data/tasksh-1.2.0/src/libshared/src/lex.cpp Examining data/tasksh-1.2.0/src/libshared/src/Lexer.cpp Examining data/tasksh-1.2.0/src/libshared/src/Lexer.h Examining data/tasksh-1.2.0/src/libshared/src/Log.cpp Examining data/tasksh-1.2.0/src/libshared/src/Log.h Examining data/tasksh-1.2.0/src/libshared/src/Msg.cpp Examining data/tasksh-1.2.0/src/libshared/src/Msg.h Examining data/tasksh-1.2.0/src/libshared/src/Packrat.cpp Examining data/tasksh-1.2.0/src/libshared/src/Packrat.h Examining data/tasksh-1.2.0/src/libshared/src/Palette.cpp Examining data/tasksh-1.2.0/src/libshared/src/Palette.h Examining data/tasksh-1.2.0/src/libshared/src/PEG.cpp Examining data/tasksh-1.2.0/src/libshared/src/PEG.h Examining data/tasksh-1.2.0/src/libshared/src/Pig.cpp Examining data/tasksh-1.2.0/src/libshared/src/Pig.h Examining data/tasksh-1.2.0/src/libshared/src/RX.cpp Examining data/tasksh-1.2.0/src/libshared/src/RX.h Examining data/tasksh-1.2.0/src/libshared/src/SAX.cpp Examining data/tasksh-1.2.0/src/libshared/src/shared.cpp Examining data/tasksh-1.2.0/src/libshared/src/shared.h Examining data/tasksh-1.2.0/src/libshared/src/Table.cpp Examining data/tasksh-1.2.0/src/libshared/src/Table.h Examining data/tasksh-1.2.0/src/libshared/src/Timer.cpp Examining data/tasksh-1.2.0/src/libshared/src/Timer.h Examining data/tasksh-1.2.0/src/libshared/src/Tree.cpp Examining data/tasksh-1.2.0/src/libshared/src/Tree.h Examining data/tasksh-1.2.0/src/libshared/src/unicode.cpp Examining data/tasksh-1.2.0/src/libshared/src/unicode.h Examining data/tasksh-1.2.0/src/libshared/src/utf8.cpp Examining data/tasksh-1.2.0/src/libshared/src/utf8.h Examining data/tasksh-1.2.0/src/libshared/src/wcwidth6.cpp Examining data/tasksh-1.2.0/src/libshared/src/FS.h Examining data/tasksh-1.2.0/src/main.cpp Examining data/tasksh-1.2.0/src/prompt.cpp Examining data/tasksh-1.2.0/src/review.cpp Examining data/tasksh-1.2.0/src/shell.cpp FINAL RESULTS: data/tasksh-1.2.0/src/libshared/src/FS.cpp:680:9: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod (full_name.c_str (), mode)) data/tasksh-1.2.0/src/libshared/src/FS.cpp:156:10: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. return access (_data.c_str (), F_OK) ? false : true; data/tasksh-1.2.0/src/libshared/src/FS.cpp:198:17: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. auto status = access (_data.c_str (), R_OK); data/tasksh-1.2.0/src/libshared/src/FS.cpp:210:17: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. auto status = access (_data.c_str (), W_OK); data/tasksh-1.2.0/src/libshared/src/FS.cpp:222:17: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. auto status = access (_data.c_str (), X_OK); data/tasksh-1.2.0/src/libshared/src/FS.cpp:799:9: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (! access (from.c_str (), F_OK)) data/tasksh-1.2.0/src/libshared/src/shared.cpp:703:12: [4] (shell) execvp: 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. _exit (execvp (executable.c_str (), argv)); data/tasksh-1.2.0/src/main.cpp:131:7: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:75:3: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:78:3: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:94:3: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:103:3: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:111:3: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:119:3: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/review.cpp:231:7: [4] (shell) system: 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. system (command.c_str ()); data/tasksh-1.2.0/src/shell.cpp:42:3: [4] (shell) system: 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. system (combined.c_str ()); data/tasksh-1.2.0/src/diag.cpp:129: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. auto env = getenv ("TASKRC"); data/tasksh-1.2.0/src/diag.cpp:134:9: [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. env = getenv ("TASKDATA"); data/tasksh-1.2.0/src/diag.cpp:140:21: [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. std::string path (getenv ("PATH")); data/tasksh-1.2.0/src/libshared/src/FS.cpp:260:24: [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 *home = getenv("HOME"); data/tasksh-1.2.0/src/libshared/src/Datetime.cpp:3555: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 weekStr[3]; data/tasksh-1.2.0/src/libshared/src/FS.cpp:378: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). if (open ()) data/tasksh-1.2.0/src/libshared/src/FS.cpp:406:12: [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). bool File::open () data/tasksh-1.2.0/src/libshared/src/FS.cpp:417:13: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). _fh = fopen (_data.c_str (), (already_exists ? "r+" : "w+")); data/tasksh-1.2.0/src/libshared/src/FS.cpp:553:5: [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). open (); data/tasksh-1.2.0/src/libshared/src/FS.cpp:569:5: [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). open (); data/tasksh-1.2.0/src/libshared/src/FS.cpp:585:5: [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). open (); data/tasksh-1.2.0/src/libshared/src/FS.cpp:596:5: [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). open (); data/tasksh-1.2.0/src/libshared/src/FS.cpp:946: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 buf[PATH_MAX]; data/tasksh-1.2.0/src/libshared/src/FS.h:90: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). bool open (); data/tasksh-1.2.0/src/libshared/src/RX.cpp:89:7: [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 message[256]; data/tasksh-1.2.0/src/libshared/src/format.cpp:245: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 formatted[24]; data/tasksh-1.2.0/src/libshared/src/format.cpp:247:33: [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. if (bytes >= 995000000) sprintf (formatted, "%.1f GiB", bytes / 1000000000.0); data/tasksh-1.2.0/src/libshared/src/format.cpp:248:33: [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. else if (bytes >= 995000) sprintf (formatted, "%.1f MiB", bytes / 1000000.0); data/tasksh-1.2.0/src/libshared/src/format.cpp:249:33: [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. else if (bytes >= 995) sprintf (formatted, "%.1f KiB", bytes / 1000.0); data/tasksh-1.2.0/src/libshared/src/format.cpp:250:33: [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. else sprintf (formatted, "%d B", (int)bytes); data/tasksh-1.2.0/src/libshared/src/format.cpp:259: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 formatted[24]; data/tasksh-1.2.0/src/libshared/src/format.cpp:262:36: [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. if (seconds >= 86400 * 365) sprintf (formatted, "%.1f y", (days / 365.0)); data/tasksh-1.2.0/src/libshared/src/format.cpp:263:36: [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. else if (seconds >= 86400 * 84) sprintf (formatted, "%1d mo", (int) (days / 30)); data/tasksh-1.2.0/src/libshared/src/format.cpp:264:36: [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. else if (seconds >= 86400 * 13) sprintf (formatted, "%d wk", (int) (float) (days / 7.0)); data/tasksh-1.2.0/src/libshared/src/format.cpp:265:36: [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. else if (seconds >= 86400) sprintf (formatted, "%d d", (int) days); data/tasksh-1.2.0/src/libshared/src/format.cpp:266:36: [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. else if (seconds >= 3600) sprintf (formatted, "%d h", (int) (seconds / 3600)); data/tasksh-1.2.0/src/libshared/src/format.cpp:267:36: [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. else if (seconds >= 60) sprintf (formatted, "%d m", (int) (seconds / 60)); data/tasksh-1.2.0/src/libshared/src/format.cpp:268:36: [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. else if (seconds >= 1) sprintf (formatted, "%d s", (int) seconds); data/tasksh-1.2.0/src/libshared/src/format.cpp:302: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 stringized[2] = {0}; data/tasksh-1.2.0/src/libshared/src/shared.cpp:664: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 buf[16384]; data/tasksh-1.2.0/src/libshared/src/utf8.cpp:114: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 sequence[5] {}; data/tasksh-1.2.0/src/libshared/src/Args.cpp:64:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (argv[i][0] == '-' && strlen (argv[i]) > 1) data/tasksh-1.2.0/src/libshared/src/Configuration.cpp:44:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). File::read (file, contents); data/tasksh-1.2.0/src/libshared/src/Configuration.cpp:89:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). File::read (file, contents); data/tasksh-1.2.0/src/libshared/src/Configuration.cpp:144:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (File::read (file, contents) && contents.length ()) data/tasksh-1.2.0/src/libshared/src/Configuration.cpp:181:11: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal != std::string::npos) data/tasksh-1.2.0/src/libshared/src/Configuration.cpp:183:51: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. std::string key = trim (line.substr (0, equal)); data/tasksh-1.2.0/src/libshared/src/Configuration.cpp:184:74: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. std::string value = trim (line.substr (equal+1, line.length () - equal)); data/tasksh-1.2.0/src/libshared/src/FS.cpp:493:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). void File::read (std::string& contents) data/tasksh-1.2.0/src/libshared/src/FS.cpp:522:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). void File::read (std::vector <std::string>& contents) data/tasksh-1.2.0/src/libshared/src/FS.cpp:690:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bool File::read (const std::string& name, std::string& contents) data/tasksh-1.2.0/src/libshared/src/FS.cpp:720:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bool File::read (const std::string& name, std::vector <std::string>& contents) data/tasksh-1.2.0/src/libshared/src/FS.h:96:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). void read (std::string&); data/tasksh-1.2.0/src/libshared/src/FS.h:97:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). void read (std::vector <std::string>&); data/tasksh-1.2.0/src/libshared/src/FS.h:112:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). static bool read (const std::string&, std::string&); data/tasksh-1.2.0/src/libshared/src/FS.h:113:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). static bool read (const std::string&, std::vector <std::string>&); data/tasksh-1.2.0/src/libshared/src/PEG.cpp:58:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). file.read (contents); data/tasksh-1.2.0/src/libshared/src/PEG.cpp:325:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). file.read (imported); data/tasksh-1.2.0/src/libshared/src/format.cpp:269:36: [1] (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 character. else strcpy (formatted, "-"); data/tasksh-1.2.0/src/libshared/src/shared.cpp:770:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read_retval = read (pout[0], &buf, sizeof (buf) - 1); ANALYSIS SUMMARY: Hits = 66 Lines analyzed = 16880 in approximately 0.36 seconds (46928 lines/second) Physical Source Lines of Code (SLOC) = 11330 Hits@level = [0] 0 [1] 19 [2] 27 [3] 4 [4] 15 [5] 1 Hits@level+ = [0+] 66 [1+] 66 [2+] 47 [3+] 20 [4+] 16 [5+] 1 Hits/KSLOC@level+ = [0+] 5.82524 [1+] 5.82524 [2+] 4.14828 [3+] 1.76523 [4+] 1.41218 [5+] 0.0882613 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.