Re: [PATCH v2 2/3] platform/x86: hp-bioscfg: fix non-ASCII truncation in hp_get_string_from_buffer()
From: Andy Shevchenko
Date: Mon Sep 28 2026 - 17:33:14 EST
On Mon, Sep 28, 2026 at 11:03 PM Muhammad Bilal <meatuni001@xxxxxxxxx> wrote:
>
> utf16s_to_utf8s() writes into dst, but the manual loop that follows
> re-walks src from the start and overwrites dst with truncating casts
> (dst[i] = *src), discarding the UTF-8 output. Any code point above
> U+007F produces garbage.
>
> Replace both with a two-stage conversion: utf16s_to_utf8s() into a
> scratch buffer, then string_escape_mem(ESCAPE_SPACE | ESCAPE_SPECIAL,
> "\\\r\n\t") into dst. Passing the four characters to @only avoids
> escaping quotes, leaving them for the existing strreplace() call.
>
> Tested on HP EliteBook 840 G2 (Fedora 44, Linux 7.2.7).
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
> Suggested-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
Wrong tag. I have not suggested the (main) idea behind this change.
You're not supposed to arbitrarily add some tags without respective
consent.
> Fixes: a34fc329b189 ("platform/x86: hp-bioscfg: bioscfg")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Muhammad Bilal <meatuni001@xxxxxxxxx>
...
> #include <linux/string.h>
> +#include <linux/string_helpers.h>
You can replace string.h with string_helpers.h as the latter implies the former.
...
> u16 *src = (u16 *)*buffer;
> u16 src_size;
>
> + char utf8_buf[MAX_BUFF_SIZE];
Try to preserve reversed xmas tree order.
> u16 orig_size;
> - u16 size;
> - int i;
> - int conv_dst_size;
> + int utf8_len;
> + int escaped_len;
--
With Best Regards,
Andy Shevchenko