2014-07-27 23:19:24 +02:00
|
|
|
Flawfinder version 1.31, (C) 2001-2014 David A. Wheeler.
|
2014-07-23 05:01:18 +02:00
|
|
|
Number of rules (primarily dangerous function names) in C/C++ ruleset: 169
|
2007-01-16 03:44:45 +01:00
|
|
|
Examining test.c
|
|
|
|
Examining test2.c
|
2014-07-19 22:42:14 +02:00
|
|
|
|
|
|
|
FINAL RESULTS:
|
|
|
|
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:32: [5] (buffer) gets:
|
2014-07-23 05:01:18 +02:00
|
|
|
Does not check for buffer overflows (CWE-120, CWE-20). Use fgets() instead.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:56: [5] (buffer) strncat:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly (e.g., incorrectly computing the correct maximum
|
|
|
|
size to add) (CWE-120). Consider strcat_s, strlcat, or automatically
|
2014-07-13 06:06:04 +02:00
|
|
|
resizing strings. Risk is high; the length parameter appears to be a
|
|
|
|
constant, instead of computing the number of characters left.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:57: [5] (buffer) _tcsncat:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly (e.g., incorrectly computing the correct maximum
|
|
|
|
size to add) (CWE-120). Consider strcat_s, strlcat, or automatically
|
2014-07-13 06:06:04 +02:00
|
|
|
resizing strings. Risk is high; the length parameter appears to be a
|
|
|
|
constant, instead of computing the number of characters left.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:60: [5] (buffer) MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (CWE-120). Risk is high,
|
|
|
|
it appears that the size is given as bytes, but the function requires size
|
|
|
|
as characters.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:62: [5] (buffer) MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (CWE-120). Risk is high,
|
|
|
|
it appears that the size is given as bytes, but the function requires size
|
|
|
|
as characters.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:73: [5] (misc) SetSecurityDescriptorDacl:
|
|
|
|
Never create NULL ACLs; an attacker can set it to Everyone (Deny All
|
2014-07-19 22:42:14 +02:00
|
|
|
Access), which would even forbid administrator access (CWE-732).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:73: [5] (misc) SetSecurityDescriptorDacl:
|
|
|
|
Never create NULL ACLs; an attacker can set it to Everyone (Deny All
|
2014-07-19 22:42:14 +02:00
|
|
|
Access), which would even forbid administrator access (CWE-732).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:17: [4] (buffer) strcpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (CWE-120).
|
|
|
|
Consider using strcpy_s, strncpy, or strlcpy (warning, strncpy is easily
|
|
|
|
misused).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:20: [4] (buffer) sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
|
|
|
|
vsnprintf.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:21: [4] (buffer) sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
|
|
|
|
vsnprintf.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:22: [4] (format) sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Potential format string problem (CWE-134). Make format string constant.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:23: [4] (format) printf:
|
2014-07-19 22:42:14 +02:00
|
|
|
If format strings can be influenced by an attacker, they can be exploited
|
|
|
|
(CWE-134). Use a constant for the format specification.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:25: [4] (buffer) scanf:
|
2014-07-19 22:42:14 +02:00
|
|
|
The scanf() family's %s operation, without a limit specification, permits
|
2014-07-23 05:01:18 +02:00
|
|
|
buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a
|
|
|
|
different input function.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:27: [4] (buffer) scanf:
|
2014-07-19 22:42:14 +02:00
|
|
|
The scanf() family's %s operation, without a limit specification, permits
|
2014-07-23 05:01:18 +02:00
|
|
|
buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a
|
|
|
|
different input function.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:38: [4] (format) syslog:
|
2014-07-19 22:42:14 +02:00
|
|
|
If syslog's format strings can be influenced by an attacker, they can be
|
|
|
|
exploited (CWE-134). Use a constant format string for syslog.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:49: [4] (buffer) _mbscpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (CWE-120).
|
|
|
|
Consider using a function version that stops copying at the end of the
|
|
|
|
buffer.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:52: [4] (buffer) lstrcat:
|
2014-07-13 06:06:04 +02:00
|
|
|
Does not check for buffer overflows when concatenating to destination
|
2014-07-19 22:42:14 +02:00
|
|
|
(CWE-120).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:75: [3] (shell) CreateProcess:
|
2014-07-13 06:06:04 +02:00
|
|
|
This causes a new process to execute and is difficult to use safely
|
|
|
|
(CWE-78). Specify the application path in the first argument, NOT as part
|
|
|
|
of the second, or embedded spaces could allow an attacker to force a
|
2014-07-19 22:42:14 +02:00
|
|
|
different program to run.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:75: [3] (shell) CreateProcess:
|
2014-07-13 06:06:04 +02:00
|
|
|
This causes a new process to execute and is difficult to use safely
|
|
|
|
(CWE-78). Specify the application path in the first argument, NOT as part
|
|
|
|
of the second, or embedded spaces could allow an attacker to force a
|
2014-07-19 22:42:14 +02:00
|
|
|
different program to run.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:91: [3] (buffer) getopt_long:
|
2014-07-19 22:42:14 +02:00
|
|
|
Some older implementations do not protect against internal buffer overflows
|
2014-07-23 05:01:18 +02:00
|
|
|
(CWE-120, CWE-20). Check implementation on installation, or limit the size
|
|
|
|
of all string inputs.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:16: [2] (buffer) strcpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (CWE-120).
|
|
|
|
Consider using strcpy_s, strncpy, or strlcpy (warning, strncpy is easily
|
|
|
|
misused). Risk is low because the source is a constant string.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:19: [2] (buffer) sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
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.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:45: [2] (buffer) char:
|
2014-07-23 05:01:18 +02:00
|
|
|
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.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:46: [2] (buffer) char:
|
2014-07-23 05:01:18 +02:00
|
|
|
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.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:50: [2] (buffer) memcpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (CWE-120).
|
|
|
|
Make sure destination can always hold the source data.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:51: [2] (buffer) CopyMemory:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (CWE-120).
|
|
|
|
Make sure destination can always hold the source data.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:97: [2] (misc) fopen:
|
|
|
|
Check when opening files - can an attacker redirect it (via symlinks),
|
2014-07-19 22:42:14 +02:00
|
|
|
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).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:15: [1] (buffer) strcpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (CWE-120).
|
|
|
|
Consider using strcpy_s, strncpy, or strlcpy (warning, strncpy is easily
|
|
|
|
misused). Risk is low because the source is a constant character.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:18: [1] (buffer) sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
|
|
|
|
vsnprintf. Risk is low because the source is a constant character.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:26: [1] (buffer) scanf:
|
2014-07-19 22:42:14 +02:00
|
|
|
It's unclear if the %s limit in the format string is small enough
|
2014-07-13 06:06:04 +02:00
|
|
|
(CWE-120). Check that the limit is sufficiently small, or use a different
|
2014-07-19 22:42:14 +02:00
|
|
|
input function.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:53: [1] (buffer) strncpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly; doesn't always \0-terminate or check for invalid
|
|
|
|
pointers (CWE-120).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:54: [1] (buffer) _tcsncpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly; doesn't always \0-terminate or check for invalid
|
|
|
|
pointers (CWE-120).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:55: [1] (buffer) strncat:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly (e.g., incorrectly computing the correct maximum
|
|
|
|
size to add) (CWE-120). Consider strcat_s, strlcat, or automatically
|
|
|
|
resizing strings.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:58: [1] (buffer) strlen:
|
2014-07-20 01:10:12 +02:00
|
|
|
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).
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:64: [1] (buffer) MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (CWE-120). Risk is very
|
|
|
|
low, the length appears to be in characters not bytes.
|
2007-01-16 03:44:45 +01:00
|
|
|
test.c:66: [1] (buffer) MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (CWE-120). Risk is very
|
|
|
|
low, the length appears to be in characters not bytes.
|
|
|
|
|
|
|
|
ANALYSIS SUMMARY:
|
2007-01-16 03:44:45 +01:00
|
|
|
|
|
|
|
Hits = 36
|
|
|
|
Lines analyzed = 118
|
|
|
|
Physical Source Lines of Code (SLOC) = 80
|
2007-01-16 04:44:31 +01:00
|
|
|
Hits@level = [0] 0 [1] 9 [2] 7 [3] 3 [4] 10 [5] 7
|
|
|
|
Hits@level+ = [0+] 36 [1+] 36 [2+] 27 [3+] 20 [4+] 17 [5+] 7
|
|
|
|
Hits/KSLOC@level+ = [0+] 450 [1+] 450 [2+] 337.5 [3+] 250 [4+] 212.5 [5+] 87.5
|
2007-01-16 03:44:45 +01:00
|
|
|
Suppressed hits = 2 (use --neverignore to show them)
|
|
|
|
Minimum risk level = 1
|
|
|
|
Not every hit is necessarily a security vulnerability.
|
|
|
|
There may be other security vulnerabilities; review your code!
|
2014-07-29 03:25:00 +02:00
|
|
|
See 'Secure Programming for Linux and Unix HOWTO'
|
|
|
|
(http://www.dwheeler.com/secure-programs) for more information.
|
2014-07-12 13:01:23 +02:00
|
|
|
|
|
|
|
Testing for no ending newline:
|
|
|
|
Lines analyzed = 32
|