Skip to content

Commit 4b1a832

Browse files
committed
acl_test: use _putenv_s() instead of _putenv() on Windows
_putenv_s() is recommended over _putenv() as a more secure variant, though the exact benefits are not detailed. Unlike the unsafe putenv() on Linux, _putenv() on Windows does appear to copy its argument. Use _putenv_s() anyway since it provides the same interface as setenv(). Signed-off-by: Peter Colberg <[email protected]>
1 parent 788e7f5 commit 4b1a832

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

test/acl_test.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,16 @@ SimpleString StringFrom(size_t x) {
188188
#endif
189189

190190
void acl_test_unsetenv(const char *var) {
191-
192191
#ifdef _WIN32
193-
{
194-
char buf[1000];
195-
sprintf(buf, "%s=", var);
196-
_putenv(buf);
197-
}
192+
_putenv_s(var, "");
198193
#else
199194
unsetenv(var);
200195
#endif
201196
}
197+
202198
void acl_test_setenv(const char *var, const char *value) {
203199
#ifdef _WIN32
204-
{
205-
char buf[1000];
206-
sprintf(buf, "%s=%s", var, value);
207-
_putenv(buf);
208-
}
200+
_putenv_s(var, value);
209201
#else
210202
setenv(var, value, 1);
211203
#endif

0 commit comments

Comments
 (0)