Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
52a87c90
Commit
52a87c90
authored
Oct 29, 2012
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msi: Add a length parameter to msi_strcpy_to_awstring and use it where appropriate.
parent
2a31a3c0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
52 deletions
+40
-52
format.c
dlls/msi/format.c
+1
-1
install.c
dlls/msi/install.c
+17
-22
msi.c
dlls/msi/msi.c
+14
-19
msipriv.h
dlls/msi/msipriv.h
+1
-1
package.c
dlls/msi/package.c
+4
-5
registry.c
dlls/msi/registry.c
+3
-4
No files found.
dlls/msi/format.c
View file @
52a87c90
...
...
@@ -934,7 +934,7 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord,
wstr
.
unicode
=
TRUE
;
wstr
.
str
.
w
=
szResult
;
r
=
msi_strcpy_to_awstring
(
value
,
&
wstr
,
sz
);
r
=
msi_strcpy_to_awstring
(
value
,
SysStringLen
(
value
),
&
wstr
,
sz
);
done:
IWineMsiRemotePackage_Release
(
remote_package
);
...
...
dlls/msi/install.c
View file @
52a87c90
...
...
@@ -178,32 +178,28 @@ UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode
return
ret
;
}
UINT
msi_strcpy_to_awstring
(
LPCWSTR
str
,
awstring
*
awbuf
,
DWORD
*
sz
)
UINT
msi_strcpy_to_awstring
(
const
WCHAR
*
str
,
int
len
,
awstring
*
awbuf
,
DWORD
*
sz
)
{
UINT
len
,
r
=
ERROR_SUCCESS
;
UINT
r
=
ERROR_SUCCESS
;
if
(
awbuf
->
str
.
w
&&
!
sz
)
if
(
awbuf
->
str
.
w
&&
!
sz
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
sz
)
return
r
;
return
ERROR_SUCCESS
;
if
(
awbuf
->
unicode
)
{
len
=
lstrlenW
(
str
);
if
(
awbuf
->
str
.
w
)
lstrcpynW
(
awbuf
->
str
.
w
,
str
,
*
sz
);
}
if
(
len
<
0
)
len
=
strlenW
(
str
);
if
(
awbuf
->
unicode
&&
awbuf
->
str
.
w
)
memcpy
(
awbuf
->
str
.
w
,
str
,
min
(
len
+
1
,
*
sz
)
*
sizeof
(
WCHAR
)
);
else
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
len
)
len
--
;
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
awbuf
->
str
.
a
,
*
sz
,
NULL
,
NULL
);
if
(
awbuf
->
str
.
a
&&
*
sz
&&
(
len
>=
*
sz
)
)
int
lenA
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
len
+
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
lenA
)
lenA
--
;
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
len
+
1
,
awbuf
->
str
.
a
,
*
sz
,
NULL
,
NULL
);
if
(
awbuf
->
str
.
a
&&
*
sz
&&
lenA
>=
*
sz
)
awbuf
->
str
.
a
[
*
sz
-
1
]
=
0
;
len
=
lenA
;
}
if
(
awbuf
->
str
.
w
&&
len
>=
*
sz
)
r
=
ERROR_MORE_DATA
;
*
sz
=
len
;
...
...
@@ -277,7 +273,7 @@ static UINT MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
if
(
FAILED
(
hr
))
goto
done
;
r
=
msi_strcpy_to_awstring
(
value
,
szPathBuf
,
pcchPathBuf
);
r
=
msi_strcpy_to_awstring
(
value
,
len
,
szPathBuf
,
pcchPathBuf
);
done:
IWineMsiRemotePackage_Release
(
remote_package
);
...
...
@@ -301,8 +297,7 @@ done:
if
(
!
path
)
return
ERROR_DIRECTORY
;
r
=
msi_strcpy_to_awstring
(
path
,
szPathBuf
,
pcchPathBuf
);
return
r
;
return
msi_strcpy_to_awstring
(
path
,
-
1
,
szPathBuf
,
pcchPathBuf
);
}
/***********************************************************************
...
...
@@ -447,7 +442,7 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
if
(
FAILED
(
hr
))
goto
done
;
r
=
msi_strcpy_to_awstring
(
value
,
szPathBuf
,
pcchPathBuf
);
r
=
msi_strcpy_to_awstring
(
value
,
len
,
szPathBuf
,
pcchPathBuf
);
done:
IWineMsiRemotePackage_Release
(
remote_package
);
...
...
@@ -478,7 +473,7 @@ done:
if
(
!
path
)
return
ERROR_DIRECTORY
;
r
=
msi_strcpy_to_awstring
(
path
,
szPathBuf
,
pcchPathBuf
);
r
=
msi_strcpy_to_awstring
(
path
,
-
1
,
szPathBuf
,
pcchPathBuf
);
msi_free
(
path
);
return
r
;
}
...
...
dlls/msi/msi.c
View file @
52a87c90
...
...
@@ -1101,6 +1101,11 @@ static LPWSTR msi_reg_get_value(HKEY hkey, LPCWSTR name, DWORD *type)
static
UINT
MSI_GetProductInfo
(
LPCWSTR
szProduct
,
LPCWSTR
szAttribute
,
awstring
*
szValue
,
LPDWORD
pcchValueBuf
)
{
static
WCHAR
empty
[]
=
{
0
};
static
const
WCHAR
sourcelist
[]
=
{
'S'
,
'o'
,
'u'
,
'r'
,
'c'
,
'e'
,
'L'
,
'i'
,
's'
,
't'
,
0
};
static
const
WCHAR
display_name
[]
=
{
'D'
,
'i'
,
's'
,
'p'
,
'l'
,
'a'
,
'y'
,
'N'
,
'a'
,
'm'
,
'e'
,
0
};
static
const
WCHAR
display_version
[]
=
{
'D'
,
'i'
,
's'
,
'p'
,
'l'
,
'a'
,
'y'
,
'V'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
0
};
static
const
WCHAR
assignment
[]
=
{
'A'
,
's'
,
's'
,
'i'
,
'g'
,
'n'
,
'm'
,
'e'
,
'n'
,
't'
,
0
};
MSIINSTALLCONTEXT
context
=
MSIINSTALLCONTEXT_USERUNMANAGED
;
UINT
r
=
ERROR_UNKNOWN_PROPERTY
;
HKEY
prodkey
,
userdata
,
source
;
...
...
@@ -1111,16 +1116,6 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
LONG
res
;
DWORD
type
=
REG_NONE
;
static
WCHAR
empty
[]
=
{
0
};
static
const
WCHAR
sourcelist
[]
=
{
'S'
,
'o'
,
'u'
,
'r'
,
'c'
,
'e'
,
'L'
,
'i'
,
's'
,
't'
,
0
};
static
const
WCHAR
display_name
[]
=
{
'D'
,
'i'
,
's'
,
'p'
,
'l'
,
'a'
,
'y'
,
'N'
,
'a'
,
'm'
,
'e'
,
0
};
static
const
WCHAR
display_version
[]
=
{
'D'
,
'i'
,
's'
,
'p'
,
'l'
,
'a'
,
'y'
,
'V'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
0
};
static
const
WCHAR
assignment
[]
=
{
'A'
,
's'
,
's'
,
'i'
,
'g'
,
'n'
,
'm'
,
'e'
,
'n'
,
't'
,
0
};
TRACE
(
"%s %s %p %p
\n
"
,
debugstr_w
(
szProduct
),
debugstr_w
(
szAttribute
),
szValue
,
pcchValueBuf
);
...
...
@@ -1244,6 +1239,8 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
if
(
pcchValueBuf
)
{
int
len
=
strlenW
(
val
);
/* If szBuffer (szValue->str) is NULL, there's no need to copy the value
* out. Also, *pcchValueBuf may be uninitialized in this case, so we
* can't rely on its value.
...
...
@@ -1251,16 +1248,14 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
if
(
szValue
->
str
.
a
||
szValue
->
str
.
w
)
{
DWORD
size
=
*
pcchValueBuf
;
if
(
strlenW
(
val
)
<
size
)
r
=
msi_strcpy_to_awstring
(
val
,
szValue
,
&
size
);
if
(
len
<
size
)
r
=
msi_strcpy_to_awstring
(
val
,
len
,
szValue
,
&
size
);
else
{
r
=
ERROR_MORE_DATA
;
}
}
if
(
!
badconfig
)
*
pcchValueBuf
=
l
strlenW
(
val
)
;
*
pcchValueBuf
=
l
en
;
}
if
(
badconfig
)
...
...
@@ -2867,7 +2862,7 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
if
(
state
==
INSTALLSTATE_LOCAL
&&
!*
path
)
state
=
INSTALLSTATE_NOTUSED
;
msi_strcpy_to_awstring
(
path
,
lpPathBuf
,
pcchBuf
);
msi_strcpy_to_awstring
(
path
,
-
1
,
lpPathBuf
,
pcchBuf
);
msi_free
(
path
);
return
state
;
}
...
...
@@ -3521,7 +3516,7 @@ static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
goto
done
;
}
r
=
msi_strcpy_to_awstring
(
user
,
lpUserNameBuf
,
pcchUserNameBuf
);
r
=
msi_strcpy_to_awstring
(
user
,
-
1
,
lpUserNameBuf
,
pcchUserNameBuf
);
if
(
r
==
ERROR_MORE_DATA
)
{
state
=
USERINFOSTATE_MOREDATA
;
...
...
@@ -3534,7 +3529,7 @@ static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
orgptr
=
org
;
if
(
!
orgptr
)
orgptr
=
szEmpty
;
r
=
msi_strcpy_to_awstring
(
orgptr
,
lpOrgNameBuf
,
pcchOrgNameBuf
);
r
=
msi_strcpy_to_awstring
(
orgptr
,
-
1
,
lpOrgNameBuf
,
pcchOrgNameBuf
);
if
(
r
==
ERROR_MORE_DATA
)
{
state
=
USERINFOSTATE_MOREDATA
;
...
...
@@ -3550,7 +3545,7 @@ static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
goto
done
;
}
r
=
msi_strcpy_to_awstring
(
serial
,
lpSerialBuf
,
pcchSerialBuf
);
r
=
msi_strcpy_to_awstring
(
serial
,
-
1
,
lpSerialBuf
,
pcchSerialBuf
);
if
(
r
==
ERROR_MORE_DATA
)
state
=
USERINFOSTATE_MOREDATA
;
}
...
...
dlls/msi/msipriv.h
View file @
52a87c90
...
...
@@ -724,7 +724,7 @@ typedef struct {
}
str
;
}
awcstring
;
UINT
msi_strcpy_to_awstring
(
LPCWSTR
str
,
awstring
*
awbuf
,
DWORD
*
sz
)
DECLSPEC_HIDDEN
;
UINT
msi_strcpy_to_awstring
(
const
WCHAR
*
,
int
,
awstring
*
,
DWORD
*
)
DECLSPEC_HIDDEN
;
/* msi server interface */
extern
HRESULT
create_msi_custom_remote
(
IUnknown
*
pOuter
,
LPVOID
*
ppObj
)
DECLSPEC_HIDDEN
;
...
...
dlls/msi/package.c
View file @
52a87c90
...
...
@@ -2232,6 +2232,7 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
MSIRECORD
*
row
=
NULL
;
UINT
r
=
ERROR_FUNCTION_FAILED
;
LPCWSTR
val
=
NULL
;
DWORD
len
=
0
;
TRACE
(
"%u %s %p %p
\n
"
,
handle
,
debugstr_w
(
name
),
szValueBuf
->
str
.
w
,
pchValueBuf
);
...
...
@@ -2246,7 +2247,6 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
IWineMsiRemotePackage
*
remote_package
;
LPWSTR
value
=
NULL
;
BSTR
bname
;
DWORD
len
;
remote_package
=
(
IWineMsiRemotePackage
*
)
msi_get_remote
(
handle
);
if
(
!
remote_package
)
...
...
@@ -2259,7 +2259,6 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
return
ERROR_OUTOFMEMORY
;
}
len
=
0
;
hr
=
IWineMsiRemotePackage_GetProperty
(
remote_package
,
bname
,
NULL
,
&
len
);
if
(
FAILED
(
hr
))
goto
done
;
...
...
@@ -2276,7 +2275,7 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
if
(
FAILED
(
hr
))
goto
done
;
r
=
msi_strcpy_to_awstring
(
value
,
szValueBuf
,
pchValueBuf
);
r
=
msi_strcpy_to_awstring
(
value
,
len
,
szValueBuf
,
pchValueBuf
);
/* Bug required by Adobe installers */
if
(
!
szValueBuf
->
unicode
&&
!
szValueBuf
->
str
.
a
)
...
...
@@ -2300,12 +2299,12 @@ done:
row
=
msi_get_property_row
(
package
->
db
,
name
);
if
(
row
)
val
=
MSI_RecordGetString
(
row
,
1
);
val
=
msi_record_get_string
(
row
,
1
,
(
int
*
)
&
len
);
if
(
!
val
)
val
=
szEmpty
;
r
=
msi_strcpy_to_awstring
(
val
,
szValueBuf
,
pchValueBuf
);
r
=
msi_strcpy_to_awstring
(
val
,
len
,
szValueBuf
,
pchValueBuf
);
if
(
row
)
msiobj_release
(
&
row
->
hdr
);
...
...
dlls/msi/registry.c
View file @
52a87c90
...
...
@@ -1557,7 +1557,7 @@ static UINT MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
}
r
=
ERROR_OUTOFMEMORY
;
if
(
(
name_sz
+
1
)
>=
name_max
)
if
(
name_sz
+
1
>=
name_max
)
{
name_max
*=
2
;
msi_free
(
name
);
...
...
@@ -1586,8 +1586,8 @@ static UINT MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
TRACE
(
"Providing %s and %s
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
val
+
ofs
));
r
=
msi_strcpy_to_awstring
(
name
,
lpQualBuf
,
pcchQual
);
r2
=
msi_strcpy_to_awstring
(
val
+
ofs
,
lpAppBuf
,
pcchAppBuf
);
r
=
msi_strcpy_to_awstring
(
name
,
-
1
,
lpQualBuf
,
pcchQual
);
r2
=
msi_strcpy_to_awstring
(
val
+
ofs
,
-
1
,
lpAppBuf
,
pcchAppBuf
);
if
(
r2
!=
ERROR_SUCCESS
)
r
=
r2
;
...
...
@@ -1596,7 +1596,6 @@ end:
msi_free
(
val
);
msi_free
(
name
);
RegCloseKey
(
key
);
return
r
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment