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
99dfc15e
Commit
99dfc15e
authored
Aug 18, 2015
by
Hans Leidekker
Committed by
Alexandre Julliard
Aug 18, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msi: Only remove environment strings that were added on install.
parent
ad9ba6a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
8 deletions
+126
-8
action.c
dlls/msi/action.c
+56
-7
action.c
dlls/msi/tests/action.c
+70
-1
No files found.
dlls/msi/action.c
View file @
99dfc15e
...
...
@@ -7103,8 +7103,8 @@ static UINT ITERATE_RemoveEnvironmentString( MSIRECORD *rec, LPVOID param )
{
MSIPACKAGE
*
package
=
param
;
LPCWSTR
name
,
value
,
component
;
LPWSTR
deformatted
=
NULL
;
DWORD
flags
;
WCHAR
*
p
,
*
q
,
*
deformatted
=
NULL
,
*
new_value
=
NULL
;
DWORD
flags
,
type
,
size
,
len
,
len_value
=
0
,
len_new_value
;
HKEY
env
;
MSICOMPONENT
*
comp
;
MSIRECORD
*
uirow
;
...
...
@@ -7141,7 +7141,20 @@ static UINT ITERATE_RemoveEnvironmentString( MSIRECORD *rec, LPVOID param )
if
(
value
&&
!
deformat_string
(
package
,
value
,
&
deformatted
))
return
ERROR_OUTOFMEMORY
;
value
=
deformatted
;
if
((
value
=
deformatted
))
{
if
(
flags
&
ENV_MOD_PREFIX
)
{
p
=
strchrW
(
value
,
';'
);
len_value
=
p
-
value
;
}
else
if
(
flags
&
ENV_MOD_APPEND
)
{
value
=
strchrW
(
value
,
';'
)
+
1
;
len_value
=
strlenW
(
value
);
}
else
len_value
=
strlenW
(
value
);
}
r
=
open_env_key
(
flags
,
&
env
);
if
(
r
!=
ERROR_SUCCESS
)
...
...
@@ -7153,13 +7166,48 @@ static UINT ITERATE_RemoveEnvironmentString( MSIRECORD *rec, LPVOID param )
if
(
flags
&
ENV_MOD_MACHINE
)
action
|=
0x20000000
;
TRACE
(
"Removing %s
\n
"
,
debugstr_w
(
name
));
size
=
0
;
type
=
REG_SZ
;
res
=
RegQueryValueExW
(
env
,
name
,
NULL
,
&
type
,
NULL
,
&
size
);
if
(
res
!=
ERROR_SUCCESS
||
(
type
!=
REG_SZ
&&
type
!=
REG_EXPAND_SZ
))
goto
done
;
if
(
!
(
new_value
=
msi_alloc
(
size
)))
goto
done
;
res
=
Reg
DeleteValueW
(
env
,
nam
e
);
res
=
Reg
QueryValueExW
(
env
,
name
,
NULL
,
&
type
,
(
BYTE
*
)
new_value
,
&
siz
e
);
if
(
res
!=
ERROR_SUCCESS
)
goto
done
;
len_new_value
=
size
/
sizeof
(
WCHAR
)
-
1
;
p
=
q
=
new_value
;
for
(;;)
{
WARN
(
"Failed to delete value %s (%d)
\n
"
,
debugstr_w
(
name
),
res
);
r
=
ERROR_SUCCESS
;
while
(
*
q
&&
*
q
!=
';'
)
q
++
;
len
=
q
-
p
;
if
(
value
&&
len
==
len_value
&&
!
memcmp
(
value
,
p
,
len
*
sizeof
(
WCHAR
)
))
{
if
(
*
q
==
';'
)
q
++
;
memmove
(
p
,
q
,
(
len_new_value
-
(
q
-
new_value
)
+
1
)
*
sizeof
(
WCHAR
)
);
break
;
}
if
(
!*
q
)
break
;
p
=
++
q
;
}
if
(
!
new_value
[
0
]
||
!
value
)
{
TRACE
(
"removing %s
\n
"
,
debugstr_w
(
name
));
res
=
RegDeleteValueW
(
env
,
name
);
if
(
res
!=
ERROR_SUCCESS
)
WARN
(
"failed to delete value %s (%d)
\n
"
,
debugstr_w
(
name
),
res
);
}
else
{
TRACE
(
"setting %s to %s
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
new_value
));
size
=
(
strlenW
(
new_value
)
+
1
)
*
sizeof
(
WCHAR
);
res
=
RegSetValueExW
(
env
,
name
,
0
,
type
,
(
BYTE
*
)
new_value
,
size
);
if
(
res
!=
ERROR_SUCCESS
)
WARN
(
"failed to set %s to %s (%d)
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
new_value
),
res
);
}
done:
...
...
@@ -7172,6 +7220,7 @@ done:
if
(
env
)
RegCloseKey
(
env
);
msi_free
(
deformatted
);
msi_free
(
new_value
);
return
r
;
}
...
...
dlls/msi/tests/action.c
View file @
99dfc15e
...
...
@@ -1205,7 +1205,13 @@ static const char res_environment_dat[] =
"var2
\t
=+-MSITESTVAR2
\t
1
\t
envvar
\n
"
"var3
\t
=MSITESTVAR3
\t
1
\t
envvar
\n
"
"var4
\t
=-MSITESTVAR4
\t\t
envvar
\n
"
"var5
\t
=MSITESTVAR5
\t\t
envvar
\n
"
;
"var5
\t
=MSITESTVAR5
\t\t
envvar
\n
"
"Var6
\t
-MSITESTVAR6
\t
1;[~]
\t
envvar
\n
"
"Var7
\t
-MSITESTVAR7
\t
[~];1
\t
envvar
\n
"
"Var8
\t
-MSITESTVAR8
\t
1;[~]
\t
envvar
\n
"
"Var9
\t
-MSITESTVAR9
\t
[~];1
\t
envvar
\n
"
"Var10
\t
-MSITESTVAR10
\t
1
\t
envvar
\n
"
"Var11
\t
-MSITESTVAR11
\t
2
\t
envvar
\n
"
;
static
const
char
res_install_exec_seq_dat
[]
=
"Action
\t
Condition
\t
Sequence
\n
"
...
...
@@ -6192,6 +6198,12 @@ static void test_remove_env_strings(void)
RegSetValueExA
(
key
,
"MSITESTVAR3"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1"
,
2
);
RegSetValueExA
(
key
,
"MSITESTVAR4"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1"
,
2
);
RegSetValueExA
(
key
,
"MSITESTVAR5"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1"
,
2
);
RegSetValueExA
(
key
,
"MSITESTVAR6"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1;2"
,
4
);
RegSetValueExA
(
key
,
"MSITESTVAR7"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1;2"
,
4
);
RegSetValueExA
(
key
,
"MSITESTVAR8"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"2;1;0"
,
6
);
RegSetValueExA
(
key
,
"MSITESTVAR9"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"0;1;2"
,
6
);
RegSetValueExA
(
key
,
"MSITESTVAR10"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1"
,
2
);
RegSetValueExA
(
key
,
"MSITESTVAR11"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
"1"
,
2
);
RegCloseKey
(
key
);
...
...
@@ -6281,6 +6293,57 @@ static void test_remove_env_strings(void)
ok
(
!
lstrcmpA
(
buffer
,
"1"
),
"expected
\"
1
\"
, got
\"
%s
\"\n
"
,
buffer
);
RegDeleteValueA
(
key
,
"MSITESTVAR5"
);
type
=
REG_NONE
;
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
res
=
RegQueryValueExA
(
key
,
"MSITESTVAR6"
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
size
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
type
==
REG_SZ
,
"expected REG_SZ, got %u
\n
"
,
type
);
ok
(
!
lstrcmpA
(
buffer
,
"2"
),
"expected
\"
2
\"
, got
\"
%s
\"\n
"
,
buffer
);
RegDeleteValueA
(
key
,
"MSITESTVAR6"
);
type
=
REG_NONE
;
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
res
=
RegQueryValueExA
(
key
,
"MSITESTVAR7"
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
size
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
type
==
REG_SZ
,
"expected REG_SZ, got %u
\n
"
,
type
);
ok
(
!
lstrcmpA
(
buffer
,
"2"
),
"expected
\"
2
\"
, got
\"
%s
\"\n
"
,
buffer
);
RegDeleteValueA
(
key
,
"MSITESTVAR7"
);
type
=
REG_NONE
;
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
res
=
RegQueryValueExA
(
key
,
"MSITESTVAR8"
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
size
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
type
==
REG_SZ
,
"expected REG_SZ, got %u
\n
"
,
type
);
ok
(
!
lstrcmpA
(
buffer
,
"2;0"
),
"expected
\"
2;0
\"
, got
\"
%s
\"\n
"
,
buffer
);
RegDeleteValueA
(
key
,
"MSITESTVAR8"
);
type
=
REG_NONE
;
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
res
=
RegQueryValueExA
(
key
,
"MSITESTVAR9"
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
size
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
type
==
REG_SZ
,
"expected REG_SZ, got %u
\n
"
,
type
);
ok
(
!
lstrcmpA
(
buffer
,
"0;2"
),
"expected
\"
0;2
\"
, got
\"
%s
\"\n
"
,
buffer
);
RegDeleteValueA
(
key
,
"MSITESTVAR9"
);
type
=
REG_NONE
;
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
res
=
RegQueryValueExA
(
key
,
"MSITESTVAR10"
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
size
);
ok
(
res
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND, got %d
\n
"
,
res
);
type
=
REG_NONE
;
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
res
=
RegQueryValueExA
(
key
,
"MSITESTVAR11"
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
size
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
type
==
REG_SZ
,
"expected REG_SZ, got %u
\n
"
,
type
);
ok
(
!
lstrcmpA
(
buffer
,
"1"
),
"expected
\"
1
\"
, got
\"
%s
\"\n
"
,
buffer
);
RegDeleteValueA
(
key
,
"MSITESTVAR11"
);
ok
(
!
delete_pf
(
"msitest
\\
envvar.txt"
,
TRUE
),
"file not removed
\n
"
);
ok
(
!
delete_pf
(
"msitest"
,
FALSE
),
"directory not removed
\n
"
);
...
...
@@ -6290,6 +6353,12 @@ error:
RegDeleteValueA
(
key
,
"MSITESTVAR3"
);
RegDeleteValueA
(
key
,
"MSITESTVAR4"
);
RegDeleteValueA
(
key
,
"MSITESTVAR5"
);
RegDeleteValueA
(
key
,
"MSITESTVAR6"
);
RegDeleteValueA
(
key
,
"MSITESTVAR7"
);
RegDeleteValueA
(
key
,
"MSITESTVAR8"
);
RegDeleteValueA
(
key
,
"MSITESTVAR9"
);
RegDeleteValueA
(
key
,
"MSITESTVAR10"
);
RegDeleteValueA
(
key
,
"MSITESTVAR11"
);
RegCloseKey
(
key
);
DeleteFileA
(
"msitest
\\
envvar.txt"
);
...
...
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