From 66fa5c8c6f8264418a3097edfd82330229a42cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 20 Jul 2013 00:37:47 +0000 Subject: [PATCH] [REGEDIT] Fix the creation of empty REG_MULTI_SZ values (they have to contain only one NULL char, since a multi-string has the form: str1\0str2\0...strN\0\0 where each strI\0 is a null-terminated string, and a multi-string is terminated by a null string. And therefore an empty multi-string has only one null char, corresponding to the terminating null string. svn path=/trunk/; revision=59529 --- reactos/base/applications/regedit/framewnd.c | 15 ++++++++++++--- reactos/base/applications/regedit/listview.c | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/reactos/base/applications/regedit/framewnd.c b/reactos/base/applications/regedit/framewnd.c index af3afb31d1a..7510472bea4 100644 --- a/reactos/base/applications/regedit/framewnd.c +++ b/reactos/base/applications/regedit/framewnd.c @@ -853,10 +853,19 @@ static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType) cbData = sizeof(WCHAR); break; case REG_MULTI_SZ: - cbData = sizeof(WCHAR) * 2; + /* + * WARNING: An empty multi-string has only one null char. + * Indeed, multi-strings are built in the following form: + * str1\0str2\0...strN\0\0 + * where each strI\0 is a null-terminated string, and it + * ends with a terminating empty string. + * Therefore an empty multi-string contains only the terminating + * empty string, that is, one null char. + */ + cbData = sizeof(WCHAR); break; - case REG_QWORD: - cbData = sizeof(DWORD) * 2; + case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */ + cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2; break; default: cbData = 0; diff --git a/reactos/base/applications/regedit/listview.c b/reactos/base/applications/regedit/listview.c index 04eb4c1328d..d187063496a 100644 --- a/reactos/base/applications/regedit/listview.c +++ b/reactos/base/applications/regedit/listview.c @@ -439,7 +439,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor return ((int)dw2 - (int)dw1); } - case REG_QWORD: + case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */ { qw1 = *(DWORDLONG*)l->val; qw2 = *(DWORDLONG*)r->val;