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
667d889d
Commit
667d889d
authored
Feb 15, 2023
by
Piotr Caban
Committed by
Alexandre Julliard
Feb 15, 2023
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Improve error handling in _wgetenv_s.
parent
b7a58677
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
environ.c
dlls/msvcrt/environ.c
+22
-19
No files found.
dlls/msvcrt/environ.c
View file @
667d889d
...
@@ -56,15 +56,12 @@ char * CDECL getenv(const char *name)
...
@@ -56,15 +56,12 @@ char * CDECL getenv(const char *name)
return
getenv_helper
(
name
);
return
getenv_helper
(
name
);
}
}
/*********************************************************************
static
wchar_t
*
wgetenv_helper
(
const
wchar_t
*
name
)
* _wgetenv (MSVCRT.@)
*/
wchar_t
*
CDECL
_wgetenv
(
const
wchar_t
*
name
)
{
{
wchar_t
**
env
;
wchar_t
**
env
;
size_t
len
;
size_t
len
;
if
(
!
MSVCRT_CHECK_PMT
(
name
!=
NULL
)
)
return
NULL
;
if
(
!
name
)
return
NULL
;
len
=
wcslen
(
name
);
len
=
wcslen
(
name
);
/* Initialize the _wenviron array if it's not already created. */
/* Initialize the _wenviron array if it's not already created. */
...
@@ -85,6 +82,16 @@ wchar_t * CDECL _wgetenv(const wchar_t *name)
...
@@ -85,6 +82,16 @@ wchar_t * CDECL _wgetenv(const wchar_t *name)
}
}
/*********************************************************************
/*********************************************************************
* _wgetenv (MSVCRT.@)
*/
wchar_t
*
CDECL
_wgetenv
(
const
wchar_t
*
name
)
{
if
(
!
MSVCRT_CHECK_PMT
(
name
!=
NULL
))
return
NULL
;
return
wgetenv_helper
(
name
);
}
/*********************************************************************
* _putenv (MSVCRT.@)
* _putenv (MSVCRT.@)
*/
*/
int
CDECL
_putenv
(
const
char
*
str
)
int
CDECL
_putenv
(
const
char
*
str
)
...
@@ -306,25 +313,21 @@ int CDECL getenv_s(size_t *ret_len, char* buffer, size_t len, const char *varnam
...
@@ -306,25 +313,21 @@ int CDECL getenv_s(size_t *ret_len, char* buffer, size_t len, const char *varnam
/******************************************************************
/******************************************************************
* _wgetenv_s (MSVCRT.@)
* _wgetenv_s (MSVCRT.@)
*/
*/
int
CDECL
_wgetenv_s
(
size_t
*
pReturnValue
,
wchar_t
*
buffer
,
size_t
numberOfElements
,
int
CDECL
_wgetenv_s
(
size_t
*
ret_len
,
wchar_t
*
buffer
,
size_t
len
,
const
wchar_t
*
varname
)
const
wchar_t
*
varname
)
{
{
wchar_t
*
e
;
wchar_t
*
e
;
if
(
!
MSVCRT_CHECK_PMT
(
pReturnValue
!=
NULL
))
return
EINVAL
;
if
(
!
MSVCRT_CHECK_PMT
(
ret_len
!=
NULL
))
return
EINVAL
;
if
(
!
MSVCRT_CHECK_PMT
(
!
(
buffer
==
NULL
&&
numberOfElements
>
0
)))
return
EINVAL
;
*
ret_len
=
0
;
if
(
!
MSVCRT_CHECK_PMT
(
varname
!=
NULL
))
return
EINVAL
;
if
(
!
MSVCRT_CHECK_PMT
((
buffer
&&
len
>
0
)
||
(
!
buffer
&&
!
len
)))
return
EINVAL
;
if
(
buffer
)
buffer
[
0
]
=
0
;
if
(
!
(
e
=
wgetenv_helper
(
varname
)))
return
0
;
*
ret_len
=
wcslen
(
e
)
+
1
;
if
(
!
len
)
return
0
;
if
(
len
<
*
ret_len
)
return
ERANGE
;
if
(
!
(
e
=
_wgetenv
(
varname
)))
{
*
pReturnValue
=
0
;
return
*
_errno
()
=
EINVAL
;
}
*
pReturnValue
=
wcslen
(
e
)
+
1
;
if
(
numberOfElements
<
*
pReturnValue
)
{
return
*
_errno
()
=
ERANGE
;
}
wcscpy
(
buffer
,
e
);
wcscpy
(
buffer
,
e
);
return
0
;
return
0
;
}
}
...
...
Vitaly Lipatov
@lav
mentioned in commit
18448aa2
·
Feb 25, 2024
mentioned in commit
18448aa2
mentioned in commit 18448aa290a84638c9dc6585a6a3dd626c4afce2
Toggle commit list
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