diff options
| author | Matthias Andree <matthias.andree@gmx.de> | 2010-08-27 21:08:14 +0200 | 
|---|---|---|
| committer | Matthias Andree <matthias.andree@gmx.de> | 2010-08-27 21:10:46 +0200 | 
| commit | 480b13c7e6d83543a82b2974a3af0c8864d7b6a7 (patch) | |
| tree | 487c92a20b70abda08cf9ecf9f5c4d85c705cf26 /socket.c | |
| parent | 0fc373e3e6c2a4016bdf2467eba2d59c920158e1 (diff) | |
| download | fetchmail-480b13c7e6d83543a82b2974a3af0c8864d7b6a7.tar.gz fetchmail-480b13c7e6d83543a82b2974a3af0c8864d7b6a7.tar.bz2 fetchmail-480b13c7e6d83543a82b2974a3af0c8864d7b6a7.zip | |
Disallow X.509 wildcard matches in domain literals.
Diffstat (limited to 'socket.c')
| -rw-r--r-- | socket.c | 18 | 
1 files changed, 17 insertions, 1 deletions
| @@ -600,7 +600,23 @@ SSL *SSLGetContext( int sock )   * The only place where a wildcard is allowed is in the leftmost   * position of p1. */  static int name_match(const char *p1, const char *p2) { -    if (p1[0] == '*' && p1[1] == '.') { +    const char *const dom = "0123456789."; +    int wildcard_ok = 1; + +    /* blank patterns never match */ +    if (p1[0] == '\0') +	return 0; + +    /* disallow wildcards in certificates for domain literals +     * (10.9.8.7-like) */ +    if (strspn(p1+(*p1 == '*' ? 1 : 0), dom) == strlen(p1)) +	wildcard_ok = 0; + +    /* disallow wildcards for domain literals */ +    if (strspn(p2, dom) == strlen(p2)) +	wildcard_ok = 0; + +    if (wildcard_ok && p1[0] == '*' && p1[1] == '.') {  	size_t l1, l2;  	++p1; | 
