Commit 23ce039c authored by Peter Jones's avatar Peter Jones

Use iconv for UCS-2 encoding.

Cyphermox discovered that when you run this:

  ( printf "\xff\x00\xfe\x00" ; echo "shimx64.efi,foo,,This is the boot entry for foo" ) | sed -z 's/./&\x00/g'

on some debian machines, printf(1) doesn't interpret the \x.. characters,
and that results in this being the encoded text:

00000000  5c 78 66 66 5c 78 66 65  73 00 68 00 69 00 6d 00  |\xff\xfes.h.i.m.|
00000010  78 00 36 00 34 00 2e 00  65 00 66 00 69 00 2c 00  |x.6.4...e.f.i.,.|
00000020  66 00 6f 00 6f 00 2c 00  2c 00 54 00 68 00 69 00  |f.o.o.,.,.T.h.i.|

which... yeah, that's wrong.  So instead, use iconv instead of
printf+sed to encode it in UCS-2.  Unfortunately, that means we don't
get endian markers, because for some reason iconv(1) doesn't have any way
to say it should include them.  But that's okay; fallback already
handles not having them and just assumes the second byte being \x00
means UCS-2LE.
Signed-off-by: default avatarPeter Jones <pjones@redhat.com>
parent 49e9775e
......@@ -229,7 +229,7 @@ buildid : $(TOPDIR)/buildid.c
$(BOOTCSVNAME) :
@echo Making $@
@( printf "\xff\xfe" ; echo "$(SHIMNAME),$(OSLABEL),,This is the boot entry for $(OSLABEL)" | sed -z 's/./&\x00/g' ) > $@
@echo "$(SHIMNAME),$(OSLABEL),,This is the boot entry for $(OSLABEL)" | iconv -t UCS-2LE > $@
install-check :
ifeq ($(origin LIBDIR),undefined)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment