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/hsail-tools-0~20180830/libHSAIL/HSAILValidator.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILFloats.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILExtManager.h Examining data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILTool.h Examining data/hsail-tools-0~20180830/libHSAIL/hsa_dwarf.h Examining data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILDump.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILParser.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILUtilities.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILInstProps.cpp Examining data/hsail-tools-0~20180830/libHSAIL/hsail_c.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILb128_t.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILBrigContainer.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILUtilities.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILConvertors.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILValidatorBase.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILTool.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp Examining data/hsail-tools-0~20180830/libHSAIL/hsail_c.cpp Examining data/hsail-tools-0~20180830/libHSAIL/SectionHeaderTable.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILItemBase.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILGenericExtension.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILDump.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILValidator.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILTypeUtilities.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILSRef.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILScanner.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILScanner.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILItems.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILBrigantine.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILValidatorBase.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILScope.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILBrigantine.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILInstProps.h Examining data/hsail-tools-0~20180830/libHSAIL/Brig.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILParser.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILExtension.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILImageExt.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILDisassembler.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILDisassembler.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILScannerRules.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILImageExt.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILItems.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILFloats.cpp Examining data/hsail-tools-0~20180830/libHSAIL/HSAILBrigContainer.h Examining data/hsail-tools-0~20180830/libHSAIL/HSAILExtManager.cpp Examining data/hsail-tools-0~20180830/HSAILAsm/HSAILAsm.cpp Examining data/hsail-tools-0~20180830/libHSAIL-AMD/HSAILAmdExt.cpp Examining data/hsail-tools-0~20180830/libHSAIL-AMD/Brig_amd.h Examining data/hsail-tools-0~20180830/libHSAIL-AMD/HSAILAmdExt.h Examining data/hsail-tools-0~20180830/libHSAIL-AMD/gcn.cpp Examining data/hsail-tools-0~20180830/libHSAIL-AMD/dg.cpp Examining data/hsail-tools-0~20180830/libHSAIL-AMD/mipmap.cpp FINAL RESULTS: data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:57:9: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). #define tempnam _tempnam data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:1058:19: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). tmpFileName = tempnam(".", ".dbg"); data/hsail-tools-0~20180830/libHSAIL/HSAILTool.cpp:391:21: [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 *v = getenv(var); data/hsail-tools-0~20180830/libHSAIL/Brig.h:1115: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 identification[8]; data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:60:30: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). #define BDG_OPEN open data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:97:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char prod[24]; data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:103:1: [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 note_section_data[16384]; data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:118: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(NoteAlloc(4, 4), &NOTENAMESZ, 4); data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:119: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(NoteAlloc(4, 4), ¬e_size, 4); data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:120: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(NoteAlloc(4, 4), ¬e_type, 4); data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:121: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(NoteAlloc(4, 4), NOTENAME, 3); data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:122: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(NoteAlloc((size_t) note_size, 4), note_data, (size_t) note_size); data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:1179: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(pn.prod, "AMD HSA HSAIL Assembler", 23); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigContainer.cpp:126: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(&secHeader()->name, name.begin, name.length()); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigContainer.cpp:527: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(hdr.identification, magic, data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:134: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 e_ident[EI_NIDENT]; data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:555: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(elfHeader.e_ident, ElfMagic, 4); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:592:9: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int open(const char* filename, bool forWriting) { data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:594: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). fd = ::open(filename, O_CREAT|O_TRUNC|O_RDWR|O_BINARY_, 0666); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:596: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). fd = ::open(filename, O_RDONLY | O_BINARY_); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:667:9: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int open(const char* filename, bool forWriting) { data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:668:14: [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). fd = fopen(filename, forWriting ? "wb+" : "rb"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:804: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(data, &buf[static_cast<size_t>(offset)], numBytes); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:840: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(buf + pos, data, numBytes); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:850: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(data, buf + offset, numBytes); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:904: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 (theFile->open(fileName, false)) { data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:915: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 (theFile->open(fileName, true)) { data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:968: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 ident[16]; data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1193: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. char buf[MAX_PREDEFINED_SECTION_NAME_LENGTH]; data/hsail-tools-0~20180830/libHSAIL/HSAILItemBase.h:91: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(&m_buffer[pos], p, n); data/hsail-tools-0~20180830/libHSAIL/HSAILScanner.cpp:122: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 line[lineLen+1]; data/hsail-tools-0~20180830/libHSAIL/HSAILUtilities.cpp:1207: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(dst,src,toCopy); data/hsail-tools-0~20180830/libHSAIL-AMD/dg.cpp:101:88: [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). virtual const char* getMnemoSuffix(const char* name) const { return name + strlen(AMD_DG_EXTENSION_OPCODE_PREFIX); } data/hsail-tools-0~20180830/libHSAIL-AMD/gcn.cpp:220:88: [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). virtual const char* getMnemoSuffix(const char* name) const { return name + strlen(AMD_GCN_EXTENSION_OPCODE_PREFIX); } data/hsail-tools-0~20180830/libHSAIL-AMD/mipmap.cpp:134:88: [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). virtual const char* getMnemoSuffix(const char* name) const { return name + strlen(AMD_MIPMAP_EXTENSION_OPCODE_PREFIX); } data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:66:30: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define BDG_READ(f, b, l) read((f), (b), (size_t)(l)) data/hsail-tools-0~20180830/libHSAIL/BrigDwarfGenerator.cpp:1185:51: [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). AddNote(NT_AMDGPU_HSA_HLDEBUG_DEBUG, SELFREF, strlen(SELFREF) + 1); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:150:41: [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). return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0; data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:638:20: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int rc = ::read(fd, data, (unsigned)numBytes); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:885:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). is.read(data, static_cast<std::streamsize>(numBytes)); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1028:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). virtual bool read(char* dst, uint64_t numBytes, uint64_t offset) const data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1092:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). validate(read((char*)&moduleHdr, sizeof(BrigModuleHeader), 0), "Failed to read BrigModuleHeader"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1121:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). validate(read((char*)§ionOffset, sizeof(uint64_t), moduleHdr.sectionIndex + idx * sizeof(uint64_t)), "Failed to read section index"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1149:22: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). validate(read(&pad, 1, pos), "Failed to read section alignment bytes"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1170:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). validate(read((char*)§ionHeader, sizeof(BrigSectionHeader), sectionOffset), "Failed to read section header"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1190:17: [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 (name && strlen(name) > 0) data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1192: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). assert(strlen(name) < MAX_PREDEFINED_SECTION_NAME_LENGTH); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1194:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). validate(read((char*)&buf, strlen(name), sectionOffset + offsetof(BrigSectionHeader, name)), "Failed to read section name"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1194:36: [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). validate(read((char*)&buf, strlen(name), sectionOffset + offsetof(BrigSectionHeader, name)), "Failed to read section name"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1195:46: [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). validate(sectionHeader.nameLength == strlen(name) && memcmp(name, buf, strlen(name)) == 0, "Invalid name of a standard section"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.cpp:1195:80: [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). validate(sectionHeader.nameLength == strlen(name) && memcmp(name, buf, strlen(name)) == 0, "Invalid name of a standard section"); data/hsail-tools-0~20180830/libHSAIL/HSAILBrigObjectFile.h:300:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). virtual bool read(char* dst, uint64_t numBytes, uint64_t offset) const = 0; data/hsail-tools-0~20180830/libHSAIL/HSAILDisassembler.cpp:1345: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). if (strlen(result) > 0) data/hsail-tools-0~20180830/libHSAIL/HSAILDisassembler.cpp:1360: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). if (strlen(result) > 0 && val != (unsigned) getNaturalAlignment(type)) data/hsail-tools-0~20180830/libHSAIL/HSAILSRef.h:68:69: [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). explicit SRef(const char *begin_) : begin(begin_), end(begin_ + strlen(begin_)) { } data/hsail-tools-0~20180830/libHSAIL/HSAILScanner.cpp:73:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). m_is.read(&m_buffer[0],length); ANALYSIS SUMMARY: Hits = 56 Lines analyzed = 25581 in approximately 0.61 seconds (41725 lines/second) Physical Source Lines of Code (SLOC) = 17708 Hits@level = [0] 1 [1] 24 [2] 29 [3] 3 [4] 0 [5] 0 Hits@level+ = [0+] 57 [1+] 56 [2+] 32 [3+] 3 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 3.21888 [1+] 3.16241 [2+] 1.80709 [3+] 0.169415 [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.