[AMD Official Use Only - General] > -----Original Message----- > From: Mike Maslenkin <[email protected]> > Sent: Monday, November 27, 2023 3:30 AM > To: Chang, Abner <[email protected]> > Cc: [email protected]; Nickle Wang <[email protected]>; Igor > Kulchytskyy <[email protected]> > Subject: Re: [PATCH V2 8/8] RedfishPkg/HostInterfaceBmcUsbNic: Fix > incorrect HI protocol record size > > Caution: This message originated from an External Source. Use proper caution > when opening attachments, clicking links, or responding. > > > On Thu, Nov 23, 2023 at 9:48 AM <[email protected]> wrote: > > > > From: Abner Chang <[email protected]> > > > > The size of structure must be minus with byte that is > > occupied by the initial array. > > > > Signed-off-by: Abner Chang <[email protected]> > > Cc: Nickle Wang <[email protected]> > > Cc: Igor Kulchytskyy <[email protected]> > > Cc: Mike Maslenkin <[email protected]> > > --- > > .../PlatformHostInterfaceBmcUsbNicLib.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git > a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter > faceBmcUsbNicLib.c > b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter > faceBmcUsbNicLib.c > > index c4a71226e63..a1ce2dd3d93 100644 > > --- > a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter > faceBmcUsbNicLib.c > > +++ > b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter > faceBmcUsbNicLib.c > > @@ -180,7 +180,7 @@ RedfishPlatformHostInterfaceProtocolData ( > > HostNameLength = (UINT8)AsciiStrSize (HostNameString); > > ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD > *)AllocateZeroPool ( > > sizeof > (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1 + > > - sizeof > (REDFISH_OVER_IP_PROTOCOL_DATA) + > > + sizeof > (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 + > > > > HostNameLength > > ); > > if (ThisProtocolRecord == NULL) { > > @@ -189,7 +189,7 @@ RedfishPlatformHostInterfaceProtocolData ( > > } > > > > ThisProtocolRecord->ProtocolType = > MCHostInterfaceProtocolTypeRedfishOverIP; > > - ThisProtocolRecord->ProtocolTypeDataLen = sizeof > (REDFISH_OVER_IP_PROTOCOL_DATA) + HostNameLength; > > + ThisProtocolRecord->ProtocolTypeDataLen = sizeof > (REDFISH_OVER_IP_PROTOCOL_DATA) -1 + HostNameLength; > > RedfishOverIpData = > > (REDFISH_OVER_IP_PROTOCOL_DATA > *)&ThisProtocolRecord->ProtocolTypeData[0]; > > // > > // Fill up REDFISH_OVER_IP_PROTOCOL_DATA > > -- > > 2.37.1.windows.1 > > > Excellent! > > BTW could we use zero-sized array for > REDFISH_OVER_IP_PROTOCOL_DATA::RedfishServiceHostname? > Alternatively, we could use "HostNameLength = (UINT8) AsciiStrLen > (HostNameString);" with appropriate comment, that space for \0 is > already reserved, Let's update this to zeroed size array in next patch to make the code easily read, as we have to update all other structure members those are declared as one byte array and remove "-1" from the code as well. You are also welcome to update these structures after our changes are merged to the master branch. Thanks Abner
-=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111715): https://edk2.groups.io/g/devel/message/111715 Mute This Topic: https://groups.io/mt/102763123/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
