Started work on proper tests.

STILL HAVING STUPID UNEXPLAINABLE NIL POINTERS.
This commit is contained in:
Caleb Gardner
2022-06-18 01:32:51 -05:00
parent 8613e35221
commit cde6a265a1
6 changed files with 121 additions and 22 deletions
+7 -3
View File
@@ -25,8 +25,9 @@ type Reader struct {
}
var (
ErrorMagic = errors.New("magic incorrect. probably not reading squashfs archive")
ErrorLog = errors.New("block log is incorrect. possible corrupted archive")
ErrorMagic = errors.New("magic incorrect. probably not reading squashfs archive")
ErrorLog = errors.New("block log is incorrect. possible corrupted archive")
ErrorVersion = errors.New("squashfs version of archive is not 4.0")
)
const (
@@ -53,12 +54,15 @@ func NewReader(r io.ReaderAt) (*Reader, error) {
if err != nil {
return nil, err
}
if !squash.s.hasMagic() {
if !squash.s.checkMagic() {
return nil, ErrorMagic
}
if !squash.s.checkBlockLog() {
return nil, ErrorLog
}
if !squash.s.checkVersion() {
return nil, ErrorVersion
}
switch squash.s.CompType {
case GZipCompression:
squash.d = decompress.GZip{}