Expand description
Locating the best image inside an .ico blob (#577).
§This parses untrusted input
An icon supplied as bytes may be anything — a truncated download, a file that is not an icon at all, or something crafted. Every field that becomes an offset or a length is therefore checked against the actual buffer before use, and a blob that does not describe a valid image is refused rather than passed to the OS with a length the OS will trust.
Handing CreateIconFromResourceEx an offset past the end of the buffer
would have it read whatever follows in our address space.
§Why we choose the image rather than the OS
LoadImage picks from a file on disk; there is no equivalent that takes a
whole .ico from memory. CreateIconFromResourceEx wants the bytes of one
image, so the directory has to be walked to find which.
Structs§
- Image
Span - The byte range of the chosen image within the blob.
Enums§
- IcoError
- Why an icon blob could not be used.
Functions§
- best_
image - Find the largest image in an
.icoblob.