-
Notifications
You must be signed in to change notification settings - Fork 0
fix(OSQUERY-010): 2 review findings in apt_sources.cpp #45
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: master
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 |
|---|---|---|
|
|
@@ -84,7 +84,7 @@ Status parseAptSourceLine(const std::string& input_line, | |
|
|
||
| apt_source.base_uri = tokens[offset]; | ||
| // Cannot have trailing slashes | ||
| while (apt_source.base_uri.back() == '/') { | ||
| while (!apt_source.base_uri.empty() && apt_source.base_uri.back() == '/') { | ||
| apt_source.base_uri.pop_back(); | ||
| } | ||
|
|
||
|
|
@@ -264,7 +264,7 @@ Status parseDeb822Block(const std::string& input_block, | |
| continue; | ||
| } | ||
| // Cannot have trailing slashes | ||
| while (uri.back() == '/') { | ||
| while (!uri.empty() && uri.back() == '/') { | ||
| uri.pop_back(); | ||
| } | ||
| uris.push_back(uri); | ||
|
Comment on lines
264
to
270
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. 𦩠π Same unchecked .back() pattern repeated in parseDeb822Block URI trimming In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
@@ -400,3 +400,4 @@ QueryData genAptSrcs(QueryContext& context) { | |
| } | ||
| } // namespace tables | ||
| } // namespace osquery | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π apt_sources.cpp back()-on-empty-string risk when parsing base_uri trailing slashes
In
parseAptSourceLine, the trailing-slash trimming loop onapt_source.base_urinow checks!apt_source.base_uri.empty()before calling.back(), preventing undefined behavior when the URI is all slashes.π€ Prompt for AI agents
fix confidence: π’ 95 high β react π/π to teach the reviewer