Milestone 5: deliver embedded RDP sessions and lifecycle hardening
This commit is contained in:
41
third_party/FreeRDP/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
vendored
Normal file
41
third_party/FreeRDP/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/environment.h>
|
||||
|
||||
int TestEnvironmentGetEnvironmentStrings(int argc, char* argv[])
|
||||
{
|
||||
int r = -1;
|
||||
|
||||
WINPR_UNUSED(argc);
|
||||
WINPR_UNUSED(argv);
|
||||
|
||||
LPTCH lpszEnvironmentBlock = GetEnvironmentStrings();
|
||||
if (!lpszEnvironmentBlock)
|
||||
goto fail;
|
||||
|
||||
TCHAR* p = lpszEnvironmentBlock;
|
||||
while (p[0] && p[1])
|
||||
{
|
||||
const size_t max = _tcslen(p);
|
||||
const int rc = _sntprintf(nullptr, 0, _T("%s\n"), p);
|
||||
if (rc < 1)
|
||||
{
|
||||
_tprintf(_T("test failed: return %d\n"), rc);
|
||||
goto fail;
|
||||
}
|
||||
if (max != (size_t)(rc - 1))
|
||||
{
|
||||
_tprintf(_T("test failed: length %") _T(PRIuz) _T(" != %d [%s]\n"), max, rc - 1, p);
|
||||
goto fail;
|
||||
}
|
||||
p += (max + 1);
|
||||
}
|
||||
|
||||
r = 0;
|
||||
fail:
|
||||
FreeEnvironmentStrings(lpszEnvironmentBlock);
|
||||
|
||||
return r;
|
||||
}
|
||||
Reference in New Issue
Block a user