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/logapp-0.16/logfile.c Examining data/logapp-0.16/capture.h Examining data/logapp-0.16/configuration.c Examining data/logapp-0.16/capture.c Examining data/logapp-0.16/logapp.h Examining data/logapp-0.16/logfile.h Examining data/logapp-0.16/main.c Examining data/logapp-0.16/configuration.h FINAL RESULTS: data/logapp-0.16/capture.c:165:4: [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(&pipe->buf[ccount-1], pipe->escreset); data/logapp-0.16/capture.c:386: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(pipe->dbuf, pipe->esccolor); data/logapp-0.16/configuration.c:497:4: [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(longpath, home); data/logapp-0.16/configuration.c:499:4: [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(longpath, filename + 2); data/logapp-0.16/logfile.c:350:2: [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(newname, oldname); data/logapp-0.16/logfile.c:351:2: [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(newname, logfile->oldext); data/logapp-0.16/logfile.c:386:2: [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(name, logfile->name); data/logapp-0.16/logfile.c:387:2: [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(name, number); data/logapp-0.16/main.c:112:6: [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. if (vfprintf(stderr, fmtstring, argptr) < 0) { data/logapp-0.16/main.c:123:9: [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. return system(cmd); data/logapp-0.16/main.c:341:7: [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. if (execvp(app.exe, app.argv) < 0) { data/logapp-0.16/configuration.c:490:10: [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. home = getenv("HOME"); data/logapp-0.16/main.c:360:8: [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("TERM"); data/logapp-0.16/configuration.c:582:2: [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(pipe->esccolor, pipe->escreset, pipe->escresetlen); data/logapp-0.16/configuration.c:1166: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 linebuf[LINEBUFSIZE]; data/logapp-0.16/configuration.c:1177:15: [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). conffile = fopen(filename, "r"); data/logapp-0.16/configuration.c:1185:15: [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). conffile = fopen(filename, "r"); data/logapp-0.16/logfile.c:59: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[MAX_HEADER + 1]; data/logapp-0.16/logfile.c:60: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 tmp[MAX_TMP + 1]; data/logapp-0.16/logfile.c:61: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 pwd[MAX_PWD + 1]; data/logapp-0.16/logfile.c:174: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[MAX_SPLIT + 1]; data/logapp-0.16/logfile.c:175: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 tmp[MAX_TMP + 1]; data/logapp-0.16/logfile.c:244: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[MAX_FOOTER + 1]; data/logapp-0.16/logfile.c:245: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 tmp[MAX_TMP + 1]; data/logapp-0.16/logfile.c:373: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 number[12]; data/logapp-0.16/logfile.c:423:17: [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). logfile->fh = open(logfile->name, flags, 0644); data/logapp-0.16/logfile.c:514:4: [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(&app.toffset, &tvtime, sizeof(struct timeval)); data/logapp-0.16/logfile.c:536: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 timestamp[16]; data/logapp-0.16/logfile.c:660:18: [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). logfile->fh = open(altname, O_WRONLY, 0644); data/logapp-0.16/logfile.c:681:17: [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). logfile->fh = open(altname, flags, 0644); data/logapp-0.16/main.c:90: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(fmtstring, EXECUTABLE, exec_len); data/logapp-0.16/main.c:99:4: [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(fmtstring + exec_len, STRING_WARNING, warn_len); data/logapp-0.16/main.c:103:4: [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(fmtstring + exec_len, STRING_ERROR, err_len); data/logapp-0.16/main.c:109:2: [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(fmtstring + fmt_len, format, format_len); data/logapp-0.16/main.c:133: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 linebuf[LINELENGTH + 1]; data/logapp-0.16/main.c:201: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(&linebuf[offset], data/logapp-0.16/main.c:259:4: [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(app.ptytermios_bak, app.ptytermios, data/logapp-0.16/capture.c:166:4: [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. strcpy(&pipe->buf[ccount-1 + rlen], "\n"); data/logapp-0.16/capture.c:238:22: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return (pipe->rdbuf.read >= pipe->rdbuf.end); data/logapp-0.16/capture.c:255:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). i = read(pipe->fh, pipe->rdbuf.start, pipe->rdbuf.len); data/logapp-0.16/capture.c:265:22: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). *buf = *pipe->rdbuf.read; data/logapp-0.16/capture.c:425:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((pipe->bfill = read(pipe->fh, pipe->buf+pipe->memcr, data/logapp-0.16/capture.c:596:14: [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. case 2: usleep(10000); data/logapp-0.16/configuration.c:495:29: [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). longpath = (char*) malloc(strlen(home) + strlen(filename) + 1); data/logapp-0.16/configuration.c:495:44: [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). longpath = (char*) malloc(strlen(home) + strlen(filename) + 1); data/logapp-0.16/configuration.c:498:4: [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(longpath, "/"); data/logapp-0.16/configuration.c:556: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). pipe->lineprefixlen = strlen(pipe->lineprefix); data/logapp-0.16/configuration.c:565: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). pipe->escresetlen = strlen(pipe->escreset); data/logapp-0.16/configuration.c:610:7: [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(pipe->regexp)) { data/logapp-0.16/configuration.c:623:7: [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(pipe->execregexp)) { data/logapp-0.16/configuration.c:637:8: [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(pipe->execcommand) == 0) { data/logapp-0.16/configuration.c:648:6: [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(config.logname) == 0) data/logapp-0.16/configuration.c:675:7: [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(config.logtimerstregexp)) { data/logapp-0.16/configuration.c:1004:13: [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). arg += strlen(config.argprefix); data/logapp-0.16/configuration.c:1083:7: [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(name) == 0) || (*name == '#')) data/logapp-0.16/configuration.c:1090:6: [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(value+1) > 0) data/logapp-0.16/configuration.c:1111:7: [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(value)==0) && (strlen(name)>1) && (name[0] == '[') data/logapp-0.16/configuration.c:1111:29: [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(value)==0) && (strlen(name)>1) && (name[0] == '[') data/logapp-0.16/configuration.c:1112:15: [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). && (name[strlen(name)-1] == ']') ) { data/logapp-0.16/configuration.c:1114:8: [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). name[strlen(name) - 1] = '\0'; data/logapp-0.16/configuration.c:1148:8: [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(value) == 0) && (arglist[argid].type == TNONE)) { data/logapp-0.16/configuration.h:82:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). char* read; data/logapp-0.16/logfile.c:76:12: [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). headlen = strlen(logfile->head); data/logapp-0.16/logfile.c:96: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). if (write(logfile->fh, app.argv[i], strlen(app.argv[i])) == -1) data/logapp-0.16/logfile.c:126:7: [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). pwd[strlen(pwd)+1] = '\0'; data/logapp-0.16/logfile.c:127:7: [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). pwd[strlen(pwd)] = '\n'; data/logapp-0.16/logfile.c:128: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). if (write(logfile->fh, pwd, strlen(pwd)) == -1) data/logapp-0.16/logfile.c:143: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). if (write(logfile->fh, environ[i], strlen(environ[i])) data/logapp-0.16/logfile.c:162: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 (write(logfile->fh, buf, strlen(buf)) == -1) data/logapp-0.16/logfile.c:269: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). len += strlen(logfile->foot) + 2; data/logapp-0.16/logfile.c:343:19: [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). newname = malloc(strlen(oldname) data/logapp-0.16/logfile.c:380: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). char *name = malloc(strlen(logfile->name) + strlen(number) + 1); data/logapp-0.16/logfile.c:380:46: [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). char *name = malloc(strlen(logfile->name) + strlen(number) + 1); data/logapp-0.16/main.c:75:15: [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). format_len = strlen(format); data/logapp-0.16/main.c:76:13: [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). exec_len = strlen(EXECUTABLE); data/logapp-0.16/main.c:77:13: [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). warn_len = strlen(STRING_WARNING); data/logapp-0.16/main.c:78:12: [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). err_len = strlen(STRING_ERROR); data/logapp-0.16/main.c:189: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). for (j=0; j<((desclen = strlen(arglist[i].desc)) + 2); j++) { data/logapp-0.16/main.c:224:6: [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(SVN_REVISION)) data/logapp-0.16/main.c:305:4: [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(10000); data/logapp-0.16/main.c:339:4: [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(10000); data/logapp-0.16/main.c:380:8: [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(app.exe)>strlen(config.strip_prefix)) data/logapp-0.16/main.c:380: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). if (strlen(app.exe)>strlen(config.strip_prefix)) data/logapp-0.16/main.c:381:16: [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). app.exe += strlen(config.strip_prefix); ANALYSIS SUMMARY: Hits = 84 Lines analyzed = 3565 in approximately 0.11 seconds (31696 lines/second) Physical Source Lines of Code (SLOC) = 2778 Hits@level = [0] 40 [1] 47 [2] 24 [3] 2 [4] 11 [5] 0 Hits@level+ = [0+] 124 [1+] 84 [2+] 37 [3+] 13 [4+] 11 [5+] 0 Hits/KSLOC@level+ = [0+] 44.6364 [1+] 30.2376 [2+] 13.3189 [3+] 4.67963 [4+] 3.95968 [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.