Fixed patches format delimited by CR/LF
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 4 Aug 2015 19:43:49 +0000 (21:43 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 18 Aug 2015 19:25:39 +0000 (21:25 +0200)
src/libimcv/plugins/imc_hcd/imc_hcd.c
src/libimcv/plugins/imv_hcd/imv_hcd_agent.c
testing/tests/tnc/tnccs-20-hcd-eap/hosts/alice/etc/ipsec.d/certs/aaaCert.pem
testing/tests/tnc/tnccs-20-hcd-eap/hosts/alice/etc/ipsec.d/private/aaaKey.pem
testing/tests/tnc/tnccs-20-hcd-eap/hosts/carol/etc/strongswan.conf
testing/tests/tnc/tnccs-20-hcd-eap/hosts/dave/etc/strongswan.conf

index 7043837..b631683 100644 (file)
@@ -392,7 +392,8 @@ static void add_quadruple(imc_msg_t *msg, char *section, quadruple_t *quad)
        const size_t version_len = 16;
        char version[version_len];
        char hex_version_default[] = "00000000000000000000000000000000";
-       char *app, *name, *patches, *pos, *string_version, *hex_version;
+       char *app, *name, *patches, *string_version, *hex_version;
+       size_t len;
        chunk_t num_version;
        enumerator_t *enumerator;
 
@@ -414,24 +415,6 @@ static void add_quadruple(imc_msg_t *msg, char *section, quadruple_t *quad)
                                        "%s.plugins.imc-hcd.subtypes.%s.%s.%s.version", 
                                        hex_version_default, lib->ns, section, quad->section, app);
 
-               /* replace \n escape character by CRLF */
-               pos = patches;
-               while (TRUE)
-               {
-                       pos = strchr(pos, '\\');
-                       if (pos == NULL)
-                       {
-                               break;
-                       }
-                       if (pos[1] == 'n')
-                       {
-                               pos[0] = '\r';
-                               pos[1] = '\n';
-                               pos++;
-                       }
-                       pos++;
-               }
-
                /* convert hex string into binary chunk */
                if (strlen(hex_version) > 2 * version_len)
                {
@@ -446,7 +429,14 @@ static void add_quadruple(imc_msg_t *msg, char *section, quadruple_t *quad)
                                                pen_type_create(PEN_PWG, quad->name_attr));
                msg->add_attribute(msg, attr);
 
-               DBG2(DBG_IMC, "  %N: %s", pwg_attr_names, quad->patches_attr, patches);
+               /* remove any trailing LF from patches string for logging */
+               len = strlen(patches);
+               if (len && (patches[len - 1] == '\n'))
+               {
+                       len--;
+               }
+               DBG2(DBG_IMC, "  %N:%s%.*s", pwg_attr_names, quad->patches_attr,
+                                               len ? "\n" : " ", len, patches);
                attr = generic_attr_string_create(chunk_from_str(patches),
                                                pen_type_create(PEN_PWG, quad->patches_attr));
                msg->add_attribute(msg, attr);
index 5fce45d..8cfa4d1 100644 (file)
@@ -260,20 +260,36 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
                                case PWG_HCD_VENDOR_NAME:
                                case PWG_HCD_TIME_SOURCE:
                                case PWG_HCD_FIRMWARE_NAME:
-                               case PWG_HCD_FIRMWARE_PATCHES:
                                case PWG_HCD_FIRMWARE_STRING_VERSION:
                                case PWG_HCD_RESIDENT_APP_NAME:
-                               case PWG_HCD_RESIDENT_APP_PATCHES:
                                case PWG_HCD_RESIDENT_APP_STRING_VERSION:
                                case PWG_HCD_USER_APP_NAME:
-                               case PWG_HCD_USER_APP_PATCHES:
                                case PWG_HCD_USER_APP_STRING_VERSION:
                                {
                                        chunk_t value;
 
                                        value = attr->get_value(attr);
                                        DBG2(DBG_IMV, "  %N: %.*s", pwg_attr_names, type.type,
-                                                                  value.len, value.ptr);
+                                                                 value.len, value.ptr);
+                                       break;
+                               }
+                               case PWG_HCD_FIRMWARE_PATCHES:
+                               case PWG_HCD_RESIDENT_APP_PATCHES:
+                               case PWG_HCD_USER_APP_PATCHES:
+                               {
+                                       chunk_t value;
+                                       size_t len;
+
+                                       value = attr->get_value(attr);
+                                       len = value.len;
+
+                                       /* remove any trailing LF from patches string */
+                                       if (len && (value.ptr[len - 1] == '\n'))
+                                       {
+                                               len--;
+                                       }
+                                       DBG2(DBG_IMV, "  %N:%s%.*s", pwg_attr_names, type.type,
+                                                                 len ? "\n" : " ", len, value.ptr);
                                        break;
                                }
                                case PWG_HCD_FIRMWARE_VERSION:
