Skip to content

Commit

Permalink
Modify how PCRSelectionList.Merge works slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisccoulson committed Dec 6, 2024
1 parent f1d394f commit 52bd011
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions types_structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func (l PCRSelectionList) MustSort() (out PCRSelectionList) {
// Merge will merge the PCR selections specified by l and r together and
// return a new set of PCR selections which contains a combination of both.
// For each PCR found in r that isn't found in l, it will be added to the
// first occurence of the corresponding PCR bank found in l if that exists,
// last occurence of the corresponding PCR bank found in l if that exists,
// or otherwise a selection for that PCR bank will be appended to the result.
//
// This will return an error if either selection list cannot be marshalled
Expand Down Expand Up @@ -714,10 +714,8 @@ func (l PCRSelectionList) Merge(r PCRSelectionList) (out PCRSelectionList, err e
panic(err)
}

if dsti == -1 {
dsti = i
dstbmp = lbmp
}
dsti = i
dstbmp = lbmp

// Avoid duplicated PCRs by clearing any in this source selection
// that exist in any selection in the destination list.
Expand Down
4 changes: 2 additions & 2 deletions types_structures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ func (s *typesStructuresSuite) TestPCRSelectionListMerge5(c *C) {
}
y := PCRSelectionList{{Hash: HashAlgorithmSHA256, Select: []int{3, 4, 2, 7}}}
expected := PCRSelectionList{
{Hash: HashAlgorithmSHA256, Select: []int{2, 4, 5, 6, 7}},
{Hash: HashAlgorithmSHA256, Select: []int{0, 1, 3}},
{Hash: HashAlgorithmSHA256, Select: []int{2, 5, 6}},
{Hash: HashAlgorithmSHA256, Select: []int{0, 1, 3, 4, 7}},
}
merged, err := x.Merge(y)
c.Check(err, IsNil)
Expand Down

0 comments on commit 52bd011

Please sign in to comment.