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/scanmem-0.17/commands.c
Examining data/scanmem-0.17/commands.h
Examining data/scanmem-0.17/common.h
Examining data/scanmem-0.17/endianness.h
Examining data/scanmem-0.17/getline.c
Examining data/scanmem-0.17/getline.h
Examining data/scanmem-0.17/handlers.c
Examining data/scanmem-0.17/handlers.h
Examining data/scanmem-0.17/interrupt.h
Examining data/scanmem-0.17/licence.h
Examining data/scanmem-0.17/list.c
Examining data/scanmem-0.17/list.h
Examining data/scanmem-0.17/main.c
Examining data/scanmem-0.17/maps.c
Examining data/scanmem-0.17/maps.h
Examining data/scanmem-0.17/menu.c
Examining data/scanmem-0.17/menu.h
Examining data/scanmem-0.17/ptrace.c
Examining data/scanmem-0.17/readline.c
Examining data/scanmem-0.17/readline.h
Examining data/scanmem-0.17/scanmem.c
Examining data/scanmem-0.17/scanmem.h
Examining data/scanmem-0.17/scanroutines.c
Examining data/scanmem-0.17/scanroutines.h
Examining data/scanmem-0.17/sets.c
Examining data/scanmem-0.17/sets.h
Examining data/scanmem-0.17/show_message.c
Examining data/scanmem-0.17/show_message.h
Examining data/scanmem-0.17/targetmem.c
Examining data/scanmem-0.17/targetmem.h
Examining data/scanmem-0.17/test/memfake.c
Examining data/scanmem-0.17/value.c
Examining data/scanmem-0.17/value.h

FINAL RESULTS:

data/scanmem-0.17/maps.c:77:24:  [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.
        linkbuf_size = readlink(exelink, exename, MAX_LINKBUF_SIZE - 1);
data/scanmem-0.17/commands.c:65:9:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
        strcpy(data->command, command);
data/scanmem-0.17/handlers.c:126:9:  [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(pager, emptyvec);
data/scanmem-0.17/handlers.c:165:18:  [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 ((retfd = popen(pager, "w")) == NULL) {
data/scanmem-0.17/handlers.c:461:17:  [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(v, bytearray_suffix);
data/scanmem-0.17/handlers.c:473:17:  [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(v, string_suffix);
data/scanmem-0.17/handlers.c:905:5:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
    strcpy(string_value, vars->current_cmdline+2);
data/scanmem-0.17/handlers.c:1194:9:  [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(command, argv[i]);
data/scanmem-0.17/handlers.c:1199:9:  [4] (shell) system:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
    if (system(command) == -1) {
data/scanmem-0.17/handlers.c:1613:12:  [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(argv[3], fmt, buf) < 1) /* should be OK even for max uint64 */
data/scanmem-0.17/maps.c:240:21:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
                    strcpy(map->filename, filename);
data/scanmem-0.17/show_message.c:33:5:  [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(stderr, fmt, args);
data/scanmem-0.17/show_message.c:42:5:  [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(stderr, fmt, args);
data/scanmem-0.17/show_message.c:51:5:  [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(stderr, fmt, args);
data/scanmem-0.17/show_message.c:61:9:  [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(stderr, fmt, args);
data/scanmem-0.17/show_message.c:73:9:  [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(stderr, fmt, args);
data/scanmem-0.17/targetmem.c:116:9:  [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(buf+bytes_used, buf_length-bytes_used,
data/scanmem-0.17/handlers.c:104:18:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
    if ((pager = getenv("PAGER")) == NULL || *pager == '\0') {
data/scanmem-0.17/main.c:119:17:  [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.
        switch (getopt_long(argc, argv, "vhdep:c:", longopts, &optindex)) {
data/scanmem-0.17/test/memfake.c:41:9:  [3] (random) srand:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
        srand(time(NULL));
data/scanmem-0.17/common.h:38:16:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
      (char *) memcpy(__new, __old, __len);                                   \
data/scanmem-0.17/common.h:51:16:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
      (char *) memcpy(__new, __old, __len);                                   \
data/scanmem-0.17/endianness.h:78:9:  [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(p, &i16, sizeof(uint16_t));
data/scanmem-0.17/endianness.h:82:9:  [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(p, &i32, sizeof(uint32_t));
data/scanmem-0.17/endianness.h:86:9:  [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(p, &i64, sizeof(uint64_t));
data/scanmem-0.17/getline.c:77:5:  [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(*lineptr, lptr, len);
data/scanmem-0.17/handlers.c:102: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 *const emptyvec[1] = { NULL };
data/scanmem-0.17/handlers.c:1281:13:  [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(val.bytes, memory_ptr, memlength);
data/scanmem-0.17/handlers.c:1360: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((dump_f = fopen(argv[3], "wb")) == NULL)
data/scanmem-0.17/maps.c:48: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 name[128], *line = NULL;
data/scanmem-0.17/maps.c:49: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 exelink[128];
data/scanmem-0.17/maps.c:56: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 linkbuf[MAX_LINKBUF_SIZE], *exename = linkbuf;
data/scanmem-0.17/maps.c:58: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 binname[MAX_LINKBUF_SIZE];
data/scanmem-0.17/maps.c:68:21:  [2] (misc) fopen:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
        if ((maps = fopen(name, "r")) == NULL) {
data/scanmem-0.17/maps.h:65: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 filename[1];           /* associated file, must be last */
data/scanmem-0.17/menu.c:113: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 prompt[64];
data/scanmem-0.17/ptrace.c:205:25:  [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(&peekbuf.cache[peekbuf.size - j], &ptraced_long, sizeof(long));
data/scanmem-0.17/ptrace.c:209:25:  [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(&peekbuf.cache[0], &ptraced_long, sizeof(long));
data/scanmem-0.17/ptrace.c:229:9:  [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(&peekbuf.cache[peekbuf.size], &ptraced_long, sizeof(long));
data/scanmem-0.17/ptrace.c:412: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 mem[32];
data/scanmem-0.17/ptrace.c:420:15:  [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(mem, O_RDONLY)) == -1) {
data/scanmem-0.17/ptrace.c:550:13:  [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(data+nread, &ptraced_long, sizeof(long));
data/scanmem-0.17/ptrace.c:645:9:  [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(memarray, memory_ptr, memlength);
data/scanmem-0.17/ptrace.c:646:9:  [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(memarray, to->bytes, val_length);
data/scanmem-0.17/ptrace.c:751:21:  [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(((int8_t*)&peek_value)+j, data+i, len-i);        
data/scanmem-0.17/scanmem.c:78: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 num_str[4] = {0};
data/scanmem-0.17/test/memfake.c:31:37:  [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).
    if (argc >= 2) MB_to_allocate = atoi(argv[1]);
data/scanmem-0.17/test/memfake.c:32:37:  [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).
    if (argc >= 3) add_randomness = atoi(argv[2]);
data/scanmem-0.17/value.c:41: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[128];
data/scanmem-0.17/value.c:88:5:  [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(dst, src, sizeof(value_t));
data/scanmem-0.17/value.h:89: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 chars[sizeof(int64_t)];
data/scanmem-0.17/value.h:116: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 chars[sizeof(int64_t)];
data/scanmem-0.17/commands.c:58: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 ((data = malloc(sizeof(command_t) + strlen(command) + 1)) == NULL) {
data/scanmem-0.17/common.h:36:22:  [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(__old) + 1;                                       \
data/scanmem-0.17/handlers.c:136:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        read(pgpipe[0], &nullbuf, 1);
data/scanmem-0.17/handlers.c:147:17:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            if (read(pgpipe[0], &pgcmdfail, 1) == -1) {
data/scanmem-0.17/handlers.c:460: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).
                assert(strlen(v) + strlen(bytearray_suffix) + 1 <= buf_len); /* or maybe realloc is better? */
data/scanmem-0.17/handlers.c:460: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).
                assert(strlen(v) + strlen(bytearray_suffix) + 1 <= buf_len); /* or maybe realloc is better? */
data/scanmem-0.17/handlers.c:464: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_len = flags + strlen(string_suffix) + 32; /* for the string and suffix, this should be enough */
data/scanmem-0.17/handlers.c:472: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).
                assert(strlen(v) + strlen(string_suffix) + 1 <= buf_len); /* or maybe realloc is better? */
data/scanmem-0.17/handlers.c:472: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).
                assert(strlen(v) + strlen(string_suffix) + 1 <= buf_len); /* or maybe realloc is better? */
data/scanmem-0.17/handlers.c:754:31:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                region->flags.read ? 'r' : '-',
data/scanmem-0.17/handlers.c:880:29:  [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 cmdline_length = strlen(vars->current_cmdline);
data/scanmem-0.17/handlers.c:1187:16:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        len += strlen(argv[i]);
data/scanmem-0.17/handlers.c:1195:9:  [1] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant character.
        strcat(command, " ");
data/scanmem-0.17/handlers.c:1572:22:  [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).
        data_width = strlen(string_parameter);
data/scanmem-0.17/handlers.c:1669:9:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
        strncpy(buf, string_parameter, data_width);
data/scanmem-0.17/maps.c:91:18:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            char read, write, exec, cow, *filename;
data/scanmem-0.17/maps.c:105:84:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            if (sscanf(line, "%lx-%lx %c%c%c%c %x %x:%x %u %[^\n]", &start, &end, &read,
data/scanmem-0.17/maps.c:159:25:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
                        strncpy(binname, filename, MAX_LINKBUF_SIZE);
data/scanmem-0.17/maps.c:167:25:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
                        strncpy(binname, filename, MAX_LINKBUF_SIZE);
data/scanmem-0.17/maps.c:219:57:  [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 ((map = calloc(1, sizeof(region_t) + strlen(filename))) == NULL) {
data/scanmem-0.17/maps.c:238:21:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
                if (strlen(filename) != 0) {
data/scanmem-0.17/maps.h:58:18:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        unsigned read:1;
data/scanmem-0.17/menu.c:63:11:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
    len = strlen(text);
data/scanmem-0.17/menu.c:138: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).
        if (strlen(*line)) {
data/scanmem-0.17/value.c:83:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120). Risk is low because the source is a
  constant string.
    strncpy(str, "unknown, [unknown]", n);

ANALYSIS SUMMARY:

Hits = 77
Lines analyzed = 7196 in approximately 0.30 seconds (24269 lines/second)
Physical Source Lines of Code (SLOC) = 4758
Hits@level = [0]  41 [1]  25 [2]  32 [3]   3 [4]  16 [5]   1
Hits@level+ = [0+] 118 [1+]  77 [2+]  52 [3+]  20 [4+]  17 [5+]   1
Hits/KSLOC@level+ = [0+] 24.8003 [1+] 16.1833 [2+] 10.929 [3+] 4.20345 [4+] 3.57293 [5+] 0.210172
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.