{"action":"created","comment":{"url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/comments/120429011","pull_request_review_id":42391076,"id":120429011,"diff_hunk":"@@ -1044,58 +1044,62 @@ w32_strerror(int errnum)\n \t\treturn _sys_errlist_ext[errnum - EADDRINUSE];\n \treturn strerror(errnum);\n }\n-/* \n- * Temporary implementation of readpassphrase. \n- * TODO - this needs to be reimplemented as per \n- * https://linux.die.net/man/3/readpassphrase\n- */\n-char * \n-readpassphrase(const char *prompt, char *out, size_t out_len, int flags) {\n-\tchar *askpass = NULL;\n-\tchar *ret = NULL;\n \n-\tDWORD mode;\n-\tsize_t len = 0;\n-\tint retr = 0;\n+char *\n+readpassphrase(const char *prompt, char *outBuf, size_t outBufLen, int flags) {\n+\tint currentIndex = 0;\n+\tchar ch;\n+\n+\tif (outBufLen == 0) {\n+\t\terrno = EINVAL;\n+\t\treturn(NULL);\n+\t}\n+\t\n+\twhile (_kbhit()) _getch();\n \n-\t/* prompt user */\n \twchar_t* wtmp = utf8_to_utf16(prompt);\n \tif (wtmp == NULL)\n \t\tfatal(\"unable to alloc memory\");\n+\n \t_cputws(wtmp);\n \tfree(wtmp);\n \n-\tlen = retr = 0;\n-\n-\twhile (_kbhit())\n-\t\t_getch();\n-\n-\twhile (len < out_len) {\n-\t\tout[len] = (unsigned char)_getch();\n-\n-\t\tif (out[len] == '\\r') {\n-\t\t\tif (_kbhit()) /* read linefeed if its there */\n-\t\t\t\t_getch();\n+\twhile (currentIndex < outBufLen - 1) {\n+\t\tch = _getch();\n+\t\t\n+\t\tif (ch == '\\r') {\n+\t\t\tif (_kbhit()) _getch(); /* read linefeed if its there */\t\t\t\t\n \t\t\tbreak;\n-\t\t}\n-\t\telse if (out[len] == '\\n') {\n+\t\t} else if (ch == '\\n') {\n \t\t\tbreak;\n-\t\t}\n-\t\telse if (out[len] == '\\b') { /* backspace */\n-\t\t\tif (len > 0)\n-\t\t\t\tlen--; /* overwrite last character */\n-\t\t}\n-\t\telse if (out[len] == '\\003') {\n-\t\t\t/* exit on Ctrl+C */\n+\t\t} else if (ch == '\\b') { /* backspace */\n+\t\t\tif (currentIndex > 0) {\n+\t\t\t\tif (flags & RPP_ECHO_ON)\n+\t\t\t\t\tprintf(\"%c \\b\", ch);\n+\n+\t\t\t\tcurrentIndex--; /* overwrite last character */\n+\t\t\t}\n+\t\t} else if (ch == '\\003') { /* exit on Ctrl+C */","path":"contrib/win32/win32compat/misc.c","position":72,"original_position":72,"commit_id":"e982afdd411c070754e68b9ea0156665fd98f684","original_commit_id":"e982afdd411c070754e68b9ea0156665fd98f684","user":{"login":"manojampalam","id":14185020,"avatar_url":"https://avatars3.githubusercontent.com/u/14185020?v=3","gravatar_id":"","url":"https://api.github.com/users/manojampalam","html_url":"https://github.com/manojampalam","followers_url":"https://api.github.com/users/manojampalam/followers","following_url":"https://api.github.com/users/manojampalam/following{/other_user}","gists_url":"https://api.github.com/users/manojampalam/gists{/gist_id}","starred_url":"https://api.github.com/users/manojampalam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manojampalam/subscriptions","organizations_url":"https://api.github.com/users/manojampalam/orgs","repos_url":"https://api.github.com/users/manojampalam/repos","events_url":"https://api.github.com/users/manojampalam/events{/privacy}","received_events_url":"https://api.github.com/users/manojampalam/received_events","type":"User","site_admin":false},"body":"If we use console APIs, as I described above, there is not need to handle and treat individual key strokes","created_at":"2017-06-06T17:40:24Z","updated_at":"2017-06-06T17:40:24Z","html_url":"https://github.com/PowerShell/openssh-portable/pull/156#discussion_r120429011","pull_request_url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156","_links":{"self":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/comments/120429011"},"html":{"href":"https://github.com/PowerShell/openssh-portable/pull/156#discussion_r120429011"},"pull_request":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156"}}},"pull_request":{"url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156","id":123816259,"html_url":"https://github.com/PowerShell/openssh-portable/pull/156","diff_url":"https://github.com/PowerShell/openssh-portable/pull/156.diff","patch_url":"https://github.com/PowerShell/openssh-portable/pull/156.patch","issue_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues/156","number":156,"state":"open","locked":false,"title":"Readpassphrase #692","user":{"login":"bagajjal","id":23668037,"avatar_url":"https://avatars3.githubusercontent.com/u/23668037?v=3","gravatar_id":"","url":"https://api.github.com/users/bagajjal","html_url":"https://github.com/bagajjal","followers_url":"https://api.github.com/users/bagajjal/followers","following_url":"https://api.github.com/users/bagajjal/following{/other_user}","gists_url":"https://api.github.com/users/bagajjal/gists{/gist_id}","starred_url":"https://api.github.com/users/bagajjal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bagajjal/subscriptions","organizations_url":"https://api.github.com/users/bagajjal/orgs","repos_url":"https://api.github.com/users/bagajjal/repos","events_url":"https://api.github.com/users/bagajjal/events{/privacy}","received_events_url":"https://api.github.com/users/bagajjal/received_events","type":"User","site_admin":false},"body":"1) Fix for #692 \r\nhttps://github.com/PowerShell/Win32-OpenSSH/issues/692\r\n\r\n2) Implement readpassphrase to align with unix implementation.","created_at":"2017-06-02T23:20:33Z","updated_at":"2017-06-06T17:40:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c51e05984373a9e2f42566aec743f98dd0d50ec","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156/commits","review_comments_url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156/comments","review_comment_url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues/156/comments","statuses_url":"https://api.github.com/repos/PowerShell/openssh-portable/statuses/e982afdd411c070754e68b9ea0156665fd98f684","head":{"label":"PowerShell:readpassphrase_#692","ref":"readpassphrase_#692","sha":"e982afdd411c070754e68b9ea0156665fd98f684","user":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars0.githubusercontent.com/u/11524380?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"repo":{"id":72603626,"name":"openssh-portable","full_name":"PowerShell/openssh-portable","owner":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars0.githubusercontent.com/u/11524380?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PowerShell/openssh-portable","description":"Portable OpenSSH","fork":true,"url":"https://api.github.com/repos/PowerShell/openssh-portable","forks_url":"https://api.github.com/repos/PowerShell/openssh-portable/forks","keys_url":"https://api.github.com/repos/PowerShell/openssh-portable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PowerShell/openssh-portable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PowerShell/openssh-portable/teams","hooks_url":"https://api.github.com/repos/PowerShell/openssh-portable/hooks","issue_events_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues/events{/number}","events_url":"https://api.github.com/repos/PowerShell/openssh-portable/events","assignees_url":"https://api.github.com/repos/PowerShell/openssh-portable/assignees{/user}","branches_url":"https://api.github.com/repos/PowerShell/openssh-portable/branches{/branch}","tags_url":"https://api.github.com/repos/PowerShell/openssh-portable/tags","blobs_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/refs{/sha}","trees_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PowerShell/openssh-portable/statuses/{sha}","languages_url":"https://api.github.com/repos/PowerShell/openssh-portable/languages","stargazers_url":"https://api.github.com/repos/PowerShell/openssh-portable/stargazers","contributors_url":"https://api.github.com/repos/PowerShell/openssh-portable/contributors","subscribers_url":"https://api.github.com/repos/PowerShell/openssh-portable/subscribers","subscription_url":"https://api.github.com/repos/PowerShell/openssh-portable/subscription","commits_url":"https://api.github.com/repos/PowerShell/openssh-portable/commits{/sha}","git_commits_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/commits{/sha}","comments_url":"https://api.github.com/repos/PowerShell/openssh-portable/comments{/number}","issue_comment_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues/comments{/number}","contents_url":"https://api.github.com/repos/PowerShell/openssh-portable/contents/{+path}","compare_url":"https://api.github.com/repos/PowerShell/openssh-portable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PowerShell/openssh-portable/merges","archive_url":"https://api.github.com/repos/PowerShell/openssh-portable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PowerShell/openssh-portable/downloads","issues_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues{/number}","pulls_url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls{/number}","milestones_url":"https://api.github.com/repos/PowerShell/openssh-portable/milestones{/number}","notifications_url":"https://api.github.com/repos/PowerShell/openssh-portable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PowerShell/openssh-portable/labels{/name}","releases_url":"https://api.github.com/repos/PowerShell/openssh-portable/releases{/id}","deployments_url":"https://api.github.com/repos/PowerShell/openssh-portable/deployments","created_at":"2016-11-02T04:18:48Z","updated_at":"2017-06-03T06:20:29Z","pushed_at":"2017-06-06T17:34:06Z","git_url":"git://github.com/PowerShell/openssh-portable.git","ssh_url":"git@github.com:PowerShell/openssh-portable.git","clone_url":"https://github.com/PowerShell/openssh-portable.git","svn_url":"https://github.com/PowerShell/openssh-portable","homepage":null,"size":39972,"stargazers_count":42,"watchers_count":42,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":10,"forks":14,"open_issues":10,"watchers":42,"default_branch":"latestw_all"}},"base":{"label":"PowerShell:latestw_all","ref":"latestw_all","sha":"fb192e832a5dbb595232d18c56bcd5c7d1eb5578","user":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars0.githubusercontent.com/u/11524380?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"repo":{"id":72603626,"name":"openssh-portable","full_name":"PowerShell/openssh-portable","owner":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars0.githubusercontent.com/u/11524380?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PowerShell/openssh-portable","description":"Portable OpenSSH","fork":true,"url":"https://api.github.com/repos/PowerShell/openssh-portable","forks_url":"https://api.github.com/repos/PowerShell/openssh-portable/forks","keys_url":"https://api.github.com/repos/PowerShell/openssh-portable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PowerShell/openssh-portable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PowerShell/openssh-portable/teams","hooks_url":"https://api.github.com/repos/PowerShell/openssh-portable/hooks","issue_events_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues/events{/number}","events_url":"https://api.github.com/repos/PowerShell/openssh-portable/events","assignees_url":"https://api.github.com/repos/PowerShell/openssh-portable/assignees{/user}","branches_url":"https://api.github.com/repos/PowerShell/openssh-portable/branches{/branch}","tags_url":"https://api.github.com/repos/PowerShell/openssh-portable/tags","blobs_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/refs{/sha}","trees_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PowerShell/openssh-portable/statuses/{sha}","languages_url":"https://api.github.com/repos/PowerShell/openssh-portable/languages","stargazers_url":"https://api.github.com/repos/PowerShell/openssh-portable/stargazers","contributors_url":"https://api.github.com/repos/PowerShell/openssh-portable/contributors","subscribers_url":"https://api.github.com/repos/PowerShell/openssh-portable/subscribers","subscription_url":"https://api.github.com/repos/PowerShell/openssh-portable/subscription","commits_url":"https://api.github.com/repos/PowerShell/openssh-portable/commits{/sha}","git_commits_url":"https://api.github.com/repos/PowerShell/openssh-portable/git/commits{/sha}","comments_url":"https://api.github.com/repos/PowerShell/openssh-portable/comments{/number}","issue_comment_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues/comments{/number}","contents_url":"https://api.github.com/repos/PowerShell/openssh-portable/contents/{+path}","compare_url":"https://api.github.com/repos/PowerShell/openssh-portable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PowerShell/openssh-portable/merges","archive_url":"https://api.github.com/repos/PowerShell/openssh-portable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PowerShell/openssh-portable/downloads","issues_url":"https://api.github.com/repos/PowerShell/openssh-portable/issues{/number}","pulls_url":"https://api.github.com/repos/PowerShell/openssh-portable/pulls{/number}","milestones_url":"https://api.github.com/repos/PowerShell/openssh-portable/milestones{/number}","notifications_url":"https://api.github.com/repos/PowerShell/openssh-portable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PowerShell/openssh-portable/labels{/name}","releases_url":"https://api.github.com/repos/PowerShell/openssh-portable/releases{/id}","deployments_url":"https://api.github.com/repos/PowerShell/openssh-portable/deployments","created_at":"2016-11-02T04:18:48Z","updated_at":"2017-06-03T06:20:29Z","pushed_at":"2017-06-06T17:34:06Z","git_url":"git://github.com/PowerShell/openssh-portable.git","ssh_url":"git@github.com:PowerShell/openssh-portable.git","clone_url":"https://github.com/PowerShell/openssh-portable.git","svn_url":"https://github.com/PowerShell/openssh-portable","homepage":null,"size":39972,"stargazers_count":42,"watchers_count":42,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":10,"forks":14,"open_issues":10,"watchers":42,"default_branch":"latestw_all"}},"_links":{"self":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156"},"html":{"href":"https://github.com/PowerShell/openssh-portable/pull/156"},"issue":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/issues/156"},"comments":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/issues/156/comments"},"review_comments":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156/comments"},"review_comment":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/pulls/156/commits"},"statuses":{"href":"https://api.github.com/repos/PowerShell/openssh-portable/statuses/e982afdd411c070754e68b9ea0156665fd98f684"}}}}
{"actor":{"display_login":"manojampalam"}}