Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0a3c2088286fdcfc6f6eb0c7e675abb405ef87a4
Ticket: 805605ffffffffffffffffffffffffffffffffff
incorrect use of isspace in tclWinPipe.c
User & Date: ronaldd on 2003-09-13 14:02:53
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Applies to Tcl Version 8.4.4 
    
    In tclWinPipe.c, Line 1588
    if (isspace(*start)) { /* INTL: ISO space. */
    a signed char is passed to isspace.  
    
    For two reasons, this is incorrect:
    
    1. The string pointed to by 'start' is 
    suppoed to be UTF-8. It does not make 
    sense to pass the bytes of an UTF-8 
    string to isspace unless they represent 
    a single character (i. e. are in the 
    range 1 - 127)
    
    2. Passing a negative value (*start is a 
    signed char!) to isspace causes the VC6 
    and VC.NET runtime libraries to access 
    memory outside the lookup-table used by 
    the ctype.h functions.
    
    Symptoms and consequences:
    1. Access to undefined memory locations
    2. Arguments may be quoted unneccessarily 
       (because isspace returns incorrectly true)
    3. Assertion fails in Debug builds of 
       VC.NET 2003 in main.test (e. g. Main-1.3)
       "File istype.c, Line 68:
        Expression (unsigned)(c+1) <= 256"
    
    How to reproduce:
    for 1.: Assembly level debugger or code inspection 
             (ctype.h for VC6, istype.c for VC.NET 2003)
    for 2.: Code inspection
    for 3.: with VC.NET run
    nmake -f makefile.vc OPTS=threads,symbols
    nmake -f makefile.vc OPTS=threads,symbols test
    The assertion should produce four dialog boxes
    
    How to fix:
    The following changes work for VC.NET and should be
    portable across all compilers:
    --- tclWinPipe.c-orig   2003-09-13 15:46:04
    +++ tclWinPipe.c        2003-09-13 15:48:47
    @@ -1584,8 +1584,11 @@
            if (arg[0] == '\0') {
                quote = 1;
            } else {
    -           for (start = arg; *start != '\0'; start++) {
    -               if (isspace(*start)) { /* INTL: ISO
    space. */
    +           int count;
    +           for (start = arg; *start != '\0'; start +=
    count) {
    +               Tcl_UniChar ch;
    +               count = Tcl_UtfToUniChar(start, &ch);
    +               if (Tcl_UniCharIsSpace(ch)) { /* INTL:
    ISO space. */
                        quote = 1;
                        break;
                    }
    
    
  4. foundin changed to: "obsolete: 8.4.4"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "ronaldd"
  9. subsystem changed to: "None"
  10. title changed to: "incorrect use of isspace in tclWinPipe.c"
  11. type changed to: "Bug"