diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | RCSID("$OpenBSD: misc.c,v 1.45 2006/02/10 00:27:13 stevesk Exp $"); | 27 | RCSID("$OpenBSD: misc.c,v 1.46 2006/03/13 10:14:29 dtucker Exp $"); |
28 | 28 | ||
29 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
30 | #include <netinet/tcp.h> | 30 | #include <netinet/tcp.h> |
@@ -128,6 +128,7 @@ set_nodelay(int fd) | |||
128 | 128 | ||
129 | /* Characters considered whitespace in strsep calls. */ | 129 | /* Characters considered whitespace in strsep calls. */ |
130 | #define WHITESPACE " \t\r\n" | 130 | #define WHITESPACE " \t\r\n" |
131 | #define QUOTE "\"" | ||
131 | 132 | ||
132 | /* return next token in configuration line */ | 133 | /* return next token in configuration line */ |
133 | char * | 134 | char * |
@@ -141,15 +142,27 @@ strdelim(char **s) | |||
141 | 142 | ||
142 | old = *s; | 143 | old = *s; |
143 | 144 | ||
144 | *s = strpbrk(*s, WHITESPACE "="); | 145 | *s = strpbrk(*s, WHITESPACE QUOTE "="); |
145 | if (*s == NULL) | 146 | if (*s == NULL) |
146 | return (old); | 147 | return (old); |
147 | 148 | ||
149 | if (*s[0] == '\"') { | ||
150 | memmove(*s, *s + 1, strlen(*s)); /* move nul too */ | ||
151 | /* Find matching quote */ | ||
152 | if ((*s = strpbrk(*s, QUOTE)) == NULL) { | ||
153 | return (NULL); /* no matching quote */ | ||
154 | } else { | ||
155 | *s[0] = '\0'; | ||
156 | return (old); | ||
157 | } | ||
158 | } | ||
159 | |||
148 | /* Allow only one '=' to be skipped */ | 160 | /* Allow only one '=' to be skipped */ |
149 | if (*s[0] == '=') | 161 | if (*s[0] == '=') |
150 | wspace = 1; | 162 | wspace = 1; |
151 | *s[0] = '\0'; | 163 | *s[0] = '\0'; |
152 | 164 | ||
165 | /* Skip any extra whitespace after first token */ | ||
153 | *s += strspn(*s + 1, WHITESPACE) + 1; | 166 | *s += strspn(*s + 1, WHITESPACE) + 1; |
154 | if (*s[0] == '=' && !wspace) | 167 | if (*s[0] == '=' && !wspace) |
155 | *s += strspn(*s + 1, WHITESPACE) + 1; | 168 | *s += strspn(*s + 1, WHITESPACE) + 1; |