mirror of
https://github.com/ssut/payload-dumper-go.git
synced 2024-05-13 19:19:11 +00:00
parent
d100a4b3a0
commit
b36ebf31e5
15
payload.go
15
payload.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/bzip2"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
|
@ -286,6 +287,18 @@ func (p *Payload) Extract(partition *chromeos_update_engine.PartitionUpdate, out
|
|||
}
|
||||
break
|
||||
|
||||
case chromeos_update_engine.InstallOperation_ZERO:
|
||||
reader := bytes.NewReader(make([]byte, expectedUncompressedBlockSize))
|
||||
n, err := io.Copy(out, reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if n != expectedUncompressedBlockSize {
|
||||
return fmt.Errorf("Verify failed (Unexpected bytes written): %s (%d != %d)", name, n, expectedUncompressedBlockSize)
|
||||
}
|
||||
break
|
||||
|
||||
default:
|
||||
return fmt.Errorf("Unhandled operation type: %s", operation.GetType().String())
|
||||
}
|
||||
|
@ -293,7 +306,7 @@ func (p *Payload) Extract(partition *chromeos_update_engine.PartitionUpdate, out
|
|||
// verify hash
|
||||
hash := hex.EncodeToString(bufSha.Sum(nil))
|
||||
expectedHash := hex.EncodeToString(operation.GetDataSha256Hash())
|
||||
if hash != expectedHash {
|
||||
if expectedHash != "" && hash != expectedHash {
|
||||
return fmt.Errorf("Verify failed (Checksum mismatch): %s (%s != %s)", name, hash, expectedHash)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user