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/triggerhappy-0.5.0/cmdsocket.c
Examining data/triggerhappy-0.5.0/cmdsocket.h
Examining data/triggerhappy-0.5.0/command.h
Examining data/triggerhappy-0.5.0/devices.c
Examining data/triggerhappy-0.5.0/devices.h
Examining data/triggerhappy-0.5.0/devtag.h
Examining data/triggerhappy-0.5.0/eventnames.c
Examining data/triggerhappy-0.5.0/eventnames.h
Examining data/triggerhappy-0.5.0/eventtable.h
Examining data/triggerhappy-0.5.0/ignore.c
Examining data/triggerhappy-0.5.0/ignore.h
Examining data/triggerhappy-0.5.0/keystate.c
Examining data/triggerhappy-0.5.0/keystate.h
Examining data/triggerhappy-0.5.0/obey.c
Examining data/triggerhappy-0.5.0/obey.h
Examining data/triggerhappy-0.5.0/th-cmd.c
Examining data/triggerhappy-0.5.0/thd.c
Examining data/triggerhappy-0.5.0/thd.h
Examining data/triggerhappy-0.5.0/trigger.c
Examining data/triggerhappy-0.5.0/trigger.h
Examining data/triggerhappy-0.5.0/triggerparser.c
Examining data/triggerhappy-0.5.0/triggerparser.h
Examining data/triggerhappy-0.5.0/uinput.c
Examining data/triggerhappy-0.5.0/uinput.h

FINAL RESULTS:

