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/alttab-1.5.0/src/alttab.c Examining data/alttab-1.5.0/src/alttab.h Examining data/alttab-1.5.0/src/autil.c Examining data/alttab-1.5.0/src/ewmh.c Examining data/alttab-1.5.0/src/gui.c Examining data/alttab-1.5.0/src/icon.c Examining data/alttab-1.5.0/src/icon.h Examining data/alttab-1.5.0/src/pngd.c Examining data/alttab-1.5.0/src/pngd.h Examining data/alttab-1.5.0/src/randr.c Examining data/alttab-1.5.0/src/rp.c Examining data/alttab-1.5.0/src/util.c Examining data/alttab-1.5.0/src/util.h Examining data/alttab-1.5.0/src/win.c Examining data/alttab-1.5.0/src/x.c Examining data/alttab-1.5.0/test/pngtest.c FINAL RESULTS: data/alttab-1.5.0/src/autil.c:36: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, MSGPREFIX); data/alttab-1.5.0/src/autil.c:40:9: [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(stderr, format, ap); data/alttab-1.5.0/src/autil.c:51:5: [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, MSGPREFIX); data/alttab-1.5.0/src/autil.c:53:5: [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(stderr, format, ap); data/alttab-1.5.0/src/rp.c:116:15: [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. if ((fp = popen("which ratpoison", "r"))) { data/alttab-1.5.0/src/util.c:181: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(exe, args); data/alttab-1.5.0/src/gui.c:283:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(time(NULL)); data/alttab-1.5.0/src/icon.c:103: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 *home = getenv("HOME"); data/alttab-1.5.0/src/icon.c:104:19: [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 *xdgdd = getenv("XDG_DATA_DIRS"); data/alttab-1.5.0/src/alttab.c:518: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 keys_pressed[32]; data/alttab-1.5.0/src/alttab.h:78: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 name[MAXNAMESZ]; data/alttab-1.5.0/src/gui.c:289:17: [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 r[3]; data/alttab-1.5.0/src/icon.c:194: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 *icon_dirs[MAXICONDIRS]; data/alttab-1.5.0/src/icon.c:256: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 app[MAXAPPLEN]; data/alttab-1.5.0/src/icon.c:263: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 sx[5]; data/alttab-1.5.0/src/icon.c:264: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 sy[5]; data/alttab-1.5.0/src/icon.c:314:14: [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). ix = atoi(sx); data/alttab-1.5.0/src/icon.c:317:14: [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). iy = atoi(sy); data/alttab-1.5.0/src/icon.c:474: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 appl[MAXAPPLEN]; data/alttab-1.5.0/src/icon.h:43: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 app[MAXAPPLEN]; // application name; uthash key data/alttab-1.5.0/src/icon.h:44: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 src_path[MAXICONPATHLEN]; // \0 -if not initialized or loaded from X window properties data/alttab-1.5.0/src/pngd.c:241:20: [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 (!(infile = fopen(pngpath, "rb"))) { data/alttab-1.5.0/src/rp.c:48: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[MAXRPOUT]; data/alttab-1.5.0/src/rp.c:137: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[MAXRPOUT]; data/alttab-1.5.0/src/rp.c:167: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 arg2[arg2len]; // fits 'groups', 'gselect N' data/alttab-1.5.0/src/rp.c:169: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[MAXRPOUT]; data/alttab-1.5.0/src/rp.c:222: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 selarg[64]; data/alttab-1.5.0/src/rp.c: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[MAXRPOUT]; data/alttab-1.5.0/src/util.c:73: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 etext[EM]; data/alttab-1.5.0/src/util.c:398: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 line[M]; data/alttab-1.5.0/src/util.c:525: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 line[104]; data/alttab-1.5.0/src/util.c:606:5: [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(r, ret_prop, size); data/alttab-1.5.0/src/util.c:676: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 xappname[MAXNAMESZ]; data/alttab-1.5.0/src/util.c:723: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 xresr[MAXNAMESZ]; data/alttab-1.5.0/src/ewmh.c:107:9: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(WM_POLL_INTERVAL); data/alttab-1.5.0/src/icon.c:102: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). int theme_len = strlen(g.option_theme); data/alttab-1.5.0/src/icon.c:115: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). id2len = strlen(icondir[hd]) + 1; data/alttab-1.5.0/src/icon.c:121:23: [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). id2len += strlen(home); data/alttab-1.5.0/src/icon.c:131:13: [1] (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). Risk is low because the source is a constant character. strcat(id2, "/"); data/alttab-1.5.0/src/icon.c:132:13: [1] (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. strncat(id2, g.option_theme, theme_len); data/alttab-1.5.0/src/icon.c:146: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). for (k = xdg + strlen(xdg) - 1; *k == '/'; k--) { data/alttab-1.5.0/src/icon.c:149: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). id2len = strlen(xdg) + strlen("/icons/") + theme_len + 1; data/alttab-1.5.0/src/icon.c:149: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). id2len = strlen(xdg) + strlen("/icons/") + theme_len + 1; data/alttab-1.5.0/src/icon.c:300:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(app, fname, applen); data/alttab-1.5.0/src/icon.c:312:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sx, dim, (xchar - dim)); data/alttab-1.5.0/src/icon.c:315:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sy, xchar + 1, dim + dimlen - xchar); data/alttab-1.5.0/src/icon.c:338:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sx, uchar+1, (xchar - uchar - 1)); data/alttab-1.5.0/src/icon.c:346:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sy, xchar + 1, app + strlen(app) - xchar); data/alttab-1.5.0/src/icon.c:346:42: [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). strncpy(sy, xchar + 1, app + strlen(app) - xchar); data/alttab-1.5.0/src/icon.c:347: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). sy[app + strlen(app) - xchar] = '\0'; data/alttab-1.5.0/src/icon.c:361:23: [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). digit = app + strlen(app) - 2; data/alttab-1.5.0/src/icon.c:362:23: [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). minus = app + strlen(app) - 3; // trick for gcc-10 pseudo-intelligence data/alttab-1.5.0/src/icon.c:384:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ic->app, app, MAXAPPLEN); data/alttab-1.5.0/src/icon.c:385:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ic->src_path, pe->fts_path, MAXICONPATHLEN-1); data/alttab-1.5.0/src/icon.c:397:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ic->src_path, pe->fts_path, MAXICONPATHLEN-1); data/alttab-1.5.0/src/rp.c:124: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). if (strlen(ratpoison_cmd) < 2) { data/alttab-1.5.0/src/rp.c:183:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(arg2, "groups", arg2len); data/alttab-1.5.0/src/util.c:187:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rb = read(link[0], buf, bufsize); data/alttab-1.5.0/src/util.c:417:57: [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). XftTextExtentsUtf8(dpy, font, (unsigned char *)str, strlen(str), &ext); data/alttab-1.5.0/src/util.c:430:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(line, line_from_char, M); data/alttab-1.5.0/src/util.c:432: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). line_clen = strlen(line); data/alttab-1.5.0/src/util.c:451: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). line_clen = strlen(line); data/alttab-1.5.0/src/util.c:464: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). line_clen = strlen(line); data/alttab-1.5.0/src/util.c:530:9: [1] (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. strncat(line, add, 26); data/alttab-1.5.0/src/win.c:333: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). tryclass += (strlen(tryclass) + 1)) { data/alttab-1.5.0/src/win.c:388:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(g.winlist[g.maxNdx].name, wm_name, MAXNAMESZ-1); data/alttab-1.5.0/src/win.c:397:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(g.winlist[g.maxNdx].name, (char *)wn, MAXNAMESZ-1); ANALYSIS SUMMARY: Hits = 67 Lines analyzed = 5463 in approximately 0.14 seconds (39347 lines/second) Physical Source Lines of Code (SLOC) = 3905 Hits@level = [0] 38 [1] 33 [2] 25 [3] 3 [4] 6 [5] 0 Hits@level+ = [0+] 105 [1+] 67 [2+] 34 [3+] 9 [4+] 6 [5+] 0 Hits/KSLOC@level+ = [0+] 26.8886 [1+] 17.1575 [2+] 8.70679 [3+] 2.30474 [4+] 1.53649 [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.