Skip to content

Commit

Permalink
font/plan9font: limit the font image's dimensions
Browse files Browse the repository at this point in the history
Fixes golang/go#57258

Change-Id: I0249e422470219594188d050ebd6dc42f1646dff
Reviewed-on: https://go-review.googlesource.com/c/image/+/458095
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
nigeltao committed Dec 19, 2022
1 parent c5235ae commit 9b8a3be
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions font/plan9font/plan9font.go
Expand Up @@ -465,6 +465,11 @@ func parseImage(data []byte) (remainingData []byte, m *plan9Image, retErr error)
}

width := bytesPerLine(r, depth)
// These bounds are somewhat arbitrary, but multiplying them together won't
// overflow an int32.
if (width > 0xffff) || (r.Dy() > 0x7fff) {
return nil, nil, errors.New("plan9font: unsupported dimensions")
}
m = &plan9Image{
depth: depth,
width: width,
Expand Down

0 comments on commit 9b8a3be

Please sign in to comment.