From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 81AB2941EDD for ; Thu, 26 Oct 2023 23:51:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=3jiLETT9YrsTaO3kPrPs4SWCy/bQwISVt+ioTfUfh0o=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1698364307; v=1; b=XuSJkE4m7f+2y+8BPeiITDrY+CxDDwjo/+IapL4L/nQtuxyfEblPBun7T2ND1ZduSRnGS0qY 9LLR6lswj7PM+vJwe55sVcxy2CmTj9d7+2i0VqMjtl4PPT78prVVx40DDE4SQAeJNfBUms9TpAM TwwE6+2XJAzA43+djPrVpoDU= X-Received: by 127.0.0.2 with SMTP id snZ1YY7687511xg79J3bOUe3; Thu, 26 Oct 2023 16:51:47 -0700 X-Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by mx.groups.io with SMTP id smtpd.web11.86023.1698364306537975892 for ; Thu, 26 Oct 2023 16:51:46 -0700 X-Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-5a86b6391e9so11764227b3.0 for ; Thu, 26 Oct 2023 16:51:46 -0700 (PDT) X-Gm-Message-State: IZEIxeIMxHsUKXnjP2sVJYdAx7686176AA= X-Google-Smtp-Source: AGHT+IGyzX3UWW657/4f3ZykLLL3iHcr335ehluRe2zL7N3lMxYJCY/reAsE38++TIkMLeI/0Wzy6u93VUrn7v3GS6o= X-Received: by 2002:a81:a941:0:b0:5a7:ba17:584b with SMTP id g62-20020a81a941000000b005a7ba17584bmr1020966ywh.1.1698364305607; Thu, 26 Oct 2023 16:51:45 -0700 (PDT) MIME-Version: 1.0 References: <20230929215915.46616-1-mike.maslenkin@gmail.com> <20230929215915.46616-10-mike.maslenkin@gmail.com> In-Reply-To: From: "Mike Maslenkin" Date: Fri, 27 Oct 2023 02:51:09 +0300 Message-ID: Subject: Re: [edk2-devel] [PATCH 9/9] RedfishClientPkg: fix StrnCpyS arguments To: "Chang, Abner" Cc: "devel@edk2.groups.io" , "nicklew@nvidia.com" , "igork@ami.com" Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=XuSJkE4m; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Mon, Oct 2, 2023 at 5:56=E2=80=AFAM Chang, Abner w= rote: > > [AMD Official Use Only - General] > > > -----Original Message----- > > From: Mike Maslenkin > > Sent: Saturday, September 30, 2023 5:59 AM > > To: devel@edk2.groups.io > > Cc: Chang, Abner ; nicklew@nvidia.com; > > igork@ami.com; Mike Maslenkin > > Subject: [PATCH 9/9] RedfishClientPkg: fix StrnCpyS arguments > > > > Caution: This message originated from an External Source. Use proper ca= ution > > when opening attachments, clicking links, or responding. > > > > > > StrnCpyS accepts string length in characters, not in bytes. > > > > Signed-off-by: Mike Maslenkin > > --- > > RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreD= xe.c > > b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c > > index 8ac165dec59e..c19d4a46d6af 100644 > > --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c > > +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c > > @@ -331,7 +331,7 @@ NewInternalInstance ( > > } > > > > > > > > NewInternalData->NodeName =3D AllocateZeroPool (StrSize (NodeName)); > > > > - StrnCpyS (NewInternalData->NodeName, StrSize (NodeName), (CONST > > CHAR16 *)NodeName, StrLen (NodeName)); > > > > + StrnCpyS (NewInternalData->NodeName, StrLen (NodeName) + 1, (CONST > > CHAR16 *)NodeName, StrLen (NodeName)); > The original code is already the size of string that includes NULL termin= ator. However, we should check if NewInternalData->NodeName is NULL or not = before copying the string. Mike, could you please help to add this check? > > Thanks > Abner > Hi, Abner The problem is not with NULL terminator The problem is that StrnCpyS takes a number of unicode chars as a second parameter, not a string size in bytes returned by StrSize(). So I left this patch unmodified and added two additional patches required for NULL pointer check. Thanks, Mike. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110144): https://edk2.groups.io/g/devel/message/110144 Mute This Topic: https://groups.io/mt/101667469/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-