@@ -306,7 +322,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
                                        attr_cast = (generic_attr_bool_t*)attr;
                                        status = attr_cast->get_status(attr_cast);
                                        DBG2(DBG_IMV, "  %N: %s", pwg_attr_names, type.type,
-                                                                  status ? "yes" : "no");
+                                                                 status ? "yes" : "no");
 
                                        if (type.type == PWG_HCD_USER_APP_ENABLED && !status)
                                        {
@@ -323,7 +339,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
                                        attr_cast = (ietf_attr_fwd_enabled_t*)attr;
                                        fwd_status = attr_cast->get_status(attr_cast);
                                        DBG2(DBG_IMV, "  %N: %N", pwg_attr_names, type.type,
-                                                                  os_fwd_status_names, fwd_status);
+                                                                 os_fwd_status_names, fwd_status);
                                        break;
                                }
 
index 6aeb0c0..42083c2 100644 (file)
@@ -1,25 +1,25 @@
 -----BEGIN CERTIFICATE-----
-MIIEIDCCAwigAwIBAgIBIjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJDSDEZ
+MIIEIDCCAwigAwIBAgIBMzANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJDSDEZ
 MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
-b290IENBMB4XDTEwMDgwNDA4Mzg0MVoXDTE1MDgwMzA4Mzg0MVowRTELMAkGA1UE
+b290IENBMB4XDTE1MDgwNDE0NTUzMVoXDTE5MDkwNjE0NTUzMVowRTELMAkGA1UE
 BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEmFhYS5z
-dHJvbmdzd2FuLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK2R
-RcAYdZ/jOhHBSjrLDYT1OhRJ2mXjyuSbWyJQogF9c6sY8W2GhTC4e1gNThZM9+Pm
-Vzs0R39kzxsmOFhuTfwIhavMzvkWJ7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10344cc 100644 (file)
@@ -41,7 +41,7 @@ libimcv {
           firmware {
                    fw-1 {
               name = Firmware ABC 
-              patches = "security patch 2014-05-08\nupgrade 2014-08-16\nsecurity patch 2015-3-22"
+              patches = "security patch 2014-05-08\r\nupgrade 2014-08-16\r\nsecurity patch 2015-3-22\r\n"
               string_version = 1.0.7
               version = 00000001000000000000000700000000
             }
@@ -55,7 +55,7 @@ libimcv {
           resident_application {
             resident-app-1 {
               name = Resident App XYZ 
-              patches = "xmas patch 2014-12-24\nservice patch 2015-05-22"
+              patches = "xmas patch 2014-12-24\r\nservice patch 2015-05-22\r\n"
               string_version = 2.5
               version = 00000002000000050000000000000000
             }
@@ -104,7 +104,7 @@ libimcv {
           resident_application {
                    resident-app-if {
               name = Resident App Interface+ 
-              patches = "service patch 2015-02-09"
+              patches = "service patch 2015-02-09\r\n"
               string_version = 2.5
               version = 00000002000000050000000000000000
             }
@@ -117,7 +117,7 @@ libimcv {
           firmware {
             fw-scanner {
               name = Scanner Firmware 
-              patches = "security patch 2013-08-11\nsecurity patch 2015-5-30"
+              patches = "security patch 2013-08-11\r\nsecurity patch 2015-5-30\r\n"
               string_version = 2.5.3
               version = 00000002000000050000000300000000
             }
index 2e99df0..f9ae432 100644 (file)
@@ -41,7 +41,7 @@ libimcv {
           firmware {
                    fw-1 {
               name = Firmware ABC 
-              patches = "security patch 2014-05-08\nupgrade 2014-08-16\nsecurity patch 2015-3-22"
+              patches = "security patch 2014-05-08\r\nupgrade 2014-08-16\r\nsecurity patch 2015-3-22\r\n"
               string_version = 1.0.7
               version = 00000001000000000000000700000000
             }
@@ -55,7 +55,7 @@ libimcv {
           resident_application {
             resident-app-1 {
               name = Resident App XYZ 
-              patches = "xmas patch 2014-12-24\nservice patch 2015-05-22"
+              patches = "xmas patch 2014-12-24\r\nservice patch 2015-05-22\r\n"
               string_version = 2.5
               version = 00000002000000050000000000000000
             }
@@ -83,7 +83,7 @@ libimcv {
           resident_application {
                    resident-app-if {
               name = Resident App Interface+ 
-              patches = "service patch 2015-02-09"
+              patches = "service patch 2015-02-09\r\n"
               string_version = 2.5
               version = 00000002000000050000000000000000
             }
@@ -96,7 +96,7 @@ libimcv {
           firmware {
             fw-scanner {
               name = Scanner Firmware 
-              patches = "security patch 2013-08-11\nsecurity patch 2015-5-30"
+              patches = "security patch 2013-08-11\r\nsecurity patch 2015-5-30\r\n"
               string_version = 2.5.3
               version = 00000002000000050000000300000000
             }