aboutsummaryrefslogtreecommitdiffstats
path: root/main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2015-07-28 11:33:38 +0300
committerTimo Teräs <timo.teras@iki.fi>2015-07-28 11:35:47 +0300
commitfc1ceeb02b3e149645205e67bcc009e742140590 (patch)
treeb559837b40485a7c0f77ce6459c03f131191283d /main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch
parentc3aa1460dbeb4e1e10972fc00314d7a80413707e (diff)
downloadaports-fc1ceeb02b3e149645205e67bcc009e742140590.tar.bz2
aports-fc1ceeb02b3e149645205e67bcc009e742140590.tar.xz
main/strongswan: cherry-pick upstream fixes
also fixes a minor memory leak in patch 1001 (the offending hunk is now just deleted, as other upstream commits fixed the issue it tried to address)
Diffstat (limited to 'main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch')
-rw-r--r--main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch b/main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch
new file mode 100644
index 0000000000..ff79e322ec
--- /dev/null
+++ b/main/strongswan/0002-host-Properly-handle-NULL-in-host_create_from_string.patch
@@ -0,0 +1,67 @@
+From 65579569adfa0e2c9602ee250f4554169ba5a87d Mon Sep 17 00:00:00 2001
+From: Tobias Brunner <tobias@strongswan.org>
+Date: Thu, 11 Jun 2015 15:07:07 +0200
+Subject: [PATCH] host: Properly handle NULL in
+ host_create_from_string[_and_family]
+
+---
+ src/libstrongswan/networking/host.c | 4 ++++
+ src/libstrongswan/tests/suites/test_host.c | 6 ++++++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/src/libstrongswan/networking/host.c b/src/libstrongswan/networking/host.c
+index 07da3ef..2e464b0 100644
+--- a/src/libstrongswan/networking/host.c
++++ b/src/libstrongswan/networking/host.c
+@@ -354,6 +354,10 @@ host_t *host_create_from_string_and_family(char *string, int family,
+ struct sockaddr_in6 v6;
+ } addr;
+
++ if (!string)
++ {
++ return NULL;
++ }
+ if (streq(string, "%any"))
+ {
+ return host_create_any_port(family ? family : AF_INET, port);
+diff --git a/src/libstrongswan/tests/suites/test_host.c b/src/libstrongswan/tests/suites/test_host.c
+index 7161b2c..5cb8013 100644
+--- a/src/libstrongswan/tests/suites/test_host.c
++++ b/src/libstrongswan/tests/suites/test_host.c
+@@ -104,6 +104,9 @@ START_TEST(test_create_from_string_v4)
+ {
+ host_t *host;
+
++ host = host_create_from_string(NULL, 500);
++ ck_assert(!host);
++
+ host = host_create_from_string("%any", 500);
+ verify_any(host, AF_INET, 500);
+ host->destroy(host);
+@@ -196,6 +199,7 @@ static void test_create_from_string_and_family_addr(char *string, chunk_t addr,
+
+ START_TEST(test_create_from_string_and_family_v4)
+ {
++ test_create_from_string_and_family_any(NULL, AF_INET, AF_UNSPEC);
+ test_create_from_string_and_family_any("%any", AF_INET, AF_INET);
+ test_create_from_string_and_family_any("%any4", AF_INET, AF_INET);
+ test_create_from_string_and_family_any("0.0.0.0", AF_INET, AF_INET);
+@@ -210,6 +214,7 @@ END_TEST
+
+ START_TEST(test_create_from_string_and_family_v6)
+ {
++ test_create_from_string_and_family_any(NULL, AF_INET6, AF_UNSPEC);
+ test_create_from_string_and_family_any("%any", AF_INET6, AF_INET6);
+ test_create_from_string_and_family_any("%any6", AF_INET6, AF_INET6);
+ test_create_from_string_and_family_any("::", AF_INET6, AF_INET6);
+@@ -224,6 +229,7 @@ END_TEST
+
+ START_TEST(test_create_from_string_and_family_other)
+ {
++ test_create_from_string_and_family_any(NULL, AF_UNSPEC, AF_UNSPEC);
+ test_create_from_string_and_family_any("%any", AF_UNSPEC, AF_INET);
+ test_create_from_string_and_family_any("%any4", AF_UNSPEC, AF_INET);
+ test_create_from_string_and_family_any("0.0.0.0", AF_UNSPEC, AF_INET);
+--
+2.4.6
+