| 458 | } |
| 459 | |
| 460 | void CheckStringImpl::sprintfOverlappingDataError(const Token *funcTok, const Token *tok, const std::string &varname) |
| 461 | { |
| 462 | const std::string func = funcTok ? funcTok->str() : "s[n]printf"; |
| 463 | |
| 464 | reportError(tok, Severity::error, "sprintfOverlappingData", |
| 465 | "$symbol:" + varname + "\n" |
| 466 | "Undefined behavior: Variable '$symbol' is used as parameter and destination in " + func + "().\n" + |
| 467 | "The variable '$symbol' is used both as a parameter and as destination in " + |
| 468 | func + "(). The origin and destination buffers overlap. Quote from glibc (C-library) " |
| 469 | "documentation (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions): " |
| 470 | "\"If copying takes place between objects that overlap as a result of a call " |
| 471 | "to sprintf() or snprintf(), the results are undefined.\"", CWE628, Certainty::normal); |
| 472 | } |
| 473 | |
| 474 | void CheckString::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) |
| 475 | { |
no test coverage detected