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/pagemon-0.01.21/pagemon.c Examining data/pagemon-0.01.21/perf.h Examining data/pagemon-0.01.21/perf.c FINAL RESULTS: data/pagemon-0.01.21/pagemon.c:387:6: [4] (buffer) sscanf: 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. if (sscanf(ptr, "%" SCNu64 " %*u %" SCNu64, minor_flt, major_flt) != 2) data/pagemon-0.01.21/pagemon.c:405:6: [4] (buffer) sscanf: 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. if (sscanf(buf, "%" SCNu64, score) != 1) data/pagemon-0.01.21/pagemon.c:441:9: [4] (buffer) sscanf: 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. ret = sscanf(buffer, "%" SCNx64 "-%" SCNx64 data/pagemon-0.01.21/pagemon.c:560:8: [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. (void)printf(APP_NAME ", version " VERSION "\n\n" data/pagemon-0.01.21/pagemon.c:1152:11: [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. int c = getopt(argc, argv, "ad:hp:rt:vz:"); data/pagemon-0.01.21/pagemon.c:131: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 attr[5]; /* Map attributes */ data/pagemon-0.01.21/pagemon.c:132: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 dev[6]; /* Map device, if any */ data/pagemon-0.01.21/pagemon.c:133: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[NAME_MAX + 1]; /* Name of mapping */ data/pagemon-0.01.21/pagemon.c:200: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_refs[PROCPATH_MAX]; /* /proc/$PID/clear_refs */ data/pagemon-0.01.21/pagemon.c:201: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_pagemap[PROCPATH_MAX];/* /proc/$PID/pagemap */ data/pagemon-0.01.21/pagemon.c:202: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_maps[PROCPATH_MAX]; /* /proc/$PID/maps */ data/pagemon-0.01.21/pagemon.c:203: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_mem[PROCPATH_MAX]; /* /proc/$PID/mem */ data/pagemon-0.01.21/pagemon.c:204: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_status[PROCPATH_MAX]; /* /proc/$PID/status */ data/pagemon-0.01.21/pagemon.c:205: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_stat[PROCPATH_MAX]; /* /proc/$PID/stat */ data/pagemon-0.01.21/pagemon.c:206: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_oom[PROCPATH_MAX]; /* /proc/$PID/oom_score */ data/pagemon-0.01.21/pagemon.c:249: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(path, O_RDONLY)) < 0) data/pagemon-0.01.21/pagemon.c:295: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 path[PATH_MAX], buf[4096], *bn; data/pagemon-0.01.21/pagemon.c:375: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[4096]; data/pagemon-0.01.21/pagemon.c:398: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[4096]; data/pagemon-0.01.21/pagemon.c:418: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[4096]; data/pagemon-0.01.21/pagemon.c:431: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). fp = fopen(g.path_maps, "r"); data/pagemon-0.01.21/pagemon.c:615: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[4096]; data/pagemon-0.01.21/pagemon.c:620: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). fp = fopen(g.path_status, "r"); data/pagemon-0.01.21/pagemon.c:626: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 vmname[9], size[8]; data/pagemon-0.01.21/pagemon.c:627: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 state[6], longstate[13]; data/pagemon-0.01.21/pagemon.c:670: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[16]; data/pagemon-0.01.21/pagemon.c:740: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). kfd = open("/proc/kpagecount", O_RDONLY); data/pagemon-0.01.21/pagemon.c:787: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(g.path_pagemap, O_RDONLY)) < 0) data/pagemon-0.01.21/pagemon.c:908: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(g.path_mem, O_RDONLY)) < 0) data/pagemon-0.01.21/pagemon.c:993: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(g.path_mem, O_RDONLY)) < 0) data/pagemon-0.01.21/pagemon.c:1309: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). fd = open(g.path_refs, O_RDWR); data/pagemon-0.01.21/perf.c:50: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 perf_path[PATH_MAX]; data/pagemon-0.01.21/perf.c:56: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 ((fp = fopen(perf_path, "r")) == NULL) data/pagemon-0.01.21/pagemon.c:251:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, buffer, sz); data/pagemon-0.01.21/pagemon.c:630:7: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (sscanf(buffer, "State: %5s %12s", state, longstate) == 2) { data/pagemon-0.01.21/pagemon.c:635:7: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (sscanf(buffer, "Vm%8s %" SCNu64 "%7s", data/pagemon-0.01.21/pagemon.c:701:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, &pagemap_info, sizeof(pagemap_info)) != sizeof(pagemap_info)) data/pagemon-0.01.21/pagemon.c:749:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(kfd, &count, sizeof(count)) != sizeof(count)) data/pagemon-0.01.21/pagemon.c:819:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t ret = read(fd, pagemap_info_buf, sz); data/pagemon-0.01.21/pagemon.c:846:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, &pagemap_info_buf[j], data/pagemon-0.01.21/pagemon.c:920:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). nread = read(fd, bytes, (size_t)xmax); data/pagemon-0.01.21/pagemon.c:1002:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, &byte, sizeof(byte)) < 0) data/pagemon-0.01.21/pagemon.c:1367:10: [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. (void)usleep(udelay); data/pagemon-0.01.21/pagemon.c:1724:9: [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. (void)usleep(udelay); data/pagemon-0.01.21/perf.c:134:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, &data, sizeof(data)) == sizeof(data)) { ANALYSIS SUMMARY: Hits = 45 Lines analyzed = 2029 in approximately 0.07 seconds (29866 lines/second) Physical Source Lines of Code (SLOC) = 1585 Hits@level = [0] 33 [1] 12 [2] 28 [3] 1 [4] 4 [5] 0 Hits@level+ = [0+] 78 [1+] 45 [2+] 33 [3+] 5 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 49.2114 [1+] 28.3912 [2+] 20.8202 [3+] 3.15457 [4+] 2.52366 [5+] 0 Dot directories skipped = 1 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.