Skip to content

Potential fix for code scanning alert no. 5: Suspicious add with sizeof#56

Merged
dongsupark merged 1 commit into
mainfrom
alert-autofix-5
May 13, 2026
Merged

Potential fix for code scanning alert no. 5: Suspicious add with sizeof#56
dongsupark merged 1 commit into
mainfrom
alert-autofix-5

Conversation

@dongsupark
Copy link
Copy Markdown
Member

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 in ApplyMapTest to use std::begin(initial_values) and std::end(initial_values) instead of &initial_values[0] and initial_values + arraysize(initial_values). This preserves exact behavior, improves readability, and removes the suspicious-offset pattern entirely.

Needed changes:

  • Add #include <iterator> (for std::begin/std::end) near existing includes.
  • Replace only the vector<int> collection(...) initialization lines in ApplyMapTest.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

dongsupark added a commit to flatcar/scripts that referenced this pull request May 11, 2026
dongsupark added a commit to flatcar/scripts that referenced this pull request May 12, 2026
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>
@dongsupark dongsupark marked this pull request as ready for review May 13, 2026 09:42
@dongsupark dongsupark requested a review from a team as a code owner May 13, 2026 09:42
@dongsupark
Copy link
Copy Markdown
Member Author

@dongsupark dongsupark merged commit 7382641 into main May 13, 2026
5 checks passed
@dongsupark dongsupark deleted the alert-autofix-5 branch May 13, 2026 11:23
dongsupark added a commit to flatcar/scripts that referenced this pull request May 13, 2026
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants