Skip to content

FileResponse has undefined behavior if the file is changed out from under it between the stat and open calls #8013

@bdraco

Description

@bdraco

This was discovered while fixing another issue in #8012 (comment)

This is a rare case so its not likely we need to prioritize fixing it but I'm sure this race has bitten someone with random unexplained failures who uses aiohttp to serve index or signature files that get changed out frequently.

Describe the bug

We can fix this by opening the file first, doing fstat to get the stat

To Reproduce

replace the file on the FS between the stat and open call

Expected behavior

The handler should still send the original file

Logs/tracebacks

n/a

Python Version

$ python --version

aiohttp Version

$ python -m pip show aiohttp

multidict Version

$ python -m pip show multidict

yarl Version

$ python -m pip show yarl

OS

n/a

Related component

Server

Additional context

n/a

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions