[edk2-devel] [PATCH v3] MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size

Mike Beaton posted 1 patch 1 year, 1 month ago
Failed in applying to current master (apply log)
There is a newer version of this series
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [PATCH v3] MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size
Posted by Mike Beaton 1 year, 1 month ago
AsciiStrLen was one byte too short (though with alignment up from an odd size
would probably always have had the required space in practice). AsciiStrSize
matches usage elsewhere in this file and in the codebase.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 96e05d4cf9..f67b7760f0 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -1987,7 +1987,7 @@ GetNameFromId (
                    NULL
                    );
   if (BestLanguage == NULL) {
-    BestLanguage = AllocateCopyPool (AsciiStrLen ("en-US"), "en-US");
+    BestLanguage = AllocateCopyPool (AsciiStrSize ("en-US"), "en-US");
     ASSERT (BestLanguage != NULL);
   }
 
-- 
2.41.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108322): https://edk2.groups.io/g/devel/message/108322
Mute This Topic: https://groups.io/mt/101189764/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v3] MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size
Posted by Mike Beaton 1 year, 1 month ago
On Wed, 6 Sept 2023 at 11:34, Mike Beaton <mjsbeaton@gmail.com> wrote:
>
> AsciiStrLen was one byte too short (though with alignment up from an odd size
> would probably always have had the required space in practice). AsciiStrSize
> matches usage elsewhere in this file and in the codebase.

I was intended to cc Ard Biesheuvel as well - I hope that is okay,
since you have definitely committed on this file (as no doubt many
others!) - but I managed to use your now-bouncing old email address
from one of those earlier commits, so I have fixed that in this reply,
and also removed from the cc list the addresses of a couple of Intel
employees who originally authored or worked on this file but which now
bounce.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108328): https://edk2.groups.io/g/devel/message/108328
Mute This Topic: https://groups.io/mt/101189764/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v3] MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size
Posted by Mike Beaton 1 year, 1 month ago
On Wed, 6 Sept 2023 at 12:55, Mike Beaton <mjsbeaton@gmail.com> wrote:
>
> On Wed, 6 Sept 2023 at 11:34, Mike Beaton <mjsbeaton@gmail.com> wrote:
> >
> > AsciiStrLen was one byte too short (though with alignment up from an odd size
> > would probably always have had the required space in practice). AsciiStrSize
> > matches usage elsewhere in this file and in the codebase.

Have just realised that the severity is worse than implied in my
current commit message,
since not only are (potentially - though almost certainly not, in practice) too
few bytes allocated, but definitely too few bytes are then copied, so
the resulting string is
only null terminated by the grace of the specific implementation, too.
Could update to a v4
of this (small) patch with a commit message mentioning this?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108329): https://edk2.groups.io/g/devel/message/108329
Mute This Topic: https://groups.io/mt/101189764/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-