File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package snapshot
1919import (
2020 "bytes"
2121 "context"
22+ "encoding/binary"
2223 "fmt"
2324 "os"
2425 "os/exec"
@@ -27,7 +28,6 @@ import (
2728 "sync"
2829 "syscall"
2930 "time"
30- "unsafe"
3131
3232 "github.com/containerd/accelerated-container-image/pkg/label"
3333 "github.com/containerd/accelerated-container-image/pkg/snapshot/diskquota"
@@ -1585,9 +1585,12 @@ func (o *snapshotter) identifyLocalStorageType(filePath string) (storageType, er
15851585}
15861586
15871587func isOverlaybdFileHeader (header []byte ) bool {
1588- magic0 := * (* uint64 )(unsafe .Pointer (& header [0 ]))
1589- magic1 := * (* uint64 )(unsafe .Pointer (& header [8 ]))
1590- magic2 := * (* uint64 )(unsafe .Pointer (& header [16 ]))
1591- return (magic0 == 281910587246170 && magic1 == 7384066304294679924 && magic2 == 7017278244700045632 ) ||
1592- (magic0 == 564050879402828 && magic1 == 5478704352671792741 && magic2 == 9993152565363659426 )
1588+ if len (header ) < 24 {
1589+ return false
1590+ }
1591+ magic0 := binary .LittleEndian .Uint64 (header [0 :8 ])
1592+ magic1 := binary .LittleEndian .Uint64 (header [8 :16 ])
1593+ magic2 := binary .LittleEndian .Uint64 (header [16 :24 ])
1594+ return (magic0 == 281910587246170 && magic1 == 7384066304294679924 && magic2 == 7017278244700045632 ) || // "ZFile\x00\x01\x00", "tuji.yyf", "@Alibaba"
1595+ (magic0 == 564050879402828 && magic1 == 5478704352671792741 && magic2 == 9993152565363659426 ) // "LSMT\x00\x01\x02\x00", …, …
15931596}
You can’t perform that action at this time.
0 commit comments