hSetNewlineMode and hSetEncoding can be performed on closed and semi-closed handles
|Reported by:||duncan||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
Description (last modified by thomie)
The hSetNewlineMode and hSetEncoding functions from GHC/IO/Handle.hs do not check that the Handle is in an open mode. It is possible to use them on closed handles. hSetEncoding on a closed Handle triggers a segfault. Similarly, the operations are also both possible on semi-closed handles, and given the way hGetContents is implemented, this will affect the result of hGetContents which is clearly against the intention of the hGetContents/semi-closed stuff.
Both functions use the withAllHandles__ helper. Unlike similar helpers like wantReadableHandle_ this one doesn't do any handle mode checking.
Additionally, hSetBuffering and hSetBinaryMode mode also use the withAllHandles__ pattern and don't obviously check for an open handle but I've not verified this.
Change History (9)
comment:3 Changed 2 years ago by thoughtpolice
- Component changed from libraries/base to Core Libraries
- Owner set to ekmett
comment:4 Changed 2 years ago by thomie
- Cc core-libraries-committee@… added
- Status changed from new to infoneeded
comment:8 Changed 10 months ago by thomie
- Cc ekmett added
- Description modified (diff)
- Status changed from infoneeded to new