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/pstotext-1.9/bundle.c Examining data/pstotext-1.9/bundle.h Examining data/pstotext-1.9/mkbundle.c Examining data/pstotext-1.9/mkrch.c Examining data/pstotext-1.9/pstotxtd.c Examining data/pstotext-1.9/ptotdll.c Examining data/pstotext-1.9/ptotdll.h Examining data/pstotext-1.9/vms.h Examining data/pstotext-1.9/main.c FINAL RESULTS: data/pstotext-1.9/main.c:102: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(templ, pattern); data/pstotext-1.9/main.c:110: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(path, templ); data/pstotext-1.9/main.c:245:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(gs_cmdline, "@%s.", cmdfile); data/pstotext-1.9/main.c:246:3: [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(gs_cmdline); data/pstotext-1.9/main.c:263: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("/usr/bin/gs", gs_argv); data/pstotext-1.9/mkbundle.c:29: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(inbuf, argv[1]); data/pstotext-1.9/mkrch.c:29: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(inbuf, argv[1]); data/pstotext-1.9/pstotxtd.c:24:9: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). #define mktemp(t) _mktemp(t) data/pstotext-1.9/pstotxtd.c:360: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(path, temp); data/pstotext-1.9/pstotxtd.c:362: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(path, temp); data/pstotext-1.9/pstotxtd.c:376:5: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). mktemp(path); data/pstotext-1.9/pstotxtd.c:474:31: [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). else {strcpy(input, "-- "); strcat(input, path);} data/pstotext-1.9/pstotxtd.c:504:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(gs_cmd, "%s @%s %s %s", gscommand, gsargtemp, data/pstotext-1.9/pstotxtd.c:513:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(gs_cmd, "%s -r72 -dNODISPLAY -dFIXEDMEDIA -dDELAYBIND -dWRITESYSTEMDICT %s -dNOPAUSE %s %s %s %s %s", data/pstotext-1.9/pstotxtd.c:533:7: [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. if (system(gs_cmd)) { data/pstotext-1.9/pstotxtd.c:541:8: [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. gs = popen(gs_cmd, "r"); data/pstotext-1.9/vms.h:27:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%s%s%X", dir, prefix, pid); data/pstotext-1.9/main.c:96:10: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). path = tempnam("SYS$SCRATCH:", ".ps2t"); data/pstotext-1.9/main.c:237:13: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). cmdfile = tempnam("SYS$SCRATCH:","PS2TGS"); data/pstotext-1.9/main.c:238:15: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). gsoutfile = tempnam("SYS$SCRATCH:","GSRES"); data/pstotext-1.9/pstotxtd.c:153:22: [3] (misc) LoadLibrary: Ensure that the full path to the library is specified, or current directory may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to find library path, if you aren't already. pstotextModule = LoadLibrary(dllname); data/pstotext-1.9/pstotxtd.c:359: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. if ( (temp = getenv("TEMP")) != NULL ) data/pstotext-1.9/pstotxtd.c:361:23: [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. else if ( (temp = getenv("TMP")) != NULL ) data/pstotext-1.9/vms.h:20:7: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). char *tempnam(char *dir, char *prefix) data/pstotext-1.9/main.c:103:8: [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). fd = mkstemp(templ); data/pstotext-1.9/main.c:112:7: [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). f = fopen(path, "w"); data/pstotext-1.9/main.c:171: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 *gs_argv[32]; data/pstotext-1.9/main.c:188:16: [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). fileout = fopen(outfile, "w", "rfm=var","rat=cr"); data/pstotext-1.9/main.c:190:16: [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). fileout = fopen(outfile, "w"); data/pstotext-1.9/main.c:239:16: [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 ((cfile = fopen(cmdfile,"w")) == NULL) {perror(cmd);exit(1);} data/pstotext-1.9/main.c:247: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). if ((gs = fopen(gsoutfile, "r")) == NULL) { data/pstotext-1.9/main.c:286: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[LINELEN]; data/pstotext-1.9/mkbundle.c:19:1: [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 inbuf[256], outbuf[256]; data/pstotext-1.9/mkbundle.c:23: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 ( (psfile = fopen(argv[1], "r")) == (FILE *)NULL ) data/pstotext-1.9/mkbundle.c:25:21: [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 ( (hdrfile = fopen(argv[2], "w")) == (FILE *)NULL ) { data/pstotext-1.9/mkrch.c:19:1: [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 inbuf[256], outbuf[256]; data/pstotext-1.9/mkrch.c:23: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 ( (psfile = fopen(argv[1], "r")) == (FILE *)NULL ) data/pstotext-1.9/mkrch.c:25:21: [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 ( (hdrfile = fopen(argv[2], "w")) == (FILE *)NULL ) { data/pstotext-1.9/pstotxtd.c:128:1: [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 dllname[256]; data/pstotext-1.9/pstotxtd.c:139:5: [2] (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 string. strcat(dllname, "pstotxta.dll"); data/pstotext-1.9/pstotxtd.c:141:5: [2] (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 string. strcat(dllname, "pstotxt3.dll"); data/pstotext-1.9/pstotxtd.c:144:5: [2] (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 string. strcat(dllname, "pstotxt1.dll"); data/pstotext-1.9/pstotxtd.c:252:1: [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 dllname[256]; data/pstotext-1.9/pstotxtd.c:253:1: [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[256]; data/pstotext-1.9/pstotxtd.c:273:5: [2] (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 string. strcat(dllname, "pstotxt2.dll"); data/pstotext-1.9/pstotxtd.c:364: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(path, "c:\\"); data/pstotext-1.9/pstotxtd.c:375:5: [2] (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 string. strcat(path, "ptXXXXXX"); data/pstotext-1.9/pstotxtd.c:377:9: [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). f = fopen(path, "w"); data/pstotext-1.9/pstotxtd.c:390:9: [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). f = fopen(path, "w"); data/pstotext-1.9/pstotxtd.c:433: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 gs_cmd[2*MAXPATHLEN]; data/pstotext-1.9/pstotxtd.c:434: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 input[MAXPATHLEN]; data/pstotext-1.9/pstotxtd.c:444: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). fileout = fopen(outfile, "w"); data/pstotext-1.9/pstotxtd.c:474:9: [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. else {strcpy(input, "-- "); strcat(input, path);} data/pstotext-1.9/pstotxtd.c:490:21: [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 ( (gsargfile = fopen(gsargtemp, "w")) == (FILE *)NULL) { data/pstotext-1.9/pstotxtd.c:539:8: [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). gs = fopen(gstemp, "r"); data/pstotext-1.9/pstotxtd.c:553: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[LINELEN]; data/pstotext-1.9/ptotdll.c:357: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 buf[1000]; data/pstotext-1.9/ptotdll.c:364: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 word[1000]; /* last word output */ data/pstotext-1.9/ptotdll.c:763: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 buf[1000]; data/pstotext-1.9/ptotdll.c:827:34: [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. const char *str; int lstr; char tempstr[2]; data/pstotext-1.9/main.c:99: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). char *templ = (char*)malloc(strlen(pattern)+1); data/pstotext-1.9/main.c:109: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). path = (char*)malloc(strlen(templ)+1); data/pstotext-1.9/main.c:186: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(outfile) != 0) { data/pstotext-1.9/pstotxtd.c:340: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). p += strlen(p)+1; data/pstotext-1.9/pstotxtd.c:372: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(path) && (path[strlen(path)-1] != '\\') ) data/pstotext-1.9/pstotxtd.c:372: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 ( strlen(path) && (path[strlen(path)-1] != '\\') ) data/pstotext-1.9/pstotxtd.c:373:6: [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(path, "\\"); data/pstotext-1.9/pstotxtd.c:443: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(outfile) != 0) { data/pstotext-1.9/pstotxtd.c:473:19: [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. if (path==NULL) strcpy(input, "-"); data/pstotext-1.9/ptotdll.c:718:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(t->word, t->buf, t->lbuf+1); data/pstotext-1.9/ptotdll.c:772:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(t->buf, buf, l); \ data/pstotext-1.9/ptotdll.c:822: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). int lstr = strlen(str); data/pstotext-1.9/ptotdll.c:823:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&buf[l], str, lstr); data/pstotext-1.9/ptotdll.c:847:14: [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). lstr = strlen(str); data/pstotext-1.9/ptotdll.c:848:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&buf[l], str, lstr); data/pstotext-1.9/ptotdll.c:862:20: [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 lstr = strlen(str); data/pstotext-1.9/ptotdll.c:863:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&buf[l], str, lstr); data/pstotext-1.9/ptotdll.c:869: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). int lstr = strlen(str); data/pstotext-1.9/ptotdll.c:870:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&buf[l], str, lstr); data/pstotext-1.9/ptotdll.c:919:11: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&t->buf[t->lbuf], buf, l); data/pstotext-1.9/vms.h:25: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). len = strlen(dir) + strlen(prefix) + 8; data/pstotext-1.9/vms.h:25: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 = strlen(dir) + strlen(prefix) + 8; ANALYSIS SUMMARY: Hits = 82 Lines analyzed = 2245 in approximately 0.10 seconds (22529 lines/second) Physical Source Lines of Code (SLOC) = 1784 Hits@level = [0] 63 [1] 22 [2] 36 [3] 7 [4] 17 [5] 0 Hits@level+ = [0+] 145 [1+] 82 [2+] 60 [3+] 24 [4+] 17 [5+] 0 Hits/KSLOC@level+ = [0+] 81.278 [1+] 45.9641 [2+] 33.6323 [3+] 13.4529 [4+] 9.52915 [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.