Make sure first argument is an int when using %.*s to print e.g. chunks

This commit is contained in:
Tobias Brunner
2012-09-28 18:01:49 +02:00
parent 4bc24ba794
commit a05f3b2021
17 changed files with 52 additions and 46 deletions
+4 -2
View File
@@ -106,14 +106,16 @@ static void build_binary_checksum(char *path)
pos = strrchr(binary, '.'); pos = strrchr(binary, '.');
if (pos && streq(pos, ".so")) 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\",")) if (streq(name, "libstrongswan\","))
{ {
snprintf(sname, sizeof(sname), "%s", "library_init"); snprintf(sname, sizeof(sname), "%s", "library_init");
} }
else 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); build_checksum(path, name, sname);
} }
+2 -1
View File
@@ -289,7 +289,8 @@ static bool load_hooks()
pos = strchr(name, '-'); pos = strchr(name, '-');
if (pos) if (pos)
{ {
snprintf(buf, sizeof(buf), "%.*s_hook_create", pos - name, name); snprintf(buf, sizeof(buf), "%.*s_hook_create", (int)(pos - name),
name);
} }
else else
{ {
+1 -1
View File
@@ -150,7 +150,7 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
if (reply.len && *reply.data) if (reply.len && *reply.data)
{ {
DBG1(DBG_LIB, "received mconsole error %d: %.*s", DBG1(DBG_LIB, "received mconsole error %d: %.*s",
reply.err, reply.len, reply.data); reply.err, (int)reply.len, reply.data);
} }
break; break;
} }
@@ -264,7 +264,7 @@ static void process_filter_id(private_eap_radius_t *this, radius_message_t *msg)
case RAT_FILTER_ID: case RAT_FILTER_ID:
filter_id = data; filter_id = data;
DBG1(DBG_IKE, "received RADIUS attribute Filter-Id: " DBG1(DBG_IKE, "received RADIUS attribute Filter-Id: "
"'%.*s'", filter_id.len, filter_id.ptr); "'%.*s'", (int)filter_id.len, filter_id.ptr);
break; break;
default: default:
break; break;
+1 -1
View File
@@ -722,7 +722,7 @@ static bool load_pin(private_stroke_cred_t *this, chunk_t line, int line_nr,
if (key) 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); this->creds->add_key(this->creds, key);
} }
return TRUE; return TRUE;
@@ -320,7 +320,7 @@ METHOD(recommendations_t, set_reason_string, TNC_Result,
bool found = FALSE; bool found = FALSE;
DBG2(DBG_TNC, "IMV %u is setting reason string to '%.*s'", 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); enumerator = this->recs->create_enumerator(this->recs);
while (enumerator->enumerate(enumerator, &entry)) while (enumerator->enumerate(enumerator, &entry))
@@ -345,7 +345,7 @@ METHOD(recommendations_t, set_reason_language, TNC_Result,
bool found = FALSE; bool found = FALSE;
DBG2(DBG_TNC, "IMV %u is setting reason language to '%.*s'", 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); enumerator = this->recs->create_enumerator(this->recs);
while (enumerator->enumerate(enumerator, &entry)) while (enumerator->enumerate(enumerator, &entry))
@@ -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) if (nas_id.len)
{ {
DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s' NAS '%.*s'", DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s' NAS '%.*s'",
not ? "could not find" : op, user_name.len, user_name.ptr, not ? "could not find" : op, (int)user_name.len,
nas_id.len, nas_id.ptr); user_name.ptr, (int)nas_id.len, nas_id.ptr);
} }
else else
{ {
DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s'", DBG1(DBG_CFG, "%s RADIUS connection for user '%.*s'",
not ? "could not find" : op, user_name.len, user_name.ptr); not ? "could not find" : op, (int)user_name.len,
user_name.ptr);
} }
} }
+6 -6
View File
@@ -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_msg = (tnccs_reason_strings_msg_t*)msg;
reason_string = reason_msg->get_reason(reason_msg, &reason_lang); reason_string = reason_msg->get_reason(reason_msg, &reason_lang);
DBG2(DBG_TNC, "reason string is '%.*s'", reason_string.len, DBG2(DBG_TNC, "reason string is '%.*s'", (int)reason_string.len,
reason_string.ptr); reason_string.ptr);
DBG2(DBG_TNC, "reason language is '%.*s'", reason_lang.len, DBG2(DBG_TNC, "language code is '%.*s'", (int)reason_lang.len,
reason_lang.ptr); reason_lang.ptr);
break; break;
} }
default: default:
@@ -311,7 +311,7 @@ METHOD(tls_t, process, status_t,
data = chunk_create(buf, buflen); data = chunk_create(buf, buflen);
DBG1(DBG_TNC, "received TNCCS Batch (%u bytes) for Connection ID %u", DBG1(DBG_TNC, "received TNCCS Batch (%u bytes) for Connection ID %u",
data.len, this->connection_id); 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); batch = tnccs_batch_create_from_data(this->is_server, ++this->batch_id, data);
status = batch->process(batch); status = batch->process(batch);
@@ -463,7 +463,7 @@ METHOD(tls_t, build, status_t,
data = this->batch->get_encoding(this->batch); data = this->batch->get_encoding(this->batch);
DBG1(DBG_TNC, "sending TNCCS Batch (%d bytes) for Connection ID %u", DBG1(DBG_TNC, "sending TNCCS Batch (%d bytes) for Connection ID %u",
data.len, this->connection_id); data.len, this->connection_id);
DBG3(DBG_TNC, "%.*s", data.len, data.ptr); DBG3(DBG_TNC, "%.*s", (int)data.len, data.ptr);
*msglen = 0; *msglen = 0;
if (data.len > *buflen) if (data.len > *buflen)
+3 -3
View 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); lang = lang_msg->get_language_preference(lang_msg);
DBG2(DBG_TNC, "setting language preference to '%.*s'", 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); this->recs->set_preferred_language(this->recs, lang);
break; 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_msg = (pb_reason_string_msg_t*)msg;
reason_string = reason_msg->get_reason_string(reason_msg); reason_string = reason_msg->get_reason_string(reason_msg);
language_code = reason_msg->get_language_code(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); 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); language_code.ptr);
break; break;
} }
@@ -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", fprintf(stderr, "deleting %s attribute (%N) with value '%.*s'%s failed.\n",
name, configuration_attribute_type_names, type, 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 else
@@ -514,7 +514,7 @@ void del_attr(char *name, char *pool, char *identity,
{ {
printf("deleted %s attribute (%N) with value '%.*s'%s.\n", printf("deleted %s attribute (%N) with value '%.*s'%s.\n",
name, configuration_attribute_type_names, type, 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 else
{ {
@@ -555,7 +555,7 @@ void del_attr(char *name, char *pool, char *identity,
fprintf(stderr, "the %s attribute (%N) with value '%.*s'%s " fprintf(stderr, "the %s attribute (%N) with value '%.*s'%s "
"was not found.\n", name, "was not found.\n", name,
configuration_attribute_type_names, type, configuration_attribute_type_names, type,
blob.len, blob.ptr, id_pool_str); (int)blob.len, blob.ptr, id_pool_str);
} }
} }
} }
+2 -2
View File
@@ -716,8 +716,8 @@ METHOD(imv_agent_t, provide_recommendation, TNC_Result,
lang_len <= BUF_LEN) lang_len <= BUF_LEN)
{ {
pref_lang.len = lang_len; pref_lang.len = lang_len;
DBG2(DBG_IMV, "preferred language is '%.*s'", DBG2(DBG_IMV, "preferred language is '%.*s'", (int)pref_lang.len,
pref_lang.len, pref_lang.ptr); pref_lang.ptr);
} }
/* find a reason string for the preferred or default language and set it */ /* find a reason string for the preferred or default language and set it */
@@ -133,7 +133,7 @@ static bool do_netstat(ietf_attr_port_filter_t *attr)
enumerator_t *enumerator; enumerator_t *enumerator;
bool allowed, found = FALSE; bool allowed, found = FALSE;
DBG2(DBG_IMC, "%.*s", strlen(buf)-1, buf); DBG2(DBG_IMC, "%.*s", (int)(strlen(buf)-1), buf);
if (n++ < 2) if (n++ < 2)
{ {
@@ -475,7 +475,8 @@ static bool login(ENGINE *engine, chunk_t keyid)
{ {
found = TRUE; found = TRUE;
key = shared->get_key(shared); 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; continue;
} }
+1 -1
View File
@@ -285,7 +285,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
else else
{ {
DBG1(DBG_ASN, " encryption algorithm '%.*s'" DBG1(DBG_ASN, " encryption algorithm '%.*s'"
" not supported", dek.len, dek.ptr); " not supported", (int)dek.len, dek.ptr);
return NOT_SUPPORTED; return NOT_SUPPORTED;
} }
eat_whitespace(&value); eat_whitespace(&value);
@@ -109,7 +109,8 @@ static void find_certificates(private_pkcs11_creds_t *this,
if (cert) if (cert)
{ {
DBG1(DBG_CFG, " loaded %strusted cert '%.*s'", 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 */ /* trusted certificates are also returned as untrusted */
this->untrusted->insert_last(this->untrusted, cert); this->untrusted->insert_last(this->untrusted, cert);
if (entry->trusted) if (entry->trusted)
@@ -120,7 +121,7 @@ static void find_certificates(private_pkcs11_creds_t *this,
else else
{ {
DBG1(DBG_CFG, " loading cert '%.*s' failed", 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->value.ptr);
free(entry->label.ptr); free(entry->label.ptr);
+1 -1
View File
@@ -334,7 +334,7 @@ static bool parse_challengePassword(private_x509_pkcs10_t *this, chunk_t blob, i
return FALSE; return FALSE;
} }
DBG2(DBG_ASN, "L%d - challengePassword:", level); 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; return TRUE;
} }
+5 -5
View File
@@ -310,7 +310,7 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
len -= written; len -= written;
chunk_printable(data, &printable, '?'); 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); chunk_free(&printable);
if (written < 0 || written >= len) if (written < 0 || written >= len)
{ {
@@ -791,7 +791,7 @@ int identification_printf_hook(printf_hook_data_t *data,
case ID_RFC822_ADDR: case ID_RFC822_ADDR:
case ID_DER_ASN1_GN_URI: case ID_DER_ASN1_GN_URI:
chunk_printable(this->encoded, &proper, '?'); 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); chunk_free(&proper);
break; break;
case ID_DER_ASN1_DN: case ID_DER_ASN1_DN:
@@ -804,8 +804,8 @@ int identification_printf_hook(printf_hook_data_t *data,
if (chunk_printable(this->encoded, NULL, '?') && if (chunk_printable(this->encoded, NULL, '?') &&
this->encoded.len != HASH_SIZE_SHA1) this->encoded.len != HASH_SIZE_SHA1)
{ /* fully printable, use ascii version */ { /* fully printable, use ascii version */
snprintf(buf, sizeof(buf), "%.*s", snprintf(buf, sizeof(buf), "%.*s", (int)this->encoded.len,
this->encoded.len, this->encoded.ptr); this->encoded.ptr);
} }
else else
{ /* not printable, hex dump */ { /* not printable, hex dump */
@@ -1024,7 +1024,7 @@ identification_t * identification_create_from_data(chunk_t data)
char buf[data.len + 1]; char buf[data.len + 1];
/* use string constructor */ /* 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); return identification_create_from_string(buf);
} }