Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom Jansen
wine
Commits
048b3ac6
Commit
048b3ac6
authored
20 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Fixed RtlSetEnvironmentVariable to deal properly with Unicode strings
that aren't null-terminated.
parent
4e5b9efc
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/ntdll/env.c
+11
-9
11 additions, 9 deletions
dlls/ntdll/env.c
with
11 additions
and
9 deletions
dlls/ntdll/env.c
+
11
−
9
View file @
048b3ac6
...
...
@@ -181,10 +181,14 @@ NTSTATUS WINAPI RtlSetEnvironmentVariable(PWSTR* penv, PUNICODE_STRING name,
penv
,
debugstr_w
(
name
->
Buffer
),
value
?
debugstr_w
(
value
->
Buffer
)
:
"--nil--"
);
if
(
!
name
||
!
name
->
Buffer
||
!
name
->
Buffer
[
0
]
)
if
(
!
name
||
!
name
->
Buffer
||
!
name
->
Length
)
return
STATUS_INVALID_PARAMETER_1
;
len
=
name
->
Length
/
sizeof
(
WCHAR
);
/* variable names can't contain a '=' except as a first character */
if
(
strchrW
(
name
->
Buffer
+
1
,
'='
))
return
STATUS_INVALID_PARAMETER
;
for
(
p
=
name
->
Buffer
+
1
;
p
<
name
->
Buffer
+
len
;
p
++
)
if
(
*
p
==
'='
)
return
STATUS_INVALID_PARAMETER
;
if
(
!
penv
)
{
...
...
@@ -192,8 +196,6 @@ NTSTATUS WINAPI RtlSetEnvironmentVariable(PWSTR* penv, PUNICODE_STRING name,
env
=
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
Environment
;
}
else
env
=
*
penv
;
len
=
name
->
Length
/
sizeof
(
WCHAR
);
/* compute current size of environment */
for
(
p
=
env
;
*
p
;
p
+=
strlenW
(
p
)
+
1
);
old_size
=
p
+
1
-
env
;
...
...
@@ -247,11 +249,11 @@ NTSTATUS WINAPI RtlSetEnvironmentVariable(PWSTR* penv, PUNICODE_STRING name,
/* Set the new string */
if
(
value
)
{
static
const
WCHAR
equalW
[]
=
{
'='
,
0
}
;
strcpyW
(
p
,
name
->
Buffer
)
;
strcatW
(
p
,
equalW
);
strcatW
(
p
,
value
->
Buffer
)
;
memcpy
(
p
,
name
->
Buffer
,
name
->
Length
)
;
p
+=
name
->
Length
/
sizeof
(
WCHAR
);
*
p
++
=
'='
;
memcpy
(
p
,
value
->
Buffer
,
value
->
Length
);
p
[
value
->
Length
/
sizeof
(
WCHAR
)]
=
0
;
}
done:
if
(
!
penv
)
RtlReleasePebLock
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment