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/procenv-0.50/src/messages.h Examining data/procenv-0.50/src/output.c Examining data/procenv-0.50/src/output.h Examining data/procenv-0.50/src/platform-headers.h Examining data/procenv-0.50/src/platform.h Examining data/procenv-0.50/src/platform/android/platform.c Examining data/procenv-0.50/src/platform/darwin/platform-darwin.h Examining data/procenv-0.50/src/platform/darwin/platform.c Examining data/procenv-0.50/src/platform/freebsd/platform-freebsd.h Examining data/procenv-0.50/src/platform/freebsd/platform.c Examining data/procenv-0.50/src/platform/hurd/platform-hurd.h Examining data/procenv-0.50/src/platform/hurd/platform.c Examining data/procenv-0.50/src/platform/linux/platform-linux.h Examining data/procenv-0.50/src/platform/linux/platform.c Examining data/procenv-0.50/src/platform/minix/platform-minix.h Examining data/procenv-0.50/src/platform/minix/platform.c Examining data/procenv-0.50/src/platform/netbsd/platform-netbsd.h Examining data/procenv-0.50/src/platform/netbsd/platform.c Examining data/procenv-0.50/src/platform/openbsd/platform-openbsd.h Examining data/procenv-0.50/src/platform/openbsd/platform.c Examining data/procenv-0.50/src/platform/platform-generic.c Examining data/procenv-0.50/src/platform/platform-generic.h Examining data/procenv-0.50/src/platform/unknown/platform-unknown.h Examining data/procenv-0.50/src/platform/unknown/platform.c Examining data/procenv-0.50/src/pr_list.c Examining data/procenv-0.50/src/pr_list.h Examining data/procenv-0.50/src/procenv.h Examining data/procenv-0.50/src/pstring.c Examining data/procenv-0.50/src/pstring.h Examining data/procenv-0.50/src/string-util.c Examining data/procenv-0.50/src/string-util.h Examining data/procenv-0.50/src/tests/check_pr_list.c Examining data/procenv-0.50/src/types.h Examining data/procenv-0.50/src/util.c Examining data/procenv-0.50/src/util.h Examining data/procenv-0.50/src/procenv.c FINAL RESULTS: data/procenv-0.50/src/platform/linux/platform.c:534:9: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. len = readlink (path, link, sizeof (link)-1); data/procenv-0.50/src/platform/linux/platform.c:601:9: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. len = readlink (path, link, sizeof (link)-1); data/procenv-0.50/src/platform/platform-generic.c:827:10: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. bytes = readlink (path, canonical, len); data/procenv-0.50/src/output.c:1986:11: [4] (format) swprintf: Potential format string problem (CWE-134). Make format string constant. ret = swprintf (q, data/procenv-0.50/src/platform/freebsd/platform.c:127: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 (user->proc_name, proc->ki_comm); data/procenv-0.50/src/platform/linux/platform.c:531:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (path, "%s/%s", prefix_path, ent->d_name); data/procenv-0.50/src/platform/linux/platform.c:599:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (path, "%s/%s", prefix_path, ent->d_name); data/procenv-0.50/src/platform/linux/platform.c:668:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. ret = sprintf (path, "%s/%s", dir, *file); data/procenv-0.50/src/platform/linux/platform.c:828:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (formatted_stime, "%s", NA_STR); data/procenv-0.50/src/platform/linux/platform.c:834:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (formatted_rtime, "%s", NA_STR); data/procenv-0.50/src/platform/linux/platform.c:840:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (formatted_ctime, "%s", NA_STR); data/procenv-0.50/src/platform/linux/platform.c:1252:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (path, "/proc/%s/status", pid); data/procenv-0.50/src/platform/linux/platform.c:1266:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (name, "%s", p); data/procenv-0.50/src/platform/linux/platform.c:1271:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (ppid, "%s", p); data/procenv-0.50/src/platform/linux/platform.c:1289:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (pid, "%s", ppid); data/procenv-0.50/src/platform/linux/platform.c:1419:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (formatted_otime, "%s", NA_STR); data/procenv-0.50/src/platform/linux/platform.c:1716: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 (user->proc_name, UNKNOWN_STR); data/procenv-0.50/src/platform/platform-generic.c:692: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 (str, opt->name); data/procenv-0.50/src/platform/platform-generic.c:829:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf (canonical, UNKNOWN_STR); data/procenv-0.50/src/procenv.c:1496: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 (copy[i], env[i]); data/procenv-0.50/src/procenv.c:1581:15: [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. user.login = getlogin (); data/procenv-0.50/src/procenv.c:2016:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf ((char *)name, "%s", NA_STR); data/procenv-0.50/src/procenv.c:2019:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf ((char *)name, "%s", UNKNOWN_STR); data/procenv-0.50/src/procenv.c:2024:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf ((char *)name, "%s", NA_STR); data/procenv-0.50/src/procenv.c:3734:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (possible, "%s%s%s", data/procenv-0.50/src/procenv.c:3874:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf (data_model, UNKNOWN_STR); data/procenv-0.50/src/procenv.c:4242:3: [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 (exec_args[0], exec_args); data/procenv-0.50/src/string-util.c:285:9: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. ret = vsnprintf (new, len, fmt, ap_copy); data/procenv-0.50/src/string-util.c:350:9: [4] (format) vswprintf: Potential format string problem (CWE-134). Make format string constant. ret = vswprintf (new, len, fmt, ap_copy); data/procenv-0.50/src/procenv.c:1870:8: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if (! realpath (tmp, real_path)) data/procenv-0.50/src/procenv.c:2614: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. v = getenv ("LANG"); data/procenv-0.50/src/procenv.c:2617: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. v = getenv ("LANGUAGE"); data/procenv-0.50/src/procenv.c:2632: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. v = getenv ("LC_ALL"); data/procenv-0.50/src/procenv.c:3549: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. e = getenv (PROCENV_OUTPUT_ENV); data/procenv-0.50/src/procenv.c:3554: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. e = getenv (PROCENV_FILE_ENV); data/procenv-0.50/src/procenv.c:3560: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. e = getenv (PROCENV_FILE_APPEND_ENV); data/procenv-0.50/src/procenv.c:3565: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. e = getenv (PROCENV_FORMAT_ENV); data/procenv-0.50/src/procenv.c:3570: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. e = getenv (PROCENV_INDENT_ENV); data/procenv-0.50/src/procenv.c:3575: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. e = getenv (PROCENV_INDENT_CHAR_ENV); data/procenv-0.50/src/procenv.c:3584: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. e = getenv (PROCENV_SEPARATOR_ENV); data/procenv-0.50/src/procenv.c:3589: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. e = getenv (PROCENV_CRUMB_SEPARATOR_ENV); data/procenv-0.50/src/procenv.c:3598: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. e = getenv (PROCENV_EXEC_ENV); data/procenv-0.50/src/procenv.c:3725: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. tmp = getenv ("PATH"); data/procenv-0.50/src/procenv.c:3963:12: [3] (buffer) getopt_long: 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. option = getopt_long (argc, argv, data/procenv-0.50/src/output.c:715: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). output_fd = open (output_file, flags, data/procenv-0.50/src/platform.h:69: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 proc_name[PROCENV_PR_GET_NAME_LEN]; data/procenv-0.50/src/platform.h:73: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 ctrl_terminal[L_ctermid]; data/procenv-0.50/src/platform.h:90: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 cwd[PATH_MAX]; data/procenv-0.50/src/platform.h:91: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 root[PATH_MAX]; data/procenv-0.50/src/platform/freebsd/platform.c:110: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 errors[_POSIX2_LINE_MAX]; data/procenv-0.50/src/platform/freebsd/platform.c:300: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 errors[_POSIX2_LINE_MAX]; data/procenv-0.50/src/platform/freebsd/platform.c:329: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 errors[_POSIX2_LINE_MAX]; data/procenv-0.50/src/platform/linux/platform.c:235: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 path[PATH_MAX]; data/procenv-0.50/src/platform/linux/platform.c:239:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (path, "/proc/%d/cmdline", (int)pid); data/procenv-0.50/src/platform/linux/platform.c:241:6: [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, "r"); data/procenv-0.50/src/platform/linux/platform.c:447: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 buffer[1024]; data/procenv-0.50/src/platform/linux/platform.c:450:6: [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 (file, "r"); data/procenv-0.50/src/platform/linux/platform.c:516: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 path[MAXPATHLEN]; data/procenv-0.50/src/platform/linux/platform.c:517: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 link[MAXPATHLEN]; data/procenv-0.50/src/platform/linux/platform.c:532:8: [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). fd = atoi (ent->d_name); data/procenv-0.50/src/platform/linux/platform.c:581: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 path[MAXPATHLEN]; data/procenv-0.50/src/platform/linux/platform.c:582: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 link[MAXPATHLEN]; data/procenv-0.50/src/platform/linux/platform.c:661: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 buffer[PROCENV_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:662: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 path[PATH_MAX]; data/procenv-0.50/src/platform/linux/platform.c:672: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, "r"); data/procenv-0.50/src/platform/linux/platform.c:701: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 buffer[1024]; data/procenv-0.50/src/platform/linux/platform.c:705:6: [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 ("/proc/self/stat", "r"); data/procenv-0.50/src/platform/linux/platform.c:728:8: [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). cpu = atoi (field); data/procenv-0.50/src/platform/linux/platform.c:781: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 formatted_stime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:782: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 formatted_rtime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:783: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 formatted_ctime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:913: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 name[17] = { 0 }; data/procenv-0.50/src/platform/linux/platform.c:1238: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 buffer[1024]; data/procenv-0.50/src/platform/linux/platform.c:1239: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 path[PATH_MAX]; data/procenv-0.50/src/platform/linux/platform.c:1240: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 name[16]; data/procenv-0.50/src/platform/linux/platform.c:1241: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 pid[16]; data/procenv-0.50/src/platform/linux/platform.c:1242: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 ppid[16]; data/procenv-0.50/src/platform/linux/platform.c:1248:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (pid, "%d", (int)getpid ()); data/procenv-0.50/src/platform/linux/platform.c:1254: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, "r"); data/procenv-0.50/src/platform/linux/platform.c:1368: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 formatted_otime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:1369: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 formatted_ctime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:1481: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 formatted_atime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:1482: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 formatted_ctime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:1483: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 formatted_dtime[CTIME_BUFFER]; data/procenv-0.50/src/platform/linux/platform.c:2138: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 buffer[1024]; data/procenv-0.50/src/platform/linux/platform.c:2140:6: [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 (cpuinfo, "r"); data/procenv-0.50/src/platform/netbsd/platform.c:108: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 errors[_POSIX2_LINE_MAX]; data/procenv-0.50/src/platform/openbsd/platform.c:109: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 errors[_POSIX2_LINE_MAX]; data/procenv-0.50/src/platform/platform-generic.c:847: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 canonical[PATH_MAX]; data/procenv-0.50/src/platform/platform-generic.c:849: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). mtab = fopen (MOUNTS, "r"); data/procenv-0.50/src/procenv.c:1585:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (user.ctrl_terminal, "/dev/tty"); data/procenv-0.50/src/procenv.c:1601:16: [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). user.tty_fd = open (user.ctrl_terminal, O_RDWR); data/procenv-0.50/src/procenv.c:1612: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. p = memcpy (&user.passwd, pw, sizeof (struct passwd)); data/procenv-0.50/src/procenv.c:1856: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 real_path[PATH_MAX]; data/procenv-0.50/src/procenv.c:1857: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 formatted_atime[32]; data/procenv-0.50/src/procenv.c:1858: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 formatted_ctime[32]; data/procenv-0.50/src/procenv.c:1859: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 formatted_mtime[32]; data/procenv-0.50/src/procenv.c:2152:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (mac_address, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", data/procenv-0.50/src/procenv.c:2253: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 address[NI_MAXHOST]; data/procenv-0.50/src/procenv.c:3444: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 formatted_time[CTIME_BUFFER]; data/procenv-0.50/src/procenv.c:3572:22: [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). set_indent_amount (atoi (e)); data/procenv-0.50/src/procenv.c:3687: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 possible[PATH_MAX]; data/procenv-0.50/src/procenv.c:3698: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 cwd[PATH_MAX]; data/procenv-0.50/src/procenv.c:3854: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 data_model[16]; data/procenv-0.50/src/procenv.c:3864:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (data_model, "LP32"); data/procenv-0.50/src/procenv.c:3866:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (data_model, "ILP32"); data/procenv-0.50/src/procenv.c:3868:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (data_model, "LLP64"); data/procenv-0.50/src/procenv.c:3870:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (data_model, "LP64"); data/procenv-0.50/src/procenv.c:3872:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (data_model, "ILP64"); data/procenv-0.50/src/procenv.c:3999:24: [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). set_indent_amount (atoi (optarg)); data/procenv-0.50/src/procenv.c:4490: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 (&node->ifaddr, ifa, sizeof (struct ifaddrs)); data/procenv-0.50/src/tests/check_pr_list.c:55: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 buffer[8]; data/procenv-0.50/src/util.c:110:7: [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). fd = open ("/dev/tty", O_RDONLY | O_NOCTTY); data/procenv-0.50/src/util.c:137: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 buffer[1024]; data/procenv-0.50/src/util.c:163:6: [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 ("/proc/self/status", "r"); data/procenv-0.50/src/output.c:698: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). ret = write (user.tty_fd, str, strlen (str)); data/procenv-0.50/src/output.c:723:33: [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). ret = write (output_fd, str, strlen (str)); data/procenv-0.50/src/output.c:878:43: [1] (buffer) wcslen: 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). wmemset (buffer->buf, wide_indent_char, wcslen (buffer->buf)); data/procenv-0.50/src/output.c:1737:15: [1] (buffer) wcslen: 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). extra += (wcslen (table->map[i].to) - 1); data/procenv-0.50/src/output.c:1803:4: [1] (buffer) wcsncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, or automatically resizing strings. wcsncat (result->buf + result->len, start, amount); data/procenv-0.50/src/output.c:1808:10: [1] (buffer) wcslen: 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 = wcslen (to); data/procenv-0.50/src/output.c:1809:4: [1] (buffer) wcsncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, or automatically resizing strings. wcsncat (result->buf + result->len, to, len); data/procenv-0.50/src/output.c:1822:2: [1] (buffer) wcsncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, or automatically resizing strings. wcsncat (result->buf + result->len, start, amount); data/procenv-0.50/src/output.c:1954:58: [1] (buffer) wcslen: 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). new_size = (len - non_printables) + (non_printables * wcslen (L"&#x..;")); data/procenv-0.50/src/output.c:1958:58: [1] (buffer) wcslen: 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). new_size = (len - non_printables) + (non_printables * wcslen (L"\\u....")); data/procenv-0.50/src/output.c:1996:14: [1] (buffer) wcslen: 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). new->len = wcslen (new->buf) + 1; data/procenv-0.50/src/platform/linux/platform.c:461: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 (buffer); data/procenv-0.50/src/platform/linux/platform.c:679: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 (buffer); data/procenv-0.50/src/platform/linux/platform.c:714: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). len = strlen (buffer); data/procenv-0.50/src/platform/linux/platform.c:1261: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 (buffer); data/procenv-0.50/src/platform/linux/platform.c:1265: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). p += 1+strlen ("Name:"); /* jump over tab char */ data/procenv-0.50/src/platform/linux/platform.c:1270: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). p += 1+strlen ("PPid:"); /* jump over tab char */ data/procenv-0.50/src/platform/linux/platform.c:2023:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (ifr.ifr_name, interface, IFNAMSIZ-1); data/procenv-0.50/src/platform/platform-generic.c:120:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (ifr.ifr_name, ifaddr->ifa_name, IFNAMSIZ-1); data/procenv-0.50/src/platform/platform-generic.c:670: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). len += strlen (opt->name); data/procenv-0.50/src/platform/platform-generic.c:694: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 (str, ","); data/procenv-0.50/src/pr_list.c:102: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). len = strlen (str); data/procenv-0.50/src/pr_list.c:181: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). len = strlen (str); data/procenv-0.50/src/procenv.c:1252:21: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). misc.umask_value = umask (S_IWGRP|S_IWOTH); data/procenv-0.50/src/procenv.c:1253:8: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). (void)umask (misc.umask_value); data/procenv-0.50/src/procenv.c:1493: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). copy[i] = calloc (1, 1+strlen (env[i])); data/procenv-0.50/src/procenv.c:1922: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). formatted_atime[ strlen (formatted_atime)-1] = '\0'; data/procenv-0.50/src/procenv.c:1928: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). formatted_mtime[ strlen (formatted_mtime)-1] = '\0'; data/procenv-0.50/src/procenv.c:1934: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). formatted_ctime[ strlen (formatted_ctime)-1] = '\0'; data/procenv-0.50/src/procenv.c:2119:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (ifr.ifr_name, ifaddr->ifa_name, IFNAMSIZ-1); data/procenv-0.50/src/procenv.c:3462:17: [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). formatted_time[strlen (formatted_time)-1] = '\0'; data/procenv-0.50/src/procenv.c:3708: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 (cwd); data/procenv-0.50/src/procenv.c:3712:3: [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. Risk is low because the source is a constant character. strncat (cwd, "/", bytes); data/procenv-0.50/src/procenv.c:3714: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). bytes -= strlen ("/"); data/procenv-0.50/src/procenv.c:3716:3: [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 (cwd, argv0, bytes); data/procenv-0.50/src/procenv.c:3736: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). element [strlen (element)-1] == '/' ? "" : "/", data/procenv-0.50/src/procenv.c:4334: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). l = strlen (str); data/procenv-0.50/src/procenv.c:4340:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (buffer, str, len); data/procenv-0.50/src/procenv.c:4343: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). buffer[strlen (str)-1] = '\0'; data/procenv-0.50/src/pstring.c:71:8: [1] (buffer) wcslen: 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 = wcslen (wstr); data/procenv-0.50/src/pstring.c:132:18: [1] (buffer) wcslen: 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). pstr->len = 1 + wcslen (pstr->buf); data/procenv-0.50/src/string-util.c:30: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). len = strlen (src); data/procenv-0.50/src/string-util.c:44:8: [1] (buffer) wcslen: 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 = wcslen (src); data/procenv-0.50/src/string-util.c:96: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). total = strlen (*dest) + 1; data/procenv-0.50/src/string-util.c:111:2: [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 (*dest, src, len); data/procenv-0.50/src/string-util.c:158:2: [1] (buffer) wcsncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, or automatically resizing strings. wcsncat ((*dest)->buf + (*dest)->len, src, len); data/procenv-0.50/src/string-util.c:186:28: [1] (buffer) wcslen: 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). wappendn (dest, wide_src, wcslen (wide_src)); data/procenv-0.50/src/string-util.c:468:2: [1] (buffer) wcsncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, or automatically resizing strings. wcsncat ((*dest)->buf + (*dest)->len, src->buf, src->len); data/procenv-0.50/src/util.c:168: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). size_t len = strlen (buffer); ANALYSIS SUMMARY: Hits = 164 Lines analyzed = 16229 in approximately 0.35 seconds (45999 lines/second) Physical Source Lines of Code (SLOC) = 10892 Hits@level = [0] 8 [1] 49 [2] 71 [3] 15 [4] 26 [5] 3 Hits@level+ = [0+] 172 [1+] 164 [2+] 115 [3+] 44 [4+] 29 [5+] 3 Hits/KSLOC@level+ = [0+] 15.7914 [1+] 15.0569 [2+] 10.5582 [3+] 4.03966 [4+] 2.6625 [5+] 0.275432 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.