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
parent 92e46cccf1
commit 73746f0367

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;