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
f943d449
Commit
f943d449
authored
Oct 22, 2022
by
Piotr Caban
Committed by
Alexandre Julliard
Oct 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fix _wputenv_s invalid argument handling.
parent
10e7c824
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
4 deletions
+39
-4
environ.c
dlls/msvcrt/environ.c
+2
-2
environ.c
dlls/msvcrt/tests/environ.c
+37
-2
No files found.
dlls/msvcrt/environ.c
View file @
f943d449
...
...
@@ -197,8 +197,8 @@ errno_t CDECL _wputenv_s(const wchar_t *name, const wchar_t *value)
TRACE
(
"%s %s
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
value
));
if
(
!
MSVCRT_CHECK_PMT
(
name
!=
NULL
))
return
-
1
;
if
(
!
MSVCRT_CHECK_PMT
(
value
!=
NULL
))
return
-
1
;
if
(
!
MSVCRT_CHECK_PMT
(
name
!=
NULL
))
return
EINVAL
;
if
(
!
MSVCRT_CHECK_PMT
(
value
!=
NULL
))
return
EINVAL
;
if
(
!
SetEnvironmentVariableW
(
name
,
value
[
0
]
?
value
:
NULL
))
{
...
...
dlls/msvcrt/tests/environ.c
View file @
f943d449
...
...
@@ -19,6 +19,7 @@
*/
#include "wine/test.h"
#include <errno.h>
#include <stdlib.h>
#include <process.h>
...
...
@@ -45,8 +46,10 @@ static const char *a_very_long_env_string =
static
char
***
(
__cdecl
*
p__p__environ
)(
void
);
static
WCHAR
***
(
__cdecl
*
p__p__wenviron
)(
void
);
static
void
(
*
p_get_environ
)(
char
***
);
static
void
(
*
p_get_wenviron
)(
WCHAR
***
);
static
void
(
__cdecl
*
p_get_environ
)(
char
***
);
static
void
(
__cdecl
*
p_get_wenviron
)(
WCHAR
***
);
static
errno_t
(
__cdecl
*
p_putenv_s
)(
const
char
*
,
const
char
*
);
static
errno_t
(
__cdecl
*
p_wputenv_s
)(
const
wchar_t
*
,
const
wchar_t
*
);
static
char
***
p_environ
;
static
WCHAR
***
p_wenviron
;
...
...
@@ -61,6 +64,8 @@ static void init(void)
p_wenviron
=
(
void
*
)
GetProcAddress
(
hmod
,
"_wenviron"
);
p_get_environ
=
(
void
*
)
GetProcAddress
(
hmod
,
"_get_environ"
);
p_get_wenviron
=
(
void
*
)
GetProcAddress
(
hmod
,
"_get_wenviron"
);
p_putenv_s
=
(
void
*
)
GetProcAddress
(
hmod
,
"_putenv_s"
);
p_wputenv_s
=
(
void
*
)
GetProcAddress
(
hmod
,
"_wputenv_s"
);
}
static
void
test_system
(
void
)
...
...
@@ -237,6 +242,8 @@ static void test__wenviron(void)
static
void
test_environment_manipulation
(
void
)
{
errno_t
ret
;
ok
(
_putenv
(
"cat="
)
==
0
,
"_putenv failed on deletion of nonexistent environment variable
\n
"
);
ok
(
_putenv
(
"cat=dog"
)
==
0
,
"failed setting cat=dog
\n
"
);
ok
(
strcmp
(
getenv
(
"cat"
),
"dog"
)
==
0
,
"getenv did not return 'dog'
\n
"
);
...
...
@@ -247,6 +254,34 @@ static void test_environment_manipulation(void)
ok
(
_putenv
(
a_very_long_env_string
)
==
0
,
"_putenv failed for long environment string
\n
"
);
ok
(
getenv
(
"nonexistent"
)
==
NULL
,
"getenv should fail with nonexistent var name
\n
"
);
if
(
p_putenv_s
)
{
ret
=
p_putenv_s
(
NULL
,
"dog"
);
ok
(
ret
==
EINVAL
,
"_putenv_s returned %d
\n
"
,
ret
);
ret
=
p_putenv_s
(
"cat"
,
NULL
);
ok
(
ret
==
EINVAL
,
"_putenv_s returned %d
\n
"
,
ret
);
ret
=
p_putenv_s
(
"a=b"
,
NULL
);
ok
(
ret
==
EINVAL
,
"_putenv_s returned %d
\n
"
,
ret
);
ret
=
p_putenv_s
(
"cat"
,
"a=b"
);
ok
(
!
ret
,
"_putenv_s returned %d
\n
"
,
ret
);
ret
=
p_putenv_s
(
"cat"
,
""
);
ok
(
!
ret
,
"_putenv_s returned %d
\n
"
,
ret
);
}
if
(
p_wputenv_s
)
{
ret
=
p_wputenv_s
(
NULL
,
L"dog"
);
ok
(
ret
==
EINVAL
,
"_wputenv_s returned %d
\n
"
,
ret
);
ret
=
p_wputenv_s
(
L"cat"
,
NULL
);
ok
(
ret
==
EINVAL
,
"_wputenv_s returned %d
\n
"
,
ret
);
ret
=
p_wputenv_s
(
L"a=b"
,
NULL
);
ok
(
ret
==
EINVAL
,
"_wputenv_s returned %d
\n
"
,
ret
);
ret
=
p_wputenv_s
(
L"cat"
,
L"a=b"
);
ok
(
!
ret
,
"_wputenv_s returned %d
\n
"
,
ret
);
ret
=
p_wputenv_s
(
L"cat"
,
L""
);
ok
(
!
ret
,
"_wputenv_s returned %d
\n
"
,
ret
);
}
}
START_TEST
(
environ
)
...
...
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