Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/image/font/sfnt: fails to parse legacy TrueType font #28339

Closed
dennwc opened this issue Oct 23, 2018 · 3 comments
Closed

x/image/font/sfnt: fails to parse legacy TrueType font #28339

dennwc opened this issue Oct 23, 2018 · 3 comments

Comments

@dennwc
Copy link
Contributor

dennwc commented Oct 23, 2018

What did you do?

Parse the FreeSans.ttf file:

data, _ := ioutil.ReadFile("FreeSans.ttf")
_, err := sfnt.Parse(data)
if err != nil {
	panic(err)
}

What did you expect to see?

no error

What did you see instead?

panic: sfnt: invalid OS/2 table

Details

The code check the size of the OS/2 header without asserting a version. The file that triggers an issue has a version = 1, which has a header size of 86 bytes instead of minimal 96 bytes required by the library.

See https://docs.microsoft.com/da-dk/typography/opentype/spec/os2 for more details.

@gopherbot gopherbot added this to the Unreleased milestone Oct 23, 2018
@dgryski
Copy link
Contributor

dgryski commented Oct 24, 2018

/cc @nigeltao

@gopherbot
Copy link

Change https://golang.org/cl/144079 mentions this issue: font/sfnt: support parsing legacy fonts with OS2 table version <= 1

@gopherbot
Copy link

Change https://golang.org/cl/146081 mentions this issue: font/sfnt: add parsing tests

@golang golang locked and limited conversation to collaborators Oct 30, 2019
mrhyperbit23z0d added a commit to mrhyperbit23z0d/bhegde8 that referenced this issue Jun 6, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
GalaxyForcew added a commit to GalaxyForcew/A1bisshy that referenced this issue Jun 6, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
yi-ge3 added a commit to yi-ge3/wislie that referenced this issue Jun 6, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
balloontmz6 added a commit to balloontmz6/Likewise42l that referenced this issue Jun 6, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
snapbakkhfbav added a commit to snapbakkhfbav/SayedBaladohr that referenced this issue Oct 6, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
MiderWong5ddop added a commit to MiderWong5ddop/sidie88f that referenced this issue Oct 7, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
rorypeckwnt4v added a commit to rorypeckwnt4v/LearnByBhanuPrataph that referenced this issue Oct 7, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
egorovcharenko9 added a commit to egorovcharenko9/RiceBIOC470z that referenced this issue Oct 7, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
RafayGhafoorf added a commit to RafayGhafoorf/dustinsand8 that referenced this issue Oct 7, 2022
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.

This CL adds a version test and handles the legacy header.

Fixes golang/go#28339

Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants