* 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>
|
2013-11-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/tests/xnu_uuid_test.c: New test.
|
* 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;
|
grub_uint8_t *xnu_uuid;
|
||||||
char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
|
char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
|
||||||
char *ptr;
|
char *ptr;
|
||||||
grub_uint8_t ctx[GRUB_MD_MD5->contextsize];
|
void *ctx;
|
||||||
int low = 0;
|
int low = 0;
|
||||||
|
|
||||||
if (argc < 1)
|
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));
|
serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16));
|
||||||
|
|
||||||
GRUB_MD_MD5->init (&ctx);
|
ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
|
||||||
GRUB_MD_MD5->write (&ctx, hash_prefix, sizeof (hash_prefix));
|
if (!ctx)
|
||||||
GRUB_MD_MD5->write (&ctx, &serial, sizeof (serial));
|
return grub_errno;
|
||||||
GRUB_MD_MD5->final (&ctx);
|
GRUB_MD_MD5->init (ctx);
|
||||||
xnu_uuid = GRUB_MD_MD5->read (&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),
|
grub_snprintf (uuid_string, sizeof (uuid_string),
|
||||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
"%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)
|
if (argc > 1)
|
||||||
grub_env_set (args[1], uuid_string);
|
grub_env_set (args[1], uuid_string);
|
||||||
|
|
||||||
|
grub_free (ctx);
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue