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/libxklavier-5.4/libxklavier/xkl_config_item.h Examining data/libxklavier-5.4/libxklavier/xkl_config_rec.h Examining data/libxklavier-5.4/libxklavier/xkl_config_registry.h Examining data/libxklavier-5.4/libxklavier/xkl_engine.h Examining data/libxklavier-5.4/libxklavier/xklavier.c Examining data/libxklavier-5.4/libxklavier/xklavier.h Examining data/libxklavier-5.4/libxklavier/xklavier_config.c Examining data/libxklavier-5.4/libxklavier/xklavier_config_iso.c Examining data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c Examining data/libxklavier-5.4/libxklavier/xklavier_config_xmm.c Examining data/libxklavier-5.4/libxklavier/xklavier_dump.c Examining data/libxklavier-5.4/libxklavier/xklavier_evt.c Examining data/libxklavier-5.4/libxklavier/xklavier_evt_xkb.c Examining data/libxklavier-5.4/libxklavier/xklavier_evt_xmm.c Examining data/libxklavier-5.4/libxklavier/xklavier_private.h Examining data/libxklavier-5.4/libxklavier/xklavier_private_xkb.h Examining data/libxklavier-5.4/libxklavier/xklavier_private_xmm.h Examining data/libxklavier-5.4/libxklavier/xklavier_props.c Examining data/libxklavier-5.4/libxklavier/xklavier_toplevel.c Examining data/libxklavier-5.4/libxklavier/xklavier_util.c Examining data/libxklavier-5.4/libxklavier/xklavier_xkb.c Examining data/libxklavier-5.4/libxklavier/xklavier_xmm.c Examining data/libxklavier-5.4/libxklavier/xklavier_xmm_opts.c Examining data/libxklavier-5.4/tests/test_config.c Examining data/libxklavier-5.4/tests/test_monitor.c FINAL RESULTS: data/libxklavier-5.4/libxklavier/xklavier_config.c:194:3: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(item->name, data/libxklavier-5.4/libxklavier/xklavier_config.c:200:3: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(item->short_description, data/libxklavier-5.4/libxklavier/xklavier_config.c:241:3: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(item->description, data/libxklavier-5.4/libxklavier/xklavier.c:443:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stdout, format, args); data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:304:5: [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(XKBCOMP, XKBCOMP, "-w0", "-I", data/libxklavier-5.4/libxklavier/xklavier_dump.c:69:3: [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(buf, b); data/libxklavier-5.4/libxklavier/xklavier_props.c:519: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(next, rules_file); data/libxklavier-5.4/libxklavier/xklavier_props.c:524: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(next, data->model); data/libxklavier-5.4/libxklavier/xklavier_props.c:529: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(next, all_layouts); data/libxklavier-5.4/libxklavier/xklavier_props.c:534: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(next, all_variants); data/libxklavier-5.4/libxklavier/xklavier_props.c:539: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(next, all_options); data/libxklavier-5.4/libxklavier/xklavier_xmm.c:269:8: [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. res = system(cmd); data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:248:6: [3] (tmpfile) tmpnam: Temporary file race condition (CWE-377). if (tmpnam(xkm_fn) != NULL && tmpnam(xkb_fn) != NULL) { data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:248:32: [3] (tmpfile) tmpnam: Temporary file race condition (CWE-377). if (tmpnam(xkm_fn) != NULL && tmpnam(xkb_fn) != NULL) { data/libxklavier-5.4/libxklavier/xklavier_xkb.c:578:6: [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. if (getenv("XKL_XKB_DISABLE") != NULL) data/libxklavier-5.4/libxklavier/xklavier_xmm.c:342:6: [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. if (getenv("XKL_XMODMAP_DISABLE") != NULL) data/libxklavier-5.4/tests/test_config.c:205:7: [3] (buffer) getopt: 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. c = getopt(argc, argv, "ha:sgm:l:o:d:w:c:p:"); data/libxklavier-5.4/tests/test_monitor.c:107:7: [3] (buffer) getopt: 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. c = getopt(argc, argv, "hd:l:"); data/libxklavier-5.4/libxklavier/xklavier.c:924:23: [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). xkl_set_debug_level(atoi(sdl)); data/libxklavier-5.4/libxklavier/xklavier_config.c:341: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 xpath_expr[1024]; data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:55: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 file_name[MAXPATHLEN] = ""; data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:237: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 xkm_fn[L_tmpnam]; data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:238: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 xkb_fn[L_tmpnam]; data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:255: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). if ((tmpxkb = fopen(xkb_fn, "w")) != NULL) { data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:326:11: [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). fopen(xkm_fn, "r")) != NULL) { data/libxklavier-5.4/libxklavier/xklavier_config_xkb.c:555: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 *output = fopen(file_name, "w"); data/libxklavier-5.4/libxklavier/xklavier_dump.c:276: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). FILE *fs = fopen(file_name, "w+"); data/libxklavier-5.4/libxklavier/xklavier_evt.c:491: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 buf[128] = ""; data/libxklavier-5.4/libxklavier/xklavier_evt.c:647: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(&old_state, &xkl_engine_priv(engine, curr_state), data/libxklavier-5.4/libxklavier/xklavier_props.c:453: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(var, varstart + 1, data/libxklavier-5.4/libxklavier/xklavier_util.c:134: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(sname, "NULL"); data/libxklavier-5.4/libxklavier/xklavier_xmm.c:255: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 cmd[1024]; data/libxklavier-5.4/tests/test_config.c:239: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). debug_level = atoi(optarg); data/libxklavier-5.4/tests/test_monitor.c:115: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). debug_level = atoi(optarg); data/libxklavier-5.4/libxklavier/xklavier_props.c:68:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (item->name, name, XKL_MAX_CI_SHORT_DESC_LENGTH-1); data/libxklavier-5.4/libxklavier/xklavier_props.c:84:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (item->short_description, short_description, XKL_MAX_CI_DESC_LENGTH-1); data/libxklavier-5.4/libxklavier/xklavier_props.c:100:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (item->description, description, XKL_MAX_CI_NAME_LENGTH-1); data/libxklavier-5.4/libxklavier/xklavier_props.c:399: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). out += strlen(out) + 1; data/libxklavier-5.4/libxklavier/xklavier_props.c:410: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). out += strlen(out) + 1; data/libxklavier-5.4/libxklavier/xklavier_props.c:415: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). out += strlen(out) + 1; data/libxklavier-5.4/libxklavier/xklavier_props.c:465: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). out += strlen(out) + 1; data/libxklavier-5.4/libxklavier/xklavier_props.c:490: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). len = (rules_file ? strlen(rules_file) : 0); data/libxklavier-5.4/libxklavier/xklavier_props.c:491: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). len += (data->model ? strlen(data->model) : 0); data/libxklavier-5.4/libxklavier/xklavier_props.c:492: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). len += (all_layouts ? strlen(all_layouts) : 0); data/libxklavier-5.4/libxklavier/xklavier_props.c:493: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). len += (all_variants ? strlen(all_variants) : 0); data/libxklavier-5.4/libxklavier/xklavier_props.c:494: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). len += (all_options ? strlen(all_options) : 0); data/libxklavier-5.4/libxklavier/xklavier_props.c:520:11: [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). next += strlen(rules_file); data/libxklavier-5.4/libxklavier/xklavier_props.c:525:11: [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). next += strlen(data->model); data/libxklavier-5.4/libxklavier/xklavier_props.c:530:11: [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). next += strlen(all_layouts); data/libxklavier-5.4/libxklavier/xklavier_props.c:535:11: [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). next += strlen(all_variants); data/libxklavier-5.4/libxklavier/xklavier_props.c:540:11: [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). next += strlen(all_options); ANALYSIS SUMMARY: Hits = 51 Lines analyzed = 10209 in approximately 0.25 seconds (40123 lines/second) Physical Source Lines of Code (SLOC) = 7099 Hits@level = [0] 133 [1] 17 [2] 16 [3] 6 [4] 9 [5] 3 Hits@level+ = [0+] 184 [1+] 51 [2+] 34 [3+] 18 [4+] 12 [5+] 3 Hits/KSLOC@level+ = [0+] 25.9191 [1+] 7.18411 [2+] 4.78941 [3+] 2.53557 [4+] 1.69038 [5+] 0.422595 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.