From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 9E7922082; Thu, 17 Jan 2019 17:44:55 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id D323714D4; Thu, 17 Jan 2019 11:44:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 17 Jan 2019 11:44:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=FpLYYW0+3nYAnlWSQwsmi+HXnNhCUvV99dTuLQ6ksHo=; b=joV+CKzVCNlB SdJXm7gjA48AjFjAsuAIB6atQYUg43ySpI/OSpQHsudokHPGgiWguHq6pw1MfvOk HjZsgSgGiBUqmH3SEAXoCexVqgBS6rZOUP5Ng3rVhbd1SeTCWm6b9+1R9I/4rNxI StKb7/G93OcAwBCQGMeNZdUixMRul2I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=FpLYYW0+3nYAnlWSQwsmi+HXnNhCUvV99dTuLQ6ks Ho=; b=YwWhucKa/uk7+gMa+ptu2UdfFYyQ1yxYfGWTvUhCA0QoXV4gPLqDIhTtB iyQUnz+91lOK9AiFcvgyN8tQKaZAX3Gi+D9te1HnMn3bHpNazS8xZPgB4z7LKBd/ GxkcBp130OmqYRaBWjrRqt2Z5k6kdKHEsFfwNawipfbZjP/fBfm/KJSoYNCtB88h BGfWDGTZbt8yNoiq7qW/EFRqaQ2c6BVGE1EQ69WT4guuFNSlyN0MPIYGpuuhnTAp z7g79BebeuQPTsHFa+9XhSBCFOYmwyXoEbtKAm5fWLk6KJgpXNedlzRKk8PG/xx7 lLUPCU1zuPRaDxkm/dk3ACWYEFxzg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrgeekgdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgjfh gggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceo thhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecukfhppeejjedrudefgedrvddtfe drudekgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvthenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 1CE23E44A6; Thu, 17 Jan 2019 11:44:51 -0500 (EST) From: Thomas Monjalon To: Chaitanya Babu Talluri Cc: dev@dpdk.org, Stephen Hemminger , Ferruh Yigit , alejandro.lucero@netronome.com, reshma.pattan@intel.com, rmody@marvell.com, shshaikh@marvell.com, beilei.xing@intel.com, qi.z.zhang@intel.com, pablo.de.lara.guarch@intel.com, declan.doherty@intel.com, stable@dpdk.org Date: Thu, 17 Jan 2019 17:44:50 +0100 Message-ID: <1682020.T5HGTybj5o@xps> In-Reply-To: <20190114082437.09600862@hermes.lan> References: <1547445875-24601-1-git-send-email-tallurix.chaitanya.babu@intel.com> <4eefd77e-aaec-90ce-05df-f320dc01af66@intel.com> <20190114082437.09600862@hermes.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] drivers: fix to replace strcat with strncat 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: Thu, 17 Jan 2019 16:44:56 -0000 14/01/2019 17:24, Stephen Hemminger: > On Mon, 14 Jan 2019 13:29:38 +0000 > Ferruh Yigit wrote: > > > On 1/14/2019 6:04 AM, Chaitanya Babu Talluri wrote: > > > Strcat does not check the destination length and there might be > > > chances of string overflow so insted of strcat, strncat is used. > > > > > > Fixes: 540a211084 ("bnx2x: driver core") > > > Fixes: e163c18a15 ("net/i40e: update ptype and pctype info") > > > Fixes: ef28aa96e5 ("net/nfp: support multiprocess") > > > Fixes: 6f4eec2565 ("test/crypto: enhance scheduler unit tests") > > > Cc: stable@dpdk.org > > > > > > Signed-off-by: Chaitanya Babu Talluri > > > > <...> > > > > > @@ -685,11 +687,11 @@ nfp_acquire_secondary_process_lock(struct nfp_pcie_user *desc) > > > * driver is used because that implies root user. > > > */ > > > home_path = getenv("HOME"); > > > - lockfile = calloc(strlen(home_path) + strlen(lockname) + 1, > > > + lockfile = calloc(LOCKFILE_HOME_PATH + strlen(lockname) + 1, > > > sizeof(char)); > > > > > > - strcat(lockfile, home_path); > > > - strcat(lockfile, "/.lock_nfp_secondary"); > > > + strncat(lockfile, home_path, LOCKFILE_HOME_PATH); > > > + strncat(lockfile, lockname, strlen(lockfile)); > > > > I guess this need to be 'LOCKFILE_HOME_PATH - strlen(lockfile) - 1' instead. > > But also this can be implemented as 'snprintf()' > > > > Since 'lockfile' allocated dynamically based on sizes of existing strings, using > > 'lockname' instead of "/.lock_nfp_secondary" will show that there won't be any > > overflow but tools still may be complaining about 'strcat' usage. > > > > > > Why not use vasprintf() instead of doing manual construction? Any update please?