diff options
author | djm@openbsd.org <djm@openbsd.org> | 2019-09-03 10:30:47 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2019-09-03 10:39:31 +0200 |
commit | dd8002fbe63d903ffea5be7b7f5fc2714acab4a0 (patch) | |
tree | ac6cf10455cbf734c7d257288ab265e6113f2e42 /authfile.c | |
parent | upstream: move skip_space() to misc.c and make it public; ok (diff) | |
download | openssh-dd8002fbe63d903ffea5be7b7f5fc2714acab4a0.tar.xz openssh-dd8002fbe63d903ffea5be7b7f5fc2714acab4a0.zip |
upstream: move advance_past_options to authfile.c and make it
public; ok markus@
OpenBSD-Commit-ID: edda2fbba2c5b1f48e60f857a2010479e80c5f3c
Diffstat (limited to 'authfile.c')
-rw-r--r-- | authfile.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/authfile.c b/authfile.c index 5e335ce43..37341189c 100644 --- a/authfile.c +++ b/authfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: authfile.c,v 1.134 2019/08/05 11:50:33 dtucker Exp $ */ +/* $OpenBSD: authfile.c,v 1.135 2019/09/03 08:30:47 djm Exp $ */ /* * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. * @@ -528,3 +528,25 @@ sshkey_check_revoked(struct sshkey *key, const char *revoked_keys_file) } } +/* + * Advanced *cpp past the end of key options, defined as the first unquoted + * whitespace character. Returns 0 on success or -1 on failure (e.g. + * unterminated quotes). + */ +int +sshkey_advance_past_options(char **cpp) +{ + char *cp = *cpp; + int quoted = 0; + + for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) { + if (*cp == '\\' && cp[1] == '"') + cp++; /* Skip both */ + else if (*cp == '"') + quoted = !quoted; + } + *cpp = cp; + /* return failure for unterminated quotes */ + return (*cp == '\0' && quoted) ? -1 : 0; +} + |