diff --git a/ext4/tar2ext4/tar2ext4.go b/ext4/tar2ext4/tar2ext4.go index 1ffca8ecfc..a82462f024 100644 --- a/ext4/tar2ext4/tar2ext4.go +++ b/ext4/tar2ext4/tar2ext4.go @@ -272,6 +272,10 @@ func ReadExt4SuperBlock(vhdPath string) (*format.SuperBlock, error) { if err := binary.Read(vhd, binary.LittleEndian, &sb); err != nil { return nil, err } + // Make sure the magic bytes are correct. + if sb.Magic != format.SuperBlockMagic { + return nil, errors.New("not an ext4 file system") + } return &sb, nil } diff --git a/test/vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/tar2ext4.go b/test/vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/tar2ext4.go index 1ffca8ecfc..a82462f024 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/tar2ext4.go +++ b/test/vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/tar2ext4.go @@ -272,6 +272,10 @@ func ReadExt4SuperBlock(vhdPath string) (*format.SuperBlock, error) { if err := binary.Read(vhd, binary.LittleEndian, &sb); err != nil { return nil, err } + // Make sure the magic bytes are correct. + if sb.Magic != format.SuperBlockMagic { + return nil, errors.New("not an ext4 file system") + } return &sb, nil }