aboutsummaryrefslogtreecommitdiff
path: root/verify
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-03-07 00:56:46 +0100
committeraxtloss <axtlos@getcryst.al>2024-03-07 00:56:46 +0100
commitc365a6bac14227a6e7e341ef8228365ca443d2fb (patch)
tree6c0fed4e74fb3198a3afb79fd7bebfa477c46a47 /verify
parent0f5bd8e774b4746c27d9a573057d57770e1cf0de (diff)
downloadfsverify-main.tar.gz
fsverify-main.tar.bz2
bugfixesHEADmain
Diffstat (limited to '')
-rw-r--r--verify/cmd/verify.go12
-rw-r--r--verify/core/storage.go4
-rw-r--r--verify/core/verification.go2
-rw-r--r--verify/getScreensize.c2
-rw-r--r--verifysetup/core/storage.go2
5 files changed, 14 insertions, 8 deletions
diff --git a/verify/cmd/verify.go b/verify/cmd/verify.go
index e263afa..1d8a976 100644
--- a/verify/cmd/verify.go
+++ b/verify/cmd/verify.go
@@ -86,11 +86,13 @@ func validateThread(blockStart int, blockEnd int, bundleSize int, diskBytes []by
func ValidateCommand(_ *cobra.Command, args []string) error {
if len(args) != 1 {
+ core.WarnUser()
return fmt.Errorf("Usage: fsverify verify [disk]")
}
header, err := core.ReadHeader(config.FsVerifyPart)
if err != nil {
+ core.WarnUser()
return err
}
@@ -98,23 +100,29 @@ func ValidateCommand(_ *cobra.Command, args []string) error {
// this does not check if the partition has been tampered with
// it only checks if the specified partition is even an fsverify partition
if header.MagicNumber != 0xACAB {
+ core.WarnUser()
return fmt.Errorf("sanity bit does not match. Expected %d, got %d", 0xACAB, header.MagicNumber)
}
fmt.Println("Reading DB")
dbfile, err := core.ReadDB(config.FsVerifyPart)
if err != nil {
+ core.WarnUser()
return err
}
key, err := core.ReadKey()
if err != nil {
+ fmt.Println(err)
+ core.WarnUser()
return err
}
fmt.Println("Key: " + key)
verified, err := core.VerifySignature(key, header.Signature, dbfile)
if err != nil {
+ core.WarnUser()
return err
} else if !verified {
+ core.WarnUser()
return fmt.Errorf("Signature verification failed\n")
} else {
fmt.Println("Signature verification success!")
@@ -123,11 +131,13 @@ func ValidateCommand(_ *cobra.Command, args []string) error {
fmt.Println("----")
disk, err := os.Open(args[0])
if err != nil {
+ core.WarnUser()
return err
}
defer disk.Close()
diskInfo, err := disk.Stat()
if err != nil {
+ core.WarnUser()
return err
}
diskSize := diskInfo.Size()
@@ -135,6 +145,7 @@ func ValidateCommand(_ *cobra.Command, args []string) error {
// If the filesystem size has increased ever since the fsverify partition was created
// it would mean that fsverify is not able to verify the entire partition, making it useless
if header.FilesystemSize*header.FilesystemUnit != int(diskSize) {
+ core.WarnUser()
return fmt.Errorf("disk size does not match disk size specified in header. Expected %d, got %d", header.FilesystemSize*header.FilesystemUnit, diskSize)
}
@@ -142,6 +153,7 @@ func ValidateCommand(_ *cobra.Command, args []string) error {
diskBytes := make([]byte, diskSize)
_, err = disk.Read(diskBytes)
if err != nil {
+ core.WarnUser()
return err
}
reader := bytes.NewReader(diskBytes)
diff --git a/verify/core/storage.go b/verify/core/storage.go
index 182e1ec..f1f9436 100644
--- a/verify/core/storage.go
+++ b/verify/core/storage.go
@@ -232,9 +232,7 @@ func GetNode(checksum string, db *bolt.DB) (Node, error) {
func CopyByteArea(start int, end int, reader *bytes.Reader) ([]byte, error) {
if end-start < 0 {
return []byte{}, fmt.Errorf("tried creating byte slice with negative length. %d to %d total %d\n", start, end, end-start)
- } else if end-start > 2000 {
- return []byte{}, fmt.Errorf("tried creating byte slice with length over 2000. %d to %d total %d\n", start, end, end-start)
- }
+ }
bytes := make([]byte, end-start)
n, err := reader.ReadAt(bytes, int64(start))
if err != nil {
diff --git a/verify/core/verification.go b/verify/core/verification.go
index 28b4e3b..5a95e75 100644
--- a/verify/core/verification.go
+++ b/verify/core/verification.go
@@ -106,8 +106,6 @@ func ReadKey() (string, error) {
func ReadBlock(node Node, part *bytes.Reader, totalReadBlocks int) ([]byte, int, error) {
if node.BlockEnd-node.BlockStart < 0 {
return []byte{}, -1, fmt.Errorf("tried creating byte slice with negative length. %d to %d total %d\n", node.BlockStart, node.BlockEnd, node.BlockEnd-node.BlockStart)
- } else if node.BlockEnd-node.BlockStart > 2000 {
- return []byte{}, -1, fmt.Errorf("tried creating byte slice with length over 2000. %d to %d total %d\n", node.BlockStart, node.BlockEnd, node.BlockEnd-node.BlockStart)
}
block := make([]byte, node.BlockEnd-node.BlockStart)
blockSize := node.BlockEnd - node.BlockStart
diff --git a/verify/getScreensize.c b/verify/getScreensize.c
index c383b71..56393b0 100644
--- a/verify/getScreensize.c
+++ b/verify/getScreensize.c
@@ -19,6 +19,6 @@ int main(void) {
if (ioctl(fbfb, FBIOGET_VSCREENINFO, &vinfo) == -1)
return 1;
- printf("%d", vinfo.yres);
+ printf("%d", vinfo.xres);
return 0;
}
diff --git a/verifysetup/core/storage.go b/verifysetup/core/storage.go
index 33efa30..c15ebfe 100644
--- a/verifysetup/core/storage.go
+++ b/verifysetup/core/storage.go
@@ -15,8 +15,6 @@ import (
func ReadBlock(start int, end int, device *bytes.Reader) ([]byte, error) {
if end-start < 0 {
return []byte{}, fmt.Errorf("tried creating byte slice with negative length. %d to %d total %d\n", start, end, end-start)
- } else if end-start > 2000 {
- return []byte{}, fmt.Errorf("tried creating byte slice with length over 2000. %d to %d total %d\n", start, end, end-start)
}
block := make([]byte, end-start)
_, err := device.Seek(int64(start), 0)