Fix out-of-bounds read in vCard QUOTED-PRINTABLE soft-line-break handling - #10270
Open
MiMoHo wants to merge 1 commit into
Open
Fix out-of-bounds read in vCard QUOTED-PRINTABLE soft-line-break handling#10270MiMoHo wants to merge 1 commit into
MiMoHo wants to merge 1 commit into
Conversation
MiMoHo
force-pushed
the
held-vcard-qp-oob
branch
from
July 16, 2026 08:14
7edf066 to
b10ad36
Compare
…ling Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MiMoHo
force-pushed
the
held-vcard-qp-oob
branch
from
July 16, 2026 11:53
b10ad36 to
d12dd87
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Parsing a vCard whose final line uses a QUOTED-PRINTABLE soft line break (a line ending with
=) triggers PHP "Undefined array key" warnings and a downstreampreg_match(): Passing nulldeprecation. Under the test suite'sfailOnWarning/failOnNoticesettings this is an outright failure; in production it emits warnings on untrusted input.Root cause
program/lib/Roundcube/rcube_vcard.phphas two QUOTED-PRINTABLE continuation loops that append the next line while the current line ends with=:vcard_decode()at line 758detect_encoding()at line 1052Both were written as
while (preg_match('/=$/', $lines[$i])) { $data .= "\n" . $lines[++$i]; }. When the last element of$linesends with=,$lines[++$i]reads past the end of the array. The loop also re-checks$lines[$i](now unset) on the next iteration, producing repeated warnings and passingnulltopreg_match.Fix
Bound both loops so they never advance past the last element:
This keeps the existing best-effort decode behaviour (a dangling
=on the last line is simply left as the end of the value) while eliminating the out-of-bounds access. The same guard is applied in bothvcard_decode()anddetect_encoding().Testing
Added
test_parse_qp_soft_break_on_last_lineintests/Framework/VCardTest.php, which decodes a vCard whose final QUOTED-PRINTABLE line ends with=, asserts no PHP warnings/errors are raised (via a temporary error handler), and checks the best-effort decoded value. The test fails on unmodified code (three PHP diagnostics) and passes with the fix. The fullVCardTestfile (15 tests, 40 assertions) passes, and phpstan level 4 reports no errors on the changed file.