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/midish-1.0.4/builtin.c
Examining data/midish-1.0.4/builtin.h
Examining data/midish-1.0.4/cons.c
Examining data/midish-1.0.4/cons.h
Examining data/midish-1.0.4/conv.c
Examining data/midish-1.0.4/conv.h
Examining data/midish-1.0.4/data.c
Examining data/midish-1.0.4/data.h
Examining data/midish-1.0.4/dbg.c
Examining data/midish-1.0.4/dbg.h
Examining data/midish-1.0.4/defs.h
Examining data/midish-1.0.4/ev.c
Examining data/midish-1.0.4/ev.h
Examining data/midish-1.0.4/exec.c
Examining data/midish-1.0.4/exec.h
Examining data/midish-1.0.4/filt.c
Examining data/midish-1.0.4/filt.h
Examining data/midish-1.0.4/frame.c
Examining data/midish-1.0.4/frame.h
Examining data/midish-1.0.4/lex.c
Examining data/midish-1.0.4/lex.h
Examining data/midish-1.0.4/main.c
Examining data/midish-1.0.4/mdep.c
Examining data/midish-1.0.4/smf.c
Examining data/midish-1.0.4/mdep_alsa.c
Examining data/midish-1.0.4/mdep_raw.c
Examining data/midish-1.0.4/mdep_sndio.c
Examining data/midish-1.0.4/metro.c
Examining data/midish-1.0.4/metro.h
Examining data/midish-1.0.4/mididev.c
Examining data/midish-1.0.4/mididev.h
Examining data/midish-1.0.4/mixout.c
Examining data/midish-1.0.4/mixout.h
Examining data/midish-1.0.4/mux.c
Examining data/midish-1.0.4/mux.h
Examining data/midish-1.0.4/name.c
Examining data/midish-1.0.4/name.h
Examining data/midish-1.0.4/node.c
Examining data/midish-1.0.4/node.h
Examining data/midish-1.0.4/norm.c
Examining data/midish-1.0.4/norm.h
Examining data/midish-1.0.4/parse.c
Examining data/midish-1.0.4/parse.h
Examining data/midish-1.0.4/pool.c
Examining data/midish-1.0.4/pool.h
Examining data/midish-1.0.4/rmidish.c
Examining data/midish-1.0.4/saveload.c
Examining data/midish-1.0.4/saveload.h
Examining data/midish-1.0.4/smf.h
Examining data/midish-1.0.4/song.c
Examining data/midish-1.0.4/song.h
Examining data/midish-1.0.4/state.c
Examining data/midish-1.0.4/state.h
Examining data/midish-1.0.4/str.c
Examining data/midish-1.0.4/str.h
Examining data/midish-1.0.4/sysex.c
Examining data/midish-1.0.4/sysex.h
Examining data/midish-1.0.4/textio.c
Examining data/midish-1.0.4/textio.h
Examining data/midish-1.0.4/timo.c
Examining data/midish-1.0.4/timo.h
Examining data/midish-1.0.4/track.c
Examining data/midish-1.0.4/track.h
Examining data/midish-1.0.4/user.c
Examining data/midish-1.0.4/user.h

FINAL RESULTS:

