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/mp3check-0.8.7/crc16.cc Examining data/mp3check-0.8.7/crc16.h Examining data/mp3check-0.8.7/id3tag.cc Examining data/mp3check-0.8.7/id3tag.h Examining data/mp3check-0.8.7/tappconfig.cc Examining data/mp3check-0.8.7/tappconfig.h Examining data/mp3check-0.8.7/tfiletools.cc Examining data/mp3check-0.8.7/tfiletools.h Examining data/mp3check-0.8.7/tmap.h Examining data/mp3check-0.8.7/tregex.cc Examining data/mp3check-0.8.7/tregex.h Examining data/mp3check-0.8.7/tvector.h Examining data/mp3check-0.8.7/mp3check.cc Examining data/mp3check-0.8.7/texception.h Examining data/mp3check-0.8.7/tstring.cc Examining data/mp3check-0.8.7/tstring.h FINAL RESULTS: data/mp3check-0.8.7/mp3check.cc:304:9: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. s.sprintf("(%03x,ID%d,l%d,prot%d,%2d,%4.1fkHz,pad%d,priv%d,mode%d,ext%d,copy%d,orig%d,emp%d)", data/mp3check-0.8.7/mp3check.cc:518:77: [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. void fmes(const char *name, const char *format, ...) __attribute__ ((format(printf,2,3))); data/mp3check-0.8.7/mp3check.cc:543:4: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vprintf(format, ap); data/mp3check-0.8.7/mp3check.cc:1610:14: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. l_str.sprintf("%2u:%02u", l_min/60, l_min%60); data/mp3check-0.8.7/mp3check.cc:1612:14: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. l_str.sprintf(" %2u", l_min); data/mp3check-0.8.7/tappconfig.cc:296:4: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, message, ap); data/mp3check-0.8.7/tappconfig.cc:313:4: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, message, ap); data/mp3check-0.8.7/tappconfig.cc:382:35: [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. __attribute__ ((noreturn,format(printf,4,5))) data/mp3check-0.8.7/tappconfig.cc:394:4: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, message, ap); data/mp3check-0.8.7/tappconfig.cc:957:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%c%c --%s%s%s%s", (!char_name.empty())?'-':' ', (!char_name.empty())?char_name[0]:' ', data/mp3check-0.8.7/tappconfig.cc:1227:4: [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((char *)terrorApplicationName, getString("application-name").c_str()); data/mp3check-0.8.7/tappconfig.h:232:26: [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. __attribute__ ((format(printf,1,2))) data/mp3check-0.8.7/tappconfig.h:237:35: [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. __attribute__ ((noreturn,format(printf,1,2))) data/mp3check-0.8.7/texception.h:57:7: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(*strp, format, ap); data/mp3check-0.8.7/tfiletools.cc:50:29: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. default: { tstring t; t.sprintf("%#o", int(filetypebits())); return t; } data/mp3check-0.8.7/tstring.cc:148:7: [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(rep->data(), s); data/mp3check-0.8.7/tstring.cc:182:10: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. if(i) sprintf("%d", i); data/mp3check-0.8.7/tstring.cc:187:4: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(format, i); data/mp3check-0.8.7/tstring.cc:192:4: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(format, d); data/mp3check-0.8.7/tstring.cc:306:15: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. void tstring::sprintf(const char *format, ...) { data/mp3check-0.8.7/tstring.cc:313:10: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. ret = vsprintf(rep->data(), format, ap); // not secure! may write out of bounds! data/mp3check-0.8.7/tstring.cc:323:13: [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. ret = vsnprintf(rep->data(), s, format, ap); data/mp3check-0.8.7/tstring.cc:1259:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%*s", width, ""); data/mp3check-0.8.7/tstring.h:321:9: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. void sprintf(const char *format, ...); data/mp3check-0.8.7/mp3check.cc:1344:25: [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* scolumns=getenv("COLUMNS"); data/mp3check-0.8.7/tappconfig.cc:1242:17: [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. char *home = getenv("HOME"); data/mp3check-0.8.7/tappconfig.cc:1369:17: [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. char *home = getenv("HOME"); data/mp3check-0.8.7/tappconfig.cc:1688:14: [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. char *p = getenv(env); data/mp3check-0.8.7/tappconfig.cc:1722:20: [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. char *home = getenv("HOME"); data/mp3check-0.8.7/id3tag.cc:178: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(p,target,128); data/mp3check-0.8.7/id3tag.cc:191: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(p,target,128); data/mp3check-0.8.7/id3tag.cc:203: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(dest,src,len); data/mp3check-0.8.7/id3tag.h:84: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 field_title[31]; data/mp3check-0.8.7/id3tag.h:85: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 field_artist[31]; data/mp3check-0.8.7/id3tag.h:86: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 field_album[31]; data/mp3check-0.8.7/id3tag.h:87: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 field_year[5]; data/mp3check-0.8.7/id3tag.h:88: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 field_comment[31]; data/mp3check-0.8.7/mp3check.cc:1346: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). columns=atoi(scolumns)-1; data/mp3check-0.8.7/mp3check.cc:1497: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). log = fopen(ac.getString("log-file").c_str(), "a"); data/mp3check-0.8.7/mp3check.cc:1539:16: [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(name, flags); data/mp3check-0.8.7/mp3check.cc:2085: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 tag[128]; data/mp3check-0.8.7/mp3check.cc:2101:19: [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 *f = fopen(name, "ab"); data/mp3check-0.8.7/tappconfig.cc:329: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 *checkpoint_file[MAX_CP]; data/mp3check-0.8.7/tappconfig.cc:330: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 *checkpoint_func[MAX_CP]; data/mp3check-0.8.7/tappconfig.cc:945: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 buf[256]; data/mp3check-0.8.7/tappconfig.cc:1251: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). FILE *tmpf = fopen(tmpname.c_str(), "w"); data/mp3check-0.8.7/tappconfig.cc:1262: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). FILE *oldf = fopen(realname.c_str(), "r"); data/mp3check-0.8.7/tappconfig.cc:1266: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 buf[1024]; data/mp3check-0.8.7/tappconfig.cc:1353:8: [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(fname.c_str(), "w"); data/mp3check-0.8.7/tregex.h:62:10: [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 buf[256]; data/mp3check-0.8.7/tstring.cc:106:4: [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->data(), data(), len+1); data/mp3check-0.8.7/tstring.cc:157:7: [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(rep->data(), s, l); data/mp3check-0.8.7/tstring.cc:231:7: [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(rep->data() + rep->len, a, alen); data/mp3check-0.8.7/tstring.cc:333: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 buf[7]; data/mp3check-0.8.7/tstring.cc:624:7: [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(q, p, r-p); // add skipped part data/mp3check-0.8.7/tstring.cc:627:7: [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(q, pre_padstring.rep->data(), pre_padstring.rep->len); // add pre pad data/mp3check-0.8.7/tstring.cc:630: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(q, replace_.rep->data(), replace_.rep->len); data/mp3check-0.8.7/tstring.cc:633: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(q, rr.rep->data(), rr.rep->len); data/mp3check-0.8.7/tstring.cc:636:7: [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(q, post_padstring.rep->data(), post_padstring.rep->len); // add post pad data/mp3check-0.8.7/tstring.cc:643:4: [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(q, p, mlen); // add rest data/mp3check-0.8.7/tstring.cc:680:4: [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(rep->data() + start, str.data(), str.length()); data/mp3check-0.8.7/tstring.cc:898:12: [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. q += ::sprintf(q, "%03o", i); data/mp3check-0.8.7/tstring.cc:900:12: [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. q += ::sprintf(q, "%o", i); data/mp3check-0.8.7/tstring.cc:906:12: [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. q += ::sprintf(q, "%03o", i); data/mp3check-0.8.7/tstring.cc:908:12: [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. q += ::sprintf(q, "x%02x", i); data/mp3check-0.8.7/tstring.cc:1012: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 buf[4]; data/mp3check-0.8.7/tstring.cc:1246: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. static char tbuf[size * numbuf]; data/mp3check-0.8.7/tstring.cc:1265:7: [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(buf, "%.*s %11d %c", width - (11 - 3), message, n, phasechar[phase++]); data/mp3check-0.8.7/tstring.cc:1275:12: [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. int l = sprintf(buf, "%.*s %*d/%*d (%5.1f%%) ", width - (12 + 2 * nlen), message, nlen, n, nlen, max, double(n)/double(max)*100.0); data/mp3check-0.8.7/tstring.cc:1290: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 buf[1024]; data/mp3check-0.8.7/tstring.cc:1323:12: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). FILE *f=fopen(filename, "rb"); data/mp3check-0.8.7/tstring.cc:1333: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). FILE *f = fopen(filename, "wb"); data/mp3check-0.8.7/tstring.cc:1343: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). FILE *f = fopen(fname, "r"); data/mp3check-0.8.7/id3tag.cc:64: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). return((strlen(p)==len)&&(p[len-2]==' ')&&(p[len-1]==' ')); data/mp3check-0.8.7/mp3check.cc:1551:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if(read(fd, (void*)p, len) != len) { data/mp3check-0.8.7/mp3check.cc:2090:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag + 3, title.c_str(), 30); data/mp3check-0.8.7/mp3check.cc:2091:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag + 3 + 30, artist.c_str(), 30); data/mp3check-0.8.7/mp3check.cc:2092:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag + 3 + 60, album.c_str(), 30); data/mp3check-0.8.7/mp3check.cc:2093:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag + 3 + 90 + 4, comment.c_str(), 28); data/mp3check-0.8.7/tappconfig.cc:1924: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). if(strlen(*list)<7) data/mp3check-0.8.7/tstring.cc:145:15: [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 l = strlen(s); data/mp3check-0.8.7/tstring.cc:224:64: [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). tstring& tstring::operator += (const char *a) {if(a) append(a, strlen(a)); return *this;} data/mp3check-0.8.7/tstring.cc:292: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(rep->data()) != rep->len) data/mp3check-0.8.7/tstring.cc:764:15: [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). rep->len = strlen(rep->data()); data/mp3check-0.8.7/tstring.cc:1309:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). size_t tstring::read(FILE *file, size_t l) { data/mp3check-0.8.7/tstring.cc:1325:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int r = read(f, buf.st_size); data/mp3check-0.8.7/tstring.h:285:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). size_t read(FILE *file, size_t len); // throw(InvalidWidth); ANALYSIS SUMMARY: Hits = 87 Lines analyzed = 7735 in approximately 0.24 seconds (32562 lines/second) Physical Source Lines of Code (SLOC) = 5657 Hits@level = [0] 107 [1] 14 [2] 44 [3] 5 [4] 24 [5] 0 Hits@level+ = [0+] 194 [1+] 87 [2+] 73 [3+] 29 [4+] 24 [5+] 0 Hits/KSLOC@level+ = [0+] 34.2938 [1+] 15.3792 [2+] 12.9044 [3+] 5.12639 [4+] 4.24253 [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.