WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
302313
PrintStream should truncate extremely long strings when printing.
https://bugs.webkit.org/show_bug.cgi?id=302313
Summary
PrintStream should truncate extremely long strings when printing.
Mark Lam
Reported
2025-11-10 22:07:43 PST
Under the hood, PrintStream uses vnsprintf() to print a string. However, vnsprintf() refuses to print any string that is INT_MAX (or more) in length. Realistically, we would never need to print an INT_MAX length string anyway. However, this appears to be tripping up fuzzers. So, let's just add a quality of life improvement to truncate that strings being printed if it is extremely long. For this patch, we'll add a check to see if the string is greater than 1000000 characters long. If so, only print the first 1000 followed by a footer that says something like "...[<N> characters not shown]" where N is the number of characters we truncated. This truncation is only done when PrintStream is used to print a CString, for which we can cheaply do a length check. We could apply the same logic to a const char* string, but that would require a strlen() computation, which has some performance cost. At this time, we're opting to not do that. Since this is just a best effort quality of life improvement, and not a critical bug fix, this tradeoff choice is fine.
rdar://158662656
Attachments
Add attachment
proposed patch, testcase, etc.
Mark Lam
Comment 1
2025-11-10 22:16:45 PST
Pull request:
https://github.com/WebKit/WebKit/pull/53726
EWS
Comment 2
2025-11-11 10:03:59 PST
Committed
302853@main
(293b864bb85a): <
https://commits.webkit.org/302853@main
> Reviewed commits have been landed. Closing PR #53726 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug