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/xlbiff-4.4/xlbiff.c FINAL RESULTS: data/xlbiff-4.4/xlbiff.c:68:37: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DP(x) if (lbiff_data.debug) printf x data/xlbiff-4.4/xlbiff.c:87:14: [4] (misc) getlogin: It's often easy to fool getlogin. Sometimes it does not work at all, because some program messed up the utmp file. Often, it gives only the first 8 characters of the login name. The user currently logged in on the controlling tty of our program need not be the user who started it. Avoid getlogin() for security-related purposes (CWE-807). Use getpwuid(geteuid()) and extract the desired information instead. extern char *getlogin(); data/xlbiff-4.4/xlbiff.c:262:19: [4] (misc) getlogin: It's often easy to fool getlogin. Sometimes it does not work at all, because some program messed up the utmp file. Often, it gives only the first 8 characters of the login name. The user currently logged in on the controlling tty of our program need not be the user who started it. Avoid getlogin() for security-related purposes (CWE-807). Use getpwuid(geteuid()) and extract the desired information instead. char *username = getlogin(); data/xlbiff-4.4/xlbiff.c:279:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(default_file,XLBIFF_MAILPATH,username); data/xlbiff-4.4/xlbiff.c:292:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(envstr, "DISPLAY=%s", XDisplayString(XtDisplay(topLevel))); data/xlbiff-4.4/xlbiff.c:439:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(cmd_buf, lbiff_data.checkCmd, lbiff_data.file, previous); data/xlbiff-4.4/xlbiff.c:543:25: [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_return = system(lbiff_data.mailerCmd); data/xlbiff-4.4/xlbiff.c:602:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(cmd_buf,lbiff_data.cmd, lbiff_data.file, lbiff_data.columns); data/xlbiff-4.4/xlbiff.c:611: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(buf+size, scan_fail_msg); data/xlbiff-4.4/xlbiff.c:821:6: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(sound_buf,lbiff_data.sound, lbiff_data.volume); data/xlbiff-4.4/xlbiff.c:824:18: [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_return = system(sound_buf); data/xlbiff-4.4/xlbiff.c:967:13: [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 ((p= popen(cmd,"r")) == NULL) data/xlbiff-4.4/xlbiff.c:1038:5: [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(profile_name, tmpdir_name); data/xlbiff-4.4/xlbiff.c:1040:5: [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(profile_name, PROFILE_TEMPLATE); data/xlbiff-4.4/xlbiff.c:1031: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. tmpdir_name = getenv("TMPDIR"); data/xlbiff-4.4/xlbiff.c:443:13: [2] (integer) atol: 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). previous = atol(outbuf); data/xlbiff-4.4/xlbiff.c:654: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((char*)&lastEvent,(char*)e,sizeof(XEvent)); data/xlbiff-4.4/xlbiff.c:971: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 junkbuf[100]; data/xlbiff-4.4/xlbiff.c:1042:18: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). profile_fd = mkstemp(profile_name); data/xlbiff-4.4/xlbiff.c:243:34: [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 (!strncmp(argv[1],"-version",strlen(argv[1]))) { data/xlbiff-4.4/xlbiff.c:246:38: [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). } else if (!strncmp(argv[1],"-help",strlen(argv[1]))) { data/xlbiff-4.4/xlbiff.c:274: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). default_file = (char*)malloc(strlen(XLBIFF_MAILPATH) data/xlbiff-4.4/xlbiff.c:275: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). + strlen(username)); data/xlbiff-4.4/xlbiff.c:289: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). char *envstr = (char*)malloc(strlen("DISPLAY=") + 1 data/xlbiff-4.4/xlbiff.c:290: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). + strlen(XDisplayString(XtDisplay(topLevel)))); data/xlbiff-4.4/xlbiff.c:428: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). cmd_buf = (char*)malloc(strlen(lbiff_data.checkCmd) + data/xlbiff-4.4/xlbiff.c:429: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). strlen(lbiff_data.file) + 10); data/xlbiff-4.4/xlbiff.c:518: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). if (strlen(s) != 0) { /* is there anything new? */ data/xlbiff-4.4/xlbiff.c:597: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). cmd_buf = (char*)malloc(strlen(lbiff_data.cmd) + data/xlbiff-4.4/xlbiff.c:598:5: [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). strlen(lbiff_data.file) + 10); data/xlbiff-4.4/xlbiff.c:612: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). size += strlen(scan_fail_msg); data/xlbiff-4.4/xlbiff.c:817:32: [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). sound_buf = (char*)malloc(strlen(lbiff_data.sound) + 10); data/xlbiff-4.4/xlbiff.c:846: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). len = strlen(s); data/xlbiff-4.4/xlbiff.c:1032:32: [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 (tmpdir_name == NULL || strlen(tmpdir_name) == 0) data/xlbiff-4.4/xlbiff.c:1034: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). namelen = strlen(tmpdir_name) + 1 + strlen(PROFILE_TEMPLATE) + 1; data/xlbiff-4.4/xlbiff.c:1034:41: [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). namelen = strlen(tmpdir_name) + 1 + strlen(PROFILE_TEMPLATE) + 1; data/xlbiff-4.4/xlbiff.c:1039:5: [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(profile_name, "/"); ANALYSIS SUMMARY: Hits = 37 Lines analyzed = 1062 in approximately 0.04 seconds (26907 lines/second) Physical Source Lines of Code (SLOC) = 677 Hits@level = [0] 14 [1] 18 [2] 4 [3] 1 [4] 14 [5] 0 Hits@level+ = [0+] 51 [1+] 37 [2+] 19 [3+] 15 [4+] 14 [5+] 0 Hits/KSLOC@level+ = [0+] 75.3323 [1+] 54.6529 [2+] 28.065 [3+] 22.1566 [4+] 20.6795 [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.