Summary
with-stty segfaults when current-input-port is not a terminal
Metadata
- Id: 3a28cea1e0e2e45c04f13a91005039e3e9d34ce1
- Trac id: 1254
- Type: defect
- Reporter: ckeen
- Owner: ashinn
- Cc:
- Status: closed
- Component: unknown
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: someday
- Version: 4.10.x
- Changetime: 2016-01-14 16:03:17 UTC
- Created: 2016-01-12 13:23:49 UTC
- Keywords: stty segfault terminal port
Attachments
- 3a28cea1e0e2e45c04f13a91005039e3e9d34ce1/attachments/stty-should-not-segfault.patch
Description
stty segfaults when the current-input-port is not a terminal.
Example:
(use stty)
(with-stty (not 'echo)
(print (read-line)))
This results in:
echo foo |./t
foo
Error: segmentation violation
Call history:
t.scm:4: print
t.scm:3: stty#with-stty
stty.scm:440: get-terminal-attributes
stty.scm:195: make-term-attrs
stty.scm:196: port?
stty.scm:196: port->fileno
stty.scm:200: free-term-attrs
stty.scm:441: dynamic-wind
stty.scm:443: stty
stty.scm:373: port?
stty.scm:376: get-terminal-attributes
stty.scm:195: make-term-attrs
stty.scm:196: port?
stty.scm:196: port->fileno
stty.scm:200: free-term-attrs
stty.scm:377: term-attrs-iflag <--
A patch is attached, where stty does nothing if get-terminal-attributes fails at the beginning and with-stty does only execute its thunk.
Maybe raising an explicit error is a better way to handle this than silently ignoring the issue.