data/triggerhappy-0.5.0/cmdsocket.c:32: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, SD_DEBUG "Found socket passed from systemd\n");
data/triggerhappy-0.5.0/cmdsocket.c:45:2:  [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(addr.sun_path, name);
data/triggerhappy-0.5.0/cmdsocket.c:56:2:  [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(server.sun_path, name);
data/triggerhappy-0.5.0/keystate.c:73: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( res, buf );
data/triggerhappy-0.5.0/trigger.c:122:5:  [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(fpath, path);
data/triggerhappy-0.5.0/trigger.c:123:5:  [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(fpath, sep);
data/triggerhappy-0.5.0/trigger.c:124:5:  [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(fpath, file);
data/triggerhappy-0.5.0/trigger.c:230:6:  [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(et->action);
data/triggerhappy-0.5.0/th-cmd.c:72:7:  [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, "s:t:", long_options, &option_index);
data/triggerhappy-0.5.0/th-cmd.c:110:25:  [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 (strcasecmp("add", getenv("ACTION")) == 0) {
data/triggerhappy-0.5.0/th-cmd.c:112:35:  [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.
		} else if (strcasecmp("remove", getenv("ACTION")) == 0) {
data/triggerhappy-0.5.0/th-cmd.c:115:15:  [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 *dev = getenv("DEVNAME");
data/triggerhappy-0.5.0/thd.c:379:7:  [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, "t:s:dhpni:u:g:", long_options, &option_index);
data/triggerhappy-0.5.0/cmdsocket.c:71: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[CMSG_SPACE(sizeof fd)];
data/triggerhappy-0.5.0/cmdsocket.c:93:3:  [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(fd, CMSG_DATA(cmessage), sizeof fd);
data/triggerhappy-0.5.0/cmdsocket.c:131: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[CMSG_SPACE(sizeof(dev_fd))];
data/triggerhappy-0.5.0/cmdsocket.c:133: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).
		int fd = open( param, O_RDONLY );
data/triggerhappy-0.5.0/cmdsocket.c:148:3:  [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(CMSG_DATA(cmessage), dev_fd, sizeof dev_fd);
data/triggerhappy-0.5.0/command.h:25: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 param[TH_COMMAND_PARAM_LENGTH];
data/triggerhappy-0.5.0/command.h: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 tag[TH_DEVICE_TAG_LENGTH];
data/triggerhappy-0.5.0/devices.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 descr[256] = "Unknown";
data/triggerhappy-0.5.0/devices.c:59: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).
		fd = open( dev, O_RDONLY );
data/triggerhappy-0.5.0/devices.h:13: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 tag[TH_DEVICE_TAG_LENGTH];
data/triggerhappy-0.5.0/eventtable.h:11: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.
static const char *EV_NAME[EV_CNT] = {
data/triggerhappy-0.5.0/eventtable.h:15: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.
static const char *KEY_NAME[KEY_CNT] = {
data/triggerhappy-0.5.0/eventtable.h:20: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.
static const char *REL_NAME[REL_CNT] = {
data/triggerhappy-0.5.0/eventtable.h:24: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.
static const char *ABS_NAME[ABS_CNT] = {
data/triggerhappy-0.5.0/eventtable.h:28: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.
static const char *SW_NAME[SW_CNT] = {
data/triggerhappy-0.5.0/keystate.c:56: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[bsize];
data/triggerhappy-0.5.0/thd.c:198:14:  [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 = fopen( pidfile, "w+" );
data/triggerhappy-0.5.0/trigger.c:64:9:  [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).
	conf = fopen(filename, "r");
data/triggerhappy-0.5.0/trigger.c:121: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 fpath[strlen(path)+strlen(sep)+strlen(file) + 1];
data/triggerhappy-0.5.0/trigger.c:223:6:  [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 ev[8];
data/triggerhappy-0.5.0/trigger.c:224:6:  [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( &(ev[0]), "%d", et->value );
data/triggerhappy-0.5.0/trigger.h:18: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 devtag[TH_DEVICE_TAG_LENGTH];
data/triggerhappy-0.5.0/triggerparser.c:104:13:  [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).
	t->value = atoi(s_value);
data/triggerhappy-0.5.0/uinput.c:23:14:  [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).
	uinput_fd = open(path, O_WRONLY);
data/triggerhappy-0.5.0/uinput.c:28:2:  [2] (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). Risk is low because the source is a constant string.
	strcpy(device.name,"triggerhappy");
data/triggerhappy-0.5.0/cmdsocket.c:48:3:  [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(addr.sun_path) + sizeof (addr.sun_family));
data/triggerhappy-0.5.0/cmdsocket.c:59:3:  [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(server.sun_path) + sizeof (server.sun_family));
data/triggerhappy-0.5.0/cmdsocket.c:112:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(cmd.param, param, TH_COMMAND_PARAM_LENGTH);
data/triggerhappy-0.5.0/cmdsocket.c:116:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(cmd.tag, tag, TH_DEVICE_TAG_LENGTH);
data/triggerhappy-0.5.0/devices.c:83:4:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
			strncpy((*p)->tag, tag, TH_DEVICE_TAG_LENGTH);
data/triggerhappy-0.5.0/keystate.c:64:5:  [1] (buffer) strncat:
  Easily used incorrectly (e.g., incorrectly computing the correct maximum
  size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf,
  or automatically resizing strings.
				strncat( buf, KS, bsize-1-strlen(KS) );
data/triggerhappy-0.5.0/keystate.c:64: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).
				strncat( buf, KS, bsize-1-strlen(KS) );
data/triggerhappy-0.5.0/keystate.c:67:4:  [1] (buffer) strncat:
  Easily used incorrectly (e.g., incorrectly computing the correct maximum
  size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf,
  or automatically resizing strings.
			strncat( &(buf[0]), name, bsize-1-strlen(buf) );
data/triggerhappy-0.5.0/keystate.c:67:38:  [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).
			strncat( &(buf[0]), name, bsize-1-strlen(buf) );
data/triggerhappy-0.5.0/keystate.c:71:40:  [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 *res = malloc( sizeof(char) * (1+strlen(buf)) );
data/triggerhappy-0.5.0/thd.c:93: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).
	const int d = (state && strlen(state)>0);
data/triggerhappy-0.5.0/thd.c:108:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	int n = read( fd, &ev, sizeof(ev) );
data/triggerhappy-0.5.0/trigger.c:59:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ssize_t read;
data/triggerhappy-0.5.0/trigger.c:77: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).
		} else if (strlen(copy) > 0) {
data/triggerhappy-0.5.0/trigger.c:94: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).
	if ( end && end[ strlen(suffix) ] == '\0' ) {
data/triggerhappy-0.5.0/trigger.c:121: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).
				char fpath[strlen(path)+strlen(sep)+strlen(file) + 1];
data/triggerhappy-0.5.0/trigger.c:121: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).
				char fpath[strlen(path)+strlen(sep)+strlen(file) + 1];
data/triggerhappy-0.5.0/trigger.c:121:41:  [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 fpath[strlen(path)+strlen(sep)+strlen(file) + 1];
data/triggerhappy-0.5.0/trigger.c:142: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).
	if (strlen(t_tag) == 0) {
data/triggerhappy-0.5.0/triggerparser.c:36:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(t->devtag, &evdef[1], TH_DEVICE_TAG_LENGTH);
data/triggerhappy-0.5.0/triggerparser.c:109: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).
		char *end = s_action + strlen(s_action) - 1;

ANALYSIS SUMMARY:

Hits = 59
Lines analyzed = 1832 in approximately 0.06 seconds (30925 lines/second)
Physical Source Lines of Code (SLOC) = 1449
Hits@level = [0]  56 [1]  21 [2]  25 [3]   5 [4]   8 [5]   0
Hits@level+ = [0+] 115 [1+]  59 [2+]  38 [3+]  13 [4+]   8 [5+]   0
Hits/KSLOC@level+ = [0+] 79.3651 [1+] 40.7177 [2+] 26.225 [3+] 8.9717 [4+] 5.52105 [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.