forked from cloudflare/golz4
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evan.jones/reader fix #4
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…rights, adjust license/doc
Change Uncompress() to return size
[golz4]add lz4 streaming API
Make the Reader work with io.Copy
add new printout to make sure using the right one
add more unit tests and checks in the Reader
Fix reader out of bounds
The LZ4_compress_fast_continue documentation is clear about this: any input data passed to the previous call, should still be available at the same memory address. Using Go byte arrays, managed by the GC does not fulfil that requirement because the arrays can be moved around in memory between two consecutive calls to the write function.
Write supports any input size
Write buffers do not move in memory
…d destination buffers
New CompressReader
Previously these functions would panic on bad input, unlike liblz4 itself, which returns errors if the input is bad. This will ensure callers can handle errors if the input is bad, rather than crash. Since decompression functions are typically used with input from outside a program, this seems worth the cost of an extra bounds check. A brief audit of a code base which uses these functions shows that many calls have no check. Some check for nil or len(input) == 0, which is incomplete.
Fixes the following warnings from the staticcheck tool. These are mostly harmless, but are also pretty trivial to clean up. Fixes: lz4_test.go:276:2: this value of err is never used (SA4006) lz4_test.go:305:2: this value of err is never used (SA4006) lz4_test.go:306:2: this value of err is never used (SA4006) lz4_test.go:350:2: this value of err is never used (SA4006) lz4_test.go:445:3: this value of n is never used (SA4006)
Go 1.16 added vet warnings to check for unsafe uses of reflect.SliceHeader. To fix them, use unsafe.Slice. This means this library now requires Go 1.17, which added this function. Fixes: ./lz4.go:162:35: possible misuse of reflect.SliceHeader ./lz4.go:509:35: possible misuse of reflect.SliceHeader
The Go io.Reader interface requires the returned byte count to be in the range [0, len(src)]. Some other standard library functions such as io.Copy will panic if a reader returns a negative value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.