Skip to content

Commit

Permalink
fix: check wry size before read header
Browse files Browse the repository at this point in the history
  • Loading branch information
zu1k committed Oct 20, 2022
1 parent 2da7512 commit fc9df8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/qqwry/qqwry.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func NewQQwry(filePath string) (*QQwry, error) {
}
}

if len(fileData) < 8 {
log.Fatalln("纯真 IP 库存在错误,请重新下载")
}

header := fileData[0:8]
start := binary.LittleEndian.Uint32(header[:4])
end := binary.LittleEndian.Uint32(header[4:])
Expand Down
4 changes: 4 additions & 0 deletions pkg/zxipv6wry/zxipv6wry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func NewZXwry(filePath string) (*ZXwry, error) {
}
}

if len(fileData) < 24 {
log.Fatalln("ZX IPv6数据库存在错误,请重新下载")
}

header := fileData[:24]
offLen := header[6]
ipLen := header[7]
Expand Down

0 comments on commit fc9df8d

Please sign in to comment.