{"action":"created","comment":{"url":"https://api.github.com/repos/tokio-rs/tokio/pulls/comments/216803847","pull_request_review_id":154373415,"id":216803847,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNjgwMzg0Nw==","diff_hunk":"@@ -41,15 +105,49 @@ impl Decoder for LinesCodec {\n     type Error = io::Error;\n \n     fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<String>, io::Error> {\n-        if let Some(newline_offset) =\n-            buf[self.next_index..].iter().position(|b| *b == b'\\n')\n-        {\n-            let newline_index = newline_offset + self.next_index;\n+        let mut trim_and_offset = None;\n+        for (offset, b) in buf[self.next_index..].iter().enumerate() {\n+            trim_and_offset = match (b, self.max_length) {\n+                // The current character is a newline, split here.\n+                (&b'\\n', _) => Some((1, offset)),\n+                // There's a maximum line length set, and we've reached it.\n+                (_, Some(max_len))\n+                    if offset.saturating_sub(self.next_index) == max_len => {\n+                    // If we're at the line length limit, check if the next\n+                    // character(s) is a newline before we decide to return an\n+                    // error.\n+                    match &buf[offset + 1..=offset + 2] {\n+                        &[b'\\n', _] => Some((1, offset + 1)),\n+                        &[b'\\r', b'\\n'] => Some((2, offset + 2)),\n+                        _ => {\n+                            // We've reached the length limit, and we're","path":"tokio-codec/src/lines_codec.rs","position":null,"original_position":109,"commit_id":"2e1076d8dd8ad36b124d575e56082509040f054d","original_commit_id":"622f2e30f54351400b7032b1b3a54f1157f7587c","user":{"login":"tobz","id":222615,"node_id":"MDQ6VXNlcjIyMjYxNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/222615?v=4","gravatar_id":"","url":"https://api.github.com/users/tobz","html_url":"https://github.com/tobz","followers_url":"https://api.github.com/users/tobz/followers","following_url":"https://api.github.com/users/tobz/following{/other_user}","gists_url":"https://api.github.com/users/tobz/gists{/gist_id}","starred_url":"https://api.github.com/users/tobz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobz/subscriptions","organizations_url":"https://api.github.com/users/tobz/orgs","repos_url":"https://api.github.com/users/tobz/repos","events_url":"https://api.github.com/users/tobz/events{/privacy}","received_events_url":"https://api.github.com/users/tobz/received_events","type":"User","site_admin":false},"body":"Looks like the comment got cut short?","created_at":"2018-09-11T20:05:45Z","updated_at":"2018-09-11T20:43:10Z","html_url":"https://github.com/tokio-rs/tokio/pull/590#discussion_r216803847","pull_request_url":"https://api.github.com/repos/tokio-rs/tokio/pulls/590","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/tokio-rs/tokio/pulls/comments/216803847"},"html":{"href":"https://github.com/tokio-rs/tokio/pull/590#discussion_r216803847"},"pull_request":{"href":"https://api.github.com/repos/tokio-rs/tokio/pulls/590"}}},"pull_request":{"url":"https://api.github.com/repos/tokio-rs/tokio/pulls/590","id":211584122,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExNTg0MTIy","html_url":"https://github.com/tokio-rs/tokio/pull/590","diff_url":"https://github.com/tokio-rs/tokio/pull/590.diff","patch_url":"https://github.com/tokio-rs/tokio/pull/590.patch","issue_url":"https://api.github.com/repos/tokio-rs/tokio/issues/590","number":590,"state":"open","locked":false,"title":"Add max line length to `LinesCodec`","user":{"login":"hawkw","id":2796466,"node_id":"MDQ6VXNlcjI3OTY0NjY=","avatar_url":"https://avatars1.githubusercontent.com/u/2796466?v=4","gravatar_id":"","url":"https://api.github.com/users/hawkw","html_url":"https://github.com/hawkw","followers_url":"https://api.github.com/users/hawkw/followers","following_url":"https://api.github.com/users/hawkw/following{/other_user}","gists_url":"https://api.github.com/users/hawkw/gists{/gist_id}","starred_url":"https://api.github.com/users/hawkw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hawkw/subscriptions","organizations_url":"https://api.github.com/users/hawkw/orgs","repos_url":"https://api.github.com/users/hawkw/repos","events_url":"https://api.github.com/users/hawkw/events{/privacy}","received_events_url":"https://api.github.com/users/hawkw/received_events","type":"User","site_admin":false},"body":"## Motivation\r\n\r\nCurrently, there is a potential denial of service vulnerability in the\r\n`lines` codec. Since there is no bound on the buffer that holds data\r\nbefore it is split into a new line, an attacker could send an unbounded\r\namount of data without sending a `\\n` character. \r\n\r\n## Solution\r\n\r\nThis branch adds a `set_decode_max_line_length` function on `LinesCodec`\r\nthat configures a limit on the maximum number of bytes per line. When\r\nthe limit is reached, the buffer will be broken into a new \"line\"\r\nregardless of the presence of a newline character. It was also necessary\r\nto add some special-case logic to avoid creating an empty line when the\r\nlength limit is reached at the character immediately _before_ a `\\r` or\r\n`\\n` character.\r\n\r\nAdditionally, this branch adds new tests for this function, including a\r\ntest for changing the line limit in-flight.\r\n\r\nFixes: #186 \r\n\r\nSigned-off-by: Eliza Weisman <eliza@buoyant.io>","created_at":"2018-08-28T23:09:19Z","updated_at":"2018-09-11T20:43:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a243b5177877ec99d4d178173dc4433f35cb895a","assignee":{"login":"hawkw","id":2796466,"node_id":"MDQ6VXNlcjI3OTY0NjY=","avatar_url":"https://avatars1.githubusercontent.com/u/2796466?v=4","gravatar_id":"","url":"https://api.github.com/users/hawkw","html_url":"https://github.com/hawkw","followers_url":"https://api.github.com/users/hawkw/followers","following_url":"https://api.github.com/users/hawkw/following{/other_user}","gists_url":"https://api.github.com/users/hawkw/gists{/gist_id}","starred_url":"https://api.github.com/users/hawkw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hawkw/subscriptions","organizations_url":"https://api.github.com/users/hawkw/orgs","repos_url":"https://api.github.com/users/hawkw/repos","events_url":"https://api.github.com/users/hawkw/events{/privacy}","received_events_url":"https://api.github.com/users/hawkw/received_events","type":"User","site_admin":false},"assignees":[{"login":"hawkw","id":2796466,"node_id":"MDQ6VXNlcjI3OTY0NjY=","avatar_url":"https://avatars1.githubusercontent.com/u/2796466?v=4","gravatar_id":"","url":"https://api.github.com/users/hawkw","html_url":"https://github.com/hawkw","followers_url":"https://api.github.com/users/hawkw/followers","following_url":"https://api.github.com/users/hawkw/following{/other_user}","gists_url":"https://api.github.com/users/hawkw/gists{/gist_id}","starred_url":"https://api.github.com/users/hawkw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hawkw/subscriptions","organizations_url":"https://api.github.com/users/hawkw/orgs","repos_url":"https://api.github.com/users/hawkw/repos","events_url":"https://api.github.com/users/hawkw/events{/privacy}","received_events_url":"https://api.github.com/users/hawkw/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":439897190,"node_id":"MDU6TGFiZWw0Mzk4OTcxOTA=","url":"https://api.github.com/repos/tokio-rs/tokio/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":897432855,"node_id":"MDU6TGFiZWw4OTc0MzI4NTU=","url":"https://api.github.com/repos/tokio-rs/tokio/labels/tokio-codec","name":"tokio-codec","color":"fef2c0","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/tokio-rs/tokio/pulls/590/commits","review_comments_url":"https://api.github.com/repos/tokio-rs/tokio/pulls/590/comments","review_comment_url":"https://api.github.com/repos/tokio-rs/tokio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tokio-rs/tokio/issues/590/comments","statuses_url":"https://api.github.com/repos/tokio-rs/tokio/statuses/2e1076d8dd8ad36b124d575e56082509040f054d","head":{"label":"tokio-rs:eliza/codec-max-len","ref":"eliza/codec-max-len","sha":"2e1076d8dd8ad36b124d575e56082509040f054d","user":{"login":"tokio-rs","id":20248544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMjQ4NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/20248544?v=4","gravatar_id":"","url":"https://api.github.com/users/tokio-rs","html_url":"https://github.com/tokio-rs","followers_url":"https://api.github.com/users/tokio-rs/followers","following_url":"https://api.github.com/users/tokio-rs/following{/other_user}","gists_url":"https://api.github.com/users/tokio-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tokio-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokio-rs/subscriptions","organizations_url":"https://api.github.com/users/tokio-rs/orgs","repos_url":"https://api.github.com/users/tokio-rs/repos","events_url":"https://api.github.com/users/tokio-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tokio-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":67836789,"node_id":"MDEwOlJlcG9zaXRvcnk2NzgzNjc4OQ==","name":"tokio","full_name":"tokio-rs/tokio","owner":{"login":"tokio-rs","id":20248544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMjQ4NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/20248544?v=4","gravatar_id":"","url":"https://api.github.com/users/tokio-rs","html_url":"https://github.com/tokio-rs","followers_url":"https://api.github.com/users/tokio-rs/followers","following_url":"https://api.github.com/users/tokio-rs/following{/other_user}","gists_url":"https://api.github.com/users/tokio-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tokio-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokio-rs/subscriptions","organizations_url":"https://api.github.com/users/tokio-rs/orgs","repos_url":"https://api.github.com/users/tokio-rs/repos","events_url":"https://api.github.com/users/tokio-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tokio-rs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tokio-rs/tokio","description":"A runtime for writing reliable, asynchronous, and slim applications with the Rust programming language.","fork":false,"url":"https://api.github.com/repos/tokio-rs/tokio","forks_url":"https://api.github.com/repos/tokio-rs/tokio/forks","keys_url":"https://api.github.com/repos/tokio-rs/tokio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tokio-rs/tokio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tokio-rs/tokio/teams","hooks_url":"https://api.github.com/repos/tokio-rs/tokio/hooks","issue_events_url":"https://api.github.com/repos/tokio-rs/tokio/issues/events{/number}","events_url":"https://api.github.com/repos/tokio-rs/tokio/events","assignees_url":"https://api.github.com/repos/tokio-rs/tokio/assignees{/user}","branches_url":"https://api.github.com/repos/tokio-rs/tokio/branches{/branch}","tags_url":"https://api.github.com/repos/tokio-rs/tokio/tags","blobs_url":"https://api.github.com/repos/tokio-rs/tokio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tokio-rs/tokio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tokio-rs/tokio/git/refs{/sha}","trees_url":"https://api.github.com/repos/tokio-rs/tokio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tokio-rs/tokio/statuses/{sha}","languages_url":"https://api.github.com/repos/tokio-rs/tokio/languages","stargazers_url":"https://api.github.com/repos/tokio-rs/tokio/stargazers","contributors_url":"https://api.github.com/repos/tokio-rs/tokio/contributors","subscribers_url":"https://api.github.com/repos/tokio-rs/tokio/subscribers","subscription_url":"https://api.github.com/repos/tokio-rs/tokio/subscription","commits_url":"https://api.github.com/repos/tokio-rs/tokio/commits{/sha}","git_commits_url":"https://api.github.com/repos/tokio-rs/tokio/git/commits{/sha}","comments_url":"https://api.github.com/repos/tokio-rs/tokio/comments{/number}","issue_comment_url":"https://api.github.com/repos/tokio-rs/tokio/issues/comments{/number}","contents_url":"https://api.github.com/repos/tokio-rs/tokio/contents/{+path}","compare_url":"https://api.github.com/repos/tokio-rs/tokio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tokio-rs/tokio/merges","archive_url":"https://api.github.com/repos/tokio-rs/tokio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tokio-rs/tokio/downloads","issues_url":"https://api.github.com/repos/tokio-rs/tokio/issues{/number}","pulls_url":"https://api.github.com/repos/tokio-rs/tokio/pulls{/number}","milestones_url":"https://api.github.com/repos/tokio-rs/tokio/milestones{/number}","notifications_url":"https://api.github.com/repos/tokio-rs/tokio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tokio-rs/tokio/labels{/name}","releases_url":"https://api.github.com/repos/tokio-rs/tokio/releases{/id}","deployments_url":"https://api.github.com/repos/tokio-rs/tokio/deployments","created_at":"2016-09-09T22:31:36Z","updated_at":"2018-09-11T19:57:55Z","pushed_at":"2018-09-11T20:30:40Z","git_url":"git://github.com/tokio-rs/tokio.git","ssh_url":"git@github.com:tokio-rs/tokio.git","clone_url":"https://github.com/tokio-rs/tokio.git","svn_url":"https://github.com/tokio-rs/tokio","homepage":"https://tokio.rs","size":4018,"stargazers_count":3096,"watchers_count":3096,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":203,"mirror_url":null,"archived":false,"open_issues_count":89,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":203,"open_issues":89,"watchers":3096,"default_branch":"master"}},"base":{"label":"tokio-rs:master","ref":"master","sha":"cc3b6af7a3927751b12a82c61fae97b4cca30c12","user":{"login":"tokio-rs","id":20248544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMjQ4NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/20248544?v=4","gravatar_id":"","url":"https://api.github.com/users/tokio-rs","html_url":"https://github.com/tokio-rs","followers_url":"https://api.github.com/users/tokio-rs/followers","following_url":"https://api.github.com/users/tokio-rs/following{/other_user}","gists_url":"https://api.github.com/users/tokio-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tokio-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokio-rs/subscriptions","organizations_url":"https://api.github.com/users/tokio-rs/orgs","repos_url":"https://api.github.com/users/tokio-rs/repos","events_url":"https://api.github.com/users/tokio-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tokio-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":67836789,"node_id":"MDEwOlJlcG9zaXRvcnk2NzgzNjc4OQ==","name":"tokio","full_name":"tokio-rs/tokio","owner":{"login":"tokio-rs","id":20248544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMjQ4NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/20248544?v=4","gravatar_id":"","url":"https://api.github.com/users/tokio-rs","html_url":"https://github.com/tokio-rs","followers_url":"https://api.github.com/users/tokio-rs/followers","following_url":"https://api.github.com/users/tokio-rs/following{/other_user}","gists_url":"https://api.github.com/users/tokio-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tokio-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokio-rs/subscriptions","organizations_url":"https://api.github.com/users/tokio-rs/orgs","repos_url":"https://api.github.com/users/tokio-rs/repos","events_url":"https://api.github.com/users/tokio-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tokio-rs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tokio-rs/tokio","description":"A runtime for writing reliable, asynchronous, and slim applications with the Rust programming language.","fork":false,"url":"https://api.github.com/repos/tokio-rs/tokio","forks_url":"https://api.github.com/repos/tokio-rs/tokio/forks","keys_url":"https://api.github.com/repos/tokio-rs/tokio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tokio-rs/tokio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tokio-rs/tokio/teams","hooks_url":"https://api.github.com/repos/tokio-rs/tokio/hooks","issue_events_url":"https://api.github.com/repos/tokio-rs/tokio/issues/events{/number}","events_url":"https://api.github.com/repos/tokio-rs/tokio/events","assignees_url":"https://api.github.com/repos/tokio-rs/tokio/assignees{/user}","branches_url":"https://api.github.com/repos/tokio-rs/tokio/branches{/branch}","tags_url":"https://api.github.com/repos/tokio-rs/tokio/tags","blobs_url":"https://api.github.com/repos/tokio-rs/tokio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tokio-rs/tokio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tokio-rs/tokio/git/refs{/sha}","trees_url":"https://api.github.com/repos/tokio-rs/tokio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tokio-rs/tokio/statuses/{sha}","languages_url":"https://api.github.com/repos/tokio-rs/tokio/languages","stargazers_url":"https://api.github.com/repos/tokio-rs/tokio/stargazers","contributors_url":"https://api.github.com/repos/tokio-rs/tokio/contributors","subscribers_url":"https://api.github.com/repos/tokio-rs/tokio/subscribers","subscription_url":"https://api.github.com/repos/tokio-rs/tokio/subscription","commits_url":"https://api.github.com/repos/tokio-rs/tokio/commits{/sha}","git_commits_url":"https://api.github.com/repos/tokio-rs/tokio/git/commits{/sha}","comments_url":"https://api.github.com/repos/tokio-rs/tokio/comments{/number}","issue_comment_url":"https://api.github.com/repos/tokio-rs/tokio/issues/comments{/number}","contents_url":"https://api.github.com/repos/tokio-rs/tokio/contents/{+path}","compare_url":"https://api.github.com/repos/tokio-rs/tokio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tokio-rs/tokio/merges","archive_url":"https://api.github.com/repos/tokio-rs/tokio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tokio-rs/tokio/downloads","issues_url":"https://api.github.com/repos/tokio-rs/tokio/issues{/number}","pulls_url":"https://api.github.com/repos/tokio-rs/tokio/pulls{/number}","milestones_url":"https://api.github.com/repos/tokio-rs/tokio/milestones{/number}","notifications_url":"https://api.github.com/repos/tokio-rs/tokio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tokio-rs/tokio/labels{/name}","releases_url":"https://api.github.com/repos/tokio-rs/tokio/releases{/id}","deployments_url":"https://api.github.com/repos/tokio-rs/tokio/deployments","created_at":"2016-09-09T22:31:36Z","updated_at":"2018-09-11T19:57:55Z","pushed_at":"2018-09-11T20:30:40Z","git_url":"git://github.com/tokio-rs/tokio.git","ssh_url":"git@github.com:tokio-rs/tokio.git","clone_url":"https://github.com/tokio-rs/tokio.git","svn_url":"https://github.com/tokio-rs/tokio","homepage":"https://tokio.rs","size":4018,"stargazers_count":3096,"watchers_count":3096,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":203,"mirror_url":null,"archived":false,"open_issues_count":89,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":203,"open_issues":89,"watchers":3096,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tokio-rs/tokio/pulls/590"},"html":{"href":"https://github.com/tokio-rs/tokio/pull/590"},"issue":{"href":"https://api.github.com/repos/tokio-rs/tokio/issues/590"},"comments":{"href":"https://api.github.com/repos/tokio-rs/tokio/issues/590/comments"},"review_comments":{"href":"https://api.github.com/repos/tokio-rs/tokio/pulls/590/comments"},"review_comment":{"href":"https://api.github.com/repos/tokio-rs/tokio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tokio-rs/tokio/pulls/590/commits"},"statuses":{"href":"https://api.github.com/repos/tokio-rs/tokio/statuses/2e1076d8dd8ad36b124d575e56082509040f054d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"tobz"}}