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/libldm-0.2.4/src/gpt.c Examining data/libldm-0.2.4/src/gpt.h Examining data/libldm-0.2.4/src/ldm.h Examining data/libldm-0.2.4/src/ldmtool.c Examining data/libldm-0.2.4/src/mbr.c Examining data/libldm-0.2.4/src/mbr.h Examining data/libldm-0.2.4/src/ldm.c Examining data/libldm-0.2.4/test/ldmread.c Examining data/libldm-0.2.4/test/partread.c FINAL RESULTS: data/libldm-0.2.4/src/ldmtool.c:587:31: [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. const char * const home = getenv("HOME"); data/libldm-0.2.4/src/gpt.c:34: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 magic[8]; data/libldm-0.2.4/src/gpt.c:43: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 padding1[4]; data/libldm-0.2.4/src/gpt.c:67: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 name[72]; data/libldm-0.2.4/src/gpt.c:115: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(_gpt, &head, sizeof(head)); data/libldm-0.2.4/src/gpt.h:44: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 name[72]; data/libldm-0.2.4/src/ldm.c:73: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 magic[8]; // "PRIVHEAD" data/libldm-0.2.4/src/ldm.c:84: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 disk_guid[64]; data/libldm-0.2.4/src/ldm.c:85: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 host_guid[64]; data/libldm-0.2.4/src/ldm.c:86: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 disk_group_guid[64]; data/libldm-0.2.4/src/ldm.c:87: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 disk_group_name[32]; data/libldm-0.2.4/src/ldm.c:90: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 padding1[9]; data/libldm-0.2.4/src/ldm.c:105: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 disk_set_guid[16]; data/libldm-0.2.4/src/ldm.c:106: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 disk_set_guid_dup[16]; data/libldm-0.2.4/src/ldm.c:112: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 name[8]; data/libldm-0.2.4/src/ldm.c:121: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 magic[8]; // "TOCBLOCK" data/libldm-0.2.4/src/ldm.c:124: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 padding1[4]; data/libldm-0.2.4/src/ldm.c:126: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 padding2[16]; data/libldm-0.2.4/src/ldm.c:133: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 magic[4]; // "VMDB" data/libldm-0.2.4/src/ldm.c:144: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 disk_group_name[31]; data/libldm-0.2.4/src/ldm.c:145: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 disk_group_guid[64]; data/libldm-0.2.4/src/ldm.c:153: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 padding1[12]; data/libldm-0.2.4/src/ldm.c:158: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 padding2[12]; data/libldm-0.2.4/src/ldm.c:166: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 magic[4]; // "VBLK" data/libldm-0.2.4/src/ldm.c:248: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(r, p, len); \ data/libldm-0.2.4/src/ldm.c:340:13: [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 guid_str[37]; data/libldm-0.2.4/src/ldm.c:880:13: [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 guid_str[37]; data/libldm-0.2.4/src/ldm.c:1417: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(ret, *var, len); (*var) += len; data/libldm-0.2.4/src/ldm.c:1698:9: [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(&disk->guid, vblk, 16); data/libldm-0.2.4/src/ldm.c:1901:21: [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[be16toh(head->entry) * vblk_data_size], data/libldm-0.2.4/src/ldm.c:1917:17: [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[be16toh(head->entry) * vblk_data_size], data/libldm-0.2.4/src/ldm.c:2162:20: [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). const int fd = open(path, O_RDONLY); data/libldm-0.2.4/src/ldmtool.c:586: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 histfile[1024] = ""; data/libldm-0.2.4/src/ldmtool.c:653:18: [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 fd = open(histfile, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0600); data/libldm-0.2.4/src/mbr.c:41: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 code[446]; data/libldm-0.2.4/src/mbr.h:66: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 code[440]; data/libldm-0.2.4/src/mbr.h:73: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 code[446]; data/libldm-0.2.4/test/partread.c:35: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). int fd = open(argv[1], O_RDONLY); data/libldm-0.2.4/test/partread.c:97: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 uuid[37]; data/libldm-0.2.4/src/gpt.c:88:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read < sizeof(head)) { data/libldm-0.2.4/src/gpt.c:89:40: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, &head + read, sizeof(head) - read, data/libldm-0.2.4/src/gpt.c:89:61: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, &head + read, sizeof(head) - read, data/libldm-0.2.4/src/gpt.c:116:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read < le32toh(head.size)) { data/libldm-0.2.4/src/gpt.c:117:49: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, (char *)(_gpt) + read, le32toh(head.size) - read, data/libldm-0.2.4/src/gpt.c:117:76: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, (char *)(_gpt) + read, le32toh(head.size) - read, data/libldm-0.2.4/src/gpt.c:157:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read < pte_array_size) { data/libldm-0.2.4/src/gpt.c:158:50: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, (*h)->pte_array + read, pte_array_size - read, data/libldm-0.2.4/src/gpt.c:158:73: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, (*h)->pte_array + read, pte_array_size - read, data/libldm-0.2.4/src/ldm.c:246:24: [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). const size_t len = strlen(p) + 1; \ data/libldm-0.2.4/src/ldm.c:1193:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read < config_size) { data/libldm-0.2.4/src/ldm.c:1194:42: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, *config + read, config_size - read, data/libldm-0.2.4/src/ldm.c:1194:62: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, *config + read, config_size - read, data/libldm-0.2.4/src/ldm.c:1195:43: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). config_start + read); data/libldm-0.2.4/src/ldm.c:1224:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read < sizeof(*privhead)) { data/libldm-0.2.4/src/ldm.c:1225:52: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t in = pread(fd, (char *) privhead + read, data/libldm-0.2.4/src/ldm.c:1226:48: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). sizeof(*privhead) - read, data/libldm-0.2.4/src/ldm.c:1227:39: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ph_start + read); ANALYSIS SUMMARY: Hits = 57 Lines analyzed = 5193 in approximately 0.14 seconds (36442 lines/second) Physical Source Lines of Code (SLOC) = 3647 Hits@level = [0] 59 [1] 18 [2] 38 [3] 1 [4] 0 [5] 0 Hits@level+ = [0+] 116 [1+] 57 [2+] 39 [3+] 1 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 31.807 [1+] 15.6293 [2+] 10.6937 [3+] 0.274198 [4+] 0 [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.