From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 2B9F311D4 for ; Tue, 22 May 2018 19:47:41 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id ABB0921A1E; Tue, 22 May 2018 13:47:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 22 May 2018 13:47:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=d1oXkNAOGS/nJNcBu/R6UaLc7W HsO539JfkVJI50bRA=; b=VfsEb92SoLd5VOLS1f9+awt9h9cX+t1dBMLJY2Z7WX RV1G9Hmi9OUwxqmozouO01w9Lk8t6qJukJWgv7KcJvNf8Sc4M9jbYEDMj62N4uWD AJZ6iZIRWauo5rCMRAAaNZAXnUfgP+wZWz2IXIuX3gTkMo0zIRo9qW9wo4gXnb77 s= 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-sender:x-me-sender:x-sasl-enc; s=fm2; bh=d1oXkN AOGS/nJNcBu/R6UaLc7WHsO539JfkVJI50bRA=; b=XRfDe5FZTHehKT01BDAr6v O92KGxe7je39XsNXx/xv3Bb9kkJytO25bg1LxD9u0lKf6iHBZ4NPqFi1a2pESKm7 lTrnN1Q4BPFoSfuCXZ+eTL6B/TLC9AKu6hqQyrTwK1BOSqhshw86gK9DZCgatRhZ MppDNLwnA0H+P5hZlL+C3IiSAj/AoABZeTD7pcw4PNp5JWEb5cUL2KKAcMm3h266 IOEonDVdGNwYGdySqmHUwiQ6Rjd3Uij01mSp8qTFirX8XkYLJk4tdv13kpa59QoT +ky/cHyzDD8VGelHs2RxQqzZL+ce48WAsoTyBmh/ioW8KquwomrC9zcF0gB3SXZg == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 30995E465F; Tue, 22 May 2018 13:47:40 -0400 (EDT) From: Thomas Monjalon To: Changpeng Liu Cc: dev@dpdk.org Date: Tue, 22 May 2018 19:47:39 +0200 Message-ID: <3339436.bIZ7ygsVkQ@xps> In-Reply-To: <1526599932-13083-2-git-send-email-changpeng.liu@intel.com> References: <1526599932-13083-1-git-send-email-changpeng.liu@intel.com> <1526599932-13083-2-git-send-email-changpeng.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH 2/2] examples/vhost_scsi: fix potential buffer overrun with safe copy API 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, 22 May 2018 17:47:41 -0000 18/05/2018 01:32, Changpeng Liu: > Signed-off-by: Changpeng Liu Missing explanations. > - strlcpy((char *)vpage->params, bdev->name, > - sizeof(vpage->params)); > + vhost_strcpy_pad((char *)vpage->params, bdev->name, > + sizeof(vpage->params), ' '); Why do you think vhost_strcpy_pad is safer than strlcpy? > - strncpy(bdev->name, bdev_name, sizeof(bdev->name)); > - strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name)); > + snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name); > + snprintf(bdev->product_name, sizeof(bdev->product_name), > + "%s", bdev_serial); You should use strlcpy.