{"action":"created","comment":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments/32195500","id":32195500,"diff_hunk":"@@ -150,9 +156,9 @@ static OSStatus read_cb(SSLConnectionRef conn, void *data, size_t *len)\n \trequested = left = *len;\n \tdo {\n \t\tret = git_stream_read(io, data + (requested - left), left);\n-\t\tif (ret < 0) {\n+\t\tif (ret <= 0) { /* There was an error or nothing could be read because stream is closed */\n \t\t\t*len = 0;\n-\t\t\treturn -1;\n+\t\t\treturn errSSLClosedAbort;","path":"src/stransport_stream.c","position":35,"original_position":35,"commit_id":"16b89ed7d7c168e896e06f6ca06ccb0277b879b3","original_commit_id":"16b89ed7d7c168e896e06f6ca06ccb0277b879b3","user":{"login":"swisspol","id":627915,"avatar_url":"https://avatars.githubusercontent.com/u/627915?v=3","gravatar_id":"","url":"https://api.github.com/users/swisspol","html_url":"https://github.com/swisspol","followers_url":"https://api.github.com/users/swisspol/followers","following_url":"https://api.github.com/users/swisspol/following{/other_user}","gists_url":"https://api.github.com/users/swisspol/gists{/gist_id}","starred_url":"https://api.github.com/users/swisspol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swisspol/subscriptions","organizations_url":"https://api.github.com/users/swisspol/orgs","repos_url":"https://api.github.com/users/swisspol/repos","events_url":"https://api.github.com/users/swisspol/events{/privacy}","received_events_url":"https://api.github.com/users/swisspol/received_events","type":"User","site_admin":false},"body":"Originally, I modified this function to behave like \"read up to *len bytes from the connection\" i.e. get rid of the `do ... while`. It worked the same way than the write function: \"write up to *len bytes to the connection\". In both cases if fewer bytes were handled, it would still return `noErr`.\r\n\r\nBut my functional tests failed when cloning a repo over HTTPS. So I figured, even though the docs do not mention that, maybe the behavior should be: \"read or write this *exact* number of bytes to the connection or fail entirely if it can't\". That's what you had done initially (why BTW?). I restored the `do ... while` in the read function and added the same behavior to the write function.\r\n\r\nIf you assume that's the desired behavior, and considering 0 can only be returned if fewer than `*len` were read, then the function should return an error. I picked `errSSLClosedAbort` for both read and write functions as it seemed the most sensitive among the possible SSL error codes.","created_at":"2015-06-11T07:26:15Z","updated_at":"2015-06-11T07:26:15Z","html_url":"https://github.com/libgit2/libgit2/pull/3208#discussion_r32195500","pull_request_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3208","_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments/32195500"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3208#discussion_r32195500"},"pull_request":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3208"}}},"pull_request":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/3208","id":37403147,"html_url":"https://github.com/libgit2/libgit2/pull/3208","diff_url":"https://github.com/libgit2/libgit2/pull/3208.diff","patch_url":"https://github.com/libgit2/libgit2/pull/3208.patch","issue_url":"https://api.github.com/repos/libgit2/libgit2/issues/3208","number":3208,"state":"open","locked":false,"title":"Fixed some Secure Transport issues on OS X","user":{"login":"swisspol","id":627915,"avatar_url":"https://avatars.githubusercontent.com/u/627915?v=3","gravatar_id":"","url":"https://api.github.com/users/swisspol","html_url":"https://github.com/swisspol","followers_url":"https://api.github.com/users/swisspol/followers","following_url":"https://api.github.com/users/swisspol/following{/other_user}","gists_url":"https://api.github.com/users/swisspol/gists{/gist_id}","starred_url":"https://api.github.com/users/swisspol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swisspol/subscriptions","organizations_url":"https://api.github.com/users/swisspol/orgs","repos_url":"https://api.github.com/users/swisspol/repos","events_url":"https://api.github.com/users/swisspol/events{/privacy}","received_events_url":"https://api.github.com/users/swisspol/received_events","type":"User","site_admin":false},"body":"This fixes a few issues with the callbacks passed to SSLSetIOFuncs():\r\n- The read callback could previously get into an infinite loop when 0\r\n  bytes were read.\r\n- The write callback has a similar implementation to the read callback\r\n  where it attempts to write the whole buffer or fails.\r\n- Callbacks now return Secure Transport result codes exclusively.","created_at":"2015-06-10T20:52:34Z","updated_at":"2015-06-11T07:26:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1a4b1205e90d10618c0b79a7e8d11f8df471236a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3208/commits","review_comments_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3208/comments","review_comment_url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/libgit2/issues/3208/comments","statuses_url":"https://api.github.com/repos/libgit2/libgit2/statuses/16b89ed7d7c168e896e06f6ca06ccb0277b879b3","head":{"label":"git-up:secure_transport","ref":"secure_transport","sha":"16b89ed7d7c168e896e06f6ca06ccb0277b879b3","user":{"login":"git-up","id":10783260,"avatar_url":"https://avatars.githubusercontent.com/u/10783260?v=3","gravatar_id":"","url":"https://api.github.com/users/git-up","html_url":"https://github.com/git-up","followers_url":"https://api.github.com/users/git-up/followers","following_url":"https://api.github.com/users/git-up/following{/other_user}","gists_url":"https://api.github.com/users/git-up/gists{/gist_id}","starred_url":"https://api.github.com/users/git-up/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-up/subscriptions","organizations_url":"https://api.github.com/users/git-up/orgs","repos_url":"https://api.github.com/users/git-up/repos","events_url":"https://api.github.com/users/git-up/events{/privacy}","received_events_url":"https://api.github.com/users/git-up/received_events","type":"Organization","site_admin":false},"repo":{"id":25694440,"name":"libgit2","full_name":"git-up/libgit2","owner":{"login":"git-up","id":10783260,"avatar_url":"https://avatars.githubusercontent.com/u/10783260?v=3","gravatar_id":"","url":"https://api.github.com/users/git-up","html_url":"https://github.com/git-up","followers_url":"https://api.github.com/users/git-up/followers","following_url":"https://api.github.com/users/git-up/following{/other_user}","gists_url":"https://api.github.com/users/git-up/gists{/gist_id}","starred_url":"https://api.github.com/users/git-up/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-up/subscriptions","organizations_url":"https://api.github.com/users/git-up/orgs","repos_url":"https://api.github.com/users/git-up/repos","events_url":"https://api.github.com/users/git-up/events{/privacy}","received_events_url":"https://api.github.com/users/git-up/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/git-up/libgit2","description":"The Library","fork":true,"url":"https://api.github.com/repos/git-up/libgit2","forks_url":"https://api.github.com/repos/git-up/libgit2/forks","keys_url":"https://api.github.com/repos/git-up/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/git-up/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/git-up/libgit2/teams","hooks_url":"https://api.github.com/repos/git-up/libgit2/hooks","issue_events_url":"https://api.github.com/repos/git-up/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/git-up/libgit2/events","assignees_url":"https://api.github.com/repos/git-up/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/git-up/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/git-up/libgit2/tags","blobs_url":"https://api.github.com/repos/git-up/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/git-up/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/git-up/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/git-up/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/git-up/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/git-up/libgit2/languages","stargazers_url":"https://api.github.com/repos/git-up/libgit2/stargazers","contributors_url":"https://api.github.com/repos/git-up/libgit2/contributors","subscribers_url":"https://api.github.com/repos/git-up/libgit2/subscribers","subscription_url":"https://api.github.com/repos/git-up/libgit2/subscription","commits_url":"https://api.github.com/repos/git-up/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/git-up/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/git-up/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/git-up/libgit2/issues/comments{/number}","contents_url":"https://api.github.com/repos/git-up/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/git-up/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/git-up/libgit2/merges","archive_url":"https://api.github.com/repos/git-up/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/git-up/libgit2/downloads","issues_url":"https://api.github.com/repos/git-up/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/git-up/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/git-up/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/git-up/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/git-up/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/git-up/libgit2/releases{/id}","created_at":"2014-10-24T15:19:55Z","updated_at":"2015-05-06T18:58:49Z","pushed_at":"2015-06-10T20:54:40Z","git_url":"git://github.com/git-up/libgit2.git","ssh_url":"git@github.com:git-up/libgit2.git","clone_url":"https://github.com/git-up/libgit2.git","svn_url":"https://github.com/git-up/libgit2","homepage":"http://libgit2.github.com","size":18151,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"libgit2:master","ref":"master","sha":"3e8c5e45cbf4f52b1100e7ae9f5cc229882b6f4d","user":{"login":"libgit2","id":394745,"avatar_url":"https://avatars.githubusercontent.com/u/394745?v=3","gravatar_id":"","url":"https://api.github.com/users/libgit2","html_url":"https://github.com/libgit2","followers_url":"https://api.github.com/users/libgit2/followers","following_url":"https://api.github.com/users/libgit2/following{/other_user}","gists_url":"https://api.github.com/users/libgit2/gists{/gist_id}","starred_url":"https://api.github.com/users/libgit2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgit2/subscriptions","organizations_url":"https://api.github.com/users/libgit2/orgs","repos_url":"https://api.github.com/users/libgit2/repos","events_url":"https://api.github.com/users/libgit2/events{/privacy}","received_events_url":"https://api.github.com/users/libgit2/received_events","type":"Organization","site_admin":false},"repo":{"id":901662,"name":"libgit2","full_name":"libgit2/libgit2","owner":{"login":"libgit2","id":394745,"avatar_url":"https://avatars.githubusercontent.com/u/394745?v=3","gravatar_id":"","url":"https://api.github.com/users/libgit2","html_url":"https://github.com/libgit2","followers_url":"https://api.github.com/users/libgit2/followers","following_url":"https://api.github.com/users/libgit2/following{/other_user}","gists_url":"https://api.github.com/users/libgit2/gists{/gist_id}","starred_url":"https://api.github.com/users/libgit2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgit2/subscriptions","organizations_url":"https://api.github.com/users/libgit2/orgs","repos_url":"https://api.github.com/users/libgit2/repos","events_url":"https://api.github.com/users/libgit2/events{/privacy}","received_events_url":"https://api.github.com/users/libgit2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libgit2/libgit2","description":"The Library","fork":false,"url":"https://api.github.com/repos/libgit2/libgit2","forks_url":"https://api.github.com/repos/libgit2/libgit2/forks","keys_url":"https://api.github.com/repos/libgit2/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgit2/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgit2/libgit2/teams","hooks_url":"https://api.github.com/repos/libgit2/libgit2/hooks","issue_events_url":"https://api.github.com/repos/libgit2/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/libgit2/libgit2/events","assignees_url":"https://api.github.com/repos/libgit2/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/libgit2/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/libgit2/libgit2/tags","blobs_url":"https://api.github.com/repos/libgit2/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgit2/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgit2/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgit2/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgit2/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/libgit2/libgit2/languages","stargazers_url":"https://api.github.com/repos/libgit2/libgit2/stargazers","contributors_url":"https://api.github.com/repos/libgit2/libgit2/contributors","subscribers_url":"https://api.github.com/repos/libgit2/libgit2/subscribers","subscription_url":"https://api.github.com/repos/libgit2/libgit2/subscription","commits_url":"https://api.github.com/repos/libgit2/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgit2/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgit2/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgit2/libgit2/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgit2/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/libgit2/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgit2/libgit2/merges","archive_url":"https://api.github.com/repos/libgit2/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgit2/libgit2/downloads","issues_url":"https://api.github.com/repos/libgit2/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/libgit2/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/libgit2/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/libgit2/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgit2/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/libgit2/libgit2/releases{/id}","created_at":"2010-09-10T16:17:48Z","updated_at":"2015-06-11T05:45:01Z","pushed_at":"2015-06-11T06:54:49Z","git_url":"git://github.com/libgit2/libgit2.git","ssh_url":"git@github.com:libgit2/libgit2.git","clone_url":"https://github.com/libgit2/libgit2.git","svn_url":"https://github.com/libgit2/libgit2","homepage":"http://libgit2.github.com","size":108352,"stargazers_count":4927,"watchers_count":4927,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1157,"mirror_url":null,"open_issues_count":136,"forks":1157,"open_issues":136,"watchers":4927,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3208"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3208"},"issue":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3208"},"comments":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3208/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3208/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3208/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/libgit2/statuses/16b89ed7d7c168e896e06f6ca06ccb0277b879b3"}}}}