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.
A revision of the patch, using an "eatspace" flag to get rid of STRIP() macro.
File Added: liulk-breakdown.1.patch
Fixes [PseudoTerminal breakDown] buffer overrun (rev 2)
A small improvement, to recognize both single and double quoted strings.
File Added: liulk-breakdown.2.patch
Thanks for the patch, I'll try to check this out soon.