summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-03-15 12:05:59 +1100
committerDamien Miller <djm@mindrot.org>2006-03-15 12:05:59 +1100
commit306d118f72670f0da447f28b7eec576dcb4a6e38 (patch)
tree0bff224f27fffa3159073c7c639f3ec0cc7fa5b7 /misc.c
parent8056a9d46ac2d75560c2fd9fc69c75ee46a43922 (diff)
- dtucker@cvs.openbsd.org 2006/03/13 10:14:29
[misc.c ssh_config.5 sshd_config.5] Allow config directives to contain whitespace by surrounding them by double quotes. mindrot #482, man page help from jmc@, ok djm@
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/misc.c b/misc.c
index e1da651ef..662480e9e 100644
--- a/misc.c
+++ b/misc.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: misc.c,v 1.45 2006/02/10 00:27:13 stevesk Exp $"); 27RCSID("$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 */
133char * 134char *
@@ -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;