提交 9a8fb30c 编写于 作者: N Nigel Tao

freetype: remove arbitrary 1<<24 limit on ttf file size.

I'm not sure why I put that limit in in the first place. I can't find
that limit in either the C Freetype code or the TTF spec.

R=bradfitz
CC=golang-dev
http://codereview.appspot.com/6201043
上级 f1ba1695
......@@ -80,14 +80,18 @@ func (d *data) skip(n int) {
func readTable(ttf []byte, offsetLength []byte) ([]byte, error) {
d := data(offsetLength)
offset := int(d.u32())
if offset < 0 || offset > 1<<24 || offset > len(ttf) {
return nil, FormatError(fmt.Sprintf("offset too large: %d", offset))
if offset < 0 {
return nil, FormatError(fmt.Sprintf("offset too large: %d", uint32(offset)))
}
length := int(d.u32())
if length < 0 || length > 1<<24 || offset+length > len(ttf) {
return nil, FormatError(fmt.Sprintf("length too large: %d", length))
if length < 0 {
return nil, FormatError(fmt.Sprintf("length too large: %d", uint32(length)))
}
return ttf[offset : offset+length], nil
end := offset + length
if end < 0 || end > len(ttf) {
return nil, FormatError(fmt.Sprintf("offset + length too large: %d", uint32(offset)+uint32(length)))
}
return ttf[offset:end], nil
}
const (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册