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

Never directly dereference AWS SDK returned pointers #557

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

hifi
Copy link
Collaborator

@hifi hifi commented Jan 5, 2024

Apparently AWS or some other provider doesn't set the Content-Length header for all get object requests and we assume it can never be nil. Since it's only used for metrics we can allow them to be incorrect in those cases.

Proper fix would be to wrap the returned io.ReadCloser with one that will count the bytes read but that feels a bit much for some edge cases.

Fixes #556

Also replaced #555 with this by wrapping all possibly unsafe uses of AWS SDK returned pointers.

@hifi hifi force-pushed the fix/s3-unsafe-use-of-content-length branch from 122fbbd to 11da7b9 Compare January 5, 2024 18:29
@hifi hifi mentioned this pull request Jan 5, 2024
@hifi hifi changed the title Don't assume AWS SDK sets ContentLength for get object Never directly deference AWS SDK returned pointers Jan 5, 2024
@hifi hifi changed the title Never directly deference AWS SDK returned pointers Never directly dereference AWS SDK returned pointers Jan 5, 2024
The SDK provides helper functions when you want an empty value if
the actual one is nil so we can just wrap all of them to avoid getting
bit.

Fixes benbjohnson#556
Replaces benbjohnson#555

Also fixes another panic when getting a delete error without key.
@hifi hifi merged commit e4254bb into benbjohnson:main Jan 7, 2024
8 checks passed
@MalteMagnussen
Copy link

MalteMagnussen commented Jun 18, 2024

@hifi / @benbjohnson - Will this be included in a new Release? :)

Thanks for all the work on Litestream

Related to: #589

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.

Crash with invalid memory address or nil pointer dereference when restoring
3 participants