summaryrefslogtreecommitdiff
path: root/match.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-02-03 23:01:19 +0000
committerDamien Miller <djm@mindrot.org>2017-02-04 10:08:15 +1100
commit68bc8cfa7642d3ccbf2cd64281c16b8b9205be59 (patch)
tree4b2ddc75ee7ac985570c4e85c37abfd8f7be4f47 /match.c
parentc924b2ef941028a1f31e6e94f54dfeeeef462a4e (diff)
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.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/match.c b/match.c
index c15dcd1ef..aeba4bb77 100644
--- a/match.c
+++ b/match.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: match.c,v 1.33 2016/11/06 05:46:37 djm Exp $ */ 1/* $OpenBSD: match.c,v 1.34 2017/02/03 23:01:19 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * 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)
284 free(s); 284 free(s);
285 return NULL; 285 return NULL;
286} 286}
287
288/*
289 * Filters a comma-separated list of strings, excluding any entry matching
290 * the 'filter' pattern list. Caller must free returned string.
291 */
292char *
293match_filter_list(const char *proposal, const char *filter)
294{
295 size_t len = strlen(proposal) + 1;
296 char *fix_prop = malloc(len);
297 char *orig_prop = strdup(proposal);
298 char *cp, *tmp;
299
300 if (fix_prop == NULL || orig_prop == NULL)
301 return NULL;
302
303 tmp = orig_prop;
304 *fix_prop = '\0';
305 while ((cp = strsep(&tmp, ",")) != NULL) {
306 if (match_pattern_list(cp, filter, 0) != 1) {
307 if (*fix_prop != '\0')
308 strlcat(fix_prop, ",", len);
309 strlcat(fix_prop, cp, len);
310 }
311 }
312 free(orig_prop);
313 return fix_prop;
314}
315