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
ea085768
Commit
ea085768
authored
Oct 02, 2008
by
Aric Stewart
Committed by
Alexandre Julliard
Oct 06, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
version: Check for out of memory in VerInstallFileA/W conversion (Coverity 635).
parent
32af90d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
8 deletions
+65
-8
install.c
dlls/version/install.c
+24
-8
install.c
dlls/version/tests/install.c
+41
-0
No files found.
dlls/version/install.c
View file @
ea085768
...
...
@@ -535,7 +535,7 @@ DWORD WINAPI VerInstallFileW(
LPCWSTR
destdir
,
LPCWSTR
curdir
,
LPWSTR
tmpfile
,
PUINT
tmpfilelen
)
{
LPSTR
wsrcf
=
NULL
,
wsrcd
=
NULL
,
wdestf
=
NULL
,
wdestd
=
NULL
,
wtmpf
=
NULL
,
wcurd
=
NULL
;
DWORD
ret
;
DWORD
ret
=
0
;
UINT
len
;
if
(
srcfilename
)
...
...
@@ -543,34 +543,50 @@ DWORD WINAPI VerInstallFileW(
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
srcfilename
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
wsrcf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
srcfilename
,
-
1
,
wsrcf
,
len
,
NULL
,
NULL
);
else
ret
=
VIF_OUTOFMEMORY
;
}
if
(
srcdir
)
if
(
srcdir
&&
!
ret
)
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
srcdir
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
wsrcd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
srcdir
,
-
1
,
wsrcd
,
len
,
NULL
,
NULL
);
else
ret
=
VIF_OUTOFMEMORY
;
}
if
(
destfilename
)
if
(
destfilename
&&
!
ret
)
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
destfilename
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
wdestf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
destfilename
,
-
1
,
wdestf
,
len
,
NULL
,
NULL
);
else
ret
=
VIF_OUTOFMEMORY
;
}
if
(
destdir
)
if
(
destdir
&&
!
ret
)
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
destdir
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
wdestd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
destdir
,
-
1
,
wdestd
,
len
,
NULL
,
NULL
);
else
ret
=
VIF_OUTOFMEMORY
;
}
if
(
curdir
)
if
(
curdir
&&
!
ret
)
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
curdir
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
wcurd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
curdir
,
-
1
,
wcurd
,
len
,
NULL
,
NULL
);
else
ret
=
VIF_OUTOFMEMORY
;
}
len
=
*
tmpfilelen
*
sizeof
(
WCHAR
);
wtmpf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
ret
=
VerInstallFileA
(
flags
,
wsrcf
,
wdestf
,
wsrcd
,
wdestd
,
wcurd
,
wtmpf
,
&
len
);
if
(
!
ret
)
{
len
=
*
tmpfilelen
*
sizeof
(
WCHAR
);
wtmpf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
!
wtmpf
)
ret
=
VIF_OUTOFMEMORY
;
}
if
(
!
ret
)
ret
=
VerInstallFileA
(
flags
,
wsrcf
,
wdestf
,
wsrcd
,
wdestd
,
wcurd
,
wtmpf
,
&
len
);
if
(
!
ret
)
*
tmpfilelen
=
MultiByteToWideChar
(
CP_ACP
,
0
,
wtmpf
,
-
1
,
tmpfile
,
*
tmpfilelen
);
else
if
(
ret
&
VIF_BUFFTOOSMALL
)
...
...
dlls/version/tests/install.c
View file @
ea085768
...
...
@@ -165,7 +165,48 @@ static void test_find_file(void)
}
}
static
void
test_install_file
(
void
)
{
CHAR
tmpname
[
MAX_PATH
];
UINT
size
=
MAX_PATH
;
DWORD
rc
;
static
const
CHAR
szSrcFileName
[]
=
"nofile.txt"
;
static
const
CHAR
szDestFileName
[]
=
"nofile2.txt"
;
static
const
CHAR
szSrcDir
[]
=
"D:
\\
oes
\\
not
\\
exist"
;
static
const
CHAR
szDestDir
[]
=
"D:
\\
oes
\\
not
\\
exist
\\
either"
;
static
const
CHAR
szCurDir
[]
=
"C:
\\
"
;
/* testing Invalid Parameters */
memset
(
tmpname
,
0
,
sizeof
(
tmpname
));
rc
=
VerInstallFileA
(
0x0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
tmpname
,
&
size
);
ok
(
rc
==
0x10000
&&
tmpname
[
0
]
==
0
,
" expected return 0x10000 and no tempname, got %08x/
\'
%s
\'\n
"
,
rc
,
tmpname
);
memset
(
tmpname
,
0
,
sizeof
(
tmpname
));
size
=
MAX_PATH
;
rc
=
VerInstallFileA
(
0x0
,
szSrcFileName
,
NULL
,
NULL
,
NULL
,
NULL
,
tmpname
,
&
size
);
memset
(
tmpname
,
0
,
sizeof
(
tmpname
));
ok
(
rc
==
0x10000
&&
tmpname
[
0
]
==
0
,
" expected return 0x10000 and no tempname, got %08x/
\'
%s
\'\n
"
,
rc
,
tmpname
);
size
=
MAX_PATH
;
rc
=
VerInstallFileA
(
0x0
,
szSrcFileName
,
szDestFileName
,
NULL
,
NULL
,
NULL
,
tmpname
,
&
size
);
memset
(
tmpname
,
0
,
sizeof
(
tmpname
));
ok
(
rc
==
0x10000
&&
tmpname
[
0
]
==
0
,
" expected return 0x10000 and no tempname, got %08x/
\'
%s
\'\n
"
,
rc
,
tmpname
);
size
=
MAX_PATH
;
rc
=
VerInstallFileA
(
0x0
,
szSrcFileName
,
szDestFileName
,
szSrcDir
,
NULL
,
NULL
,
tmpname
,
&
size
);
memset
(
tmpname
,
0
,
sizeof
(
tmpname
));
ok
(
rc
==
0x10000
&&
tmpname
[
0
]
==
0
,
" expected return 0x10000 and no tempname, got %08x/
\'
%s
\'\n
"
,
rc
,
tmpname
);
/* Source file does not exist*/
size
=
MAX_PATH
;
rc
=
VerInstallFileA
(
0x0
,
szSrcFileName
,
szDestFileName
,
szSrcDir
,
szDestDir
,
NULL
,
tmpname
,
&
size
);
memset
(
tmpname
,
0
,
sizeof
(
tmpname
));
ok
(
rc
==
0x10000
&&
tmpname
[
0
]
==
0
,
" expected return 0x10000 and no tempname, got %08x/
\'
%s
\'\n
"
,
rc
,
tmpname
);
size
=
MAX_PATH
;
rc
=
VerInstallFileA
(
0x0
,
szSrcFileName
,
szDestFileName
,
szSrcDir
,
szDestDir
,
szCurDir
,
tmpname
,
&
size
);
ok
(
rc
==
0x10000
&&
tmpname
[
0
]
==
0
,
" expected return 0x10000 and no tempname, got %08x/
\'
%s
\'\n
"
,
rc
,
tmpname
);
}
START_TEST
(
install
)
{
test_find_file
();
test_install_file
();
}
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