Skip to content
Browse files

Fix uninitialized memory read when the .ssh directory is empty

We now don't bother checking whether the .ssh directory exists. We just
rely on FindFirstFile failing both when there is no .ssh directory and it
contains no public keys.
  • Loading branch information...
1 parent 9d75208 commit ed9f9e1f0fe218c49a6a1638fabacfe8bbda9e1d @aroben aroben committed
Showing with 5 additions and 6 deletions.
  1. +5 −6 GHKeyBrowser/GHKeyBrowserDlg.cpp
View
11 GHKeyBrowser/GHKeyBrowserDlg.cpp
@@ -208,15 +208,14 @@ BOOL CGHKeyBrowserDlg::OnInitDialog()
SetHandleInformation(hChildStdOutRd, HANDLE_FLAG_INHERIT, 0);
wchar_t ssh_path[MAX_PATH];
- ExpandEnvironmentStrings(L"%HOMEDRIVE%%HOMEPATH%\\.ssh", ssh_path, MAX_PATH);
- if (GetFileAttributes(ssh_path) == 0xFFFFFFFF) {
- MessageBox(L"You don't appear to have any SSH keys!", L"~/.ssh doesn't exist");
- TerminateProcess(GetCurrentProcess(), -1);
- }
+ ExpandEnvironmentStrings(L"%HOMEDRIVE%%HOMEPATH%\\.ssh\\*.pub", ssh_path, MAX_PATH);
WIN32_FIND_DATA fd;
- wcscat(ssh_path, L"\\*.pub");
HANDLE hFd = FindFirstFile(ssh_path, &fd);
+ if (hFd == INVALID_HANDLE_VALUE) {
+ MessageBox(L"You don't appear to have any SSH keys!", L"~/.ssh doesn't exist");
+ TerminateProcess(GetCurrentProcess(), -1);
+ }
wchar_t* fallback_buf = NULL;

0 comments on commit ed9f9e1

Please sign in to comment.
Something went wrong with that request. Please try again.