fix(cliprdr): accept CF_DIB with BITFIELDS compression and standard masks - #1940
Draft
Marynych Oleksandr (maryny4) wants to merge 1 commit into
Draft
fix(cliprdr): accept CF_DIB with BITFIELDS compression and standard masks#1940Marynych Oleksandr (maryny4) wants to merge 1 commit into
Marynych Oleksandr (maryny4) wants to merge 1 commit into
Conversation
…asks Windows commonly places 32bpp `CF_DIB` on the clipboard with `BI_BITFIELDS` compression and the standard BGRA color masks. The `CF_DIBV5` path already accepts that and validates the masks, but the `CF_DIB` path rejected every compression other than `BI_RGB`, so `dib_to_png` failed and consumers such as `ironrdp-web` and `ironrdp-daemon` dropped the image; a downstream project has to rewrite the header to `BI_RGB` to paste it at all. With the standard masks the pixels are laid out exactly as with `BI_RGB`, so once the masks are validated they decode the same way. Move the mask validation shared with `BITMAPV5HEADER` into one helper, read the three masks that follow a `BITFIELDS` `BITMAPINFOHEADER` (the V1 layout has no alpha mask) and account for them in the logical length reported by `validate_dib`. Non-standard mask orders stay rejected on both paths.
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.
Windows commonly puts 32bpp
CF_DIBon the clipboard withBI_BITFIELDScompression and the standard BGRA color masks. TheCF_DIBV5path already accepts that and validates the masks, but theCF_DIBpath rejected every compression other thanBI_RGB, sodib_to_pngfailed and consumers such asironrdp-webandironrdp-daemondropped the image; a downstream project has to rewrite the header toBI_RGBto paste it at all.With the standard masks the pixels are laid out exactly as with
BI_RGB, so once the masks are validated they decode the same way. This moves the mask validation shared withBITMAPV5HEADERinto one helper, reads the three masks that follow aBITFIELDSBITMAPINFOHEADER(the V1 layout carries no alpha mask) and accounts for them in the logical length reported byvalidate_dib. Non-standard mask orders stay rejected on both paths, as before.Tests build the
BITFIELDSvariants from the existingcf_dib.pduandcf_dibv5.pdufixtures. A V1BITFIELDSDIB with standard masks decodes to a PNG byte-identical to theBI_RGBfixture andvalidate_dibreports the full length including the masks; a non-standard mask order is refused; masks cut off mid-header are a decode error rather than a panic; and the V5 path keeps its previous behavior through the shared helper.