Skip to content

mergefonts can crash with an all whitespace value#1806

Closed
caolanm wants to merge 1 commit intoadobe-type-tools:developfrom
caolanm:develop
Closed

mergefonts can crash with an all whitespace value#1806
caolanm wants to merge 1 commit intoadobe-type-tools:developfrom
caolanm:develop

Conversation

@caolanm
Copy link
Copy Markdown

@caolanm caolanm commented Oct 10, 2025

echo | mergefonts -cid tests/mergefonts_data/input/cidwhitespace/cidfontinfo.txt Segmentation fault (core dumped)

As a minimal fix if the start/end searchs are swapped so that the search for the end of whitespace is done before searching for the start then the new null terminator set by the end search will stop the start search going past the buffer end.

Description

Replace this text with a description of your changes, indicating whether
it is a bug fix, enhancement, etc. and which general area(s) are affected
(documentation, specific tool, group of tools, tests, etc.).

If the contribution closes (fixes, resolves) a specific open
issue, please link
the issue
.

Checklist:

  • I have followed the Contribution Guidelines
  • I have added test code and data to prove that my code functions correctly
  • I have verified that new and existing tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

echo | mergefonts -cid tests/mergefonts_data/input/cidwhitespace/cidfontinfo.txt
Segmentation fault (core dumped)

As a minimal fix if the start/end searchs are swapped so that the search
for the end of whitespace is done before searching for the start then
the new null terminator set by the end search will stop the start search
going past the buffer end.
@skef
Copy link
Copy Markdown
Collaborator

skef commented Feb 12, 2026

This fix is being merged into the addfeatures branch .

@skef skef closed this Feb 12, 2026
skef pushed a commit that referenced this pull request Feb 12, 2026
Fixes crash when processing input containing only whitespace characters
in font metadata fields. The bug caused a segmentation fault due to
buffer overrun in the stringStrip() function.

The fix reorders the whitespace trimming operations: the end-of-string
search and null terminator placement now happens before the start-of-string
search. This prevents the start search from reading past the buffer end
when the entire string consists of whitespace.

Test case added to verify the fix prevents SIGSEGV on inputs like:
  FontName	(  )

Based on PR #1806 by Caolán McNamara (@caolanm)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants