* grub-core/commands/xnu_uuid.c: Remove variable length arrays.
This commit is contained in:
parent
a388e25576
commit
44a387e0ea
2 changed files with 15 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
|||
2013-11-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/commands/xnu_uuid.c: Remove variable length arrays.
|
||||
|
||||
2013-11-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/tests/xnu_uuid_test.c: New test.
|
||||
|
|
|
@ -50,7 +50,7 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_uint8_t *xnu_uuid;
|
||||
char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
|
||||
char *ptr;
|
||||
grub_uint8_t ctx[GRUB_MD_MD5->contextsize];
|
||||
void *ctx;
|
||||
int low = 0;
|
||||
|
||||
if (argc < 1)
|
||||
|
@ -65,11 +65,14 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16));
|
||||
|
||||
GRUB_MD_MD5->init (&ctx);
|
||||
GRUB_MD_MD5->write (&ctx, hash_prefix, sizeof (hash_prefix));
|
||||
GRUB_MD_MD5->write (&ctx, &serial, sizeof (serial));
|
||||
GRUB_MD_MD5->final (&ctx);
|
||||
xnu_uuid = GRUB_MD_MD5->read (&ctx);
|
||||
ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
|
||||
if (!ctx)
|
||||
return grub_errno;
|
||||
GRUB_MD_MD5->init (ctx);
|
||||
GRUB_MD_MD5->write (ctx, hash_prefix, sizeof (hash_prefix));
|
||||
GRUB_MD_MD5->write (ctx, &serial, sizeof (serial));
|
||||
GRUB_MD_MD5->final (ctx);
|
||||
xnu_uuid = GRUB_MD_MD5->read (ctx);
|
||||
|
||||
grub_snprintf (uuid_string, sizeof (uuid_string),
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
|
@ -91,6 +94,8 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (argc > 1)
|
||||
grub_env_set (args[1], uuid_string);
|
||||
|
||||
grub_free (ctx);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue