Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accidental mutation of shared cty.Paths in ValueMarks funcs #32543

Merged
merged 1 commit into from Jan 20, 2023

Commits on Jan 19, 2023

  1. Fix accidental mutation of shared cty.Paths in ValueMarks funcs

    Go's `append()` reserves the right to mutate its primary argument in-place, and
    expects the caller to assign its return value to the same variable that was
    passed as the primary argument. Due to what was almost definitely a typo
    (followed by copy-paste mishap), the configschema `Block.ValueMarks` and
    `Object.ValueMarks` functions were treating it like an immutable function that
    returns a new slice.
    
    In rare and hard-to-reproduce cases, this was causing bizarre malfunctions when
    marking sensitive schema attributes in deeply-nested block structures --
    omitting the marks for some sensitive values (馃毃), and marking other entire
    blocks as sensitive (which is supposed to be impossible). The chaotic and
    unreliable nature of the bugs is likely related to `append()`'s automatic slice
    reallocation behavior (if the append operation overflows the original array
    allocation, the resulting behavior can _look_ immutable), but there might be
    other contributing factors too.
    
    This commit fixes existing instances of the problem, and wraps the desired
    copy-and-append behavior in a helper function to simplify handling shared parent
    paths in an immutable way.
    nfagerlund committed Jan 19, 2023
    Copy the full SHA
    83428c9 View commit details
    Browse the repository at this point in the history