]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: fold consecutive '*' wildcards to mitigate combinatorial
authordjm@openbsd.org <djm@openbsd.org>
Tue, 3 Nov 2020 22:53:12 +0000 (22:53 +0000)
committerDamien Miller <djm@mindrot.org>
Tue, 3 Nov 2020 23:09:25 +0000 (10:09 +1100)
explosion of recursive searches; ok dtucker

OpenBSD-Commit-ID: d18bcb39c40fb8a1ab61153db987e7d11dd3792b

match.c

diff --git a/match.c b/match.c
index 927565c188c67183755f6e9bde525706e534161a..3ac854d38f0042867be47868469edb795e7ff836 100644 (file)
--- a/match.c
+++ b/match.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: match.c,v 1.42 2020/07/05 23:59:45 djm Exp $ */
+/* $OpenBSD: match.c,v 1.43 2020/11/03 22:53:12 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -53,7 +53,6 @@
  * Returns true if the given string matches the pattern (which may contain ?
  * and * as wildcards), and zero if it does not match.
  */
-
 int
 match_pattern(const char *s, const char *pattern)
 {
@@ -63,8 +62,9 @@ match_pattern(const char *s, const char *pattern)
                        return !*s;
 
                if (*pattern == '*') {
-                       /* Skip the asterisk. */
-                       pattern++;
+                       /* Skip this and any consecutive asterisks. */
+                       while (*pattern == '*')
+                               pattern++;
 
                        /* If at end of pattern, accept immediately. */
                        if (!*pattern)