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/usbmuxd-1.1.1/src/client.c
Examining data/usbmuxd-1.1.1/src/client.h
Examining data/usbmuxd-1.1.1/src/conf.c
Examining data/usbmuxd-1.1.1/src/conf.h
Examining data/usbmuxd-1.1.1/src/device.h
Examining data/usbmuxd-1.1.1/src/log.c
Examining data/usbmuxd-1.1.1/src/log.h
Examining data/usbmuxd-1.1.1/src/main.c
Examining data/usbmuxd-1.1.1/src/preflight.c
Examining data/usbmuxd-1.1.1/src/preflight.h
Examining data/usbmuxd-1.1.1/src/usb.c
Examining data/usbmuxd-1.1.1/src/usb.h
Examining data/usbmuxd-1.1.1/src/usbmuxd-proto.h
Examining data/usbmuxd-1.1.1/src/utils.c
Examining data/usbmuxd-1.1.1/src/utils.h
Examining data/usbmuxd-1.1.1/src/device.c

FINAL RESULTS:

data/usbmuxd-1.1.1/src/main.c:113:2:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
	chmod(socket_path, 0666);
data/usbmuxd-1.1.1/src/main.c:647:7:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
		if (chmod(userprefdir, 02775) < 0) {
data/usbmuxd-1.1.1/src/main.c:673:9:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
				if (chown(userprefdir, pw->pw_uid, pw->pw_gid) < 0) {
data/usbmuxd-1.1.1/src/client.c:459:4:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
			sprintf(idstring, "%u-%s", client->number, progname);
data/usbmuxd-1.1.1/src/log.c:75:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		sprintf(fs, "[%d] %s\n", level, fmt);
data/usbmuxd-1.1.1/src/log.c:89:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt);
data/usbmuxd-1.1.1/src/log.c:96: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, fs, ap);
data/usbmuxd-1.1.1/src/log.h:40:85:  [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.
void usbmuxd_log(enum loglevel level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
data/usbmuxd-1.1.1/src/main.c:101: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(bind_addr.sun_path, socket_path);
data/usbmuxd-1.1.1/src/utils.c:157: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(s1, s2);
data/usbmuxd-1.1.1/src/conf.c:199:2:  [3] (random) srand:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
	srand(time(NULL) - idx);
data/usbmuxd-1.1.1/src/main.c:428: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, opts_spec, longopts, (int *) 0);
data/usbmuxd-1.1.1/src/client.c:86:3:  [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(name, "/proc/%d/cmdline", pid);
data/usbmuxd-1.1.1/src/client.c:87: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).
		FILE* f = fopen(name, "r");
data/usbmuxd-1.1.1/src/client.c:319: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(client->ob_buf + client->ob_size, &hdr, sizeof(hdr));
data/usbmuxd-1.1.1/src/client.c:321: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(client->ob_buf + client->ob_size + sizeof(hdr), payload, payload_length);
data/usbmuxd-1.1.1/src/conf.c:112:2:  [2] (buffer) wchar_t:
  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.
	wchar_t path[MAX_PATH+1];
data/usbmuxd-1.1.1/src/device.c:229: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 + mux_header_size, header, hdrlen);
data/usbmuxd-1.1.1/src/device.c:231: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(buffer + mux_header_size + hdrlen, data, length);
data/usbmuxd-1.1.1/src/device.c:543: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(conn->ib_buf + conn->ib_size, payload, payload_length);
data/usbmuxd-1.1.1/src/device.c:673: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(buf, payload, payload_length);
data/usbmuxd-1.1.1/src/device.c:761: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(dev->pktbuf + dev->pktlen, buffer, length);
data/usbmuxd-1.1.1/src/device.c:776:4:  [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(dev->pktbuf, buffer, length);
data/usbmuxd-1.1.1/src/main.c:508: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 pids[10];
data/usbmuxd-1.1.1/src/main.c:532: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).
	res = lfd = open(lockfile, O_WRONLY|O_CREAT, 0644);
data/usbmuxd-1.1.1/src/main.c:596: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).
	res = lfd = open(lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
data/usbmuxd-1.1.1/src/main.c:609:2:  [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(pids, "%d", getpid());
data/usbmuxd-1.1.1/src/preflight.c:367: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(infocopy, info, sizeof(struct device_info));
data/usbmuxd-1.1.1/src/usb.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 serial[256];
data/usbmuxd-1.1.1/src/usbmuxd-proto.h:86: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 serial_number[256];
data/usbmuxd-1.1.1/src/utils.c:137: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(dest->list, src->list, sizeof(void*) * src->capacity);
data/usbmuxd-1.1.1/src/utils.c:225:6:  [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(filename, "rb");
data/usbmuxd-1.1.1/src/utils.c:262:6:  [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(filename, "wb");
data/usbmuxd-1.1.1/src/client.c:458:28:  [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 *idstring = malloc(strlen(progname) + 12);
data/usbmuxd-1.1.1/src/client.c:540:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(dmsg.serial_number, dev->serial, 256);
data/usbmuxd-1.1.1/src/conf.c:121:50:  [1] (buffer) wcslen:
  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).
			base_config_dir = config_utf16_to_utf8 (path, wcslen(path), NULL, NULL);
data/usbmuxd-1.1.1/src/conf.c:135: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).
		int i = strlen(__config_dir)-1;
data/usbmuxd-1.1.1/src/device.c:331:7:  [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/usbmuxd-1.1.1/src/device.c:600:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
				strncpy(buf, (char*)payload+1, payload_length-1);
data/usbmuxd-1.1.1/src/device.c:611:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
				strncpy(buf, (char*)payload+1, payload_length-1);
data/usbmuxd-1.1.1/src/log.c:72: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).
	fs = malloc(20 + strlen(fmt));
data/usbmuxd-1.1.1/src/main.c:290:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		if((res = read(pfd[0],&status,sizeof(int))) != sizeof(int)) {
data/usbmuxd-1.1.1/src/main.c:610: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).
	if ((size_t)(res = write(lfd, pids, strlen(pids))) != strlen(pids)) {
data/usbmuxd-1.1.1/src/main.c:610:56:  [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)(res = write(lfd, pids, strlen(pids))) != strlen(pids)) {
data/usbmuxd-1.1.1/src/preflight.c:97: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(notification) == 0) {
data/usbmuxd-1.1.1/src/utils.c:159: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).
	return s1 + strlen(s2);
data/usbmuxd-1.1.1/src/utils.c:187: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(str) + 1; /* plus 1 for the null terminator */
data/usbmuxd-1.1.1/src/utils.c:192:10:  [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(s);

ANALYSIS SUMMARY:

Hits = 48
Lines analyzed = 5550 in approximately 0.14 seconds (38572 lines/second)
Physical Source Lines of Code (SLOC) = 4264
Hits@level = [0]  34 [1]  15 [2]  21 [3]   2 [4]   7 [5]   3
Hits@level+ = [0+]  82 [1+]  48 [2+]  33 [3+]  12 [4+]  10 [5+]   3
Hits/KSLOC@level+ = [0+] 19.2308 [1+] 11.257 [2+] 7.73921 [3+] 2.81426 [4+] 2.34522 [5+] 0.703565
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.