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/libgpiod-1.6.1/lib/helpers.c
Examining data/libgpiod-1.6.1/lib/ctxless.c
Examining data/libgpiod-1.6.1/lib/iter.c
Examining data/libgpiod-1.6.1/lib/core.c
Examining data/libgpiod-1.6.1/lib/misc.c
Examining data/libgpiod-1.6.1/bindings/cxx/iter.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/gpiod.hpp
Examining data/libgpiod-1.6.1/bindings/cxx/line.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/line_bulk.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/gpiod-cxx-test-main.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/gpiod-cxx-test.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/gpio-mockup.hpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/tests-event.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/tests-iter.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/tests-line.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/tests/gpio-mockup.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/chip.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/examples/gpiofindcxx.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/examples/gpioinfocxx.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/examples/gpiomoncxx.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/examples/gpiogetcxx.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/examples/gpiosetcxx.cpp
Examining data/libgpiod-1.6.1/bindings/cxx/examples/gpiodetectcxx.cpp
Examining data/libgpiod-1.6.1/bindings/python/gpiodmodule.c
Examining data/libgpiod-1.6.1/bindings/python/tests/gpiomockupmodule.c
Examining data/libgpiod-1.6.1/tests/tests-misc.c
Examining data/libgpiod-1.6.1/tests/tests-line.c
Examining data/libgpiod-1.6.1/tests/tests-event.c
Examining data/libgpiod-1.6.1/tests/tests-iter.c
Examining data/libgpiod-1.6.1/tests/gpiod-test.h
Examining data/libgpiod-1.6.1/tests/tests-ctxless.c
Examining data/libgpiod-1.6.1/tests/tests-chip.c
Examining data/libgpiod-1.6.1/tests/mockup/gpio-mockup.c
Examining data/libgpiod-1.6.1/tests/mockup/gpio-mockup.h
Examining data/libgpiod-1.6.1/tests/gpiod-test.c
Examining data/libgpiod-1.6.1/tools/tools-common.c
Examining data/libgpiod-1.6.1/tools/gpiodetect.c
Examining data/libgpiod-1.6.1/tools/gpioset.c
Examining data/libgpiod-1.6.1/tools/gpiofind.c
Examining data/libgpiod-1.6.1/tools/gpiomon.c
Examining data/libgpiod-1.6.1/tools/tools-common.h
Examining data/libgpiod-1.6.1/tools/gpioget.c
Examining data/libgpiod-1.6.1/tools/gpioinfo.c
Examining data/libgpiod-1.6.1/include/gpiod.h

FINAL RESULTS:

