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 DA4F72B91 for ; Sun, 28 Oct 2018 11:41:45 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6162A21BF8; Sun, 28 Oct 2018 06:41:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 28 Oct 2018 06:41:45 -0400 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=y5C+i5cE4q698SJpdDZKR9gzLHlTcnXZpCgeDrqvlX4=; b=PGEVPFeCjKqv 6UFYgpsFpWZvIfuUJ24Yk8y1oznM49wyb52RIvs4RdRlkQ0Q0epO4/90J/kXagzV U+GsHW5wX/oOy6u0oYtkKArb4b+8t3OoqUHnkbbGqLEJ3NcmJCP1DC+AgpKCgLE3 Uy3kJFO624P7bPUDpaX+23FZXLQrfxE= 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=y5C+i5cE4q698SJpdDZKR9gzLHlTcnXZpCgeDrqvl X4=; b=aH5yow+QsefFE61+nK6bkM4Fp78Ae7JmjDN6ndkVMkzc8mwLDBbbS1Eq9 w/me544/WvhmR5GO8DL3mZVFuCGrljLyfZJfc5Sfwnu9kxs5/+ye/AvMw/FBbo4q +Ou2FDOVJhlIejlMdWSyWEEi7tbx1yq2UqOtkGcu9u8o/X5r7sI/R36vTkRGAba5 vFy0Oq6/+LmsmWZQze2zFChsBOyAAIkDQfJRRkZanx01TpGwnUKHa+SFEsThjSbp 4mLNk8ZkH/P6bS6gvASkFysuJC38fV9v4M2iPYEbnVWTcKfnksUSlbaGYMsT1MYJ 1lUgemCw6M0O4O3HB0cUqTXjf9PgA== X-ME-Sender: 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 3B66FE4119; Sun, 28 Oct 2018 06:41:44 -0400 (EDT) From: Thomas Monjalon To: Ziye Yang Cc: dev@dpdk.org, konstantin.ananyev@intel.com, Ziye Yang , ferruh.yigit@intel.com Date: Sun, 28 Oct 2018 11:41:50 +0100 Message-ID: <2291161.Cnx30EFnGb@xps> In-Reply-To: <30207781.zVJTsycACh@xps> References: <1536125954-46632-1-git-send-email-ziye.yang@intel.com> <1536715910-38320-1-git-send-email-ziye.yang@intel.com> <30207781.zVJTsycACh@xps> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v8] linuxapp, eal: Fix the memory leak issue of logid 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: Sun, 28 Oct 2018 10:41:46 -0000 22/10/2018 10:00, Thomas Monjalon: > 12/09/2018 03:31, Ziye Yang: > > From: Ziye Yang > > > > This patch is used to fix the memory leak issue of logid. > > We use the ASAN test in SPDK when intergrating DPDK and > > find this memory leak issue. > > > > Signed-off-by: Ziye Yang > > --- > > - logid = strrchr(argv[0], '/'); > > - logid = strdup(logid ? logid + 1: argv[0]); > > - > > + p = strrchr(argv[0], '/'); > > + snprintf(logid, sizeof(logid), "%s", (p ? p + 1 : argv[0])); > > Shouldn't it be strlcpy instead of snprintf? Applied with suggested replacement: - snprintf(logid, sizeof(logid), "%s", (p ? p + 1 : argv[0])); + strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));