disk: guard against nil pointer dereferencing

Add guards protecting against dereferencing the pointer receiver of
method calls.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
Christian Kellner 2022-02-19 13:28:40 +01:00 committed by Tom Gundersen
parent beaf411628
commit 206e030f2c
6 changed files with 51 additions and 7 deletions

View file

@ -66,6 +66,10 @@ func (lc *LUKSContainer) Clone() Entity {
}
func (lc *LUKSContainer) GenUUID(rng *rand.Rand) {
if lc == nil {
return
}
if lc.UUID == "" {
lc.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String()
}