[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/8] registry: Fix wrong truncation of Unicode.Length
- To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Owen Smith <owen.smith@xxxxxxxxxx>
- Date: Fri, 14 Aug 2026 11:58:01 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RAFnGhvrcwPPgmz5IRYh4beY2DEJr+2vb2ASy2CBPDg=; b=iDdmq2tDlkC0VuCUV6kqjBT1LFwSi5yjX5jCe0bVul4p2Gfkmf9KrQ72QrOlfJJ9luyyUsq2VkdPkgDxV3yzNAymEm0bbb9J4NOUz6MsRr2RAqT0JiUwHGVFRJOe6D4EFGjyA9GRjSvDniz2RDfRqaovL6kZxn9yEPZMrx/ukS25h0tg/oBMScRQ7p4owSpuxJqw7CHnkqHfT2GUQsI+bqc+e0lWl9MSYp6AStS+/HPOflPCIqT1eLWg27+JY2ZxTfb0CHNf1lMKmJZMareyQ16XkqeLzrNKbF6z2/srnl9Nts+ab41WcABD51ToM++/oU0VfpnQT0/uUA1k2iGIqA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SRcPIz9gBJ63WoHkMkf5mJvJyOeFP4dsJT6jUWdTLtxncv84nWrxbwKcv92ZKHh2SYKjweYcgYUcp669hpUuUlhcd9U1vp4642iHrhqPtEXJ1Om8xoDDCTQdsJqz2mRh5qRZVK8nDwIkDaDVb4WkApYk1KRc+rTagRvOTyZUhgeH8nubj3z/7uWcs02ZoE4Ld9vVnScUn1UYH/veWuu1G95/V74M36HSQ6OEa08zpRSnlVjD835Nmwk/AkOVmKSctoq0+BHlh2AmuhERwMDC7z2W5fRcr+vAeyuFTLxT0/EHLDv3PEkLCIY/OJKbn5hlOp+8D2VpjCWYPbz8ZjjDgA==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Delivery-date: Fri, 14 Aug 2026 11:58:09 +0000
- List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
- Msip_labels:
- Thread-index: AQHdK7681agTujSIwE+S8mNzjuInbradUQiAgAAfdVk=
- Thread-topic: [PATCH 4/8] registry: Fix wrong truncation of Unicode.Length
>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?
>
detecting an overrun and failing would be better - I will rework this patch
>> 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;
>>
|