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/hostname-3.23/hostname.c FINAL RESULTS: data/hostname-3.23/hostname.c:467:13: [3] (buffer) getopt_long: 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((o = getopt_long(argc, argv, "aAdfbF:h?iIsVy", long_options, NULL)) != -1) data/hostname-3.23/hostname.c:61: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. static char buf[NI_MAXHOST]; data/hostname-3.23/hostname.c:280: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[NI_MAXHOST]; data/hostname-3.23/hostname.c:360: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 buf[INET6_ADDRSTRLEN]; data/hostname-3.23/hostname.c:403: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). if ((fp = fopen(filename, "r")) == NULL) { data/hostname-3.23/hostname.c:522:5: [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(name, "localhost"); data/hostname-3.23/hostname.c:190: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 i, len = strlen(name); data/hostname-3.23/hostname.c:218: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). for (i = strlen(name) - 1; i >= 0 && isspace(name[i]); i--); data/hostname-3.23/hostname.c:225:25: [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 (sethostname(name, strlen(name))) { data/hostname-3.23/hostname.c:235:27: [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 (setdomainname(name, strlen(name))) { ANALYSIS SUMMARY: Hits = 10 Lines analyzed = 553 in approximately 0.21 seconds (2687 lines/second) Physical Source Lines of Code (SLOC) = 401 Hits@level = [0] 17 [1] 4 [2] 5 [3] 1 [4] 0 [5] 0 Hits@level+ = [0+] 27 [1+] 10 [2+] 6 [3+] 1 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 67.3317 [1+] 24.9377 [2+] 14.9626 [3+] 2.49377 [4+] 0 [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.