Fix: Fail fast on unsupported volume versions (#8047)

* Fix: Fail fast when initializing volume with Version 0

* Fix: Fail fast when loading unsupported volume version (e.g. 0 or 4)

* Refactor: Use IsSupportedVersion helper function for version validation
This commit is contained in:
Chris Lu
2026-01-16 19:19:18 -08:00
committed by GitHub
parent 0a46577700
commit a473278bfa
3 changed files with 10 additions and 0 deletions

View File

@@ -18,6 +18,9 @@ func (v *Volume) maybeWriteSuperBlock(ver needle.Version) error {
return e
}
if datSize == 0 {
if !needle.IsSupportedVersion(ver) {
return fmt.Errorf("volume super block version %d is not supported", ver)
}
v.SuperBlock.Version = ver
_, e = v.DataBackend.WriteAt(v.SuperBlock.Bytes(), 0)
if e != nil && os.IsPermission(e) {