Skip to content

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

Draft
dongsupark wants to merge 1 commit into
mainfrom
alert-autofix-5
Draft

Potential fix for code scanning alert no. 5: Suspicious add with sizeof#56
dongsupark wants to merge 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.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
dongsupark added a commit to flatcar/scripts that referenced this pull request May 11, 2026
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.

1 participant