]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream commit
authordjm@openbsd.org <djm@openbsd.org>
Fri, 10 Mar 2017 04:24:55 +0000 (04:24 +0000)
committerDamien Miller <djm@mindrot.org>
Fri, 10 Mar 2017 04:35:39 +0000 (15:35 +1100)
make hostname matching really insensitive to case;
bz#2685, reported by Petr Cerny; ok dtucker@

Upstream-ID: e632b7a9bf0d0558d5ff56dab98b7cca6c3db549

match.c

diff --git a/match.c b/match.c
index a7585e2bdbd28aa7b6d27f98df1f7890592776dd..3cf40306b025fbea8b67f3914cd7d4ebab134e0b 100644 (file)
--- a/match.c
+++ b/match.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: match.c,v 1.36 2017/03/10 03:52:48 djm Exp $ */
+/* $OpenBSD: match.c,v 1.37 2017/03/10 04:24:55 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 
 #include "xmalloc.h"
 #include "match.h"
+#include "misc.h"
 
 /*
  * Returns true if the given string matches the pattern (which may contain ?
@@ -177,7 +179,13 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
 int
 match_hostname(const char *host, const char *pattern)
 {
-       return match_pattern_list(host, pattern, 1);
+       char *hostcopy = xstrdup(host);
+       int r;
+
+       lowercase(hostcopy);
+       r = match_pattern_list(hostcopy, pattern, 1);
+       free(hostcopy);
+       return r;
 }
 
 /*