Make sure first argument is an int when using %.*s to print e.g. chunks
authorTobias Brunner <tobias@strongswan.org>
Fri, 28 Sep 2012 16:01:49 +0000 (18:01 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 28 Sep 2012 16:01:49 +0000 (18:01 +0200)
17 files changed:
src/checksum/checksum_builder.c
src/conftest/conftest.c
src/dumm/mconsole.c
src/libcharon/plugins/eap_radius/eap_radius.c
src/libcharon/plugins/stroke/stroke_cred.c
src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c
src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libhydra/plugins/attr_sql/pool_attributes.c
src/libimcv/imv/imv_agent.c
src/libimcv/plugins/imc_scanner/imc_scanner.c
src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c
src/libstrongswan/plugins/pem/pem_builder.c
src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
src/libstrongswan/plugins/x509/x509_pkcs10.c
src/libstrongswan/utils/identification.c

index 670ec76..b083d54 100644 (file)
@@ -106,14 +106,16 @@ static void build_binary_checksum(char *path)
                pos = strrchr(binary, '.');
                if (pos && streq(pos, ".so"))
                {
-                       snprintf(name, sizeof(name), "%.*s\",", pos - binary, binary);
+                       snprintf(name, sizeof(name), "%.*s\",", (int)(pos - binary),
+                                        binary);
                        if (streq(name, "libstrongswan\","))
                        {
                                snprintf(sname, sizeof(sname), "%s", "library_init");
                        }
                        else
                        {
-                               snprintf(sname, sizeof(sname), "%.*s_init", pos - binary, binary);
+                               snprintf(sname, sizeof(sname), "%.*s_init", (int)(pos - binary),
+                                                binary);
                        }
                        build_checksum(path, name, sname);
                }
index 00decdd..6491fd2 100644 (file)
@@ -289,7 +289,8 @@ static bool load_hooks()
                pos = strchr(name, '-');
                if (pos)
                {
-                       snprintf(buf, sizeof(buf), "%.*s_hook_create", pos - name, name);
+                       snprintf(buf, sizeof(buf), "%.*s_hook_create", (int)(pos - name),
+                                        name);
                }
                else
                {
index de70b7e..40045cc 100644 (file)
@@ -150,7 +150,7 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
                                if (reply.len && *reply.data)
                                {
                                        DBG1(DBG_LIB, "received mconsole error %d: %.*s",
-                                                reply.err, reply.len, reply.data);
+                                                reply.err, (int)reply.len, reply.data);
                                }
                                break;
                        }
index ed142b2..870ed1f 100644 (file)
@@ -264,7 +264,7 @@ static void process_filter_id(private_eap_radius_t *this, radius_message_t *msg)
                        case RAT_FILTER_ID:
                                filter_id = data;
                                DBG1(DBG_IKE, "received RADIUS attribute Filter-Id: "
-                                                         "'%.*s'", filter_id.len, filter_id.ptr);
+                                                         "'%.*s'", (int)filter_id.len, filter_id.ptr);
                                break;
                        default:
                                break;
index f09d144..ebc09c0 100644 (file)
@@ -722,7 +722,7 @@ static bool load_pin(private_stroke_cred_t *this, chunk_t line, int line_nr,
 
        if (key)
        {
-               DBG1(DBG_CFG, "  loaded private key from %.*s", sc.len, sc.ptr);
+               DBG1(DBG_CFG, "  loaded private key from %.*s", (int)sc.len, sc.ptr);
                this->creds->add_key(this->creds, key);
        }
        return TRUE;
index 856bd6c..396d5d8 100644 (file)
@@ -320,7 +320,7 @@ METHOD(recommendations_t, set_reason_string, TNC_Result,
        bool found = FALSE;
 
        DBG2(DBG_TNC, "IMV %u is setting reason string to '%.*s'",
-                id, reason.len, reason.ptr);
+                id, (int)reason.len, reason.ptr);
 
        enumerator = this->recs->create_enumerator(this->recs);
        while (enumerator->enumerate(enumerator, &entry))
@@ -345,7 +345,7 @@ METHOD(recommendations_t, set_reason_language, TNC_Result,
        bool found = FALSE;
 
        DBG2(DBG_TNC, "IMV %u is setting reason language to '%.*s'",
-                id, reason_lang.len, reason_lang.ptr);
+                id, (int)reason_lang.len, reason_lang.ptr);
 
        enumerator = this->recs->create_enumerator(this->recs);
        while (enumerator->enumerate(enumerator, &entry))
index 0abda8d..bca4398 100644 (file)
@@ -33,7 +33,7 @@ struct private_tnc_pdp_connections_t {
 
        /**
         * List of TNC PEP RADIUS Connections
-        */ 
+        */
        linked_list_t *list;
 };
 
@@ -94,13 +94,14 @@ static void dbg_nas_user(chunk_t nas_id, chunk_t user_name, bool not, char *op)
        if (nas_id.len)
        {
                DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s' NAS '%.*s'",
-                                          not ? "could not find" : op, user_name.len, user_name.ptr,
-                                          nas_id.len, nas_id.ptr);
+                                          not ? "could not find" : op, (int)user_name.len,
+                                          user_name.ptr, (int)nas_id.len, nas_id.ptr);
        }
        else
        {
-               DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s'", 
-                                          not ? "could not find" : op, user_name.len, user_name.ptr);
+               DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s'",
+                                          not ? "could not find" : op, (int)user_name.len,
+                                          user_name.ptr);
        }
 }
 
