Re: [PATCH 10/18] Do proper conversion from UTF-16 to UTF-8

From: H. Peter Anvin
Date: Sun Sep 22 2013 - 20:25:25 EST


On 09/22/2013 04:07 PM, Roy Franz wrote:
> On Sun, Sep 22, 2013 at 3:54 PM, H. Peter Anvin <hpa@xxxxxxxxx> wrote:
>> Sorry this version is broken and doesn't even compile due to remaining options_size references.
>
> I compiled and tested this series on both x86_64 (using OVMF) and on
> the ARM simulator. I just doubled checked
> my kernel .config to verify this was not being omitted and I'm pretty
> sure this doesn't have any compilation problems.
> I did make a few changes to get the untested version you sent out to
> compile, but they all seemed to be straightforward typo type fixes.
> I'll gladly address any defects in this patch, but I don't see an
> compilation problems.
>

Ah yes, I see now... you fixed up the compile problem but did so
incorrectly.

int load_options_size = image->load_options_size / 2; /* ASCII */

This is a number of UTF-16 chars, the comment is completely wrong;

- while (*s2 && *s2 != '\n' && options_size <
load_options_size) {
+ while (*s2 && *s2 != '\n' && options_bytes <
load_options_size) {
+ options_bytes += efi_utf8_bytes(*s2);
s2++;
- options_size++;
}
+ options_chars = s2 - options;

You can't compare options_bytes against load_options_size; the latter
being a UTF-16 shortword count.

So the loop really needs to update options_chars in the loop to compare
it against load_options_size:

while (*s2 && *s2 != '\n' && options_chars < load_options_size) {
options_bytes += efi_utf8_bytes(*s2++);
option_chars++;
}

-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/