Skip to content

google-cloud-nio: CloudStorageReadChannel: fix critical bug that could cause the channel position to overflow - #2283

Merged
michaelbausor merged 1 commit into
googleapis:masterfrom
droazen:dr_fix_CloudStorageReadChannel_position_overflow
Aug 24, 2017
Merged

google-cloud-nio: CloudStorageReadChannel: fix critical bug that could cause the channel position to overflow#2283
michaelbausor merged 1 commit into
googleapis:masterfrom
droazen:dr_fix_CloudStorageReadChannel_position_overflow

Conversation

@droazen

Copy link
Copy Markdown

This fixes a critical bug in CloudStorageReadChannel in which the channel position
(a long) was getting down-cast to int in CloudStorageReadChannel.innerOpen(). This
could cause the channel position to become negative or a wildly incorrect positive
value if the channel position was greater than MAX_INT.

In practice, this bug would only manifest itself if the channel was constructed with
a non-zero initial position, or if the channel was reopened in response to an error.

Included a test case that fails without the fix, and passes with the fix.

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 27, 2017
@lbergelson

Copy link
Copy Markdown
Contributor

The long nightmare is almost over!

@pshapiro4broad

Copy link
Copy Markdown

👍

@lbergelson

Copy link
Copy Markdown
Contributor

This will fix broadinstitute/gatk#2516 and broadinstitute/gatk#3316

@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 72215b5 on droazen:dr_fix_CloudStorageReadChannel_position_overflow into ** on GoogleCloudPlatform:master**.

droazen added a commit to broadinstitute/gatk that referenced this pull request Jul 27, 2017
…shaded
This includes the fix for the position overflowing in CloudStorageReadChannel
(googleapis/google-cloud-java#2283), as well
as the fix for the intermittent 503 errors we've already been depending on
(googleapis/google-cloud-java#2281)
droazen added a commit to broadinstitute/gatk that referenced this pull request Jul 27, 2017
…shaded
This includes the fix for the position overflowing in CloudStorageReadChannel
(googleapis/google-cloud-java#2283), as well
as the fix for the intermittent 503 errors we've already been depending on
(googleapis/google-cloud-java#2281)
droazen added a commit to broadinstitute/gatk that referenced this pull request Jul 27, 2017
…shaded (#3373)
This includes the fix for the position overflowing in CloudStorageReadChannel
(googleapis/google-cloud-java#2283), as well
as the fix for the intermittent 503 errors we've already been depending on
(googleapis/google-cloud-java#2281)
@droazen

Copy link
Copy Markdown
Author

@garrettjonesgoogle Could we please get an official review on this PR and #2281? Without these patches google-cloud-nio is unusable at large scale, so as a large-scale user of this library we are naturally eager to see these make it into a future release! :)

This PR (#2283) fixes a nasty bug that could cause the channel position to overflow and become either negative or a wildly incorrect positive value, leading to corruption of the input stream from the client perspective. This is not a hypothetical problem -- we experienced it quite frequently!

The other PR (#2281) wraps additional GCS operations within retry loops. Without that patch, 10-20% of our jobs were failing with transient 503 errors.

Thanks for your help!

@michaelbausormichaelbausor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one nit from Codacy

// This position value will overflow to a negative value if a long -> int cast is attempted
long startPosition = 11918483280L;
ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class);
final CloudStorageReadChannel channel = CloudStorageReadChannel.create(gcsStorage, file, startPosition, 1);

This comment was marked as spam.

…d cause the channel position to overflow
This fixes a critical bug in CloudStorageReadChannel in which the channel position
(a long) was getting down-cast to int in CloudStorageReadChannel.innerOpen(). This
could cause the channel position to become negative or a wildly incorrect positive
value if the channel position was greater than MAX_INT.
In practice, this bug would only manifest itself if the channel was constructed with
a non-zero initial position, or if the channel was reopened in response to an error.
Included a test case that fails without the fix, and passes with the fix.
@droazen
droazenforce-pushed the dr_fix_CloudStorageReadChannel_position_overflow branch from 72215b5 to 398cdaaCompareAugust 24, 2017 14:40
@droazen

Copy link
Copy Markdown
Author

@michaelbausor Thanks for the review! I've addressed the codacy error, so this should be good to go now I think.

@michaelbausor
michaelbausor merged commit 4055f1f into googleapis:masterAug 24, 2017
@droazen

Copy link
Copy Markdown
Author

Thanks for merging this and #2281@michaelbausor! Is there a timeline for the next google-cloud-java release?

@michaelbausor

Copy link
Copy Markdown
Contributor

Re the timing of the next release, @garrettjonesgoogle will know best

suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
suztomo pushed a commit that referenced this pull request Mar 30, 2026
…low (#2283)
This fixes a critical bug in CloudStorageReadChannel in which the channel position
(a long) was getting down-cast to int in CloudStorageReadChannel.innerOpen(). This
could cause the channel position to become negative or a wildly incorrect positive
value if the channel position was greater than MAX_INT.
In practice, this bug would only manifest itself if the channel was constructed with
a non-zero initial position, or if the channel was reopened in response to an error.
Included a test case that fails without the fix, and passes with the fix.
lqiu96 pushed a commit that referenced this pull request Apr 1, 2026
…low (#2283)
This fixes a critical bug in CloudStorageReadChannel in which the channel position
(a long) was getting down-cast to int in CloudStorageReadChannel.innerOpen(). This
could cause the channel position to become negative or a wildly incorrect positive
value if the channel position was greater than MAX_INT.
In practice, this bug would only manifest itself if the channel was constructed with
a non-zero initial position, or if the channel was reopened in response to an error.
Included a test case that fails without the fix, and passes with the fix.
meltsufin pushed a commit that referenced this pull request May 2, 2026
* chore(main): release 3.35.0
* chore: generate libraries at Thu Jan 15 15:40:14 UTC 2026
---------
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: cloud-java-bot <cloud-java-bot@google.com>
benjaminp pushed a commit to benjaminp/google-cloud-java that referenced this pull request Jul 13, 2026
…eapis#2283)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.truth:truth](https://togithub.com/google/truth) | `1.4.3` -> `1.4.4` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.truth:truth/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.truth:truth/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.truth:truth/1.4.3/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.truth:truth/1.4.3/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
---
### Release Notes
<details>
<summary>google/truth (com.google.truth:truth)</summary>
### [`v1.4.4`](https://togithub.com/google/truth/releases/tag/v1.4.4)
[Compare Source](https://togithub.com/google/truth/compare/v1.4.3...v1.4.4)
- Annotated the rest of the main package for nullness, and moved the `@NullMarked` annotation from individual classes up to the package to avoid [a warning under `--release 8`](https://togithub.com/google/truth/issues/1320). ([`e107aea`](https://togithub.com/google/truth/commit/e107aeadc))
- Improved the failure message for `matches` to conditionally suggest using `containsMatch`. ([`7e9fc7a`](https://togithub.com/google/truth/commit/7e9fc7aec))
</details>
---
### Configuration
📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/googleapis/java-bigtable).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@droazen@lbergelson@pshapiro4broad@coveralls@michaelbausor@googlebot