From patchwork Thu Jul 26 09:55:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10545511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51EA5157A for ; Thu, 26 Jul 2018 09:55:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FBD92AE84 for ; Thu, 26 Jul 2018 09:55:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33EA32AF48; Thu, 26 Jul 2018 09:55:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B62672AE84 for ; Thu, 26 Jul 2018 09:55:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729111AbeGZLLM (ORCPT ); Thu, 26 Jul 2018 07:11:12 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:44259 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729029AbeGZLLM (ORCPT ); Thu, 26 Jul 2018 07:11:12 -0400 Received: by mail-qk0-f193.google.com with SMTP id v17-v6so586731qkb.11 for ; Thu, 26 Jul 2018 02:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=8cm+25wlKHiX4CNt1T6df6Orj17BbaeYy3+TkBQCIyI=; b=kcEMHz/Zrd3rtRiZSHlWJjg5PbxqgmRLkQEGbOFmgRnhJyc66/TwhsnUgsLCEEzSoZ mz4x2m3AiI+el4PJ76L5pzRkZqT7J7N4wRLivFRlQEi0Ky+hUEFRYiTEOiHgxN9NpQDw /CkwyGEd0P9iStLUoizpauVD6Pyr6QNSvfRLmKvAJfobym0hdMpYf/tCd1rCP5AR8rVd j6Gca0JEH/mfTGL+efioOfFSd8Raohcc9qfpr1MIf+HQB4+OIW6UwKP2JwOj/11+NitN ehmuWF1gZ7bofi0W8OiR5GQ0gI7d8bPCVucRdxkLX7D76ktBMEJUxi6SUw9fatcMj7Mn cvbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=8cm+25wlKHiX4CNt1T6df6Orj17BbaeYy3+TkBQCIyI=; b=cSX1/F0JWsDRYl/HFoMdt9D6PN7y4XXN+hqzK4xCSmWKpW3W5sEmQL8Juy8GkdwTMZ 2+6oMIWekoRDPlVTZkRoZV/9oZjwEIyNGd3D9neds5DnFrn2Q0HXa0iCb+pH0j8nTuLA kiNWwcSE2xF0GKQEMP+s+lMrr+Q9f+r+IXVFEoK+qPxwm3rEP5gTvmQVchmTLINHJL1H LwzkW7yyYkM7UMb+ULPE5MfCVy+6D4MSS2x90C6t4VfDpjDnt9d4qlPy6pnTzMrtxvWP 1ba7Jjl/K4v4LrCYzKgkF3O5HOP7mFXnHb4KA2kJCkdQ8STAYnhzPJ1k2KD4JqqAgf7N qHVQ== X-Gm-Message-State: AOUpUlHhkOXKVZdx2EtwY4Y+0KKfYFr2s3szf1GC5saS3chEn9vAFOrY Ob97gGdFeNJsyxp7Cr+aJwYOdgjl/RQ= X-Google-Smtp-Source: AAOMgpeM4I9Mdy4H69KOA7VntiynoM+ziIi7bFq2e4W9DRuiUEI0tcT6eAPplxeQxrKESvyFZL0ZWQ== X-Received: by 2002:a37:5e03:: with SMTP id s3-v6mr979304qkb.339.1532598907672; Thu, 26 Jul 2018 02:55:07 -0700 (PDT) Received: from [192.168.1.183] (c-73-142-227-196.hsd1.ma.comcast.net. [73.142.227.196]) by smtp.googlemail.com with ESMTPSA id l22-v6sm561087qkh.72.2018.07.26.02.55.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 02:55:07 -0700 (PDT) To: Honggang LI Cc: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCHv2 opensm] osm_sm_mad_ctrl.c: Reduce path buffer sizes to avoid format truncation in log_rcv_cb_error Message-ID: <34122fe3-bf91-04c4-0665-fe663ce6dfee@dev.mellanox.co.il> Date: Thu, 26 Jul 2018 05:55:06 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP make[2]: Entering directory '/home/honli/upstream-repos/opensm/opensm' depbase=`echo osm_sm_mad_ctrl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -DHAVE_CONFIG_H -I. -I../include -I../include/opensm -I./../include -I./../../libibumad/include -I/usr/local/include -Werror -Wall -Wwrite-strings -g -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE=1 -g -O2 -MT osm_sm_mad_ctrl.o -MD -MP -MF $depbase.Tpo -c -o osm_sm_mad_ctrl.o osm_sm_mad_ctrl.c &&\ mv -f $depbase.Tpo $depbase.Po osm_sm_mad_ctrl.c: In function ‘log_rcv_cb_error’: osm_sm_mad_ctrl.c:571:28: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4078 [-Werror=format-truncation=] "\n\t\t\tInitial path: %s Return path: %s", ^~ ipath, rpath); ~~~~~ osm_sm_mad_ctrl.c:570:3: note: ‘snprintf’ output between 33 and 8223 bytes into a destination of size 4096 snprintf(buf, sizeof(buf), ^~~~~~~~~~~~~~~~~~~~~~~~~~ "\n\t\t\tInitial path: %s Return path: %s", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ipath, rpath); ~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Honggang Li Signed-off-by: Hal Rosenstock Acked-by: Honggang Li --- opensm/osm_sm_mad_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensm/osm_sm_mad_ctrl.c b/opensm/osm_sm_mad_ctrl.c index ebac558..5d1323f 100644 --- a/opensm/osm_sm_mad_ctrl.c +++ b/opensm/osm_sm_mad_ctrl.c @@ -560,7 +560,7 @@ static void log_rcv_cb_error(osm_log_t *p_log, ib_smp_t *p_smp, ib_net16_t statu uint32_t i; if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) { - char ipath[BUF_SIZE], rpath[BUF_SIZE]; + char ipath[256], rpath[256]; int ni = sprintf(ipath, "%d", p_smp->initial_path[0]); int nr = sprintf(rpath, "%d", p_smp->return_path[0]); for (i = 1; i <= p_smp->hop_count; i++) {