From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 4E8FE1B1D6 for ; Mon, 14 Jan 2019 17:24:45 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id e11so10353436plt.11 for ; Mon, 14 Jan 2019 08:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VBPdzJFn8XyzVcgYFzp4P7Jpw1IUgFqcIrkXNwq328M=; b=xLMmKBRsr02WWYQgWpNYdzANmJMqaOGOHUN8vGCNWQALRPbp5bzCJM/UR/f8Ocxuht 4TkWl8OEpcZgiIRulqc1sF2CG1Zj0krkO3SLxAi3cM3B9kzEsFOKBu+FBIuoMYffGf6B dE8+hEGuTdEr/9RvsyiyC8jO/f5AIXtEwDpP2bgv+tkKf3ZHXMA6MH6pI1Y5Ch5pJ/R4 mDt0anczQsky0tT/DDJSqNKNgVhjaTixor8/u894qubOQLXjaymhOWXwOY1Ldsxo3k1j INNgZ/e3fCVkRG48EQZwIfZGUQPSCcmxUhV2x1YnJ1N1ZI0mvc+SWIUiySKBESuiluhv CHPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VBPdzJFn8XyzVcgYFzp4P7Jpw1IUgFqcIrkXNwq328M=; b=MqB/AmIl665KOyTtGLmbepIBIM/Us5PWTkpaIQGKC1rJ8e7OjNEOZvm+8f9RjjGBUw lbbyP0U4NYkbyd1kMnAqQK9FkvGpEKuluU9lbjtiGumyjAWrCjBQawWm9bxsLly4ZyGC iHFbfAFJKG7xvVGK2tYqyGygfufpipPhRew+jYsZRyopHk3zBo0Qz1tTInnsuHUqETxY SgjIL4VWeAsD8eqEJ0XJcFQKihcBWIOkTDv9CrfWZsQZa19v02FLcMHImypoFc7lN5uE qpaFlPVefdY72nlLE1DLSwyT3EYOePZKSBkHkuDO3GYH1RSSHLHjqewC87R0b/uWiihS X/QQ== X-Gm-Message-State: AJcUukeMgZCwFIzh7E2FTK5Ditv4Pu6T4UuFwY20XZjTZxzZ3fL/CosN G2HdqTl1YwbWRtmIpqJe6TrB+A== X-Google-Smtp-Source: ALg8bN5b/rqQPCIKYdk7GZle4zvLG5xZoRMaPAIFmDfNMnSsvDZLsDKpq+WWMCuvZU7XOTPDfeLp4Q== X-Received: by 2002:a17:902:b78b:: with SMTP id e11mr26284517pls.90.1547483084208; Mon, 14 Jan 2019 08:24:44 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id m67sm1082899pfm.73.2019.01.14.08.24.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 08:24:44 -0800 (PST) Date: Mon, 14 Jan 2019 08:24:37 -0800 From: Stephen Hemminger To: Ferruh Yigit Cc: Chaitanya Babu Talluri , dev@dpdk.org, 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 Message-ID: <20190114082437.09600862@hermes.lan> In-Reply-To: <4eefd77e-aaec-90ce-05df-f320dc01af66@intel.com> References: <1547445875-24601-1-git-send-email-tallurix.chaitanya.babu@intel.com> <4eefd77e-aaec-90ce-05df-f320dc01af66@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Mon, 14 Jan 2019 16:24:45 -0000 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?