diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-02-04 00:01:19 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-02-04 00:08:15 +0100 |
commit | 68bc8cfa7642d3ccbf2cd64281c16b8b9205be59 (patch) | |
tree | 4b2ddc75ee7ac985570c4e85c37abfd8f7be4f47 /match.c | |
parent | upstream commit (diff) | |
download | openssh-68bc8cfa7642d3ccbf2cd64281c16b8b9205be59.tar.xz openssh-68bc8cfa7642d3ccbf2cd64281c16b8b9205be59.zip |
upstream commit
support =- for removing methods from algorithms lists,
e.g. Ciphers=-*cbc; suggested by Cristian Ionescu-Idbohrn in bz#2671 "I like
it" markus@
Upstream-ID: c78c38f9f81a963b33d0eade559f6048add24a6d
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: match.c,v 1.33 2016/11/06 05:46:37 djm Exp $ */ +/* $OpenBSD: match.c,v 1.34 2017/02/03 23:01:19 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -284,3 +284,32 @@ match_list(const char *client, const char *server, u_int *next) free(s); return NULL; } + +/* + * Filters a comma-separated list of strings, excluding any entry matching + * the 'filter' pattern list. Caller must free returned string. + */ +char * +match_filter_list(const char *proposal, const char *filter) +{ + size_t len = strlen(proposal) + 1; + char *fix_prop = malloc(len); + char *orig_prop = strdup(proposal); + char *cp, *tmp; + + if (fix_prop == NULL || orig_prop == NULL) + return NULL; + + tmp = orig_prop; + *fix_prop = '\0'; + while ((cp = strsep(&tmp, ",")) != NULL) { + if (match_pattern_list(cp, filter, 0) != 1) { + if (*fix_prop != '\0') + strlcat(fix_prop, ",", len); + strlcat(fix_prop, cp, len); + } + } + free(orig_prop); + return fix_prop; +} + |