Author: hbelusca
Date: Fri Jun 2 00:05:53 2017
New Revision: 74740
URL:
http://svn.reactos.org/svn/reactos?rev=74740&view=rev
Log:
[MKHIVE]: Fix string byte size vs. count in number of characters confusion in
append_multi_sz_value(); this was already OK in wine's code. Should fix corrupted
multi-string entries in the livecd registry hives, for example...
In addition, always open the hive file to be created in write mode only.
CORE-13347
Modified:
trunk/reactos/sdk/tools/mkhive/binhive.c
trunk/reactos/sdk/tools/mkhive/reginf.c
Modified: trunk/reactos/sdk/tools/mkhive/binhive.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/tools/mkhive/binhive.c…
==============================================================================
--- trunk/reactos/sdk/tools/mkhive/binhive.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/tools/mkhive/binhive.c [iso-8859-1] Fri Jun 2 00:05:53 2017
@@ -41,7 +41,7 @@
printf(" Creating binary hive: %s\n", FileName);
/* Create new hive file */
- File = fopen(FileName, "w+b");
+ File = fopen(FileName, "wb");
if (File == NULL)
{
printf(" Error creating/opening file\n");
Modified: trunk/reactos/sdk/tools/mkhive/reginf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/tools/mkhive/reginf.c?…
==============================================================================
--- trunk/reactos/sdk/tools/mkhive/reginf.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/tools/mkhive/reginf.c [iso-8859-1] Fri Jun 2 00:05:53 2017
@@ -120,11 +120,10 @@
IN HKEY KeyHandle,
IN PWCHAR ValueName,
IN PWCHAR Strings,
- IN ULONG StringSize)
+ IN ULONG StringSize) // In characters
{
- ULONG Size;
+ ULONG Size, Total; // In bytes
ULONG Type;
- ULONG Total;
PWCHAR Buffer;
PWCHAR p;
size_t len;
@@ -139,7 +138,7 @@
if ((Error != ERROR_SUCCESS) || (Type != REG_MULTI_SZ))
return;
- Buffer = malloc ((Size + StringSize) * sizeof(WCHAR));
+ Buffer = malloc(Size + StringSize * sizeof(WCHAR));
if (Buffer == NULL)
return;
@@ -164,9 +163,9 @@
if (*p == 0) /* not found, need to append it */
{
- memcpy (p, Strings, len);
+ memcpy(p, Strings, len * sizeof(WCHAR));
p[len] = 0;
- Total += len;
+ Total += len * sizeof(WCHAR);
}
Strings += len;
}
@@ -179,7 +178,7 @@
0,
REG_MULTI_SZ,
(PUCHAR)Buffer,
- Total * sizeof(WCHAR));
+ Total + sizeof(WCHAR));
}
done: