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/pg-checksums-1.0/pg_checksums.c
Examining data/pg-checksums-1.0/port.c
Examining data/pg-checksums-1.0/port.h

FINAL RESULTS:

data/pg-checksums-1.0/pg_checksums.c:210:2:  [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(total_size_str, sizeof(total_size_str), INT64_FORMAT,
data/pg-checksums-1.0/pg_checksums.c:212:2:  [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(current_size_str, sizeof(current_size_str), INT64_FORMAT,
data/pg-checksums-1.0/pg_checksums.c:243:3:  [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, isatty(fileno(stderr)) ? "\r" : "\n");
data/pg-checksums-1.0/port.c:469:25:  [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, ANSI_ESCAPE_FMT, sgr_locus);
data/pg-checksums-1.0/port.c:476:33:  [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, UINT64_FORMAT ":", lineno);
data/pg-checksums-1.0/port.c:480:25:  [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, ANSI_ESCAPE_RESET);
data/pg-checksums-1.0/port.c:489:41:  [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, ANSI_ESCAPE_FMT, sgr_error);
data/pg-checksums-1.0/port.c:492:41:  [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, ANSI_ESCAPE_RESET);
data/pg-checksums-1.0/port.c:496:41:  [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, ANSI_ESCAPE_FMT, sgr_error);
data/pg-checksums-1.0/port.c:499:41:  [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, ANSI_ESCAPE_RESET);
data/pg-checksums-1.0/port.c:503:41:  [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, ANSI_ESCAPE_FMT, sgr_warning);
data/pg-checksums-1.0/port.c:506:41:  [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, ANSI_ESCAPE_RESET);
data/pg-checksums-1.0/port.c:516:24:  [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.
        required_len = vsnprintf(NULL, 0, fmt, ap2) + 1;
data/pg-checksums-1.0/port.c:526:17:  [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, ap);
data/pg-checksums-1.0/port.c:530: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.
        vsnprintf(buf, required_len, fmt, ap);
data/pg-checksums-1.0/pg_checksums.c:677:14:  [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.
	while ((c = getopt_long(argc, argv, "abcD:def:NPv", long_options, &option_index)) != -1)
data/pg-checksums-1.0/pg_checksums.c:739: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.
			DataDir = getenv("PGDATA");
data/pg-checksums-1.0/port.c:366:29:  [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.
	const char *pg_color_env = getenv("PG_COLOR");
data/pg-checksums-1.0/port.c:385:31:  [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.
		const char *pg_colors_env = getenv("PG_COLORS");
data/pg-checksums-1.0/pg_checksums.c:170:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		total_size_str[32];
data/pg-checksums-1.0/pg_checksums.c:171:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		current_size_str[32];
data/pg-checksums-1.0/pg_checksums.c:277:6:  [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).
	f = open(fn, PG_BINARY | flags, 0);
data/pg-checksums-1.0/pg_checksums.c:536:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		path[MAXPGPATH];
data/pg-checksums-1.0/pg_checksums.c:549: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		fn[MAXPGPATH];
data/pg-checksums-1.0/pg_checksums.c:584:4:  [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		fnonly[MAXPGPATH];
data/pg-checksums-1.0/pg_checksums.c:603:17:  [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).
				segmentno = atoi(segmentpath);
data/pg-checksums-1.0/pg_checksums.c:697:9:  [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 (atoi(optarg) == 0)
data/pg-checksums-1.0/port.c:28:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		ControlFilePath[MAXPGPATH];
data/pg-checksums-1.0/port.c:33:12:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
	if ((fd = open(ControlFilePath, O_RDONLY | PG_BINARY, 0)) == -1)
data/pg-checksums-1.0/port.c:61:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		buffer[PG_CONTROL_FILE_SIZE];
data/pg-checksums-1.0/port.c:62:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		ControlFilePath[MAXPGPATH];
data/pg-checksums-1.0/port.c:88:2:  [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(buffer, ControlFile, sizeof(ControlFileData));
data/pg-checksums-1.0/port.c:92:7:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
	fd = open(ControlFilePath, O_WRONLY | PG_BINARY,
data/pg-checksums-1.0/port.c:161:7:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
	fd = open(fname, flags, 0);
data/pg-checksums-1.0/port.c:221: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		subpath[MAXPGPATH * 2];
data/pg-checksums-1.0/port.c:283:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		pg_wal[MAXPGPATH];
data/pg-checksums-1.0/port.c:284:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char		pg_tblspc[MAXPGPATH];
data/pg-checksums-1.0/pg_checksums.c:296:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		int			r = read(f, buf.data, BLCKSZ);
data/pg-checksums-1.0/pg_checksums.c:559:6:  [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).
					strlen(PG_TEMP_FILE_PREFIX)) == 0)
data/pg-checksums-1.0/pg_checksums.c:565:6:  [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).
					strlen(PG_TEMP_FILES_DIR)) == 0)
data/pg-checksums-1.0/port.c:40:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
data/pg-checksums-1.0/port.c:450: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).
        Assert(fmt[strlen(fmt) - 1] != '\n');

ANALYSIS SUMMARY:

Hits = 42
Lines analyzed = 1639 in approximately 0.06 seconds (26688 lines/second)
Physical Source Lines of Code (SLOC) = 1130
Hits@level = [0]  62 [1]   5 [2]  18 [3]   4 [4]  15 [5]   0
Hits@level+ = [0+] 104 [1+]  42 [2+]  37 [3+]  19 [4+]  15 [5+]   0
Hits/KSLOC@level+ = [0+] 92.0354 [1+] 37.1681 [2+] 32.7434 [3+] 16.8142 [4+] 13.2743 [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.