{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/63589886","id":63589886,"diff_hunk":"@@ -67,42 +74,50 @@\n \n         Node node = root;\n         int current = 0;\n-        int bits = 0;\n+        int currentBits = 0;\n+        int symbolBits = 0;\n         for (int i = 0; i < buf.length; i++) {\n             int b = buf[i] & 0xFF;\n             current = (current << 8) | b;\n-            bits += 8;\n-            while (bits >= 8) {\n-                int c = (current >>> (bits - 8)) & 0xFF;\n+            currentBits += 8;\n+            symbolBits += 8;\n+            while (currentBits >= 8) {\n+                int c = (current >>> (currentBits - 8)) & 0xFF;\n                 node = node.children[c];\n-                bits -= node.bits;\n+                currentBits -= node.bits;\n                 if (node.isTerminal()) {\n                     if (node.symbol == HpackUtil.HUFFMAN_EOS) {\n                         throw EOS_DECODED;\n                     }\n                     baos.write(node.symbol);\n                     node = root;\n+                    symbolBits = currentBits;\n                 }\n             }\n         }\n \n-        while (bits > 0) {\n-            int c = (current << (8 - bits)) & 0xFF;\n+        while (currentBits > 0) {","path":"codec-http2/src/main/java/io/netty/handler/codec/http2/internal/hpack/HuffmanDecoder.java","position":56,"original_position":56,"commit_id":"99215f89c51bab7004f2c82e415d4a875cb8d742","original_commit_id":"99215f89c51bab7004f2c82e415d4a875cb8d742","user":{"login":"nmittler","id":6493296,"avatar_url":"https://avatars.githubusercontent.com/u/6493296?v=3","gravatar_id":"","url":"https://api.github.com/users/nmittler","html_url":"https://github.com/nmittler","followers_url":"https://api.github.com/users/nmittler/followers","following_url":"https://api.github.com/users/nmittler/following{/other_user}","gists_url":"https://api.github.com/users/nmittler/gists{/gist_id}","starred_url":"https://api.github.com/users/nmittler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmittler/subscriptions","organizations_url":"https://api.github.com/users/nmittler/orgs","repos_url":"https://api.github.com/users/nmittler/repos","events_url":"https://api.github.com/users/nmittler/events{/privacy}","received_events_url":"https://api.github.com/users/nmittler/received_events","type":"User","site_admin":false},"body":"Add docs to this for loop?","created_at":"2016-05-17T19:42:29Z","updated_at":"2016-05-17T19:42:29Z","html_url":"https://github.com/netty/netty/pull/5268#discussion_r63589886","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/5268","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/63589886"},"html":{"href":"https://github.com/netty/netty/pull/5268#discussion_r63589886"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/5268"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/5268","id":70412498,"html_url":"https://github.com/netty/netty/pull/5268","diff_url":"https://github.com/netty/netty/pull/5268.diff","patch_url":"https://github.com/netty/netty/pull/5268.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/5268","number":5268,"state":"open","locked":false,"title":"HTTP/2 HPACK Header Name Validation and Trailing Padding","user":{"login":"carl-mastrangelo","id":8943572,"avatar_url":"https://avatars.githubusercontent.com/u/8943572?v=3","gravatar_id":"","url":"https://api.github.com/users/carl-mastrangelo","html_url":"https://github.com/carl-mastrangelo","followers_url":"https://api.github.com/users/carl-mastrangelo/followers","following_url":"https://api.github.com/users/carl-mastrangelo/following{/other_user}","gists_url":"https://api.github.com/users/carl-mastrangelo/gists{/gist_id}","starred_url":"https://api.github.com/users/carl-mastrangelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carl-mastrangelo/subscriptions","organizations_url":"https://api.github.com/users/carl-mastrangelo/orgs","repos_url":"https://api.github.com/users/carl-mastrangelo/repos","events_url":"https://api.github.com/users/carl-mastrangelo/events{/privacy}","received_events_url":"https://api.github.com/users/carl-mastrangelo/received_events","type":"User","site_admin":false},"body":"Motivation:\r\nThe HPACK code currently disallows empty header names. This is not explicitly forbidden by the HPACK RFC https://tools.ietf.org/html/rfc7541. However the HTTP/1.x RFC https://tools.ietf.org/html/rfc7230#section-3.2 and thus HTTP/2 both disallow empty header names, and so this precondition check should be moved from the HPACK code to the protocol level.\r\nHPACK also requires that string literals which are huffman encoded must be treated as an encoding error if the string has more than 7 trailing padding bits https://tools.ietf.org/html/rfc7541#section-5.2, but this is currently not enforced.\r\n\r\nResult:\r\n- HPACK to allow empty header names\r\n- HTTP/1.x and HTTP/2 header validation should not allow empty header names\r\n- Enforce max of 7 trailing padding bits\r\n\r\nResult:\r\nCode is more compliant with the above mentioned RFCs\r\nFixes https://github.com/netty/netty/issues/5228","created_at":"2016-05-17T19:07:35Z","updated_at":"2016-05-17T19:42:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"071fd0c3b9e4c4fe57c6af304f331e9a49bcde49","assignee":{"login":"nmittler","id":6493296,"avatar_url":"https://avatars.githubusercontent.com/u/6493296?v=3","gravatar_id":"","url":"https://api.github.com/users/nmittler","html_url":"https://github.com/nmittler","followers_url":"https://api.github.com/users/nmittler/followers","following_url":"https://api.github.com/users/nmittler/following{/other_user}","gists_url":"https://api.github.com/users/nmittler/gists{/gist_id}","starred_url":"https://api.github.com/users/nmittler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmittler/subscriptions","organizations_url":"https://api.github.com/users/nmittler/orgs","repos_url":"https://api.github.com/users/nmittler/repos","events_url":"https://api.github.com/users/nmittler/events{/privacy}","received_events_url":"https://api.github.com/users/nmittler/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/5268/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/5268/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/5268/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/99215f89c51bab7004f2c82e415d4a875cb8d742","head":{"label":"carl-mastrangelo:hpack_validate","ref":"hpack_validate","sha":"99215f89c51bab7004f2c82e415d4a875cb8d742","user":{"login":"carl-mastrangelo","id":8943572,"avatar_url":"https://avatars.githubusercontent.com/u/8943572?v=3","gravatar_id":"","url":"https://api.github.com/users/carl-mastrangelo","html_url":"https://github.com/carl-mastrangelo","followers_url":"https://api.github.com/users/carl-mastrangelo/followers","following_url":"https://api.github.com/users/carl-mastrangelo/following{/other_user}","gists_url":"https://api.github.com/users/carl-mastrangelo/gists{/gist_id}","starred_url":"https://api.github.com/users/carl-mastrangelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carl-mastrangelo/subscriptions","organizations_url":"https://api.github.com/users/carl-mastrangelo/orgs","repos_url":"https://api.github.com/users/carl-mastrangelo/repos","events_url":"https://api.github.com/users/carl-mastrangelo/events{/privacy}","received_events_url":"https://api.github.com/users/carl-mastrangelo/received_events","type":"User","site_admin":false},"repo":{"id":56262123,"name":"netty","full_name":"carl-mastrangelo/netty","owner":{"login":"carl-mastrangelo","id":8943572,"avatar_url":"https://avatars.githubusercontent.com/u/8943572?v=3","gravatar_id":"","url":"https://api.github.com/users/carl-mastrangelo","html_url":"https://github.com/carl-mastrangelo","followers_url":"https://api.github.com/users/carl-mastrangelo/followers","following_url":"https://api.github.com/users/carl-mastrangelo/following{/other_user}","gists_url":"https://api.github.com/users/carl-mastrangelo/gists{/gist_id}","starred_url":"https://api.github.com/users/carl-mastrangelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carl-mastrangelo/subscriptions","organizations_url":"https://api.github.com/users/carl-mastrangelo/orgs","repos_url":"https://api.github.com/users/carl-mastrangelo/repos","events_url":"https://api.github.com/users/carl-mastrangelo/events{/privacy}","received_events_url":"https://api.github.com/users/carl-mastrangelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/carl-mastrangelo/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/carl-mastrangelo/netty","forks_url":"https://api.github.com/repos/carl-mastrangelo/netty/forks","keys_url":"https://api.github.com/repos/carl-mastrangelo/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/carl-mastrangelo/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/carl-mastrangelo/netty/teams","hooks_url":"https://api.github.com/repos/carl-mastrangelo/netty/hooks","issue_events_url":"https://api.github.com/repos/carl-mastrangelo/netty/issues/events{/number}","events_url":"https://api.github.com/repos/carl-mastrangelo/netty/events","assignees_url":"https://api.github.com/repos/carl-mastrangelo/netty/assignees{/user}","branches_url":"https://api.github.com/repos/carl-mastrangelo/netty/branches{/branch}","tags_url":"https://api.github.com/repos/carl-mastrangelo/netty/tags","blobs_url":"https://api.github.com/repos/carl-mastrangelo/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/carl-mastrangelo/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/carl-mastrangelo/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/carl-mastrangelo/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/carl-mastrangelo/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/carl-mastrangelo/netty/languages","stargazers_url":"https://api.github.com/repos/carl-mastrangelo/netty/stargazers","contributors_url":"https://api.github.com/repos/carl-mastrangelo/netty/contributors","subscribers_url":"https://api.github.com/repos/carl-mastrangelo/netty/subscribers","subscription_url":"https://api.github.com/repos/carl-mastrangelo/netty/subscription","commits_url":"https://api.github.com/repos/carl-mastrangelo/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/carl-mastrangelo/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/carl-mastrangelo/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/carl-mastrangelo/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/carl-mastrangelo/netty/contents/{+path}","compare_url":"https://api.github.com/repos/carl-mastrangelo/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/carl-mastrangelo/netty/merges","archive_url":"https://api.github.com/repos/carl-mastrangelo/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/carl-mastrangelo/netty/downloads","issues_url":"https://api.github.com/repos/carl-mastrangelo/netty/issues{/number}","pulls_url":"https://api.github.com/repos/carl-mastrangelo/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/carl-mastrangelo/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/carl-mastrangelo/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/carl-mastrangelo/netty/labels{/name}","releases_url":"https://api.github.com/repos/carl-mastrangelo/netty/releases{/id}","deployments_url":"https://api.github.com/repos/carl-mastrangelo/netty/deployments","created_at":"2016-04-14T18:48:47Z","updated_at":"2016-04-14T18:48:59Z","pushed_at":"2016-05-17T19:06:18Z","git_url":"git://github.com/carl-mastrangelo/netty.git","ssh_url":"git@github.com:carl-mastrangelo/netty.git","clone_url":"https://github.com/carl-mastrangelo/netty.git","svn_url":"https://github.com/carl-mastrangelo/netty","homepage":"http://netty.io/","size":40616,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"4.1"}},"base":{"label":"netty:4.1","ref":"4.1","sha":"a517cce92fee24f2967bba7c84eea835b79fcab1","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","deployments_url":"https://api.github.com/repos/netty/netty/deployments","created_at":"2010-11-09T09:22:21Z","updated_at":"2016-05-17T16:47:19Z","pushed_at":"2016-05-17T19:07:35Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":67404,"stargazers_count":6844,"watchers_count":6844,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3484,"mirror_url":null,"open_issues_count":313,"forks":3484,"open_issues":313,"watchers":6844,"default_branch":"4.1"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/5268"},"html":{"href":"https://github.com/netty/netty/pull/5268"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/5268"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/5268/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/5268/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/5268/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/99215f89c51bab7004f2c82e415d4a875cb8d742"}}}}