From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C870F7EB0 for ; Tue, 16 Dec 2014 17:49:30 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 16 Dec 2014 08:30:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,587,1413270000"; d="scan'208";a="624674892" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 16 Dec 2014 08:30:25 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sBGGUPF9008786; Tue, 16 Dec 2014 16:30:25 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sBGGUOj5022314; Tue, 16 Dec 2014 16:30:24 GMT Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id sBGGUOgs022310; Tue, 16 Dec 2014 16:30:24 GMT From: Bruce Richardson To: dev@dpdk.org Date: Tue, 16 Dec 2014 16:30:24 +0000 Message-Id: <1418747424-22254-4-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1418747424-22254-1-git-send-email-bruce.richardson@intel.com> References: <1418747424-22254-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 3/3] eal: for safety, use snprintf instead of sprintf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 16:49:31 -0000 When printing the version string to a local variable, use snprintf for safety over sprintf. This is general good practice even if the values to print are all hard-coded. Signed-off-by: Bruce Richardson --- lib/librte_eal/common/include/rte_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h index 54cb9a6..356207c 100644 --- a/lib/librte_eal/common/include/rte_version.h +++ b/lib/librte_eal/common/include/rte_version.h @@ -104,13 +104,13 @@ rte_version(void) if (version[0] != 0) return version; if (strlen(RTE_VER_SUFFIX) == 0) - sprintf(version, "%s %d.%d.%d", + snprintf(version, sizeof(version), "%s %d.%d.%d", RTE_VER_PREFIX, RTE_VER_MAJOR, RTE_VER_MINOR, RTE_VER_PATCH_LEVEL); else - sprintf(version, "%s %d.%d.%d%s%d", + snprintf(version, sizeof(version), "%s %d.%d.%d%s%d", RTE_VER_PREFIX, RTE_VER_MAJOR, RTE_VER_MINOR, -- 1.9.3