cURL / Mailing Lists / curl-library / Single Mail

curl-library

curlrc parsing

From: Gisle Vanem <gvanem_at_broadpark.no>
Date: Thu, 22 Jan 2004 16:35:34 +0100

With the MSVC compiled curl and DEBUG_CONFIG I got this:
  GOT: --netrc-optional
  PARAM: ".6"
  ...\_curlrc:4: warning: '--netrc-optional' had unsupported trailing garbage

when _curlrc does *not* end in a newline. I can't see why, but this
code in parseconfig() (at line 2070):
      /* pass spaces and separator(s) */
      while(isspace((int)*line) || isseparator(*line))
        line++;

is reading past the 0-termination of 'aline'. Patch follows:

--- CVS-latest/src/main.c Thu Jan 22 13:46:07 2004
+++ src/main.c Thu Jan 22 16:32:53 2004
@@ -2039,6 +2039,7 @@
       lineno++;
       line = aline;
       alloced_param=FALSE;
+ param = NULL;

       /* lines with # in the fist column is a comment! */
       while(isspace((int)*line))
@@ -2061,11 +2062,12 @@
         line++;
       /* ... and has ended here */

- *line++=0; /* zero terminate, we have a local copy of the data */
-
 #ifdef DEBUG_CONFIG
       fprintf(stderr, "GOT: %s\n", option);
 #endif
+ if (!*line)
+ goto no_param;
+ *line++=0; /* zero terminate, we have a local copy of the data */

       /* pass spaces and separator(s) */
       while(isspace((int)*line) || isseparator(*line))
@@ -2125,6 +2127,7 @@
           free(param);
         param = NULL;
       }
+no_param:

 #ifdef DEBUG_CONFIG
       fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));

---------

--gv

-------------------------------------------------------
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-22