cURL / Mailing Lists / curl-users / Single Mail

curl-users

--trace handling

From: David Byron <dbyron_at_dbyron.com>
Date: Mon, 19 Jan 2004 13:08:31 -0800

I see a couple of problems with the way --trace is currently handled.
I'm working with this version of curl and have a pretty fresh (couple of
hours) cvs checkout.

$ ./curl --version
curl 7.11.0-CVS (i686-pc-cygwin) libcurl/7.11.0-CVS zlib/1.1.4
Protocols: ftp gopher telnet dict ldap http file
Features: libz Debug

1. If you specify --trace <filename> where filename is such that fopen
fails, the call to fclose on main.c(1.224), line 3377 causes problems
(i. e. crashes). The fix here is simple, add && config->trace_stream to
the conditional on line 3366. An easy way for me to see the problem is
to do this:

$ mkdir blah
$ ./curl --trace blah www.google.com

2. If you specify a curl config file like this:

$ ./curl -K foo www.google.com

where foo contains

--trace

doesn't benefit from the required argument checking in getparameter
because param on line 2125 (again of main.c(1.224)) is "" and not NULL.
The symptom of this is that curl runs anyway and dumps the trace info to
stderr (or wherever it's redirected). Without the fix in #1 above, it
also runs into the same problem there and crashes.

I think I fixed this by getting param to be NULL instead of "" when
calling getparameter on line 2125 of main.c. This has the side effect
of also catching things like --user-agent without an agent string in the
config file.

The patch is attached. I'm concerned that the behavior when specifying
--trace without the required argument on the command line is different
than when you do that in a config file. On the command line, curl
doesn't download anything and returns exit code 2. In the config file,
curl prints a warning and continues on its way. My reflex is to make
the behavior the same both ways but I thought I'd take this one step at
a time.

Let me know what you think. My testsuite results are as follows with
this patch:

$ ./runtests.pl
********* System characteristics ********
* curl 7.11.0-CVS (i686-pc-cygwin)
* libcurl/7.11.0-CVS zlib/1.1.4
* Host: LLEVAR
* System: CYGWIN_NT-5.1 LLEVAR 1.5.6(0.108/3/2) 2004-01-19 00:43 i686
unknown un
known Cygwin
* Server SSL: OFF
* libcurl SSL: OFF
* libcurl debug: ON
* valgrind: OFF
*****************************************

<stuff cut>

TESTDONE: 148 tests out of 148 reported OK: 100%
TESTDONE: 170 tests were considered.
TESTINFO: 22 tests were skipped due to these restraints:
TESTINFO: "no HTTPS server" 7 times (300, 301, 302, 303, 304, 305, 306)
TESTINFO: "curl lacks SSL support" 11 times (67, 68, 69, 70, 81, 89, 90,
91, 94,
 96, 509)
TESTINFO: "no FTPS server" 4 times (400, 401, 402, 403)

Thanks much.

-DB

-- 
David Byron               dbyron_at_dbyron.com
498 Jean Street           voice:(510)452-1475
Oakland, CA 94610

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn

Received on 2004-01-19