Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6089758f12b96ae60b829d9d15046a758ac656c5d190bef3f730a902a784f27b
Ticket: 43b434812a6e79e3c5a2e394d57fda75a47af2b6
Tcl 9.0 uses stat64() but not struct stat64 on Linux i686
User & Date: chrstphrchvz on 2020-08-21 09:28:27
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Using Ubuntu 18.04 i686 (32 bit Intel), Tcl 9.0 ([c1e3046f2f]) appears to configure with <tt>TclOSstat()</tt> defined as <tt>stat64()</tt>, but also with <tt>Tcl_StatBuf</tt> defined to <tt>struct stat</tt> rather than <tt>struct stat64</tt>. Since <tt>struct stat64</tt> is larger (96 bytes rather than 88), calling <tt>stat64()</tt> with a pointer to <tt>struct stat</tt> will write to memory outside of the <tt>struct stat</tt>. (The <tt>struct stat</tt> is likely also invalid after doing so.)
    
    I notice this because I can't even start tclsh9.0 without it crashing in <tt>TclpMatchInDirectory()</tt> (tclUnixFile.c): calling <tt>TclOSstat()</tt> (<tt>stat64()</tt>) at line 312 clobbers the address stored in <tt>ds.string</tt>, and when <tt>Tcl_DStringSetLength()</tt> is called at line 380, it writes to an invalid address when doing <tt>dsPtr-&gt;string&#91;length&#93; = 0</tt> (tclUtil.c line 2808).
    
    I don't observe this issue in Tcl 8.7 ([95051c8d1e]) where <tt>TclOSstat()</tt> and <tt>Tcl_StatBuf</tt> are defined as <tt>stat64()</tt> and <tt>struct stat64</tt> respectively.
    
  5. foundin changed to: "9.0"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "chrstphrchvz"
  13. subsystem changed to: "37. File System"
  14. title changed to:
    Tcl 9.0 uses stat64() but not struct stat64 on Linux i686
    
  15. type changed to: "Bug"