From patchwork Sun Dec 9 11:06:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Garrett Cooper X-Patchwork-Id: 1853621 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D60893FCF2 for ; Sun, 9 Dec 2012 11:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755032Ab2LILGc (ORCPT ); Sun, 9 Dec 2012 06:06:32 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:37828 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754984Ab2LILGb (ORCPT ); Sun, 9 Dec 2012 06:06:31 -0500 Received: by mail-pa0-f46.google.com with SMTP id bh2so1400474pad.19 for ; Sun, 09 Dec 2012 03:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:user-agent:mime-version :content-type; bh=Fjefi449AyVAC0cnvg+eJdqxtwS4LOlHH7+sexl4Oe8=; b=F3birr6i/I+SJz9aIZk4p95/5/Zw6JrFXq8SaoTSKALIQd1xmiljDPNV8ToH7EJ3r/ 7DaMN5Jn0WwszllGfKsmYyITJ+ITN4Dbzh4OqEnSuASK5vAAFjz3nH/s8csmjfiJrzQE wiqRrTh5UeWiT+cbvyB7BO9DZ42kQi41gnX0aCBUx/rKQ5tAYfyhvCvu1FAhJTIk1mXP lOxr3j6g7NSDy8/bg77RCabSnq1PbZRN6d2wxl9ejcB51BcoKatBGr790KgUPct5Prfg dL3+FwMHEw/+vQaLqmhgaMXC06PtOFBSdCcMo2Xaj0SWx2hqw5xDhUO5FunxxBpGB8gT Pd3g== Received: by 10.68.212.200 with SMTP id nm8mr9363197pbc.4.1355051191077; Sun, 09 Dec 2012 03:06:31 -0800 (PST) Received: from c-24-19-191-56.hsd1.wa.comcast.net (c-24-19-191-56.hsd1.wa.comcast.net. [24.19.191.56]) by mx.google.com with ESMTPS id sg7sm9926143pbb.50.2012.12.09.03.06.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Dec 2012 03:06:30 -0800 (PST) Date: Sun, 9 Dec 2012 03:06:25 -0800 (PST) From: Garrett Cooper To: linux-rdma@vger.kernel.org Subject: [PATCH 2/3] Fix -Wformat-security warnings with clang Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org clang with -Wformat-security warnings is extremely paranoid when it come to calling printf-like functions like osm_log* with a variable content buffer of some kind. This commit explicitly uses the "%s" format string to make formatting the variable buffer safer. Signed-off-by: Garrett Cooper --- opensm/osm_helper.c | 96 ++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/opensm/osm_helper.c b/opensm/osm_helper.c index e13b044..10b88d7 100644 --- a/opensm/osm_helper.c +++ b/opensm/osm_helper.c @@ -888,7 +888,7 @@ void osm_dump_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid, osm_dump_port_info_to_buf(node_guid, port_guid, port_num, p_pi, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); /* show the capabilities mask */ if (p_pi->capability_mask) { @@ -910,7 +910,7 @@ void osm_dump_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid, osm_dump_port_info_to_buf(node_guid, port_guid, port_num, p_pi, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); /* show the capabilities mask */ if (p_pi->capability_mask) { @@ -955,7 +955,7 @@ void osm_dump_mlnx_ext_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid, osm_dump_mlnx_ext_port_info_to_buf(node_guid, port_guid, port_num, p_pi, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -970,7 +970,7 @@ void osm_dump_mlnx_ext_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_gui osm_dump_mlnx_ext_port_info_to_buf(node_guid, port_guid, port_num, p_pi, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1072,7 +1072,7 @@ void osm_dump_portinfo_record(IN osm_log_t * p_log, osm_dump_portinfo_record_to_buf(p_pir, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); /* show the capabilities mask */ if (p_pi->capability_mask) { @@ -1094,7 +1094,7 @@ void osm_dump_portinfo_record_v2(IN osm_log_t * p_log, osm_dump_portinfo_record_to_buf(p_pir, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); /* show the capabilities mask */ if (p_pi->capability_mask) { @@ -1146,7 +1146,7 @@ void osm_dump_guid_info(IN osm_log_t * p_log, IN ib_net64_t node_guid, osm_dump_guid_info_to_buf(node_guid, port_guid, block_num, p_gi, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1162,7 +1162,7 @@ void osm_dump_guid_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid, osm_dump_guid_info_to_buf(node_guid, port_guid, block_num, p_gi, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1207,7 +1207,7 @@ void osm_dump_guidinfo_record(IN osm_log_t * p_log, osm_dump_guidinfo_record_to_buf(p_gir, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1221,7 +1221,7 @@ void osm_dump_guidinfo_record_v2(IN osm_log_t * p_log, osm_dump_guidinfo_record_to_buf(p_gir, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1264,7 +1264,7 @@ void osm_dump_node_info(IN osm_log_t * p_log, IN const ib_node_info_t * p_ni, osm_dump_node_info_to_buf(p_ni, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1276,7 +1276,7 @@ void osm_dump_node_info_v2(IN osm_log_t * p_log, IN const ib_node_info_t * p_ni, osm_dump_node_info_to_buf(p_ni, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1333,7 +1333,7 @@ void osm_dump_node_record(IN osm_log_t * p_log, osm_dump_node_record_to_buf(p_nr, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1347,7 +1347,7 @@ void osm_dump_node_record_v2(IN osm_log_t * p_log, osm_dump_node_record_to_buf(p_nr, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1401,7 +1401,7 @@ void osm_dump_path_record(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr, osm_dump_path_record_to_buf(p_pr, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1413,7 +1413,7 @@ void osm_dump_path_record_v2(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr osm_dump_path_record_to_buf(p_pr, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1486,7 +1486,7 @@ void osm_dump_multipath_record(IN osm_log_t * p_log, osm_dump_multipath_record_to_buf(p_mpr, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1500,7 +1500,7 @@ void osm_dump_multipath_record_v2(IN osm_log_t * p_log, osm_dump_multipath_record_to_buf(p_mpr, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1547,7 +1547,7 @@ void osm_dump_mc_record(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr, osm_dump_mc_record_to_buf(p_mcmr, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1559,7 +1559,7 @@ void osm_dump_mc_record_v2(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mc osm_dump_mc_record_to_buf(p_mcmr, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1664,7 +1664,7 @@ void osm_dump_service_record(IN osm_log_t * p_log, osm_dump_service_record_to_buf(p_sr, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1678,7 +1678,7 @@ void osm_dump_service_record_v2(IN osm_log_t * p_log, osm_dump_service_record_to_buf(p_sr, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1768,7 +1768,7 @@ void osm_dump_inform_info(IN osm_log_t * p_log, else osm_dump_inform_info_to_buf(p_ii, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1785,7 +1785,7 @@ void osm_dump_inform_info_v2(IN osm_log_t * p_log, else osm_dump_inform_info_to_buf(p_ii, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1897,7 +1897,7 @@ void osm_dump_inform_info_record(IN osm_log_t * p_log, else osm_dump_inform_info_record_to_buf(p_iir, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1914,7 +1914,7 @@ void osm_dump_inform_info_record_v2(IN osm_log_t * p_log, else osm_dump_inform_info_record_to_buf(p_iir, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -1945,7 +1945,7 @@ void osm_dump_link_record(IN osm_log_t * p_log, osm_dump_link_record_to_buf(p_lr, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -1959,7 +1959,7 @@ void osm_dump_link_record_v2(IN osm_log_t * p_log, osm_dump_link_record_to_buf(p_lr, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2002,7 +2002,7 @@ void osm_dump_switch_info(IN osm_log_t * p_log, osm_dump_switch_info_to_buf(p_si, buf); - osm_log(p_log, OSM_LOG_VERBOSE, buf); + osm_log(p_log, OSM_LOG_VERBOSE, "%s", buf); } } @@ -2016,7 +2016,7 @@ void osm_dump_switch_info_v2(IN osm_log_t * p_log, osm_dump_switch_info_to_buf(p_si, buf); - osm_log_v2(p_log, OSM_LOG_VERBOSE, file_id, buf); + osm_log_v2(p_log, OSM_LOG_VERBOSE, file_id, "%s", buf); } } @@ -2066,7 +2066,7 @@ void osm_dump_switch_info_record(IN osm_log_t * p_log, osm_dump_switch_info_record_to_buf(p_sir, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -2080,7 +2080,7 @@ void osm_dump_switch_info_record_v2(IN osm_log_t * p_log, osm_dump_switch_info_record_to_buf(p_sir, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2120,7 +2120,7 @@ void osm_dump_pkey_block(IN osm_log_t * p_log, IN uint64_t port_guid, osm_dump_pkey_block_to_buf(port_guid, block_num, port_num, p_pkey_tbl, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -2136,7 +2136,7 @@ void osm_dump_pkey_block_v2(IN osm_log_t * p_log, IN uint64_t port_guid, osm_dump_pkey_block_to_buf(port_guid, block_num, port_num, p_pkey_tbl, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2179,7 +2179,7 @@ void osm_dump_slvl_map_table(IN osm_log_t * p_log, IN uint64_t port_guid, osm_dump_slvl_map_table_to_buf(port_guid, in_port_num, out_port_num, p_slvl_tbl, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -2195,7 +2195,7 @@ void osm_dump_slvl_map_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid, osm_dump_slvl_map_table_to_buf(port_guid, in_port_num, out_port_num, p_slvl_tbl, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2237,7 +2237,7 @@ void osm_dump_vl_arb_table(IN osm_log_t * p_log, IN uint64_t port_guid, osm_dump_vl_arb_table_to_buf(port_guid, block_num, port_num, p_vla_tbl, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -2253,7 +2253,7 @@ void osm_dump_vl_arb_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid, osm_dump_vl_arb_table_to_buf(port_guid, block_num, port_num, p_vla_tbl, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2285,7 +2285,7 @@ void osm_dump_sm_info(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi, osm_dump_sm_info_to_buf(p_smi, buf); - osm_log(p_log, OSM_LOG_DEBUG, buf); + osm_log(p_log, OSM_LOG_DEBUG, "%s", buf); } } @@ -2297,7 +2297,7 @@ void osm_dump_sm_info_v2(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi, osm_dump_sm_info_to_buf(p_smi, buf); - osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, buf); + osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, "%s", buf); } } @@ -2336,7 +2336,7 @@ void osm_dump_sm_info_record(IN osm_log_t * p_log, osm_dump_sm_info_record_to_buf(p_smir, buf); - osm_log(p_log, OSM_LOG_DEBUG, buf); + osm_log(p_log, OSM_LOG_DEBUG, "%s", buf); } } @@ -2350,7 +2350,7 @@ void osm_dump_sm_info_record_v2(IN osm_log_t * p_log, osm_dump_sm_info_record_to_buf(p_smir, buf); - osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, buf); + osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, "%s", buf); } } @@ -2569,7 +2569,7 @@ void osm_dump_notice(IN osm_log_t * p_log, else osm_dump_notice_to_buf(p_ntci, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -2585,7 +2585,7 @@ void osm_dump_notice_v2(IN osm_log_t * p_log, else osm_dump_notice_to_buf(p_ntci, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2700,7 +2700,7 @@ void osm_dump_dr_smp(IN osm_log_t * p_log, IN const ib_smp_t * p_smp, osm_dump_dr_smp_to_buf(p_smp, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s", buf); } } @@ -2712,7 +2712,7 @@ void osm_dump_dr_smp_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp, osm_dump_dr_smp_to_buf(p_smp, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } } @@ -2774,7 +2774,7 @@ void osm_dump_sa_mad(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad, osm_dump_sa_mad_to_buf(p_mad, buf); - osm_log(p_log, log_level, buf); + osm_log(p_log, log_level, "%s\n", buf); } } @@ -2786,7 +2786,7 @@ void osm_dump_sa_mad_v2(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad, osm_dump_sa_mad_to_buf(p_mad, buf); - osm_log_v2(p_log, log_level, file_id, buf); + osm_log_v2(p_log, log_level, file_id, "%s", buf); } }