Closed Bug 2051149 Opened 3 months ago Closed 3 months ago

ParseCFHTML validates startFragment twice instead of endFragment (Coverity CID 1639416)

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: Sylvestre, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

HTMLEditor::ParseCFHTML validates the parsed CF_HTML offsets, but the EndFragment check tested startFragment < 0 instead of endFragment < 0 (a copy-paste error). A CF_HTML payload with a negative EndFragment offset was therefore accepted and used to Substring() out the fragment and context, extracting the wrong (oversized) region of the clipboard buffer instead of being rejected.

nsTSubstring::Substring clamps out-of-range start/length, so this is not an out-of-bounds read -- it is a correctness/robustness defect on malformed clipboard input, not a memory-safety bug.

Coverity CID 1639416.

The EndFragment block re-checked startFragment < 0, so a negative
endFragment from malformed CF_HTML passed validation and was later used
as a Substring offset/length.

Pushed by sledru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8a8de7c1834e https://hg.mozilla.org/integration/autoland/rev/efb2aafcd7aa Validate endFragment, not startFragment, in ParseCFHTML (Coverity CID 1639416) r=masayuki
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch
QA Whiteboard: [qa-triage-done-c155/b154]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: