public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug
@ 2023-10-30 20:24 Ashish Singhal via groups.io
  2023-10-30 20:24 ` [edk2-devel] [PATCH 2/2] EmbeddedPkg: Allow longer android kernel command line Ashish Singhal via groups.io
  2023-11-06 17:55 ` [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Ashish Singhal via groups.io
  0 siblings, 2 replies; 5+ messages in thread
From: Ashish Singhal via groups.io @ 2023-10-30 20:24 UTC (permalink / raw)
  To: devel, quic_llindhol, ardb+tianocore, abner.chang, git, jbrasen
  Cc: Ashish Singhal

Curently, AndroidBootImgLib expects input kernel command line
to never exceed 256 unicode characters where the image header
allows for 512 ascii characters. If image header allows 512
ascii characters, similar number of unicode characters should be
allowed at the minimum.

Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
---
 .../AndroidBootImgLib/AndroidBootImgLib.c     | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index 1359a66db2..02769cd0df 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -321,8 +321,9 @@ AndroidBootImgGetFdt (
 
 EFI_STATUS
 AndroidBootImgUpdateArgs (
-  IN  VOID  *BootImg,
-  OUT VOID  *KernelArgs
+  IN  VOID    *BootImg,
+  OUT VOID    *KernelArgs,
+  IN  UINT32  KernelArgsSize
   )
 {
   CHAR8       ImageKernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
@@ -337,13 +338,13 @@ AndroidBootImgUpdateArgs (
   AsciiStrToUnicodeStrS (
     ImageKernelArgs,
     KernelArgs,
-    ANDROID_BOOTIMG_KERNEL_ARGS_SIZE >> 1
+    KernelArgsSize
     );
   // Append platform kernel arguments
   if (mAndroidBootImg->AppendArgs) {
     Status = mAndroidBootImg->AppendArgs (
                                 KernelArgs,
-                                ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
+                                KernelArgsSize
                                 );
   }
 
@@ -611,11 +612,16 @@ AndroidBootImgBoot (
   MEMORY_DEVICE_PATH         KernelDevicePath;
   EFI_HANDLE                 ImageHandle;
   VOID                       *NewKernelArg;
+  UINT32                     NewKernelArgSize;
   EFI_LOADED_IMAGE_PROTOCOL  *ImageInfo;
   VOID                       *RamdiskData;
   UINTN                      RamdiskSize;
   IN  VOID                   *FdtBase;
 
+  if ((Buffer == NULL) || (BufferSize == 0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
   NewKernelArg = NULL;
   ImageHandle  = NULL;
 
@@ -637,14 +643,15 @@ AndroidBootImgBoot (
     goto Exit;
   }
 
-  NewKernelArg = AllocateZeroPool (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
+  NewKernelArgSize = ANDROID_BOOTIMG_KERNEL_ARGS_SIZE;
+  NewKernelArg     = AllocateZeroPool (sizeof (CHAR16) * NewKernelArgSize);
   if (NewKernelArg == NULL) {
     DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
     Status = EFI_OUT_OF_RESOURCES;
     goto Exit;
   }
 
-  Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg);
+  Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg, NewKernelArgSize);
   if (EFI_ERROR (Status)) {
     goto Exit;
   }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110337): https://edk2.groups.io/g/devel/message/110337
Mute This Topic: https://groups.io/mt/102284239/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-11-15  3:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 20:24 [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Ashish Singhal via groups.io
2023-10-30 20:24 ` [edk2-devel] [PATCH 2/2] EmbeddedPkg: Allow longer android kernel command line Ashish Singhal via groups.io
2023-11-06 17:55 ` [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Ashish Singhal via groups.io
2023-11-10  2:06   ` Chang, Abner via groups.io
2023-11-15  3:13     ` Ashish Singhal via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox