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/jbig2dec-0.19/config_win32.h
Examining data/jbig2dec-0.19/getopt.c
Examining data/jbig2dec-0.19/getopt.h
Examining data/jbig2dec-0.19/getopt1.c
Examining data/jbig2dec-0.19/jbig2.h
Examining data/jbig2dec-0.19/jbig2_arith.c
Examining data/jbig2dec-0.19/jbig2_arith.h
Examining data/jbig2dec-0.19/jbig2_arith_iaid.c
Examining data/jbig2dec-0.19/jbig2_arith_iaid.h
Examining data/jbig2dec-0.19/jbig2_arith_int.c
Examining data/jbig2dec-0.19/jbig2_arith_int.h
Examining data/jbig2dec-0.19/jbig2_generic.c
Examining data/jbig2dec-0.19/jbig2_generic.h
Examining data/jbig2dec-0.19/jbig2_halftone.c
Examining data/jbig2dec-0.19/jbig2_halftone.h
Examining data/jbig2dec-0.19/jbig2_huffman.c
Examining data/jbig2dec-0.19/jbig2_huffman.h
Examining data/jbig2dec-0.19/jbig2_hufftab.c
Examining data/jbig2dec-0.19/jbig2_hufftab.h
Examining data/jbig2dec-0.19/jbig2_image.c
Examining data/jbig2dec-0.19/jbig2_image.h
Examining data/jbig2dec-0.19/jbig2_image_pbm.c
Examining data/jbig2dec-0.19/jbig2_image_png.c
Examining data/jbig2dec-0.19/jbig2_image_rw.h
Examining data/jbig2dec-0.19/jbig2_mmr.c
Examining data/jbig2dec-0.19/jbig2_mmr.h
Examining data/jbig2dec-0.19/jbig2_page.c
Examining data/jbig2dec-0.19/jbig2_page.h
Examining data/jbig2dec-0.19/jbig2_priv.h
Examining data/jbig2dec-0.19/jbig2_refinement.c
Examining data/jbig2dec-0.19/jbig2_refinement.h
Examining data/jbig2dec-0.19/jbig2_segment.c
Examining data/jbig2dec-0.19/jbig2_segment.h
Examining data/jbig2dec-0.19/jbig2_symbol_dict.c
Examining data/jbig2dec-0.19/jbig2_symbol_dict.h
Examining data/jbig2dec-0.19/jbig2_text.c
Examining data/jbig2dec-0.19/jbig2_text.h
Examining data/jbig2dec-0.19/jbig2dec.c
Examining data/jbig2dec-0.19/memcmp.c
Examining data/jbig2dec-0.19/memento.c
Examining data/jbig2dec-0.19/memento.h
Examining data/jbig2dec-0.19/os_types.h
Examining data/jbig2dec-0.19/pbm2png.c
Examining data/jbig2dec-0.19/sha1.c
Examining data/jbig2dec-0.19/sha1.h
Examining data/jbig2dec-0.19/jbig2.c

FINAL RESULTS:

data/jbig2dec-0.19/config_win32.h:43:11:  [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.
#  define vsnprintf _vsnprintf
data/jbig2dec-0.19/config_win32.h:59:11:  [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.
#  define snprintf _snprintf
data/jbig2dec-0.19/config_win32.h:59:20:  [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.
#  define snprintf _snprintf
data/jbig2dec-0.19/jbig2.c:94:9:  [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.
    n = vsnprintf(buf, sizeof(buf), fmt, ap);
data/jbig2dec-0.19/jbig2_huffman.c:129:9:  [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(stderr, ((word >> i) & 1) ? "1" : "0");
data/jbig2dec-0.19/memento.c:110:5:  [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(log_buffer2, sizeof(log_buffer2)-1, fmt, args);
data/jbig2dec-0.19/memento.c:153:9:  [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 fprintf android_fprintf
data/jbig2dec-0.19/memento.c:169:11:  [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.
    ret = vfprintf(file, fmt, args);
data/jbig2dec-0.19/memento.c:173:5:  [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(text, 4096, fmt, args);
data/jbig2dec-0.19/memento.c:180:9:  [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 fprintf windows_fprintf
data/jbig2dec-0.19/memento.c:553: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(command, sizeof(command),
data/jbig2dec-0.19/memento.c:558:13:  [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.
        e = system(command);
data/jbig2dec-0.19/memento.c:1299:5:  [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(stderr, FMTP":(size=" FMTZ ",num=%d)",
data/jbig2dec-0.19/memento.c:1526:5:  [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(stderr, FMTZ" mallocs, "FMTZ" frees, "FMTZ" reallocs\n", (FMTZ_CAST)memento.numMallocs,
data/jbig2dec-0.19/memento.c:1545:5:  [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(stderr, FMTP":(size="FMTZ",num=%d)",
data/jbig2dec-0.19/memento.c:1815:17:  [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.
                system(text);
data/jbig2dec-0.19/getopt.c:209:9:  [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.
#ifndef getenv
data/jbig2dec-0.19/getopt.c:210:14:  [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.
extern char *getenv();
data/jbig2dec-0.19/getopt.c:385:23:  [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.
    posixly_correct = getenv("POSIXLY_CORRECT");
data/jbig2dec-0.19/getopt.c:870:1:  [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.
getopt(argc, argv, optstring)
data/jbig2dec-0.19/getopt.c:896:13:  [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.
        c = getopt(argc, argv, "abc:d:0123456789");
data/jbig2dec-0.19/getopt.h:144:12:  [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.
extern int getopt(int __argc, char *const *__argv, const char *__shortopts);
data/jbig2dec-0.19/getopt.h:146:12:  [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.
extern int getopt();
data/jbig2dec-0.19/getopt.h:150:12:  [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.
extern int getopt_long(int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind);
data/jbig2dec-0.19/getopt.h:157:12:  [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.
extern int getopt();
data/jbig2dec-0.19/getopt.h:159:12:  [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.
extern int getopt_long();
data/jbig2dec-0.19/getopt1.c:66:1:  [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.
getopt_long(argc, argv, options, long_options, opt_index)
data/jbig2dec-0.19/getopt1.c:120:13:  [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.
        c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index);
data/jbig2dec-0.19/jbig2dec.c:271:18:  [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.
        option = getopt_long(argc, argv, "Vh?qv:do:t:eM:", long_options, &option_idx);
data/jbig2dec-0.19/memento.c:207:7:  [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.
char *getenv(const char *);
data/jbig2dec-0.19/memento.c:380:5:  [3] (misc) InitializeCriticalSection:
  Exceptions can be thrown in low-memory situations. Use
  InitializeCriticalSectionAndSpinCount instead.
    InitializeCriticalSection(m);
data/jbig2dec-0.19/memento.c:384:5:  [3] (misc) EnterCriticalSection:
  On some versions of Windows, exceptions can be thrown in low-memory
  situations. Use InitializeCriticalSectionAndSpinCount instead.
    EnterCriticalSection(&memento.mutex)
data/jbig2dec-0.19/memento.c:751:19:  [3] (misc) LoadLibrary:
  Ensure that the full path to the library is specified, or current directory
  may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to
  find library path, if you aren't already.
    HMODULE mod = LoadLibrary("kernel32.dll");
data/jbig2dec-0.19/memento.c:758:11:  [3] (misc) LoadLibrary:
  Ensure that the full path to the library is specified, or current directory
  may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to
  find library path, if you aren't already.
    mod = LoadLibrary("Dbghelp.dll");
data/jbig2dec-0.19/memento.c:1637:11:  [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.
    env = getenv("MEMENTO_FAILAT");
data/jbig2dec-0.19/memento.c:1640:11:  [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.
    env = getenv("MEMENTO_BREAKAT");
data/jbig2dec-0.19/memento.c:1643:11:  [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.
    env = getenv("MEMENTO_PARANOIA");
data/jbig2dec-0.19/memento.c:1648:11:  [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.
    env = getenv("MEMENTO_PARANOIDAT");
data/jbig2dec-0.19/memento.c:1651:11:  [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.
    env = getenv("MEMENTO_SQUEEZEAT");
data/jbig2dec-0.19/memento.c:1654:11:  [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.
    env = getenv("MEMENTO_PATTERN");
data/jbig2dec-0.19/memento.c:1657:11:  [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.
    env = getenv("MEMENTO_MAXMEMORY");
data/jbig2dec-0.19/memento.c:1847:9:  [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 (getenv("MEMENTO_NOJIT"))
data/jbig2dec-0.19/jbig2.c:89: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[1024];
data/jbig2dec-0.19/jbig2.c:280: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(buf, ctx->buf + ctx->buf_rd_ix, already);
data/jbig2dec-0.19/jbig2.c:289: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(ctx->buf + ctx->buf_wr_ix, data, size);
data/jbig2dec-0.19/jbig2_generic.c:890: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(src + image->stride, src, image->stride);
data/jbig2dec-0.19/jbig2_generic.c:1431: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(gbat, segment_data + 18, gbat_bytes);
data/jbig2dec-0.19/jbig2_generic.c:1446: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(params.gbat, gbat, gbat_bytes);
data/jbig2dec-0.19/jbig2_image_pbm.c:41: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).
    if ((out = fopen(filename, "wb")) == NULL) {
data/jbig2dec-0.19/jbig2_image_pbm.c:76:15:  [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 ((in = fopen(filename, "rb")) == NULL) {
data/jbig2dec-0.19/jbig2_image_pbm.c:96: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[32];
data/jbig2dec-0.19/jbig2_image_png.c:143: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).
    if ((out = fopen(filename, "wb")) == NULL) {
data/jbig2dec-0.19/jbig2_refinement.c:92: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 name[32];
data/jbig2dec-0.19/jbig2_refinement.c:147: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 name[32];
data/jbig2dec-0.19/jbig2_symbol_dict.c:74: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[24];
data/jbig2dec-0.19/jbig2_symbol_dict.c:467: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(region_params.gbat, params->sdat, sdat_bytes);
data/jbig2dec-0.19/jbig2_symbol_dict.c:587: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(rparams.grat, params->sdrat, 4);
data/jbig2dec-0.19/jbig2_symbol_dict.c:613:21:  [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[64];
data/jbig2dec-0.19/jbig2_symbol_dict.c:618: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).
                    out = fopen(name, "wb");
data/jbig2dec-0.19/jbig2_symbol_dict.c:690: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(dst, src, stride);
data/jbig2dec-0.19/jbig2_symbol_dict.c:991: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(params.sdat, segment_data + 2, sdat_bytes);
data/jbig2dec-0.19/jbig2_symbol_dict.c:998: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(params.sdrat, segment_data + offset, 4);
data/jbig2dec-0.19/jbig2_text.c:437: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(rparams.grat, params->sbrat, 4);
data/jbig2dec-0.19/jbig2dec.c:107: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(ptr, &size, sizeof(size));
data/jbig2dec-0.19/jbig2dec.c:175: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(p, &size, sizeof(size));
data/jbig2dec-0.19/jbig2dec.c:216: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 md[SHA1_DIGEST_SIZE];
data/jbig2dec-0.19/jbig2dec.c:217: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 digest[2 * SHA1_DIGEST_SIZE + 1];
data/jbig2dec-0.19/jbig2dec.c:285:35:  [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).
                params->verbose = atoi(optarg);
data/jbig2dec-0.19/jbig2dec.c:503: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(output_filename, c, len);
data/jbig2dec-0.19/jbig2dec.c:504: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(output_filename + len, extension, extlen);
data/jbig2dec-0.19/jbig2dec.c:595:17:  [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(fn, "rb");
data/jbig2dec-0.19/jbig2dec.c:605:17:  [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(fn, "rb");
data/jbig2dec-0.19/jbig2dec.c:611: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).
            f_page = fopen(fn_page, "rb");
data/jbig2dec-0.19/jbig2dec.c:738:28:  [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 ((out = fopen(params.output_filename, "wb")) == NULL) {
data/jbig2dec-0.19/memento.c:98: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 log_buffer[4096];
data/jbig2dec-0.19/memento.c:101: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 log_buffer2[4096];
data/jbig2dec-0.19/memento.c:129: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(&log_buffer[log_fill], q, p-q);
data/jbig2dec-0.19/memento.c:165: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 text[4096];
data/jbig2dec-0.19/memento.c:206:5:  [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 atoi(const char *);
data/jbig2dec-0.19/memento.c:237: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 MEMENTO_PRESIZE_MUST_BE_A_MULTIPLE_OF_4[Memento_PreSize & 3 ? -1 : 1];
data/jbig2dec-0.19/memento.c:238: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 MEMENTO_POSTSIZE_MUST_BE_A_MULTIPLE_OF_4[Memento_PostSize & 3 ? -1 : 1];
data/jbig2dec-0.19/memento.c:239: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 MEMENTO_POSTSIZE_MUST_BE_AT_LEAST_4[Memento_PostSize >= 4 ? 1 : -1];
data/jbig2dec-0.19/memento.c:240: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 MEMENTO_PRESIZE_MUST_BE_AT_LEAST_4[Memento_PreSize >= 4 ? 1 : -1];
data/jbig2dec-0.19/memento.c:349: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                 preblk[Memento_PreSize];
data/jbig2dec-0.19/memento.c:447:24:  [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 *)(void *)(B))[(B)->rawsize + sizeof(Memento_BlkHeader)])
data/jbig2dec-0.19/memento.c:498: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 backtrace_exe[4096];
data/jbig2dec-0.19/memento.c:547: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.
    static char command[1024];
data/jbig2dec-0.19/memento.c:652: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(backtrace_exe, strings[0], s - strings[0]);
data/jbig2dec-0.19/memento.c:803: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 symbol_buffer[sizeof(MY_SYMBOL_INFO) + 1024 + 1];
data/jbig2dec-0.19/memento.c:935: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(&details->stack, &stack[skip], count * sizeof(void *));
data/jbig2dec-0.19/memento.c:1638:29:  [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).
    memento.failAt = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1641:30:  [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).
    memento.breakAt = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1644: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).
    memento.paranoia = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1649: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).
    memento.paranoidAt = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1652:32:  [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).
    memento.squeezeAt = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1655:30:  [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).
    memento.pattern = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1658:32:  [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).
    memento.maxMemory = (env ? atoi(env) : 0);
data/jbig2dec-0.19/memento.c:1679:23:  [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 *blkend = &((char *)MEMBLK_TOBLK(b))[b->rawsize];
data/jbig2dec-0.19/memento.c:1812:17:  [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 text[32];
data/jbig2dec-0.19/memento.c:1814:17:  [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(text, "kill %d", pid);
data/jbig2dec-0.19/memento.c:2679:24:  [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 *)MEMBLK_TOBLK(memblk))[data->index]);
data/jbig2dec-0.19/sha1.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(block, buffer, 64);
data/jbig2dec-0.19/sha1.c:211: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(&context->buffer[j], data, (i = 64 - j));
data/jbig2dec-0.19/sha1.c:219: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(&context->buffer[j], &data[i], len - i);
data/jbig2dec-0.19/sha1.c:267: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 digest[SHA1_DIGEST_SIZE], buffer[16384];
data/jbig2dec-0.19/sha1.c:279: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 (!(file = fopen(argv[1], "rb"))) {
data/jbig2dec-0.19/sha1.c:325:13:  [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(c, "%02X", digest[i * 4 + j]);
data/jbig2dec-0.19/sha1.c:340: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 output[80];
data/jbig2dec-0.19/getopt.c:231: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).
# if (!defined __STDC__ || !__STDC__) && !defined strlen
data/jbig2dec-0.19/getopt.c:234:12:  [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).
extern int strlen(const char *);
data/jbig2dec-0.19/getopt.c:407:53:  [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).
                int len = nonoption_flags_max_len = strlen(orig_str);
data/jbig2dec-0.19/getopt.c:623: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).
                        == (unsigned int)strlen(p->name)) {
data/jbig2dec-0.19/getopt.c:641: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).
            nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:665:33:  [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).
                    nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:676:33:  [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).
                    nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:681: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).
            nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:774:63:  [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 ((unsigned int)(nameend - nextchar) == strlen(p->name)) {
data/jbig2dec-0.19/getopt.c:791: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).
                nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:807:37:  [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).
                        nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:816:37:  [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).
                        nextchar += strlen(nextchar);
data/jbig2dec-0.19/getopt.c:820: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).
                nextchar += strlen(nextchar);
data/jbig2dec-0.19/jbig2.c:97:9:  [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(buf, "failed to generate error string", sizeof(buf));
data/jbig2dec-0.19/jbig2_image_pbm.c:99:17:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((c = fgetc(in)) != 'P') {
data/jbig2dec-0.19/jbig2_image_pbm.c:103:14:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if ((c = fgetc(in)) != '4') {
data/jbig2dec-0.19/jbig2_image_pbm.c:114:13:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        c = fgetc(in);
data/jbig2dec-0.19/jbig2_image_pbm.c:120:25:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            while ((c = fgetc(in)) != '\n');
data/jbig2dec-0.19/jbig2_image_pbm.c:130:32:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            while (isdigit(c = fgetc(in))) {
data/jbig2dec-0.19/jbig2dec.c:489: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(c);
data/jbig2dec-0.19/jbig2dec.c:492: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(e);
data/jbig2dec-0.19/jbig2dec.c:494:14:  [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).
    extlen = strlen(extension);
data/jbig2dec-0.19/jbig2dec.c:726: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).
                int len = strlen(params.output_filename);
data/jbig2dec-0.19/memento.c:135:13:  [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.
            usleep(1);
data/jbig2dec-0.19/memento.c:143:13:  [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.
            usleep(1);
data/jbig2dec-0.19/memento.c:1147:18:  [1] (buffer) mismatch:
  Function does not check the second iterator for over-read conditions
  (CWE-126). This function is often discouraged by most C++ coding standards
  in favor of its safer alternatives provided since C++14. Consider using a
  form of this function that checks the second iterator before potentially
  overflowing it.
            goto mismatch;
data/jbig2dec-0.19/memento.c:1155:1:  [1] (buffer) mismatch:
  Function does not check the second iterator for over-read conditions
  (CWE-126). This function is often discouraged by most C++ coding standards
  in favor of its safer alternatives provided since C++14. Consider using a
  form of this function that checks the second iterator before potentially
  overflowing it.
mismatch:
data/jbig2dec-0.19/sha1.c:328:9:  [1] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source is a constant character.
        sprintf(c, " ");
data/jbig2dec-0.19/sha1.c:346: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).
        SHA1_Update(&context, (uint8_t *) test_data[k], strlen(test_data[k]));

ANALYSIS SUMMARY:

Hits = 137
Lines analyzed = 18679 in approximately 0.54 seconds (34596 lines/second)
Physical Source Lines of Code (SLOC) = 13498
Hits@level = [0] 280 [1]  29 [2]  66 [3]  26 [4]  16 [5]   0
Hits@level+ = [0+] 417 [1+] 137 [2+] 108 [3+]  42 [4+]  16 [5+]   0
Hits/KSLOC@level+ = [0+] 30.8935 [1+] 10.1497 [2+] 8.00119 [3+] 3.11157 [4+] 1.18536 [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.