Skip to content

Commit

Permalink
修复远程桌面密码大于15字节时的崩溃问题。Issues#7
Browse files Browse the repository at this point in the history
  • Loading branch information
“dwj0” committed Nov 16, 2021
1 parent 81f5870 commit baa2444
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Binary file modified RemoteMan/RemoteMan.rc
Binary file not shown.
1 change: 1 addition & 0 deletions RemoteMan/RemoteMan.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<ClCompile Include="RemoteManDlg.cpp" />
<ClCompile Include="sqlite3.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
Expand Down
8 changes: 4 additions & 4 deletions RemoteMan/RemoteManDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void CAboutDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()

char *CryptRDPPassword(char const *Password, char *OutPassword)
char *CryptRDPPassword(char const *Password, char *OutPassword, int MaxLen)
{
DATA_BLOB DataIn ;
DATA_BLOB DataOut ;
Expand Down Expand Up @@ -130,7 +130,7 @@ char *CryptRDPPassword(char const *Password, char *OutPassword)
int len=0;
for (n=0; n<DataOut.cbData; n++)
{
len+=sprintf_s(OutPassword+len,512-len,"%02X",DataOut.pbData[n]);
len+=sprintf_s(OutPassword+len,MaxLen-len,"%02X",DataOut.pbData[n]);
}
return OutPassword;
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ void CRemoteManDlg::OnToolbarClickedOpenVNC(void)

void CRemoteManDlg::MstscConnent(HOST_STRUCT const *pHost, CONFIG_STRUCT const *pConfig)
{
char RdpStr[1536],str[512];
char RdpStr[2048],str[768];
//连接模式
int len=sprintf_s(RdpStr,sizeof(RdpStr),"screen mode id:i:%d\r\n",pConfig->MstscWinpos==0?2:1);
//宽高
Expand Down Expand Up @@ -1167,7 +1167,7 @@ void CRemoteManDlg::MstscConnent(HOST_STRUCT const *pHost, CONFIG_STRUCT const *
len+=sizeof("shell working directory:s:\r\n")-1;
//RDP密码加密数据
if (pHost->Password[0]!=0)
len+=sprintf_s(RdpStr+len,sizeof(RdpStr)-len,"password 51:b:%s\r\n",CryptRDPPassword(pHost->Password,str));
len+=sprintf_s(RdpStr+len,sizeof(RdpStr)-len,"password 51:b:%s\r\n",CryptRDPPassword(pHost->Password,str,sizeof(str)));
//禁止网络质量自动检测
strcpy_s(RdpStr+len,sizeof(RdpStr)-len,"networkautodetect:i:0\r\n");
len+=sizeof("networkautodetect:i:0\r\n")-1;
Expand Down

0 comments on commit baa2444

Please sign in to comment.