Fix nullptr crash in RecConfigOverrideFromEnvironment with runroot#12917
Open
brbzull0 wants to merge 1 commit intoapache:masterfrom
Open
Fix nullptr crash in RecConfigOverrideFromEnvironment with runroot#12917brbzull0 wants to merge 1 commit intoapache:masterfrom
brbzull0 wants to merge 1 commit intoapache:masterfrom
Conversation
When runroot is active and the PROXY_CONFIG_* environment variables for
path records (bin_path, local_state_dir, logfile_dir, plugin_dir) are
not set, RecConfigOverrideFromEnvironment() returned nullptr. This
violated its documented contract ("return either the overridden value,
or the original value") and caused a std::logic_error crash during
records.yaml parsing:
basic_string: construction from null is not valid
The nullptr was assigned to std::string in SetRecordFromYAMLNode(),
which threw the exception. The bug was masked in autests because the
framework always sets these env vars.
Fix: return the original config value instead of nullptr when
RecConfigOverrideFromRunroot() matches. The record value is then
resolved by Layout::relative() at runtime, producing the correct path.
Add a test that unsets the 4 path env vars to exercise the runroot code
path, and validates record values via traffic_ctl config get.
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.
When runroot is active and the
PROXY_CONFIG_*environment variables for path records (bin_path,local_state_dir``,logfile_dir,plugin_dir) are not set,RecConfigOverrideFromEnvironment()returnednullptr. This violated its documented contract ("return either the overridden value, or the original value") and caused astd::logic_erro`r crash during records.yaml parsing:The nullptr was assigned to
std::stringinSetRecordFromYAMLNode(), which threw the exception. The bug was masked in autests because the framework always sets these env vars.Fix: return the original config value instead of nullptr when RecConfigOverrideFromRunroot() matches. The record value is then resolved by
Layout::relative()at runtime, producing the correct path.Add a test that unsets the 4 path env vars to exercise the runroot code path, and validates record values via
traffic_ctl config get.