mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #490] Infinite Loop in workbook_close() with Invalid Chart Scale Parameters #382
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#382
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LkkkLxy on GitHub (Oct 11, 2025).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/490
Originally assigned to: @jmcnamara on GitHub.
Description
An infinite loop vulnerability exists in libxlsxwriter that causes the program to hang indefinitely when
workbook_close()is called after inserting a chart with infinite or extremely large scale values inlxw_chart_options.Steps to Reproduce
Environment
Compilation Command
Minimal Test Case
Expected Behavior
The library should either:
x_scaleandy_scaleparameters and return an error for invalid values (INFINITY, NAN, negative values)Actual Behavior
The program hangs indefinitely in
workbook_close()and must be forcefully terminated.Verification
Root Cause
The infinite loop occurs in
src/worksheet.c:3010in the_worksheet_position_object_pixels()function:When
chart_opts.x_scaleis set toINFINITY:widthbecomesINFINITYwidth >= _worksheet_size_col(...)is always trueINFINITY - finite_value = INFINITYCall Stack
Additional Information
This bug is detected by fuzzing.
@jmcnamara commented on GitHub (Oct 13, 2025):
I think this is a user error. If the user enters INFINITY then they are getting what they ask for.
I will look into a fix anyway.
@jmcnamara commented on GitHub (Oct 30, 2025):
Fixed on main. Thanks for the report.
@kruftindustries commented on GitHub (Jan 16, 2026):
This is bad timing but I studied this issue and found excel calculates the percent based on a maximum width and height, not sure if it's different on other machines or if there are settings that can affect the value.
#define LXW_OBJECT_MAX_SIZE_PIXELS 225408.0 /* Excel max: 2348 inches * 96 DPI */
#define LXW_OBJECT_MIN_SCALE 0.01 /
@jmcnamara commented on GitHub (Jan 16, 2026):
@kruftindustries That looks like a bug but it is different from this one. Could you open a new bug report for it. Thanks.