Skip to content
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
wants to merge 94 commits into from
Closed

Conversation

evanj
Copy link

@evanj evanj commented Dec 20, 2021

No description provided.

jmoiron and others added 30 commits November 10, 2016 21:55
[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
j-vizcaino and others added 26 commits January 21, 2020 18:18
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.
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.
@evanj evanj closed this Dec 20, 2021
@evanj evanj deleted the evan.jones/reader-fix branch December 20, 2021 18:32
@evanj evanj restored the evan.jones/reader-fix branch December 20, 2021 18:32
@evanj evanj deleted the evan.jones/reader-fix branch December 27, 2021 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants