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/mp3val-0.1.8/crc.cpp Examining data/mp3val-0.1.8/crc.h Examining data/mp3val-0.1.8/crossapi.h Examining data/mp3val-0.1.8/main.cpp Examining data/mp3val-0.1.8/mpegparse.cpp Examining data/mp3val-0.1.8/mpegparse.h Examining data/mp3val-0.1.8/out.cpp Examining data/mp3val-0.1.8/out.h Examining data/mp3val-0.1.8/report.cpp Examining data/mp3val-0.1.8/report.h Examining data/mp3val-0.1.8/crossapi.cpp FINAL RESULTS: data/mp3val-0.1.8/crossapi.cpp:363:2: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(filename,cfa->st_mode); data/mp3val-0.1.8/crossapi.cpp:42: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(cfd->cFileName,wfd.cFileName); data/mp3val-0.1.8/crossapi.cpp:53: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(cfd->cFileName,wfd.cFileName); data/mp3val-0.1.8/main.cpp:232: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((char *)pcBuffer2,szFileName); data/mp3val-0.1.8/crossapi.cpp:73:2: [3] (tmpfile) GetTempFileName: Temporary file race condition in certain cases (e.g., if run as SYSTEM in many versions of Windows) (CWE-377). GetTempFileName((char *)pcDirBuffer,"mp3",0,(char *)pcBuffer); data/mp3val-0.1.8/crossapi.cpp:220:9: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. return realpath(szFileName,pcBuffer) != 0; data/mp3val-0.1.8/crossapi.cpp:70: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 pcDirBuffer[CROSSAPI_MAX_PATH]; data/mp3val-0.1.8/crossapi.cpp:183: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 pcTmpBuf[TMPBUFSIZE]; data/mp3val-0.1.8/crossapi.cpp:225: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(pcBuffer,"/tmp/mp3val.XXXXXX"); data/mp3val-0.1.8/crossapi.cpp:226:9: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). return mkstemp(pcBuffer); data/mp3val-0.1.8/crossapi.cpp:242:5: [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). id=open(szOldName,O_RDONLY); data/mp3val-0.1.8/crossapi.cpp:244:5: [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). od=open(szNewName,O_WRONLY|O_CREAT|O_TRUNC,0644); data/mp3val-0.1.8/crossapi.cpp:282: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). return open(szFileName,flags); data/mp3val-0.1.8/crossapi.cpp:325:8: [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). hFile=open(filename,O_RDONLY); data/mp3val-0.1.8/crossapi.h:57: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 cFileName[CROSSAPI_MAX_PATH]; data/mp3val-0.1.8/main.cpp:30: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 pcBuffer[CROSSAPI_MAX_PATH+1]; data/mp3val-0.1.8/main.cpp:31: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 pcBuffer2[CROSSAPI_MAX_PATH+1]; data/mp3val-0.1.8/main.cpp:54: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 szFullLogFile[CROSSAPI_MAX_PATH+2]; data/mp3val-0.1.8/main.cpp:55: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 szStartDir[CROSSAPI_MAX_PATH+2]; data/mp3val-0.1.8/main.cpp:57: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 szPipedFileName[CROSSAPI_MAX_PATH+2]; data/mp3val-0.1.8/main.cpp:187:11: [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). log_out.open(szLogFileName,ios::out|ios::app|ios::binary); data/mp3val-0.1.8/main.cpp:233: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((char *)pcBuffer2,".bak"); data/mp3val-0.1.8/report.cpp: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 szMsgBuf[256]; data/mp3val-0.1.8/report.cpp:69: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(szMsgBuf,"Wrong CRC in %d frames",mpginfo->iCRCErrors); data/mp3val-0.1.8/report.cpp:89: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(szMsgBuf,"Wrong number of MPEG frames specified in Xing header (%d instead of %d)",mpginfo->iFrames,mpeg_total); data/mp3val-0.1.8/report.cpp:94: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(szMsgBuf,"Wrong number of MPEG data bytes specified in Xing header (%d instead of %d)",mpginfo->iBytes,mpginfo->iTotalMPEGBytes); data/mp3val-0.1.8/report.cpp:101: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(szMsgBuf,"Wrong number of MPEG frames specified in VBRI header (%d instead of %d)",mpginfo->iFrames,mpeg_total); data/mp3val-0.1.8/report.cpp:106: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(szMsgBuf,"Wrong number of MPEG data bytes specified in VBRI header (%d instead of %d)",mpginfo->iBytes,mpginfo->iTotalMPEGBytes); data/mp3val-0.1.8/crossapi.cpp:204:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(cfd->cFileName,szFileName,CROSSAPI_MAX_PATH); data/mp3val-0.1.8/crossapi.cpp:250:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). iBytesRead=read(id,pcTmpBuf,TMPBUFSIZE); data/mp3val-0.1.8/main.cpp:88: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(argv[i])>=2)&&(!memcmp(argv[i],"-l",2))) { data/mp3val-0.1.8/main.cpp:266: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). for(p=szFileNameIn+(strlen(szFileNameIn)-1);(p>=szFileNameIn)&&(*p!='\\')&&(*p!='/');p--); data/mp3val-0.1.8/main.cpp:281: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). if(*szFileNameOut[strlen(*szFileNameOut)-1]=='\"') *szFileNameOut[strlen(*szFileNameOut)-1]='\0'; data/mp3val-0.1.8/main.cpp:281: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). if(*szFileNameOut[strlen(*szFileNameOut)-1]=='\"') *szFileNameOut[strlen(*szFileNameOut)-1]='\0'; ANALYSIS SUMMARY: Hits = 34 Lines analyzed = 1903 in approximately 0.07 seconds (25694 lines/second) Physical Source Lines of Code (SLOC) = 1379 Hits@level = [0] 0 [1] 6 [2] 22 [3] 2 [4] 3 [5] 1 Hits@level+ = [0+] 34 [1+] 34 [2+] 28 [3+] 6 [4+] 4 [5+] 1 Hits/KSLOC@level+ = [0+] 24.6555 [1+] 24.6555 [2+] 20.3046 [3+] 4.35098 [4+] 2.90065 [5+] 0.725163 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.