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/gmemusage-0.2/common.h Examining data/gmemusage-0.2/defaults.h Examining data/gmemusage-0.2/gmemusage.c Examining data/gmemusage-0.2/hash.c Examining data/gmemusage-0.2/proc.c Examining data/gmemusage-0.2/resource.c FINAL RESULTS: data/gmemusage-0.2/gmemusage.c:138: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 ( progname , strrchr ( argv [0] , '/' ) + 1 ) ; data/gmemusage-0.2/gmemusage.c:142: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 ( progname , argv [0] ) ; data/gmemusage-0.2/gmemusage.c:661:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf ( buf , "%-*s %6s : %5dK" , longestLabel , data/gmemusage-0.2/gmemusage.c:668:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf ( buf , "%s (%d)" , this [i] . pi -> procname , data/gmemusage-0.2/gmemusage.c:673:6: [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 ( buf , this [i] . pi -> procname ) ; data/gmemusage-0.2/hash.c:74: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 ( thisproc -> procname , procname ) ; data/gmemusage-0.2/hash.c:101: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 ( thisproc -> procname , procname ) ; data/gmemusage-0.2/proc.c:149:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf ( buf , "/proc/%s/status" , procdir -> d_name ) ; data/gmemusage-0.2/proc.c:167:6: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. sscanf ( buf , "%*s %s" , procName ) ; data/gmemusage-0.2/resource.c:182:11: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(fullname, "%s.%s", parentname, name); data/gmemusage-0.2/resource.c:183:11: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(fullclass, "%s.%s", parentclass, class); data/gmemusage-0.2/resource.c:245:15: [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. dDisplay = getenv ( "DISPLAY" ) ; data/gmemusage-0.2/common.h:14: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/gmemusage-0.2/defaults.h:16:8: [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. extern char data/gmemusage-0.2/gmemusage.c:51: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 data/gmemusage-0.2/gmemusage.c:264: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 data/gmemusage-0.2/gmemusage.c:522:6: [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 ( thProc . procname , "< %d" , Threshhold ) ; data/gmemusage-0.2/gmemusage.c:629: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/gmemusage-0.2/gmemusage.c:655:6: [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 ( nprocbuf , "(%d)" , this [i] . pi -> nProcs ) ; data/gmemusage-0.2/gmemusage.c:776: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 data/gmemusage-0.2/gmemusage.c:799:4: [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 ( cd_height , " Height - %d pixels" , data/gmemusage-0.2/gmemusage.c:801:4: [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 ( cd_width , " Width - %d pixels" , data/gmemusage-0.2/gmemusage.c:803:4: [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 ( cd_depth , " Depth - %d planes" , data/gmemusage-0.2/proc.c:31: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 data/gmemusage-0.2/proc.c:56:21: [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). if ( ( meminfo = fopen ( "/proc/meminfo" , "r" ) ) == NULL ) data/gmemusage-0.2/proc.c:93: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 data/gmemusage-0.2/proc.c:95: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 data/gmemusage-0.2/proc.c:150:27: [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). if ( ( StatusFile = fopen ( buf , "r" ) ) == NULL ) data/gmemusage-0.2/resource.c:88: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 data/gmemusage-0.2/resource.c:177: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 buffer[1024]; data/gmemusage-0.2/resource.c:178: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 fullname[1024]; data/gmemusage-0.2/resource.c:179: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 fullclass[1024]; data/gmemusage-0.2/resource.c:212:26: [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). *((int *) valuep) = atoi(buffer); data/gmemusage-0.2/gmemusage.c:566:12: [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 ( this [i] . pi -> procname ) > longestLabel ) data/gmemusage-0.2/gmemusage.c:568:18: [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). longestLabel = strlen ( this [i] . pi -> procname ) ; data/gmemusage-0.2/gmemusage.c:680: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). buf , strlen ( buf ) ) ; data/gmemusage-0.2/gmemusage.c:785:11: [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). len1 = strlen ( string1 ) ; data/gmemusage-0.2/gmemusage.c:786:11: [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). len2 = strlen ( string2 ) ; data/gmemusage-0.2/gmemusage.c:787:11: [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). len3 = strlen ( string3 ) ; data/gmemusage-0.2/gmemusage.c:805:11: [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). len4 = strlen ( string4 ) ; data/gmemusage-0.2/gmemusage.c:806:11: [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). len1 = strlen ( cd_height ) ; data/gmemusage-0.2/gmemusage.c:807:11: [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). len2 = strlen ( cd_width ) ; data/gmemusage-0.2/gmemusage.c:808:11: [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). len3 = strlen ( cd_depth ) ; data/gmemusage-0.2/gmemusage.c:850:4: [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). strlen ( string1 ) ) ; data/gmemusage-0.2/proc.c:40:20: [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). MemLineLen = strlen ( MemLine ) ; data/gmemusage-0.2/proc.c:111: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). NameLineLen = strlen ( NameLine ) , data/gmemusage-0.2/proc.c:112:23: [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). VmSizeLineLen = strlen ( VmSizeLine ) , data/gmemusage-0.2/proc.c:113:23: [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). VmDataLineLen = strlen ( VmDataLine ) , data/gmemusage-0.2/proc.c:114: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). VmStkLineLen = strlen ( VmStkLine ) , data/gmemusage-0.2/proc.c:115: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). VmExeLineLen = strlen ( VmExeLine ) , data/gmemusage-0.2/proc.c:116: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). VmRSSLineLen = strlen ( VmRSSLine ) ; data/gmemusage-0.2/resource.c:189: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). len = strlen(string); data/gmemusage-0.2/resource.c:191:11: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(buffer, string, sizeof(buffer)); data/gmemusage-0.2/resource.c:205:15: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(s, string, len); ANALYSIS SUMMARY: Hits = 54 Lines analyzed = 1633 in approximately 0.08 seconds (19662 lines/second) Physical Source Lines of Code (SLOC) = 1321 Hits@level = [0] 41 [1] 21 [2] 21 [3] 1 [4] 11 [5] 0 Hits@level+ = [0+] 95 [1+] 54 [2+] 33 [3+] 12 [4+] 11 [5+] 0 Hits/KSLOC@level+ = [0+] 71.9152 [1+] 40.8781 [2+] 24.9811 [3+] 9.08403 [4+] 8.32702 [5+] 0 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.