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/herbstluftwm-0.9.0/ipc-client/client-utils.c Examining data/herbstluftwm-0.9.0/ipc-client/client-utils.h Examining data/herbstluftwm-0.9.0/ipc-client/ipc-client.c Examining data/herbstluftwm-0.9.0/ipc-client/ipc-client.h Examining data/herbstluftwm-0.9.0/ipc-client/main.c Examining data/herbstluftwm-0.9.0/src/arglist.cpp Examining data/herbstluftwm-0.9.0/src/arglist.h Examining data/herbstluftwm-0.9.0/src/argparse.cpp Examining data/herbstluftwm-0.9.0/src/argparse.h Examining data/herbstluftwm-0.9.0/src/attribute.cpp Examining data/herbstluftwm-0.9.0/src/attribute.h Examining data/herbstluftwm-0.9.0/src/attribute_.h Examining data/herbstluftwm-0.9.0/src/byname.cpp Examining data/herbstluftwm-0.9.0/src/byname.h Examining data/herbstluftwm-0.9.0/src/child.h Examining data/herbstluftwm-0.9.0/src/client.cpp Examining data/herbstluftwm-0.9.0/src/client.h Examining data/herbstluftwm-0.9.0/src/clientmanager.cpp Examining data/herbstluftwm-0.9.0/src/clientmanager.h Examining data/herbstluftwm-0.9.0/src/command.cpp Examining data/herbstluftwm-0.9.0/src/command.h Examining data/herbstluftwm-0.9.0/src/completion.cpp Examining data/herbstluftwm-0.9.0/src/completion.h Examining data/herbstluftwm-0.9.0/src/decoration.cpp Examining data/herbstluftwm-0.9.0/src/decoration.h Examining data/herbstluftwm-0.9.0/src/desktopwindow.cpp Examining data/herbstluftwm-0.9.0/src/desktopwindow.h Examining data/herbstluftwm-0.9.0/src/entity.cpp Examining data/herbstluftwm-0.9.0/src/entity.h Examining data/herbstluftwm-0.9.0/src/ewmh.cpp Examining data/herbstluftwm-0.9.0/src/ewmh.h Examining data/herbstluftwm-0.9.0/src/finite.h Examining data/herbstluftwm-0.9.0/src/fixprecdec.cpp Examining data/herbstluftwm-0.9.0/src/fixprecdec.h Examining data/herbstluftwm-0.9.0/src/floating.cpp Examining data/herbstluftwm-0.9.0/src/floating.h Examining data/herbstluftwm-0.9.0/src/framedata.cpp Examining data/herbstluftwm-0.9.0/src/framedata.h Examining data/herbstluftwm-0.9.0/src/framedecoration.cpp Examining data/herbstluftwm-0.9.0/src/framedecoration.h Examining data/herbstluftwm-0.9.0/src/frameparser.cpp Examining data/herbstluftwm-0.9.0/src/frameparser.h Examining data/herbstluftwm-0.9.0/src/frametree.cpp Examining data/herbstluftwm-0.9.0/src/frametree.h Examining data/herbstluftwm-0.9.0/src/globals.h Examining data/herbstluftwm-0.9.0/src/hlwmcommon.cpp Examining data/herbstluftwm-0.9.0/src/hlwmcommon.h Examining data/herbstluftwm-0.9.0/src/hook.cpp Examining data/herbstluftwm-0.9.0/src/hook.h Examining data/herbstluftwm-0.9.0/src/hookmanager.cpp Examining data/herbstluftwm-0.9.0/src/hookmanager.h Examining data/herbstluftwm-0.9.0/src/indexingobject.h Examining data/herbstluftwm-0.9.0/src/ipc-protocol.h Examining data/herbstluftwm-0.9.0/src/ipc-server.cpp Examining data/herbstluftwm-0.9.0/src/ipc-server.h Examining data/herbstluftwm-0.9.0/src/keycombo.cpp Examining data/herbstluftwm-0.9.0/src/keycombo.h Examining data/herbstluftwm-0.9.0/src/keymanager.cpp Examining data/herbstluftwm-0.9.0/src/keymanager.h Examining data/herbstluftwm-0.9.0/src/layout.cpp Examining data/herbstluftwm-0.9.0/src/layout.h Examining data/herbstluftwm-0.9.0/src/link.h Examining data/herbstluftwm-0.9.0/src/main.cpp Examining data/herbstluftwm-0.9.0/src/monitor.cpp Examining data/herbstluftwm-0.9.0/src/monitor.h Examining data/herbstluftwm-0.9.0/src/monitordetection.cpp Examining data/herbstluftwm-0.9.0/src/monitordetection.h Examining data/herbstluftwm-0.9.0/src/monitormanager.cpp Examining data/herbstluftwm-0.9.0/src/monitormanager.h Examining data/herbstluftwm-0.9.0/src/mouse.cpp Examining data/herbstluftwm-0.9.0/src/mouse.h Examining data/herbstluftwm-0.9.0/src/mousedraghandler.cpp Examining data/herbstluftwm-0.9.0/src/mousedraghandler.h Examining data/herbstluftwm-0.9.0/src/mousemanager.cpp Examining data/herbstluftwm-0.9.0/src/mousemanager.h Examining data/herbstluftwm-0.9.0/src/namedhook.cpp Examining data/herbstluftwm-0.9.0/src/namedhook.h Examining data/herbstluftwm-0.9.0/src/object.cpp Examining data/herbstluftwm-0.9.0/src/object.h Examining data/herbstluftwm-0.9.0/src/optional.h Examining data/herbstluftwm-0.9.0/src/panelmanager.cpp Examining data/herbstluftwm-0.9.0/src/panelmanager.h Examining data/herbstluftwm-0.9.0/src/plainstack.h Examining data/herbstluftwm-0.9.0/src/rectangle.cpp Examining data/herbstluftwm-0.9.0/src/rectangle.h Examining data/herbstluftwm-0.9.0/src/regexstr.cpp Examining data/herbstluftwm-0.9.0/src/regexstr.h Examining data/herbstluftwm-0.9.0/src/root.cpp Examining data/herbstluftwm-0.9.0/src/root.h Examining data/herbstluftwm-0.9.0/src/rootcommands.cpp Examining data/herbstluftwm-0.9.0/src/rootcommands.h Examining data/herbstluftwm-0.9.0/src/rulemanager.cpp Examining data/herbstluftwm-0.9.0/src/rulemanager.h Examining data/herbstluftwm-0.9.0/src/rules.cpp Examining data/herbstluftwm-0.9.0/src/rules.h Examining data/herbstluftwm-0.9.0/src/settings.cpp Examining data/herbstluftwm-0.9.0/src/settings.h Examining data/herbstluftwm-0.9.0/src/signal.h Examining data/herbstluftwm-0.9.0/src/stack.cpp Examining data/herbstluftwm-0.9.0/src/stack.h Examining data/herbstluftwm-0.9.0/src/tag.cpp Examining data/herbstluftwm-0.9.0/src/tag.h Examining data/herbstluftwm-0.9.0/src/tagmanager.cpp Examining data/herbstluftwm-0.9.0/src/tagmanager.h Examining data/herbstluftwm-0.9.0/src/theme.cpp Examining data/herbstluftwm-0.9.0/src/theme.h Examining data/herbstluftwm-0.9.0/src/tilingresult.cpp Examining data/herbstluftwm-0.9.0/src/tilingresult.h Examining data/herbstluftwm-0.9.0/src/tmp.cpp Examining data/herbstluftwm-0.9.0/src/tmp.h Examining data/herbstluftwm-0.9.0/src/types.cpp Examining data/herbstluftwm-0.9.0/src/types.h Examining data/herbstluftwm-0.9.0/src/utils.cpp Examining data/herbstluftwm-0.9.0/src/utils.h Examining data/herbstluftwm-0.9.0/src/x11-types.cpp Examining data/herbstluftwm-0.9.0/src/x11-types.h Examining data/herbstluftwm-0.9.0/src/x11-utils.cpp Examining data/herbstluftwm-0.9.0/src/x11-utils.h Examining data/herbstluftwm-0.9.0/src/xconnection.cpp Examining data/herbstluftwm-0.9.0/src/xconnection.h Examining data/herbstluftwm-0.9.0/src/xkeygrabber.cpp Examining data/herbstluftwm-0.9.0/src/xkeygrabber.h Examining data/herbstluftwm-0.9.0/src/xmainloop.cpp Examining data/herbstluftwm-0.9.0/src/xmainloop.h Examining data/herbstluftwm-0.9.0/utilities/XFetchName.c FINAL RESULTS: data/herbstluftwm-0.9.0/src/globals.h:34:13: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, __VA_ARGS__); \ data/herbstluftwm-0.9.0/src/globals.h:41:9: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, __VA_ARGS__); \ data/herbstluftwm-0.9.0/src/globals.h:47:9: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, __VA_ARGS__); \ data/herbstluftwm-0.9.0/src/ipc-server.cpp:90:5: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf(atom_name, 1000, HERBST_HOOK_PROPERTY_FORMAT, nextHookNumber_); data/herbstluftwm-0.9.0/src/main.cpp:223:41: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). {"mktemp", { tmp, &Tmp::mktemp, data/herbstluftwm-0.9.0/src/main.cpp:295:5: [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. execvp(command[0], command); data/herbstluftwm-0.9.0/src/main.cpp:407:9: [4] (shell) execl: 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. execl(path.c_str(), path.c_str(), nullptr); data/herbstluftwm-0.9.0/src/main.cpp:411:9: [4] (shell) execl: 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. execl(global_autostart, global_autostart, nullptr); data/herbstluftwm-0.9.0/src/tmp.cpp:12:10: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). int Tmp::mktemp(Input input, Output output) { data/herbstluftwm-0.9.0/src/tmp.h:11:9: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). int mktemp(Input input, Output output); data/herbstluftwm-0.9.0/utilities/XFetchName.c:8:23: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DIE(...) do { fprintf(stderr, __VA_ARGS__); exit(1); } while(0) data/herbstluftwm-0.9.0/ipc-client/main.c:192:17: [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. int c = getopt_long(argc, argv, "+n0lwc:iqhv", long_options, &option_index); data/herbstluftwm-0.9.0/src/main.cpp:388:33: [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* xdg_config_home = getenv("XDG_CONFIG_HOME"); data/herbstluftwm-0.9.0/src/main.cpp:392:26: [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* home = getenv("HOME"); data/herbstluftwm-0.9.0/src/main.cpp:435:17: [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. int c = getopt_long(argc, argv, "+c:vlh", long_options, &option_index); data/herbstluftwm-0.9.0/src/rootcommands.cpp:767:20: [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* envvar = getenv(name.c_str()); data/herbstluftwm-0.9.0/ipc-client/main.c:46: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. char buf[1000]; data/herbstluftwm-0.9.0/ipc-client/main.c:202:32: [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). g_hook_count = atoi(optarg); data/herbstluftwm-0.9.0/src/command.cpp:405: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 buf[100]; data/herbstluftwm-0.9.0/src/command.cpp:454:26: [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). int position = CLAMP(atoi(argv[1]), 0, argc-2); data/herbstluftwm-0.9.0/src/frametree.cpp:145: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). delta = atoi(deltaStr.c_str()); data/herbstluftwm-0.9.0/src/frametree.cpp:162: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). focusedFrame()->setSelection(atoi(index.c_str())); data/herbstluftwm-0.9.0/src/hook.cpp:20: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 monitor_name[STRING_BUF_SIZE]; data/herbstluftwm-0.9.0/src/ipc-server.cpp:89: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 atom_name[1000]; data/herbstluftwm-0.9.0/src/monitor.cpp:408:27: [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). monitor->pad_up = atoi(argv[2]); data/herbstluftwm-0.9.0/src/monitor.cpp:411:30: [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). monitor->pad_right = atoi(argv[3]); data/herbstluftwm-0.9.0/src/monitor.cpp:414: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). monitor->pad_down = atoi(argv[4]); data/herbstluftwm-0.9.0/src/monitor.cpp:417: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). monitor->pad_left = atoi(argv[5]); data/herbstluftwm-0.9.0/src/monitor.cpp:592: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). delta = atoi(argv[1]); data/herbstluftwm-0.9.0/src/monitormanager.cpp:102:37: [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). int idx = cur_monitor + atoi(str.c_str()); data/herbstluftwm-0.9.0/src/monitormanager.cpp:116:19: [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). int idx = atoi(str.c_str()); data/herbstluftwm-0.9.0/src/rules.cpp:218: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 buf[1000]; // 1kb ought to be enough for every int data/herbstluftwm-0.9.0/src/rules.cpp:219:9: [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(buf, "%d", client->pid_()); data/herbstluftwm-0.9.0/src/rules.cpp:231: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 buf[1000]; // 1kb ought to be enough for every int data/herbstluftwm-0.9.0/src/rules.cpp:232:9: [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(buf, "%d", client->pgid_()); data/herbstluftwm-0.9.0/src/xconnection.cpp:80: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 errorCodeString[100] = "unknown"; data/herbstluftwm-0.9.0/utilities/XFetchName.c:15:27: [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). unsigned int window = atoi(argv[1]); data/herbstluftwm-0.9.0/ipc-client/main.c:272: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). size_t output_len = strlen(output); data/herbstluftwm-0.9.0/src/completion.cpp:68:21: [1] (buffer) mismatch: 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. auto res = std::mismatch(shorter.begin(), shorter.end(), longer.begin()); data/herbstluftwm-0.9.0/src/namedhook.cpp:40:28: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). auto newvalue = o->read(name); data/herbstluftwm-0.9.0/src/namedhook.cpp:169:24: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). auto newvalue = o->read(path_.back()); data/herbstluftwm-0.9.0/src/rootcommands.cpp:397: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 (attr_name.substr(0,strlen(USER_ATTRIBUTE_PREFIX)) != USER_ATTRIBUTE_PREFIX) { data/herbstluftwm-0.9.0/src/rootcommands.cpp:461: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 (a->name().substr(0,strlen(USER_ATTRIBUTE_PREFIX)) != USER_ATTRIBUTE_PREFIX) { data/herbstluftwm-0.9.0/src/rootcommands.cpp:478:39: [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 a->name().substr(0,strlen(USER_ATTRIBUTE_PREFIX)) data/herbstluftwm-0.9.0/src/utils.cpp:249: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). slow_assert(j == strlen(ESCAPE_CHARACTERS)); data/herbstluftwm-0.9.0/src/utils.cpp:251:39: [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). slow_assert(0 <= j && j < strlen(ESCAPE_CHARACTERS)); data/herbstluftwm-0.9.0/src/utils.cpp:274: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). slow_assert(s < strlen(source)); data/herbstluftwm-0.9.0/src/utils.cpp:280: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). slow_assert(s < strlen(source)); data/herbstluftwm-0.9.0/src/utils.cpp:285: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). slow_assert(s < strlen(source)); data/herbstluftwm-0.9.0/src/utils.cpp:294: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). slow_assert(s < strlen(source)); data/herbstluftwm-0.9.0/src/utils.cpp:299:22: [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). slow_assert(s == strlen(source)); ANALYSIS SUMMARY: Hits = 51 Lines analyzed = 22431 in approximately 0.52 seconds (43036 lines/second) Physical Source Lines of Code (SLOC) = 17486 Hits@level = [0] 39 [1] 14 [2] 21 [3] 5 [4] 11 [5] 0 Hits@level+ = [0+] 90 [1+] 51 [2+] 37 [3+] 16 [4+] 11 [5+] 0 Hits/KSLOC@level+ = [0+] 5.14697 [1+] 2.91662 [2+] 2.11598 [3+] 0.915018 [4+] 0.629075 [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.