golang/image Documentation

repository·master·Indexed 19 days ago

https://github.com/golang/image

Supplementary Go image packages that extend the functionality of the standard library image package.

Tokens
167
Snippets
0
Records
1
Agent score
19%

What's inside golang/image

  1. Prevent resource exhaustion when decoding images

    master

    When processing arbitrary or untrusted images, you should follow a two-step decoding process to prevent resource exhaustion (e.g., memory exhaustion from extremely large images).

    1. Call DecodeConfig first to retrieve the image header, which contains the dimensions (width and height).
    2. Inspect the dimensions returned in the header.
    3. Only call Decode if the dimensions are within safe limits for your application's available resources.

    Note that calling Decode on an image that results in an extremely large allocation is not considered a security vulnerability of the package itself; the responsibility for resource management lies with the consumer.