Commit 74881aa
committed
Fix Windows GetEnv mangling non-ASCII environment values
On Windows, GetEnv read variables through the narrow _dupenv_s, which
returns the value in the active ANSI code page (e.g. CP-1252). Non-ASCII
values -- such as a home path with an accented username -- were then
reinterpreted as UTF-8 and came out mangled, so ~/.aws/credentials and
~/.aws/config failed to load and the profile provider fell back to an
anonymous request (GitHub issue #3865).
Read env vars through the wide _wdupenv_s and convert explicitly to
UTF-8, since Windows stores them natively as UTF-16. Mirrors the same
fix in the CRT (awslabs/aws-c-common#1260). Non-MSVC compilers keep the
existing std::getenv path.
Adds a Windows-only regression test that injects a non-ASCII value via
the wide CRT API and asserts GetEnv returns the correct UTF-8 bytes.1 parent 69ee6af commit 74881aa
2 files changed
Lines changed: 25 additions & 12 deletions
File tree
- src/aws-cpp-sdk-core/source/platform/windows
- tests/aws-cpp-sdk-core-tests/utils
Lines changed: 7 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 17 | | |
23 | 18 | | |
24 | | - | |
25 | | - | |
| 19 | + | |
| 20 | + | |
26 | 21 | | |
27 | | - | |
| 22 | + | |
28 | 23 | | |
29 | 24 | | |
30 | | - | |
| 25 | + | |
31 | 26 | | |
32 | | - | |
33 | | - | |
| 27 | + | |
34 | 28 | | |
| 29 | + | |
35 | 30 | | |
36 | 31 | | |
37 | 32 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
35 | 53 | | |
36 | 54 | | |
37 | 55 | | |
| |||
0 commit comments