diff options
author | Paul Querna <pquerna@apache.org> | 2016-03-13 14:00:11 -0700 |
---|---|---|
committer | Paul Querna <pquerna@apache.org> | 2016-03-14 16:40:21 -0700 |
commit | 4a9e7c4cb155ac3284bdca098227b1a78495a26f (patch) | |
tree | bd509927a0025b65e6fe8739c3cb7d8b327a5f19 /src/core/tsi | |
parent | 27df68940577764f4a98a1972d9958005e0ef858 (diff) |
Improve looks_like_ip_address for IPv6 addresses, and add tests
Diffstat (limited to 'src/core/tsi')
-rw-r--r-- | src/core/tsi/ssl_transport_security.c | 7 | ||||
-rw-r--r-- | src/core/tsi/ssl_transport_security.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c index d8f7b5b0e0..fcbd910f07 100644 --- a/src/core/tsi/ssl_transport_security.c +++ b/src/core/tsi/ssl_transport_security.c @@ -206,13 +206,16 @@ static void ssl_info_callback(const SSL *ssl, int where, int ret) { } /* Returns 1 if name looks like an IP address, 0 otherwise. - This is a very rough heuristic as it does not handle IPV6 or things like: - 0300.0250.00.01, 0xC0.0Xa8.0x0.0x1, 000030052000001, 0xc0.052000001 */ + This is a very rough heuristic, and only handles IPv6 in hexadecimal form. */ static int looks_like_ip_address(const char *name) { size_t i; size_t dot_count = 0; size_t num_size = 0; for (i = 0; i < strlen(name); i++) { + if (name[i] == ':') { + /* IPv6 Address in hexadecimal form, : is not allowed in DNS names. */ + return 1; + } if (name[i] >= '0' && name[i] <= '9') { if (num_size > 3) return 0; num_size++; diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index b587d7ce31..4909af4c47 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without |