summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--compat.c112
-rw-r--r--match.c26
-rw-r--r--match.h7
4 files changed, 85 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index d47f11af..f4f1f790 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,9 @@
- markus@cvs.openbsd.org 2001/12/05 15:04:48
[version.h]
post 3.0.2
+ - markus@cvs.openbsd.org 2001/12/05 16:54:51
+ [compat.c match.c match.h]
+ make theo and djm happy: bye bye regexp
20011126
- (tim) [contrib/cygwin/README, openbsd-compat/bsd-cygwin_util.c,
@@ -6987,4 +6990,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.1685 2001/12/06 18:02:59 mouring Exp $
+$Id: ChangeLog,v 1.1686 2001/12/06 18:06:05 mouring Exp $
diff --git a/compat.c b/compat.c
index 0b8d5382..09ca4a44 100644
--- a/compat.c
+++ b/compat.c
@@ -23,22 +23,13 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: compat.c,v 1.54 2001/12/05 10:06:12 deraadt Exp $");
-
-#ifdef HAVE_LIBPCRE
-# include <pcreposix.h>
-#else /* Use native regex libraries */
-# ifdef HAVE_REGEX_H
-# include <regex.h>
-# else
-# include "openbsd-compat/fake-regex.h"
-# endif
-#endif /* HAVE_LIBPCRE */
+RCSID("$OpenBSD: compat.c,v 1.55 2001/12/05 16:54:51 markus Exp $");
#include "packet.h"
#include "xmalloc.h"
#include "compat.h"
#include "log.h"
+#include "match.h"
int compat13 = 0;
int compat20 = 0;
@@ -60,86 +51,97 @@ enable_compat13(void)
void
compat_datafellows(const char *version)
{
- int i, ret;
- char ebuf[1024];
- regex_t reg;
+ int i;
static struct {
char *pat;
int bugs;
} check[] = {
- { "^OpenSSH[-_]2\\.[012]",
- SSH_OLD_SESSIONID|SSH_BUG_BANNER|
+ { "OpenSSH-2.0*,"
+ "OpenSSH-2.1*,"
+ "OpenSSH_2.1*,"
+ "OpenSSH_2.2*", SSH_OLD_SESSIONID|SSH_BUG_BANNER|
SSH_OLD_DHGEX|SSH_BUG_NOREKEY },
- { "^OpenSSH_2\\.3\\.0", SSH_BUG_BANNER|SSH_BUG_BIGENDIANAES|
+ { "OpenSSH_2.3.0*", SSH_BUG_BANNER|SSH_BUG_BIGENDIANAES|
SSH_OLD_DHGEX|SSH_BUG_NOREKEY},
- { "^OpenSSH_2\\.3\\.", SSH_BUG_BIGENDIANAES|SSH_OLD_DHGEX|
+ { "OpenSSH_2.3.*", SSH_BUG_BIGENDIANAES|SSH_OLD_DHGEX|
SSH_BUG_NOREKEY},
- { "^OpenSSH_2\\.5\\.[01]p1",
+ { "OpenSSH_2.5.0p1*,"
+ "OpenSSH_2.5.1p1*",
SSH_BUG_BIGENDIANAES|SSH_OLD_DHGEX|
SSH_BUG_NOREKEY },
- { "^OpenSSH_2\\.5\\.[012]",
- SSH_OLD_DHGEX|SSH_BUG_NOREKEY },
- { "^OpenSSH_2\\.5\\.3",
+ { "OpenSSH_2.5.0*,"
+ "OpenSSH_2.5.1*,"
+ "OpenSSH_2.5.2*", SSH_OLD_DHGEX|SSH_BUG_NOREKEY },
+ { "OpenSSH_2.5.3*",
SSH_BUG_NOREKEY },
- { "^OpenSSH", 0 },
- { "MindTerm", 0 },
- { "^2\\.1\\.0", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
+ { "OpenSSH*", 0 },
+ { "*MindTerm*", 0 },
+ { "2.1.0*", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
SSH_BUG_RSASIGMD5|SSH_BUG_HBSERVICE },
- { "^2\\.1 ", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
+ { "2.1 *", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
SSH_BUG_RSASIGMD5|SSH_BUG_HBSERVICE },
- { "^2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SH_OLD_SESSIONID }, /* Van Dyke */
- { "^3\\.0 SecureCRT", SSH_OLD_SESSIONID },
- { "^1\\.7 SecureFX", SSH_OLD_SESSIONID },
- { "^1\\.2\\.1[89]", SSH_BUG_IGNOREMSG },
- { "^1\\.2\\.2[012]", SSH_BUG_IGNOREMSG },
- { "^1\\.3\\.2", SSH_BUG_IGNOREMSG }, /* f-secure */
- { "^SSH Compatible Server", /* Netscreen */
- SSH_BUG_PASSWORDPAD },
- { "^OSU_0", SSH_BUG_PASSWORDPAD },
- { "^OSU_1\\.[0-4]", SSH_BUG_PASSWORDPAD },
- { "^OSU_1\\.5alpha[1-3]",
+ { "2.3.*", SSH_BUG_DEBUG|SSH_BUG_RSASIGMD5 },
+ { "2.4", SSH_OLD_SESSIONID }, /* Van Dyke */
+ { "2.*", SSH_BUG_DEBUG },
+ { "3.0.*", SSH_BUG_DEBUG },
+ { "3.0 SecureCRT*", SSH_OLD_SESSIONID },
+ { "1.7 SecureFX*", SSH_OLD_SESSIONID },
+ { "1.2.18*,"
+ "1.2.19*,"
+ "1.2.20*,"
+ "1.2.21*,"
+ "1.2.22*", SSH_BUG_IGNOREMSG },
+ { "1.3.2*", SSH_BUG_IGNOREMSG }, /* f-secure */
+ { "*SSH Compatible Server*", /* Netscreen */
SSH_BUG_PASSWORDPAD },
- { "^SSH_Version_Mapper",
+ { "*OSU_0*,"
+ "OSU_1.0*,"
+ "OSU_1.1*,"
+ "OSU_1.2*,"
+ "OSU_1.3*,"
+ "OSU_1.4*,"
+ "OSU_1.5alpha1*,"
+ "OSU_1.5alpha2*,"
+ "OSU_1.5alpha3*", SSH_BUG_PASSWORDPAD },
+ { "*SSH_Version_Mapper*",
SSH_BUG_SCANNER },
{ NULL, 0 }
};
+
/* process table, return first match */
for (i = 0; check[i].pat; i++) {
- ret = regcomp(&reg, check[i].pat, REG_EXTENDED|REG_NOSUB);
- if (ret != 0) {
- regerror(ret, &reg, ebuf, sizeof(ebuf));
- ebuf[sizeof(ebuf)-1] = '\0';
- error("regerror: %s", ebuf);
- continue;
- }
- ret = regexec(&reg, version, 0, NULL, 0);
- regfree(&reg);
- if (ret == 0) {
+ if (match_pattern_list(version, check[i].pat,
+ strlen(check[i].pat), 0) == 1) {
debug("match: %s pat %s", version, check[i].pat);
datafellows = check[i].bugs;
return;
diff --git a/match.c b/match.c
index 188b9a41..ca4d92c4 100644
--- a/match.c
+++ b/match.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: match.c,v 1.14 2001/06/27 04:48:53 markus Exp $");
+RCSID("$OpenBSD: match.c,v 1.15 2001/12/05 16:54:51 markus Exp $");
#include "match.h"
#include "xmalloc.h"
@@ -104,14 +104,15 @@ match_pattern(const char *s, const char *pattern)
}
/*
- * Tries to match the host name (which must be in all lowercase) against the
+ * Tries to match the string 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)
+match_pattern_list(const char *string, const char *pattern, u_int len,
+ int dolower)
{
char sub[1024];
int negated;
@@ -134,7 +135,8 @@ match_hostname(const char *host, const char *pattern, u_int len)
for (subi = 0;
i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
subi++, i++)
- sub[subi] = isupper(pattern[i]) ? tolower(pattern[i]) : pattern[i];
+ sub[subi] = dolower && isupper(pattern[i]) ?
+ tolower(pattern[i]) : pattern[i];
/* If subpattern too long, return failure (no match). */
if (subi >= sizeof(sub) - 1)
return 0;
@@ -146,8 +148,8 @@ match_hostname(const char *host, const char *pattern, u_int len)
/* Null-terminate the subpattern. */
sub[subi] = '\0';
- /* Try to match the subpattern against the host name. */
- if (match_pattern(host, sub)) {
+ /* Try to match the subpattern against the string. */
+ if (match_pattern(string, sub)) {
if (negated)
return -1; /* Negative */
else
@@ -163,6 +165,18 @@ match_hostname(const char *host, const char *pattern, u_int len)
}
/*
+ * 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);
+}
+
+/*
* returns 0 if we get a negative match for the hostname or the ip
* or if we get no match at all. returns 1 otherwise.
*/
diff --git a/match.h b/match.h
index f05fe9b3..7b777de3 100644
--- a/match.h
+++ b/match.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: match.h,v 1.9 2001/06/26 06:32:56 itojun Exp $ */
+/* $OpenBSD: match.h,v 1.10 2001/12/05 16:54:51 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -14,8 +14,9 @@
#ifndef MATCH_H
#define MATCH_H
-int match_pattern(const char *, const char *);
-int match_hostname(const char *, const char *, u_int);
+int match_pattern(const char *, const char *);
+int match_pattern_list(const char *, const char *, u_int, int);
+int match_hostname(const char *, const char *, u_int);
int match_host_and_ip(const char *, const char *, const char *);
int match_user(const char *, const char *, const char *, const char *);
char *match_list(const char *, const char *, u_int *);