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/ufiformat-0.9.9/ufi_detect.h
Examining data/ufiformat-0.9.9/ufi_command.h
Examining data/ufiformat-0.9.9/ufi_format.c
Examining data/ufiformat-0.9.9/ufi_detect.c
Examining data/ufiformat-0.9.9/ufi_command.c

FINAL RESULTS:

data/ufiformat-0.9.9/ufi_detect.c:233:11:  [5] (race) readlink:
  This accepts filename arguments; if an attacker can move those files or
  change the link content, a race condition results. Also, it does not
  terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach.
	if ((n = readlink(path, buf, sizeof(buf))) < 12 || strncmp(buf + n - 12, "/usb-storage", 12) != 0) {
data/ufiformat-0.9.9/ufi_detect.c:58:12:  [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).
    return strcpy(dst, src);
data/ufiformat-0.9.9/ufi_format.c:423: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, short_options, long_options, NULL)) != -1) {
data/ufiformat-0.9.9/ufi_command.c:79:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char sense_buffer[32];
data/ufiformat-0.9.9/ufi_command.c:147: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(name, src + offset, i);
data/ufiformat-0.9.9/ufi_command.c:165:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char response[READ_FORMAT_CAPACITIES_CMD[8]];
data/ufiformat-0.9.9/ufi_command.c:197:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char response[INQUIRY_CMD[8]];
data/ufiformat-0.9.9/ufi_command.c:211:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char response[MODE_SENSE_CMD[8]];
data/ufiformat-0.9.9/ufi_command.c:222:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char command[sizeof(FORMAT_UNIT_CMD)];
data/ufiformat-0.9.9/ufi_command.c:223:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char data[sizeof(FORMAT_UNIT_DATA)];
data/ufiformat-0.9.9/ufi_detect.c:86: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).
    if ((fd = open(dev, O_RDONLY | O_NONBLOCK)) < 0) {
data/ufiformat-0.9.9/ufi_detect.c:99: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 tmp[PATH_MAX];
data/ufiformat-0.9.9/ufi_detect.c:111:6:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
	    sprintf(tmp, "/dev/sd%c", 'a' + i);
data/ufiformat-0.9.9/ufi_detect.c:113:6:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
	    sprintf(tmp, "/dev/sd%c%c", 'a' + (i / 26), 'a' + (i % 26));
data/ufiformat-0.9.9/ufi_detect.c:132: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 tmp[PATH_MAX];
data/ufiformat-0.9.9/ufi_detect.c:143: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(tmp, "/dev/sg%d", i);
data/ufiformat-0.9.9/ufi_detect.c:224: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 path[PATH_MAX];
data/ufiformat-0.9.9/ufi_detect.c:225: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[1024];
data/ufiformat-0.9.9/ufi_detect.c:229: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(path, "/sys/class/scsi_host/host%d/device/../driver", host_id);
data/ufiformat-0.9.9/ufi_detect.c:237: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(path, "/sys/class/scsi_host/host%d/device/../bInterfaceClass", host_id);
data/ufiformat-0.9.9/ufi_detect.c:238: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).
	if ((fp = fopen(path, "r")) == NULL) {
data/ufiformat-0.9.9/ufi_detect.c:247: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(path, "/sys/class/scsi_host/host%d/device/../bInterfaceSubClass", host_id);
data/ufiformat-0.9.9/ufi_detect.c:248: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).
	if ((fp = fopen(path, "r")) == NULL) {
data/ufiformat-0.9.9/ufi_detect.c:260: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(path, "/proc/scsi/usb-storage/%d", host_id);
data/ufiformat-0.9.9/ufi_detect.c:261:15:  [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).
    if ((fp = fopen(path, "r")) == NULL) {
data/ufiformat-0.9.9/ufi_detect.c:263:6:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
	    sprintf(path, "/proc/scsi/usb-storage-%d/%d", i, host_id);
data/ufiformat-0.9.9/ufi_detect.c:264:16:  [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).
	    if ((fp = fopen(path, "r")) != NULL) {
data/ufiformat-0.9.9/ufi_detect.c:306: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 sg_path[PATH_MAX];
data/ufiformat-0.9.9/ufi_detect.c:307: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 sd_path[PATH_MAX];
data/ufiformat-0.9.9/ufi_format.c:118: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).
    if ((fd = open(sg, O_RDWR | O_NONBLOCK)) < 0) {
data/ufiformat-0.9.9/ufi_format.c:251: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).
    if ((fd = open(sg, O_RDWR | O_NONBLOCK)) < 0) {
data/ufiformat-0.9.9/ufi_format.c:333: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).
	while ((fd = open(sg, O_RDONLY)) < 0 && errno == ENOMEDIUM && time(NULL) - tt < 10) {
data/ufiformat-0.9.9/ufi_format.c:421: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 tmp[256];
data/ufiformat-0.9.9/ufi_format.c:430: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).
	    format_size = atoi(optarg);
data/ufiformat-0.9.9/ufi_format.c:431:6:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
	    sprintf(tmp, "%d", format_size);
data/ufiformat-0.9.9/ufi_detect.c:54:9:  [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(src) >= len) {
data/ufiformat-0.9.9/ufi_format.c:346:12:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		if ((n = read(fd, buf, sector * block)) != sector * block) {

ANALYSIS SUMMARY:

Hits = 37
Lines analyzed = 1192 in approximately 0.04 seconds (27496 lines/second)
Physical Source Lines of Code (SLOC) = 975
Hits@level = [0]  36 [1]   2 [2]  32 [3]   1 [4]   1 [5]   1
Hits@level+ = [0+]  73 [1+]  37 [2+]  35 [3+]   3 [4+]   2 [5+]   1
Hits/KSLOC@level+ = [0+] 74.8718 [1+] 37.9487 [2+] 35.8974 [3+] 3.07692 [4+] 2.05128 [5+] 1.02564
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.