delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/21/07:40:18

From: wjones AT TC DOT FLUKE DOT COM (Warren Jones)
Subject: B20: Command line args truncated
21 Nov 1998 07:40:18 -0800 :
Message-ID: <19981120165427.44249.cygnus.gnu-win32@tc.fluke.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019