Repository navigation
fix crash in consul_health when an entry has no Checks array - #331
Merged
Merged
Conversation
ngx_http_upsync_consul_health_parse_json() dereferenced the result of cJSON_GetObjectItem(server_next, "Checks") without a NULL check, so a health entry without a "Checks" array crashed the worker. Skip the health check loop in that case, keeping the server and still applying its tags.
xiaokai-wang
approved these changes
Oct 16, 2026
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.
ngx_http_upsync_consul_health_parse_json()readschecks->childwithout checking thatcJSON_GetObjectItem(server_next, "Checks")returned non-NULL. A/v1/health/service/<name>entry without aChecksarray crashes the worker (SIGSEGV). This has been there since consul_health was added in #183.The fix skips only the health check loop when
Checksis missing, so the server is kept and itsweight=/max_fails=/fail_timeout=/down/backuptags are still applied.Tested with an AddressSanitizer build against nginx 1.26.3 and a mock Consul health endpoint returning three entries (all checks passing; one check critical; no
Checksbut aweight=5tag):SEGV ... ngx_http_upsync_module.c:1698 in ngx_http_upsync_consul_health_parse_json