Skip to content

Commit 505c38a

Browse files
committed
handle ucs-2 cmdline
1 parent 53aeaae commit 505c38a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

efimain.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <stdio.h>
2020
#include "ntloader.h"
2121
#include "cmdline.h"
22+
#include "charset.h"
2223
#include "efi.h"
2324
#include "efifile.h"
2425
#include "efiblock.h"
@@ -55,14 +56,16 @@ const char sbat[ sizeof (SBAT_CSV) - 1 ] __sbat = SBAT_CSV;
5556
static void efi_cmdline (EFI_LOADED_IMAGE_PROTOCOL *loaded)
5657
{
5758
size_t cmdline_len = (loaded->LoadOptionsSize / sizeof (wchar_t));
58-
char cmdline[ cmdline_len + 1 /* NUL */ ];
59-
const wchar_t *wcmdline = loaded->LoadOptions;
59+
char *cmdline = efi_malloc (4 * cmdline_len + 1);
6060

6161
/* Convert command line to ASCII */
62-
snprintf (cmdline, sizeof (cmdline), "%ls", wcmdline);
62+
*ucs2_to_utf8 ((uint8_t *) cmdline,
63+
loaded->LoadOptions, cmdline_len) = 0;
6364

6465
/* Process command line */
6566
process_cmdline (cmdline);
67+
68+
efi_free (cmdline);
6669
}
6770

6871
/**

0 commit comments

Comments
 (0)