data/libgpiod-1.6.1/lib/core.c:122:6:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
	if (access(sysfsp, R_OK) != 0) {
data/libgpiod-1.6.1/tests/mockup/gpio-mockup.c:116:7:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
	rv = access("/sys/kernel/debug/gpio-mockup", R_OK | W_OK);
data/libgpiod-1.6.1/tools/gpioinfo.c:109:3:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
		printf(buffmt, buf);
data/libgpiod-1.6.1/tools/tools-common.c:33:2:  [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, va);
data/libgpiod-1.6.1/tools/tools-common.c:46:2:  [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, va);
data/libgpiod-1.6.1/tools/tools-common.h:19:48:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
#define PRINTF(fmt, arg)	__attribute__((format(printf, fmt, arg)))
data/libgpiod-1.6.1/lib/core.c:93:40:  [3] (buffer) realpath:
  This function does not protect against buffer overflows, and some
  implementations can overflow internally (CWE-120/CWE-785!). Ensure that the
  destination buffer is at least of size MAXPATHLEN, andto protect against
  implementation problems, the input argument should also be checked to
  ensure it is no larger than MAXPATHLEN.
	realname = S_ISLNK(statbuf.st_mode) ? realpath(path, NULL)
data/libgpiod-1.6.1/tools/gpiodetect.c:41:10:  [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.
		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
data/libgpiod-1.6.1/tools/gpiofind.c:41:10:  [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.
		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
data/libgpiod-1.6.1/tools/gpioget.c:52:10:  [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.
		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
data/libgpiod-1.6.1/tools/gpioinfo.c:192:10:  [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.
		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
data/libgpiod-1.6.1/tools/gpiomon.c:240:10:  [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.
		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
data/libgpiod-1.6.1/tools/gpioset.c:205:10:  [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.
		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
data/libgpiod-1.6.1/bindings/cxx/chip.cpp:63:8:  [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).
	this->open(device, how);
data/libgpiod-1.6.1/bindings/cxx/chip.cpp:72: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).
void chip::open(const ::std::string& device, int how)
data/libgpiod-1.6.1/bindings/cxx/gpiod.hpp:97:17:  [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).
	GPIOD_API void open(const ::std::string &device, int how = OPEN_LOOKUP);
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:77:24:  [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).
		REQUIRE_NOTHROW(chip.open(mockup::instance().chip_name(1),
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:83:24:  [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).
		REQUIRE_NOTHROW(chip.open(mockup::instance().chip_path(1),
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:89:24:  [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).
		REQUIRE_NOTHROW(chip.open("gpio-mockup-B", ::gpiod::chip::OPEN_BY_LABEL));
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:94:24:  [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).
		REQUIRE_NOTHROW(chip.open(::std::to_string(mockup::instance().chip_num(1)),
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:121:24:  [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).
		REQUIRE_NOTHROW(chip.open(mockup::instance().chip_name(1)));
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:126:24:  [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).
		REQUIRE_NOTHROW(chip.open(mockup::instance().chip_path(1)));
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:131:24:  [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).
		REQUIRE_NOTHROW(chip.open("gpio-mockup-B"));
data/libgpiod-1.6.1/bindings/cxx/tests/tests-chip.cpp:136:24:  [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).
		REQUIRE_NOTHROW(chip.open(::std::to_string(mockup::instance().chip_num(1))));
data/libgpiod-1.6.1/bindings/python/gpiodmodule.c:1940:42:  [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).
		self->chip = gpiod_chip_open_by_number(atoi(descr));
data/libgpiod-1.6.1/lib/core.c:63: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 name[32];
data/libgpiod-1.6.1/lib/core.c:64: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 consumer[32];
data/libgpiod-1.6.1/lib/core.c:73: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 name[32];
data/libgpiod-1.6.1/lib/core.c:74: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 label[32];
data/libgpiod-1.6.1/lib/core.c:79: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 *name, *realname, *sysfsp, sysfsdev[16], devstr[16];
data/libgpiod-1.6.1/lib/core.c:141: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(sysfsp, O_RDONLY);
data/libgpiod-1.6.1/lib/core.c:174: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(path, O_RDWR | O_CLOEXEC);
data/libgpiod-1.6.1/tests/mockup/gpio-mockup.c:435: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(path, flags);
data/libgpiod-1.6.1/tests/mockup/gpio-mockup.c:476: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 buf[2];
data/libgpiod-1.6.1/tools/gpiofind.c:38: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 chip[32];
data/libgpiod-1.6.1/lib/core.c:146:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	rd = read(fd, sysfsdev, sizeof(sysfsdev) - 1);
data/libgpiod-1.6.1/lib/core.c:152: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).
	if ((size_t)rd != strlen(devstr) ||
data/libgpiod-1.6.1/lib/core.c:203:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(chip->name, info.name, sizeof(chip->name));
data/libgpiod-1.6.1/lib/core.c:211:3:  [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(chip->label, "unknown", sizeof(chip->label));
data/libgpiod-1.6.1/lib/core.c:213:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(chip->label, info.label, sizeof(chip->label));
data/libgpiod-1.6.1/lib/core.c:427:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(line->name, info.name, sizeof(line->name));
data/libgpiod-1.6.1/lib/core.c:428:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(line->consumer, info.consumer, sizeof(line->consumer));
data/libgpiod-1.6.1/lib/core.c:584:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(req.consumer_label, config->consumer,
data/libgpiod-1.6.1/lib/core.c:626:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(req.consumer_label, config->consumer,
data/libgpiod-1.6.1/lib/core.c:1096:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	rd = read(fd, evdata, num_events * sizeof(*evdata));
data/libgpiod-1.6.1/tests/mockup/gpio-mockup.c:172:9:  [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).
	params[strlen(params) - 1] = '\0'; /* Remove the last comma. */
data/libgpiod-1.6.1/tests/mockup/gpio-mockup.c:456:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	rd = read(fd, &buf, 1);
data/libgpiod-1.6.1/tests/tests-event.c:690:3:  [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(10000);
data/libgpiod-1.6.1/tests/tests-event.c:758:3:  [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(10000);
data/libgpiod-1.6.1/tests/tests-event.c:825:3:  [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(10000);
data/libgpiod-1.6.1/tests/tests-line.c:105:19:  [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).
	g_assert_cmpuint(strlen(gpiod_line_consumer(line)), ==, 31);
data/libgpiod-1.6.1/tests/tests-misc.c:23:19:  [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).
	g_assert_cmpuint(strlen(ver), >, 0);
data/libgpiod-1.6.1/tools/gpioinfo.c:99:8:  [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(buf) - 1;
data/libgpiod-1.6.1/tools/gpioset.c:95:2:  [1] (buffer) getchar:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	getchar();

ANALYSIS SUMMARY:

Hits = 54
Lines analyzed = 16232 in approximately 0.51 seconds (31523 lines/second)
Physical Source Lines of Code (SLOC) = 11023
Hits@level = [0] 130 [1]  19 [2]  22 [3]   7 [4]   6 [5]   0
Hits@level+ = [0+] 184 [1+]  54 [2+]  35 [3+]  13 [4+]   6 [5+]   0
Hits/KSLOC@level+ = [0+] 16.6924 [1+] 4.89885 [2+] 3.17518 [3+] 1.17935 [4+] 0.544316 [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.