{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/11030","labels_url":"https://api.github.com/repos/golang/go/issues/11030/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/11030/comments","events_url":"https://api.github.com/repos/golang/go/issues/11030/events","html_url":"https://github.com/golang/go/issues/11030","id":83827505,"number":11030,"title":"compress/flate: reader is not RFC1951 compliant","user":{"login":"dsnet","id":6354026,"avatar_url":"https://avatars.githubusercontent.com/u/6354026?v=3","gravatar_id":"","url":"https://api.github.com/users/dsnet","html_url":"https://github.com/dsnet","followers_url":"https://api.github.com/users/dsnet/followers","following_url":"https://api.github.com/users/dsnet/following{/other_user}","gists_url":"https://api.github.com/users/dsnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dsnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsnet/subscriptions","organizations_url":"https://api.github.com/users/dsnet/orgs","repos_url":"https://api.github.com/users/dsnet/repos","events_url":"https://api.github.com/users/dsnet/events{/privacy}","received_events_url":"https://api.github.com/users/dsnet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/2","html_url":"https://github.com/golang/go/milestones/Go1.5Maybe","labels_url":"https://api.github.com/repos/golang/go/milestones/2/labels","id":905114,"number":2,"title":"Go1.5Maybe","description":"Things that might make Go 1.5, but aren't critical.\r\n","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":128,"closed_issues":14,"state":"open","created_at":"2014-12-16T02:39:13Z","updated_at":"2015-06-04T21:39:42Z","due_on":"2015-07-31T04:00:00Z","closed_at":null},"comments":8,"created_at":"2015-06-02T04:12:11Z","updated_at":"2015-06-04T23:19:18Z","closed_at":null,"body":"Running the following produces an error:\r\n```go\r\npackage main\r\n\r\nimport \"bytes\"\r\nimport \"compress/flate\"\r\n\r\nfunc main() {\r\n\tb := bytes.NewBuffer([]byte{\r\n\t\t0x05, 0xc0, 0x07, 0x06, 0x00, 0x00, 0x00, 0x80, 0x40, 0x0f, 0xff, 0x37, 0xa0, 0xca,\r\n\t})\r\n\tr := flate.NewReader(b)\r\n\t_, err := r.Read(nil)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n}\r\n```\r\n\r\nThe byte slice above represents a single valid DEFLATE block compressed with a dynamic huffman tree, consisting of 257 literal/length codes and 1 distance codes. It should decompresses to nothing.\r\n\r\nIn the last byte (0xCA), the bit sequence (with LSB on left) is  01010011. The 11 at the end is the EOM marker in DEFLATE; the 0 to the left of that is the single code used for the distance tree.\r\n\r\nAccording to RFC1951 section 3.2.7, it says the following:\r\n> One distance code of zero bits means that there are no distance codes used at all (the data is all literals).\r\n\r\nAs can be seen above, the tree section terminates immediately with an EOM marker (11) and never uses the distance codes. Thus, this should properly decompress."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/109090217","html_url":"https://github.com/golang/go/issues/11030#issuecomment-109090217","issue_url":"https://api.github.com/repos/golang/go/issues/11030","id":109090217,"user":{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T23:19:18Z","updated_at":"2015-06-04T23:19:18Z","body":"Yeah, sounds legit to me too.  Seems like we should just relax (*huffmanDecoder).init to allow empty trees like how we already allow single-code trees.\r\n\r\n@dsnet Do you want to work on a CL for this?  If not, I can prepare one.\r\n\r\nAnd thanks for the analysis and test case!"}}