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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimal gpt partition size is wrong #143

Open
therjak opened this issue May 2, 2022 · 3 comments
Open

minimal gpt partition size is wrong #143

therjak opened this issue May 2, 2022 · 3 comments

Comments

@therjak
Copy link
Contributor

therjak commented May 2, 2022

in partition/gpt/partition.go are multiple checks for end > start.
(e.g.

case start >= 0 && end > start && size == calculatedSize:
)

Both start and end represent sectors with start the first and end the last sector of the partition. so the minimal allowed sector size of a partition becomes 2 while it should be 1.
this is somewhat correctly reflected in

case size > 0 && start > 0 && end == 0:

if size equals blocksize (but it would create an invalid result for 0 < size < blocksize, with end = start-1).
The code will fail later on in a second check for end > start.

@deitch
Copy link
Collaborator

deitch commented May 3, 2022

Are you suggesting that this:

 case start >= 0 && end > start && size == calculatedSize: 

should be

 case start >= 0 && end >= start && size == calculatedSize: 

To be honest, this line is a bit in error in that it doesn't do anything, as it is a lone case statement.

@therjak
Copy link
Contributor Author

therjak commented May 3, 2022

yes.

case p.Size <= 0 && p.End > p.Start:

case start >= 0 && end > start && size == calculatedSize:

case size == 0 && start >= 0 && end > start:

should allow end == start

I assume

case p.Size > 0 && p.End <= p.Start:

should be
case p.Size != 0 && p.End < p.Start:
or
case p.Size != 0 && p.End == 0

(btw p.Size <= 0 is the same same p.Size == 0 as it is unsigned but I guess that is more about preference)

@deitch
Copy link
Collaborator

deitch commented May 3, 2022

Happy to take a PR on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants