[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/8] registry: Fix wrong truncation of Unicode.Length


  • To: Owen Smith <owen.smith@xxxxxxxxxx>, win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Fri, 14 Aug 2026 12:04:15 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Delivery-date: Fri, 14 Aug 2026 10:04:21 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 14/08/2026 09:30, Owen Smith wrote:
> Assisted-by: ClaudeCode:claude-opus-4.8
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
> ---
>   src/common/registry.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/common/registry.c b/src/common/registry.c

Other drivers will need the same patch as well.

> index 1f7a73c..204e2e8 100644
> --- a/src/common/registry.c
> +++ b/src/common/registry.c
> @@ -1460,11 +1460,13 @@ RegistryAnsiToSz(

Should RegistryAnsiToMultiSz be updated in the same way?

>       if (Partial == NULL)
>           goto fail1;
>   
> +    ASSERT3U(Length * sizeof (WCHAR), <=, 0xFFFF); // MAX_USHORT
> +

If the intent is to unconditionally truncate if 
RtlAnsiStringToUnicodeString fails, I don't know if we would want 
another assert here. If that's not the case, wouldn't it be better to 
simply remove the truncation code path and fail?

>       Partial->TitleIndex = 0;
>       Partial->Type = REG_SZ;
>       Partial->DataLength = Length * sizeof (WCHAR);
>   
> -    Unicode.MaximumLength = (UCHAR)Partial->DataLength;
> +    Unicode.MaximumLength = (USHORT)Partial->DataLength;
>       Unicode.Buffer = (PWCHAR)Partial->Data;
>       Unicode.Length = 0;
>   



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.