File openssh-6.6p1-ssh_case_insensitive_host_matching.patch of Package openssh.9495
# HG changeset patch
# Parent 99d957bbc40d559162a602772cacf74207895366
Match hostnames in a case-insensitive manner.
bsc#1017099
backport of upstream commit dd3e2298663f4cc1a06bc69582d00dcfee27d73c
diff --git a/openssh-6.6p1/match.c b/openssh-6.6p1/match.c
--- a/openssh-6.6p1/match.c
+++ b/openssh-6.6p1/match.c
@@ -37,19 +37,21 @@
#include "includes.h"
#include <sys/types.h>
#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 ?
* and * as wildcards), and zero if it does not match.
*/
int
match_pattern(const char *s, const char *pattern)
@@ -174,17 +176,23 @@ match_pattern_list(const char *string, c
* Tries to match the host name (which must be in all lowercase) against the
* comma-separated sequence of subpatterns (each possibly preceded by ! to
* indicate negation). Returns -1 if negation matches, 1 if there is
* a positive match, 0 if there is no match at all.
*/
int
match_hostname(const char *host, const char *pattern, u_int len)
{
- return match_pattern_list(host, pattern, len, 1);
+ char *hostcopy = xstrdup(host);
+ int r;
+
+ lowercase(hostcopy);
+ r = match_pattern_list(hostcopy, pattern, len, 1);
+ free(hostcopy);
+ return r;
}
/*
* returns 0 if we get a negative match for the hostname or the ip
* or if we get no match at all. returns -1 on error, or 1 on
* successful match.
*/
int