-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #901 Improve out-of-bounds check to detect error with sprintf() #8473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -384,7 +384,7 @@ namespace ValueFlow | |
| v.debugPath.emplace_back(tok, std::move(s)); | ||
| } | ||
|
|
||
| MathLib::bigint valueFlowGetStrLength(const Token* tok) | ||
| MathLib::bigint valueFlowGetStrLength(const Token* tok, const Settings& settings) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could just pass
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but we are doing that all over the place. And in the end, it just means slightly more code at the call site, slightly less code in the called function.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually not that bad - see #8500 (I actually made those changes a while before I spotted it in this PR). |
||
| { | ||
| if (tok->tokType() == Token::eString) | ||
| return Token::getStrLength(tok); | ||
|
|
@@ -394,8 +394,10 @@ namespace ValueFlow | |
| return v->intvalue; | ||
| if (const Value* v = tok->getKnownValue(Value::ValueType::TOK)) { | ||
| if (v->tokvalue != tok) | ||
| return valueFlowGetStrLength(v->tokvalue); | ||
| return valueFlowGetStrLength(v->tokvalue, settings); | ||
| } | ||
| if (const Token* cont = settings.library.getContainerFromYield(tok, Library::Container::Yield::BUFFER_NT)) | ||
| return valueFlowGetStrLength(cont, settings); | ||
| return 0; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.