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/libusbmuxd-2.0.2/common/collection.c
Examining data/libusbmuxd-2.0.2/common/collection.h
Examining data/libusbmuxd-2.0.2/common/socket.c
Examining data/libusbmuxd-2.0.2/common/socket.h
Examining data/libusbmuxd-2.0.2/common/thread.c
Examining data/libusbmuxd-2.0.2/common/thread.h
Examining data/libusbmuxd-2.0.2/include/usbmuxd-proto.h
Examining data/libusbmuxd-2.0.2/include/usbmuxd.h
Examining data/libusbmuxd-2.0.2/src/libusbmuxd.c
Examining data/libusbmuxd-2.0.2/tools/inetcat.c
Examining data/libusbmuxd-2.0.2/tools/iproxy.c

FINAL RESULTS:

data/libusbmuxd-2.0.2/src/libusbmuxd.c:116:77:  [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.
#define LIBUSBMUXD_DEBUG(level, format, ...) if (level <= libusbmuxd_debug) fprintf(stderr, ("[" PACKAGE "] " format), __VA_ARGS__); fflush(stderr);
data/libusbmuxd-2.0.2/common/thread.c:93:2:  [3] (misc) InitializeCriticalSection:
  Exceptions can be thrown in low-memory situations. Use
  InitializeCriticalSectionAndSpinCount instead.
	InitializeCriticalSection(mutex);
data/libusbmuxd-2.0.2/common/thread.c:111:2:  [3] (misc) EnterCriticalSection:
  On some versions of Windows, exceptions can be thrown in low-memory
  situations. Use InitializeCriticalSectionAndSpinCount instead.
	EnterCriticalSection(mutex);
data/libusbmuxd-2.0.2/src/libusbmuxd.c:161:30:  [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 *usbmuxd_socket_addr = getenv("USBMUXD_SOCKET_ADDRESS");
data/libusbmuxd-2.0.2/tools/inetcat.c:119:17:  [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, "dhu:lnv", longopts, NULL)) != -1) {
data/libusbmuxd-2.0.2/tools/iproxy.c:272: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, "dhu:lns:v", longopts, NULL)) != -1) {
data/libusbmuxd-2.0.2/common/socket.c:268: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 portstr[8];
data/libusbmuxd-2.0.2/common/socket.c:287: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(portstr, "%d", port);
data/libusbmuxd-2.0.2/common/socket.c:576: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 addrtxt[48];
data/libusbmuxd-2.0.2/common/socket.c:605: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 portstr[8];
data/libusbmuxd-2.0.2/common/socket.c:632: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(portstr, "%d", port);
data/libusbmuxd-2.0.2/include/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/libusbmuxd-2.0.2/include/usbmuxd.h:53: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 udid[44];
data/libusbmuxd-2.0.2/include/usbmuxd.h:55: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 conn_data[200];
data/libusbmuxd-2.0.2/src/libusbmuxd.c:224: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(devinfo->udid + 32, "%08x", devinfo->handle);
data/libusbmuxd-2.0.2/src/libusbmuxd.c:277:7:  [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(devinfo->conn_data, netaddr, addr_len);
data/libusbmuxd-2.0.2/src/libusbmuxd.c:381: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(header, &hdr, sizeof(hdr));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:395:5:  [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(*payload, &dwval, sizeof(dwval));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:427:6:  [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(*payload, &dwval, sizeof(dwval));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:439:6:  [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(*payload, &dwval, sizeof(dwval));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:464: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(header, &hdr, sizeof(hdr));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:498: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(result, res, sizeof(uint32_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:613: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).
	FILE *f = fopen(infopl, "r");
data/libusbmuxd-2.0.2/src/libusbmuxd.c:680: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).
	FILE *f = fopen("/proc/self/stat", "r");
data/libusbmuxd-2.0.2/src/libusbmuxd.c:831: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(&ev.device, dev, sizeof(usbmuxd_device_info_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:931: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 buff[EVENT_BUF_LEN] = {0};
data/libusbmuxd-2.0.2/src/libusbmuxd.c:1050: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(&handle, payload, sizeof(uint32_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:1064: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(&handle, payload, sizeof(uint32_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:1175:5:  [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(&ev.device, dev, sizeof(usbmuxd_device_info_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:1200:5:  [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(&ev.device, dev, sizeof(usbmuxd_device_info_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:1347:5:  [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(&handle, payload, sizeof(uint32_t));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:1380: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(&newlist[dev_cnt], di, sizeof(usbmuxd_device_info_t));
data/libusbmuxd-2.0.2/tools/inetcat.c:163:23:  [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).
    int device_port = atoi(argv[0]);
data/libusbmuxd-2.0.2/tools/inetcat.c:215: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.
        unsigned char saddr_[32];
data/libusbmuxd-2.0.2/tools/inetcat.c:220:13:  [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(&saddr->sa_data[0], (char*)dev->conn_data+2, 14);
data/libusbmuxd-2.0.2/tools/inetcat.c:225:13:  [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(&saddr->sa_data[0], (char*)dev->conn_data+2, 26);
data/libusbmuxd-2.0.2/tools/inetcat.c:237: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.
        char addrtxt[48];
data/libusbmuxd-2.0.2/tools/iproxy.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 buffer[32768];
data/libusbmuxd-2.0.2/tools/iproxy.c:136: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(&saddr->sa_data[0], (char*)dev->conn_data + 2, 14);
data/libusbmuxd-2.0.2/tools/iproxy.c:142: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(&saddr->sa_data[0], (char*)dev->conn_data + 2, 26);
data/libusbmuxd-2.0.2/tools/iproxy.c:154: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 addrtxt[48];
data/libusbmuxd-2.0.2/common/socket.c:155:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(name.sun_path, filename, sizeof(name.sun_path));
data/libusbmuxd-2.0.2/common/socket.c:221:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(name.sun_path, filename, sizeof(name.sun_path));
data/libusbmuxd-2.0.2/src/libusbmuxd.c:87:13:  [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).
	size_t n = strlen(src);
data/libusbmuxd-2.0.2/src/libusbmuxd.c:90:9:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	return strncpy(dst, src, len) + n;
data/libusbmuxd-2.0.2/src/libusbmuxd.c:219: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(devinfo->udid) == 24) {
data/libusbmuxd-2.0.2/src/libusbmuxd.c:577:23:  [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 *p = execpath + strlen(execpath) - 1;
data/libusbmuxd-2.0.2/src/libusbmuxd.c:598:15:  [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).
	size_t len = strlen(execpath) + sizeof(CONTENTS_INFO_PLIST) + 1;
data/libusbmuxd-2.0.2/src/libusbmuxd.c:664: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).
			char *p = pname+strlen(pname)-1;
data/libusbmuxd-2.0.2/src/libusbmuxd.c:934:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		len = read (inot_fd, buff, EVENT_BUF_LEN -1);
data/libusbmuxd-2.0.2/tools/inetcat.c:73:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    ssize_t ret = read(fd, buf, bufread);

ANALYSIS SUMMARY:

Hits = 51
Lines analyzed = 4283 in approximately 0.12 seconds (34709 lines/second)
Physical Source Lines of Code (SLOC) = 3254
Hits@level = [0]  65 [1]  10 [2]  35 [3]   5 [4]   1 [5]   0
Hits@level+ = [0+] 116 [1+]  51 [2+]  41 [3+]   6 [4+]   1 [5+]   0
Hits/KSLOC@level+ = [0+] 35.6484 [1+] 15.673 [2+] 12.5999 [3+] 1.84388 [4+] 0.307314 [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.