{"action":"created","comment":{"url":"https://api.github.com/repos/systemd/systemd/pulls/comments/73626155","id":73626155,"diff_hunk":"@@ -245,26 +247,31 @@ int read_full_stream(FILE *f, char **contents, size_t *size) {\n                 char *t;\n                 size_t k;\n \n-                t = realloc(buf, n+1);\n+                t = realloc(buf, n + 1);\n                 if (!t)\n                         return -ENOMEM;\n \n                 buf = t;\n                 k = fread(buf + l, 1, n - l, f);\n+                if (k > 0)\n+                        l += k;\n \n-                if (k <= 0) {\n-                        if (ferror(f))\n-                                return -errno;\n+                if (ferror(f))\n+                        return -errno;\n \n+                if (feof(f))\n                         break;\n-                }\n \n-                l += k;\n-                n *= 2;\n+                /* We aren't expecting fread() to return a short read outside\n+                 * of (error && eof), assert buffer is full and enlarge buffer.\n+                 */\n+                assert(l == n);\n \n                 /* Safety check */\n-                if (n > 4*1024*1024)\n+                if (n >= READ_FULL_BYTES_MAX)","path":"src/basic/fileio.c","position":51,"original_position":51,"commit_id":"065e99323d79a3e42094c2871fce0c986456d663","original_commit_id":"065e99323d79a3e42094c2871fce0c986456d663","user":{"login":"vcaputo","id":1452963,"avatar_url":"https://avatars.githubusercontent.com/u/1452963?v=3","gravatar_id":"","url":"https://api.github.com/users/vcaputo","html_url":"https://github.com/vcaputo","followers_url":"https://api.github.com/users/vcaputo/followers","following_url":"https://api.github.com/users/vcaputo/following{/other_user}","gists_url":"https://api.github.com/users/vcaputo/gists{/gist_id}","starred_url":"https://api.github.com/users/vcaputo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vcaputo/subscriptions","organizations_url":"https://api.github.com/users/vcaputo/orgs","repos_url":"https://api.github.com/users/vcaputo/repos","events_url":"https://api.github.com/users/vcaputo/events{/privacy}","received_events_url":"https://api.github.com/users/vcaputo/received_events","type":"User","site_admin":false},"body":"err, wait, how did this get through review  :)\r\n\r\nThis MAX should be MIN!\r\nhttps://github.com/systemd/systemd/pull/3887/files#diff-848519cc5291ffea7f8df5ed838136a4R274","created_at":"2016-08-05T00:32:13Z","updated_at":"2016-08-05T00:32:13Z","html_url":"https://github.com/systemd/systemd/pull/3887#discussion_r73626155","pull_request_url":"https://api.github.com/repos/systemd/systemd/pulls/3887","_links":{"self":{"href":"https://api.github.com/repos/systemd/systemd/pulls/comments/73626155"},"html":{"href":"https://github.com/systemd/systemd/pull/3887#discussion_r73626155"},"pull_request":{"href":"https://api.github.com/repos/systemd/systemd/pulls/3887"}}},"pull_request":{"url":"https://api.github.com/repos/systemd/systemd/pulls/3887","id":80017582,"html_url":"https://github.com/systemd/systemd/pull/3887","diff_url":"https://github.com/systemd/systemd/pull/3887.diff","patch_url":"https://github.com/systemd/systemd/pull/3887.patch","issue_url":"https://api.github.com/repos/systemd/systemd/issues/3887","number":3887,"state":"closed","locked":false,"title":"fileio: fix read_full_stream() bugs","user":{"login":"vcaputo","id":1452963,"avatar_url":"https://avatars.githubusercontent.com/u/1452963?v=3","gravatar_id":"","url":"https://api.github.com/users/vcaputo","html_url":"https://github.com/vcaputo","followers_url":"https://api.github.com/users/vcaputo/followers","following_url":"https://api.github.com/users/vcaputo/following{/other_user}","gists_url":"https://api.github.com/users/vcaputo/gists{/gist_id}","starred_url":"https://api.github.com/users/vcaputo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vcaputo/subscriptions","organizations_url":"https://api.github.com/users/vcaputo/orgs","repos_url":"https://api.github.com/users/vcaputo/repos","events_url":"https://api.github.com/users/vcaputo/events{/privacy}","received_events_url":"https://api.github.com/users/vcaputo/received_events","type":"User","site_admin":false},"body":"read_full_stream() _always_ allocated twice the memory needed, due to only\r\nbreaking the realloc() && fread() loop when fread() returned 0, requiring\r\nanother iteration and exponentially enlarged buffer just to discover the EOF\r\ncondition.\r\n    \r\nThis also caused file sizes >2MiB && <= 4MiB to erroneously be treated as\r\nE2BIG, due to the inappropriately doubled buffer size exceeding `4*1024*1024`.\r\n    \r\nAlso made the `4*1024*1024` magic number a READ_FULL_BYTES_MAX constant.","created_at":"2016-08-04T04:41:01Z","updated_at":"2016-08-05T00:32:13Z","closed_at":"2016-08-04T20:52:02Z","merged_at":"2016-08-04T20:52:02Z","merge_commit_sha":"c2d11a630287631d3b401a5cf300ea3655e21fd1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/systemd/systemd/pulls/3887/commits","review_comments_url":"https://api.github.com/repos/systemd/systemd/pulls/3887/comments","review_comment_url":"https://api.github.com/repos/systemd/systemd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/systemd/systemd/issues/3887/comments","statuses_url":"https://api.github.com/repos/systemd/systemd/statuses/065e99323d79a3e42094c2871fce0c986456d663","head":{"label":"vcaputo:read_full_stream_fixup","ref":"read_full_stream_fixup","sha":"065e99323d79a3e42094c2871fce0c986456d663","user":{"login":"vcaputo","id":1452963,"avatar_url":"https://avatars.githubusercontent.com/u/1452963?v=3","gravatar_id":"","url":"https://api.github.com/users/vcaputo","html_url":"https://github.com/vcaputo","followers_url":"https://api.github.com/users/vcaputo/followers","following_url":"https://api.github.com/users/vcaputo/following{/other_user}","gists_url":"https://api.github.com/users/vcaputo/gists{/gist_id}","starred_url":"https://api.github.com/users/vcaputo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vcaputo/subscriptions","organizations_url":"https://api.github.com/users/vcaputo/orgs","repos_url":"https://api.github.com/users/vcaputo/repos","events_url":"https://api.github.com/users/vcaputo/events{/privacy}","received_events_url":"https://api.github.com/users/vcaputo/received_events","type":"User","site_admin":false},"repo":{"id":38005055,"name":"systemd","full_name":"vcaputo/systemd","owner":{"login":"vcaputo","id":1452963,"avatar_url":"https://avatars.githubusercontent.com/u/1452963?v=3","gravatar_id":"","url":"https://api.github.com/users/vcaputo","html_url":"https://github.com/vcaputo","followers_url":"https://api.github.com/users/vcaputo/followers","following_url":"https://api.github.com/users/vcaputo/following{/other_user}","gists_url":"https://api.github.com/users/vcaputo/gists{/gist_id}","starred_url":"https://api.github.com/users/vcaputo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vcaputo/subscriptions","organizations_url":"https://api.github.com/users/vcaputo/orgs","repos_url":"https://api.github.com/users/vcaputo/repos","events_url":"https://api.github.com/users/vcaputo/events{/privacy}","received_events_url":"https://api.github.com/users/vcaputo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vcaputo/systemd","description":"systemd upstream","fork":true,"url":"https://api.github.com/repos/vcaputo/systemd","forks_url":"https://api.github.com/repos/vcaputo/systemd/forks","keys_url":"https://api.github.com/repos/vcaputo/systemd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vcaputo/systemd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vcaputo/systemd/teams","hooks_url":"https://api.github.com/repos/vcaputo/systemd/hooks","issue_events_url":"https://api.github.com/repos/vcaputo/systemd/issues/events{/number}","events_url":"https://api.github.com/repos/vcaputo/systemd/events","assignees_url":"https://api.github.com/repos/vcaputo/systemd/assignees{/user}","branches_url":"https://api.github.com/repos/vcaputo/systemd/branches{/branch}","tags_url":"https://api.github.com/repos/vcaputo/systemd/tags","blobs_url":"https://api.github.com/repos/vcaputo/systemd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vcaputo/systemd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vcaputo/systemd/git/refs{/sha}","trees_url":"https://api.github.com/repos/vcaputo/systemd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vcaputo/systemd/statuses/{sha}","languages_url":"https://api.github.com/repos/vcaputo/systemd/languages","stargazers_url":"https://api.github.com/repos/vcaputo/systemd/stargazers","contributors_url":"https://api.github.com/repos/vcaputo/systemd/contributors","subscribers_url":"https://api.github.com/repos/vcaputo/systemd/subscribers","subscription_url":"https://api.github.com/repos/vcaputo/systemd/subscription","commits_url":"https://api.github.com/repos/vcaputo/systemd/commits{/sha}","git_commits_url":"https://api.github.com/repos/vcaputo/systemd/git/commits{/sha}","comments_url":"https://api.github.com/repos/vcaputo/systemd/comments{/number}","issue_comment_url":"https://api.github.com/repos/vcaputo/systemd/issues/comments{/number}","contents_url":"https://api.github.com/repos/vcaputo/systemd/contents/{+path}","compare_url":"https://api.github.com/repos/vcaputo/systemd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vcaputo/systemd/merges","archive_url":"https://api.github.com/repos/vcaputo/systemd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vcaputo/systemd/downloads","issues_url":"https://api.github.com/repos/vcaputo/systemd/issues{/number}","pulls_url":"https://api.github.com/repos/vcaputo/systemd/pulls{/number}","milestones_url":"https://api.github.com/repos/vcaputo/systemd/milestones{/number}","notifications_url":"https://api.github.com/repos/vcaputo/systemd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vcaputo/systemd/labels{/name}","releases_url":"https://api.github.com/repos/vcaputo/systemd/releases{/id}","deployments_url":"https://api.github.com/repos/vcaputo/systemd/deployments","created_at":"2015-06-24T19:00:49Z","updated_at":"2015-06-24T19:00:54Z","pushed_at":"2016-08-05T00:25:07Z","git_url":"git://github.com/vcaputo/systemd.git","ssh_url":"git@github.com:vcaputo/systemd.git","clone_url":"https://github.com/vcaputo/systemd.git","svn_url":"https://github.com/vcaputo/systemd","homepage":"http://www.freedesktop.org/wiki/Software/systemd/","size":65701,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"systemd:master","ref":"master","sha":"eb18df724ba541ac1c7fd5c77d9244fa6bc5cabf","user":{"login":"systemd","id":1918868,"avatar_url":"https://avatars.githubusercontent.com/u/1918868?v=3","gravatar_id":"","url":"https://api.github.com/users/systemd","html_url":"https://github.com/systemd","followers_url":"https://api.github.com/users/systemd/followers","following_url":"https://api.github.com/users/systemd/following{/other_user}","gists_url":"https://api.github.com/users/systemd/gists{/gist_id}","starred_url":"https://api.github.com/users/systemd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/systemd/subscriptions","organizations_url":"https://api.github.com/users/systemd/orgs","repos_url":"https://api.github.com/users/systemd/repos","events_url":"https://api.github.com/users/systemd/events{/privacy}","received_events_url":"https://api.github.com/users/systemd/received_events","type":"Organization","site_admin":false},"repo":{"id":32873313,"name":"systemd","full_name":"systemd/systemd","owner":{"login":"systemd","id":1918868,"avatar_url":"https://avatars.githubusercontent.com/u/1918868?v=3","gravatar_id":"","url":"https://api.github.com/users/systemd","html_url":"https://github.com/systemd","followers_url":"https://api.github.com/users/systemd/followers","following_url":"https://api.github.com/users/systemd/following{/other_user}","gists_url":"https://api.github.com/users/systemd/gists{/gist_id}","starred_url":"https://api.github.com/users/systemd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/systemd/subscriptions","organizations_url":"https://api.github.com/users/systemd/orgs","repos_url":"https://api.github.com/users/systemd/repos","events_url":"https://api.github.com/users/systemd/events{/privacy}","received_events_url":"https://api.github.com/users/systemd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/systemd/systemd","description":"systemd upstream","fork":false,"url":"https://api.github.com/repos/systemd/systemd","forks_url":"https://api.github.com/repos/systemd/systemd/forks","keys_url":"https://api.github.com/repos/systemd/systemd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/systemd/systemd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/systemd/systemd/teams","hooks_url":"https://api.github.com/repos/systemd/systemd/hooks","issue_events_url":"https://api.github.com/repos/systemd/systemd/issues/events{/number}","events_url":"https://api.github.com/repos/systemd/systemd/events","assignees_url":"https://api.github.com/repos/systemd/systemd/assignees{/user}","branches_url":"https://api.github.com/repos/systemd/systemd/branches{/branch}","tags_url":"https://api.github.com/repos/systemd/systemd/tags","blobs_url":"https://api.github.com/repos/systemd/systemd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/systemd/systemd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/systemd/systemd/git/refs{/sha}","trees_url":"https://api.github.com/repos/systemd/systemd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/systemd/systemd/statuses/{sha}","languages_url":"https://api.github.com/repos/systemd/systemd/languages","stargazers_url":"https://api.github.com/repos/systemd/systemd/stargazers","contributors_url":"https://api.github.com/repos/systemd/systemd/contributors","subscribers_url":"https://api.github.com/repos/systemd/systemd/subscribers","subscription_url":"https://api.github.com/repos/systemd/systemd/subscription","commits_url":"https://api.github.com/repos/systemd/systemd/commits{/sha}","git_commits_url":"https://api.github.com/repos/systemd/systemd/git/commits{/sha}","comments_url":"https://api.github.com/repos/systemd/systemd/comments{/number}","issue_comment_url":"https://api.github.com/repos/systemd/systemd/issues/comments{/number}","contents_url":"https://api.github.com/repos/systemd/systemd/contents/{+path}","compare_url":"https://api.github.com/repos/systemd/systemd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/systemd/systemd/merges","archive_url":"https://api.github.com/repos/systemd/systemd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/systemd/systemd/downloads","issues_url":"https://api.github.com/repos/systemd/systemd/issues{/number}","pulls_url":"https://api.github.com/repos/systemd/systemd/pulls{/number}","milestones_url":"https://api.github.com/repos/systemd/systemd/milestones{/number}","notifications_url":"https://api.github.com/repos/systemd/systemd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/systemd/systemd/labels{/name}","releases_url":"https://api.github.com/repos/systemd/systemd/releases{/id}","deployments_url":"https://api.github.com/repos/systemd/systemd/deployments","created_at":"2015-03-25T15:27:27Z","updated_at":"2016-08-04T15:12:42Z","pushed_at":"2016-08-05T00:25:52Z","git_url":"git://github.com/systemd/systemd.git","ssh_url":"git@github.com:systemd/systemd.git","clone_url":"https://github.com/systemd/systemd.git","svn_url":"https://github.com/systemd/systemd","homepage":"http://www.freedesktop.org/wiki/Software/systemd/","size":79765,"stargazers_count":1233,"watchers_count":1233,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":527,"mirror_url":null,"open_issues_count":402,"forks":527,"open_issues":402,"watchers":1233,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/systemd/systemd/pulls/3887"},"html":{"href":"https://github.com/systemd/systemd/pull/3887"},"issue":{"href":"https://api.github.com/repos/systemd/systemd/issues/3887"},"comments":{"href":"https://api.github.com/repos/systemd/systemd/issues/3887/comments"},"review_comments":{"href":"https://api.github.com/repos/systemd/systemd/pulls/3887/comments"},"review_comment":{"href":"https://api.github.com/repos/systemd/systemd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/systemd/systemd/pulls/3887/commits"},"statuses":{"href":"https://api.github.com/repos/systemd/systemd/statuses/065e99323d79a3e42094c2871fce0c986456d663"}}}}
{"actor":{"display_login":"vcaputo"}}