* Fix bugs in our code that converts ucs2 strings to utf8 where we

unintentionally drop bits from the original string - Jason Andryuk
 
  * Add the efi-pstore variables to the variable whitelist so that
    users can continue to delete them via efivarfs without needing to
    manipulate the immutable flag - Matt Fleming
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJWwxxEAAoJEC84WcCNIz1VtaIP/0ezAbOwoqSzy9wPZVuYaEON
 0ge+4Ksd6v+IGxSTqfq2naVVEc+V7i8Hj2ermyZ1luswEpd8zggL2VdZLHT02zjk
 IQjTmNGA/13aKtCbG56Z3sVOuUb/1szIpFFc7P2GlEcfW7u/ElZRC8934HEl6CGe
 MIwZbwq0+tAYte120/RZAs0Rif6zUfPt18YO7F88S6Nc6blkkuxx/hl7jwxhkZHf
 KAiz0FJUrMAQj8sYACAyLkHE1SnRKl6JYoPMpQurSQVD2ROh6Z6q4hJLHvzYFfe0
 mrfskqhP4gskczv4XdV+Hgqh9CRqdUENB6MA0N+lXRcfxdUJY/4HPoed2wuxfcA0
 EL7fDY0BLC4d80bhXW+5ZfTuQddL50Mx/2XLzjFjMBEoFWE1liUtFUh0WNdaeNru
 ggdes7QGsuct92teUPjfSHxMYFpoNz2cJc4M2mcmvhBedWgVEPdqV6Ys6T29tWAa
 f79JPo4zeI2SsDhYraqtUtckj7IKSNS+PYzgSjlVhY7et4ktREndpFONhoBL0GBc
 4N7EdE/9bSBgOFNnmbyHVJiU8vb+B5USktHK1kIs0dTXs5O8mNtpF1IVjaY9w+MV
 gjBn8D2OQLDuZWDERWazKwmAU4OlSjrcmctip0YanQR/fqC7AxD3VlwpxXuru3Dn
 ZUdgENWVB9CCwpPHmCMY
 =kClF
 -----END PGP SIGNATURE-----

Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi into x86/urgent

Pull EFI bug fixes from Matt Fleming:

 * Fix bugs in our code that converts ucs2 strings to utf8 where we
   unintentionally drop bits from the original string (Jason Andryuk)

 * Add the efi-pstore variables to the variable whitelist so that
   users can continue to delete them via efivarfs without needing to
   manipulate the immutable flag (Matt Fleming)

Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2016-02-16 16:46:40 +01:00
commit 02a5f765c9
2 changed files with 8 additions and 7 deletions

View file

@ -198,6 +198,7 @@ static const struct variable_validate variable_validate[] = {
{ EFI_GLOBAL_VARIABLE_GUID, "OsIndications", NULL },
{ EFI_GLOBAL_VARIABLE_GUID, "PlatformLang", validate_ascii_string },
{ EFI_GLOBAL_VARIABLE_GUID, "Timeout", validate_uint16 },
{ LINUX_EFI_CRASH_GUID, "*", NULL },
{ NULL_GUID, "", NULL },
};

View file

@ -59,9 +59,9 @@ ucs2_utf8size(const ucs2_char_t *src)
for (i = 0; i < ucs2_strlen(src); i++) {
u16 c = src[i];
if (c > 0x800)
if (c >= 0x800)
j += 3;
else if (c > 0x80)
else if (c >= 0x80)
j += 2;
else
j += 1;
@ -88,19 +88,19 @@ ucs2_as_utf8(u8 *dest, const ucs2_char_t *src, unsigned long maxlength)
for (i = 0; maxlength && i < limit; i++) {
u16 c = src[i];
if (c > 0x800) {
if (c >= 0x800) {
if (maxlength < 3)
break;
maxlength -= 3;
dest[j++] = 0xe0 | (c & 0xf000) >> 12;
dest[j++] = 0x80 | (c & 0x0fc0) >> 8;
dest[j++] = 0x80 | (c & 0x0fc0) >> 6;
dest[j++] = 0x80 | (c & 0x003f);
} else if (c > 0x80) {
} else if (c >= 0x80) {
if (maxlength < 2)
break;
maxlength -= 2;
dest[j++] = 0xc0 | (c & 0xfe0) >> 5;
dest[j++] = 0x80 | (c & 0x01f);
dest[j++] = 0xc0 | (c & 0x7c0) >> 6;
dest[j++] = 0x80 | (c & 0x03f);
} else {
maxlength -= 1;
dest[j++] = c & 0x7f;