From 64312c4fd44d2d1892d9073c27d826b17b55af8d Mon Sep 17 00:00:00 2001 From: winesync Date: Sun, 16 Jan 2022 21:17:20 +0100 Subject: [PATCH] [WINESYNC] reg: Prevent buffer over-read when querying REG_NONE values with no data. Signed-off-by: Hugh McMaster Signed-off-by: Alexandre Julliard wine commit id 60c8dfdd0bbaff4a2369f884ec1a553a06735676 by Hugh McMaster --- base/applications/cmdutils/reg/query.c | 8 ++++++++ sdk/tools/winesync/reg.cfg | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/base/applications/cmdutils/reg/query.c b/base/applications/cmdutils/reg/query.c index 7e42719faf9..4886fb84bc1 100644 --- a/base/applications/cmdutils/reg/query.c +++ b/base/applications/cmdutils/reg/query.c @@ -50,7 +50,15 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes) WCHAR *ptr; buffer = malloc((size_bytes * 2 + 1) * sizeof(WCHAR)); + + if (!size_bytes) + { + *buffer = 0; + break; + } + ptr = buffer; + for (i = 0; i < size_bytes; i++) ptr += swprintf(ptr, 3, L"%02X", src[i]); break; diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 0922b41dd80..3b85d966bea 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 1dd785d1490f64c33e89003453f7c82292d185d5 + wine: 60c8dfdd0bbaff4a2369f884ec1a553a06735676