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/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c
Examining data/r-cran-tikzdevice-0.12.3.1/src/init.c
Examining data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.h

FINAL RESULTS:

data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:628:5:  [4] (format) sprintf:
  Potential format string problem (CWE-134). Make format string constant.
    sprintf(tikzInfo->outFileName, tikzInfo->originalFileName, tikzInfo->pageNum);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:642: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(tikzInfo->outColorFileName, strlen(tikzInfo->originalColorFileName)+strlen(tikzInfo->outFileName), tikzInfo->originalColorFileName, fname);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:646: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(tikzInfo->outColorFileName, strlen(tikzInfo->originalColorFileName)+strlen(tikzInfo->outFileName), tikzInfo->originalColorFileName, tikzInfo->outFileName);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:1191:3:  [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( tikzString, str );
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:2144: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(tikzInfo->outputFile, format, ap);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:2158: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(tikzInfo->colorFile, format, ap);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:2403: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(ret, str);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:542:16:  [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).
    int perc = atoi(colorstr+4);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:583:27:  [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).
    tikzInfo->colorFile = fopen(R_ExpandFileName(tikzInfo->outColorFileName), "w");
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:652:35:  [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 ( !(tikzInfo->outputFile = fopen(R_ExpandFileName(tikzInfo->outFileName), "w")) )
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:1175:7:  [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( tikzString, "\\bfseries " );
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:1180:7:  [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( tikzString, "\\itshape " );
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:1185:7:  [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( tikzString, "\\bfseries\\itshape " );
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:1843: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 (*pdest)[sizeof tikzInfo->drawColor / sizeof* tikzInfo->drawColor];
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:1946: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 dashlist[8];
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.h:92: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 drawColor[32];
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.h:93: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 fillColor[32];
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:540:45:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  if ( strncmp(colorstr, "gray", 4) == 0 && strlen(colorstr) > 4)
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:630: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).
  if( strlen(tikzInfo->originalColorFileName) > 0 )
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:632:85:  [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).
      tikzInfo->outColorFileName = calloc_x_strlen(tikzInfo->originalColorFileName, strlen(tikzInfo->outFileName));
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:642: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).
        snprintf(tikzInfo->outColorFileName, strlen(tikzInfo->originalColorFileName)+strlen(tikzInfo->outFileName), tikzInfo->originalColorFileName, fname);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:642:86:  [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).
        snprintf(tikzInfo->outColorFileName, strlen(tikzInfo->originalColorFileName)+strlen(tikzInfo->outFileName), tikzInfo->originalColorFileName, fname);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:646: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).
        snprintf(tikzInfo->outColorFileName, strlen(tikzInfo->originalColorFileName)+strlen(tikzInfo->outFileName), tikzInfo->originalColorFileName, tikzInfo->outFileName);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:646:86:  [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).
        snprintf(tikzInfo->outColorFileName, strlen(tikzInfo->originalColorFileName)+strlen(tikzInfo->outFileName), tikzInfo->originalColorFileName, tikzInfo->outFileName);
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:2408: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).
  return (char*) calloc(strlen(str) + 1 + extra, sizeof(char));
data/r-cran-tikzdevice-0.12.3.1/src/tikzDevice.c:2417:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(dst, src, n - 1);

ANALYSIS SUMMARY:

Hits = 26
Lines analyzed = 2681 in approximately 0.09 seconds (31133 lines/second)
Physical Source Lines of Code (SLOC) = 1290
Hits@level = [0]   2 [1]   9 [2]  10 [3]   0 [4]   7 [5]   0
Hits@level+ = [0+]  28 [1+]  26 [2+]  17 [3+]   7 [4+]   7 [5+]   0
Hits/KSLOC@level+ = [0+] 21.7054 [1+] 20.155 [2+] 13.1783 [3+] 5.42636 [4+] 5.42636 [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.