From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 1732BAABC for ; Wed, 9 May 2018 11:53:47 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id f8-v6so26587372wmc.4 for ; Wed, 09 May 2018 02:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=UR6UrIRuf1OhIJPQQT53Lw6xm2Kk0IiMTnUGh/DstIs=; b=c2N2MevHlX6DWQvgB+9NN4nPYRfMlRVLg71aiXFgTm+boy56BbQLPOZNmZcYAsK/hA Ran4eNV4mcbKsqitDGu7jP8ui2yTXV7Hs3VNYGIVdMUDbXtrL4Eywk+jp9mcBFTss7r/ yW0jrucmTZtzfAMkPSCWXrGumA1VgOsoRHZyjtDRU2mmTyeVFZDOnPLKuij9eMzRqPDu 9euo+SzincLvWzctHqTPsHjOJMh0H6hyrM0tCnBAdFlvI4oThpHysQgV9MyI5YmA5i6p k0hC6GFqX5aHKJCMN8DvnxoAeRwq6FEMajSEZcQk4/rhkPjON5kHzGOxoBPe+t8EPH7/ M2rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UR6UrIRuf1OhIJPQQT53Lw6xm2Kk0IiMTnUGh/DstIs=; b=bzPhbQczaWNIMNktHXTaN1wfa8y6UJ7SFuDUEI/Q+IgymWznAwRAswf8Fce8HL5Hi9 sq2LY1/XaZmWiBkgyK2DNs9FtbjFkkurRgh5CCqNVdAW7cQAjDQwLq3dQIm+AET6n5N4 7n/+xP0nFkkNmnmH1tEss+UfsPriW5vZY8LX1dMCD4quq6ecX9IRpppLrzUg9Me6czmA Z+gRXf8M0KzJnnTaLQHnMzuZPDn+ate8/fQ/z/hKwQZl3lM7LhECLdSGPq8CV3V8ZzLB Vr89R24Ifk4ozIALn2xdsxeytYXHtco1VFF4OR3KbN/mCC02YX1RfDCVbljXmcVi4rSg O9xQ== X-Gm-Message-State: ALQs6tDDt37UpLaYNoXkU+6CyjXzk1qfh16GzlTvLtF7MWslVmCDli4t s9DUhXLppSUHG3l+IkuiWmAkMmm980YEd6nUIqs+SOVu X-Google-Smtp-Source: AB8JxZoLrKLnsOgEvTQkfRxZ/7q8AJkv3E+9Z0CSNbR4HSZC3S7DM7p7yAVxPndUyTkLodUnT7enWlEzVTLfHAWpZLA= X-Received: by 2002:a50:a802:: with SMTP id j2-v6mr59286847edc.138.1525859626879; Wed, 09 May 2018 02:53:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.212.155 with HTTP; Wed, 9 May 2018 02:53:46 -0700 (PDT) In-Reply-To: <152582948090.6809.17293544631396610744.stgit@localhost.localdomain> References: <152582834896.6809.14521072557832633661.stgit@localhost.localdomain> <152582948090.6809.17293544631396610744.stgit@localhost.localdomain> From: Alejandro Lucero Date: Wed, 9 May 2018 10:53:46 +0100 Message-ID: To: Andy Green Cc: dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use 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: Wed, 09 May 2018 09:53:47 -0000 On Wed, May 9, 2018 at 2:31 AM, Andy Green wrote: > /home/agreen/projects/dpdk/drivers/net/nfp/nfpcore/nfp_resource.c: > 76:2:error: =E2=80=98strncpy=E2=80=99 output may be truncated copying 8 b= ytes from > a string of length 8 [-Werror=3Dstringop-truncation] > strncpy(name_pad, res->name, sizeof(name_pad)); > > Signed-off-by: Andy Green > --- > drivers/net/nfp/nfpcore/nfp_resource.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c > b/drivers/net/nfp/nfpcore/nfp_resource.c > index e1df2b2e1..a165b93df 100644 > --- a/drivers/net/nfp/nfpcore/nfp_resource.c > +++ b/drivers/net/nfp/nfpcore/nfp_resource.c > @@ -7,6 +7,8 @@ > #include > #include > > +#include > + > #include "nfp_cpp.h" > #include "nfp6000/nfp6000.h" > #include "nfp_resource.h" > @@ -65,15 +67,15 @@ struct nfp_resource { > static int > nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res) > { > - char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ] =3D {}; > + char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ + 2]; > struct nfp_resource_entry entry; > uint32_t cpp_id, key; > int ret, i; > > cpp_id =3D NFP_CPP_ID(NFP_RESOURCE_TBL_TARGET, 3, 0); /* Atomic > read */ > > - memset(name_pad, 0, NFP_RESOURCE_ENTRY_NAME_SZ); > - strncpy(name_pad, res->name, sizeof(name_pad)); > + memset(name_pad, 0, sizeof(name_pad)); > + strlcpy(name_pad, res->name, sizeof(name_pad)); > > /* Search for a matching entry */ > if (!memcmp(name_pad, NFP_RESOURCE_TBL_NAME "\0\0\0\0\0\0\0\0", > 8)) { > > I'm afraid this patch is breaking the PMD NFP initialization. It is due to how the name pad is used for getting a key which is compared against a key generated by the firmware. Because the name_pad size change, this next change is also required: - key =3D nfp_crc32_posix(name_pad, sizeof(name_pad)); + key =3D nfp_crc32_posix(name_pad, NFP_RESOURCE_ENTRY_NAME_SZ);