Potential fix for code scanning alert no. 5: Suspicious add with sizeof#56
Merged
Conversation
dongsupark
added a commit
to flatcar/scripts
that referenced
this pull request
May 11, 2026
flatcar/update_engine#56 Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark
added a commit
to flatcar/scripts
that referenced
this pull request
May 12, 2026
flatcar/update_engine#56 Signed-off-by: Dongsu Park <dongsu@dpark.io>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Dongsu Park <dongsu@dpark.io>
1eddb9b to
37cbd67
Compare
Member
Author
|
Jenkins CI passed: https://jenkins.flatcar.org/job/container/job/packages_all_arches/21/cldsv/ |
krnowak
approved these changes
May 13, 2026
dongsupark
added a commit
to flatcar/scripts
that referenced
this pull request
May 13, 2026
flatcar/update_engine#56 Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark
added a commit
to flatcar/scripts
that referenced
this pull request
May 13, 2026
Fix suspicious add with sizeof found by CodeQL scanning. Pulls in flatcar/update_engine#56. Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark
added a commit
to flatcar/scripts
that referenced
this pull request
May 13, 2026
Fix suspicious add with sizeof found by CodeQL scanning. Pulls in flatcar/update_engine#56. Signed-off-by: Dongsu Park <dongsu@dpark.io>
1 task
dongsupark
added a commit
to flatcar/scripts
that referenced
this pull request
May 13, 2026
Fix suspicious add with sizeof found by CodeQL scanning. Pulls in flatcar/update_engine#56. Signed-off-by: Dongsu Park <dongsu@dpark.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/flatcar/update_engine/security/code-scanning/5
General fix: avoid pointer arithmetic with size-derived expressions in container range construction; use explicit begin/end helpers or indexing forms that clearly operate on elements.
Best fix here (without functional change): in
src/update_engine/utils_unittest.cc, update the vector construction inApplyMapTestto usestd::begin(initial_values)andstd::end(initial_values)instead of&initial_values[0]andinitial_values + arraysize(initial_values). This preserves exact behavior, improves readability, and removes the suspicious-offset pattern entirely.Needed changes:
#include <iterator>(forstd::begin/std::end) near existing includes.vector<int> collection(...)initialization lines inApplyMapTest.Suggested fixes powered by Copilot Autofix. Review carefully before merging.