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/musescore-sftools-20180325/sfconvert.cpp Examining data/musescore-sftools-20180325/sfont.cpp Examining data/musescore-sftools-20180325/sfont.h Examining data/musescore-sftools-20180325/xml.cpp Examining data/musescore-sftools-20180325/xml.h FINAL RESULTS: data/musescore-sftools-20180325/xml.cpp:91:7: [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(buffer, BS, format, args); data/musescore-sftools-20180325/sfconvert.cpp:70:19: [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, "xcp:dS:szq:a:")) != EOF) { data/musescore-sftools-20180325/sfont.cpp:1203:7: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(time(NULL)); data/musescore-sftools-20180325/sfconvert.cpp:79:40: [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). presets.append(atoi(optarg)); data/musescore-sftools-20180325/sfconvert.cpp:85:37: [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). oggSerial = atoi(optarg); data/musescore-sftools-20180325/sfconvert.cpp:138:21: [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 (!fo.open(QIODevice::WriteOnly)) { data/musescore-sftools-20180325/sfont.cpp:122: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). if (!file->open(QIODevice::ReadOnly)) { data/musescore-sftools-20180325/sfont.cpp:134:19: [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 fourcc[5]; data/musescore-sftools-20180325/sfont.cpp:190: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. char fourcc[4]; data/musescore-sftools-20180325/sfont.cpp:328:16: [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[4]; data/musescore-sftools-20180325/sfont.cpp:341: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. char data[2500]; data/musescore-sftools-20180325/sfont.cpp:868:16: [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[4]; data/musescore-sftools-20180325/sfont.cpp:901: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). if (!f.open(QIODevice::ReadOnly)) data/musescore-sftools-20180325/sfont.cpp:949: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. char name[20]; data/musescore-sftools-20180325/sfont.cpp:952:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(name, preset->name, strlen(preset->name)); data/musescore-sftools-20180325/sfont.cpp:1080: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. char name[20]; data/musescore-sftools-20180325/sfont.cpp:1083:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(name, instrument->name, strlen(instrument->name)); data/musescore-sftools-20180325/sfont.cpp:1109: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. char name[20]; data/musescore-sftools-20180325/sfont.cpp:1112:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(name, s->name, strlen(s->name)); data/musescore-sftools-20180325/sfont.cpp:1134: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 (!f.open(QIODevice::ReadOnly)) { data/musescore-sftools-20180325/sfont.cpp:1176: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 (!f.open(QIODevice::ReadOnly)) { data/musescore-sftools-20180325/sfont.cpp:1215: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. char obuf[1024 * 1024]; data/musescore-sftools-20180325/sfont.cpp:1222:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(p, og.header, og.header_len); data/musescore-sftools-20180325/sfont.cpp:1224:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(p, og.body, og.body_len); data/musescore-sftools-20180325/sfont.cpp:1254:31: [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(p, og.header, og.header_len); data/musescore-sftools-20180325/sfont.cpp:1256:31: [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(p, og.body, og.body_len); data/musescore-sftools-20180325/sfont.cpp:1279:25: [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(p, og.header, og.header_len); data/musescore-sftools-20180325/sfont.cpp:1281:25: [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(p, og.body, og.body_len); data/musescore-sftools-20180325/sfont.cpp:1315: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 (!fi.open(QIODevice::ReadOnly)) { data/musescore-sftools-20180325/sfont.cpp:1445: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 buffer[16]; data/musescore-sftools-20180325/sfont.cpp:1446:13: [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(buffer, "sf%d.cpp", i + 1); data/musescore-sftools-20180325/sfont.cpp:1447:17: [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). f = fopen(buffer, "w+"); data/musescore-sftools-20180325/sfont.cpp:1487:11: [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). f = fopen("sf.cpp", "w+"); data/musescore-sftools-20180325/sfont.cpp:1678:11: [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). f = fopen("sf.cpp", "w+"); data/musescore-sftools-20180325/xml.cpp:90:6: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[BS]; data/musescore-sftools-20180325/sfconvert.cpp:123:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (!sf.read()) { data/musescore-sftools-20180325/sfont.cpp:119:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bool SoundFont::read() data/musescore-sftools-20180325/sfont.cpp:198:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read(signature, 4) != 4) data/musescore-sftools-20180325/sfont.cpp:209:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read((char*)&format, 4) != 4) data/musescore-sftools-20180325/sfont.cpp:275:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read((char*)&format, 2) != 2) data/musescore-sftools-20180325/sfont.cpp:290:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read((char*)&format, 2) != 2) data/musescore-sftools-20180325/sfont.cpp:305:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read((char*)&val, 1) != 1) data/musescore-sftools-20180325/sfont.cpp:317:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read(&val, 1) != 1) data/musescore-sftools-20180325/sfont.cpp:329:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read((char*)data, 4) != 4) data/musescore-sftools-20180325/sfont.cpp:342:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (file->read((char*)data, n) != n) data/musescore-sftools-20180325/sfont.cpp:850: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). int nn = strlen(s) + 1; data/musescore-sftools-20180325/sfont.cpp:907:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). f.read(buffer, len); data/musescore-sftools-20180325/sfont.cpp:952: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). memcpy(name, preset->name, strlen(preset->name)); data/musescore-sftools-20180325/sfont.cpp:1083:44: [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). memcpy(name, instrument->name, strlen(instrument->name)); data/musescore-sftools-20180325/sfont.cpp:1112:35: [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). memcpy(name, s->name, strlen(s->name)); data/musescore-sftools-20180325/sfont.cpp:1141:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). f.read((char*)buffer, len * sizeof(short)); data/musescore-sftools-20180325/sfont.cpp:1183:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). f.read((char*)ibuffer, samples * sizeof(short)); data/musescore-sftools-20180325/sfont.cpp:1322:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fi.read((char*)ibuffer, samples * sizeof(short)); data/musescore-sftools-20180325/sfont.h:235:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bool read(); ANALYSIS SUMMARY: Hits = 54 Lines analyzed = 2601 in approximately 0.09 seconds (30358 lines/second) Physical Source Lines of Code (SLOC) = 1939 Hits@level = [0] 110 [1] 19 [2] 32 [3] 2 [4] 1 [5] 0 Hits@level+ = [0+] 164 [1+] 54 [2+] 35 [3+] 3 [4+] 1 [5+] 0 Hits/KSLOC@level+ = [0+] 84.5797 [1+] 27.8494 [2+] 18.0505 [3+] 1.54719 [4+] 0.51573 [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.