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
35a9398f
Commit
35a9398f
authored
Apr 03, 2006
by
qingdoa daoo
Committed by
Alexandre Julliard
Apr 03, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Allow environment strings longer than 512 characters.
parent
6a13925a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
10 deletions
+53
-10
environ.c
dlls/msvcrt/environ.c
+31
-10
environ.c
dlls/msvcrt/tests/environ.c
+22
-0
No files found.
dlls/msvcrt/environ.c
View file @
35a9398f
...
@@ -73,20 +73,28 @@ MSVCRT_wchar_t *_wgetenv(const MSVCRT_wchar_t *name)
...
@@ -73,20 +73,28 @@ MSVCRT_wchar_t *_wgetenv(const MSVCRT_wchar_t *name)
*/
*/
int
_putenv
(
const
char
*
str
)
int
_putenv
(
const
char
*
str
)
{
{
char
name
[
256
],
value
[
512
]
;
char
*
name
,
*
value
;
char
*
dst
=
name
;
char
*
dst
;
int
ret
;
int
ret
;
TRACE
(
"%s
\n
"
,
str
);
TRACE
(
"%s
\n
"
,
str
);
if
(
!
str
)
if
(
!
str
)
return
-
1
;
return
-
1
;
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
if
(
!
name
)
return
-
1
;
dst
=
name
;
while
(
*
str
&&
*
str
!=
'='
)
while
(
*
str
&&
*
str
!=
'='
)
*
dst
++
=
*
str
++
;
*
dst
++
=
*
str
++
;
if
(
!*
str
++
)
if
(
!*
str
++
)
return
-
1
;
{
*
dst
=
'\0'
;
ret
=
-
1
;
dst
=
value
;
goto
finish
;
}
*
dst
++
=
'\0'
;
value
=
dst
;
while
(
*
str
)
while
(
*
str
)
*
dst
++
=
*
str
++
;
*
dst
++
=
*
str
++
;
*
dst
=
'\0'
;
*
dst
=
'\0'
;
...
@@ -101,6 +109,9 @@ int _putenv(const char *str)
...
@@ -101,6 +109,9 @@ int _putenv(const char *str)
_environ
=
msvcrt_SnapshotOfEnvironmentA
(
_environ
);
_environ
=
msvcrt_SnapshotOfEnvironmentA
(
_environ
);
if
(
_wenviron
)
if
(
_wenviron
)
_wenviron
=
msvcrt_SnapshotOfEnvironmentW
(
_wenviron
);
_wenviron
=
msvcrt_SnapshotOfEnvironmentW
(
_wenviron
);
finish:
HeapFree
(
GetProcessHeap
(),
0
,
name
);
return
ret
;
return
ret
;
}
}
...
@@ -109,20 +120,27 @@ int _putenv(const char *str)
...
@@ -109,20 +120,27 @@ int _putenv(const char *str)
*/
*/
int
_wputenv
(
const
MSVCRT_wchar_t
*
str
)
int
_wputenv
(
const
MSVCRT_wchar_t
*
str
)
{
{
MSVCRT_wchar_t
name
[
256
],
value
[
512
]
;
MSVCRT_wchar_t
*
name
,
*
value
;
MSVCRT_wchar_t
*
dst
=
name
;
MSVCRT_wchar_t
*
dst
;
int
ret
;
int
ret
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
str
));
TRACE
(
"%s
\n
"
,
debugstr_w
(
str
));
if
(
!
str
)
if
(
!
str
)
return
-
1
;
return
-
1
;
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
str
)
+
1
)
*
sizeof
(
MSVCRT_wchar_t
));
if
(
!
name
)
return
-
1
;
dst
=
name
;
while
(
*
str
&&
*
str
!=
'='
)
while
(
*
str
&&
*
str
!=
'='
)
*
dst
++
=
*
str
++
;
*
dst
++
=
*
str
++
;
if
(
!*
str
++
)
if
(
!*
str
++
)
return
-
1
;
{
*
dst
=
0
;
ret
=
-
1
;
dst
=
value
;
goto
finish
;
}
*
dst
++
=
0
;
value
=
dst
;
while
(
*
str
)
while
(
*
str
)
*
dst
++
=
*
str
++
;
*
dst
++
=
*
str
++
;
*
dst
=
0
;
*
dst
=
0
;
...
@@ -137,5 +155,8 @@ int _wputenv(const MSVCRT_wchar_t *str)
...
@@ -137,5 +155,8 @@ int _wputenv(const MSVCRT_wchar_t *str)
_environ
=
msvcrt_SnapshotOfEnvironmentA
(
_environ
);
_environ
=
msvcrt_SnapshotOfEnvironmentA
(
_environ
);
if
(
_wenviron
)
if
(
_wenviron
)
_wenviron
=
msvcrt_SnapshotOfEnvironmentW
(
_wenviron
);
_wenviron
=
msvcrt_SnapshotOfEnvironmentW
(
_wenviron
);
finish:
HeapFree
(
GetProcessHeap
(),
0
,
name
);
return
ret
;
return
ret
;
}
}
dlls/msvcrt/tests/environ.c
View file @
35a9398f
...
@@ -21,6 +21,27 @@
...
@@ -21,6 +21,27 @@
#include "wine/test.h"
#include "wine/test.h"
#include <stdlib.h>
#include <stdlib.h>
static
const
char
*
a_very_long_env_string
=
"LIBRARY_PATH="
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/;"
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/;"
"/mingw/lib/gcc/mingw32/3.4.2/;"
"/usr/lib/gcc/mingw32/3.4.2/;"
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/mingw32/3.4.2/;"
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/;"
"/mingw/mingw32/lib/mingw32/3.4.2/;"
"/mingw/mingw32/lib/;"
"/mingw/lib/mingw32/3.4.2/;"
"/mingw/lib/;"
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../mingw32/3.4.2/;"
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../;"
"/mingw/lib/mingw32/3.4.2/;"
"/mingw/lib/;"
"/lib/mingw32/3.4.2/;"
"/lib/;"
"/usr/lib/mingw32/3.4.2/;"
"/usr/lib/"
;
START_TEST
(
environ
)
START_TEST
(
environ
)
{
{
ok
(
_putenv
(
"cat="
)
==
0
,
"_putenv failed on deletion of nonexistent environment variable
\n
"
);
ok
(
_putenv
(
"cat="
)
==
0
,
"_putenv failed on deletion of nonexistent environment variable
\n
"
);
...
@@ -30,6 +51,7 @@ START_TEST(environ)
...
@@ -30,6 +51,7 @@ START_TEST(environ)
ok
(
_putenv
(
"="
)
==
-
1
,
"should not accept '=' as input
\n
"
);
ok
(
_putenv
(
"="
)
==
-
1
,
"should not accept '=' as input
\n
"
);
ok
(
_putenv
(
"=dog"
)
==
-
1
,
"should not accept '=dog' as input
\n
"
);
ok
(
_putenv
(
"=dog"
)
==
-
1
,
"should not accept '=dog' as input
\n
"
);
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
"
);
ok
(
getenv
(
"nonexistent"
)
==
NULL
,
"getenv should fail with nonexistent var name
\n
"
);
}
}
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