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
0ab56b88
Commit
0ab56b88
authored
Feb 06, 2023
by
Zebediah Figura
Committed by
Alexandre Julliard
Feb 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Fail installation when trying to append to a registry value of the wrong type.
parent
d7c8279c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
install.c
dlls/setupapi/install.c
+22
-7
install.c
dlls/setupapi/tests/install.c
+2
-2
No files found.
dlls/setupapi/install.c
View file @
0ab56b88
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
*/
*/
#include <stdarg.h>
#include <stdarg.h>
#include <stdbool.h>
#define COBJMACROS
#define COBJMACROS
...
@@ -227,17 +228,26 @@ static HKEY get_root_key( const WCHAR *name, HKEY def_root )
...
@@ -227,17 +228,26 @@ static HKEY get_root_key( const WCHAR *name, HKEY def_root )
*
*
* Append a multisz string to a multisz registry value.
* Append a multisz string to a multisz registry value.
*/
*/
static
void
append_multi_sz_value
(
HKEY
hkey
,
const
WCHAR
*
value
,
const
WCHAR
*
strings
,
static
bool
append_multi_sz_value
(
HKEY
hkey
,
const
WCHAR
*
value
,
const
WCHAR
*
strings
,
DWORD
str_size
)
DWORD
str_size
)
{
{
DWORD
size
,
type
,
total
;
DWORD
size
,
type
,
total
;
WCHAR
*
buffer
,
*
p
;
WCHAR
*
buffer
,
*
p
;
if
(
RegQueryValueExW
(
hkey
,
value
,
NULL
,
&
type
,
NULL
,
&
size
))
return
;
if
(
RegQueryValueExW
(
hkey
,
value
,
NULL
,
&
type
,
NULL
,
&
size
))
return
true
;
if
(
type
!=
REG_MULTI_SZ
)
return
;
if
(
type
!=
REG_MULTI_SZ
)
{
WARN
(
"value %s exists but has wrong type %#lx
\n
"
,
debugstr_w
(
value
),
type
);
SetLastError
(
ERROR_INVALID_DATA
);
return
false
;
}
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
size
+
str_size
)
*
sizeof
(
WCHAR
)
)))
return
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
size
+
str_size
)
*
sizeof
(
WCHAR
)
)))
return
false
;
if
(
RegQueryValueExW
(
hkey
,
value
,
NULL
,
NULL
,
(
BYTE
*
)
buffer
,
&
size
))
goto
done
;
if
(
RegQueryValueExW
(
hkey
,
value
,
NULL
,
NULL
,
(
BYTE
*
)
buffer
,
&
size
))
{
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
false
;
}
/* compare each string against all the existing ones */
/* compare each string against all the existing ones */
total
=
size
;
total
=
size
;
...
@@ -261,8 +271,9 @@ static void append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
...
@@ -261,8 +271,9 @@ static void append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
TRACE
(
"setting value %s to %s
\n
"
,
debugstr_w
(
value
),
debugstr_w
(
buffer
)
);
TRACE
(
"setting value %s to %s
\n
"
,
debugstr_w
(
value
),
debugstr_w
(
buffer
)
);
RegSetValueExW
(
hkey
,
value
,
0
,
REG_MULTI_SZ
,
(
BYTE
*
)
buffer
,
total
);
RegSetValueExW
(
hkey
,
value
,
0
,
REG_MULTI_SZ
,
(
BYTE
*
)
buffer
,
total
);
}
}
done:
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
true
;
}
}
...
@@ -374,7 +385,11 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
...
@@ -374,7 +385,11 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
if
(
flags
&
FLG_ADDREG_APPEND
)
if
(
flags
&
FLG_ADDREG_APPEND
)
{
{
if
(
!
str
)
return
TRUE
;
if
(
!
str
)
return
TRUE
;
append_multi_sz_value
(
hkey
,
value
,
str
,
size
);
if
(
!
append_multi_sz_value
(
hkey
,
value
,
str
,
size
))
{
HeapFree
(
GetProcessHeap
(),
0
,
str
);
return
FALSE
;
}
HeapFree
(
GetProcessHeap
(),
0
,
str
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
return
TRUE
;
return
TRUE
;
}
}
...
...
dlls/setupapi/tests/install.c
View file @
0ab56b88
...
@@ -2376,8 +2376,8 @@ static void test_append_reg(void)
...
@@ -2376,8 +2376,8 @@ static void test_append_reg(void)
ret
=
SetupInstallFromInfSectionA
(
NULL
,
hinf
,
"DefaultInstall"
,
SPINST_REGISTRY
,
ret
=
SetupInstallFromInfSectionA
(
NULL
,
hinf
,
"DefaultInstall"
,
SPINST_REGISTRY
,
NULL
,
"C:
\\
"
,
0
,
SetupDefaultQueueCallbackA
,
context
,
NULL
,
NULL
);
NULL
,
"C:
\\
"
,
0
,
SetupDefaultQueueCallbackA
,
context
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
,
"Expected failure.
\n
"
);
ok
(
!
ret
,
"Expected failure.
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_DATA
,
"Got error %#lx.
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INVALID_DATA
,
"Got error %#lx.
\n
"
,
GetLastError
());
size
=
sizeof
(
value
);
size
=
sizeof
(
value
);
l
=
RegQueryValueExA
(
key
,
"value"
,
NULL
,
&
type
,
(
BYTE
*
)
value
,
&
size
);
l
=
RegQueryValueExA
(
key
,
"value"
,
NULL
,
&
type
,
(
BYTE
*
)
value
,
&
size
);
...
...
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