...
| Code Block | ||
|---|---|---|
| ||
char buf[BUFSIZ + 1];
char *p;
if (fgets(buf, sizeof(buf), fp)) {
p = strchr(buf, '\n');
if (p) {
*p = '\0';
}
}
else {
/* handle error condition */
}
|
Risk Assessment
Assuming a newline character is read can result in data truncation.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
FI036-C | 1 (low) | 1 (unlikely) | 3 (low) | P3 | L3 |
...
References
| Wiki Markup |
|---|
\[[Lai 06|AA. C References#Lai 06]\] \[[Seacord 05|AA. C References#Seacord 05]\] Chapter 2, "Strings" \[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] Section 7.19.7.2, "The fgets function" |