From: Tobias Brunner Date: Fri, 22 Mar 2013 10:34:16 +0000 (+0100) Subject: Check return value of asprintf(3) when converting AR identity X-Git-Tag: 5.0.3rc1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03237238b8c3d4a00f5414adeb02390548b1710b;p=thirdparty%2Fstrongswan.git Check return value of asprintf(3) when converting AR identity Using chunk_t.ptr as target was also not optimal as it resulted in a compiler warning. --- diff --git a/src/libcharon/plugins/tnc_tnccs/tnc_tnccs_manager.c b/src/libcharon/plugins/tnc_tnccs/tnc_tnccs_manager.c index 76d5e1d9ff..36bab7068f 100644 --- a/src/libcharon/plugins/tnc_tnccs/tnc_tnccs_manager.c +++ b/src/libcharon/plugins/tnc_tnccs/tnc_tnccs_manager.c @@ -719,6 +719,7 @@ METHOD(tnccs_manager_t, get_attribute, TNC_Result, tncif_identity_t *tnc_id; u_int32_t id_type, subject_type; chunk_t id_value; + char *id_str; TNC_Result result; list = linked_list_create(); @@ -752,9 +753,10 @@ METHOD(tnccs_manager_t, get_attribute, TNC_Result, id_type = TNC_ID_UNKNOWN; subject_type = TNC_SUBJECT_UNKNOWN; } - if (id_type != TNC_ID_UNKNOWN) + if (id_type != TNC_ID_UNKNOWN && + asprintf(&id_str, "%Y", peer) >= 0) { - id_value.len = asprintf(&id_value.ptr, "%Y", peer); + id_value = chunk_from_str(id_str); tnc_id = tncif_identity_create( pen_type_create(PEN_TCG, id_type), id_value, pen_type_create(PEN_TCG, subject_type),