@@ -134,7 +135,7 @@ METHOD(tnc_pdp_connections_t, add, void,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        if (!found)
        {
                entry = malloc_thing(entry_t);
index 3b563a3..56858a8 100644 (file)
@@ -128,7 +128,7 @@ METHOD(tnccs_t, send_msg, TNC_Result,
                return TNC_RESULT_NO_LONG_MESSAGE_TYPES;
        }
        msg_type = (msg_vid << 8) | msg_subtype;
+
        pa_subtype_names = get_pa_subtype_names(msg_vid);
        if (pa_subtype_names)
        {
@@ -272,10 +272,10 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
 
                        reason_msg = (tnccs_reason_strings_msg_t*)msg;
                        reason_string = reason_msg->get_reason(reason_msg, &reason_lang);
-                       DBG2(DBG_TNC, "reason string is '%.*s'",   reason_string.len,
-                                                                                                         reason_string.ptr);
-                       DBG2(DBG_TNC, "reason language is '%.*s'", reason_lang.len,
-                                                                                                         reason_lang.ptr);
+                       DBG2(DBG_TNC, "reason string is '%.*s'", (int)reason_string.len,
+                                                                                                        reason_string.ptr);
+                       DBG2(DBG_TNC, "language code is '%.*s'", (int)reason_lang.len,
+                                                                                                        reason_lang.ptr);
                        break;
                }
                default:
@@ -311,7 +311,7 @@ METHOD(tls_t, process, status_t,
        data = chunk_create(buf, buflen);
        DBG1(DBG_TNC, "received TNCCS Batch (%u bytes) for Connection ID %u",
                                   data.len, this->connection_id);
-       DBG3(DBG_TNC, "%.*s", data.len, data.ptr);
+       DBG3(DBG_TNC, "%.*s", (int)data.len, data.ptr);
        batch = tnccs_batch_create_from_data(this->is_server, ++this->batch_id, data);
        status = batch->process(batch);
 
@@ -463,7 +463,7 @@ METHOD(tls_t, build, status_t,
                data = this->batch->get_encoding(this->batch);
                DBG1(DBG_TNC, "sending TNCCS Batch (%d bytes) for Connection ID %u",
                                           data.len, this->connection_id);
-               DBG3(DBG_TNC, "%.*s", data.len, data.ptr);
+               DBG3(DBG_TNC, "%.*s", (int)data.len, data.ptr);
                *msglen = 0;
 
                if (data.len > *buflen)
index f2e958c..44e1d27 100644 (file)
@@ -357,7 +357,7 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
                        lang = lang_msg->get_language_preference(lang_msg);
 
                        DBG2(DBG_TNC, "setting language preference to '%.*s'",
-                                                  lang.len, lang.ptr);
+                                                  (int)lang.len, lang.ptr);
                        this->recs->set_preferred_language(this->recs, lang);
                        break;
                }
@@ -369,9 +369,9 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
                        reason_msg = (pb_reason_string_msg_t*)msg;
                        reason_string = reason_msg->get_reason_string(reason_msg);
                        language_code = reason_msg->get_language_code(reason_msg);
-                       DBG2(DBG_TNC, "reason string is '%.*s'", reason_string.len,
+                       DBG2(DBG_TNC, "reason string is '%.*s'", (int)reason_string.len,
                                                                                                         reason_string.ptr);
-                       DBG2(DBG_TNC, "language code is '%.*s'", language_code.len,
+                       DBG2(DBG_TNC, "language code is '%.*s'", (int)language_code.len,
                                                                                                         language_code.ptr);
                        break;
                }
@@ -723,7 +723,7 @@ METHOD(tls_t, build, status_t,
                        {
                                this->batch_type = PB_BATCH_NONE;
                        }
-                       
+
                        status = ALREADY_DONE;
                }
                else
index 5c73974..d3fc06e 100644 (file)
@@ -492,7 +492,7 @@ void del_attr(char *name, char *pool, char *identity,
                        {
                                fprintf(stderr, "deleting %s attribute (%N) with value '%.*s'%s failed.\n",
                                                                name, configuration_attribute_type_names, type,
-                                                               blob_db.len, blob_db.ptr, id_pool_str);
+                                                               (int)blob_db.len, blob_db.ptr, id_pool_str);
                        }
 
                        else
@@ -514,7 +514,7 @@ void del_attr(char *name, char *pool, char *identity,
                {
                        printf("deleted %s attribute (%N) with value '%.*s'%s.\n",
                                   name, configuration_attribute_type_names, type,
-                                  blob_db.len, blob_db.ptr, id_pool_str);
+                                  (int)blob_db.len, blob_db.ptr, id_pool_str);
                }
                else
                {
@@ -555,7 +555,7 @@ void del_attr(char *name, char *pool, char *identity,
                                fprintf(stderr, "the %s attribute (%N) with value '%.*s'%s "
                                                                "was not found.\n", name,
                                                                 configuration_attribute_type_names, type,
-                                                                blob.len, blob.ptr, id_pool_str);
+                                                                (int)blob.len, blob.ptr, id_pool_str);
                        }
                }
        }
index d098595..fa04e02 100644 (file)
@@ -396,7 +396,7 @@ METHOD(imv_agent_t, create_state, TNC_Result,
        has_long = get_bool_attribute(this, conn_id, TNC_ATTRIBUTEID_HAS_LONG_TYPES);
        has_excl = get_bool_attribute(this, conn_id, TNC_ATTRIBUTEID_HAS_EXCLUSIVE);
        has_soh  = get_bool_attribute(this, conn_id, TNC_ATTRIBUTEID_HAS_SOH);
-       tnccs_p = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFTNCCS_PROTOCOL); 
+       tnccs_p = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFTNCCS_PROTOCOL);
        tnccs_v = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFTNCCS_VERSION);
        t_p = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFT_PROTOCOL);
        t_v = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFT_VERSION);
