mirror of
https://github.com/wader/fq.git
synced 2024-11-30 09:58:13 +03:00
luajit: magic number: raw bits, check with assert
This commit is contained in:
parent
29ab66b3eb
commit
e44f5c00b8
@ -59,12 +59,7 @@ type DumpInfo struct {
|
||||
}
|
||||
|
||||
func LuaJITDecodeHeader(di *DumpInfo, d *decode.D) {
|
||||
magic := d.FieldStr("magic", 3, encoding.Nop)
|
||||
|
||||
ok := bytes.Equal([]byte(magic), []byte{0x1b, 0x4c, 0x4a})
|
||||
if !ok {
|
||||
d.Errorf("invalid magic number")
|
||||
}
|
||||
d.FieldRawLen("magic", 3*8, d.AssertBitBuf([]byte{0x1b, 0x4c, 0x4a})) // ESC 'L' 'J'
|
||||
|
||||
d.FieldU8("version")
|
||||
|
||||
|
2
format/luajit/testdata/simple.fqtest
vendored
2
format/luajit/testdata/simple.fqtest
vendored
@ -1,7 +1,7 @@
|
||||
$ fq dv -d luajit simple.luac
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: simple.luac (luajit) 0x0-0x14e.7 (335)
|
||||
| | | header{}: 0x0-0x17.7 (24)
|
||||
0x000|1b 4c 4a |.LJ | magic: "\x1bLJ" 0x0-0x2.7 (3)
|
||||
0x000|1b 4c 4a |.LJ | magic: raw bits (valid) 0x0-0x2.7 (3)
|
||||
0x000| 02 | . | version: 2 0x3-0x3.7 (1)
|
||||
| | | flags{}: 0x4-0x4.7 (1)
|
||||
0x000| 0c | . | raw: 12 0x4-0x4.7 (1)
|
||||
|
@ -1,7 +1,7 @@
|
||||
$ fq dv -d luajit simple_stripped.luac
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: simple_stripped.luac (luajit) 0x0-0xf9.7 (250)
|
||||
| | | header{}: 0x0-0x4.7 (5)
|
||||
0x00|1b 4c 4a |.LJ | magic: "\x1bLJ" 0x0-0x2.7 (3)
|
||||
0x00|1b 4c 4a |.LJ | magic: raw bits (valid) 0x0-0x2.7 (3)
|
||||
0x00| 02 | . | version: 2 0x3-0x3.7 (1)
|
||||
| | | flags{}: 0x4-0x4.7 (1)
|
||||
0x00| 0e | . | raw: 14 0x4-0x4.7 (1)
|
||||
|
Loading…
Reference in New Issue
Block a user