Skip to content

pkg/extend fix panic for empty partition tables #4101

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

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

ChrisIgel
Copy link
Contributor

@ChrisIgel ChrisIgel commented Jan 29, 2025

- What I did

Fix a go panic when trying to resize a device with a partition table with 0 partitions.

- How I did it

Check the condition and return early.

- How to verify it

Create and mount a dummy device with an empty partition table and let pkg/extend try to resize the device.
The following error should no longer occur:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.extend({0xc000013880, 0xa}, {0x5341a3, 0x4})
        /<redacted>/linuxkit/pkg/extend/extend.go:93 +0x119c
main.autoextend({0x5341a3, 0x4})
        /<redacted>/linuxkit/pkg/extend/extend.go:60 +0x1b0
main.main()
        /<redacted>/linuxkit/pkg/extend/extend.go:333 +0x8e

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Chris Irrgang <chris.irrgang@gmx.de>
Copy link
Collaborator

@deitch deitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, can you run ./scripts/update-component-sha.sh --pkg ./pkg/extend from within the linuxkit repo root, so the examples and everything pick it up?

@ChrisIgel
Copy link
Contributor Author

This is fine, can you run ./scripts/update-component-sha.sh --pkg ./pkg/extend from within the linuxkit repo root, so the examples and everything pick it up?

I already did that :)

@deitch
Copy link
Collaborator

deitch commented Jan 30, 2025

Yeah, you are right. I was sure it was elsewhere, but it is not.

@deitch deitch merged commit 7ac34a6 into linuxkit:master Jan 30, 2025
22 checks passed
@ChrisIgel ChrisIgel deleted the bugfix/pkg-extend-panic branch January 30, 2025 14:06
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

Successfully merging this pull request may close these issues.

2 participants