{"action":"created","issue":{"url":"https://api.github.com/repos/Cyan4973/lz4/issues/156","labels_url":"https://api.github.com/repos/Cyan4973/lz4/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/Cyan4973/lz4/issues/156/comments","events_url":"https://api.github.com/repos/Cyan4973/lz4/issues/156/events","html_url":"https://github.com/Cyan4973/lz4/issues/156","id":106636754,"number":156,"title":"Distinguishing between decompression errors","user":{"login":"nemequ","id":1151,"avatar_url":"https://avatars.githubusercontent.com/u/1151?v=3","gravatar_id":"","url":"https://api.github.com/users/nemequ","html_url":"https://github.com/nemequ","followers_url":"https://api.github.com/users/nemequ/followers","following_url":"https://api.github.com/users/nemequ/following{/other_user}","gists_url":"https://api.github.com/users/nemequ/gists{/gist_id}","starred_url":"https://api.github.com/users/nemequ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nemequ/subscriptions","organizations_url":"https://api.github.com/users/nemequ/orgs","repos_url":"https://api.github.com/users/nemequ/repos","events_url":"https://api.github.com/users/nemequ/events{/privacy}","received_events_url":"https://api.github.com/users/nemequ/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-15T20:15:09Z","updated_at":"2015-09-16T02:09:58Z","closed_at":null,"body":"`LZ4_decompress_safe` returns\r\n\r\n> the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize)\r\n> If destination buffer is not large enough, decoding will stop and output an error code (<0).\r\n> If the source stream is detected malformed, the function will stop decoding and return a negative result.\r\n> This function is protected against buffer overflow exploits, including malicious data packets.\r\n\r\nI would like to be able to distinguish between the different errors.  At least I would like to know if the input was malformed, incomplete, or the output buffer was just too small.\r\n\r\nAFAICT the error code isn't really documented anywhere, only that <0 is an error.  Maybe you could just return -1, -2, or -3 (or whatever) depending on the type of error…?"},"comment":{"url":"https://api.github.com/repos/Cyan4973/lz4/issues/comments/140602466","html_url":"https://github.com/Cyan4973/lz4/issues/156#issuecomment-140602466","issue_url":"https://api.github.com/repos/Cyan4973/lz4/issues/156","id":140602466,"user":{"login":"nemequ","id":1151,"avatar_url":"https://avatars.githubusercontent.com/u/1151?v=3","gravatar_id":"","url":"https://api.github.com/users/nemequ","html_url":"https://github.com/nemequ","followers_url":"https://api.github.com/users/nemequ/followers","following_url":"https://api.github.com/users/nemequ/following{/other_user}","gists_url":"https://api.github.com/users/nemequ/gists{/gist_id}","starred_url":"https://api.github.com/users/nemequ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nemequ/subscriptions","organizations_url":"https://api.github.com/users/nemequ/orgs","repos_url":"https://api.github.com/users/nemequ/repos","events_url":"https://api.github.com/users/nemequ/events{/privacy}","received_events_url":"https://api.github.com/users/nemequ/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T02:09:58Z","updated_at":"2015-09-16T02:09:58Z","body":"I'm not sure `LZ4_isError` is really necessary—testing for <0 isn't hard.  Zstd's errors are a bit less obvious (not sure about FSE, I haven't used it).  `LZ4_getErrorName` would be nice, though."}}