limit sscanf field widths when parsing AFM files (PR #26645)

14 views
Skip to first unread message

Javid Khan

unread,
Jun 29, 2026, 12:20:30 PM (3 days ago) Jun 29
to wx-...@googlegroups.com, Subscribed

wxPostScriptDCImpl::DoGetTextExtent reads an AFM font metric file into several small fixed stack buffers (cString[10], descString[20], encString[50] and so on) using sscanf with bare %s conversions. The leading strncmp checks only look at each line's prefix, so a malformed AFM line whose first token runs on past the keyword, or whose later fields are over-long, writes past the end of these buffers; this is a stack buffer overflow and ASan flags it on a crafted file. The fix caps each %s with a field width matching its buffer so over-long tokens are truncated rather than overflowing, and since the tokens in valid AFM files are all short the parsed metrics are unchanged.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26645

Commit Summary

  • e59d4e3 limit sscanf field widths when parsing AFM files

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26645@github.com>

VZ

unread,
Jun 30, 2026, 7:23:33 PM (2 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26645)

Using %s without width limit is definitely wrong, thanks for fixing this.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26645/c4848721178@github.com>

VZ

unread,
Jun 30, 2026, 7:31:22 PM (2 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed

Closed #26645 via b0e297a.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26645/issue_event/27402848288@github.com>

Reply all
Reply to author
Forward
0 new messages