@@ -478,7 +478,7 @@ METHOD(imv_agent_t, change_state, TNC_Result,
                        DBG1(DBG_IMV, "IMV %u \"%s\" was notified of unknown state %u "
                                                  "for Connection ID %u",
                                                  this->id, this->name, new_state, connection_id);
-                       return TNC_RESULT_INVALID_PARAMETER;            
+                       return TNC_RESULT_INVALID_PARAMETER;
        }
        return TNC_RESULT_SUCCESS;
 }
@@ -716,8 +716,8 @@ METHOD(imv_agent_t, provide_recommendation, TNC_Result,
                        lang_len <= BUF_LEN)
                {
                        pref_lang.len = lang_len;
-                       DBG2(DBG_IMV, "preferred language is '%.*s'",
-                                                  pref_lang.len, pref_lang.ptr);
+                       DBG2(DBG_IMV, "preferred language is '%.*s'", (int)pref_lang.len,
+                                pref_lang.ptr);
                }
 
                /* find a reason string for the preferred or default language and set it */
index 58533ea..34c9359 100644 (file)
@@ -38,7 +38,7 @@ static const char imc_name[] = "Scanner";
 #define IMC_SUBTYPE            PA_SUBTYPE_ITA_SCANNER
 
 static imc_agent_t *imc_scanner;
+
 /**
  * see section 3.8.1 of TCG TNC IF-IMC Specification 1.3
  */
@@ -133,7 +133,7 @@ static bool do_netstat(ietf_attr_port_filter_t *attr)
                enumerator_t *enumerator;
                bool allowed, found = FALSE;
 
-               DBG2(DBG_IMC, "%.*s", strlen(buf)-1, buf);
+               DBG2(DBG_IMC, "%.*s", (int)(strlen(buf)-1), buf);
 
                if (n++ < 2)
                {
@@ -209,7 +209,7 @@ static bool do_netstat(ietf_attr_port_filter_t *attr)
                        }
                }
                enumerator->destroy(enumerator);
-               
+
                /* Skip the duplicate port entry */
                if (found)
                {
@@ -297,7 +297,7 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
                return TNC_RESULT_FATAL;
        }
 
