Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 701f028ce7de0173e4f5a8b1d821fa9208efc6c47b8f38cf946e8e4c988b645b
Ticket: 0061c7a476f141128775d7982dc807f0ecf00d6a
signed integer overflow in ZipReadInt()
User & Date: chrstphrchvz on 2022-04-16 16:40:27
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    UBSan (<tt>-fsanitize=shift-base</tt>) error:
    <blockquote><pre>
    <span style="font-weight:bold">tcl/generic/tclZipfs.c:470:55: <span style="color:crimson">runtime error:</span> left shift of 252 by 24 places cannot be represented in type 'int'</span>
    </pre></blockquote>
    
    Avoid by casting to <tt>unsigned int</tt> before shifting:
    <blockquote><pre>
    --- generic/tclZipfs.c.orig
    +++ generic/tclZipfs.c
    @@ -467,7 +467,8 @@ ZipReadInt(
            Tcl_Panic("out of bounds read(4): start=%p, end=%p, ptr=%p",
                    bufferStart, bufferEnd, ptr);
         }
    <span style="color:crimson">-    return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);</span>
    <span style="color:green">+    return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) |
    +           ((unsigned int)ptr[3] << 24);</span>
     }
     
     static inline unsigned short
    </pre></blockquote>
    
  5. foundin changed to: "core-8-branch"
  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: "signed integer overflow in ZipReadInt()"
  15. type changed to: "Patch"