Opened 6 years ago

Closed 6 years ago

#1254 closed defect (fixed)

with-stty segfaults when current-input-port is not a terminal

Reported by: Christian Kellermann Owned by: Alex Shinn
Priority: major Milestone: someday
Component: unknown Version: 4.10.x
Keywords: stty segfault terminal port Cc:
Estimated difficulty:

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.

Attachments (1)

stty-should-not-segfault.patch (850 bytes) - added by Christian Kellermann 6 years ago.

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by Christian Kellermann

comment:1 Changed 6 years ago by Alex Shinn

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.