[openssh-commits] [openssh] 06/06: upstream: Allow escaped quotes \" and \' in ssh_config and

git+noreply at mindrot.org git+noreply at mindrot.org
Sat Mar 3 14:18:14 AEDT 2018


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 713d9cb510e0e7759398716cbe6dcf43e574be71
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Fri Mar 2 03:02:11 2018 +0000

    upstream: Allow escaped quotes \" and \' in ssh_config and
    
    sshd_config quotes option strings. bz#1596 ok markus@
    
    OpenBSD-Commit-ID: dd3a29fc2dc905e8780198e5a6a30b096de1a1cb
---
 misc.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/misc.c b/misc.c
index f6fbb5e4..b45a9ec6 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.123 2018/01/08 15:21:49 markus Exp $ */
+/* $OpenBSD: misc.c,v 1.124 2018/03/02 03:02:11 djm Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2005,2006 Damien Miller.  All rights reserved.
@@ -242,7 +242,7 @@ set_rdomain(int fd, const char *name)
 char *
 strdelim(char **s)
 {
-	char *old;
+	char *old, *cp;
 	int wspace = 0;
 
 	if (*s == NULL)
@@ -256,13 +256,24 @@ strdelim(char **s)
 
 	if (*s[0] == '\"') {
 		memmove(*s, *s + 1, strlen(*s)); /* move nul too */
+
 		/* Find matching quote */
-		if ((*s = strpbrk(*s, QUOTE)) == NULL) {
-			return (NULL);		/* no matching quote */
-		} else {
-			*s[0] = '\0';
-			*s += strspn(*s + 1, WHITESPACE) + 1;
-			return (old);
+		for (cp = *s; ; cp++) {
+			if (*cp == '\0')
+				return NULL; /* no matching quote */
+			if (*cp == '\\') {
+				/* Escape sequence */
+				if (cp[1] == '\"' || cp[1] == '\'' ||
+				    cp[1] == '\\') {
+					memmove(cp, cp + 1, strlen(cp));
+					continue;
+				}
+				return NULL; /* invalid escape */
+			} else if (*cp == '\"') {
+				*(cp++) = '\0';
+				*s += strspn(cp, WHITESPACE);
+				return old;
+			}
 		}
 	}
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list