-       /* parse received PA-TNC message and automatically handle any errors */ 
+       /* parse received PA-TNC message and automatically handle any errors */
        result = imc_scanner->receive_message(imc_scanner, state, msg, msg_vid,
                                                        msg_subtype, src_imv_id, dst_imc_id, &pa_tnc_msg);
 
index d1afd94..98cd700 100644 (file)
@@ -475,7 +475,8 @@ static bool login(ENGINE *engine, chunk_t keyid)
        {
                found = TRUE;
                key = shared->get_key(shared);
-               if (snprintf(pin, sizeof(pin), "%.*s", key.len, key.ptr) >= sizeof(pin))
+               if (snprintf(pin, sizeof(pin),
+                                        "%.*s", (int)key.len, key.ptr) >= sizeof(pin))
                {
                        continue;
                }
index efbf47d..9b97770 100644 (file)
@@ -285,7 +285,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
                                        else
                                        {
                                                DBG1(DBG_ASN, "  encryption algorithm '%.*s'"
-                                                        " not supported", dek.len, dek.ptr);
+                                                        " not supported", (int)dek.len, dek.ptr);
                                                return NOT_SUPPORTED;
                                        }
                                        eat_whitespace(&value);
index a81ec11..7536ce1 100644 (file)
@@ -109,7 +109,8 @@ static void find_certificates(private_pkcs11_creds_t *this,
                if (cert)
                {
                        DBG1(DBG_CFG, "    loaded %strusted cert '%.*s'",
-                                entry->trusted ? "" : "un", entry->label.len, entry->label.ptr);
+                                entry->trusted ? "" : "un", (int)entry->label.len,
+                                entry->label.ptr);
                        /* trusted certificates are also returned as untrusted */
                        this->untrusted->insert_last(this->untrusted, cert);
                        if (entry->trusted)
@@ -120,7 +121,7 @@ static void find_certificates(private_pkcs11_creds_t *this,
                else
                {
                        DBG1(DBG_CFG, "    loading cert '%.*s' failed",
-                                entry->label.len, entry->label.ptr);
+                               (int)entry->label.len, entry->label.ptr);
                }
                free(entry->value.ptr);
                free(entry->label.ptr);
index 5a9b2d9..9fa91fe 100644 (file)
@@ -334,7 +334,7 @@ static bool parse_challengePassword(private_x509_pkcs10_t *this, chunk_t blob, i
                return FALSE;
        }
        DBG2(DBG_ASN, "L%d - challengePassword:", level);
-       DBG4(DBG_ASN, "  '%.*s'", blob.len, blob.ptr);
+       DBG4(DBG_ASN, "  '%.*s'", (int)blob.len, blob.ptr);
        return TRUE;
 }
 
index 08a1679..2669c2d 100644 (file)
@@ -310,7 +310,7 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
                len -= written;
 
                chunk_printable(data, &printable, '?');
-               written = snprintf(buf, len, "%.*s", printable.len, printable.ptr);
+               written = snprintf(buf, len, "%.*s", (int)printable.len, printable.ptr);
                chunk_free(&printable);
                if (written < 0 || written >= len)
                {
@@ -791,7 +791,7 @@ int identification_printf_hook(printf_hook_data_t *data,
                case ID_RFC822_ADDR:
                case ID_DER_ASN1_GN_URI:
                        chunk_printable(this->encoded, &proper, '?');
-                       snprintf(buf, sizeof(buf), "%.*s", proper.len, proper.ptr);
+                       snprintf(buf, sizeof(buf), "%.*s", (int)proper.len, proper.ptr);
                        chunk_free(&proper);
                        break;
                case ID_DER_ASN1_DN:
@@ -804,8 +804,8 @@ int identification_printf_hook(printf_hook_data_t *data,
                        if (chunk_printable(this->encoded, NULL, '?') &&
                                this->encoded.len != HASH_SIZE_SHA1)
                        {       /* fully printable, use ascii version */
-                               snprintf(buf, sizeof(buf), "%.*s",
-                                                this->encoded.len, this->encoded.ptr);
+                               snprintf(buf, sizeof(buf), "%.*s", (int)this->encoded.len,
+                                                this->encoded.ptr);
                        }
                        else
                        {       /* not printable, hex dump */
@@ -1024,7 +1024,7 @@ identification_t * identification_create_from_data(chunk_t data)
        char buf[data.len + 1];
 
        /* use string constructor */
-       snprintf(buf, sizeof(buf), "%.*s", data.len, data.ptr);
+       snprintf(buf, sizeof(buf), "%.*s", (int)data.len, data.ptr);
        return identification_create_from_string(buf);
 }