This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B20: Command line args truncated


In B20, command line arguments are truncated to 259 characters when:

    1. A Cygwin program is called from a non-Cygwin program.
    2. A command line argument is enclosed in double quotes.

I'm including a simple batch file that demonstrates the problem,
although I first observed it when the Cygwin shell (ash) was
spawned by a non-Cygwin port of gmake, and the quoted command
line was truncated (sh -c "...").

It's pretty clear that the args are getting truncated when they're
passed through the glob() function.  Several working arrays in glob()
are defined using MAXPATHLEN, which just happens to equal 259.
I'm not so clear on the best solution.  A simple-minded approach
would be to replace MAXPATHLEN with some larger number, or maybe
dynamically size the arrays based on the length of the incoming
pattern.

Perhaps someone who's more familiar with this code will have a
better idea.  It might also help to know what has changed since
B19 (which doesn't have this problem).  According to the ChangeLog,
it looks like the changes were probably in dcrt0.cc, where glob()
is called.

--
Warren Jones

----------------------------- demo.bat -----------------------------
@echo off

rem Make a string 500 characters long:
set A=12345678901234567890123456789012345678901234567890
set B=%A%%A%%A%%A%%A%%A%%A%%A%%A%%A%

set CYGROOT=C:\cygnus\b20
set bin=%CYGROOT%\H-i586-cygwin32\bin
set PATH=%bin%;%PATH%
set   sh=%bin%\sh.exe
set echo=%bin%\echo

%echo% -n "Unquoted arg OK ...          "
%echo% -n %B%   | wc -c

%echo% -n "Quoted arg is truncated ...  "
%echo% -n "%B%" | wc -c

%echo% -n "Two args, each truncated ... "
%echo% -n "%B%" "%B%" | wc -c

%echo% -n "Quoted arg is truncated ...  "
%sh% -c "echo -n %B%" | wc -c

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]