From a450f1f684c909c73af7d2fd7065df19b12796e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jet=20=28=E3=82=B8=E3=82=A7=E3=83=83=E3=83=88=29?= <34238471+jet2jet@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:09:26 +0900 Subject: [PATCH 1/2] Replace C-style casts with C++ casts in auth and UI helpers --- EasySFTP/Func.cpp | 2 +- ShellDLL/Auth.cpp | 24 ++++++++++++------------ ShellDLL/Func.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/EasySFTP/Func.cpp b/EasySFTP/Func.cpp index 58352c7..957e504 100644 --- a/EasySFTP/Func.cpp +++ b/EasySFTP/Func.cpp @@ -42,7 +42,7 @@ extern "C" int __stdcall MyMessageBoxW(HWND hWnd, LPCWSTR lpszText, LPCWSTR lpsz lpszText = strText; } if (lpszCaption == NULL) - lpszCaption = (LPCWSTR) IDS_APP_TITLE; + lpszCaption = MAKEINTRESOURCEW(IDS_APP_TITLE); if (HIWORD(lpszCaption) == 0 && lpszCaption != NULL) { strCaption.LoadString((UINT) LOWORD(lpszCaption)); diff --git a/ShellDLL/Auth.cpp b/ShellDLL/Auth.cpp index 9306f21..de37a41 100644 --- a/ShellDLL/Auth.cpp +++ b/ShellDLL/Auth.cpp @@ -376,8 +376,8 @@ bool CAuthentication::AssignAgentFlags(CAuthSession* pAuthSession) if (pAuthSession->nPrevFlags == 0) return false; // get key type data (in the head of blob data) - DWORD dwKeyTypeLen = ConvertEndian(*((DWORD*)(pAuthSession->lpCurrentKey + 4))); - LPCSTR lpszKeyType = (LPCSTR)(pAuthSession->lpCurrentKey + 8); + DWORD dwKeyTypeLen = ConvertEndian(*reinterpret_cast(pAuthSession->lpCurrentKey + 4)); + LPCSTR lpszKeyType = reinterpret_cast(pAuthSession->lpCurrentKey + 8); if ((dwKeyTypeLen == 7 && memcmp(lpszKeyType, "ssh-rsa", dwKeyTypeLen) == 0) || (dwKeyTypeLen == 28 && memcmp(lpszKeyType, "ssh-rsa-cert-v01@openssh.com", dwKeyTypeLen) == 0)) @@ -431,7 +431,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication pAuthSession->dwSignature = AUTH_SESSION_SIGNATURE; pAuthSession->pAgent = pAgent; pAuthSession->lpPageantKeyList = lpKeyList; - pAuthSession->dwKeyCount = ConvertEndian(*((DWORD*)lpKeyList)); + pAuthSession->dwKeyCount = ConvertEndian(*reinterpret_cast(lpKeyList)); pAuthSession->dwKeyIndex = 0; pAuthSession->lpCurrentKey = lpKeyList + 4; pAuthSession->nPrevFlags = -1; @@ -447,18 +447,18 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication LPCBYTE pBlob; size_t nBlobLen; - nBlobLen = (size_t)ConvertEndian(*((DWORD*)p)); + nBlobLen = static_cast(ConvertEndian(*reinterpret_cast(p))); pBlob = (p + 4); p += nBlobLen + 4; { - DWORD dwKeyTypeLen = ConvertEndian(*((DWORD*)(pBlob))); - LPCSTR lpszKeyType = (LPCSTR)(pBlob + 4); + DWORD dwKeyTypeLen = ConvertEndian(*reinterpret_cast(pBlob)); + LPCSTR lpszKeyType = reinterpret_cast(pBlob + 4); // get the comment of key - DWORD dwCommentLen = ConvertEndian(*((DWORD*)p)); - CMyStringW str; - str.SetUTF8String((LPCBYTE)(p + 4), static_cast(dwCommentLen)); + DWORD dwCommentLen = ConvertEndian(*reinterpret_cast(p)); + CMyStringW str; + str.SetUTF8String(reinterpret_cast(p + 4), static_cast(dwCommentLen)); p += dwCommentLen + 4; CMyStringW strType, strDebug; strType.SetString(lpszKeyType, dwKeyTypeLen); @@ -485,7 +485,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication return LIBSSH2_ERROR_AGENT_PROTOCOL; } // skip signature length - auto entireLen = ConvertEndian(*((DWORD*)pSignedData)); + auto entireLen = ConvertEndian(*reinterpret_cast(pSignedData)); pSignedData += 4; nSignedLen -= 4; // skip signing method @@ -494,7 +494,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication free(buff); return LIBSSH2_ERROR_AGENT_PROTOCOL; } - auto methodLen = ConvertEndian(*((DWORD*)pSignedData)); + auto methodLen = ConvertEndian(*reinterpret_cast(pSignedData)); pSignedData += 4; nSignedLen -= 4; if (nSignedLen < methodLen) @@ -511,7 +511,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication free(buff); return LIBSSH2_ERROR_AGENT_PROTOCOL; } - auto signatureLen = ConvertEndian(*((DWORD*)pSignedData)); + auto signatureLen = ConvertEndian(*reinterpret_cast(pSignedData)); pSignedData += 4; nSignedLen -= 4; if (nSignedLen < signatureLen) diff --git a/ShellDLL/Func.cpp b/ShellDLL/Func.cpp index ada02c7..33b8708 100644 --- a/ShellDLL/Func.cpp +++ b/ShellDLL/Func.cpp @@ -60,7 +60,7 @@ extern "C" int __stdcall MyMessageBoxW(HWND hWnd, LPCWSTR lpszText, LPCWSTR lpsz lpszText = strText; } if (lpszCaption == NULL) - lpszCaption = (LPCWSTR) IDS_APP_TITLE; + lpszCaption = MAKEINTRESOURCEW(IDS_APP_TITLE); if (HIWORD(lpszCaption) == 0 && lpszCaption != NULL) { strCaption.LoadString((UINT) LOWORD(lpszCaption)); From cdba95067a3e762485cf665bf4d6ad9efd5c4bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jet=20=28=E3=82=B8=E3=82=A7=E3=83=83=E3=83=88=29?= <34238471+jet2jet@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:52:03 +0900 Subject: [PATCH 2/2] fix: preserve constness when reading key type length --- ShellDLL/Auth.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellDLL/Auth.cpp b/ShellDLL/Auth.cpp index de37a41..64e971b 100644 --- a/ShellDLL/Auth.cpp +++ b/ShellDLL/Auth.cpp @@ -452,7 +452,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication p += nBlobLen + 4; { - DWORD dwKeyTypeLen = ConvertEndian(*reinterpret_cast(pBlob)); + DWORD dwKeyTypeLen = ConvertEndian(*reinterpret_cast(pBlob)); LPCSTR lpszKeyType = reinterpret_cast(pBlob + 4); // get the comment of key