summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-03-02 03:02:11 +0000
committerDamien Miller <djm@mindrot.org>2018-03-02 14:39:17 +1100
commit713d9cb510e0e7759398716cbe6dcf43e574be71 (patch)
treeeaf9f4b2b360a4cc940b9d6db01d80f0e20a6142
parent94b4e2d29afaaaef89a95289b16c18bf5627f7cd (diff)
upstream: Allow escaped quotes \" and \' in ssh_config and
sshd_config quotes option strings. bz#1596 ok markus@ OpenBSD-Commit-ID: dd3a29fc2dc905e8780198e5a6a30b096de1a1cb
-rw-r--r--misc.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/misc.c b/misc.c
index f6fbb5e4a..b45a9ec63 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.123 2018/01/08 15:21:49 markus Exp $ */ 1/* $OpenBSD: misc.c,v 1.124 2018/03/02 03:02:11 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -242,7 +242,7 @@ set_rdomain(int fd, const char *name)
242char * 242char *
243strdelim(char **s) 243strdelim(char **s)
244{ 244{
245 char *old; 245 char *old, *cp;
246 int wspace = 0; 246 int wspace = 0;
247 247
248 if (*s == NULL) 248 if (*s == NULL)
@@ -256,13 +256,24 @@ strdelim(char **s)
256 256
257 if (*s[0] == '\"') { 257 if (*s[0] == '\"') {
258 memmove(*s, *s + 1, strlen(*s)); /* move nul too */ 258 memmove(*s, *s + 1, strlen(*s)); /* move nul too */
259
259 /* Find matching quote */ 260 /* Find matching quote */
260 if ((*s = strpbrk(*s, QUOTE)) == NULL) { 261 for (cp = *s; ; cp++) {
261 return (NULL); /* no matching quote */ 262 if (*cp == '\0')
262 } else { 263 return NULL; /* no matching quote */
263 *s[0] = '\0'; 264 if (*cp == '\\') {
264 *s += strspn(*s + 1, WHITESPACE) + 1; 265 /* Escape sequence */
265 return (old); 266 if (cp[1] == '\"' || cp[1] == '\'' ||
267 cp[1] == '\\') {
268 memmove(cp, cp + 1, strlen(cp));
269 continue;
270 }
271 return NULL; /* invalid escape */
272 } else if (*cp == '\"') {
273 *(cp++) = '\0';
274 *s += strspn(cp, WHITESPACE);
275 return old;
276 }
266 } 277 }
267 } 278 }
268 279