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/hdparm-9.58+ds/sgio.c Examining data/hdparm-9.58+ds/fallocate.c Examining data/hdparm-9.58+ds/wdidle3.c Examining data/hdparm-9.58+ds/apt.c Examining data/hdparm-9.58+ds/dvdspeed.c Examining data/hdparm-9.58+ds/sgio.h Examining data/hdparm-9.58+ds/hdparm.h Examining data/hdparm-9.58+ds/geom.c Examining data/hdparm-9.58+ds/identify.c Examining data/hdparm-9.58+ds/fibmap.c Examining data/hdparm-9.58+ds/contrib/make_bad_sector.c Examining data/hdparm-9.58+ds/contrib/fix_standby.c Examining data/hdparm-9.58+ds/fwdownload.c Examining data/hdparm-9.58+ds/sysfs.c Examining data/hdparm-9.58+ds/hdparm.c FINAL RESULTS: data/hdparm-9.58+ds/geom.c:234:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(path, "%s/%s", dir, entry->d_name); data/hdparm-9.58+ds/hdparm.c:191:2: [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. printf(value ? " (on)\n" : " (off)\n"); data/hdparm-9.58+ds/hdparm.c:533:3: [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. printf((idw[49] & 0x400) ? "on/off" : "yes"); data/hdparm-9.58+ds/hdparm.c:2968:24: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. const char *passwd = getpass("Please enter the drive password: "); data/hdparm-9.58+ds/hdparm.c:2977:3: [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(security_password, passwd); data/hdparm-9.58+ds/hdparm.c:3005:3: [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(security_password, argp); data/hdparm-9.58+ds/hdparm.c:3312:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(err_prefix, "%s[%u]", name, i); data/hdparm-9.58+ds/sysfs.c:28: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(pathtail+1, new); data/hdparm-9.58+ds/sysfs.c:46:13: [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. count = fprintf(fp, fmt, val); data/hdparm-9.58+ds/sysfs.c:50:13: [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. count = fprintf(fp, fmt, *(unsigned int *)val); data/hdparm-9.58+ds/sysfs.c:54:14: [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. count = fprintf(fp, fmt, *(unsigned long long *)val); data/hdparm-9.58+ds/sysfs.c:56:14: [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. count = fprintf(fp, fmt, *(unsigned long *)val); data/hdparm-9.58+ds/sysfs.c:80:11: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. count = fscanf(fp, fmt, val1, val2); data/hdparm-9.58+ds/sysfs.c:105:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(pathtail, "/%s", entry->d_name); data/hdparm-9.58+ds/sysfs.c:218: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(path, start_path); data/hdparm-9.58+ds/sysfs.c:229:3: [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(file_path, path); data/hdparm-9.58+ds/sysfs.c:231:3: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(file_path, attr); data/hdparm-9.58+ds/sysfs.c:233:7: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(file_path, F_OK | R_OK) == 0) { data/hdparm-9.58+ds/apt.c:164: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 cdb[12]; data/hdparm-9.58+ds/contrib/make_bad_sector.c:106: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(devpath, O_RDWR); data/hdparm-9.58+ds/dvdspeed.c:21: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 buffer[28]; data/hdparm-9.58+ds/fallocate.c:34: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(path, O_WRONLY|O_CREAT|O_EXCL, 0600); data/hdparm-9.58+ds/fibmap.c:34: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 lba_info[64], len_info[32]; data/hdparm-9.58+ds/fibmap.c:46: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(lba_info, "%10llu %10llu", begin_lba, end_lba); data/hdparm-9.58+ds/fibmap.c:48:3: [2] (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). Risk is low because the source is a constant string. strcpy(lba_info, " - - "); data/hdparm-9.58+ds/fibmap.c:50:3: [2] (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). Risk is low because the source is a constant string. strcpy(len_info, " - "); data/hdparm-9.58+ds/fibmap.c:52: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(len_info, "%10llu", nsectors); data/hdparm-9.58+ds/fibmap.c:225: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(file_name, O_RDONLY)) == -1) { data/hdparm-9.58+ds/fwdownload.c:59: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(r->data, data, bytecount); data/hdparm-9.58+ds/fwdownload.c:98: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). if ((fwfd = open(fwpath, O_RDONLY)) == -1 || fstat(fwfd, &st) == -1) { data/hdparm-9.58+ds/geom.c:28: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/hdparm-9.58+ds/geom.c:30: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 *fp = fopen(proc_devices, "r"); data/hdparm-9.58+ds/geom.c:40:15: [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). *major = atoi(buf); data/hdparm-9.58+ds/geom.c:109: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[32]; data/hdparm-9.58+ds/geom.c:120: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 member_path[32]; data/hdparm-9.58+ds/geom.c:121: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(member_path, "md/rd%u/offset", member); data/hdparm-9.58+ds/geom.c:124: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(member_path, "md/rd%u/block/dev", member); data/hdparm-9.58+ds/geom.c:127:31: [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). if (md_major() == (unsigned)atoi(buf)) /* disallow recursive RAIDs */ data/hdparm-9.58+ds/geom.c:129: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(member_path, "md/rd%u/block/start", member); data/hdparm-9.58+ds/geom.c:256: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/hdparm-9.58+ds/geom.c:263: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(path, O_RDONLY|O_NONBLOCK); data/hdparm-9.58+ds/hdparm.c:98: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 security_password[33], *fwpath, *raw_identify_path; data/hdparm-9.58+ds/hdparm.c:103: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. static const char *sanitize_states_str[SANITIZE_STATE_NUMBER] = { data/hdparm-9.58+ds/hdparm.c:110: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. static const char *sanitize_err_reason_str[SANITIZE_ERR_NUMBER] = { data/hdparm-9.58+ds/hdparm.c:185:7: [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. const char *BuffType[4] = {"unknown", "1Sect", "DualPort", "DualPortCache"}; data/hdparm-9.58+ds/hdparm.c:467: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 pmodes[64] = {0,}, dmodes[128]={0,}, umodes[128]={0,}; data/hdparm-9.58+ds/hdparm.c:500:3: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(pmodes, "pio0 "); data/hdparm-9.58+ds/hdparm.c:501:18: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (tPIO >= 1) strcat(pmodes, "pio1 "); data/hdparm-9.58+ds/hdparm.c:502:18: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (tPIO >= 2) strcat(pmodes, "pio2 "); data/hdparm-9.58+ds/hdparm.c:514:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[62] & 1) strcat(dmodes,"sdma0 "); data/hdparm-9.58+ds/hdparm.c:516:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[62] & 2) strcat(dmodes,"sdma1 "); data/hdparm-9.58+ds/hdparm.c:518:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[62] & 4) strcat(dmodes,"sdma2 "); data/hdparm-9.58+ds/hdparm.c:520:24: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[62] & 0xf8) strcat(dmodes,"sdma? "); data/hdparm-9.58+ds/hdparm.c:522:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[63] & 1) strcat(dmodes,"mdma0 "); data/hdparm-9.58+ds/hdparm.c:524:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[63] & 2) strcat(dmodes,"mdma1 "); data/hdparm-9.58+ds/hdparm.c:526:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[63] & 4) strcat(dmodes,"mdma2 "); data/hdparm-9.58+ds/hdparm.c:528:24: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[63] & 0xf8) strcat(dmodes,"mdma? "); data/hdparm-9.58+ds/hdparm.c:539:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[64] & 1) strcat(pmodes, "pio3 "); data/hdparm-9.58+ds/hdparm.c:540:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[64] & 2) strcat(pmodes, "pio4 "); data/hdparm-9.58+ds/hdparm.c:541:21: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[64] &~3) strcat(pmodes, "pio? "); data/hdparm-9.58+ds/hdparm.c:545:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x001) strcat(umodes,"udma0 "); data/hdparm-9.58+ds/hdparm.c:547:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x002) strcat(umodes,"udma1 "); data/hdparm-9.58+ds/hdparm.c:549:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x004) strcat(umodes,"udma2 "); data/hdparm-9.58+ds/hdparm.c:551:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x008) strcat(umodes,"udma3 "); data/hdparm-9.58+ds/hdparm.c:553:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x010) strcat(umodes,"udma4 "); data/hdparm-9.58+ds/hdparm.c:555:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x020) strcat(umodes,"udma5 "); data/hdparm-9.58+ds/hdparm.c:557:25: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. if (idw[88] & 0x040) strcat(umodes,"udma6 "); data/hdparm-9.58+ds/hdparm.c:601:15: [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 const char *states[4] = {"off", "on", "tristate", "unknown"}; data/hdparm-9.58+ds/hdparm.c:954: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(data+2, security_password, 32); data/hdparm-9.58+ds/hdparm.c:1105: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, r->data, 512); data/hdparm-9.58+ds/hdparm.c:1308: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(data, (__u8*) dco, 512); data/hdparm-9.58+ds/hdparm.c:1573: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(dst, idw, bytes); data/hdparm-9.58+ds/hdparm.c:1585: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 model[41]; data/hdparm-9.58+ds/hdparm.c:2001: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(devname, open_flags); data/hdparm-9.58+ds/hdparm.c:2669: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). int rfd = open(raw_identify_path, O_WRONLY|O_TRUNC|O_CREAT, 0644); data/hdparm-9.58+ds/hdparm.c:3310: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 err_prefix[64]; data/hdparm-9.58+ds/hdparm.c:3373: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/hdparm-9.58+ds/hdparm.h:43: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. extern const char *BuffType[4]; data/hdparm-9.58+ds/identify.c:228: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. static const char *feat_word59_str[16] = { data/hdparm-9.58+ds/identify.c:264:7: [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. const char *minor_str[MINOR_MAX+2] = { /* word 81 value: */ data/hdparm-9.58+ds/identify.c:302:7: [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. const char actual_ver[MINOR_MAX+2] = { data/hdparm-9.58+ds/identify.c:349: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. static const char unknown[8] = "obsolete"; data/hdparm-9.58+ds/identify.c:353: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. static const char *feat_word69_str[16] = { data/hdparm-9.58+ds/identify.c:372: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. static const char *feat_word82_str[16] = { data/hdparm-9.58+ds/identify.c:390: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. static const char *feat_word83_str[16] = { data/hdparm-9.58+ds/identify.c:408: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. static const char *feat_word84_str[16] = { data/hdparm-9.58+ds/identify.c:426: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. static const char *feat_3_str[16] = { data/hdparm-9.58+ds/identify.c:444: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. static const char *cap_sata0_str[16] = { data/hdparm-9.58+ds/identify.c:462: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. static const char *feat_sata0_str[16] = { data/hdparm-9.58+ds/identify.c:524: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. static const char *feat_sct_str[16] = { data/hdparm-9.58+ds/identify.c:1298: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 modes[256]; data/hdparm-9.58+ds/identify.c:1308: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(modes + strlen(modes), "pio%u ", mode + 4); data/hdparm-9.58+ds/identify.c:1318: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(modes + strlen(modes), "mdma%u ", mode + 2); data/hdparm-9.58+ds/identify.c:1323:26: [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 const unsigned char io_times [4] = {255,120,100,80}; data/hdparm-9.58+ds/identify.c:1324:26: [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 const unsigned char mem_times[4] = {250,120,100,80}; data/hdparm-9.58+ds/identify.c:1338: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(modes + strlen(modes), "io_udma%u ", mode + 4); data/hdparm-9.58+ds/identify.c:1348: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(modes + strlen(modes), "mem_udma%u ", mode + 4); data/hdparm-9.58+ds/sgio.c:193: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 cdb[SG_ATA_16_LEN]; data/hdparm-9.58+ds/sgio.c:194: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 sb[32], *desc; data/hdparm-9.58+ds/sysfs.c:38:7: [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). fp = fopen(path, "w"); data/hdparm-9.58+ds/sysfs.c:76:7: [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). fp = fopen(path, "r"); data/hdparm-9.58+ds/sysfs.c:128:2: [2] (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). Risk is low because the source is a constant string. strcpy(path, "/sys/block"); data/hdparm-9.58+ds/sysfs.c:156: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 path[PATH_MAX]; data/hdparm-9.58+ds/sysfs.c:202: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 path[PATH_MAX]; data/hdparm-9.58+ds/sysfs.c:204: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 file_path[PATH_MAX + FILENAME_MAX]; data/hdparm-9.58+ds/sysfs.c:221:3: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(path, "/.."); data/hdparm-9.58+ds/wdidle3.c:93: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 data[512]; data/hdparm-9.58+ds/wdidle3.c:114: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 data[512]; data/hdparm-9.58+ds/wdidle3.c:133: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 data[512]; data/hdparm-9.58+ds/geom.c:36: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). int len = strlen(buf); data/hdparm-9.58+ds/hdparm.c:245:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((rc = read(fd, buf, TIMING_BUF_BYTES)) != TIMING_BUF_BYTES) { data/hdparm-9.58+ds/hdparm.c:460:16: [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). for (e = s + strlen(s); *--e == ' '; *e = '\0'); data/hdparm-9.58+ds/hdparm.c:513:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[62] & 0x100) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:515:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[62] & 0x200) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:517:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[62] & 0x400) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:519:26: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[62] & 0xf800) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:521:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[63] & 0x100) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:523:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[63] & 0x200) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:525:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[63] & 0x400) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:527:26: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[63] & 0xf800) strcat(dmodes,"*"); data/hdparm-9.58+ds/hdparm.c:544:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x100) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:546:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x200) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:548:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x400) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:550:25: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x800) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:552:26: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x1000) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:554:26: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x2000) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:556:26: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. if (idw[88] & 0x4000) strcat(umodes,"*"); data/hdparm-9.58+ds/hdparm.c:1207: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). for (i = strlen(fdevname); --i > 2 && (fdevname[i] >= '0' && fdevname[i] <= '9');) { data/hdparm-9.58+ds/hdparm.c:2907:26: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (ishex(d[digit=0] = getchar()) data/hdparm-9.58+ds/hdparm.c:2908:26: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). && ishex(d[++digit] = getchar()) data/hdparm-9.58+ds/hdparm.c:2909:26: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). && ishex(d[++digit] = getchar()) data/hdparm-9.58+ds/hdparm.c:2910:26: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). && ishex(d[++digit] = getchar())) { data/hdparm-9.58+ds/hdparm.c:2920:18: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). d[digit=0] = getchar(); data/hdparm-9.58+ds/hdparm.c:2973: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(passwd) >= sizeof(security_password)) { data/hdparm-9.58+ds/hdparm.c:2989: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(argp) != (maxlen * 2)) { data/hdparm-9.58+ds/hdparm.c:3001: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). } else if (strlen(argp) > maxlen) { data/hdparm-9.58+ds/hdparm.c:3033: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(argp) != (maxlen * 2)) { data/hdparm-9.58+ds/hdparm.c:3190: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). argp += strlen(argp); data/hdparm-9.58+ds/identify.c:1307:6: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(modes, "*"); data/hdparm-9.58+ds/identify.c:1308:21: [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). sprintf(modes + strlen(modes), "pio%u ", mode + 4); data/hdparm-9.58+ds/identify.c:1317:6: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(modes, "*"); data/hdparm-9.58+ds/identify.c:1318:21: [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). sprintf(modes + strlen(modes), "mdma%u ", mode + 2); data/hdparm-9.58+ds/identify.c:1337:7: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(modes, "*"); data/hdparm-9.58+ds/identify.c:1338: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). sprintf(modes + strlen(modes), "io_udma%u ", mode + 4); data/hdparm-9.58+ds/identify.c:1347:7: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(modes, "*"); data/hdparm-9.58+ds/identify.c:1348: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). sprintf(modes + strlen(modes), "mem_udma%u ", mode + 4); data/hdparm-9.58+ds/sysfs.c:25: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). char *pathtail = path + strlen(path); data/hdparm-9.58+ds/sysfs.c:101: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). pathtail = path + strlen(path); data/hdparm-9.58+ds/sysfs.c:230:3: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(file_path, "/"); ANALYSIS SUMMARY: Hits = 149 Lines analyzed = 8133 in approximately 0.30 seconds (27364 lines/second) Physical Source Lines of Code (SLOC) = 6946 Hits@level = [0] 636 [1] 40 [2] 91 [3] 0 [4] 18 [5] 0 Hits@level+ = [0+] 785 [1+] 149 [2+] 109 [3+] 18 [4+] 18 [5+] 0 Hits/KSLOC@level+ = [0+] 113.015 [1+] 21.4512 [2+] 15.6925 [3+] 2.59142 [4+] 2.59142 [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.