Skip to content

MimeTypeValidator.Validate never closes the file it opens #1077

Description

@priteshgupta

Validate() opens the uploaded file to sniff the content type and never closes it. For any part above the adapter’s multipart memory threshold, that handle is a real file on disk, so the descriptor and its blocks stay held until the finalizer runs. multipart.Form.RemoveAll() only unlinks the temp file; it doesn’t close anything, so a service doing a lot of uploads can drift on file descriptors and ephemeral disk with nothing obvious pointing at the cause.

A deferred close in Validate() should cover that path. readFile() also opens the file before validation and returns without closing it when validation fails, so that path should be fixed too. Still present in v2.39.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions