Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
debe525f
Commit
debe525f
authored
Jun 16, 2010
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jun 16, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Validate the cabinet filename parameter in SetupIterateCabinetW.
parent
bc21be89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
2 deletions
+118
-2
setupcab.c
dlls/setupapi/setupcab.c
+6
-2
setupcab.c
dlls/setupapi/tests/setupcab.c
+112
-0
No files found.
dlls/setupapi/setupcab.c
View file @
debe525f
...
...
@@ -622,7 +622,7 @@ BOOL WINAPI SetupIterateCabinetW(PCWSTR CabinetFile, DWORD Reserved,
UINT
len
;
SC_HSC_W
my_hsc
;
ERF
erf
;
WCHAR
pszCabPathW
[
MAX_PATH
],
*
p
;
WCHAR
pszCabPathW
[
MAX_PATH
],
*
p
=
NULL
;
DWORD
fpnsize
;
BOOL
ret
;
...
...
@@ -632,7 +632,11 @@ BOOL WINAPI SetupIterateCabinetW(PCWSTR CabinetFile, DWORD Reserved,
if
(
!
LoadCABINETDll
())
return
FALSE
;
if
(
!
CabinetFile
)
return
FALSE
;
if
(
!
CabinetFile
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
fpnsize
=
GetFullPathNameW
(
CabinetFile
,
MAX_PATH
,
pszCabPathW
,
&
p
);
if
(
fpnsize
>
MAX_PATH
)
{
...
...
dlls/setupapi/tests/setupcab.c
View file @
debe525f
...
...
@@ -40,6 +40,17 @@ static void create_source_fileA(LPSTR filename, const BYTE *data, DWORD size)
CloseHandle
(
handle
);
}
static
void
create_source_fileW
(
LPWSTR
filename
,
const
BYTE
*
data
,
DWORD
size
)
{
HANDLE
handle
;
DWORD
written
;
handle
=
CreateFileW
(
filename
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
WriteFile
(
handle
,
data
,
size
,
&
written
,
NULL
);
CloseHandle
(
handle
);
}
static
UINT
CALLBACK
dummy_callbackA
(
PVOID
Context
,
UINT
Notification
,
UINT_PTR
Param1
,
UINT_PTR
Param2
)
{
...
...
@@ -48,6 +59,14 @@ static UINT CALLBACK dummy_callbackA(PVOID Context, UINT Notification,
return
0
;
}
static
UINT
CALLBACK
dummy_callbackW
(
PVOID
Context
,
UINT
Notification
,
UINT_PTR
Param1
,
UINT_PTR
Param2
)
{
ok
(
0
,
"Received unexpected notification (%p, %u, %lu, %lu)
\n
"
,
Context
,
Notification
,
Param1
,
Param2
);
return
0
;
}
static
void
test_invalid_parametersA
(
void
)
{
BOOL
ret
;
...
...
@@ -115,7 +134,100 @@ static void test_invalid_parametersA(void)
DeleteFileA
(
source
);
}
static
void
test_invalid_parametersW
(
void
)
{
static
const
WCHAR
nonexistentW
[]
=
{
'c'
,
':'
,
'\\'
,
'n'
,
'o'
,
'n'
,
'e'
,
'x'
,
'i'
,
's'
,
't'
,
'e'
,
'n'
,
't'
,
'.'
,
'c'
,
'a'
,
'b'
,
0
};
static
const
WCHAR
docW
[]
=
{
'd'
,
'o'
,
'c'
,
0
};
static
const
WCHAR
emptyW
[]
=
{
0
};
BOOL
ret
;
WCHAR
source
[
MAX_PATH
],
temp
[
MAX_PATH
];
int
i
;
const
struct
{
PCWSTR
CabinetFile
;
PSP_FILE_CALLBACK
MsgHandler
;
DWORD
expected_lasterror
;
int
todo_lasterror
;
}
invalid_parameters
[]
=
{
{
nonexistentW
,
NULL
,
ERROR_FILE_NOT_FOUND
},
{
nonexistentW
,
dummy_callbackW
,
ERROR_FILE_NOT_FOUND
},
{
source
,
NULL
,
ERROR_INVALID_DATA
,
1
},
{
source
,
dummy_callbackW
,
ERROR_INVALID_DATA
,
1
},
};
ret
=
SetupIterateCabinetW
(
NULL
,
0
,
NULL
,
NULL
);
if
(
!
ret
&&
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
{
win_skip
(
"SetupIterateCabinetW is not available
\n
"
);
return
;
}
GetTempPathW
(
sizeof
(
temp
)
/
sizeof
(
WCHAR
),
temp
);
GetTempFileNameW
(
temp
,
docW
,
0
,
source
);
create_source_fileW
(
source
,
NULL
,
0
);
for
(
i
=
0
;
i
<
sizeof
(
invalid_parameters
)
/
sizeof
(
invalid_parameters
[
0
]);
i
++
)
{
SetLastError
(
0xdeadbeef
);
ret
=
SetupIterateCabinetW
(
invalid_parameters
[
i
].
CabinetFile
,
0
,
invalid_parameters
[
i
].
MsgHandler
,
NULL
);
ok
(
!
ret
,
"[%d] Expected SetupIterateCabinetW to return 0, got %d
\n
"
,
i
,
ret
);
if
(
invalid_parameters
[
i
].
todo_lasterror
)
{
todo_wine
ok
(
GetLastError
()
==
invalid_parameters
[
i
].
expected_lasterror
,
"[%d] Expected GetLastError() to return %u, got %u
\n
"
,
i
,
invalid_parameters
[
i
].
expected_lasterror
,
GetLastError
());
}
else
{
ok
(
GetLastError
()
==
invalid_parameters
[
i
].
expected_lasterror
,
"[%d] Expected GetLastError() to return %u, got %u
\n
"
,
i
,
invalid_parameters
[
i
].
expected_lasterror
,
GetLastError
());
}
}
SetLastError
(
0xdeadbeef
);
ret
=
SetupIterateCabinetW
(
NULL
,
0
,
NULL
,
NULL
);
ok
(
!
ret
,
"Expected SetupIterateCabinetW to return 0, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
/* Vista/Win2k8 */
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupIterateCabinetW
(
NULL
,
0
,
dummy_callbackW
,
NULL
);
ok
(
!
ret
,
"Expected SetupIterateCabinetW to return 0, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
/* Vista/Win2k8 */
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupIterateCabinetW
(
emptyW
,
0
,
NULL
,
NULL
);
ok
(
!
ret
,
"Expected SetupIterateCabinetW to return 0, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
/* NT4/Win2k */
"Expected GetLastError() to return ERROR_NOT_ENOUGH_MEMORY, got %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupIterateCabinetW
(
emptyW
,
0
,
dummy_callbackW
,
NULL
);
ok
(
!
ret
,
"Expected SetupIterateCabinetW to return 0, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
/* NT4/Win2k */
"Expected GetLastError() to return ERROR_NOT_ENOUGH_MEMORY, got %u
\n
"
,
GetLastError
());
DeleteFileW
(
source
);
}
START_TEST
(
setupcab
)
{
test_invalid_parametersA
();
test_invalid_parametersW
();
}
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