data/midish-1.0.4/mdep.c:344:3:  [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(name, PATH_MAX, "%s" "/" "." RC_NAME, home);
data/midish-1.0.4/mdep_alsa.c:83:3:  [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/midish-1.0.4/rmidish.c:105:7:  [4] (shell) execlp:
  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.
		if (execlp(path, path, "-v", (char *)NULL) < 0) {
data/midish-1.0.4/rmidish.c:366:7:  [4] (shell) execlp:
  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.
		if (execlp(path, path, (char *)NULL) < 0) {
data/midish-1.0.4/main.c:55:15:  [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.
	while ((ch = getopt(argc, argv, "bv")) != -1) {
data/midish-1.0.4/mdep.c:342: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.
	home = getenv("HOME");
data/midish-1.0.4/builtin.c:550: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 map[DEFAULT_MAXNCHANS];
data/midish-1.0.4/builtin.c:1799: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 map[DEFAULT_MAXNCHANS];
data/midish-1.0.4/dbg.c:60:1:  [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 dbg_buf[DBG_BUFSZ];	/* buffer where traces are stored */
data/midish-1.0.4/dbg.c:98: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 dig[sizeof(num) * 2], *p = dig, c;
data/midish-1.0.4/dbg.c:121: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 dig[sizeof(num) * 3], *p = dig;
data/midish-1.0.4/lex.h: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 strval[TOK_MAXLEN + 1];
data/midish-1.0.4/mdep.c:73:1:  [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 cons_buf[CONS_BUFSIZE];
data/midish-1.0.4/mdep.c:153:18:  [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 unsigned char midibuf[MIDI_BUFSIZE];
data/midish-1.0.4/mdep.c:339: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[PATH_MAX];
data/midish-1.0.4/mdep_alsa.c:123: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/midish-1.0.4/mdep_raw.c:109: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).
	dev->fd = open(dev->path, mode, 0666);
data/midish-1.0.4/mididev.c:279:10:  [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).
	o->ops->open(o);
data/midish-1.0.4/mididev.h:60:9:  [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 (*open)(struct mididev *);
data/midish-1.0.4/mididev.h:100:11:  [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 nibble[8];	/* nibbles of hr:min:sec:fr */
data/midish-1.0.4/mididev.h:139:11:  [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	  idata[2];		/* current event's data */
data/midish-1.0.4/mididev.h:144:11:  [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	  obuf[MIDIDEV_BUFLEN];	/* output buffer */
data/midish-1.0.4/mux.c:781:11:  [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 mmc_reloc[13];
data/midish-1.0.4/node.c:76: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.
	static char str[2 * NODE_MAXDEPTH + 1] = "";
data/midish-1.0.4/rmidish.c:62:11:  [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 buf[MIDISH_BUFLEN];	/* fifo for reading */
data/midish-1.0.4/rmidish.c:224:1:  [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 linebuf[LINELENGTH];
data/midish-1.0.4/rmidish.c:225:1:  [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 prompt[PROMPTLENGTH] = "[----:--]>";
data/midish-1.0.4/rmidish.c:339: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[PATH_MAX];
data/midish-1.0.4/rmidish.c:350: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(path, argv[0], dirlen);
data/midish-1.0.4/rmidish.c:359: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(path + dirlen, MIDISH, filelen + 1);
data/midish-1.0.4/smf.c:47:1:  [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 smftype_header[4] = { 'M', 'T', 'h', 'd' };
data/midish-1.0.4/smf.c:48:1:  [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 smftype_track[4]  = { 'M', 'T', 'r', 'k' };
data/midish-1.0.4/smf.c:68:12:  [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).
	o->file = fopen(path, mode);
data/midish-1.0.4/smf.c:93:11:  [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 buf[4];
data/midish-1.0.4/smf.c:109:11:  [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 buf[4];
data/midish-1.0.4/smf.c:125:11:  [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 buf[4];
data/midish-1.0.4/smf.c:193: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[4];
data/midish-1.0.4/smf.c:231:11:  [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 buf[4];
data/midish-1.0.4/smf.c:254:11:  [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 buf[4];
data/midish-1.0.4/smf.c:276:11:  [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 buf[4];
data/midish-1.0.4/smf.c:318:11:  [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 buf[MAXBYTES];
data/midish-1.0.4/smf.c:833: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 trackname[MAXTRACKNAME];
data/midish-1.0.4/smf.c:890: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 trackname[MAXTRACKNAME];
data/midish-1.0.4/sysex.h:38:11:  [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 data[CHUNK_SIZE];
data/midish-1.0.4/textio.c:73:13:  [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).
		o->file = fopen(filename, "r");
data/midish-1.0.4/textio.c:136:13:  [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).
		o->file = fopen(filename, "w");
data/midish-1.0.4/mdep.c:190:21:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
				res = dev->ops->read(dev, midibuf, MIDI_BUFSIZE);
data/midish-1.0.4/mdep.c:230:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		res = read(STDIN_FILENO, cons_buf, CONS_BUFSIZE);
data/midish-1.0.4/mdep_raw.c:134:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	res = read(dev->fd, buf, count);
data/midish-1.0.4/mididev.h:65:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	unsigned (*read)(struct mididev *, unsigned char *, unsigned);
data/midish-1.0.4/rmidish.c:160:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		n = read(p->sout, p->buf + end, count);
data/midish-1.0.4/rmidish.c:185: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).
	if (write(p->sin, str, strlen(str)) < 0) {
data/midish-1.0.4/rmidish.c:319: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(text);
data/midish-1.0.4/rmidish.c:348: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).
		dirlen = strlen(argv[0]);
data/midish-1.0.4/rmidish.c:354: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).
	filelen = strlen(MIDISH);
data/midish-1.0.4/smf.c:142:39:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	if (o->index + 1 > o->length || (c = fgetc(o->file)) < 0) {
data/midish-1.0.4/smf.c:162:40:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		if (o->index + 1 > o->length || (c = fgetc(o->file)) == EOF) {
data/midish-1.0.4/textio.c:99:8:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		*c = fgetc(o->file);

ANALYSIS SUMMARY:

Hits = 58
Lines analyzed = 24133 in approximately 0.57 seconds (42680 lines/second)
Physical Source Lines of Code (SLOC) = 17542
Hits@level = [0]  27 [1]  12 [2]  40 [3]   2 [4]   4 [5]   0
Hits@level+ = [0+]  85 [1+]  58 [2+]  46 [3+]   6 [4+]   4 [5+]   0
Hits/KSLOC@level+ = [0+] 4.84551 [1+] 3.30635 [2+] 2.62228 [3+] 0.342036 [4+] 0.228024 [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.