Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7d4686cfab956d6f82e9637cb4b84ede39891fff46328ff39a1a845bf7d86ba0
Ticket: fb368527aeed240f2b345be96119ea66e1fce6fb
String truncation in encoding > 2GB length
User & Date: apnadkarni on 2023-02-26 16:51:09
Changes

  1. icomment:
    Jan,
    
    That tclZlib.c example you linked is pretty easy to fix, isn't it? Unless I'm missing something, not enough to convince me I'm afraid!
    
    The use of `TCL_CONVERT_SPACE` (it was also my first thought) does not help because it does not distinguish between the caller not giving a large enough buffer versus the function `Tcl_ExternalToUtf`  not being able to handle source lengths that large.
    
    Consider being called with srcLen=2GB+1 and dstLen=4GB. The function will return `TCL_CONVERT_NOSPACE` and the natural thing is for the caller to double it's output buffer! It takes some thinking and additional logic on the part of the programmer (and I guarantee they will not even realize this until they actually hit a bug)  to distinguish between the real destination buffer too small case and the source data greater than function limits. Not a good API design imo.
    
    So I still think those functions need to change. The DString variants can continue to take Tcl_Size arguments since there is no confusion there with output parameters. They will need to adapt to loop calling the lower level routines which they do now anyway.
    
    /Ashok
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"