Skip to content

Commit eb6fe80

Browse files
authored
Merge pull request #4 from jet2jet/codex/replace-c-style-casts-with-c++-casts
Replace C-style casts with C++ casts in authentication and UI helpers
2 parents 308ade5 + cdba950 commit eb6fe80

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

EasySFTP/Func.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern "C" int __stdcall MyMessageBoxW(HWND hWnd, LPCWSTR lpszText, LPCWSTR lpsz
4242
lpszText = strText;
4343
}
4444
if (lpszCaption == NULL)
45-
lpszCaption = (LPCWSTR) IDS_APP_TITLE;
45+
lpszCaption = MAKEINTRESOURCEW(IDS_APP_TITLE);
4646
if (HIWORD(lpszCaption) == 0 && lpszCaption != NULL)
4747
{
4848
strCaption.LoadString((UINT) LOWORD(lpszCaption));

ShellDLL/Auth.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ bool CAuthentication::AssignAgentFlags(CAuthSession* pAuthSession)
376376
if (pAuthSession->nPrevFlags == 0)
377377
return false;
378378
// get key type data (in the head of blob data)
379-
DWORD dwKeyTypeLen = ConvertEndian(*((DWORD*)(pAuthSession->lpCurrentKey + 4)));
380-
LPCSTR lpszKeyType = (LPCSTR)(pAuthSession->lpCurrentKey + 8);
379+
DWORD dwKeyTypeLen = ConvertEndian(*reinterpret_cast<DWORD*>(pAuthSession->lpCurrentKey + 4));
380+
LPCSTR lpszKeyType = reinterpret_cast<LPCSTR>(pAuthSession->lpCurrentKey + 8);
381381

382382
if ((dwKeyTypeLen == 7 && memcmp(lpszKeyType, "ssh-rsa", dwKeyTypeLen) == 0) ||
383383
(dwKeyTypeLen == 28 && memcmp(lpszKeyType, "ssh-rsa-cert-v01@openssh.com", dwKeyTypeLen) == 0))
@@ -431,7 +431,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication
431431
pAuthSession->dwSignature = AUTH_SESSION_SIGNATURE;
432432
pAuthSession->pAgent = pAgent;
433433
pAuthSession->lpPageantKeyList = lpKeyList;
434-
pAuthSession->dwKeyCount = ConvertEndian(*((DWORD*)lpKeyList));
434+
pAuthSession->dwKeyCount = ConvertEndian(*reinterpret_cast<DWORD*>(lpKeyList));
435435
pAuthSession->dwKeyIndex = 0;
436436
pAuthSession->lpCurrentKey = lpKeyList + 4;
437437
pAuthSession->nPrevFlags = -1;
@@ -447,18 +447,18 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication
447447
LPCBYTE pBlob;
448448
size_t nBlobLen;
449449

450-
nBlobLen = (size_t)ConvertEndian(*((DWORD*)p));
450+
nBlobLen = static_cast<size_t>(ConvertEndian(*reinterpret_cast<DWORD*>(p)));
451451
pBlob = (p + 4);
452452
p += nBlobLen + 4;
453453

454454
{
455-
DWORD dwKeyTypeLen = ConvertEndian(*((DWORD*)(pBlob)));
456-
LPCSTR lpszKeyType = (LPCSTR)(pBlob + 4);
455+
DWORD dwKeyTypeLen = ConvertEndian(*reinterpret_cast<const DWORD*>(pBlob));
456+
LPCSTR lpszKeyType = reinterpret_cast<LPCSTR>(pBlob + 4);
457457

458458
// get the comment of key
459-
DWORD dwCommentLen = ConvertEndian(*((DWORD*)p));
460-
CMyStringW str;
461-
str.SetUTF8String((LPCBYTE)(p + 4), static_cast<size_t>(dwCommentLen));
459+
DWORD dwCommentLen = ConvertEndian(*reinterpret_cast<DWORD*>(p));
460+
CMyStringW str;
461+
str.SetUTF8String(reinterpret_cast<LPCBYTE>(p + 4), static_cast<size_t>(dwCommentLen));
462462
p += dwCommentLen + 4;
463463
CMyStringW strType, strDebug;
464464
strType.SetString(lpszKeyType, dwKeyTypeLen);
@@ -485,7 +485,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication
485485
return LIBSSH2_ERROR_AGENT_PROTOCOL;
486486
}
487487
// skip signature length
488-
auto entireLen = ConvertEndian(*((DWORD*)pSignedData));
488+
auto entireLen = ConvertEndian(*reinterpret_cast<DWORD*>(pSignedData));
489489
pSignedData += 4;
490490
nSignedLen -= 4;
491491
// skip signing method
@@ -494,7 +494,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication
494494
free(buff);
495495
return LIBSSH2_ERROR_AGENT_PROTOCOL;
496496
}
497-
auto methodLen = ConvertEndian(*((DWORD*)pSignedData));
497+
auto methodLen = ConvertEndian(*reinterpret_cast<DWORD*>(pSignedData));
498498
pSignedData += 4;
499499
nSignedLen -= 4;
500500
if (nSignedLen < methodLen)
@@ -511,7 +511,7 @@ AuthReturnType CAuthentication::SSHAuthenticateWithAgent(IEasySFTPAuthentication
511511
free(buff);
512512
return LIBSSH2_ERROR_AGENT_PROTOCOL;
513513
}
514-
auto signatureLen = ConvertEndian(*((DWORD*)pSignedData));
514+
auto signatureLen = ConvertEndian(*reinterpret_cast<DWORD*>(pSignedData));
515515
pSignedData += 4;
516516
nSignedLen -= 4;
517517
if (nSignedLen < signatureLen)

ShellDLL/Func.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extern "C" int __stdcall MyMessageBoxW(HWND hWnd, LPCWSTR lpszText, LPCWSTR lpsz
6060
lpszText = strText;
6161
}
6262
if (lpszCaption == NULL)
63-
lpszCaption = (LPCWSTR) IDS_APP_TITLE;
63+
lpszCaption = MAKEINTRESOURCEW(IDS_APP_TITLE);
6464
if (HIWORD(lpszCaption) == 0 && lpszCaption != NULL)
6565
{
6666
strCaption.LoadString((UINT) LOWORD(lpszCaption));

0 commit comments

Comments
 (0)