Skip to content

Commit

Permalink
Bug #47, Windows XP模式编译时_wputenv_s发生缓冲区越界访问
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed May 7, 2023
1 parent 35fa85a commit 8328cb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,4 @@ Static/
*.id2
*.xlsx
SymbolCache/
*.lastcodeanalysissucceeded
3 changes: 2 additions & 1 deletion ucrtbase.msvcrt/putenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ template<typename TCAHR> __forceinline errno_t __cdecl common_putenv_s(
auto cName = _tcslen(_Name);
auto cValue = _tcslen(_Value);

auto _EnvString = (TCAHR*)_malloca(cName + cValue + 2 * sizeof(TCAHR));
// 我们需要额外添加二个字符,一个用于存储连接符 '=',另外一个用于字符串终止符 '\0'。
auto _EnvString = (TCAHR*)_malloca((cName + cValue + 2) * sizeof(TCAHR));
if (!_EnvString)
return errno;

Expand Down

0 comments on commit 8328cb9

Please sign in to comment.