Skip to content

Commit

Permalink
Handle case where no rollback version was yet stored (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored Feb 28, 2024
1 parent 5e575ce commit ad572e0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions trusted_os/rpmb.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"encoding/gob"
"errors"
"fmt"
"io"
"log"

"golang.org/x/crypto/pbkdf2"
Expand Down Expand Up @@ -165,6 +166,10 @@ func (r *RPMB) expectedVersion(offset uint16) (*semver.Version, error) {
}
var v string
if err := gob.NewDecoder(bytes.NewBuffer(buf)).Decode(&v); err != nil {
if err == io.EOF {
// We've not previously stored a version, so return 0.0.0
return semver.NewVersion("0.0.0")
}
return nil, err
}

Expand Down

0 comments on commit ad572e0

Please sign in to comment.