From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 3533F9E7 for ; Tue, 7 Feb 2017 10:18:57 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 07 Feb 2017 01:18:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,345,1477983600"; d="scan'208";a="1104077391" Received: from gklab-246-020.igk.intel.com (HELO Sent) ([10.217.246.20]) by fmsmga001.fm.intel.com with SMTP; 07 Feb 2017 01:18:53 -0800 Received: by Sent (sSMTP sendmail emulation); Tue, 07 Feb 2017 10:20:20 +0100 From: Aleksander Gajewski To: declan.doherty@intel.com Cc: dev@dpdk.org, Aleksander Gajewski Date: Tue, 7 Feb 2017 10:20:18 +0100 Message-Id: <1486459218-11455-1-git-send-email-aleksanderx.gajewski@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] app/test-crypto-perf: fix buffer not null terminated X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Feb 2017 09:18:58 -0000 Fix problem: the string buffer may not have a null terminator if the source string's length is equal to the buffer size. Coverity issue: 141069 Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Aleksander Gajewski --- app/test-crypto-perf/cperf_options_parsing.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 3b7342d..691e788 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -198,7 +198,8 @@ struct name_id_map { if (strlen(arg) > (sizeof(opts->device_type) - 1)) return -1; - strncpy(opts->device_type, arg, sizeof(opts->device_type)); + strncpy(opts->device_type, arg, sizeof(opts->device_type) - 1); + *(opts->device_type + sizeof(opts->device_type) - 1) = '\0'; return 0; } -- 1.9.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.