Skip to content

Integer Overflow In BaseWriteChannel #1389

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

Closed
Dima1224 opened this issue Nov 10, 2016 · 7 comments · Fixed by #1390
Closed

Integer Overflow In BaseWriteChannel #1389

Dima1224 opened this issue Nov 10, 2016 · 7 comments · Fixed by #1390
Assignees
Labels
api: storage Issues related to the Cloud Storage API.

Comments

@Dima1224
Copy link

Hi there. I'm testing out com.google.cloud.storage.Storage.writer() for writing to GCS. It works very well for files smaller than 2GB, but right around the 2GB mark WriteChannel throws an exception indicating that there's something wrong with the Content-Range header.

com.google.api.client.http.HttpResponseException: 400|Failed to parse Content-Range header.

I noticed that the Content-Range header is set in com.google.cloud.storage.spi.DefaultStorageRpc.write() and is calculated using com.google.cloud.BaseWriteChannel.position, which is an int. The problem is that at the 2GB mark the position variable overflows and becomes negative, causing panic and mayhem.

Here are some screenshots to paint a fuller picture:

trace1

trace2

Any chance we can get a patch for this? Should I submit a pull request?

@mziccard
Copy link
Contributor

mziccard commented Nov 10, 2016

Uh very sorry for the panic and mayhem. I believe we have fixed an analogous issue for the reader and this was left behind.

A PR would be awesome, it should be as simple as making position in BaseWriteChannel a long and changing the two getters position() and getPosition() to long as well. Let me know if you can make it, otherwise I'll kick one out ASAP.

@mziccard mziccard added the api: storage Issues related to the Cloud Storage API. label Nov 10, 2016
@Dima1224
Copy link
Author

Can I ask you to do it? I don't have the code base checked out, was debugging against the sources jar.

@mziccard
Copy link
Contributor

Can I ask you to do it?

This is kind of my job so I'll be more than happy :D

@Dima1224
Copy link
Author

Looks like I'm talking to the right guy :)

@Dima1224
Copy link
Author

Thanks! Any idea when the fix will be released?

@mziccard
Copy link
Contributor

@Dima1224 Beginning of next week the latest!

@Dima1224
Copy link
Author

Thanks for the lightning fast turnaround once again, @mziccard! Much appreciated.

github-actions bot pushed a commit that referenced this issue Jun 21, 2022
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 454027580

Source-Link: googleapis/googleapis@1b22277

Source-Link: https://github.com/googleapis/googleapis-gen/commit/e04cea20d0d12eb5c3bdb360a9e72b654edcb638
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTA0Y2VhMjBkMGQxMmViNWMzYmRiMzYwYTllNzJiNjU0ZWRjYjYzOCJ9
github-actions bot pushed a commit to yoshi-code-bot/google-cloud-java that referenced this issue Oct 6, 2022
… v3.7.0 (googleapis#1389)

[![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.cloud:google-cloud-asset](https://togithub.com/googleapis/java-asset) | `3.6.0` -> `3.7.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-asset/3.7.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-asset/3.7.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-asset/3.7.0/compatibility-slim/3.6.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-asset/3.7.0/confidence-slim/3.6.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### 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**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-asset).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMTQuMCIsInVwZGF0ZWRJblZlciI6IjMyLjIxNC4wIn0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants