...
| Code Block | ||||
|---|---|---|---|---|
| ||||
void getPassword(void) {
char pwd[64];
if (retrievePassword(pwd, sizeof(pwd))) {
/* Checking of password, secure operations, etc. */
}
memset(pwd, 0, sizeof(pwd));
*(volatile char*)pwd= *(volatile char*)pwd;
}
|
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Automated Detection
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| CodeSonar |
| BADFUNC.MEMSET | Use of memset | ||||||
| LDRA tool suite |
| 35 S, 57 S, 8 D, 65 D, 76 D, 105 D, I J, 3 J | Partially Implementedimplemented |
Related Guidelines
...
| [ISO/IEC 9899:2011] | Subclause 6.8.5, "Iteration Statements" Subclause K.3.7.4.1, "The memset_s Function" |
| [MSDN] | "SecureZeroMemory" "Optimize (C/C++)" |
| [US-CERT] | "MEMSET" |
| [Wheeler 2003] | Section 11.4, "Specially Protect Secrets (Passwords and Keys) in User Memory" |
...
...