[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/16] hw/uefi: add var-service-core.c
From: |
Gerd Hoffmann |
Subject: |
Re: [PATCH 05/16] hw/uefi: add var-service-core.c |
Date: |
Wed, 22 Nov 2023 17:30:21 +0100 |
Hi,
> - in general, we should filter out surrogate code points, for any use.
> any UCS2 string from the guest that contains a surrogate code point
> should be considered invalid, and the request should be rejected based
> just on that.
Something like this?
edk2 seems to be inconsistent with strings, sometimes they are expected
to include a terminating '\0' char (most of the time), sometimes not
(in variable policies for example).
gboolean uefi_str_is_valid(const uint16_t *str, size_t len,
gboolean must_be_null_terminated)
{
size_t pos = 0;
for (;;) {
if (pos == len) {
if (must_be_null_terminated) {
return false;
} else {
return true;
}
}
switch (str[pos]) {
case 0:
/* end of string */
return true;
;;
case 0xd800 ... 0xdfff:
/* outlaw surrogates */
return false;
default:
/* char is good, check next */
break;
}
pos++;
}
}
take care,
Gerd
- [PATCH 00/16] hw/uefi: add uefi variable service, Gerd Hoffmann, 2023/11/15
- [PATCH 07/16] hw/uefi: add var-service-auth.c, Gerd Hoffmann, 2023/11/15
- [PATCH 11/16] hw/uefi: add to Kconfig, Gerd Hoffmann, 2023/11/15
- [PATCH 12/16] hw/uefi: add to meson, Gerd Hoffmann, 2023/11/15
- [PATCH 05/16] hw/uefi: add var-service-core.c, Gerd Hoffmann, 2023/11/15
- [PATCH 04/16] hw/uefi: add var-service-guid.c, Gerd Hoffmann, 2023/11/15
- [PATCH 01/16] hw/uefi: add include/hw/uefi/var-service-api.h, Gerd Hoffmann, 2023/11/15
- [PATCH 15/16] hw/arm: add uefi variable support to virt machine type, Gerd Hoffmann, 2023/11/15
- [PATCH 14/16] hw/uefi: add uefi-vars-isa device, Gerd Hoffmann, 2023/11/15
- [PATCH 08/16] hw/uefi: add var-service-policy.c, Gerd Hoffmann, 2023/11/15
- [PATCH 13/16] hw/uefi: add uefi-vars-sysbus device, Gerd Hoffmann, 2023/11/15
- [PATCH 03/16] hw/uefi: add include/hw/uefi/var-service.h, Gerd Hoffmann, 2023/11/15