Alexandre Julliard : msi: Avoid creating zero-length string values in the registry.
Alexandre Julliard
julliard at winehq.org
Wed Apr 23 07:59:15 CDT 2008
Module: wine
Branch: master
Commit: 06bf8ea291576ab03be01f11bb0c7466336ff1ea
URL: http://source.winehq.org/git/wine.git/?a=commit;h=06bf8ea291576ab03be01f11bb0c7466336ff1ea
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Apr 22 17:05:05 2008 +0200
msi: Avoid creating zero-length string values in the registry.
---
dlls/msi/action.c | 6 ++++--
dlls/msi/registry.c | 7 +++++--
dlls/msi/source.c | 2 +-
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 11a4ad7..44fae9d 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -2426,7 +2426,7 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
{
static const WCHAR szEmpty[] = {0};
value_data = (LPSTR)strdupW(szEmpty);
- size = 0;
+ size = sizeof(szEmpty);
type = REG_SZ;
}
@@ -3772,8 +3772,10 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
size = strlenW(feature->Feature_Parent)*sizeof(WCHAR);
if (!absent)
{
+ static const WCHAR emptyW[] = {0};
+ size += sizeof(WCHAR);
RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
- (LPBYTE)feature->Feature_Parent,size);
+ (LPBYTE)(feature->Feature_Parent ? feature->Feature_Parent : emptyW),size);
}
else
{
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 74f84f7..b95d5bb 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -381,7 +381,7 @@ DWORD msi_version_str_to_dword(LPCWSTR p)
LPWSTR msi_version_dword_to_str(DWORD version)
{
- const WCHAR fmt[] = { '%','u','.','%','u','.','%','u',0 };
+ static const WCHAR fmt[] = { '%','u','.','%','u','.','%','u',0 };
LPWSTR str = msi_alloc(20);
sprintfW(str, fmt,
(version&0xff000000)>>24,
@@ -392,7 +392,10 @@ LPWSTR msi_version_dword_to_str(DWORD version)
LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
{
- DWORD len = value ? (lstrlenW(value) + 1) * sizeof (WCHAR) : 0;
+ static const WCHAR emptyW[] = {0};
+ DWORD len;
+ if (!value) value = emptyW;
+ len = (lstrlenW(value) + 1) * sizeof (WCHAR);
return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, len );
}
diff --git a/dlls/msi/source.c b/dlls/msi/source.c
index 0f9e087..4c38116 100644
--- a/dlls/msi/source.c
+++ b/dlls/msi/source.c
@@ -822,7 +822,7 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
}
else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
{
- DWORD size = lstrlenW(szValue)*sizeof(WCHAR);
+ DWORD size = (lstrlenW(szValue) + 1) * sizeof(WCHAR);
rc = RegSetValueExW(sourcekey, INSTALLPROPERTY_PACKAGENAMEW, 0,
REG_SZ, (const BYTE *)szValue, size);
if (rc != ERROR_SUCCESS)
More information about the wine-cvs
mailing list