summaryrefslogtreecommitdiff
path: root/src/tool_parsecfg.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-11-06 23:57:44 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-11-29 15:17:08 +0100
commit0db811b69b2d5a18f8122d94db4e520909fd992b (patch)
treedd01b3c1eed1f225f7017acef98675509b3704ad /src/tool_parsecfg.c
parentd81cbbcc2c3637ae7d5f21cbcbda93dbf0c9776e (diff)
downloadcurl-0db811b69b2d5a18f8122d94db4e520909fd992b.tar.gz
parseconfig: dash options can't specified with colon or equals
Bug: http://curl.haxx.se/bug/view.cgi?id=1297 Reported-by: Michael Osipov
Diffstat (limited to 'src/tool_parsecfg.c')
-rw-r--r--src/tool_parsecfg.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index 680688ab7..4d5145bcc 100644
--- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c
@@ -35,7 +35,10 @@
#include "memdebug.h" /* keep this as LAST include */
#define CURLRC DOT_CHAR "curlrc"
-#define ISSEP(x) (((x) == '=') || ((x) == ':'))
+
+/* only acknowledge colon or equals as separators if the option was not
+ specified with an initial dash! */
+#define ISSEP(x,dash) (!dash && (((x) == '=') || ((x) == ':')))
static const char *unslashquote(const char *line, char *param);
static char *my_get_line(FILE *fp);
@@ -123,6 +126,7 @@ int parseconfig(const char *filename,
char *param;
int lineno = 0;
bool alloced_param;
+ bool dashed_option;
while(NULL != (aline = my_get_line(file))) {
lineno++;
@@ -146,7 +150,11 @@ int parseconfig(const char *filename,
/* the option keywords starts here */
option = line;
- while(*line && !ISSPACE(*line) && !ISSEP(*line))
+
+ /* the option starts with a dash? */
+ dashed_option = option[0]=='-'?TRUE:FALSE;
+
+ while(*line && !ISSPACE(*line) && !ISSEP(*line, dashed_option))
line++;
/* ... and has ended here */
@@ -158,7 +166,7 @@ int parseconfig(const char *filename,
#endif
/* pass spaces and separator(s) */
- while(*line && (ISSPACE(*line) || ISSEP(*line)))
+ while(*line && (ISSPACE(*line) || ISSEP(*line, dashed_option)))
line++;
/* the parameter starts here (unless quoted) */