Skip to content

Conversation

@cederom
Copy link
Contributor

@cederom cederom commented Mar 17, 2025

Summary

Changing readingbitmap from bool to int, initializing it to the number of bitmaps allocated, decrementing it each time a bitmap is consumed, and using it as the termination condition for the while loop, ensures that loop termination does not depend on data from the file.

Note: Patch provided by @hartmannathan.

Impact

Fix user controllable chunk allocation condition when crafted input file is provided.

Testing

% uname -a
FreeBSD octagon 14.2-RELEASE-p1 FreeBSD 14.2-RELEASE-p1 GENERIC amd64
% cd tools
% gcc -o bdf-converter bdf-converter.c
% ./bdf-converter invalid.tff
Generated "nxfonts_myfont.h"
% cat nxfonts_myfont.h
%

Changing readingbitmap from bool to int, initializing it to the number
of bitmaps allocated, decrementing it each time a bitmap is consumed,
and using it as the termination condition for the while loop,
ensures that loop termination does not depend on data from the file.

Note: Patch provided by Nathan Hartman.

Signed-off-by: Tomasz 'CeDeROM' CEDRO <[email protected]>
@github-actions github-actions bot added Area: Tooling Size: S The size of the change in this PR is small labels Mar 17, 2025
@nuttxpr
Copy link

nuttxpr commented Mar 17, 2025

[Experimental Bot, please feedback here]

No. The PR is missing several key pieces of information required by the NuttX guidelines.

Specifically:

  • Summary: While it explains the how, it lacks the why. What is the actual problem being solved? (e.g., "Fixes a vulnerability that allows a malicious TTF file to cause an infinite loop in the bdf-converter tool."). It also doesn't specify which functional part of the code is changed (e.g., tools/bdf-converter.c).
  • Impact: While it mentions a user impact, it needs to explicitly answer all the YES/NO questions, even if the answer is NO. It's particularly important to address security impact given this appears to be a security fix. The description of the fix also needs expanding - what kind of user-controllable chunk allocation? How could this be exploited?
  • Testing: The provided testing is insufficient. It shows the tool runs on one host and generates an empty header file with a crafted input. This doesn't demonstrate the fix. It needs to show:
    • The before behavior: The infinite loop or other undesired effect occurring with the bad input on a representative target.
    • The after behavior: The correct behavior with the bad input on the same target, demonstrating the fix. Ideally also show correct behavior with valid input.
    • More than one target architecture where feasible.

The provided testing log shows an empty output file (cat nxfonts_myfont.h). This might be the intended behavior with an invalid font, but it needs to be explicitly stated whether this is expected. If it is, then a test case with a valid font file is also needed to demonstrate correct code function after the change.

Copy link
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy 16K :-) #16000

@acassis acassis merged commit 3eddfe5 into apache:master Mar 18, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Tooling Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants