Skip to content

Potential fix for code scanning alert no. 3: Unsigned difference expression compared to zero #44

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

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

dongsupark
Copy link
Member

Potential fix for https://github.com/flatcar/update_engine/security/code-scanning/3

To fix the issue, we need to avoid unsigned subtraction in the loop condition. Instead of count - bytes_written > 0, we can directly compare bytes_written with count using bytes_written < count. This approach avoids the risk of underflow and achieves the same logical result.

The fix involves replacing the condition on line 21 with bytes_written < count. This change ensures that the loop behaves correctly regardless of the values of count and bytes_written.


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

…ession compared to zero

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@dongsupark dongsupark merged commit 585a0bb into main Jul 10, 2025
4 checks passed
@dongsupark dongsupark deleted the fix-unsigned-difference branch July 10, 2025 12:37
dongsupark added a commit to flatcar/scripts that referenced this pull request Jul 10, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Jul 16, 2025
Bump coreos-base/update_engine to 2025-07-10.

Pulls in flatcar/update_engine#44,
flatcar/update_engine#45,
flatcar/update_engine#46.

Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark added a commit to flatcar/scripts that referenced this pull request Jul 16, 2025
Bump coreos-base/update_engine to 2025-07-10.

Pulls in flatcar/update_engine#44,
flatcar/update_engine#45,
flatcar/update_engine#46.

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