host: Don't log port if it is zero
authorTobias Brunner <tobias@strongswan.org>
Fri, 17 Feb 2017 11:32:04 +0000 (12:32 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 2 Mar 2017 07:27:30 +0000 (08:27 +0100)
src/libstrongswan/networking/host.c
src/libstrongswan/tests/suites/test_host.c

index b71d2da..9537204 100644 (file)
@@ -139,7 +139,7 @@ int host_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
                                        snprintf(buffer, sizeof(buffer),
                                                         "(address conversion failed)");
                                }
-                               else if (spec->hash)
+                               else if (spec->hash && port)
                                {
                                        len = strlen(buffer);
                                        snprintf(buffer + len, sizeof(buffer) - len,
index 5d05457..63f0eb2 100644 (file)
@@ -657,18 +657,18 @@ END_TEST
 static struct {
        char *addr;
        uint16_t port;
-       /* results for %H, %+H, %#H (falls back to [0]) */
+       /* results for %H, %+H, %#H (falls back to the first entry) */
        char *result[3];
 } printf_data[] = {
        {NULL,          0, { "(null)" }},
        {NULL,        500, { "(null)" }},
-       {"%any",        0, { "%any", "0.0.0.0", "0.0.0.0[0]" }},
+       {"%any",        0, { "%any", "0.0.0.0", "0.0.0.0" }},
        {"%any",      500, { "%any", "0.0.0.0", "0.0.0.0[500]" }},
-       {"%any6",       0, { "%any6", "::", "::[0]" }},
+       {"%any6",       0, { "%any6", "::", "::" }},
        {"%any6",     500, { "%any6", "::", "::[500]" }},
-       {"192.168.0.1",   0, { "192.168.0.1", "192.168.0.1", "192.168.0.1[0]" }},
+       {"192.168.0.1",   0, { "192.168.0.1" }},
        {"192.168.0.1", 500, { "192.168.0.1", "192.168.0.1", "192.168.0.1[500]" }},
-       {"fec1::1",     0, { "fec1::1", "fec1::1", "fec1::1[0]" }},
+       {"fec1::1",     0, { "fec1::1" }},
        {"fec1::1",   500, { "fec1::1", "fec1::1", "fec1::1[500]" }},
 };