Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f11750d026d4684bcf0cb6e71cc47fa068cbe621
Ticket: 2000586fffffffffffffffffffffffffffffffff
Dangerous reuse of channel names in unix
User & Date: ferrieux on 2008-06-23 08:48:18
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The string representation of channels in unix is too directly linked to the file descriptor, which is reused over time. This means that a given channel may be closed, then another one be created later with the same one, and the original channel become usable again, pointing to the wrong file. Demo:
    
      % set f [open /dev/null r]
      file3
      % set g [open /dev/null r]
      file4
      % close $f
      % set h [open /etc/issue.net r]
      file3
      % gets $f line
      30
    
    In Windows this does not occur because channel names use handles, and the system seems to never reuse handles (is it guaranteed ?).
    
    I think this bug can be solved in a platform-independent and more robust manner (imagine Windows starts reusing handles...), by using our own OS-independent naming system. It could be as simple as incrementing a per-interp uniqueID. No need to keep a compact range of values, since lookup-by-name is only rarely done (and already with a hashtable) thanks to the addition of tclChannelType.
    
    For those wary of the 32-bit wrapping, a Wide could be considered ;-)
    
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "ferrieux"
  10. subsystem changed to: "25. Channel System"
  11. title changed to: "Dangerous reuse of channel names in unix"
  12. type changed to: "Bug"