Fix hex representation of binary variable contents

The getenv code was mishandling the conversion of binary to hex. Grub's
sprintf() doesn't seem to support the full set of format conversions, so
fix this in the nasty way.
This commit is contained in:
Matthew Garrett 2016-01-07 15:31:36 -08:00 committed by David Michael
parent 3d995d8c97
commit d779b3e0fc
1 changed files with 1 additions and 1 deletions

View File

@ -119,7 +119,7 @@ grub_cmd_getenv (grub_extcmd_context_t ctxt, int argc, char **args)
{ {
bindata = grub_zalloc(datasize * 2 + 1); bindata = grub_zalloc(datasize * 2 + 1);
for (i=0; i<datasize; i++) for (i=0; i<datasize; i++)
grub_snprintf(bindata + i*2, 3, "%02x", data[i]); grub_snprintf(bindata + i*2, 3, "%02x", data[i] & 0xff);
if (grub_env_set (args[0], bindata)) if (grub_env_set (args[0], bindata))
goto done; goto done;