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/nvtop-1.0.0/include/nvtop/extract_gpuinfo.h
Examining data/nvtop-1.0.0/include/nvtop/get_process_info.h
Examining data/nvtop-1.0.0/include/nvtop/interface.h
Examining data/nvtop-1.0.0/include/nvtop/interface_layout_selection.h
Examining data/nvtop-1.0.0/include/nvtop/plot.h
Examining data/nvtop-1.0.0/include/nvtop/time.h
Examining data/nvtop-1.0.0/include/uthash.h
Examining data/nvtop-1.0.0/src/extract_gpuinfo.c
Examining data/nvtop-1.0.0/src/get_process_info_linux.c
Examining data/nvtop-1.0.0/src/interface.c
Examining data/nvtop-1.0.0/src/interface_layout_selection.c
Examining data/nvtop-1.0.0/src/nvtop.c
Examining data/nvtop-1.0.0/src/plot.c
Examining data/nvtop-1.0.0/src/time.c

FINAL RESULTS:

data/nvtop-1.0.0/include/uthash.h:514:29:  [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.
#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0)
data/nvtop-1.0.0/src/get_process_info_linux.c:38:7:  [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(pid_path, pid_path_size, "/proc/%" PRIdMAX, (intmax_t)pid);
data/nvtop-1.0.0/src/interface.c:1199:19:  [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.
    size_t size = snprintf(pid_str, sizeof_process_field[process_pid] + 1,
data/nvtop-1.0.0/src/nvtop.c:96:3:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
  strcpy(option_copy, str);
data/nvtop-1.0.0/src/nvtop.c:135:19:  [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.
    int optchar = getopt_long(argc, argv, opts, long_opts, NULL);
data/nvtop-1.0.0/include/nvtop/extract_gpuinfo.h:77: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 device_name[NVML_DEVICE_NAME_BUFFER_SIZE]; // Device Name
data/nvtop-1.0.0/include/nvtop/extract_gpuinfo.h:109:12:  [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 valid[valid_max_val / CHAR_BIT + 1]; // Validity bits
data/nvtop-1.0.0/src/extract_gpuinfo.c:79: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(dev_info->device_name, "UNKNOWN", strlen("UNKNOWN") + 1);
data/nvtop-1.0.0/src/extract_gpuinfo.c:138: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(infos->process_name, "N/A", 4);
data/nvtop-1.0.0/src/extract_gpuinfo.c:143: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(infos->user_name, "N/A", 4);
data/nvtop-1.0.0/src/get_process_info_linux.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 pid_path[pid_path_size];
data/nvtop-1.0.0/src/get_process_info_linux.c:70:20:  [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 *pid_file = fopen(pid_path, "r");
data/nvtop-1.0.0/src/get_process_info_linux.c:189: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).
  FILE *stat_file = fopen(pid_path, "r");
data/nvtop-1.0.0/src/interface.c:581:53:  [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 void draw_bare_percentage(WINDOW *win, const char *prelude,
data/nvtop-1.0.0/src/interface.c:583:40:  [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 inside_braces_right[1024]) {
data/nvtop-1.0.0/src/interface.c:669:7:  [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(dev->device_name, dinfo->device_name, namelen);
data/nvtop-1.0.0/src/interface.c:676: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 buff[1024];
data/nvtop-1.0.0/src/interface.c:1124: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 process_print_buffer[process_buffer_line_size];
data/nvtop-1.0.0/src/interface.c:1159: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 pid_str[sizeof_process_field[process_pid] + 1];
data/nvtop-1.0.0/src/interface.c:1160: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 guid_str[sizeof_process_field[process_gpu_id] + 1];
data/nvtop-1.0.0/src/interface.c:1161: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 memory[sizeof_process_field[process_memory] + 1];
data/nvtop-1.0.0/src/interface.c:1162: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 cpu_percent[sizeof_process_field[process_cpu_usage] + 1];
data/nvtop-1.0.0/src/interface.c:1163: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 cpu_mem[sizeof_process_field[process_cpu_mem_usage] + 1];
data/nvtop-1.0.0/src/interface.c:1581:43:  [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.
                      0., 100., 2, (const char * [2]){"MAX GPU", "MAX MEM"});
data/nvtop-1.0.0/src/interface.c:1585:7:  [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 gpuNum[8];
data/nvtop-1.0.0/src/interface.c:1589:43:  [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.
                      0., 100., 2, (const char * [2]){gpuNum, "MEM"});
data/nvtop-1.0.0/src/interface.c:1593:7:  [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 gpuNum[2][8];
data/nvtop-1.0.0/src/interface.c:1594:7:  [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 memNum[2][8];
data/nvtop-1.0.0/src/interface.c:1602:18:  [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 * [4]){gpuNum[0], memNum[0], gpuNum[1], memNum[1]});
data/nvtop-1.0.0/include/uthash.h:95:26:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
#define uthash_strlen(s) strlen(s)
data/nvtop-1.0.0/src/extract_gpuinfo.c:79:46:  [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).
    memcpy(dev_info->device_name, "UNKNOWN", strlen("UNKNOWN") + 1);
data/nvtop-1.0.0/src/get_process_info_linux.c:55:20:  [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 namelen = strlen(user_info->pw_name) + 1;
data/nvtop-1.0.0/src/get_process_info_linux.c:58:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(*buffer, user_info->pw_name, namelen);
data/nvtop-1.0.0/src/interface.c:587: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).
  size_t size_prelude = strlen(prelude);
data/nvtop-1.0.0/src/interface.c:602:51:  [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).
  unsigned int right_side_braces_space_required = strlen(inside_braces_right);
data/nvtop-1.0.0/src/interface.c:667: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).
      size_t namelen = strlen(dinfo->device_name) + 1;
data/nvtop-1.0.0/src/interface.c:923:32:  [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).
          maximum_name_length, strlen(dev_info[i].compute_procs[j].user_name));
data/nvtop-1.0.0/src/interface.c:945:32:  [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).
          maximum_name_length, strlen(dev_info[i].graphic_procs[j].user_name));
data/nvtop-1.0.0/src/interface.c:1438: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).
      for (size_t j = strlen(option_selection_hidden[i]);
data/nvtop-1.0.0/src/interface.c:1449: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).
      for (size_t j = strlen(option_selection_kill[i][1]);
data/nvtop-1.0.0/src/interface.c:1460: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).
      for (size_t j = strlen(option_selection_sort[i][1]);
data/nvtop-1.0.0/src/nvtop.c:95:31:  [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 *option_copy = malloc((strlen(str) + 1) * sizeof(*option_copy));
data/nvtop-1.0.0/src/nvtop.c:244:31:  [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 device_name_size = strlen(dev_infos->device_name);
data/nvtop-1.0.0/src/plot.c:90: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).
      size_t length = strlen(legend[i]);

ANALYSIS SUMMARY:

Hits = 44
Lines analyzed = 4753 in approximately 0.14 seconds (34609 lines/second)
Physical Source Lines of Code (SLOC) = 3905
Hits@level = [0]  45 [1]  15 [2]  24 [3]   1 [4]   4 [5]   0
Hits@level+ = [0+]  89 [1+]  44 [2+]  29 [3+]   5 [4+]   4 [5+]   0
Hits/KSLOC@level+ = [0+] 22.7913 [1+] 11.2676 [2+] 7.42638 [3+] 1.28041 [4+] 1.02433 [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.