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/cowdancer-0.89/benchmarking/time-output.c Examining data/cowdancer-0.89/cow-shell.c Examining data/cowdancer-0.89/cowbuilder.c Examining data/cowdancer-0.89/cowbuilder_util.c Examining data/cowdancer-0.89/cowbuilder_util.h Examining data/cowdancer-0.89/cowdancer-ilistcreate.c Examining data/cowdancer-0.89/cowdancer-ilistdump.c Examining data/cowdancer-0.89/cowdancer.c Examining data/cowdancer-0.89/file.c Examining data/cowdancer-0.89/file.h Examining data/cowdancer-0.89/forkexec.c Examining data/cowdancer-0.89/ilist.h Examining data/cowdancer-0.89/ilistcreate.c Examining data/cowdancer-0.89/initrd/qemuinit.c Examining data/cowdancer-0.89/log.c Examining data/cowdancer-0.89/log.h Examining data/cowdancer-0.89/main.c Examining data/cowdancer-0.89/parameter.c Examining data/cowdancer-0.89/parameter.h Examining data/cowdancer-0.89/qemuarch.c Examining data/cowdancer-0.89/qemuarch.h Examining data/cowdancer-0.89/qemubuilder.c Examining data/cowdancer-0.89/qemuipsanitize.c Examining data/cowdancer-0.89/qemuipsanitize.h Examining data/cowdancer-0.89/test_cowbuilder.c Examining data/cowdancer-0.89/test_cowbuilder_util.c Examining data/cowdancer-0.89/test_file.c Examining data/cowdancer-0.89/test_forkexec.c Examining data/cowdancer-0.89/test_ilistcreate.c Examining data/cowdancer-0.89/test_parameter.c Examining data/cowdancer-0.89/test_qemuarch.c Examining data/cowdancer-0.89/test_qemuipsanitize.c Examining data/cowdancer-0.89/tests/002_test_open.c Examining data/cowdancer-0.89/tests/003_test_fopen.c Examining data/cowdancer-0.89/tests/004_test_fopen64.c Examining data/cowdancer-0.89/tests/012_test_chown.c Examining data/cowdancer-0.89/tests/013_test_chmod.c Examining data/cowdancer-0.89/tests/015_test_ilistdelete.c Examining data/cowdancer-0.89/tests/016_memleakcheck.c Examining data/cowdancer-0.89/tests/018_testcxx.cc Examining data/cowdancer-0.89/tests/021_test_open.c Examining data/cowdancer-0.89/tests/022_kernel_waitpid.c FINAL RESULTS: data/cowdancer-0.89/cowdancer.c:570:8: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. #undef chown data/cowdancer-0.89/cowdancer.c:571:5: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. int chown(const char *s, uid_t u, gid_t g) { data/cowdancer-0.89/cowdancer.c:669:8: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. #undef chmod data/cowdancer-0.89/cowdancer.c:670:5: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. int chmod(const char *s, mode_t mode) { data/cowdancer-0.89/file.c:93:6: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(dest, st.st_mode)) { data/cowdancer-0.89/ilistcreate.c:83:6: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(ilistpath, 0644)) { data/cowdancer-0.89/qemubuilder.c:188:6: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(s, 0700)) { data/cowdancer-0.89/tests/012_test_chown.c:29:2: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. chown(argv[2], uid, gid); data/cowdancer-0.89/tests/013_test_chmod.c:19:2: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(argv[1], 0400); data/cowdancer-0.89/cow-shell.c:103: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(av[1], av + 1); data/cowdancer-0.89/cow-shell.c:108:3: [4] (shell) execlp: 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. execlp(myshell, myshell, NULL); data/cowdancer-0.89/cow-shell.c:112:3: [4] (shell) execlp: 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. execlp("/bin/sh", "/bin/sh", NULL); data/cowdancer-0.89/cowbuilder.c:132:5: [4] (shell) execl: 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. execl("/bin/cp", "/bin/cp", "-a", s, backup_file, NULL); data/cowdancer-0.89/cowdancer.c:376:5: [4] (shell) execl: 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. execl("/bin/cp", "/bin/cp", "-a", canonical, backup_file, NULL); data/cowdancer-0.89/file.c:170:12: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. if (-1 == sprintf(p, "%s/%s", chroot, pathname)) { data/cowdancer-0.89/forkexec.c:60:4: [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(argv[0], (char *const *)argv); data/cowdancer-0.89/forkexec.c:139:4: [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(path, (char *const *)argv); data/cowdancer-0.89/ilistcreate.c:39:21: [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 (NULL == (inf = popen(findcommandline, "r"))) { data/cowdancer-0.89/log.c:182:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(file, format, args); data/cowdancer-0.89/log.c:195:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(file, format, args); data/cowdancer-0.89/log.h:56:23: [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. __attribute__((format(printf, 2, 3))) void data/cowdancer-0.89/log.h:61:23: [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. __attribute__((format(printf, 2, 3))) void data/cowdancer-0.89/log.h:64:23: [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. __attribute__((format(printf, 2, 0))) void data/cowdancer-0.89/parameter.c:136:6: [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. f = popen(s, "r"); data/cowdancer-0.89/qemuarch.c:105:12: [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. FILE *f = popen("dpkg --print-architecture", "r"); data/cowdancer-0.89/qemubuilder.c:632: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(argv[0], argv); data/cowdancer-0.89/qemubuilder.c:853:2: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf( data/cowdancer-0.89/qemubuilder.c:927: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(hostcommand1); data/cowdancer-0.89/qemubuilder.c:963: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(hostcommand2); data/cowdancer-0.89/qemubuilder.c:1161:2: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf( data/cowdancer-0.89/tests/022_kernel_waitpid.c:15:4: [4] (shell) execl: 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. execl("/bin/cp", "/bin/cp", "-a", "/tmp/test", "/tmp/test2", NULL); data/cowdancer-0.89/cow-shell.c:61:5: [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. getenv("LD_PRELOAD") ?: "", data/cowdancer-0.89/cow-shell.c:62:5: [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. getenv("LD_PRELOAD") ? " " : "", data/cowdancer-0.89/cow-shell.c:63:5: [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. getenv("COWDANCER_SO") ?: COWDANCER_SO); data/cowdancer-0.89/cow-shell.c:75:3: [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. getenv("COWDANCER_REUSE") && !strcmp(getenv("COWDANCER_REUSE"), "yes"); data/cowdancer-0.89/cow-shell.c:75:40: [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. getenv("COWDANCER_REUSE") && !strcmp(getenv("COWDANCER_REUSE"), "yes"); data/cowdancer-0.89/cow-shell.c:105:25: [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. const char *myshell = getenv("SHELL") ?: "/bin/sh"; data/cowdancer-0.89/cowdancer.c:72:7: [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 (!getenv("COWDANCER_ILISTFILE")) { data/cowdancer-0.89/cowdancer.c:78: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. (fd = origlibc_open(getenv("COWDANCER_ILISTFILE"), O_RDONLY, 0))) { data/cowdancer-0.89/cowdancer.c:82: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. getenv("COWDANCER_ILISTFILE")); data/cowdancer-0.89/cowdancer.c:89: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. getenv("COWDANCER_ILISTFILE")); data/cowdancer-0.89/cowdancer.c:115:9: [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. getenv("COWDANCER_ILISTFILE")); data/cowdancer-0.89/cowdancer.c:158: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. if (getenv("COWDANCER_DEBUG")) { data/cowdancer-0.89/cowdancer.c:165: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. if (getenv("COWDANCER_DEBUG")) { data/cowdancer-0.89/cowdancer.c:219:7: [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 (getenv("COWDANCER_DEBUG")) { data/cowdancer-0.89/cowdancer.c:310: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. if (getenv("COWDANCER_DEBUG")) { data/cowdancer-0.89/cowdancer.c:452:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:479:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:501:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:518:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:541:7: [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 (!getenv("COWDANCER_IGNORE") && likely_fopen_write(t)) { data/cowdancer-0.89/cowdancer.c:559:7: [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 (!getenv("COWDANCER_IGNORE") && likely_fopen_write(t)) { data/cowdancer-0.89/cowdancer.c:577:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:638:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:657:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:676:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:694:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/cowdancer.c:712:7: [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 (!getenv("COWDANCER_IGNORE")) { data/cowdancer-0.89/file.c:158:37: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. int mknod_inside_chroot(const char *chroot, data/cowdancer-0.89/file.c:162:26: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. char *p = alloca(strlen(chroot) + strlen(pathname) + 2); data/cowdancer-0.89/file.c:170:32: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (-1 == sprintf(p, "%s/%s", chroot, pathname)) { data/cowdancer-0.89/file.h:27:37: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. int mknod_inside_chroot(const char *chroot, data/cowdancer-0.89/ilistcreate.c:49:7: [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 (getenv("COWDANCER_DEBUG")) { data/cowdancer-0.89/initrd/qemuinit.c:154:6: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (chroot("root/")) { data/cowdancer-0.89/log.c:45:9: [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. term = getenv("TERM"); data/cowdancer-0.89/parameter.c:505:14: [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. while ((c = getopt_long(ac, av, "b:B:c:hv", long_options, &index_point)) != data/cowdancer-0.89/parameter.c:779:26: [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. const char *sudo_uid = getenv("SUDO_UID"); data/cowdancer-0.89/parameter.c:786:26: [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. const char *sudo_gid = getenv("SUDO_GID"); data/cowdancer-0.89/qemubuilder.c:502:11: [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. term = getenv("TERM"); data/cowdancer-0.89/test_file.c:35:4: [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. (getenv("FAKEROOTKEY") && strcmp(getenv("FAKEROOTKEY"), ""))) { data/cowdancer-0.89/test_file.c:35:36: [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. (getenv("FAKEROOTKEY") && strcmp(getenv("FAKEROOTKEY"), ""))) { data/cowdancer-0.89/test_qemuarch.c:41:4: [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. (getenv("FAKEROOTKEY") && strcmp(getenv("FAKEROOTKEY"), ""))) { data/cowdancer-0.89/test_qemuarch.c:41:36: [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. (getenv("FAKEROOTKEY") && strcmp(getenv("FAKEROOTKEY"), ""))) { data/cowdancer-0.89/benchmarking/time-output.c:28: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 b[4096]; data/cowdancer-0.89/benchmarking/time-output.c:33: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(argv[1], "w"); data/cowdancer-0.89/cowdancer-ilistdump.c:32: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(argv[1], "r"); data/cowdancer-0.89/cowdancer.c:348:15: [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). close(ret = mkstemp(backup_file)); data/cowdancer-0.89/cowdancer.c:440:5: [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). int open(const char *a, int flags, ...) { data/cowdancer-0.89/cowdancer.c:534: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). #undef fopen data/cowdancer-0.89/cowdancer.c:535: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). FILE *fopen(const char *s, const char *t) { data/cowdancer-0.89/file.c:62:19: [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). if (-1 == (fin = open(orig, O_RDONLY))) { data/cowdancer-0.89/forkexec.c:101:8: [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 *argv[1024]; data/cowdancer-0.89/ilistcreate.c:77:22: [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 (NULL == (outf = fopen(ilistpath, "w"))) { data/cowdancer-0.89/initrd/qemuinit.c:32:11: [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). int fd = open("/proc/cmdline", O_RDONLY); data/cowdancer-0.89/initrd/qemuinit.c:33: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[BUFSIZ]; data/cowdancer-0.89/parameter.c:49: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 *pbuildercommandline[MAXPBUILDERCOMMANDLINE]; data/cowdancer-0.89/parameter.c:67: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 *debootstrap_command_line[MAX_DEBOOTSTRAP_COMMAND_LINE]; data/cowdancer-0.89/parameter.c:169:23: [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). pc->memory_megs = atoi(delim); data/cowdancer-0.89/parameter.c:209:26: [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). pc->buildresultuid = atoi(delim); data/cowdancer-0.89/parameter.c:211:26: [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). pc->buildresultgid = atoi(delim); data/cowdancer-0.89/parameter.c:781: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). pc.buildresultuid = atoi(sudo_uid); data/cowdancer-0.89/parameter.c:788: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). pc.buildresultgid = atoi(sudo_gid); data/cowdancer-0.89/parameter.h:64: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 *inputfile[MAX_CUSTOM_FILES + 1]; data/cowdancer-0.89/parameter.h:65: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 *outputfile[MAX_CUSTOM_FILES + 1]; data/cowdancer-0.89/parameter.h:119:8: [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. extern char *pbuildercommandline[MAXPBUILDERCOMMANDLINE]; data/cowdancer-0.89/parameter.h:150:8: [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. extern char *debootstrap_command_line[MAX_DEBOOTSTRAP_COMMAND_LINE]; data/cowdancer-0.89/qemubuilder.c:185:12: [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 (!(f = fopen(s, "w"))) { data/cowdancer-0.89/qemubuilder.c:452:19: [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). exit_code = atoi(matchptr + strlen(qemu_keyword)); data/cowdancer-0.89/qemubuilder.c:497: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 *argv[MAX_ARGS]; data/cowdancer-0.89/qemubuilder.c:995:12: [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). FILE *f = fopen(dscfile, "r"); data/cowdancer-0.89/test_cowbuilder.c:23: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). close(mkstemp(temp)); data/cowdancer-0.89/test_cowbuilder.c:24: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). close(mkstemp(temp2)); data/cowdancer-0.89/test_cowbuilder_util.c:32: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 dest[256]; data/cowdancer-0.89/test_cowbuilder_util.c:49: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(dest, "-some-string+g"); data/cowdancer-0.89/test_file.c:14:2: [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). mkstemp(temp); data/cowdancer-0.89/test_file.c:22:2: [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). mkstemp(temp); data/cowdancer-0.89/test_parameter.c:44: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 *test[32]; data/cowdancer-0.89/tests/002_test_open.c:20:6: [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). a = open(argv[1], O_RDONLY); data/cowdancer-0.89/tests/002_test_open.c:21:6: [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). b = open(argv[2], O_WRONLY); data/cowdancer-0.89/tests/002_test_open.c:22:6: [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). c = open(argv[3], O_RDWR); data/cowdancer-0.89/tests/003_test_fopen.c:17: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). writeandclose(fopen(argv[1], "r")); data/cowdancer-0.89/tests/003_test_fopen.c:18: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). writeandclose(fopen(argv[2], "w")); data/cowdancer-0.89/tests/003_test_fopen.c:19: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). writeandclose(fopen(argv[3], "a")); data/cowdancer-0.89/tests/004_test_fopen64.c:17: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). writeandclose(fopen(argv[1], "r")); data/cowdancer-0.89/tests/004_test_fopen64.c:18: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). writeandclose(fopen(argv[2], "w")); data/cowdancer-0.89/tests/004_test_fopen64.c:19: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). writeandclose(fopen(argv[3], "a")); data/cowdancer-0.89/tests/012_test_chown.c:26: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). gid = atoi(argv[1]); /* get the gid to change to */ data/cowdancer-0.89/tests/013_test_chmod.c:20:8: [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). fid = open(argv[2], O_RDONLY); data/cowdancer-0.89/tests/015_test_ilistdelete.c:30: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). if (-1 == (fd = open("a", O_WRONLY))) { data/cowdancer-0.89/tests/016_memleakcheck.c:33:12: [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 (!(f = fopen(p, "r"))) { data/cowdancer-0.89/tests/016_memleakcheck.c:52: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). if (-1 == (fd = open("1/a", O_WRONLY))) { data/cowdancer-0.89/tests/016_memleakcheck.c:70:19: [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). if (-1 == (fd = open("1/b", O_WRONLY))) { data/cowdancer-0.89/tests/016_memleakcheck.c:84: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 (!(f = fopen("1/c", "w"))) { data/cowdancer-0.89/tests/021_test_open.c:19:8: [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). fd1 = open(av[1], O_RDONLY); data/cowdancer-0.89/tests/021_test_open.c:21:8: [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). fd2 = open(av[1], O_RDONLY); data/cowdancer-0.89/file.c:70:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((count = read(fin, buf, buffer_size)) > 0) { data/cowdancer-0.89/file.c:162: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). char *p = alloca(strlen(chroot) + strlen(pathname) + 2); data/cowdancer-0.89/file.c:162: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 *p = alloca(strlen(chroot) + strlen(pathname) + 2); data/cowdancer-0.89/initrd/qemuinit.c:34:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int len = read(fd, buf, sizeof(buf) - 1); data/cowdancer-0.89/initrd/qemuinit.c:45: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). if (!strncmp(option, s, strlen(option)) && s[strlen(option)] == '=') { data/cowdancer-0.89/initrd/qemuinit.c:45:48: [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(option, s, strlen(option)) && s[strlen(option)] == '=') { data/cowdancer-0.89/initrd/qemuinit.c:80:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(S_IWGRP | S_IWOTH); data/cowdancer-0.89/parameter.c:93: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). size_t len = strlen(p); data/cowdancer-0.89/parameter.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). assert(strlen(ret) == len - 1); data/cowdancer-0.89/parameter.c:757: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). int len = strlen(buildplace_); data/cowdancer-0.89/qemubuilder.c:170: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). for (c = s + strlen(mountpoint) + 1; *c; ++c) { data/cowdancer-0.89/qemubuilder.c:236: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). int trailing_slash = targetdir[strlen(targetdir) - 1] == '/'; data/cowdancer-0.89/qemubuilder.c:383: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). int file_len = strlen(file); data/cowdancer-0.89/qemubuilder.c:388: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). int ext_len = strlen(ext); data/cowdancer-0.89/qemubuilder.c:444:6: [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(100000); data/cowdancer-0.89/qemubuilder.c:446:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). count = read(sp[0], buf, buffer_size); data/cowdancer-0.89/qemubuilder.c:450:35: [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). buf, count, qemu_keyword, strlen(qemu_keyword))) != data/cowdancer-0.89/qemubuilder.c:452:35: [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). exit_code = atoi(matchptr + strlen(qemu_keyword)); data/cowdancer-0.89/test_cowbuilder_util.c:52: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). assert(strlen(dest) == 12); data/cowdancer-0.89/test_file.c:42:3: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(S_IWOTH); data/cowdancer-0.89/test_qemuarch.c:47:3: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(S_IWOTH); data/cowdancer-0.89/tests/016_memleakcheck.c:38:21: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (EOF != (c = fgetc(f))) { ANALYSIS SUMMARY: Hits = 147 Lines analyzed = 6284 in approximately 0.24 seconds (25766 lines/second) Physical Source Lines of Code (SLOC) = 4616 Hits@level = [0] 51 [1] 22 [2] 52 [3] 42 [4] 22 [5] 9 Hits@level+ = [0+] 198 [1+] 147 [2+] 125 [3+] 73 [4+] 31 [5+] 9 Hits/KSLOC@level+ = [0+] 42.8943 [1+] 31.8458 [2+] 27.0797 [3+] 15.8146 [4+] 6.71577 [5+] 1.94974 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.