gpt: reject '0<unit>' partition start values that crash sgdisk - #1284
Open
yottanami wants to merge 2 commits into
Open
gpt: reject '0<unit>' partition start values that crash sgdisk#1284yottanami wants to merge 2 commits into
yottanami wants to merge 2 commits into
Conversation
sgdisk treats a bare '0' as 'next available range', but '0' directly followed by a size unit (0M, 0K, 0G, 0T, 0P) is parsed as a literal zero-byte offset instead, which collides with the GPT header/table area and makes sgdisk fail with a confusing error instead of doing what the user expects. Add a type check on the start option (same pattern as the size option a few lines above) that rejects this specific footgun at eval time, while still allowing a bare '0' and any non-zero offset. Fixes nix-community#702
The repo's jsonTypes check (lib/default.nix's typesSerializerLib) runs option definitions through a stub lib for doc generation that doesn't implement addCheck, so the previous commit's direct lib.types.addCheck call crashed that check with 'attribute addCheck missing'. Guard the lookup with 'or' so the doc-generation stub degrades to a no-op (same as any other unrestricted str option there) while real evaluation still gets the genuine addCheck and its validation.
Author
|
Pushed a follow-up commit: the Also noting: the |
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.
sgdisktreats a bare"0"forstartas "next available range", but"0"directly followed by a size unit (0M,0K,0G,0T,0P) is parsed as a literal zero-byte offset instead — which collides with the GPT header/table area and makessgdiskfail with a confusing error instead of doing what the user expects (see the errors quoted in the issue).This adds a type check on the
startoption (lib/types/gpt.nix), following the same pattern used by thesizeoption a few lines above, that rejects this specific footgun at Nix-eval time with a clear description, while still allowing a bare"0"and any non-zero offset (e.g."1M","2048","-1M").Checked all in-repo usages of
starton gpt-typed partitions (examples + tests) — they all use non-zero offsets like"1M"already, so this shouldn't affect any existing configuration.I don't have a local Nix environment to run
nix flake check/ the test suite against this change — flagging that so a maintainer/CI can verify the syntax and formatting (nixfmt) directly.Fixes #702