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/libopenusb-1.1.11/src/api.c Examining data/libopenusb-1.1.11/src/bsd.c Examining data/libopenusb-1.1.11/src/darwin.c Examining data/libopenusb-1.1.11/src/darwin.h Examining data/libopenusb-1.1.11/src/descr.h Examining data/libopenusb-1.1.11/src/descriptors.c Examining data/libopenusb-1.1.11/src/devices.c Examining data/libopenusb-1.1.11/src/emulation.c Examining data/libopenusb-1.1.11/src/io.c Examining data/libopenusb-1.1.11/src/linux.c Examining data/libopenusb-1.1.11/src/linux.h Examining data/libopenusb-1.1.11/src/list.c Examining data/libopenusb-1.1.11/src/list.h Examining data/libopenusb-1.1.11/src/openusb.h Examining data/libopenusb-1.1.11/src/sunos.c Examining data/libopenusb-1.1.11/src/sunos.h Examining data/libopenusb-1.1.11/src/usb.c Examining data/libopenusb-1.1.11/src/usbi.h Examining data/libopenusb-1.1.11/tests/testopenusb.c FINAL RESULTS: data/libopenusb-1.1.11/src/bsd.c:278:5: [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(buf, sizeof(buf) - 1, "%s." EP_FORMAT, dpriv->filename, ep); data/libopenusb-1.1.11/src/emulation.c:65:9: [4] (format) vsnprintf: 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. (void) vsnprintf(usb_error_string, sizeof (usb_error_string), data/libopenusb-1.1.11/src/sunos.c:837:10: [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). (void) strcpy(p, str); data/libopenusb-1.1.11/src/usb.c:87:3: [4] (format) vsnprintf: 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. vsnprintf(str, sizeof (str), fmt, ap); data/libopenusb-1.1.11/src/linux.c:561:6: [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 (getenv("USB_PATH")) { data/libopenusb-1.1.11/src/linux.c:562:22: [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 (check_usb_path(getenv("USB_PATH"))) { data/libopenusb-1.1.11/src/linux.c:563:24: [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. strncpy(device_dir, getenv("USB_PATH"), sizeof(device_dir) - 1); data/libopenusb-1.1.11/src/usb.c:360:6: [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 (getenv("OPENUSB_DEBUG")) data/libopenusb-1.1.11/src/usb.c:361:37: [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. openusb_global_debug_level = atoi(getenv("OPENUSB_DEBUG")); data/libopenusb-1.1.11/src/usb.c:444:16: [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. driver_path = getenv("OPENUSB_BACKEND_PATH"); data/libopenusb-1.1.11/src/usb.c:536:6: [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 (getenv("OPENUSB_DEBUG")) data/libopenusb-1.1.11/src/usb.c:537:27: [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. hdl->debug_level = atoi(getenv("OPENUSB_DEBUG")); data/libopenusb-1.1.11/tests/testopenusb.c:1367:13: [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((c = getopt(argc, argv, "t:lmaps")) != -1) { data/libopenusb-1.1.11/src/api.c:319: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[8]; data/libopenusb-1.1.11/src/api.c:1150: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(result, &req->req.bulk->result, len); data/libopenusb-1.1.11/src/api.c:1152: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(result, &req->req.intr->result,len); data/libopenusb-1.1.11/src/api.c:1154: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(result, req->req.isoc->isoc_results,len); data/libopenusb-1.1.11/src/bsd.c:60: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 filename[PATH_MAX + 1]; data/libopenusb-1.1.11/src/bsd.c:157: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 ctlpath[PATH_MAX + 1]; data/libopenusb-1.1.11/src/bsd.c:169:13: [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(ctlpath, O_RDWR); data/libopenusb-1.1.11/src/bsd.c:171:15: [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(ctlpath, O_RDONLY); data/libopenusb-1.1.11/src/bsd.c:269: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 buf[20]; data/libopenusb-1.1.11/src/bsd.c:283: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). fd = open(buf, O_RDWR); data/libopenusb-1.1.11/src/bsd.c:285: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). fd = open(buf, mode); data/libopenusb-1.1.11/src/bsd.c:405: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 buf[20]; data/libopenusb-1.1.11/src/bsd.c:411: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). fd = open(buf, O_RDWR); data/libopenusb-1.1.11/src/bsd.c:447: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). cfd = open(bus->dirname, O_RDONLY); data/libopenusb-1.1.11/src/bsd.c:456: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 buf[20]; data/libopenusb-1.1.11/src/bsd.c:475:11: [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). dfd = open(buf, O_RDONLY); data/libopenusb-1.1.11/src/darwin.c:342: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 buf[20]; data/libopenusb-1.1.11/src/darwin.c:381:5: [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(buf, "%03i", busnum++); data/libopenusb-1.1.11/src/darwin.c:438: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(idev->sys_path, "%03i-%04x-%04x-%02x-%02x", address, idVendor, idProduct, bDeviceClass, bDeviceSubClass); data/libopenusb-1.1.11/src/darwin.c:735:41: [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). if (hdev && hdev->priv && hdev->priv->open) { data/libopenusb-1.1.11/src/darwin.c:923:36: [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). if (!usbInterface && hdev->priv->open && hdev->idev->cur_config_value == 0) { data/libopenusb-1.1.11/src/darwin.c:1603: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(bufferpos, isoc->pkts.packets[i].payload, isoc->pkts.packets[i].length); data/libopenusb-1.1.11/src/darwin.h:117:29: [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 open; /* device is open */ data/libopenusb-1.1.11/src/descriptors.c:103: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(dp, sp, 2); sp += 2; dp += 2; data/libopenusb-1.1.11/src/descriptors.c:112: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(dp, sp, 4); sp += 4; dp += 4; data/libopenusb-1.1.11/src/descriptors.c:241: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(ep->extra, extra, extra_len); data/libopenusb-1.1.11/src/descriptors.c:388: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(as->extra, extra, extra_len); data/libopenusb-1.1.11/src/descriptors.c:583: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(cfg->extra, extra, extra_len); data/libopenusb-1.1.11/src/descriptors.c:692: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 devbuf[USBI_DEVICE_DESC_SIZE+1]; data/libopenusb-1.1.11/src/descriptors.c:716: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(dev->desc.device_raw.data, devbuf, count); data/libopenusb-1.1.11/src/descriptors.c:752:12: [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[8]; data/libopenusb-1.1.11/src/devices.c:1180: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 tbuf[256]; data/libopenusb-1.1.11/src/devices.c:1262: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 strings[256]; data/libopenusb-1.1.11/src/devices.c:1379: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(pdata->manufacturer, strings, strings[0]); data/libopenusb-1.1.11/src/devices.c:1400: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(pdata->product, strings, strings[0]); data/libopenusb-1.1.11/src/devices.c:1421: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(pdata->serialnumber, strings, strings[0]); data/libopenusb-1.1.11/src/devices.c:1455: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(pdata->raw_cfg_desc, descdata, datalen); data/libopenusb-1.1.11/src/emulation.c:51: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 usb_error_string[1024]; data/libopenusb-1.1.11/src/emulation.c:179: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->filename, idev->sys_path, PATH_MAX); data/libopenusb-1.1.11/src/emulation.c:356: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(ep01->extra, ep10->extra, ep10->extralen); data/libopenusb-1.1.11/src/emulation.c:403: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(ifdesc->extra, alt->extra, alt->extralen); data/libopenusb-1.1.11/src/emulation.c:455: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(&dev->descriptor, &desc->device, sizeof(usb_device_desc_t)); data/libopenusb-1.1.11/src/emulation.c:497: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(pcfg->extra, config->extra, config->extralen); data/libopenusb-1.1.11/src/io.c:35: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 buf[2] = {1, 1}; /* We don't need this on OS/X */ data/libopenusb-1.1.11/src/io.c:97: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 buf[1]={1}; /* We don't need this on OS/X */ data/libopenusb-1.1.11/src/linux.c:35:8: [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 device_dir[PATH_MAX + 1] = ""; data/libopenusb-1.1.11/src/linux.c:123: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(idev->sys_path, O_RDWR); data/libopenusb-1.1.11/src/linux.c:125: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(idev->sys_path, O_RDONLY); data/libopenusb-1.1.11/src/linux.c:691:12: [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). busnum = atoi(entry->d_name); data/libopenusb-1.1.11/src/linux.c:724:18: [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). ibus->busnum = atoi(entry->d_name); data/libopenusb-1.1.11/src/linux.c:828: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(io->priv->urbs[0].buffer, setup, USBI_CONTROL_SETUP_LEN); data/libopenusb-1.1.11/src/linux.c:833: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(io->priv->urbs[0].buffer + USBI_CONTROL_SETUP_LEN, data/libopenusb-1.1.11/src/linux.c:1143: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(urb_buffer, isoc->pkts.packets[k].payload, packet_len); data/libopenusb-1.1.11/src/linux.c:1343: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(io->req->req.ctrl->payload, data/libopenusb-1.1.11/src/linux.c:1583: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(isoc->pkts.packets[io->priv->isoc_packet_offset].payload, data/libopenusb-1.1.11/src/linux.c:1822: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(&tvNext, &tvo, sizeof(tvo)); data/libopenusb-1.1.11/src/linux.c:2103: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(cfgr.data, buf, 8); data/libopenusb-1.1.11/src/linux.c:2134: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(cfgdescr, cfgr.data, cfgr.len); data/libopenusb-1.1.11/src/linux.c:2272: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). busnum = atoi(busnumString); data/libopenusb-1.1.11/src/linux.c:2292:14: [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). devnum = atoi(udev_device_get_sysattr_value(dev, "devnum")); data/libopenusb-1.1.11/src/linux.c:2295:20: [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). max_children = atoi(udev_device_get_sysattr_value(dev, "maxchild")); data/libopenusb-1.1.11/src/linux.c:2306:17: [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). pdevnum = atoi(pdevnumString); data/libopenusb-1.1.11/src/linux.h:62: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 driver[USBK_MAXDRIVERNAME + 1]; data/libopenusb-1.1.11/src/linux.h:110:12: [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 port[127]; /* port to device num mapping */ data/libopenusb-1.1.11/src/sunos.c:162: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 newpath[PATH_MAX+1]; data/libopenusb-1.1.11/src/sunos.c:493: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 ugendevstat[PATH_MAX]; data/libopenusb-1.1.11/src/sunos.c:506:11: [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). statfd = open(ugendevstat,O_RDONLY); data/libopenusb-1.1.11/src/sunos.c:621: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(*buffer, &hs_root_hub_dev_descr, data/libopenusb-1.1.11/src/sunos.c:624: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(*buffer, &fs_root_hub_dev_descr, data/libopenusb-1.1.11/src/sunos.c:635: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(*buffer, &root_hub_config_descriptor, data/libopenusb-1.1.11/src/sunos.c:700: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(descrp, pd, USBI_DEVICE_DESC_SIZE); data/libopenusb-1.1.11/src/sunos.c:729: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(descrp, rdata, proplen); data/libopenusb-1.1.11/src/sunos.c:1220: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 filename[PATH_MAX + 1]; data/libopenusb-1.1.11/src/sunos.c:1236:30: [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). hdev->priv->eps[0].datafd = open(filename, O_RDWR); data/libopenusb-1.1.11/src/sunos.c:1248:30: [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). hdev->priv->eps[0].statfd = open(filename, O_RDONLY); data/libopenusb-1.1.11/src/sunos.c:1747: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 filename[PATH_MAX + 1], statfilename[PATH_MAX + 1]; data/libopenusb-1.1.11/src/sunos.c:1748: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 cfg_num[16], alt_num[16]; data/libopenusb-1.1.11/src/sunos.c:1823: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). if ((fdstat = open(statfilename, O_RDWR)) == -1) { data/libopenusb-1.1.11/src/sunos.c:1860: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). if ((fd = open(filename, mode)) == -1) { data/libopenusb-1.1.11/src/sunos.c:1868:16: [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). if ((fdstat = open(statfilename, O_RDONLY)) == -1) { data/libopenusb-1.1.11/src/sunos.c:1891: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[USBI_CONTROL_SETUP_LEN]; data/libopenusb-1.1.11/src/sunos.c:1929:10: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. (void) memcpy(buf, data, USBI_CONTROL_SETUP_LEN); data/libopenusb-1.1.11/src/sunos.c:1930:10: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. (void) memcpy(buf + USBI_CONTROL_SETUP_LEN, ctrl->payload, data/libopenusb-1.1.11/src/sunos.c:2233: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((void *)p, packet[pkt].payload, data/libopenusb-1.1.11/src/sunos.c:2362: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(packet[pkt].payload, p, packet[pkt].length); data/libopenusb-1.1.11/src/usb.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 str[512]; data/libopenusb-1.1.11/src/usb.c:271: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 filepath[PATH_MAX]; data/libopenusb-1.1.11/src/usb.c:361:32: [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). openusb_global_debug_level = atoi(getenv("OPENUSB_DEBUG")); data/libopenusb-1.1.11/src/usb.c:537:22: [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). hdl->debug_level = atoi(getenv("OPENUSB_DEBUG")); data/libopenusb-1.1.11/src/usb.c:923:19: [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). ret = idev->ops->open(hdev); data/libopenusb-1.1.11/src/usb.c:1055: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 buf[1]={1}; /* We don't need this on OS/X */ data/libopenusb-1.1.11/src/usb.c:1325: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 buf[16]; data/libopenusb-1.1.11/src/usbi.h:29: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 filepath[PATH_MAX + 1]; /* plugin object path */ data/libopenusb-1.1.11/src/usbi.h:41: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 sys_path[PATH_MAX + 1]; /* file path */ data/libopenusb-1.1.11/src/usbi.h:67: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 sys_path[PATH_MAX + 1]; data/libopenusb-1.1.11/src/usbi.h:68: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 bus_path[OPENUSB_BUS_PATH_MAX]; data/libopenusb-1.1.11/src/usbi.h:195: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). int32_t (*open)(struct usbi_dev_handle *dev); data/libopenusb-1.1.11/tests/testopenusb.c:224: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[256]; data/libopenusb-1.1.11/tests/testopenusb.c:342: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 bulkdata[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:343: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 bulkrd[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:419: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 bulkdata[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:420: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 bulkrd[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:498: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 bulkdata[ISOC_PKT_NUM*ISOC_PKT_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:499: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 bulkrd[ISOC_PKT_NUM*ISOC_PKT_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:576: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 bulkdata[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:577: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 bulkrd[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:698: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 bulkdata[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:699: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 bulkrd[BULK_DATA_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:700: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 isocrd[ISOC_PKT_NUM*ISOC_PKT_LEN]; data/libopenusb-1.1.11/tests/testopenusb.c:862: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(req1, req, sizeof(struct openusb_request_handle)); data/libopenusb-1.1.11/tests/testopenusb.c:897: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(req1, req, sizeof(struct openusb_request_handle)); data/libopenusb-1.1.11/src/bsd.c:352:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, bytes + retrieved, numbytes - retrieved); data/libopenusb-1.1.11/src/bsd.c:427:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(bus->dirname, buf, sizeof(bus->dirname) - 1); data/libopenusb-1.1.11/src/bsd.c:506:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(dpriv->filename, buf, sizeof(dpriv->filename) - 1); data/libopenusb-1.1.11/src/darwin.c:302:5: [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 (10); data/libopenusb-1.1.11/src/darwin.c:382:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ibus->sys_path, buf, sizeof(ibus->sys_path) - 1); data/libopenusb-1.1.11/src/emulation.c:156:2: [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(bus->dirname, "/dev/usb/", sizeof(bus->dirname)); data/libopenusb-1.1.11/src/linux.c:90:7: [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(uts.release) < 4) data/libopenusb-1.1.11/src/linux.c:563:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(device_dir, getenv("USB_PATH"), sizeof(device_dir) - 1); data/libopenusb-1.1.11/src/linux.c:571:4: [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(device_dir, "/dev/bus/usb", sizeof(device_dir) - 1); data/libopenusb-1.1.11/src/linux.c:574:4: [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(device_dir, "/proc/bus/usb", sizeof(device_dir) - 1); data/libopenusb-1.1.11/src/linux.c:684:43: [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 (!strchr("0123456789", entry->d_name[strlen(entry->d_name) - 1])) { data/libopenusb-1.1.11/src/linux.c:1857:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(hdev->priv->event_pipe[0], buf, 1) == -1) { data/libopenusb-1.1.11/src/linux.c:1874:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(hdev->event_pipe[0], buf, 1) == -1) { data/libopenusb-1.1.11/src/linux.c:2053:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, devdescr, USBI_DEVICE_DESC_SIZE); data/libopenusb-1.1.11/src/linux.c:2080:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, buf, 8); data/libopenusb-1.1.11/src/linux.c:2105:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, cfgr.data + 8, cfgr.len - 8); data/libopenusb-1.1.11/src/linux.c:2183:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(name, getdrv.driver, namelen - 1); data/libopenusb-1.1.11/src/linux.c:2601:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(hotplug_pipe[0], &buf, 1) == -1) { data/libopenusb-1.1.11/src/sunos.c:520:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(statfd, &status, sizeof(status)) data/libopenusb-1.1.11/src/sunos.c:644:7: [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(idev->sys_path)) == 0) { data/libopenusb-1.1.11/src/sunos.c:795:11: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(p, str, data/libopenusb-1.1.11/src/sunos.c:796: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). strlen(str) - strlen(newstr) + 1); data/libopenusb-1.1.11/src/sunos.c:796:22: [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(str) - strlen(newstr) + 1); data/libopenusb-1.1.11/src/sunos.c:824:10: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(p, str, strlen(str) - strlen(newstr)); data/libopenusb-1.1.11/src/sunos.c:824: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). (void) strncpy(p, str, strlen(str) - strlen(newstr)); data/libopenusb-1.1.11/src/sunos.c:824: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). (void) strncpy(p, str, strlen(str) - strlen(newstr)); data/libopenusb-1.1.11/src/sunos.c:1597:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, &status, sizeof (status)); data/libopenusb-1.1.11/src/sunos.c:1703:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, data, size); data/libopenusb-1.1.11/src/usb.c:249:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(backend->filepath, filepath, PATH_MAX); data/libopenusb-1.1.11/src/usb.c:1326:4: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(devh->event_pipe[0], buf, sizeof(buf)); ANALYSIS SUMMARY: Hits = 154 Lines analyzed = 18488 in approximately 0.48 seconds (38719 lines/second) Physical Source Lines of Code (SLOC) = 12184 Hits@level = [0] 248 [1] 30 [2] 111 [3] 9 [4] 4 [5] 0 Hits@level+ = [0+] 402 [1+] 154 [2+] 124 [3+] 13 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 32.9941 [1+] 12.6395 [2+] 10.1773 [3+] 1.06697 [4+] 0.328299 [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.