aboutsummaryrefslogtreecommitdiff
path: root/src/config_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/config_parser.c')
-rw-r--r--src/config_parser.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/config_parser.c b/src/config_parser.c
index 354ed35c..2f91d39f 100644
--- a/src/config_parser.c
+++ b/src/config_parser.c
@@ -76,7 +76,8 @@ out:
char *ssh_config_get_token(char **str)
{
register char *c;
- char *r;
+ bool had_equal = false;
+ char *r = NULL;
/* Ignore leading spaces */
for (c = *str; *c; c++) {
@@ -88,24 +89,36 @@ char *ssh_config_get_token(char **str)
/* If we start with quote, return the whole quoted block */
if (*c == '\"') {
for (r = ++c; *c; c++) {
- if (*c == '\"') {
+ if (*c == '\"' || *c == '\n') {
*c = '\0';
+ c++;
+ break;
+ }
+ /* XXX Unmatched quotes extend to the end of line */
+ }
+ } else {
+ /* Otherwise terminate on space, equal or newline */
+ for (r = c; *c; c++) {
+ if (*c == '\0') {
goto out;
+ } else if (isblank(*c) || *c == '=' || *c == '\n') {
+ had_equal = (*c == '=');
+ *c = '\0';
+ c++;
+ break;
}
}
}
- /* Otherwise terminate on space, equal or newline */
- for (r = c; *c; c++) {
- if (isblank(*c) || *c == '=' || *c == '\n') {
- *c = '\0';
- goto out;
+ /* Skip any other remaining whitespace */
+ while (isblank(*c) || *c == '\n' || (!had_equal && *c == '=')) {
+ if (*c == '=') {
+ had_equal = true;
}
+ c++;
}
-
out:
- *str = c + 1;
-
+ *str = c;
return r;
}