Summary

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

Metadata

Attachments

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.

Changes and comments

[2016-01-12 13:24:05 UTC] ckeen attached stty-should-not-segfault.patch (description=#f)

[2016-01-14 16:03:17 UTC] ashinn changed status from new to closed

[2016-01-14 16:03:17 UTC] ashinn set resolution to fixed