mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #496] Heap oob read in lxw_styles_write_string_fragment on empty style string #386
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#386
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 @hgarrereyn on GitHub (Dec 18, 2025).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/496
Hi, there is a potential bug in
lxw_styles_write_string_fragmentreachable when invoked with an empty string.This bug was reproduced on
f0647157ba.Description
What crashes and where:
if (isspace((unsigned char)string[0]) || isspace((unsigned char)string[strlen(string) - 1]))
Suggested fix in the library:
size_t len = strlen(string);
if (len > 0 && (isspace((unsigned char)string[0]) || isspace((unsigned char)string[len - 1]))) {
LXW_PUSH_ATTRIBUTES_STR("xml:space", "preserve");
}
POC
The following testcase demonstrates the bug:
testcase.cpp
stdout
stderr
Steps to Reproduce
The crash was triaged with the following Dockerfile:
Dockerfile
Build Command
Reproduce
Dockerfileandtestcase.cppinto a local folder.Additional Info
This testcase was discovered by
STITCH, an autonomous fuzzing system. All reports are reviewed manually (by a human) before submission.@jmcnamara commented on GitHub (Dec 18, 2025):
A couple of things:
lxw_styles_write_string_fragmentisn't an API that a user would call. It is an internal function and only "public" because of C's limited function privacy rules.lxw_styles_write_string_fragmentis called there is a check for empty strings before the function is called.Closing.