diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2017-09-11 15:28:41 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2017-09-11 15:28:41 +0000 |
commit | 21d9f3cc23972d04bbe0d485f138f4b214cbdc43 (patch) | |
tree | a910517a9a7985c3a5911ff5fb51da7ccd8ea0f5 | |
parent | e999a72de8a69798310f9c8f8ed24131ac53cea9 (diff) | |
download | libapr-21d9f3cc23972d04bbe0d485f138f4b214cbdc43.tar.gz |
Merge 1808039 from trunk:
* network_io/unix/sockaddr.c (looks_like_ip): Fail for the empty
string.
* test/testipsub.c: Test that calling apr_ipsubnet_create with the
empty string fails.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1808042 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | network_io/unix/sockaddr.c | 4 | ||||
-rw-r--r-- | test/testipsub.c | 1 |
3 files changed, 8 insertions, 0 deletions
@@ -9,6 +9,9 @@ Changes for APR 1.6.3 after truncate could return stale data from the buffer. [Evgeny Kotkov <evgeny.kotkov visualsvn.com>] + *) apr_ipsubnet_create() now fails for an empty input string. + [Joe Orton] + Changes for APR 1.6.2 *) Corrected non-Unix builds for APR_LOCK_DEFAULT. diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c index 1500861af..a51e61874 100644 --- a/network_io/unix/sockaddr.c +++ b/network_io/unix/sockaddr.c @@ -1062,6 +1062,10 @@ static apr_status_t parse_ip(apr_ipsubnet_t *ipsub, const char *ipstr, int netwo static int looks_like_ip(const char *ipstr) { + if (strlen(ipstr) == 0) { + return 0; + } + if (strchr(ipstr, ':')) { /* definitely not a hostname; assume it is intended to be an IPv6 address */ return 1; diff --git a/test/testipsub.c b/test/testipsub.c index 804bb3dcd..89a3a1fa1 100644 --- a/test/testipsub.c +++ b/test/testipsub.c @@ -45,6 +45,7 @@ static void test_bad_input(abts_case *tc, void *data) ,{"127.0.0.1.2", NULL, APR_EBADIP} ,{"127.0.0.1.2", "8", APR_EBADIP} ,{"127", "255.0.0.0", APR_EBADIP} /* either EBADIP or EBADMASK seems fine */ + ,{"", NULL, APR_EBADIP} #if APR_HAVE_IPV6 ,{"::1", NULL, APR_SUCCESS} ,{"::1", "20", APR_SUCCESS} |