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/sbd-1.4.1/src/sbd-cluster.c Examining data/sbd-1.4.1/src/sbd-common.c Examining data/sbd-1.4.1/src/sbd-inquisitor.c Examining data/sbd-1.4.1/src/sbd-md.c Examining data/sbd-1.4.1/src/sbd-pacemaker.c Examining data/sbd-1.4.1/src/sbd.h Examining data/sbd-1.4.1/src/setproctitle.c Examining data/sbd-1.4.1/tests/sbd-testbed.c FINAL RESULTS: data/sbd-1.4.1/src/sbd-cluster.c:467:12: [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. if(readlink(proc_path, exe_path, PATH_MAX - 1) < 0) { data/sbd-1.4.1/src/sbd-cluster.c:490:14: [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. rc = readlink(proc_path, exe_path, PATH_MAX - 1); data/sbd-1.4.1/src/sbd-common.c:340:11: [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(entry_name, buf, sizeof(buf) - 1); data/sbd-1.4.1/src/sbd-common.c:406:14: [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(entry_name, buf, sizeof(buf) - 1); data/sbd-1.4.1/src/sbd-inquisitor.c:261:7: [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. rc = readlink(proc_path, exe_path, PATH_MAX-1); data/sbd-1.4.1/src/sbd-inquisitor.c:269:7: [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. rc = readlink(proc_path, myexe_path, PATH_MAX-1); data/sbd-1.4.1/src/sbd-cluster.c:414:5: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(procpath, entry->d_name); data/sbd-1.4.1/src/sbd-common.c:300:5: [4] (format) snprintf: 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. snprintf(entry_name, sizeof(entry_name), data/sbd-1.4.1/src/sbd-common.c:327:5: [4] (format) snprintf: 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. snprintf(entry_name, sizeof(entry_name), data/sbd-1.4.1/src/sbd-common.c:373:5: [4] (format) snprintf: 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. snprintf(entry_name, sizeof(entry_name), data/sbd-1.4.1/src/sbd-common.c:403:8: [4] (format) snprintf: 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. snprintf(entry_name, sizeof(entry_name), data/sbd-1.4.1/src/setproctitle.c:178:3: [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. vsnprintf(statbuf, sizeof(statbuf), fmt, msg); data/sbd-1.4.1/src/setproctitle.c:182:3: [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. vsnprintf(statbuf + strlen(statbuf), sizeof(statbuf) - strlen(statbuf), data/sbd-1.4.1/src/setproctitle.c:190:3: [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. vsnprintf(statbuf + strlen(statbuf), sizeof(statbuf) - strlen(statbuf), data/sbd-1.4.1/tests/sbd-testbed.c:518:1: [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(FILE *stream, const char *format, ...) data/sbd-1.4.1/tests/sbd-testbed.c:529:14: [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. rv = vsnprintf(buf, sizeof(buf), format, ap); data/sbd-1.4.1/tests/sbd-testbed.c:541:14: [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. rv = vfprintf(stream, format, ap); data/sbd-1.4.1/tests/sbd-testbed.c:548:1: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. fscanf(FILE *stream, const char *format, ...) data/sbd-1.4.1/tests/sbd-testbed.c:555:10: [4] (buffer) vfscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. rv = vfscanf(stream, format, ap); data/sbd-1.4.1/src/sbd-inquisitor.c:889:17: [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. value = getenv("SBD_PACEMAKER"); data/sbd-1.4.1/src/sbd-inquisitor.c:896:17: [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. value = getenv("SBD_STARTMODE"); data/sbd-1.4.1/src/sbd-inquisitor.c:905:17: [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. value = getenv("SBD_WATCHDOG_DEV"); data/sbd-1.4.1/src/sbd-inquisitor.c:914:17: [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. value = getenv("SBD_WATCHDOG"); data/sbd-1.4.1/src/sbd-inquisitor.c:919:17: [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. value = getenv("SBD_WATCHDOG_TIMEOUT"); data/sbd-1.4.1/src/sbd-inquisitor.c:927:17: [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. value = getenv("SBD_PIDFILE"); data/sbd-1.4.1/src/sbd-inquisitor.c:933:17: [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. value = getenv("SBD_DELAY_START"); data/sbd-1.4.1/src/sbd-inquisitor.c:949:17: [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. value = getenv("SBD_TIMEOUT_ACTION"); data/sbd-1.4.1/src/sbd-inquisitor.c:954:17: [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. value = getenv("SBD_MOVE_TO_ROOT_CGROUP"); data/sbd-1.4.1/src/sbd-inquisitor.c:967:14: [3] (buffer) getopt: 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(argc, argv, "czC:DPRTWZhvw:d:n:p:1:2:3:4:5:t:I:F:S:s:r:")) != -1) { data/sbd-1.4.1/src/sbd-inquisitor.c:1104:17: [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. value = getenv("SBD_DEVICE"); data/sbd-1.4.1/tests/sbd-testbed.c:166:17: [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. value = getenv("SBD_PRELOAD_LOG"); data/sbd-1.4.1/tests/sbd-testbed.c:179:17: [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. value = getenv("SBD_WATCHDOG_DEV"); data/sbd-1.4.1/tests/sbd-testbed.c:184:17: [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. value = getenv("SBD_DEVICE"); data/sbd-1.4.1/tests/sbd-testbed.c:196:17: [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. value = getenv("SBD_TRANSLATE_AIO"); data/sbd-1.4.1/src/sbd-cluster.c:397:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char procpath[128] = { 0 }; data/sbd-1.4.1/src/sbd-cluster.c:404:17: [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). local_pid = atoi(entry->d_name); data/sbd-1.4.1/src/sbd-cluster.c:413:5: [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(procpath, "/proc/"); data/sbd-1.4.1/src/sbd-cluster.c:415:10: [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(procpath, O_RDONLY); data/sbd-1.4.1/src/sbd-cluster.c:435:9: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(procpath, "/status"); data/sbd-1.4.1/src/sbd-cluster.c:436: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). file = fopen(procpath, "r"); data/sbd-1.4.1/src/sbd-cluster.c:461:9: [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_path[PATH_MAX], exe_path[PATH_MAX]; data/sbd-1.4.1/src/sbd-cluster.c:485:9: [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_path[PATH_MAX], exe_path[PATH_MAX]; data/sbd-1.4.1/src/sbd-cluster.c:527:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char entry_name[16]; data/sbd-1.4.1/src/sbd-common.c:179:9: [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). wdfd = open(wddev, O_WRONLY); data/sbd-1.4.1/src/sbd-common.c:284: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 entry_name[280]; data/sbd-1.4.1/src/sbd-common.c:286: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[280] = ""; data/sbd-1.4.1/src/sbd-common.c:302: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 = fopen(entry_name, "r"); data/sbd-1.4.1/src/sbd-common.c:348: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. memcpy(buf, WATCHDOG_NODEDIR, WATCHDOG_NODEDIR_LEN); data/sbd-1.4.1/src/sbd-common.c:500: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 buffer[16]; data/sbd-1.4.1/src/sbd-common.c:575:14: [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. unsigned char buf[1024]; data/sbd-1.4.1/src/sbd-common.c:669:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fname[PATH_MAX]; data/sbd-1.4.1/src/sbd-common.c:674:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen(fname, "rt"); data/sbd-1.4.1/src/sbd-common.c:702:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen(fname, "rt"); data/sbd-1.4.1/src/sbd-common.c:734:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen("/sys/fs/cgroup/cpu/cpu.rt_runtime_us", "rt"); data/sbd-1.4.1/src/sbd-common.c:750:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen("/sys/fs/cgroup/cpu/tasks", "w"); data/sbd-1.4.1/src/sbd-common.c:842:10: [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). procf = fopen("/proc/sys/kernel/sysrq", "r"); data/sbd-1.4.1/src/sbd-common.c:857:10: [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). procf = fopen("/proc/sys/kernel/sysrq", "w"); data/sbd-1.4.1/src/sbd-common.c:872:10: [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). procf = fopen("/proc/sysrq-trigger", "a"); data/sbd-1.4.1/src/sbd-common.c:1025: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). (void)open(devnull, O_RDONLY); data/sbd-1.4.1/src/sbd-common.c:1027: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). (void)open(devnull, O_WRONLY); data/sbd-1.4.1/src/sbd-common.c:1029: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). (void)open(devnull, O_WRONLY); data/sbd-1.4.1/src/sbd-common.c:1057:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fmt[FMT_MAX]; data/sbd-1.4.1/src/sbd-inquisitor.c:248: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_path[PATH_MAX], exe_path[PATH_MAX], myexe_path[PATH_MAX]; data/sbd-1.4.1/src/sbd-inquisitor.c:287: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 lf_name[256], tf_name[256], buf[LOCKSTRLEN+1]; data/sbd-1.4.1/src/sbd-inquisitor.c:303:12: [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 ((fd = open(lf_name, O_RDONLY)) >= 0) { data/sbd-1.4.1/src/sbd-inquisitor.c:333:12: [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 ((fd = open(tf_name, O_CREAT | O_WRONLY | O_EXCL, 0644)) < 0) { data/sbd-1.4.1/src/sbd-inquisitor.c:386: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 lf_name[256]; data/sbd-1.4.1/src/sbd-inquisitor.c:980:17: [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). start_mode = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:984: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). timeout_startup = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1043:33: [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). timeout_watchdog_crashdump = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1048: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). timeout_watchdog = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1054: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). timeout_allocate = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1057: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). timeout_loop = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1060: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). timeout_msgwait = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1063:28: [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). timeout_watchdog_warn = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1068:31: [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). servant_restart_interval = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1073:17: [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). timeout_io = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1078:28: [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). servant_restart_count = atoi(optarg); data/sbd-1.4.1/src/sbd-inquisitor.c:1170: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 *p[2]; data/sbd-1.4.1/src/sbd-md.c:34: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. static char sbd_magic[8] = "SBD_SBD_"; data/sbd-1.4.1/src/sbd-md.c:115:14: [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). st->devfd = open(devname, O_SYNC|O_RDWR|O_DIRECT); data/sbd-1.4.1/src/sbd-md.c:343: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 uuid[37]; data/sbd-1.4.1/src/sbd-md.c:376: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 uuid[37]; data/sbd-1.4.1/src/sbd-md.c:585: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 uuid[37]; data/sbd-1.4.1/src/sbd-md.c:1059: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 uuid[37]; data/sbd-1.4.1/src/sbd.h:70: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 magic[8]; data/sbd-1.4.1/src/sbd.h:87: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 from[SECTOR_NAME_MAX+1]; data/sbd-1.4.1/src/sbd.h:93: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[SECTOR_NAME_MAX+1]; data/sbd-1.4.1/src/setproctitle.c:160:10: [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. static char statbuf[BUFSIZ]; data/sbd-1.4.1/tests/sbd-testbed.c:75: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. static char *sbd_device[3] = {NULL, NULL, NULL}; data/sbd-1.4.1/tests/sbd-testbed.c:168: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). log_fp = fopen(value, "a"); data/sbd-1.4.1/tests/sbd-testbed.c:221:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/sbd-1.4.1/tests/sbd-testbed.c:262:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/sbd-1.4.1/tests/sbd-testbed.c:265:9: [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(buf, "trigger %ds\n", watchdog_timeout); data/sbd-1.4.1/tests/sbd-testbed.c:274:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/sbd-1.4.1/tests/sbd-testbed.c:278:9: [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(buf, "disarm\n"); data/sbd-1.4.1/tests/sbd-testbed.c:286:1: [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). open(const char *pathname, int flags, ...) data/sbd-1.4.1/tests/sbd-testbed.c:475:1: [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). fopen(const char *pathname, const char *mode) data/sbd-1.4.1/tests/sbd-testbed.c:527:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/sbd-1.4.1/src/sbd-cluster.c:405:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if ((local_pid <= 0) || (strlen(entry->d_name) > 114)) { data/sbd-1.4.1/src/sbd-common.c:1023:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(022); data/sbd-1.4.1/src/sbd-common.c:1047:18: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). for (i = 0; i < strlen(local_uname); i++) data/sbd-1.4.1/src/sbd-inquisitor.c:313:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, buf, sizeof(buf)) < 1) { data/sbd-1.4.1/src/sbd-inquisitor.c:796: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). max = strlen(line); data/sbd-1.4.1/src/sbd-inquisitor.c:824:23: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). entry[strlen(entry)-space_run] = '\0'; data/sbd-1.4.1/src/sbd-inquisitor.c:1105:24: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if ((value) && strlen(value)) { data/sbd-1.4.1/src/sbd-inquisitor.c:1142: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 ((disk_count > 0) && (strlen(local_uname) > SECTOR_NAME_MAX)) { data/sbd-1.4.1/src/sbd-md.c:523:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s_node->name, name, SECTOR_NAME_MAX); data/sbd-1.4.1/src/sbd-md.c:620:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s_mbox->from, local_uname, SECTOR_NAME_MAX); data/sbd-1.4.1/src/sbd-md.c:672:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s_mbox->from, local_uname, SECTOR_NAME_MAX); data/sbd-1.4.1/src/setproctitle.c:99: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). envpsize += strlen(envp[i]) + 1; data/sbd-1.4.1/src/setproctitle.c:121:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). LastArgv = argv[i] + strlen(argv[i]); data/sbd-1.4.1/src/setproctitle.c:126:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). LastArgv = envp[i] + strlen(envp[i]); data/sbd-1.4.1/src/setproctitle.c:182:23: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). vsnprintf(statbuf + strlen(statbuf), sizeof(statbuf) - strlen(statbuf), data/sbd-1.4.1/src/setproctitle.c:182:58: [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). vsnprintf(statbuf + strlen(statbuf), sizeof(statbuf) - strlen(statbuf), data/sbd-1.4.1/src/setproctitle.c:190:23: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). vsnprintf(statbuf + strlen(statbuf), sizeof(statbuf) - strlen(statbuf), data/sbd-1.4.1/src/setproctitle.c:190:58: [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). vsnprintf(statbuf + strlen(statbuf), sizeof(statbuf) - strlen(statbuf), data/sbd-1.4.1/src/setproctitle.c:200:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). i = strlen(statbuf); data/sbd-1.4.1/tests/sbd-testbed.c:235:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(watchdog_pipe[0], &buf[i], 1); data/sbd-1.4.1/tests/sbd-testbed.c:266:42: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (write(watchdog_pipe[1], buf, strlen(buf)) != strlen(buf)) { data/sbd-1.4.1/tests/sbd-testbed.c:266:58: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (write(watchdog_pipe[1], buf, strlen(buf)) != strlen(buf)) { data/sbd-1.4.1/tests/sbd-testbed.c:279:42: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (write(watchdog_pipe[1], buf, strlen(buf)) != strlen(buf)) { data/sbd-1.4.1/tests/sbd-testbed.c:279:58: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (write(watchdog_pipe[1], buf, strlen(buf)) != strlen(buf)) { ANALYSIS SUMMARY: Hits = 123 Lines analyzed = 6071 in approximately 0.17 seconds (35967 lines/second) Physical Source Lines of Code (SLOC) = 4763 Hits@level = [0] 102 [1] 24 [2] 65 [3] 15 [4] 13 [5] 6 Hits@level+ = [0+] 225 [1+] 123 [2+] 99 [3+] 34 [4+] 19 [5+] 6 Hits/KSLOC@level+ = [0+] 47.2391 [1+] 25.8241 [2+] 20.7852 [3+] 7.13836 [4+] 3.98908 [5+] 1.25971 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.