acpi/acpigen: Fix buffer length in acpigen_write_name_unicode()

The buffer length is in bytes, and since we are converting from ASCII
to UTF-16, the value written needs to be 2x the string length + null
terminator.

TEST=build/boot google skyrim (frostflow), dump acpi and check bytecode
for correct buffer length preceding unicode strings.

Change-Id: Id322e3ff457ca1c92c55125224ca6cfab8762a84
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78977
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Matt DeVillier 2023-11-09 15:04:58 -06:00 committed by Felix Held
parent 238ff1e9c7
commit d4d40c64e1

View File

@ -185,7 +185,7 @@ void acpigen_write_name_unicode(const char *name, const char *string)
acpigen_write_name(name); acpigen_write_name(name);
acpigen_emit_byte(BUFFER_OP); acpigen_emit_byte(BUFFER_OP);
acpigen_write_len_f(); acpigen_write_len_f();
acpigen_write_integer(len); acpigen_write_integer(2 * len);
for (size_t i = 0; i < len; i++) { for (size_t i = 0; i < len; i++) {
const signed char c = string[i]; const signed char c = string[i];
/* Simple ASCII to UTF-16 conversion, replace non ASCII characters */ /* Simple ASCII to UTF-16 conversion, replace non ASCII characters */