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
d4e9b2cd
Commit
d4e9b2cd
authored
Jan 31, 2013
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 31, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msi: Fix the return value of MsiGetFileVersion for some corner cases.
parent
cafbad3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
3 deletions
+42
-3
msi.c
dlls/msi/msi.c
+5
-3
msi.c
dlls/msi/tests/msi.c
+37
-0
No files found.
dlls/msi/msi.c
View file @
d4e9b2cd
...
...
@@ -3158,7 +3158,7 @@ static UINT get_file_version( const WCHAR *path, WCHAR *verbuf, DWORD *verlen,
static
const
WCHAR
szVersionResource
[]
=
{
'\\'
,
0
};
static
const
WCHAR
szVersionFormat
[]
=
{
'%'
,
'd'
,
'.'
,
'%'
,
'd'
,
'.'
,
'%'
,
'd'
,
'.'
,
'%'
,
'd'
,
0
};
static
const
WCHAR
szLangFormat
[]
=
{
'%'
,
'd'
,
0
};
UINT
ret
=
ERROR_
SUCCESS
;
UINT
ret
=
ERROR_
MORE_DATA
;
DWORD
len
,
error
;
LPVOID
version
;
VS_FIXEDFILEINFO
*
ffi
;
...
...
@@ -3169,6 +3169,7 @@ static UINT get_file_version( const WCHAR *path, WCHAR *verbuf, DWORD *verlen,
{
error
=
GetLastError
();
if
(
error
==
ERROR_BAD_PATHNAME
)
return
ERROR_FILE_NOT_FOUND
;
if
(
error
==
ERROR_RESOURCE_DATA_NOT_FOUND
)
return
ERROR_FILE_INVALID
;
return
error
;
}
if
(
!
(
version
=
msi_alloc
(
len
)))
return
ERROR_OUTOFMEMORY
;
...
...
@@ -3177,6 +3178,7 @@ static UINT get_file_version( const WCHAR *path, WCHAR *verbuf, DWORD *verlen,
msi_free
(
version
);
return
GetLastError
();
}
if
(
!
verbuf
&&
!
verlen
&&
!
langbuf
&&
!
langlen
)
return
ERROR_SUCCESS
;
if
(
verlen
)
{
if
(
VerQueryValueW
(
version
,
szVersionResource
,
(
LPVOID
*
)
&
ffi
,
&
len
)
&&
len
>
0
)
...
...
@@ -3186,7 +3188,7 @@ static UINT get_file_version( const WCHAR *path, WCHAR *verbuf, DWORD *verlen,
HIWORD
(
ffi
->
dwFileVersionLS
),
LOWORD
(
ffi
->
dwFileVersionLS
)
);
if
(
verbuf
)
lstrcpynW
(
verbuf
,
tmp
,
*
verlen
);
len
=
strlenW
(
tmp
);
if
(
len
>=
*
verlen
)
ret
=
ERROR_MORE_DATA
;
if
(
*
verlen
>
len
)
ret
=
ERROR_SUCCESS
;
*
verlen
=
len
;
}
else
...
...
@@ -3202,7 +3204,7 @@ static UINT get_file_version( const WCHAR *path, WCHAR *verbuf, DWORD *verlen,
sprintfW
(
tmp
,
szLangFormat
,
*
lang
);
if
(
langbuf
)
lstrcpynW
(
langbuf
,
tmp
,
*
langlen
);
len
=
strlenW
(
tmp
);
if
(
len
>=
*
langlen
)
ret
=
ERROR_MORE_DATA
;
if
(
*
langlen
>
len
)
ret
=
ERROR_SUCCESS
;
*
langlen
=
len
;
}
else
...
...
dlls/msi/tests/msi.c
View file @
d4e9b2cd
...
...
@@ -2829,6 +2829,9 @@ static void test_MsiGetFileVersion(void)
DWORD
verchecksz
,
langchecksz
;
/* NULL szFilePath */
r
=
MsiGetFileVersionA
(
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
r
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
r
);
versz
=
MAX_PATH
;
langsz
=
MAX_PATH
;
lstrcpyA
(
version
,
"version"
);
...
...
@@ -2844,6 +2847,9 @@ static void test_MsiGetFileVersion(void)
ok
(
langsz
==
MAX_PATH
,
"Expected %d, got %d
\n
"
,
MAX_PATH
,
langsz
);
/* empty szFilePath */
r
=
MsiGetFileVersionA
(
""
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
r
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND, got %d
\n
"
,
r
);
versz
=
MAX_PATH
;
langsz
=
MAX_PATH
;
lstrcpyA
(
version
,
"version"
);
...
...
@@ -2941,6 +2947,9 @@ static void test_MsiGetFileVersion(void)
create_file
(
"ver.txt"
,
"ver.txt"
,
20
);
/* file exists, no version information */
r
=
MsiGetFileVersionA
(
"ver.txt"
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
r
==
ERROR_FILE_INVALID
,
"Expected ERROR_FILE_INVALID, got %d
\n
"
,
r
);
versz
=
MAX_PATH
;
langsz
=
MAX_PATH
;
lstrcpyA
(
version
,
"version"
);
...
...
@@ -3042,6 +3051,34 @@ static void test_MsiGetFileVersion(void)
"Expected first character of %s, got %s
\n
"
,
langcheck
,
lang
);
ok
(
langsz
>=
langchecksz
,
"Expected %d >= %d
\n
"
,
langsz
,
langchecksz
);
/* pcchVersionBuf big enough, pcchLangBuf not big enough */
versz
=
MAX_PATH
;
langsz
=
0
;
lstrcpyA
(
version
,
"version"
);
r
=
MsiGetFileVersionA
(
path
,
version
,
&
versz
,
NULL
,
&
langsz
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
ok
(
versz
==
verchecksz
,
"Expected %d, got %d
\n
"
,
verchecksz
,
versz
);
ok
(
!
lstrcmpA
(
version
,
vercheck
),
"Expected %s, got %s
\n
"
,
vercheck
,
version
);
ok
(
langsz
>=
langchecksz
&&
langsz
<
MAX_PATH
,
"Expected %d >= %d
\n
"
,
langsz
,
langchecksz
);
/* pcchVersionBuf not big enough, pcchLangBuf big enough */
versz
=
5
;
langsz
=
MAX_PATH
;
lstrcpyA
(
lang
,
"lang"
);
r
=
MsiGetFileVersionA
(
path
,
NULL
,
&
versz
,
lang
,
&
langsz
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
ok
(
versz
==
verchecksz
,
"Expected %d, got %d
\n
"
,
verchecksz
,
versz
);
ok
(
langsz
>=
langchecksz
&&
langsz
<
MAX_PATH
,
"Expected %d >= %d
\n
"
,
langsz
,
langchecksz
);
ok
(
lstrcmpA
(
lang
,
"lang"
),
"lang buffer not modified
\n
"
);
/* NULL pcchVersionBuf and pcchLangBuf */
r
=
MsiGetFileVersionA
(
path
,
version
,
NULL
,
lang
,
NULL
);
ok
(
r
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
r
);
/* All NULL except szFilePath */
r
=
MsiGetFileVersionA
(
path
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
HeapFree
(
GetProcessHeap
(),
0
,
vercheck
);
HeapFree
(
GetProcessHeap
(),
0
,
langcheck
);
}
...
...
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