2007-01-16 03:44:45 +01:00
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf8">
|
|
|
|
<title>Flawfinder Results</title>
|
|
|
|
<meta name="author" content="David A. Wheeler">
|
|
|
|
<meta name="keywords" lang="en" content="flawfinder results, security scan">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Flawfinder Results</h1>
|
|
|
|
Here are the security scan results from
|
2021-08-29 22:26:59 +02:00
|
|
|
<a href="https://dwheeler.com/flawfinder">Flawfinder version 2.0.19</a>,
|
2019-05-20 04:55:14 +02:00
|
|
|
(C) 2001-2019 <a href="https://dwheeler.com">David A. Wheeler</a>.
|
2021-01-09 19:04:56 +01:00
|
|
|
Number of rules (primarily dangerous function names) in C/C++ ruleset: 222
|
2007-01-16 03:44:45 +01:00
|
|
|
<p>
|
|
|
|
Examining test.c <br>
|
|
|
|
Examining test2.c <br>
|
2014-07-19 22:42:14 +02:00
|
|
|
|
|
|
|
<h2>Final Results</h2>
|
2007-01-16 03:44:45 +01:00
|
|
|
<ul>
|
|
|
|
<li>test.c:32: <b> [5] </b> (buffer) <i> gets:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>, <a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/20.html">CWE-20</a>). Use
|
2014-07-19 22:42:14 +02:00
|
|
|
fgets() instead. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
gets(f);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:60: <b> [5] </b> (buffer) <i> strncat:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly (e.g., incorrectly computing the correct maximum
|
2014-09-01 21:14:55 +02:00
|
|
|
size to add) [MS-banned] (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-09-01 21:14:55 +02:00
|
|
|
Consider strcat_s, strlcat, snprintf, or automatically resizing strings.
|
|
|
|
Risk is high; the length parameter appears to be a constant, instead of
|
|
|
|
computing the number of characters left. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
strncat(d,s,sizeof(d)); /* Misuse - this should be flagged as riskier. */
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:61: <b> [5] </b> (buffer) <i> _tcsncat:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly (e.g., incorrectly computing the correct maximum
|
2014-09-01 21:14:55 +02:00
|
|
|
size to add) [MS-banned] (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-07-19 22:42:14 +02:00
|
|
|
Consider strcat_s, strlcat, or automatically resizing strings. Risk is
|
|
|
|
high; the length parameter appears to be a constant, instead of computing
|
|
|
|
the number of characters left. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
_tcsncat(d,s,sizeof(d)); /* Misuse - flag as riskier */
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:64: <b> [5] </b> (buffer) <i> MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Risk
|
|
|
|
is high, it appears that the size is given as bytes, but the function
|
|
|
|
requires size as characters. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
MultiByteToWideChar(CP_ACP,0,szName,-1,wszUserName,sizeof(wszUserName));
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:66: <b> [5] </b> (buffer) <i> MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Risk
|
|
|
|
is high, it appears that the size is given as bytes, but the function
|
|
|
|
requires size as characters. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
MultiByteToWideChar(CP_ACP,0,szName,-1,wszUserName,sizeof wszUserName);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:77: <b> [5] </b> (misc) <i> SetSecurityDescriptorDacl:
|
2007-01-16 03:44:45 +01:00
|
|
|
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 (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/732.html">CWE-732</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:77: <b> [5] </b> (misc) <i> SetSecurityDescriptorDacl:
|
2007-01-16 03:44:45 +01:00
|
|
|
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 (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/732.html">CWE-732</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:17: <b> [4] </b> (buffer) <i> strcpy:
|
2014-08-09 19:32:37 +02:00
|
|
|
Does not check for buffer overflows when copying to destination [MS-banned]
|
2018-01-26 05:52:35 +01:00
|
|
|
(<a href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-09-01 21:14:55 +02:00
|
|
|
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily
|
2014-07-19 22:42:14 +02:00
|
|
|
misused). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
strcpy(b, a);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:20: <b> [4] </b> (buffer) <i> sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Use
|
2014-07-19 22:42:14 +02:00
|
|
|
sprintf_s, snprintf, or vsnprintf. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
sprintf(s, "hello %s", bug);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:21: <b> [4] </b> (buffer) <i> sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Use
|
2014-07-19 22:42:14 +02:00
|
|
|
sprintf_s, snprintf, or vsnprintf. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
sprintf(s, gettext("hello %s"), bug);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:22: <b> [4] </b> (format) <i> sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Potential format string problem (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/134.html">CWE-134</a>). Make
|
2014-07-19 22:42:14 +02:00
|
|
|
format string constant. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
sprintf(s, unknown, bug);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:23: <b> [4] </b> (format) <i> printf:
|
2014-07-19 22:42:14 +02:00
|
|
|
If format strings can be influenced by an attacker, they can be exploited
|
2018-01-26 05:52:35 +01:00
|
|
|
(<a href="https://cwe.mitre.org/data/definitions/134.html">CWE-134</a>).
|
|
|
|
Use a constant for the format specification. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
printf(bf, x);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:25: <b> [4] </b> (buffer) <i> scanf:
|
2014-07-19 22:42:14 +02:00
|
|
|
The scanf() family's %s operation, without a limit specification, permits
|
|
|
|
buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>, <a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/20.html">CWE-20</a>). Specify
|
|
|
|
a limit to %s, or use a different input function. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
scanf("%s", s);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:27: <b> [4] </b> (buffer) <i> scanf:
|
2014-07-19 22:42:14 +02:00
|
|
|
The scanf() family's %s operation, without a limit specification, permits
|
|
|
|
buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>, <a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/20.html">CWE-20</a>). Specify
|
|
|
|
a limit to %s, or use a different input function. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
scanf("%s", s);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:38: <b> [4] </b> (format) <i> syslog:
|
2014-07-19 22:42:14 +02:00
|
|
|
If syslog's format strings can be influenced by an attacker, they can be
|
|
|
|
exploited (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/134.html">CWE-134</a>). Use a
|
2014-07-19 22:42:14 +02:00
|
|
|
constant format string for syslog. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
syslog(LOG_ERR, attacker_string);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:49: <b> [4] </b> (buffer) <i> _mbscpy:
|
2014-08-09 19:32:37 +02:00
|
|
|
Does not check for buffer overflows when copying to destination [MS-banned]
|
2018-01-26 05:52:35 +01:00
|
|
|
(<a href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-07-19 22:42:14 +02:00
|
|
|
Consider using a function version that stops copying at the end of the
|
|
|
|
buffer. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
_mbscpy(d,s); /* like strcpy, this doesn't check for buffer overflow */
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:56: <b> [4] </b> (buffer) <i> lstrcat:
|
2014-09-01 21:14:55 +02:00
|
|
|
Does not check for buffer overflows when concatenating to destination
|
|
|
|
[MS-banned] (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
lstrcat(d,s);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:79: <b> [3] </b> (shell) <i> CreateProcess:
|
2014-07-19 22:42:14 +02:00
|
|
|
This causes a new process to execute and is difficult to use safely (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/78.html">CWE-78</a>). Specify
|
2014-07-19 22:42:14 +02:00
|
|
|
the application path in the first argument, NOT as part of the second, or
|
|
|
|
embedded spaces could allow an attacker to force a different program to
|
|
|
|
run. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
CreateProcess(NULL, "C:\\Program Files\\GoodGuy\\GoodGuy.exe -x", "");
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:79: <b> [3] </b> (shell) <i> CreateProcess:
|
2014-07-19 22:42:14 +02:00
|
|
|
This causes a new process to execute and is difficult to use safely (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/78.html">CWE-78</a>). Specify
|
2014-07-19 22:42:14 +02:00
|
|
|
the application path in the first argument, NOT as part of the second, or
|
|
|
|
embedded spaces could allow an attacker to force a different program to
|
|
|
|
run. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
CreateProcess(NULL, "C:\\Program Files\\GoodGuy\\GoodGuy.exe -x", "");
|
|
|
|
</pre>
|
2021-01-10 02:37:20 +01:00
|
|
|
<li>test.c:81: <b> [3] </b> (misc) <i> LoadLibraryEx:
|
|
|
|
Ensure that the full path to the library is specified, or current directory
|
|
|
|
may be used (<a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/829.html">CWE-829</a>, <a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/20.html">CWE-20</a>). Use a
|
|
|
|
flag like LOAD_LIBRARY_SEARCH_SYSTEM32 or
|
|
|
|
LOAD_LIBRARY_SEARCH_APPLICATION_DIR to search only desired folders. </i>
|
|
|
|
<pre>
|
|
|
|
(void) LoadLibraryEx(L"user32.dll", nullptr, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
</pre>
|
|
|
|
<li>test.c:99: <b> [3] </b> (buffer) <i> getopt_long:
|
2014-07-19 22:42:14 +02:00
|
|
|
Some older implementations do not protect against internal buffer overflows
|
2018-01-26 05:52:35 +01:00
|
|
|
(<a href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>, <a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/20.html">CWE-20</a>). Check
|
2014-07-23 05:01:18 +02:00
|
|
|
implementation on installation, or limit the size of all string inputs. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
while ((optc = getopt_long (argc, argv, "a",longopts, NULL )) != EOF) {
|
|
|
|
</pre>
|
|
|
|
<li>test.c:16: <b> [2] </b> (buffer) <i> strcpy:
|
2014-08-09 19:32:37 +02:00
|
|
|
Does not check for buffer overflows when copying to destination [MS-banned]
|
2018-01-26 05:52:35 +01:00
|
|
|
(<a href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-09-01 21:14:55 +02:00
|
|
|
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily
|
2014-07-19 22:42:14 +02:00
|
|
|
misused). Risk is low because the source is a constant string. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
strcpy(a, gettext("Hello there")); // Did this work?
|
|
|
|
</pre>
|
|
|
|
<li>test.c:19: <b> [2] </b> (buffer) <i> sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Use
|
2014-07-19 22:42:14 +02:00
|
|
|
sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a
|
|
|
|
constant maximum length. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
sprintf(s, "hello");
|
|
|
|
</pre>
|
|
|
|
<li>test.c:45: <b> [2] </b> (buffer) <i> char:
|
2014-07-23 05:01:18 +02:00
|
|
|
Statically-sized arrays can be improperly restricted, leading to potential
|
2018-01-26 05:48:05 +01:00
|
|
|
overflows or other issues (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/119.html">CWE-119</a>!/<a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
|
|
|
Perform bounds checking, use functions that limit length, or ensure that
|
|
|
|
the size is larger than the maximum possible length. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
char d[20];
|
|
|
|
</pre>
|
|
|
|
<li>test.c:46: <b> [2] </b> (buffer) <i> char:
|
2014-07-23 05:01:18 +02:00
|
|
|
Statically-sized arrays can be improperly restricted, leading to potential
|
2018-01-26 05:48:05 +01:00
|
|
|
overflows or other issues (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/119.html">CWE-119</a>!/<a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
|
|
|
Perform bounds checking, use functions that limit length, or ensure that
|
|
|
|
the size is larger than the maximum possible length. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
char s[20];
|
|
|
|
</pre>
|
|
|
|
<li>test.c:50: <b> [2] </b> (buffer) <i> memcpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Make
|
2014-07-19 22:42:14 +02:00
|
|
|
sure destination can always hold the source data. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
memcpy(d,s); // fail - no size
|
2007-01-16 03:44:45 +01:00
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:53: <b> [2] </b> (buffer) <i> memcpy:
|
|
|
|
Does not check for buffer overflows when copying to destination (<a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Make
|
|
|
|
sure destination can always hold the source data. </i>
|
|
|
|
<pre>
|
|
|
|
memcpy(&n,s,sizeof(s)); // fail - sizeof not of destination
|
|
|
|
</pre>
|
|
|
|
<li>test.c:54: <b> [2] </b> (buffer) <i> memcpy:
|
|
|
|
Does not check for buffer overflows when copying to destination (<a
|
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Make
|
|
|
|
sure destination can always hold the source data. </i>
|
|
|
|
<pre>
|
|
|
|
memcpy(d,s,n); // fail - size unguessable
|
|
|
|
</pre>
|
|
|
|
<li>test.c:55: <b> [2] </b> (buffer) <i> CopyMemory:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows when copying to destination (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Make
|
2014-07-19 22:42:14 +02:00
|
|
|
sure destination can always hold the source data. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
CopyMemory(d,s);
|
|
|
|
</pre>
|
2021-01-10 02:37:20 +01:00
|
|
|
<li>test.c:105: <b> [2] </b> (misc) <i> fopen:
|
2007-01-16 03:44:45 +01:00
|
|
|
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? (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/362.html">CWE-362</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
f = fopen("/etc/passwd", "r");
|
|
|
|
</pre>
|
|
|
|
<li>test.c:15: <b> [1] </b> (buffer) <i> strcpy:
|
2014-08-09 19:32:37 +02:00
|
|
|
Does not check for buffer overflows when copying to destination [MS-banned]
|
2018-01-26 05:52:35 +01:00
|
|
|
(<a href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-09-01 21:14:55 +02:00
|
|
|
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily
|
2014-07-19 22:42:14 +02:00
|
|
|
misused). Risk is low because the source is a constant character. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
strcpy(a, "\n"); // Did this work?
|
|
|
|
</pre>
|
|
|
|
<li>test.c:18: <b> [1] </b> (buffer) <i> sprintf:
|
2014-07-19 22:42:14 +02:00
|
|
|
Does not check for buffer overflows (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Use
|
2014-07-19 22:42:14 +02:00
|
|
|
sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a
|
|
|
|
constant character. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
sprintf(s, "\n");
|
|
|
|
</pre>
|
|
|
|
<li>test.c:26: <b> [1] </b> (buffer) <i> scanf:
|
2014-07-19 22:42:14 +02:00
|
|
|
It's unclear if the %s limit in the format string is small enough (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Check
|
2014-07-19 22:42:14 +02:00
|
|
|
that the limit is sufficiently small, or use a different input function. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
scanf("%10s", s);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:57: <b> [1] </b> (buffer) <i> strncpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly; doesn't always \0-terminate or check for invalid
|
2014-08-09 19:32:37 +02:00
|
|
|
pointers [MS-banned] (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
strncpy(d,s);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:58: <b> [1] </b> (buffer) <i> _tcsncpy:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly; doesn't always \0-terminate or check for invalid
|
2014-08-09 19:32:37 +02:00
|
|
|
pointers [MS-banned] (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
_tcsncpy(d,s);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:59: <b> [1] </b> (buffer) <i> strncat:
|
2014-07-19 22:42:14 +02:00
|
|
|
Easily used incorrectly (e.g., incorrectly computing the correct maximum
|
2014-09-01 21:14:55 +02:00
|
|
|
size to add) [MS-banned] (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>).
|
2014-09-01 21:14:55 +02:00
|
|
|
Consider strcat_s, strlcat, snprintf, or automatically resizing strings. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
strncat(d,s,10);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:62: <b> [1] </b> (buffer) <i> 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) (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/126.html">CWE-126</a>). </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
n = strlen(d);
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:68: <b> [1] </b> (buffer) <i> MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Risk
|
|
|
|
is very low, the length appears to be in characters not bytes. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
MultiByteToWideChar(CP_ACP,0,szName,-1,wszUserName,sizeof(wszUserName)/sizeof(wszUserName[0]));
|
|
|
|
</pre>
|
2018-12-19 14:12:33 +01:00
|
|
|
<li>test.c:70: <b> [1] </b> (buffer) <i> MultiByteToWideChar:
|
2014-07-19 22:42:14 +02:00
|
|
|
Requires maximum length in CHARACTERS, not bytes (<a
|
2018-01-26 05:52:35 +01:00
|
|
|
href="https://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Risk
|
|
|
|
is very low, the length appears to be in characters not bytes. </i>
|
2007-01-16 03:44:45 +01:00
|
|
|
<pre>
|
|
|
|
MultiByteToWideChar(CP_ACP,0,szName,-1,wszUserName,sizeof wszUserName /sizeof(wszUserName[0]));
|
|
|
|
</pre>
|
|
|
|
</ul>
|
2014-07-19 22:42:14 +02:00
|
|
|
<h2>Analysis Summary</h2>
|
2007-01-16 03:44:45 +01:00
|
|
|
<p>
|
2021-01-10 02:37:20 +01:00
|
|
|
Hits = 39
|
2007-01-16 03:44:45 +01:00
|
|
|
<br>
|
2021-01-10 02:37:20 +01:00
|
|
|
Lines analyzed = 126
|
2007-01-16 03:44:45 +01:00
|
|
|
<br>
|
2021-01-10 02:37:20 +01:00
|
|
|
Physical Source Lines of Code (SLOC) = 86
|
2007-01-16 03:44:45 +01:00
|
|
|
<br>
|
2021-01-10 02:37:20 +01:00
|
|
|
Hits@level = [0] 16 [1] 9 [2] 9 [3] 4 [4] 10 [5] 7 <br>
|
|
|
|
Hits@level+ = [0+] 55 [1+] 39 [2+] 30 [3+] 21 [4+] 17 [5+] 7 <br>
|
|
|
|
Hits/KSLOC@level+ = [0+] 639.535 [1+] 453.488 [2+] 348.837 [3+] 244.186 [4+] 197.674 [5+] 81.3953 <br>
|
2007-01-16 03:44:45 +01:00
|
|
|
Suppressed hits = 2 (use --neverignore to show them)
|
|
|
|
<br>
|
|
|
|
Minimum risk level = 1
|
|
|
|
<br>
|
|
|
|
Not every hit is necessarily a security vulnerability.
|
2021-01-09 18:55:44 +01:00
|
|
|
You can inhibit a report by adding a comment in this form:
|
|
|
|
// flawfinder: ignore
|
|
|
|
Make *sure* it's a false positive!
|
|
|
|
You can use the option --neverignore to show these.
|
2007-01-16 03:44:45 +01:00
|
|
|
<br>
|
|
|
|
There may be other security vulnerabilities; review your code!
|
2014-07-29 03:25:00 +02:00
|
|
|
<br>
|
2018-10-01 03:35:11 +02:00
|
|
|
See '<a href="https://dwheeler.com/secure-programs">Secure Programming HOWTO</a>'
|
|
|
|
(<a href="https://dwheeler.com/secure-programs">https://dwheeler.com/secure-programs</a>) for more information.
|
2007-01-16 03:44:45 +01:00
|
|
|
</body>
|
|
|
|
</html>
|