efi/libstub: Get the exact UTF-8 length
authorArvind Sankar <nivedita@alum.mit.edu>
Mon, 18 May 2020 19:07:15 +0000 (15:07 -0400)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 20 May 2020 17:09:20 +0000 (19:09 +0200)
commit15c316bcbc23b777eae4e21f129526190aa20af1
tree503a287a15d51fbcc7621f72fe5f447bd6cfa07d
parenta713979e443d4036e76e13bb3d30e9fa248915aa
efi/libstub: Get the exact UTF-8 length

efi_convert_cmdline currently overestimates the length of the equivalent
UTF-8 encoding.

snprintf can now be used to do the conversion to UTF-8, however, it does
not have a way to specify the size of the UTF-16 string, only the size
of the resulting UTF-8 string. So in order to use it, we need to
precalculate the exact UTF-8 size.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200518190716.751506-24-nivedita@alum.mit.edu
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/efi-stub-helper.c