On Thu, 7 Sept 2023 at 04:35, Mike Beaton <mjsbea...@gmail.com> wrote: > > The immediately preceding call, GetBestLanguage, plus the implementation of > HiiGetString, which is called immediately afterwards, make it clear that > BestLanguage is a null-terminated ASCII string, and not just a five byte, > non-null terminated buffer. > > Therefore AsciiStrLen is one byte too short, meaning that whether the space > allocated is really sufficient and whether the resultant string is really > null-terminated becomes implementation-dependent. Rather than switching to > AsciiStrSize, we use an explicitly compile-time string length calculation > (both compile-time and run-time approaches are currently used elsewhere in > the codebase for copying static strings).
Apologies for the multiple versions, but I thought it was important to clarify in the commit message above that this really was a fix, not a misunderstanding. I also realised, in this last version, that sizeof is preferable here to AsciiStrSize (and that sizeof is, in fact, already often used when copying static strings elsewhere in the codebase - both sizeof and (Ascii)StrSize are used in various places, but with more use of sizeof). -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108358): https://edk2.groups.io/g/devel/message/108358 Mute This Topic: https://groups.io/mt/101208544/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-