diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2000-10-10 20:20:46 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2000-10-10 20:20:46 +0000 |
commit | 9b298ea041d3e421606057df3225bba83f7dd8cc (patch) | |
tree | a373f2b8c68f512ef15e57843234c50455e3195b /usr.bin/ssh/compat.c | |
parent | 04fed8ca7e01985c3440e053e126da0d4f5e916e (diff) |
use rexexp for version string matching
Diffstat (limited to 'usr.bin/ssh/compat.c')
-rw-r--r-- | usr.bin/ssh/compat.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/usr.bin/ssh/compat.c b/usr.bin/ssh/compat.c index eeb6e2ef126..19dc76d9616 100644 --- a/usr.bin/ssh/compat.c +++ b/usr.bin/ssh/compat.c @@ -23,12 +23,13 @@ */ #include "includes.h" -RCSID("$OpenBSD: compat.c,v 1.23 2000/09/07 21:13:37 markus Exp $"); +RCSID("$OpenBSD: compat.c,v 1.24 2000/10/10 20:20:45 markus Exp $"); #include "ssh.h" #include "packet.h" #include "xmalloc.h" #include "compat.h" +#include <regex.h> int compat13 = 0; int compat20 = 0; @@ -50,27 +51,39 @@ enable_compat13(void) void compat_datafellows(const char *version) { - int i; - size_t len; - struct { - char *version; + int i, ret; + char ebuf[1024]; + regex_t reg; + static struct { + char *pat; int bugs; } check[] = { - {"2.1.0", SSH_BUG_SIGBLOB|SSH_BUG_HMAC}, - {"2.0.1", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|SSH_BUG_PUBKEYAUTH|SSH_BUG_X11FWD}, - {"2.", SSH_BUG_HMAC|SSH_COMPAT_SESSIONID_ENCODING}, - {NULL, 0} + {"^.*MindTerm", 0}, + {"^2\\.1\\.0 ", SSH_BUG_SIGBLOB|SSH_BUG_HMAC}, + {"^2\\.0\\.", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|SSH_BUG_PUBKEYAUTH|SSH_BUG_X11FWD}, + {"^2\\.[23]\\.0 ", SSH_BUG_HMAC|SSH_COMPAT_SESSIONID_ENCODING}, + {"^2\\.[2-9]\\.", SSH_COMPAT_SESSIONID_ENCODING}, + {"^2\\.", SSH_BUG_HMAC|SSH_COMPAT_SESSIONID_ENCODING}, + {NULL, 0} }; /* process table, return first match */ - for (i = 0; check[i].version; i++) { - len = strlen(check[i].version); - if (strlen(version) >= len && - (strncmp(version, check[i].version, len) == 0)) { - verbose("datafellows: %.200s", version); + for (i = 0; check[i].pat; i++) { + ret = regcomp(®, check[i].pat, REG_EXTENDED|REG_NOSUB); + if (ret != 0) { + regerror(ret, ®, ebuf, sizeof(ebuf)); + ebuf[sizeof(ebuf)-1] = '\0'; + error("regerror: %s", ebuf); + continue; + } + ret = regexec(®, version, 0, NULL, 0); + regfree(®); + if (ret == 0) { + debug("match: %s pat %s\n", version, check[i].pat); datafellows = check[i].bugs; return; } } + debug("no match: %s", version); } #define SEP "," |