Menu

#34 [PseudoTerminal breakDown] tmp buffer overrun

open
None
5
2009-10-01
2009-01-10
Likai Liu
No

In the instance method [PseudoTerminal breakDown] of PseudoTerminal.m, tmp can be easily overflown if the command line contains a long token, causing a crash.

I rewrote the method so that:

1. I increased the capacity of tmp slightly (I tested the capacity as small as 4 to make sure the code works properly).
2. tmp overflows to an NSMutableString, which is used to assemble each token.
3. Uses isspace(c) macro in ctype.h to detect white spaces.
4. Properly strip white spaces in the beginning of the command line (white spaces at the end of the command line is still ignored, like before).
5. Quotes can be escaped, so as unquoted spaces.

Patch is attached below.

Discussion

  • Likai Liu

    Likai Liu - 2009-01-11

    A revision of the patch, using an "eatspace" flag to get rid of STRIP() macro.
    File Added: liulk-breakdown.1.patch

     
  • Likai Liu

    Likai Liu - 2009-01-31

    Fixes [PseudoTerminal breakDown] buffer overrun (rev 2)

     
  • Likai Liu

    Likai Liu - 2009-01-31

    A small improvement, to recognize both single and double quoted strings.
    File Added: liulk-breakdown.2.patch

     
  • James Bunton

    James Bunton - 2009-02-07
    • assigned_to: nobody --> delx
     
  • James Bunton

    James Bunton - 2009-06-09
    • priority: 5 --> 6
     
  • James Bunton

    James Bunton - 2009-09-16

    Thanks for the patch, I'll try to check this out soon.

     
  • James Bunton

    James Bunton - 2009-09-16
    • milestone: --> 257198
     
  • James Bunton

    James Bunton - 2009-10-01
    • milestone: 257198 -->
    • priority: 6 --> 5
     

Log in to post a comment.