Repository navigation
Fix: guard against underflow in gvm_hosts_move_current_host_to_end - #1150
Merged
greenbonebot merged 3 commits intoOct 20, 2026
Conversation
Without this guard the index wraps to SIZE_MAX and the host array is read out of bounds.
With an empty set current equals count equals zero, so decrementing wraps the index and a later next call reads past the host array.
greenbonebot
enabled auto-merge (rebase)
October 20, 2026 12:38
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
a-h-abdelsalam
approved these changes
Oct 20, 2026
greenbonebot
deleted the
fix/49-out-of-bounds-read-when-hosts-current-is-0-in-gvm-hosts-move-current-host-to-end
branch
October 20, 2026 12:53
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.
What
Return early when
hosts->currentis 0 in both branches ofgvm_hosts_move_current_host_to_end, before decrementing the index.Why
The function decremented
hosts->currentunconditionally, so when it was 0(before the first host, or with an empty set) the
size_twrapped toSIZE_MAXand the host array was read out of bounds. The fix is needed toavoid those reads.
Testing
gvm_hosts_move_current_host_to_end_before_first_host(hosts-test):before the fix, ASan reported a heap-buffer-overflow read in
gvm_hosts_move_current_host_to_endatbase/hosts.c:1369; after the fixthe case passes clean.
gvm_hosts_move_current_host_to_end_empty_hosts(hosts-test): before thefix, ASan reported a heap-buffer-overflow read in
gvm_hosts_nextatbase/hosts.c:1332; after the fix the case passes clean.The full gvm-libs unit suite is ASan-clean with the fix.